diff --git a/modules/video_coding/codecs/test/videoprocessor.cc b/modules/video_coding/codecs/test/videoprocessor.cc index 98ba07f764..0cf2fa0808 100644 --- a/modules/video_coding/codecs/test/videoprocessor.cc +++ b/modules/video_coding/codecs/test/videoprocessor.cc @@ -310,6 +310,25 @@ void VideoProcessor::SetRates(size_t bitrate_kbps, size_t framerate_fps) { << "Failed to update encoder with new rate " << bitrate_kbps << "."; } +int32_t VideoProcessor::VideoProcessorDecodeCompleteCallback::Decoded( + VideoFrame& image) { + // Post the callback to the right task queue, if needed. + if (!task_queue_->IsCurrent()) { + // There might be a limited amount of output buffers, make a copy to make + // sure we don't block the decoder. + VideoFrame copy(I420Buffer::Copy(*image.video_frame_buffer()->ToI420()), + image.rotation(), image.timestamp_us()); + copy.set_timestamp(image.timestamp()); + + task_queue_->PostTask([this, copy]() { + video_processor_->FrameDecoded(copy, simulcast_svc_idx_); + }); + return 0; + } + video_processor_->FrameDecoded(image, simulcast_svc_idx_); + return 0; +} + void VideoProcessor::FrameEncoded( const webrtc::EncodedImage& encoded_image, const webrtc::CodecSpecificInfo& codec_specific) { diff --git a/modules/video_coding/codecs/test/videoprocessor.h b/modules/video_coding/codecs/test/videoprocessor.h index d44ee1fc39..f3808f88c1 100644 --- a/modules/video_coding/codecs/test/videoprocessor.h +++ b/modules/video_coding/codecs/test/videoprocessor.h @@ -133,17 +133,7 @@ class VideoProcessor { RTC_DCHECK(task_queue_); } - int32_t Decoded(webrtc::VideoFrame& image) override { - // Post the callback to the right task queue, if needed. - if (!task_queue_->IsCurrent()) { - task_queue_->PostTask([this, image]() { - video_processor_->FrameDecoded(image, simulcast_svc_idx_); - }); - return 0; - } - video_processor_->FrameDecoded(image, simulcast_svc_idx_); - return 0; - } + int32_t Decoded(webrtc::VideoFrame& image) override; int32_t Decoded(webrtc::VideoFrame& image, int64_t decode_time_ms) override {