Simplify IsFmtpParam according to RFC 4855.
This should help pave the way for injectable audio codecs, since external implementations need to be able to signal arbitrary fmtp parameters. BUG=webrtc:5806 Review-Url: https://codereview.webrtc.org/2661453003 Cr-Commit-Position: refs/heads/master@{#16360}
This commit is contained in:
parent
55d6539b86
commit
aa4b0775aa
@ -1597,33 +1597,11 @@ void WriteFmtpParameters(const cricket::CodecParameterMap& parameters,
|
||||
}
|
||||
|
||||
bool IsFmtpParam(const std::string& name) {
|
||||
const char* kFmtpParams[] = {
|
||||
// TODO(hta): Split FMTP parameters apart from parameters in general.
|
||||
// FMTP parameters are codec specific, not generic.
|
||||
kCodecParamMinPTime,
|
||||
kCodecParamSPropStereo,
|
||||
kCodecParamStereo,
|
||||
kCodecParamUseInbandFec,
|
||||
kCodecParamUseDtx,
|
||||
kCodecParamStartBitrate,
|
||||
kCodecParamMaxBitrate,
|
||||
kCodecParamMinBitrate,
|
||||
kCodecParamMaxQuantization,
|
||||
kCodecParamSctpProtocol,
|
||||
kCodecParamSctpStreams,
|
||||
kCodecParamMaxAverageBitrate,
|
||||
kCodecParamMaxPlaybackRate,
|
||||
kCodecParamAssociatedPayloadType,
|
||||
cricket::kH264FmtpPacketizationMode,
|
||||
cricket::kH264FmtpLevelAsymmetryAllowed,
|
||||
cricket::kH264FmtpProfileLevelId,
|
||||
cricket::kFlexfecFmtpRepairWindow};
|
||||
for (size_t i = 0; i < arraysize(kFmtpParams); ++i) {
|
||||
if (name.compare(kFmtpParams[i]) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
// RFC 4855, section 3 specifies the mapping of media format parameters to SDP
|
||||
// parameters. Only ptime, maxptime, channels and rate are placed outside of
|
||||
// the fmtp line. In WebRTC, channels and rate are already handled separately
|
||||
// and thus not included in the CodecParameterMap.
|
||||
return name != kCodecParamPTime && name != kCodecParamMaxPTime;
|
||||
}
|
||||
|
||||
// Retreives fmtp parameters from |params|, which may contain other parameters
|
||||
|
||||
@ -3074,6 +3074,65 @@ TEST_F(WebRtcSdpTest, DeserializeVideoFmtpWithSpace) {
|
||||
EXPECT_EQ(found->second, "40");
|
||||
}
|
||||
|
||||
TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithUnknownParameter) {
|
||||
AudioContentDescription* acd = static_cast<AudioContentDescription*>(
|
||||
GetFirstAudioContent(&desc_)->description);
|
||||
|
||||
cricket::AudioCodecs codecs = acd->codecs();
|
||||
codecs[0].params["unknown-future-parameter"] = "SomeFutureValue";
|
||||
acd->set_codecs(codecs);
|
||||
|
||||
ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(),
|
||||
jdesc_.session_id(),
|
||||
jdesc_.session_version()));
|
||||
std::string message = webrtc::SdpSerialize(jdesc_, false);
|
||||
std::string sdp_with_fmtp = kSdpFullString;
|
||||
InjectAfter("a=rtpmap:111 opus/48000/2\r\n",
|
||||
"a=fmtp:111 unknown-future-parameter=SomeFutureValue\r\n",
|
||||
&sdp_with_fmtp);
|
||||
EXPECT_EQ(sdp_with_fmtp, message);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithKnownFmtpParameter) {
|
||||
AudioContentDescription* acd = static_cast<AudioContentDescription*>(
|
||||
GetFirstAudioContent(&desc_)->description);
|
||||
|
||||
cricket::AudioCodecs codecs = acd->codecs();
|
||||
codecs[0].params["stereo"] = "1";
|
||||
acd->set_codecs(codecs);
|
||||
|
||||
ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(),
|
||||
jdesc_.session_id(),
|
||||
jdesc_.session_version()));
|
||||
std::string message = webrtc::SdpSerialize(jdesc_, false);
|
||||
std::string sdp_with_fmtp = kSdpFullString;
|
||||
InjectAfter("a=rtpmap:111 opus/48000/2\r\n",
|
||||
"a=fmtp:111 stereo=1\r\n",
|
||||
&sdp_with_fmtp);
|
||||
EXPECT_EQ(sdp_with_fmtp, message);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithPTimeAndMaxPTime) {
|
||||
AudioContentDescription* acd = static_cast<AudioContentDescription*>(
|
||||
GetFirstAudioContent(&desc_)->description);
|
||||
|
||||
cricket::AudioCodecs codecs = acd->codecs();
|
||||
codecs[0].params["ptime"] = "20";
|
||||
codecs[0].params["maxptime"] = "120";
|
||||
acd->set_codecs(codecs);
|
||||
|
||||
ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(),
|
||||
jdesc_.session_id(),
|
||||
jdesc_.session_version()));
|
||||
std::string message = webrtc::SdpSerialize(jdesc_, false);
|
||||
std::string sdp_with_fmtp = kSdpFullString;
|
||||
InjectAfter("a=rtpmap:104 ISAC/32000\r\n",
|
||||
"a=maxptime:120\r\n" // No comma here. String merging!
|
||||
"a=ptime:20\r\n",
|
||||
&sdp_with_fmtp);
|
||||
EXPECT_EQ(sdp_with_fmtp, message);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcSdpTest, SerializeVideoFmtp) {
|
||||
VideoContentDescription* vcd = static_cast<VideoContentDescription*>(
|
||||
GetFirstVideoContent(&desc_)->description);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user