sdp: backfill default codec parameters for H264 and VP9
as preparation for H265 work. BUG=webrtc:15703 Change-Id: Ib6e0afa5ccbb8172a70d4e4eb876639559070fd6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/329981 Commit-Queue: Philipp Hancke <phancke@microsoft.com> Reviewed-by: Henrik Boström <hbos@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41350}
This commit is contained in:
parent
dfb54b5747
commit
cdd92da549
@ -2614,6 +2614,25 @@ void MaybeCreateStaticPayloadAudioCodecs(const std::vector<int>& fmts,
|
||||
}
|
||||
}
|
||||
|
||||
static void BackfillCodecParameters(std::vector<cricket::Codec>& codecs) {
|
||||
for (auto& codec : codecs) {
|
||||
std::string unused_value;
|
||||
if (absl::EqualsIgnoreCase(cricket::kVp9CodecName, codec.name)) {
|
||||
// https://datatracker.ietf.org/doc/html/draft-ietf-payload-vp9#section-6
|
||||
// profile-id defaults to "0"
|
||||
if (!codec.GetParam(cricket::kVP9ProfileId, &unused_value)) {
|
||||
codec.SetParam(cricket::kVP9ProfileId, "0");
|
||||
}
|
||||
} else if (absl::EqualsIgnoreCase(cricket::kH264CodecName, codec.name)) {
|
||||
// https://www.rfc-editor.org/rfc/rfc6184#section-6.2
|
||||
// packetization-mode defaults to "0"
|
||||
if (!codec.GetParam(cricket::kH264FmtpPacketizationMode, &unused_value)) {
|
||||
codec.SetParam(cricket::kH264FmtpPacketizationMode, "0");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static std::unique_ptr<MediaContentDescription> ParseContentDescription(
|
||||
absl::string_view message,
|
||||
const cricket::MediaType media_type,
|
||||
@ -2657,6 +2676,9 @@ static std::unique_ptr<MediaContentDescription> ParseContentDescription(
|
||||
const cricket::Codec& b) {
|
||||
return payload_type_preferences[a.id] > payload_type_preferences[b.id];
|
||||
});
|
||||
// Backfill any default parameters.
|
||||
BackfillCodecParameters(codecs);
|
||||
|
||||
media_desc->set_codecs(codecs);
|
||||
return media_desc;
|
||||
}
|
||||
|
||||
@ -5096,3 +5096,42 @@ TEST_F(WebRtcSdpTest, IgnoresUnknownAttributeLines) {
|
||||
JsepSessionDescription jdesc(kDummyType);
|
||||
EXPECT_TRUE(SdpDeserialize(sdp, &jdesc));
|
||||
}
|
||||
|
||||
TEST_F(WebRtcSdpTest, BackfillsDefaultFmtpValues) {
|
||||
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=group:BUNDLE 0\r\n"
|
||||
"a=fingerprint:sha-1 "
|
||||
"4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB\r\n"
|
||||
"a=setup:actpass\r\n"
|
||||
"a=ice-ufrag:ETEn\r\n"
|
||||
"a=ice-pwd:OtSK0WpNtpUjkY4+86js7Z/l\r\n"
|
||||
"m=video 9 UDP/TLS/RTP/SAVPF 96 97\r\n"
|
||||
"c=IN IP4 0.0.0.0\r\n"
|
||||
"a=rtcp-mux\r\n"
|
||||
"a=sendonly\r\n"
|
||||
"a=mid:0\r\n"
|
||||
"a=rtpmap:96 H264/90000\r\n"
|
||||
"a=rtpmap:97 VP9/90000\r\n"
|
||||
"a=ssrc:1234 cname:test\r\n";
|
||||
JsepSessionDescription jdesc(kDummyType);
|
||||
EXPECT_TRUE(SdpDeserialize(sdp, &jdesc));
|
||||
ASSERT_EQ(1u, jdesc.description()->contents().size());
|
||||
const auto content = jdesc.description()->contents()[0];
|
||||
const auto* description = content.media_description();
|
||||
ASSERT_NE(description, nullptr);
|
||||
const std::vector<cricket::Codec> codecs = description->codecs();
|
||||
ASSERT_EQ(codecs.size(), 2u);
|
||||
std::string value;
|
||||
|
||||
EXPECT_EQ(codecs[0].name, "H264");
|
||||
EXPECT_TRUE(codecs[0].GetParam("packetization-mode", &value));
|
||||
EXPECT_EQ(value, "0");
|
||||
|
||||
EXPECT_EQ(codecs[1].name, "VP9");
|
||||
EXPECT_TRUE(codecs[1].GetParam("profile-id", &value));
|
||||
EXPECT_EQ(value, "0");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user