fix rtx payload type remapping issue

If we reference a remote codec that was offered without rtx we need
to change the reference of our local rtx codec in a reoffer.
This only happens with stopped transceivers.

BUG=chromium:1201441

Change-Id: I60dc4908ba7ba2c0249a2a05b03a7b35af504e18
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/238382
Commit-Queue: Philipp Hancke <philipp.hancke@googlemail.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35487}
This commit is contained in:
Philipp Hancke
2021-11-18 18:27:12 +01:00
committed by WebRTC LUCI CQ
parent a2e3d80cf6
commit 16dae2062f
2 changed files with 72 additions and 0 deletions

View File

@ -2381,6 +2381,22 @@ bool MediaSessionDescriptionFactory::AddVideoContentForOffer(
filtered_codecs, codec, nullptr)) {
// Use the `found_codec` from `video_codecs` because it has the
// correctly mapped payload type.
if (IsRtxCodec(codec)) {
// For RTX we might need to adjust the apt parameter if we got a
// remote offer without RTX for a codec for which we support RTX.
auto referenced_codec =
GetAssociatedCodecForRtx(supported_video_codecs, codec);
RTC_DCHECK(referenced_codec);
// Find the codec we should be referencing and point to it.
VideoCodec changed_referenced_codec;
if (FindMatchingCodec<VideoCodec>(supported_video_codecs,
filtered_codecs, *referenced_codec,
&changed_referenced_codec)) {
found_codec.SetParam(kCodecParamAssociatedPayloadType,
changed_referenced_codec.id);
}
}
filtered_codecs.push_back(found_codec);
}
}

View File

@ -1266,4 +1266,60 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest,
callee->observer()->latest_negotiation_needed_event()));
}
TEST_F(PeerConnectionSignalingUnifiedPlanTest, RtxReofferApt) {
auto callee = CreatePeerConnection();
std::string sdp =
"v=0\r\n"
"o=- 8403615332048243445 2 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
"t=0 0\r\n"
"m=video 9 UDP/TLS/RTP/SAVPF 102\r\n"
"c=IN IP4 0.0.0.0\r\n"
"a=rtcp:9 IN IP4 0.0.0.0\r\n"
"a=ice-ufrag:IZeV\r\n"
"a=ice-pwd:uaZhQD4rYM/Tta2qWBT1Bbt4\r\n"
"a=ice-options:trickle\r\n"
"a=fingerprint:sha-256 "
"D8:6C:3D:FA:23:E2:2C:63:11:2D:D0:86:BE:C4:D0:65:F9:42:F7:1C:06:04:27:E6:"
"1C:2C:74:01:8D:50:67:23\r\n"
"a=setup:actpass\r\n"
"a=mid:0\r\n"
"a=sendrecv\r\n"
"a=msid:stream track\r\n"
"a=rtcp-mux\r\n"
"a=rtcp-rsize\r\n"
"a=rtpmap:102 VP8/90000\r\n"
"a=rtcp-fb:102 goog-remb\r\n"
"a=rtcp-fb:102 transport-cc\r\n"
"a=rtcp-fb:102 ccm fir\r\n"
"a=rtcp-fb:102 nack\r\n"
"a=rtcp-fb:102 nack pli\r\n"
"a=ssrc:1224551896 cname:/exJcmhSLpyu9FgV\r\n";
std::unique_ptr<webrtc::SessionDescriptionInterface> remote_description =
webrtc::CreateSessionDescription(SdpType::kOffer, sdp, nullptr);
EXPECT_TRUE(callee->SetRemoteDescription(std::move(remote_description)));
auto answer = callee->CreateAnswer(RTCOfferAnswerOptions());
EXPECT_TRUE(
callee->SetLocalDescription(CloneSessionDescription(answer.get())));
callee->pc()->GetTransceivers()[0]->Stop();
auto reoffer = callee->CreateOffer(RTCOfferAnswerOptions());
auto codecs = reoffer->description()
->contents()[0]
.media_description()
->as_video()
->codecs();
ASSERT_GT(codecs.size(), 2u);
EXPECT_EQ(codecs[0].name, "VP8");
EXPECT_EQ(codecs[1].name, "rtx");
auto apt_it = codecs[1].params.find("apt");
ASSERT_NE(apt_it, codecs[1].params.end());
// The apt should match the id from the remote offer.
EXPECT_EQ(apt_it->second, rtc::ToString(codecs[0].id));
EXPECT_EQ(apt_it->second, "102");
}
} // namespace webrtc