Templatize and clean up codec wildcards.
BUG=4123 R=pthatcher@webrtc.org Review URL: https://webrtc-codereview.appspot.com/39209004 Cr-Commit-Position: refs/heads/master@{#8422} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8422 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
30540fe722
commit
a744a28b92
@ -2436,10 +2436,9 @@ void UpdateCodec(MediaContentDescription* content_desc, int payload_type,
|
|||||||
AddOrReplaceCodec<T, U>(content_desc, new_codec);
|
AddOrReplaceCodec<T, U>(content_desc, new_codec);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PopWildcardCodec(std::vector<cricket::VideoCodec>* codecs,
|
template <class T>
|
||||||
cricket::VideoCodec* wildcard_codec) {
|
bool PopWildcardCodec(std::vector<T>* codecs, T* wildcard_codec) {
|
||||||
for (std::vector<cricket::VideoCodec>::iterator iter = codecs->begin();
|
for (auto iter = codecs->begin(); iter != codecs->end(); ++iter) {
|
||||||
iter != codecs->end(); ++iter) {
|
|
||||||
if (iter->id == kWildcardPayloadType) {
|
if (iter->id == kWildcardPayloadType) {
|
||||||
*wildcard_codec = *iter;
|
*wildcard_codec = *iter;
|
||||||
codecs->erase(iter);
|
codecs->erase(iter);
|
||||||
@ -2449,18 +2448,17 @@ bool PopWildcardCodec(std::vector<cricket::VideoCodec>* codecs,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFromWildcardVideoCodecs(VideoContentDescription* video_desc) {
|
template<class T>
|
||||||
std::vector<cricket::VideoCodec> codecs = video_desc->codecs();
|
void UpdateFromWildcardCodecs(cricket::MediaContentDescriptionImpl<T>* desc) {
|
||||||
cricket::VideoCodec wildcard_codec;
|
auto codecs = desc->codecs();
|
||||||
|
T wildcard_codec;
|
||||||
if (!PopWildcardCodec(&codecs, &wildcard_codec)) {
|
if (!PopWildcardCodec(&codecs, &wildcard_codec)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (std::vector<cricket::VideoCodec>::iterator iter = codecs.begin();
|
for (auto& codec : codecs) {
|
||||||
iter != codecs.end(); ++iter) {
|
|
||||||
cricket::VideoCodec& codec = *iter;
|
|
||||||
AddFeedbackParameters(wildcard_codec.feedback_params, &codec);
|
AddFeedbackParameters(wildcard_codec.feedback_params, &codec);
|
||||||
}
|
}
|
||||||
video_desc->set_codecs(codecs);
|
desc->set_codecs(codecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddAudioAttribute(const std::string& name, const std::string& value,
|
void AddAudioAttribute(const std::string& name, const std::string& value,
|
||||||
@ -2704,6 +2702,8 @@ bool ParseContent(const std::string& message,
|
|||||||
if (media_type == cricket::MEDIA_TYPE_AUDIO) {
|
if (media_type == cricket::MEDIA_TYPE_AUDIO) {
|
||||||
AudioContentDescription* audio_desc =
|
AudioContentDescription* audio_desc =
|
||||||
static_cast<AudioContentDescription*>(media_desc);
|
static_cast<AudioContentDescription*>(media_desc);
|
||||||
|
UpdateFromWildcardCodecs(audio_desc);
|
||||||
|
|
||||||
// Verify audio codec ensures that no audio codec has been populated with
|
// Verify audio codec ensures that no audio codec has been populated with
|
||||||
// only fmtp.
|
// only fmtp.
|
||||||
if (!VerifyAudioCodecs(audio_desc)) {
|
if (!VerifyAudioCodecs(audio_desc)) {
|
||||||
@ -2714,14 +2714,14 @@ bool ParseContent(const std::string& message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (media_type == cricket::MEDIA_TYPE_VIDEO) {
|
if (media_type == cricket::MEDIA_TYPE_VIDEO) {
|
||||||
VideoContentDescription* video_desc =
|
VideoContentDescription* video_desc =
|
||||||
static_cast<VideoContentDescription*>(media_desc);
|
static_cast<VideoContentDescription*>(media_desc);
|
||||||
UpdateFromWildcardVideoCodecs(video_desc);
|
UpdateFromWildcardCodecs(video_desc);
|
||||||
// Verify video codec ensures that no video codec has been populated with
|
// Verify video codec ensures that no video codec has been populated with
|
||||||
// only rtcp-fb.
|
// only rtcp-fb.
|
||||||
if (!VerifyVideoCodecs(video_desc)) {
|
if (!VerifyVideoCodecs(video_desc)) {
|
||||||
return ParseFailed("Failed to parse video codecs correctly.", error);
|
return ParseFailed("Failed to parse video codecs correctly.", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RFC 5245
|
// RFC 5245
|
||||||
|
@ -1255,7 +1255,7 @@ class WebRtcSdpTest : public testing::Test {
|
|||||||
|
|
||||||
void TestDeserializeRtcpFb(JsepSessionDescription* jdesc_output,
|
void TestDeserializeRtcpFb(JsepSessionDescription* jdesc_output,
|
||||||
bool use_wildcard) {
|
bool use_wildcard) {
|
||||||
std::string sdp =
|
std::string sdp_session_and_audio =
|
||||||
"v=0\r\n"
|
"v=0\r\n"
|
||||||
"o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
|
"o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
|
||||||
"s=-\r\n"
|
"s=-\r\n"
|
||||||
@ -1265,17 +1265,19 @@ class WebRtcSdpTest : public testing::Test {
|
|||||||
// description.
|
// description.
|
||||||
"a=msid-semantic: WMS\r\n"
|
"a=msid-semantic: WMS\r\n"
|
||||||
"m=audio 9 RTP/SAVPF 111\r\n"
|
"m=audio 9 RTP/SAVPF 111\r\n"
|
||||||
"a=rtpmap:111 opus/48000/2\r\n"
|
"a=rtpmap:111 opus/48000/2\r\n";
|
||||||
"a=rtcp-fb:111 nack\r\n"
|
std::string sdp_video =
|
||||||
"m=video 3457 RTP/SAVPF 101\r\n"
|
"m=video 3457 RTP/SAVPF 101\r\n"
|
||||||
"a=rtpmap:101 VP8/90000\r\n"
|
"a=rtpmap:101 VP8/90000\r\n"
|
||||||
"a=rtcp-fb:101 nack\r\n"
|
"a=rtcp-fb:101 nack\r\n"
|
||||||
"a=rtcp-fb:101 nack pli\r\n"
|
"a=rtcp-fb:101 nack pli\r\n"
|
||||||
"a=rtcp-fb:101 goog-remb\r\n"
|
"a=rtcp-fb:101 goog-remb\r\n";
|
||||||
"a=rtcp-fb:101 ccm fir\r\n";
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
|
os << sdp_session_and_audio;
|
||||||
|
os << "a=rtcp-fb:" << (use_wildcard ? "*" : "111") << " nack\r\n";
|
||||||
|
os << sdp_video;
|
||||||
os << "a=rtcp-fb:" << (use_wildcard ? "*" : "101") << " ccm fir\r\n";
|
os << "a=rtcp-fb:" << (use_wildcard ? "*" : "101") << " ccm fir\r\n";
|
||||||
sdp += os.str();
|
std::string sdp = os.str();
|
||||||
// Deserialize
|
// Deserialize
|
||||||
SdpParseError error;
|
SdpParseError error;
|
||||||
EXPECT_TRUE(webrtc::SdpDeserialize(sdp, jdesc_output, &error));
|
EXPECT_TRUE(webrtc::SdpDeserialize(sdp, jdesc_output, &error));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user