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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 return VCM_OK; | 228 return VCM_OK; |
229 } | 229 } |
230 | 230 |
231 int32_t VideoReceiver::RegisterDecoderTimingCallback( | 231 int32_t VideoReceiver::RegisterDecoderTimingCallback( |
232 VCMDecoderTimingCallback* decoderTiming) { | 232 VCMDecoderTimingCallback* decoderTiming) { |
233 CriticalSectionScoped cs(process_crit_sect_.get()); | 233 CriticalSectionScoped cs(process_crit_sect_.get()); |
234 _decoderTimingCallback = decoderTiming; | 234 _decoderTimingCallback = decoderTiming; |
235 return VCM_OK; | 235 return VCM_OK; |
236 } | 236 } |
237 | 237 |
238 // Register an externally defined decoder/render object. | 238 // Register an externally defined decoder object. |
239 // Can be a decoder only or a decoder coupled with a renderer. | |
240 void VideoReceiver::RegisterExternalDecoder(VideoDecoder* externalDecoder, | 239 void VideoReceiver::RegisterExternalDecoder(VideoDecoder* externalDecoder, |
241 uint8_t payloadType, | 240 uint8_t payloadType) { |
242 bool internalRenderTiming) { | |
243 CriticalSectionScoped cs(_receiveCritSect); | 241 CriticalSectionScoped cs(_receiveCritSect); |
244 if (externalDecoder == NULL) { | 242 if (externalDecoder == NULL) { |
245 // Make sure the VCM updates the decoder next time it decodes. | 243 // Make sure the VCM updates the decoder next time it decodes. |
246 _decoder = NULL; | 244 _decoder = NULL; |
247 RTC_CHECK(_codecDataBase.DeregisterExternalDecoder(payloadType)); | 245 RTC_CHECK(_codecDataBase.DeregisterExternalDecoder(payloadType)); |
248 return; | 246 return; |
249 } | 247 } |
250 _codecDataBase.RegisterExternalDecoder(externalDecoder, payloadType, | 248 _codecDataBase.RegisterExternalDecoder(externalDecoder, payloadType); |
251 internalRenderTiming); | 249 return; |
stefan-webrtc
2015/12/07 09:02:19
Remove
perkj_webrtc
2015/12/07 12:06:34
Done.
| |
252 } | 250 } |
253 | 251 |
254 // Register a frame type request callback. | 252 // Register a frame type request callback. |
255 int32_t VideoReceiver::RegisterFrameTypeCallback( | 253 int32_t VideoReceiver::RegisterFrameTypeCallback( |
256 VCMFrameTypeCallback* frameTypeCallback) { | 254 VCMFrameTypeCallback* frameTypeCallback) { |
257 CriticalSectionScoped cs(process_crit_sect_.get()); | 255 CriticalSectionScoped cs(process_crit_sect_.get()); |
258 _frameTypeCallback = frameTypeCallback; | 256 _frameTypeCallback = frameTypeCallback; |
259 return VCM_OK; | 257 return VCM_OK; |
260 } | 258 } |
261 | 259 |
(...skipping 12 matching lines...) Expand all Loading... | |
274 } | 272 } |
275 | 273 |
276 void VideoReceiver::TriggerDecoderShutdown() { | 274 void VideoReceiver::TriggerDecoderShutdown() { |
277 _receiver.TriggerDecoderShutdown(); | 275 _receiver.TriggerDecoderShutdown(); |
278 } | 276 } |
279 | 277 |
280 // Decode next frame, blocking. | 278 // Decode next frame, blocking. |
281 // Should be called as often as possible to get the most out of the decoder. | 279 // Should be called as often as possible to get the most out of the decoder. |
282 int32_t VideoReceiver::Decode(uint16_t maxWaitTimeMs) { | 280 int32_t VideoReceiver::Decode(uint16_t maxWaitTimeMs) { |
283 int64_t nextRenderTimeMs; | 281 int64_t nextRenderTimeMs; |
284 bool supports_render_scheduling; | 282 bool has_only_one_output_buffer = false; |
stefan-webrtc
2015/12/07 09:02:19
prefers_decode_late?
perkj_webrtc
2015/12/07 12:06:34
Done.
| |
285 { | 283 { |
286 CriticalSectionScoped cs(_receiveCritSect); | 284 CriticalSectionScoped cs(_receiveCritSect); |
287 supports_render_scheduling = _codecDataBase.SupportsRenderScheduling(); | 285 has_only_one_output_buffer = _codecDataBase.PreferDecodeLate(); |
288 } | 286 } |
289 | 287 |
290 VCMEncodedFrame* frame = _receiver.FrameForDecoding( | 288 VCMEncodedFrame* frame = _receiver.FrameForDecoding( |
291 maxWaitTimeMs, nextRenderTimeMs, supports_render_scheduling); | 289 maxWaitTimeMs, nextRenderTimeMs, has_only_one_output_buffer); |
292 | 290 |
293 if (frame == NULL) { | 291 if (frame == NULL) { |
294 return VCM_FRAME_NOT_READY; | 292 return VCM_FRAME_NOT_READY; |
295 } else { | 293 } else { |
296 CriticalSectionScoped cs(_receiveCritSect); | 294 CriticalSectionScoped cs(_receiveCritSect); |
297 | 295 |
298 // If this frame was too late, we should adjust the delay accordingly | 296 // If this frame was too late, we should adjust the delay accordingly |
299 _timing.UpdateCurrentDelay(frame->RenderTimeMs(), | 297 _timing.UpdateCurrentDelay(frame->RenderTimeMs(), |
300 clock_->TimeInMilliseconds()); | 298 clock_->TimeInMilliseconds()); |
301 | 299 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 | 360 |
363 // Must be called from inside the receive side critical section. | 361 // Must be called from inside the receive side critical section. |
364 int32_t VideoReceiver::Decode(const VCMEncodedFrame& frame) { | 362 int32_t VideoReceiver::Decode(const VCMEncodedFrame& frame) { |
365 TRACE_EVENT_ASYNC_STEP1("webrtc", | 363 TRACE_EVENT_ASYNC_STEP1("webrtc", |
366 "Video", | 364 "Video", |
367 frame.TimeStamp(), | 365 frame.TimeStamp(), |
368 "Decode", | 366 "Decode", |
369 "type", | 367 "type", |
370 frame.FrameType()); | 368 frame.FrameType()); |
371 // Change decoder if payload type has changed | 369 // Change decoder if payload type has changed |
372 const bool renderTimingBefore = _codecDataBase.SupportsRenderScheduling(); | 370 _decoder = |
373 _decoder = _codecDataBase.GetDecoder(frame, &_decodedFrameCallback); | 371 _codecDataBase.GetDecoder(frame, &_decodedFrameCallback); |
374 if (renderTimingBefore != _codecDataBase.SupportsRenderScheduling()) { | |
375 // Make sure we reset the decode time estimate since it will | |
376 // be zero for codecs without render timing. | |
377 _timing.ResetDecodeTime(); | |
378 } | |
379 if (_decoder == NULL) { | 372 if (_decoder == NULL) { |
380 return VCM_NO_CODEC_REGISTERED; | 373 return VCM_NO_CODEC_REGISTERED; |
381 } | 374 } |
382 // Decode a frame | 375 // Decode a frame |
383 int32_t ret = _decoder->Decode(frame, clock_->TimeInMilliseconds()); | 376 int32_t ret = _decoder->Decode(frame, clock_->TimeInMilliseconds()); |
384 | 377 |
385 // Check for failed decoding, run frame type request callback if needed. | 378 // Check for failed decoding, run frame type request callback if needed. |
386 bool request_key_frame = false; | 379 bool request_key_frame = false; |
387 if (ret < 0) { | 380 if (ret < 0) { |
388 if (ret == VCM_ERROR_REQUEST_SLI) { | 381 if (ret == VCM_ERROR_REQUEST_SLI) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 } | 560 } |
568 | 561 |
569 void VideoReceiver::RegisterPreDecodeImageCallback( | 562 void VideoReceiver::RegisterPreDecodeImageCallback( |
570 EncodedImageCallback* observer) { | 563 EncodedImageCallback* observer) { |
571 CriticalSectionScoped cs(_receiveCritSect); | 564 CriticalSectionScoped cs(_receiveCritSect); |
572 pre_decode_image_callback_ = observer; | 565 pre_decode_image_callback_ = observer; |
573 } | 566 } |
574 | 567 |
575 } // namespace vcm | 568 } // namespace vcm |
576 } // namespace webrtc | 569 } // namespace webrtc |
OLD | NEW |