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 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 // Creates an audio content description with no streams, and some default | 1023 // Creates an audio content description with no streams, and some default |
1024 // configuration. | 1024 // configuration. |
1025 AudioContentDescription* CreateAudioContentDescription() { | 1025 AudioContentDescription* CreateAudioContentDescription() { |
1026 AudioContentDescription* audio = new AudioContentDescription(); | 1026 AudioContentDescription* audio = new AudioContentDescription(); |
1027 audio->set_rtcp_mux(true); | 1027 audio->set_rtcp_mux(true); |
1028 audio->set_rtcp_reduced_size(true); | 1028 audio->set_rtcp_reduced_size(true); |
1029 audio->AddCrypto(CryptoParams(1, "AES_CM_128_HMAC_SHA1_32", | 1029 audio->AddCrypto(CryptoParams(1, "AES_CM_128_HMAC_SHA1_32", |
1030 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32", | 1030 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32", |
1031 "dummy_session_params")); | 1031 "dummy_session_params")); |
1032 audio->set_protocol(cricket::kMediaProtocolSavpf); | 1032 audio->set_protocol(cricket::kMediaProtocolSavpf); |
1033 AudioCodec opus(111, "opus", 48000, 0, 2, 3); | 1033 AudioCodec opus(111, "opus", 48000, 0, 2); |
1034 audio->AddCodec(opus); | 1034 audio->AddCodec(opus); |
1035 audio->AddCodec(AudioCodec(103, "ISAC", 16000, 32000, 1, 2)); | 1035 audio->AddCodec(AudioCodec(103, "ISAC", 16000, 32000, 1)); |
1036 audio->AddCodec(AudioCodec(104, "ISAC", 32000, 56000, 1, 1)); | 1036 audio->AddCodec(AudioCodec(104, "ISAC", 32000, 56000, 1)); |
1037 return audio; | 1037 return audio; |
1038 } | 1038 } |
1039 | 1039 |
1040 // Creates a video content description with no streams, and some default | 1040 // Creates a video content description with no streams, and some default |
1041 // configuration. | 1041 // configuration. |
1042 VideoContentDescription* CreateVideoContentDescription() { | 1042 VideoContentDescription* CreateVideoContentDescription() { |
1043 VideoContentDescription* video = new VideoContentDescription(); | 1043 VideoContentDescription* video = new VideoContentDescription(); |
1044 video->AddCrypto(CryptoParams( | 1044 video->AddCrypto(CryptoParams( |
1045 1, "AES_CM_128_HMAC_SHA1_80", | 1045 1, "AES_CM_128_HMAC_SHA1_80", |
1046 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32", "")); | 1046 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32", "")); |
1047 video->set_protocol(cricket::kMediaProtocolSavpf); | 1047 video->set_protocol(cricket::kMediaProtocolSavpf); |
1048 video->AddCodec( | 1048 video->AddCodec( |
1049 VideoCodec(120, JsepSessionDescription::kDefaultVideoCodecName, | 1049 VideoCodec(120, JsepSessionDescription::kDefaultVideoCodecName, |
1050 JsepSessionDescription::kMaxVideoCodecWidth, | 1050 JsepSessionDescription::kMaxVideoCodecWidth, |
1051 JsepSessionDescription::kMaxVideoCodecHeight, | 1051 JsepSessionDescription::kMaxVideoCodecHeight, |
1052 JsepSessionDescription::kDefaultVideoCodecFramerate, | 1052 JsepSessionDescription::kDefaultVideoCodecFramerate)); |
1053 JsepSessionDescription::kDefaultVideoCodecPreference)); | |
1054 return video; | 1053 return video; |
1055 } | 1054 } |
1056 | 1055 |
1057 template <class MCD> | 1056 template <class MCD> |
1058 void CompareMediaContentDescription(const MCD* cd1, | 1057 void CompareMediaContentDescription(const MCD* cd1, |
1059 const MCD* cd2) { | 1058 const MCD* cd2) { |
1060 // type | 1059 // type |
1061 EXPECT_EQ(cd1->type(), cd1->type()); | 1060 EXPECT_EQ(cd1->type(), cd1->type()); |
1062 | 1061 |
1063 // content direction | 1062 // content direction |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 EXPECT_EQ(new_sdp, message); | 1392 EXPECT_EQ(new_sdp, message); |
1394 return true; | 1393 return true; |
1395 } | 1394 } |
1396 | 1395 |
1397 void AddSctpDataChannel() { | 1396 void AddSctpDataChannel() { |
1398 rtc::scoped_ptr<DataContentDescription> data( | 1397 rtc::scoped_ptr<DataContentDescription> data( |
1399 new DataContentDescription()); | 1398 new DataContentDescription()); |
1400 data_desc_ = data.get(); | 1399 data_desc_ = data.get(); |
1401 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp); | 1400 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp); |
1402 DataCodec codec(cricket::kGoogleSctpDataCodecId, | 1401 DataCodec codec(cricket::kGoogleSctpDataCodecId, |
1403 cricket::kGoogleSctpDataCodecName, 0); | 1402 cricket::kGoogleSctpDataCodecName); |
1404 codec.SetParam(cricket::kCodecParamPort, kDefaultSctpPort); | 1403 codec.SetParam(cricket::kCodecParamPort, kDefaultSctpPort); |
1405 data_desc_->AddCodec(codec); | 1404 data_desc_->AddCodec(codec); |
1406 desc_.AddContent(kDataContentName, NS_JINGLE_DRAFT_SCTP, data.release()); | 1405 desc_.AddContent(kDataContentName, NS_JINGLE_DRAFT_SCTP, data.release()); |
1407 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 1406 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
1408 kDataContentName, TransportDescription(kUfragData, kPwdData)))); | 1407 kDataContentName, TransportDescription(kUfragData, kPwdData)))); |
1409 } | 1408 } |
1410 | 1409 |
1411 void AddRtpDataChannel() { | 1410 void AddRtpDataChannel() { |
1412 rtc::scoped_ptr<DataContentDescription> data( | 1411 rtc::scoped_ptr<DataContentDescription> data( |
1413 new DataContentDescription()); | 1412 new DataContentDescription()); |
1414 data_desc_ = data.get(); | 1413 data_desc_ = data.get(); |
1415 | 1414 |
1416 data_desc_->AddCodec(DataCodec(101, "google-data", 1)); | 1415 data_desc_->AddCodec(DataCodec(101, "google-data")); |
1417 StreamParams data_stream; | 1416 StreamParams data_stream; |
1418 data_stream.id = kDataChannelMsid; | 1417 data_stream.id = kDataChannelMsid; |
1419 data_stream.cname = kDataChannelCname; | 1418 data_stream.cname = kDataChannelCname; |
1420 data_stream.sync_label = kDataChannelLabel; | 1419 data_stream.sync_label = kDataChannelLabel; |
1421 data_stream.ssrcs.push_back(kDataChannelSsrc); | 1420 data_stream.ssrcs.push_back(kDataChannelSsrc); |
1422 data_desc_->AddStream(data_stream); | 1421 data_desc_->AddStream(data_stream); |
1423 data_desc_->AddCrypto(CryptoParams( | 1422 data_desc_->AddCrypto(CryptoParams( |
1424 1, "AES_CM_128_HMAC_SHA1_80", | 1423 1, "AES_CM_128_HMAC_SHA1_80", |
1425 "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5", "")); | 1424 "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5", "")); |
1426 data_desc_->set_protocol(cricket::kMediaProtocolSavpf); | 1425 data_desc_->set_protocol(cricket::kMediaProtocolSavpf); |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1988 | 1987 |
1989 TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { | 1988 TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { |
1990 AddSctpDataChannel(); | 1989 AddSctpDataChannel(); |
1991 JsepSessionDescription jsep_desc(kDummyString); | 1990 JsepSessionDescription jsep_desc(kDummyString); |
1992 | 1991 |
1993 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 1992 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
1994 DataContentDescription* dcdesc = static_cast<DataContentDescription*>( | 1993 DataContentDescription* dcdesc = static_cast<DataContentDescription*>( |
1995 jsep_desc.description()->GetContentDescriptionByName(kDataContentName)); | 1994 jsep_desc.description()->GetContentDescriptionByName(kDataContentName)); |
1996 | 1995 |
1997 const int kNewPort = 1234; | 1996 const int kNewPort = 1234; |
1998 cricket::DataCodec codec( | 1997 cricket::DataCodec codec(cricket::kGoogleSctpDataCodecId, |
1999 cricket::kGoogleSctpDataCodecId, cricket::kGoogleSctpDataCodecName, 0); | 1998 cricket::kGoogleSctpDataCodecName); |
2000 codec.SetParam(cricket::kCodecParamPort, kNewPort); | 1999 codec.SetParam(cricket::kCodecParamPort, kNewPort); |
2001 dcdesc->AddOrReplaceCodec(codec); | 2000 dcdesc->AddOrReplaceCodec(codec); |
2002 | 2001 |
2003 std::string message = webrtc::SdpSerialize(jsep_desc, false); | 2002 std::string message = webrtc::SdpSerialize(jsep_desc, false); |
2004 | 2003 |
2005 std::string expected_sdp = kSdpString; | 2004 std::string expected_sdp = kSdpString; |
2006 expected_sdp.append(kSdpSctpDataChannelString); | 2005 expected_sdp.append(kSdpSctpDataChannelString); |
2007 | 2006 |
2008 char default_portstr[16]; | 2007 char default_portstr[16]; |
2009 char new_portstr[16]; | 2008 char new_portstr[16]; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2170 // The rtpmap line for static payload codec is optional. | 2169 // The rtpmap line for static payload codec is optional. |
2171 "a=rtpmap:18 G729/16000\r\n" | 2170 "a=rtpmap:18 G729/16000\r\n" |
2172 "a=rtpmap:103 ISAC/16000\r\n"; | 2171 "a=rtpmap:103 ISAC/16000\r\n"; |
2173 | 2172 |
2174 JsepSessionDescription jdesc(kDummyString); | 2173 JsepSessionDescription jdesc(kDummyString); |
2175 EXPECT_TRUE(SdpDeserialize(kSdpNoRtpmapString, &jdesc)); | 2174 EXPECT_TRUE(SdpDeserialize(kSdpNoRtpmapString, &jdesc)); |
2176 cricket::AudioContentDescription* audio = | 2175 cricket::AudioContentDescription* audio = |
2177 static_cast<AudioContentDescription*>( | 2176 static_cast<AudioContentDescription*>( |
2178 jdesc.description()->GetContentDescriptionByName(cricket::CN_AUDIO)); | 2177 jdesc.description()->GetContentDescriptionByName(cricket::CN_AUDIO)); |
2179 AudioCodecs ref_codecs; | 2178 AudioCodecs ref_codecs; |
2180 // The codecs in the AudioContentDescription will be sorted by preference. | 2179 // The codecs in the AudioContentDescription should be in the same order as |
2181 ref_codecs.push_back(AudioCodec(0, "PCMU", 8000, 0, 1, 3)); | 2180 // the payload types (<fmt>s) on the m= line. |
2182 ref_codecs.push_back(AudioCodec(18, "G729", 16000, 0, 1, 2)); | 2181 ref_codecs.push_back(AudioCodec(0, "PCMU", 8000, 0, 1)); |
2183 ref_codecs.push_back(AudioCodec(103, "ISAC", 16000, 32000, 1, 1)); | 2182 ref_codecs.push_back(AudioCodec(18, "G729", 16000, 0, 1)); |
| 2183 ref_codecs.push_back(AudioCodec(103, "ISAC", 16000, 32000, 1)); |
2184 EXPECT_EQ(ref_codecs, audio->codecs()); | 2184 EXPECT_EQ(ref_codecs, audio->codecs()); |
2185 } | 2185 } |
2186 | 2186 |
2187 TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutRtpmapButWithFmtp) { | 2187 TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutRtpmapButWithFmtp) { |
2188 static const char kSdpNoRtpmapString[] = | 2188 static const char kSdpNoRtpmapString[] = |
2189 "v=0\r\n" | 2189 "v=0\r\n" |
2190 "o=- 11 22 IN IP4 127.0.0.1\r\n" | 2190 "o=- 11 22 IN IP4 127.0.0.1\r\n" |
2191 "s=-\r\n" | 2191 "s=-\r\n" |
2192 "t=0 0\r\n" | 2192 "t=0 0\r\n" |
2193 "m=audio 49232 RTP/AVP 18 103\r\n" | 2193 "m=audio 49232 RTP/AVP 18 103\r\n" |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3141 EXPECT_TRUE( | 3141 EXPECT_TRUE( |
3142 SdpDeserialize(kUnifiedPlanSdpFullString, &deserialized_description)); | 3142 SdpDeserialize(kUnifiedPlanSdpFullString, &deserialized_description)); |
3143 | 3143 |
3144 EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description)); | 3144 EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description)); |
3145 } | 3145 } |
3146 | 3146 |
3147 TEST_F(WebRtcSdpTest, SerializeUnifiedPlanSessionDescription) { | 3147 TEST_F(WebRtcSdpTest, SerializeUnifiedPlanSessionDescription) { |
3148 MakeUnifiedPlanDescription(); | 3148 MakeUnifiedPlanDescription(); |
3149 TestSerialize(jdesc_, true); | 3149 TestSerialize(jdesc_, true); |
3150 } | 3150 } |
OLD | NEW |