Add RTP header extension API regression tests

which describe the existing behavior that necessitated the revert
  b396e2b159b060791954495d68278a55e8f72092

Also change the fake media engine audio clockrate to 8000 instead
of 0 and the fake media engine video payload type to something but
0 as this value seems to be treated specially by the video engine
and is a payload type reserved for PCMU.

BUG=chromium:1051821

Change-Id: Ib0a345d59baba50a565f01685d240e41584367e6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/299000
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39699}
This commit is contained in:
Philipp Hancke 2023-03-23 16:41:52 +01:00 committed by WebRTC LUCI CQ
parent 48476d84d5
commit f21cdb0afa
2 changed files with 134 additions and 7 deletions

View File

@ -444,7 +444,7 @@ void FakeVideoMediaChannel::GenerateSendKeyFrame(
FakeVoiceEngine::FakeVoiceEngine() : fail_create_channel_(false) {
// Add a fake audio codec. Note that the name must not be "" as there are
// sanity checks against that.
SetCodecs({AudioCodec(101, "fake_audio_codec", 0, 0, 1)});
SetCodecs({AudioCodec(101, "fake_audio_codec", 8000, 0, 1)});
}
void FakeVoiceEngine::Init() {}
rtc::scoped_refptr<webrtc::AudioState> FakeVoiceEngine::GetAudioState() const {
@ -544,8 +544,8 @@ FakeVideoEngine::FakeVideoEngine()
: capture_(false), fail_create_channel_(false) {
// Add a fake video codec. Note that the name must not be "" as there are
// sanity checks against that.
send_codecs_.push_back(VideoCodec(0, "fake_video_codec"));
recv_codecs_.push_back(VideoCodec(0, "fake_video_codec"));
send_codecs_.push_back(VideoCodec(111, "fake_video_codec"));
recv_codecs_.push_back(VideoCodec(111, "fake_video_codec"));
}
bool FakeVideoEngine::SetOptions(const VideoOptions& options) {
options_ = options;

View File

@ -288,16 +288,23 @@ TEST_P(PeerConnectionHeaderExtensionTest,
"A7:24:72:CA:6E:02:55:39:BA:66:DF:6E:CC:4C:D8:B0:1A:BF:1A:56:65:7D:F4:03:"
"AD:7E:77:43:2A:29:EC:93\r\n"
"a=ice-ufrag:6HHHdzzeIhkE0CKj\r\n"
"a=ice-pwd:XYDGVpfvklQIEnZ6YnyLsAew\r\n"
"m=audio 9 RTP/AVPF 111\r\n"
"a=ice-pwd:XYDGVpfvklQIEnZ6YnyLsAew\r\n";
if (media_type == cricket::MEDIA_TYPE_AUDIO) {
sdp +=
"m=audio 9 RTP/AVPF 111\r\n"
"a=rtpmap:111 fake_audio_codec/8000\r\n";
} else {
sdp +=
"m=video 9 RTP/AVPF 111\r\n"
"a=rtpmap:111 fake_video_codec/90000\r\n";
}
sdp +=
"c=IN IP4 0.0.0.0\r\n"
"a=rtcp-mux\r\n"
"a=sendonly\r\n"
"a=mid:audio\r\n"
"a=rtpmap:111 fake_audio_codec/0\r\n"
"a=setup:actpass\r\n"
"a=extmap:1 urn:bogus\r\n";
RTC_LOG(LS_ERROR) << sdp;
auto offer = CreateSessionDescription(SdpType::kOffer, sdp);
pc->SetRemoteDescription(std::move(offer));
pc->CreateAnswerAndSetAsLocal(
@ -314,6 +321,126 @@ TEST_P(PeerConnectionHeaderExtensionTest,
}
}
// This test is a regression test for behavior that the API
// enables in a proper way. It conflicts with the behavior
// of the API to only offer non-stopped extensions.
TEST_P(PeerConnectionHeaderExtensionTest,
SdpMungingWithoutApiUsageEnablesExtensions) {
cricket::MediaType media_type;
SdpSemantics semantics;
std::tie(media_type, semantics) = GetParam();
if (semantics != SdpSemantics::kUnifiedPlan)
return;
std::unique_ptr<PeerConnectionWrapper> pc =
CreatePeerConnection(media_type, semantics);
std::string sdp =
"v=0\r\n"
"o=- 0 3 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
"t=0 0\r\n"
"a=fingerprint:sha-256 "
"A7:24:72:CA:6E:02:55:39:BA:66:DF:6E:CC:4C:D8:B0:1A:BF:1A:56:65:7D:F4:03:"
"AD:7E:77:43:2A:29:EC:93\r\n"
"a=ice-ufrag:6HHHdzzeIhkE0CKj\r\n"
"a=ice-pwd:XYDGVpfvklQIEnZ6YnyLsAew\r\n";
if (media_type == cricket::MEDIA_TYPE_AUDIO) {
sdp +=
"m=audio 9 RTP/AVPF 111\r\n"
"a=rtpmap:111 fake_audio_codec/8000\r\n";
} else {
sdp +=
"m=video 9 RTP/AVPF 111\r\n"
"a=rtpmap:111 fake_video_codec/90000\r\n";
}
sdp +=
"c=IN IP4 0.0.0.0\r\n"
"a=rtcp-mux\r\n"
"a=sendrecv\r\n"
"a=mid:audio\r\n"
"a=setup:actpass\r\n"
"a=extmap:1 uri1\r\n";
auto offer = CreateSessionDescription(SdpType::kOffer, sdp);
pc->SetRemoteDescription(std::move(offer));
auto answer =
pc->CreateAnswer(PeerConnectionInterface::RTCOfferAnswerOptions());
std::string modified_sdp;
ASSERT_TRUE(answer->ToString(&modified_sdp));
modified_sdp += "a=extmap:1 uri1\r\n";
auto modified_answer =
CreateSessionDescription(SdpType::kAnswer, modified_sdp);
ASSERT_TRUE(pc->SetLocalDescription(std::move(modified_answer)));
auto session_description = pc->CreateOffer();
ASSERT_TRUE(session_description->ToString(&sdp));
EXPECT_THAT(session_description->description()
->contents()[0]
.media_description()
->rtp_header_extensions(),
ElementsAre(Field(&RtpExtension::uri, "uri1"),
Field(&RtpExtension::uri, "uri2"),
Field(&RtpExtension::uri, "uri3"),
Field(&RtpExtension::uri, "uri4")));
}
TEST_P(PeerConnectionHeaderExtensionTest, EnablingExtensionsAfterRemoteOffer) {
cricket::MediaType media_type;
SdpSemantics semantics;
std::tie(media_type, semantics) = GetParam();
if (semantics != SdpSemantics::kUnifiedPlan)
return;
std::unique_ptr<PeerConnectionWrapper> pc =
CreatePeerConnection(media_type, semantics);
std::string sdp =
"v=0\r\n"
"o=- 0 3 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
"t=0 0\r\n"
"a=fingerprint:sha-256 "
"A7:24:72:CA:6E:02:55:39:BA:66:DF:6E:CC:4C:D8:B0:1A:BF:1A:56:65:7D:F4:03:"
"AD:7E:77:43:2A:29:EC:93\r\n"
"a=ice-ufrag:6HHHdzzeIhkE0CKj\r\n"
"a=ice-pwd:XYDGVpfvklQIEnZ6YnyLsAew\r\n";
if (media_type == cricket::MEDIA_TYPE_AUDIO) {
sdp +=
"m=audio 9 RTP/AVPF 111\r\n"
"a=rtpmap:111 fake_audio_codec/8000\r\n";
} else {
sdp +=
"m=video 9 RTP/AVPF 111\r\n"
"a=rtpmap:111 fake_video_codec/90000\r\n";
}
sdp +=
"c=IN IP4 0.0.0.0\r\n"
"a=rtcp-mux\r\n"
"a=sendrecv\r\n"
"a=mid:audio\r\n"
"a=setup:actpass\r\n"
"a=extmap:5 uri1\r\n";
auto offer = CreateSessionDescription(SdpType::kOffer, sdp);
pc->SetRemoteDescription(std::move(offer));
ASSERT_GT(pc->pc()->GetTransceivers().size(), 0u);
auto transceiver = pc->pc()->GetTransceivers()[0];
auto modified_extensions = transceiver->GetHeaderExtensionsToNegotiate();
modified_extensions[0].direction = RtpTransceiverDirection::kSendRecv;
transceiver->SetHeaderExtensionsToNegotiate(modified_extensions);
pc->CreateAnswerAndSetAsLocal(
PeerConnectionInterface::RTCOfferAnswerOptions());
auto session_description = pc->CreateOffer();
auto extensions = session_description->description()
->contents()[0]
.media_description()
->rtp_header_extensions();
EXPECT_THAT(extensions, ElementsAre(Field(&RtpExtension::uri, "uri1"),
Field(&RtpExtension::uri, "uri2"),
Field(&RtpExtension::uri, "uri3"),
Field(&RtpExtension::uri, "uri4")));
// Check uri1's id still matches the remote id.
EXPECT_EQ(extensions[0].id, 5);
}
INSTANTIATE_TEST_SUITE_P(
,
PeerConnectionHeaderExtensionTest,