diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn index 82177ad26c..b79e0de6f4 100644 --- a/modules/video_coding/BUILD.gn +++ b/modules/video_coding/BUILD.gn @@ -288,7 +288,9 @@ rtc_library("video_codec_interface") { ] deps = [ ":codec_globals_headers", + "../../api/units:time_delta", "../../api/video:video_frame", + "../../api/video:video_frame_type", "../../api/video:video_rtp_headers", "../../api/video_codecs:scalability_mode", "../../api/video_codecs:video_codecs_api", diff --git a/modules/video_coding/generic_decoder.cc b/modules/video_coding/generic_decoder.cc index 1f2c6004e8..1568c29e7f 100644 --- a/modules/video_coding/generic_decoder.cc +++ b/modules/video_coding/generic_decoder.cc @@ -220,9 +220,11 @@ void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, decodedImage.set_timestamp_us( frame_info->render_time ? frame_info->render_time->us() : -1); - _receiveCallback->FrameToRender(decodedImage, qp, decode_time, - frame_info->content_type, - frame_info->frame_type); + _receiveCallback->FrameToRender({.video_frame = decodedImage, + .qp = qp, + .decode_time = decode_time, + .content_type = frame_info->content_type, + .frame_type = frame_info->frame_type}); } void VCMDecodedFrameCallback::OnDecoderInfoChanged( diff --git a/modules/video_coding/generic_decoder_unittest.cc b/modules/video_coding/generic_decoder_unittest.cc index 7edc961a9d..fef8083a70 100644 --- a/modules/video_coding/generic_decoder_unittest.cc +++ b/modules/video_coding/generic_decoder_unittest.cc @@ -17,6 +17,10 @@ #include "api/array_view.h" #include "api/rtp_packet_infos.h" +#include "api/units/time_delta.h" +#include "api/video/video_content_type.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" #include "api/video_codecs/video_decoder.h" #include "common_video/test/utilities.h" #include "modules/video_coding/timing/timing.h" @@ -37,7 +41,15 @@ class ReceiveCallback : public VCMReceiveCallback { TimeDelta decode_time, VideoContentType content_type, VideoFrameType frame_type) override { - frames_.push_back(frame); + return FrameToRender({.video_frame = frame, + .qp = qp, + .decode_time = decode_time, + .content_type = content_type, + .frame_type = frame_type}); + } + + int32_t FrameToRender(const struct FrameToRender& arguments) override { + frames_.push_back(arguments.video_frame); return 0; } diff --git a/modules/video_coding/include/video_coding_defines.h b/modules/video_coding/include/video_coding_defines.h index 4821d5e973..eb8e728598 100644 --- a/modules/video_coding/include/video_coding_defines.h +++ b/modules/video_coding/include/video_coding_defines.h @@ -16,8 +16,10 @@ #include +#include "api/units/time_delta.h" #include "api/video/video_content_type.h" #include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" #include "api/video/video_timing.h" #include "api/video_codecs/video_decoder.h" @@ -51,11 +53,25 @@ enum VCMVideoProtection { // rendered. class VCMReceiveCallback { public: + struct FrameToRender { + VideoFrame& video_frame; + std::optional qp; + TimeDelta decode_time; + VideoContentType content_type; + VideoFrameType frame_type; + }; + + // TODO: bugs.webrtc.org/358039777 - Delete this function. + [[deprecated("Use FrameToRender(FrameToRender) instead.")]] virtual int32_t FrameToRender(VideoFrame& videoFrame, // NOLINT std::optional qp, TimeDelta decode_time, VideoContentType content_type, VideoFrameType frame_type) = 0; + // TODO: bugs.webrtc.org/358039777 - Make this pure virtual. + virtual int32_t FrameToRender(const struct FrameToRender& arguments) { + return 0; + } virtual void OnDroppedFrames(uint32_t frames_dropped); diff --git a/modules/video_coding/video_receiver2_unittest.cc b/modules/video_coding/video_receiver2_unittest.cc index 48ae8afa04..8cdd8abab5 100644 --- a/modules/video_coding/video_receiver2_unittest.cc +++ b/modules/video_coding/video_receiver2_unittest.cc @@ -10,12 +10,18 @@ #include "modules/video_coding/video_receiver2.h" +#include #include +#include #include #include "api/test/mock_video_decoder.h" +#include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "api/video/encoded_frame.h" +#include "api/video/video_content_type.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" #include "common_video/test/utilities.h" #include "modules/video_coding/decoder_database.h" #include "modules/video_coding/timing/timing.h" @@ -43,6 +49,10 @@ class MockVCMReceiveCallback : public VCMReceiveCallback { VideoContentType, VideoFrameType), (override)); + MOCK_METHOD(int32_t, + FrameToRender, + (const struct FrameToRender&), + (override)); MOCK_METHOD(void, OnIncomingPayloadType, (int), (override)); MOCK_METHOD(void, OnDecoderInfoChanged, diff --git a/modules/video_coding/video_receiver_unittest.cc b/modules/video_coding/video_receiver_unittest.cc index 7a048269fb..7e21a5c4da 100644 --- a/modules/video_coding/video_receiver_unittest.cc +++ b/modules/video_coding/video_receiver_unittest.cc @@ -8,12 +8,20 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include + #include "api/test/mock_video_decoder.h" +#include "api/units/time_delta.h" +#include "api/video/video_content_type.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" #include "api/video_codecs/video_decoder.h" #include "modules/video_coding/include/video_coding.h" #include "modules/video_coding/timing/timing.h" #include "modules/video_coding/video_coding_impl.h" #include "system_wrappers/include/clock.h" +#include "test/gmock.h" #include "test/gtest.h" #include "test/scoped_key_value_config.h" @@ -46,6 +54,10 @@ class MockVCMReceiveCallback : public VCMReceiveCallback { VideoContentType, VideoFrameType), (override)); + MOCK_METHOD(int32_t, + FrameToRender, + (const struct FrameToRender&), + (override)); MOCK_METHOD(void, OnIncomingPayloadType, (int), (override)); MOCK_METHOD(void, OnDecoderInfoChanged, diff --git a/video/video_stream_decoder2.cc b/video/video_stream_decoder2.cc index df4f353068..1f5ef42fcf 100644 --- a/video/video_stream_decoder2.cc +++ b/video/video_stream_decoder2.cc @@ -10,6 +10,13 @@ #include "video/video_stream_decoder2.h" +#include +#include + +#include "api/units/time_delta.h" +#include "api/video/video_content_type.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" #include "api/video_codecs/video_decoder.h" #include "modules/video_coding/video_receiver2.h" #include "rtc_base/checks.h" @@ -48,9 +55,18 @@ int32_t VideoStreamDecoder::FrameToRender(VideoFrame& video_frame, TimeDelta decode_time, VideoContentType content_type, VideoFrameType frame_type) { - receive_stats_callback_->OnDecodedFrame(video_frame, qp, decode_time, - content_type, frame_type); - incoming_video_stream_->OnFrame(video_frame); + return FrameToRender({.video_frame = video_frame, + .qp = qp, + .decode_time = decode_time, + .content_type = content_type, + .frame_type = frame_type}); +} +int32_t VideoStreamDecoder::FrameToRender( + const struct FrameToRender& arguments) { + receive_stats_callback_->OnDecodedFrame( + arguments.video_frame, arguments.qp, arguments.decode_time, + arguments.content_type, arguments.frame_type); + incoming_video_stream_->OnFrame(arguments.video_frame); return 0; } diff --git a/video/video_stream_decoder2.h b/video/video_stream_decoder2.h index 7847025f0b..8a89e32ae7 100644 --- a/video/video_stream_decoder2.h +++ b/video/video_stream_decoder2.h @@ -11,12 +11,18 @@ #ifndef VIDEO_VIDEO_STREAM_DECODER2_H_ #define VIDEO_VIDEO_STREAM_DECODER2_H_ +#include #include #include #include +#include #include #include "api/scoped_refptr.h" +#include "api/units/time_delta.h" +#include "api/video/video_content_type.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" #include "api/video/video_sink_interface.h" #include "api/video_codecs/video_decoder.h" #include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" @@ -45,6 +51,7 @@ class VideoStreamDecoder : public VCMReceiveCallback { TimeDelta decode_time, VideoContentType content_type, VideoFrameType frame_type) override; + int32_t FrameToRender(const struct FrameToRender& arguments) override; void OnDroppedFrames(uint32_t frames_dropped) override; void OnIncomingPayloadType(int payload_type) override; void OnDecoderInfoChanged(