From 1c951ecb32d78078573d59717ef33f7da840b69d Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Wed, 25 May 2022 10:44:22 +0200 Subject: [PATCH] video_replay: add flexfec support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit which is useful for validating flexfec recovers frames correctly. This can be tested by passing a keyframe covered by flexfec along with the fec packets and removing one packet from the frame. BUG=None Change-Id: Icd73eca138f62b9387bf850a6efbd7db03b4b569 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261956 Reviewed-by: Björn Terelius Commit-Queue: Harald Alvestrand Reviewed-by: Mirko Bonadei Reviewed-by: Rasmus Brandt Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#37392} --- call/video_receive_stream.h | 2 +- rtc_tools/video_replay.cc | 39 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h index 714d8e4293..0d3f2a628f 100644 --- a/call/video_receive_stream.h +++ b/call/video_receive_stream.h @@ -213,7 +213,7 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface { // Set if the stream is protected using FlexFEC. bool protected_by_flexfec = false; - // Optional callback sink to support additional packet handlsers such as + // Optional callback sink to support additional packet handlers such as // FlexFec. RtpPacketSinkInterface* packet_sink_ = nullptr; diff --git a/rtc_tools/video_replay.cc b/rtc_tools/video_replay.cc index 416da72885..346d962685 100644 --- a/rtc_tools/video_replay.cc +++ b/rtc_tools/video_replay.cc @@ -64,6 +64,12 @@ ABSL_FLAG(int, webrtc::test::CallTest::kUlpfecPayloadType, "ULPFEC payload type"); +// Flag for FLEXFEC payload type. +ABSL_FLAG(int, + flexfec_payload_type, + webrtc::test::CallTest::kFlexfecPayloadType, + "FLEXFEC payload type"); + ABSL_FLAG(int, media_payload_type_rtx, webrtc::test::CallTest::kSendRtxPayloadType, @@ -84,6 +90,11 @@ ABSL_FLAG(uint32_t, webrtc::test::CallTest::kSendRtxSsrcs[0], "Incoming RTX SSRC"); +ABSL_FLAG(uint32_t, + ssrc_flexfec, + webrtc::test::CallTest::kFlexfecSendSsrc, + "Incoming FLEXFEC SSRC"); + // Flag for abs-send-time id. ABSL_FLAG(int, abs_send_time_id, -1, "RTP extension ID for abs-send-time"); @@ -160,6 +171,10 @@ static int UlpfecPayloadType() { return absl::GetFlag(FLAGS_ulpfec_payload_type); } +static int FlexfecPayloadType() { + return absl::GetFlag(FLAGS_flexfec_payload_type); +} + static int MediaPayloadTypeRtx() { return absl::GetFlag(FLAGS_media_payload_type_rtx); } @@ -176,6 +191,10 @@ static uint32_t SsrcRtx() { return absl::GetFlag(FLAGS_ssrc_rtx); } +static uint32_t SsrcFlexfec() { + return absl::GetFlag(FLAGS_ssrc_flexfec); +} + static int AbsSendTimeId() { return absl::GetFlag(FLAGS_abs_send_time_id); } @@ -377,6 +396,9 @@ class RtpReplayer final { for (const auto& receive_stream : stream_state->receive_streams) { call->DestroyVideoReceiveStream(receive_stream); } + for (const auto& flexfec_stream : stream_state->flexfec_streams) { + call->DestroyFlexfecReceiveStream(flexfec_stream); + } call.reset(); sync_event.Set(); })); @@ -391,6 +413,7 @@ class RtpReplayer final { test::NullTransport transport; std::vector>> sinks; std::vector receive_streams; + std::vector flexfec_streams; std::unique_ptr decoder_factory; }; @@ -469,6 +492,20 @@ class RtpReplayer final { receive_config.rtp.ulpfec_payload_type = UlpfecPayloadType(); receive_config.rtp.red_payload_type = RedPayloadType(); receive_config.rtp.nack.rtp_history_ms = 1000; + + if (FlexfecPayloadType() != -1) { + receive_config.rtp.protected_by_flexfec = true; + webrtc::FlexfecReceiveStream::Config flexfec_config( + &(stream_state->transport)); + flexfec_config.payload_type = FlexfecPayloadType(); + flexfec_config.protected_media_ssrcs.push_back(Ssrc()); + flexfec_config.rtp.remote_ssrc = SsrcFlexfec(); + FlexfecReceiveStream* flexfec_stream = + call->CreateFlexfecReceiveStream(flexfec_config); + receive_config.rtp.packet_sink_ = flexfec_stream; + stream_state->flexfec_streams.push_back(flexfec_stream); + } + if (TransmissionOffsetId() != -1) { receive_config.rtp.extensions.push_back(RtpExtension( RtpExtension::kTimestampOffsetUri, TransmissionOffsetId())); @@ -622,6 +659,8 @@ int main(int argc, char* argv[]) { ValidateOptionalPayloadType(absl::GetFlag(FLAGS_red_payload_type_rtx))); RTC_CHECK( ValidateOptionalPayloadType(absl::GetFlag(FLAGS_ulpfec_payload_type))); + RTC_CHECK( + ValidateOptionalPayloadType(absl::GetFlag(FLAGS_flexfec_payload_type))); RTC_CHECK( ValidateRtpHeaderExtensionId(absl::GetFlag(FLAGS_abs_send_time_id))); RTC_CHECK(ValidateRtpHeaderExtensionId(