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 25 matching lines...) Expand all Loading... | |
36 _receiveStatsCallback(NULL), | 36 _receiveStatsCallback(NULL), |
37 _decoderTimingCallback(NULL), | 37 _decoderTimingCallback(NULL), |
38 _packetRequestCallback(NULL), | 38 _packetRequestCallback(NULL), |
39 render_buffer_callback_(NULL), | 39 render_buffer_callback_(NULL), |
40 _decoder(NULL), | 40 _decoder(NULL), |
41 #ifdef DEBUG_DECODER_BIT_STREAM | 41 #ifdef DEBUG_DECODER_BIT_STREAM |
42 _bitStreamBeforeDecoder(NULL), | 42 _bitStreamBeforeDecoder(NULL), |
43 #endif | 43 #endif |
44 _frameFromFile(), | 44 _frameFromFile(), |
45 _scheduleKeyRequest(false), | 45 _scheduleKeyRequest(false), |
46 drop_frames_until_keyframe_(false), | |
46 max_nack_list_size_(0), | 47 max_nack_list_size_(0), |
48 _codecDataBase(nullptr, nullptr), | |
47 pre_decode_image_callback_(NULL), | 49 pre_decode_image_callback_(NULL), |
48 _codecDataBase(nullptr, nullptr), | |
49 _receiveStatsTimer(1000, clock_), | 50 _receiveStatsTimer(1000, clock_), |
50 _retransmissionTimer(10, clock_), | 51 _retransmissionTimer(10, clock_), |
51 _keyRequestTimer(500, clock_) { | 52 _keyRequestTimer(500, clock_) { |
52 assert(clock_); | 53 assert(clock_); |
53 #ifdef DEBUG_DECODER_BIT_STREAM | 54 #ifdef DEBUG_DECODER_BIT_STREAM |
54 _bitStreamBeforeDecoder = fopen("decoderBitStream.bit", "wb"); | 55 _bitStreamBeforeDecoder = fopen("decoderBitStream.bit", "wb"); |
55 #endif | 56 #endif |
56 } | 57 } |
57 | 58 |
58 VideoReceiver::~VideoReceiver() { | 59 VideoReceiver::~VideoReceiver() { |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 CriticalSectionScoped cs(_receiveCritSect); | 276 CriticalSectionScoped cs(_receiveCritSect); |
276 prefer_late_decoding = _codecDataBase.PrefersLateDecoding(); | 277 prefer_late_decoding = _codecDataBase.PrefersLateDecoding(); |
277 } | 278 } |
278 | 279 |
279 VCMEncodedFrame* frame = _receiver.FrameForDecoding( | 280 VCMEncodedFrame* frame = _receiver.FrameForDecoding( |
280 maxWaitTimeMs, &nextRenderTimeMs, prefer_late_decoding); | 281 maxWaitTimeMs, &nextRenderTimeMs, prefer_late_decoding); |
281 | 282 |
282 if (!frame) | 283 if (!frame) |
283 return VCM_FRAME_NOT_READY; | 284 return VCM_FRAME_NOT_READY; |
284 | 285 |
286 { | |
287 CriticalSectionScoped cs(process_crit_sect_.get()); | |
288 if (drop_frames_until_keyframe_) { | |
289 // Still getting delta frames, schedule another keyframe request as if | |
290 // decode failed. | |
291 if (frame->FrameType() != kVideoFrameKey) { | |
292 _scheduleKeyRequest = true; | |
293 _receiver.ReleaseFrame(frame); | |
294 return VCM_FRAME_NOT_READY; | |
295 } | |
296 drop_frames_until_keyframe_ = false; | |
297 } | |
298 } | |
stefan-webrtc
2016/02/01 16:23:08
Should we instead make sure the jitter buffer does
pbos-webrtc
2016/02/02 13:25:12
Not obvious to me how to make the jitter buffer co
| |
285 CriticalSectionScoped cs(_receiveCritSect); | 299 CriticalSectionScoped cs(_receiveCritSect); |
286 | 300 |
287 // If this frame was too late, we should adjust the delay accordingly | 301 // If this frame was too late, we should adjust the delay accordingly |
288 _timing.UpdateCurrentDelay(frame->RenderTimeMs(), | 302 _timing.UpdateCurrentDelay(frame->RenderTimeMs(), |
289 clock_->TimeInMilliseconds()); | 303 clock_->TimeInMilliseconds()); |
290 | 304 |
291 if (pre_decode_image_callback_) { | 305 if (pre_decode_image_callback_) { |
292 EncodedImage encoded_image(frame->EncodedImage()); | 306 EncodedImage encoded_image(frame->EncodedImage()); |
293 int qp = -1; | 307 int qp = -1; |
294 if (qp_parser_.GetQp(*frame, &qp)) { | 308 if (qp_parser_.GetQp(*frame, &qp)) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 ret = VCM_OK; | 387 ret = VCM_OK; |
374 } | 388 } |
375 if (request_key_frame) { | 389 if (request_key_frame) { |
376 CriticalSectionScoped cs(process_crit_sect_.get()); | 390 CriticalSectionScoped cs(process_crit_sect_.get()); |
377 _scheduleKeyRequest = true; | 391 _scheduleKeyRequest = true; |
378 } | 392 } |
379 TRACE_EVENT_ASYNC_END0("webrtc", "Video", frame.TimeStamp()); | 393 TRACE_EVENT_ASYNC_END0("webrtc", "Video", frame.TimeStamp()); |
380 return ret; | 394 return ret; |
381 } | 395 } |
382 | 396 |
383 // Reset the decoder state | |
384 int32_t VideoReceiver::ResetDecoder() { | |
385 bool reset_key_request = false; | |
386 { | |
387 CriticalSectionScoped cs(_receiveCritSect); | |
388 if (_decoder != NULL) { | |
389 _receiver.Reset(); | |
390 _timing.Reset(); | |
391 reset_key_request = true; | |
392 _decoder->Reset(); | |
393 } | |
394 } | |
395 if (reset_key_request) { | |
396 CriticalSectionScoped cs(process_crit_sect_.get()); | |
397 _scheduleKeyRequest = false; | |
398 } | |
399 return VCM_OK; | |
400 } | |
401 | |
402 // Register possible receive codecs, can be called multiple times | 397 // Register possible receive codecs, can be called multiple times |
403 int32_t VideoReceiver::RegisterReceiveCodec(const VideoCodec* receiveCodec, | 398 int32_t VideoReceiver::RegisterReceiveCodec(const VideoCodec* receiveCodec, |
404 int32_t numberOfCores, | 399 int32_t numberOfCores, |
405 bool requireKeyFrame) { | 400 bool requireKeyFrame) { |
406 CriticalSectionScoped cs(_receiveCritSect); | 401 CriticalSectionScoped cs(_receiveCritSect); |
407 if (receiveCodec == NULL) { | 402 if (receiveCodec == NULL) { |
408 return VCM_PARAMETER_ERROR; | 403 return VCM_PARAMETER_ERROR; |
409 } | 404 } |
410 if (!_codecDataBase.RegisterReceiveCodec(receiveCodec, numberOfCores, | 405 if (!_codecDataBase.RegisterReceiveCodec(receiveCodec, numberOfCores, |
411 requireKeyFrame)) { | 406 requireKeyFrame)) { |
(...skipping 30 matching lines...) Expand all Loading... | |
442 // without payload. | 437 // without payload. |
443 // TODO(holmer): We should fix this in the jitter buffer. | 438 // TODO(holmer): We should fix this in the jitter buffer. |
444 payloadLength = 0; | 439 payloadLength = 0; |
445 } | 440 } |
446 const VCMPacket packet(incomingPayload, payloadLength, rtpInfo); | 441 const VCMPacket packet(incomingPayload, payloadLength, rtpInfo); |
447 int32_t ret = _receiver.InsertPacket(packet, rtpInfo.type.Video.width, | 442 int32_t ret = _receiver.InsertPacket(packet, rtpInfo.type.Video.width, |
448 rtpInfo.type.Video.height); | 443 rtpInfo.type.Video.height); |
449 // TODO(holmer): Investigate if this somehow should use the key frame | 444 // TODO(holmer): Investigate if this somehow should use the key frame |
450 // request scheduling to throttle the requests. | 445 // request scheduling to throttle the requests. |
451 if (ret == VCM_FLUSH_INDICATOR) { | 446 if (ret == VCM_FLUSH_INDICATOR) { |
447 { | |
448 CriticalSectionScoped process_cs(process_crit_sect_.get()); | |
449 drop_frames_until_keyframe_ = true; | |
450 } | |
452 RequestKeyFrame(); | 451 RequestKeyFrame(); |
453 ResetDecoder(); | |
454 } else if (ret < 0) { | 452 } else if (ret < 0) { |
455 return ret; | 453 return ret; |
456 } | 454 } |
457 return VCM_OK; | 455 return VCM_OK; |
458 } | 456 } |
459 | 457 |
460 // Minimum playout delay (used for lip-sync). This is the minimum delay required | 458 // Minimum playout delay (used for lip-sync). This is the minimum delay required |
461 // to sync with audio. Not included in VideoCodingModule::Delay() | 459 // to sync with audio. Not included in VideoCodingModule::Delay() |
462 // Defaults to 0 ms. | 460 // Defaults to 0 ms. |
463 int32_t VideoReceiver::SetMinimumPlayoutDelay(uint32_t minPlayoutDelayMs) { | 461 int32_t VideoReceiver::SetMinimumPlayoutDelay(uint32_t minPlayoutDelayMs) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
540 } | 538 } |
541 | 539 |
542 void VideoReceiver::RegisterPreDecodeImageCallback( | 540 void VideoReceiver::RegisterPreDecodeImageCallback( |
543 EncodedImageCallback* observer) { | 541 EncodedImageCallback* observer) { |
544 CriticalSectionScoped cs(_receiveCritSect); | 542 CriticalSectionScoped cs(_receiveCritSect); |
545 pre_decode_image_callback_ = observer; | 543 pre_decode_image_callback_ = observer; |
546 } | 544 } |
547 | 545 |
548 } // namespace vcm | 546 } // namespace vcm |
549 } // namespace webrtc | 547 } // namespace webrtc |
OLD | NEW |