| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 int64_t nextRenderTimeMs; | 280 int64_t nextRenderTimeMs; |
| 281 bool prefer_late_decoding = false; | 281 bool prefer_late_decoding = false; |
| 282 { | 282 { |
| 283 CriticalSectionScoped cs(_receiveCritSect); | 283 CriticalSectionScoped cs(_receiveCritSect); |
| 284 prefer_late_decoding = _codecDataBase.PrefersLateDecoding(); | 284 prefer_late_decoding = _codecDataBase.PrefersLateDecoding(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 VCMEncodedFrame* frame = _receiver.FrameForDecoding( | 287 VCMEncodedFrame* frame = _receiver.FrameForDecoding( |
| 288 maxWaitTimeMs, nextRenderTimeMs, prefer_late_decoding); | 288 maxWaitTimeMs, nextRenderTimeMs, prefer_late_decoding); |
| 289 | 289 |
| 290 if (frame == NULL) { | 290 if (!frame) |
| 291 return VCM_FRAME_NOT_READY; | 291 return VCM_FRAME_NOT_READY; |
| 292 } else { | |
| 293 CriticalSectionScoped cs(_receiveCritSect); | |
| 294 | 292 |
| 295 // If this frame was too late, we should adjust the delay accordingly | 293 CriticalSectionScoped cs(_receiveCritSect); |
| 296 _timing.UpdateCurrentDelay(frame->RenderTimeMs(), | |
| 297 clock_->TimeInMilliseconds()); | |
| 298 | 294 |
| 299 if (pre_decode_image_callback_) { | 295 // If this frame was too late, we should adjust the delay accordingly |
| 300 EncodedImage encoded_image(frame->EncodedImage()); | 296 _timing.UpdateCurrentDelay(frame->RenderTimeMs(), |
| 301 int qp = -1; | 297 clock_->TimeInMilliseconds()); |
| 302 if (qp_parser_.GetQp(*frame, &qp)) { | 298 |
| 303 encoded_image.qp_ = qp; | 299 if (pre_decode_image_callback_) { |
| 304 } | 300 EncodedImage encoded_image(frame->EncodedImage()); |
| 305 pre_decode_image_callback_->Encoded( | 301 int qp = -1; |
| 306 encoded_image, frame->CodecSpecific(), NULL); | 302 if (qp_parser_.GetQp(*frame, &qp)) { |
| 303 encoded_image.qp_ = qp; |
| 307 } | 304 } |
| 305 pre_decode_image_callback_->Encoded(encoded_image, frame->CodecSpecific(), |
| 306 NULL); |
| 307 } |
| 308 | 308 |
| 309 #ifdef DEBUG_DECODER_BIT_STREAM | 309 #ifdef DEBUG_DECODER_BIT_STREAM |
| 310 if (_bitStreamBeforeDecoder != NULL) { | 310 if (_bitStreamBeforeDecoder != NULL) { |
| 311 // Write bit stream to file for debugging purposes | 311 // Write bit stream to file for debugging purposes |
| 312 if (fwrite( | 312 if (fwrite(frame->Buffer(), 1, frame->Length(), _bitStreamBeforeDecoder) != |
| 313 frame->Buffer(), 1, frame->Length(), _bitStreamBeforeDecoder) != | 313 frame->Length()) { |
| 314 frame->Length()) { | 314 return -1; |
| 315 return -1; | |
| 316 } | |
| 317 } | |
| 318 #endif | |
| 319 const int32_t ret = Decode(*frame); | |
| 320 _receiver.ReleaseFrame(frame); | |
| 321 frame = NULL; | |
| 322 if (ret != VCM_OK) { | |
| 323 return ret; | |
| 324 } | 315 } |
| 325 } | 316 } |
| 326 return VCM_OK; | 317 #endif |
| 318 const int32_t ret = Decode(*frame); |
| 319 _receiver.ReleaseFrame(frame); |
| 320 return ret; |
| 327 } | 321 } |
| 328 | 322 |
| 329 int32_t VideoReceiver::RequestSliceLossIndication( | 323 int32_t VideoReceiver::RequestSliceLossIndication( |
| 330 const uint64_t pictureID) const { | 324 const uint64_t pictureID) const { |
| 331 TRACE_EVENT1("webrtc", "RequestSLI", "picture_id", pictureID); | 325 TRACE_EVENT1("webrtc", "RequestSLI", "picture_id", pictureID); |
| 332 CriticalSectionScoped cs(process_crit_sect_.get()); | 326 CriticalSectionScoped cs(process_crit_sect_.get()); |
| 333 if (_frameTypeCallback != NULL) { | 327 if (_frameTypeCallback != NULL) { |
| 334 const int32_t ret = | 328 const int32_t ret = |
| 335 _frameTypeCallback->SliceLossIndicationRequest(pictureID); | 329 _frameTypeCallback->SliceLossIndicationRequest(pictureID); |
| 336 if (ret < 0) { | 330 if (ret < 0) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 } | 552 } |
| 559 | 553 |
| 560 void VideoReceiver::RegisterPreDecodeImageCallback( | 554 void VideoReceiver::RegisterPreDecodeImageCallback( |
| 561 EncodedImageCallback* observer) { | 555 EncodedImageCallback* observer) { |
| 562 CriticalSectionScoped cs(_receiveCritSect); | 556 CriticalSectionScoped cs(_receiveCritSect); |
| 563 pre_decode_image_callback_ = observer; | 557 pre_decode_image_callback_ = observer; |
| 564 } | 558 } |
| 565 | 559 |
| 566 } // namespace vcm | 560 } // namespace vcm |
| 567 } // namespace webrtc | 561 } // namespace webrtc |
| OLD | NEW |