OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1021 // Creates an audio content description with no streams, and some default | 1021 // Creates an audio content description with no streams, and some default |
1022 // configuration. | 1022 // configuration. |
1023 AudioContentDescription* CreateAudioContentDescription() { | 1023 AudioContentDescription* CreateAudioContentDescription() { |
1024 AudioContentDescription* audio = new AudioContentDescription(); | 1024 AudioContentDescription* audio = new AudioContentDescription(); |
1025 audio->set_rtcp_mux(true); | 1025 audio->set_rtcp_mux(true); |
1026 audio->set_rtcp_reduced_size(true); | 1026 audio->set_rtcp_reduced_size(true); |
1027 audio->AddCrypto(CryptoParams(1, "AES_CM_128_HMAC_SHA1_32", | 1027 audio->AddCrypto(CryptoParams(1, "AES_CM_128_HMAC_SHA1_32", |
1028 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32", | 1028 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32", |
1029 "dummy_session_params")); | 1029 "dummy_session_params")); |
1030 audio->set_protocol(cricket::kMediaProtocolSavpf); | 1030 audio->set_protocol(cricket::kMediaProtocolSavpf); |
1031 AudioCodec opus(111, "opus", 48000, 0, 2, 3); | 1031 AudioCodec opus(111, "opus", 48000, 0, 2); |
1032 audio->AddCodec(opus); | 1032 audio->AddCodec(opus); |
1033 audio->AddCodec(AudioCodec(103, "ISAC", 16000, 32000, 1, 2)); | 1033 audio->AddCodec(AudioCodec(103, "ISAC", 16000, 32000, 1)); |
1034 audio->AddCodec(AudioCodec(104, "ISAC", 32000, 56000, 1, 1)); | 1034 audio->AddCodec(AudioCodec(104, "ISAC", 32000, 56000, 1)); |
1035 return audio; | 1035 return audio; |
1036 } | 1036 } |
1037 | 1037 |
1038 // Creates a video content description with no streams, and some default | 1038 // Creates a video content description with no streams, and some default |
1039 // configuration. | 1039 // configuration. |
1040 VideoContentDescription* CreateVideoContentDescription() { | 1040 VideoContentDescription* CreateVideoContentDescription() { |
1041 VideoContentDescription* video = new VideoContentDescription(); | 1041 VideoContentDescription* video = new VideoContentDescription(); |
1042 video->AddCrypto(CryptoParams( | 1042 video->AddCrypto(CryptoParams( |
1043 1, "AES_CM_128_HMAC_SHA1_80", | 1043 1, "AES_CM_128_HMAC_SHA1_80", |
1044 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32", "")); | 1044 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32", "")); |
1045 video->set_protocol(cricket::kMediaProtocolSavpf); | 1045 video->set_protocol(cricket::kMediaProtocolSavpf); |
1046 video->AddCodec( | 1046 video->AddCodec( |
1047 VideoCodec(120, JsepSessionDescription::kDefaultVideoCodecName, | 1047 VideoCodec(120, JsepSessionDescription::kDefaultVideoCodecName, |
1048 JsepSessionDescription::kMaxVideoCodecWidth, | 1048 JsepSessionDescription::kMaxVideoCodecWidth, |
1049 JsepSessionDescription::kMaxVideoCodecHeight, | 1049 JsepSessionDescription::kMaxVideoCodecHeight, |
1050 JsepSessionDescription::kDefaultVideoCodecFramerate, | 1050 JsepSessionDescription::kDefaultVideoCodecFramerate)); |
1051 JsepSessionDescription::kDefaultVideoCodecPreference)); | |
1052 return video; | 1051 return video; |
1053 } | 1052 } |
1054 | 1053 |
1055 template <class MCD> | 1054 template <class MCD> |
1056 void CompareMediaContentDescription(const MCD* cd1, | 1055 void CompareMediaContentDescription(const MCD* cd1, |
1057 const MCD* cd2) { | 1056 const MCD* cd2) { |
1058 // type | 1057 // type |
1059 EXPECT_EQ(cd1->type(), cd1->type()); | 1058 EXPECT_EQ(cd1->type(), cd1->type()); |
1060 | 1059 |
1061 // content direction | 1060 // content direction |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1391 EXPECT_EQ(new_sdp, message); | 1390 EXPECT_EQ(new_sdp, message); |
1392 return true; | 1391 return true; |
1393 } | 1392 } |
1394 | 1393 |
1395 void AddSctpDataChannel() { | 1394 void AddSctpDataChannel() { |
1396 rtc::scoped_ptr<DataContentDescription> data( | 1395 rtc::scoped_ptr<DataContentDescription> data( |
1397 new DataContentDescription()); | 1396 new DataContentDescription()); |
1398 data_desc_ = data.get(); | 1397 data_desc_ = data.get(); |
1399 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp); | 1398 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp); |
1400 DataCodec codec(cricket::kGoogleSctpDataCodecId, | 1399 DataCodec codec(cricket::kGoogleSctpDataCodecId, |
1401 cricket::kGoogleSctpDataCodecName, 0); | 1400 cricket::kGoogleSctpDataCodecName); |
1402 codec.SetParam(cricket::kCodecParamPort, kDefaultSctpPort); | 1401 codec.SetParam(cricket::kCodecParamPort, kDefaultSctpPort); |
1403 data_desc_->AddCodec(codec); | 1402 data_desc_->AddCodec(codec); |
1404 desc_.AddContent(kDataContentName, NS_JINGLE_DRAFT_SCTP, data.release()); | 1403 desc_.AddContent(kDataContentName, NS_JINGLE_DRAFT_SCTP, data.release()); |
1405 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 1404 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
1406 kDataContentName, TransportDescription(kUfragData, kPwdData)))); | 1405 kDataContentName, TransportDescription(kUfragData, kPwdData)))); |
1407 } | 1406 } |
1408 | 1407 |
1409 void AddRtpDataChannel() { | 1408 void AddRtpDataChannel() { |
1410 rtc::scoped_ptr<DataContentDescription> data( | 1409 rtc::scoped_ptr<DataContentDescription> data( |
1411 new DataContentDescription()); | 1410 new DataContentDescription()); |
1412 data_desc_ = data.get(); | 1411 data_desc_ = data.get(); |
1413 | 1412 |
1414 data_desc_->AddCodec(DataCodec(101, "google-data", 1)); | 1413 data_desc_->AddCodec(DataCodec(101, "google-data")); |
1415 StreamParams data_stream; | 1414 StreamParams data_stream; |
1416 data_stream.id = kDataChannelMsid; | 1415 data_stream.id = kDataChannelMsid; |
1417 data_stream.cname = kDataChannelCname; | 1416 data_stream.cname = kDataChannelCname; |
1418 data_stream.sync_label = kDataChannelLabel; | 1417 data_stream.sync_label = kDataChannelLabel; |
1419 data_stream.ssrcs.push_back(kDataChannelSsrc); | 1418 data_stream.ssrcs.push_back(kDataChannelSsrc); |
1420 data_desc_->AddStream(data_stream); | 1419 data_desc_->AddStream(data_stream); |
1421 data_desc_->AddCrypto(CryptoParams( | 1420 data_desc_->AddCrypto(CryptoParams( |
1422 1, "AES_CM_128_HMAC_SHA1_80", | 1421 1, "AES_CM_128_HMAC_SHA1_80", |
1423 "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5", "")); | 1422 "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5", "")); |
1424 data_desc_->set_protocol(cricket::kMediaProtocolSavpf); | 1423 data_desc_->set_protocol(cricket::kMediaProtocolSavpf); |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1986 | 1985 |
1987 TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { | 1986 TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { |
1988 AddSctpDataChannel(); | 1987 AddSctpDataChannel(); |
1989 JsepSessionDescription jsep_desc(kDummyString); | 1988 JsepSessionDescription jsep_desc(kDummyString); |
1990 | 1989 |
1991 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 1990 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
1992 DataContentDescription* dcdesc = static_cast<DataContentDescription*>( | 1991 DataContentDescription* dcdesc = static_cast<DataContentDescription*>( |
1993 jsep_desc.description()->GetContentDescriptionByName(kDataContentName)); | 1992 jsep_desc.description()->GetContentDescriptionByName(kDataContentName)); |
1994 | 1993 |
1995 const int kNewPort = 1234; | 1994 const int kNewPort = 1234; |
1996 cricket::DataCodec codec( | 1995 cricket::DataCodec codec(cricket::kGoogleSctpDataCodecId, |
1997 cricket::kGoogleSctpDataCodecId, cricket::kGoogleSctpDataCodecName, 0); | 1996 cricket::kGoogleSctpDataCodecName); |
1998 codec.SetParam(cricket::kCodecParamPort, kNewPort); | 1997 codec.SetParam(cricket::kCodecParamPort, kNewPort); |
1999 dcdesc->AddOrReplaceCodec(codec); | 1998 dcdesc->AddOrReplaceCodec(codec); |
2000 | 1999 |
2001 std::string message = webrtc::SdpSerialize(jsep_desc, false); | 2000 std::string message = webrtc::SdpSerialize(jsep_desc, false); |
2002 | 2001 |
2003 std::string expected_sdp = kSdpString; | 2002 std::string expected_sdp = kSdpString; |
2004 expected_sdp.append(kSdpSctpDataChannelString); | 2003 expected_sdp.append(kSdpSctpDataChannelString); |
2005 | 2004 |
2006 char default_portstr[16]; | 2005 char default_portstr[16]; |
2007 char new_portstr[16]; | 2006 char new_portstr[16]; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2141 // The rtpmap line for static payload codec is optional. | 2140 // The rtpmap line for static payload codec is optional. |
2142 "a=rtpmap:18 G729/16000\r\n" | 2141 "a=rtpmap:18 G729/16000\r\n" |
2143 "a=rtpmap:103 ISAC/16000\r\n"; | 2142 "a=rtpmap:103 ISAC/16000\r\n"; |
2144 | 2143 |
2145 JsepSessionDescription jdesc(kDummyString); | 2144 JsepSessionDescription jdesc(kDummyString); |
2146 EXPECT_TRUE(SdpDeserialize(kSdpNoRtpmapString, &jdesc)); | 2145 EXPECT_TRUE(SdpDeserialize(kSdpNoRtpmapString, &jdesc)); |
2147 cricket::AudioContentDescription* audio = | 2146 cricket::AudioContentDescription* audio = |
2148 static_cast<AudioContentDescription*>( | 2147 static_cast<AudioContentDescription*>( |
2149 jdesc.description()->GetContentDescriptionByName(cricket::CN_AUDIO)); | 2148 jdesc.description()->GetContentDescriptionByName(cricket::CN_AUDIO)); |
2150 AudioCodecs ref_codecs; | 2149 AudioCodecs ref_codecs; |
2151 // The codecs in the AudioContentDescription will be sorted by preference. | 2150 // The codecs in the AudioContentDescription will be sorted by preference. |
pbos-webrtc
2016/04/05 09:30:32
This is no longer correct, grep for preference a b
Taylor Brandstetter
2016/04/05 17:57:13
Well they're still sorted by preference (the order
pbos-webrtc
2016/04/05 18:11:35
Can you clarify that in the comment (preferred cod
Taylor Brandstetter
2016/04/06 01:11:15
Comment has been clarified. Only reference to "pre
| |
2152 ref_codecs.push_back(AudioCodec(0, "PCMU", 8000, 0, 1, 3)); | 2151 ref_codecs.push_back(AudioCodec(0, "PCMU", 8000, 0, 1)); |
2153 ref_codecs.push_back(AudioCodec(18, "G729", 16000, 0, 1, 2)); | 2152 ref_codecs.push_back(AudioCodec(18, "G729", 16000, 0, 1)); |
2154 ref_codecs.push_back(AudioCodec(103, "ISAC", 16000, 32000, 1, 1)); | 2153 ref_codecs.push_back(AudioCodec(103, "ISAC", 16000, 32000, 1)); |
2155 EXPECT_EQ(ref_codecs, audio->codecs()); | 2154 EXPECT_EQ(ref_codecs, audio->codecs()); |
2156 } | 2155 } |
2157 | 2156 |
2158 TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutRtpmapButWithFmtp) { | 2157 TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutRtpmapButWithFmtp) { |
2159 static const char kSdpNoRtpmapString[] = | 2158 static const char kSdpNoRtpmapString[] = |
2160 "v=0\r\n" | 2159 "v=0\r\n" |
2161 "o=- 11 22 IN IP4 127.0.0.1\r\n" | 2160 "o=- 11 22 IN IP4 127.0.0.1\r\n" |
2162 "s=-\r\n" | 2161 "s=-\r\n" |
2163 "t=0 0\r\n" | 2162 "t=0 0\r\n" |
2164 "m=audio 49232 RTP/AVP 18 103\r\n" | 2163 "m=audio 49232 RTP/AVP 18 103\r\n" |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3112 EXPECT_TRUE( | 3111 EXPECT_TRUE( |
3113 SdpDeserialize(kUnifiedPlanSdpFullString, &deserialized_description)); | 3112 SdpDeserialize(kUnifiedPlanSdpFullString, &deserialized_description)); |
3114 | 3113 |
3115 EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description)); | 3114 EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description)); |
3116 } | 3115 } |
3117 | 3116 |
3118 TEST_F(WebRtcSdpTest, SerializeUnifiedPlanSessionDescription) { | 3117 TEST_F(WebRtcSdpTest, SerializeUnifiedPlanSessionDescription) { |
3119 MakeUnifiedPlanDescription(); | 3118 MakeUnifiedPlanDescription(); |
3120 TestSerialize(jdesc_, true); | 3119 TestSerialize(jdesc_, true); |
3121 } | 3120 } |
OLD | NEW |