Chromium Code Reviews| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 "a=ssrc:3 label:video_track_id_1\r\n"; | 188 "a=ssrc:3 label:video_track_id_1\r\n"; |
| 189 | 189 |
| 190 // SDP reference string without the candidates. | 190 // SDP reference string without the candidates. |
| 191 static const char kSdpString[] = | 191 static const char kSdpString[] = |
| 192 "v=0\r\n" | 192 "v=0\r\n" |
| 193 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" | 193 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" |
| 194 "s=-\r\n" | 194 "s=-\r\n" |
| 195 "t=0 0\r\n" | 195 "t=0 0\r\n" |
| 196 "a=msid-semantic: WMS local_stream_1\r\n" | 196 "a=msid-semantic: WMS local_stream_1\r\n" |
| 197 "m=audio 9 RTP/SAVPF 111 103 104\r\n" | 197 "m=audio 9 RTP/SAVPF 111 103 104\r\n" |
| 198 "c=IN IP4 0.0.0.0\r\n" | 198 "c=IN IP4 74.125.127.126\r\n" |
|
Taylor Brandstetter
2017/03/18 00:46:07
I still think, since this is intended to be "refer
Zhi Huang
2017/03/18 19:27:55
Done.
| |
| 199 "a=rtcp:9 IN IP4 0.0.0.0\r\n" | 199 "a=rtcp:9 IN IP4 0.0.0.0\r\n" |
| 200 "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n" | 200 "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n" |
| 201 "a=mid:audio_content_name\r\n" | 201 "a=mid:audio_content_name\r\n" |
| 202 "a=sendrecv\r\n" | 202 "a=sendrecv\r\n" |
| 203 "a=rtcp-mux\r\n" | 203 "a=rtcp-mux\r\n" |
| 204 "a=rtcp-rsize\r\n" | 204 "a=rtcp-rsize\r\n" |
| 205 "a=crypto:1 AES_CM_128_HMAC_SHA1_32 " | 205 "a=crypto:1 AES_CM_128_HMAC_SHA1_32 " |
| 206 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 " | 206 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 " |
| 207 "dummy_session_params\r\n" | 207 "dummy_session_params\r\n" |
| 208 "a=rtpmap:111 opus/48000/2\r\n" | 208 "a=rtpmap:111 opus/48000/2\r\n" |
| 209 "a=rtpmap:103 ISAC/16000\r\n" | 209 "a=rtpmap:103 ISAC/16000\r\n" |
| 210 "a=rtpmap:104 ISAC/32000\r\n" | 210 "a=rtpmap:104 ISAC/32000\r\n" |
| 211 "a=ssrc:1 cname:stream_1_cname\r\n" | 211 "a=ssrc:1 cname:stream_1_cname\r\n" |
| 212 "a=ssrc:1 msid:local_stream_1 audio_track_id_1\r\n" | 212 "a=ssrc:1 msid:local_stream_1 audio_track_id_1\r\n" |
| 213 "a=ssrc:1 mslabel:local_stream_1\r\n" | 213 "a=ssrc:1 mslabel:local_stream_1\r\n" |
| 214 "a=ssrc:1 label:audio_track_id_1\r\n" | 214 "a=ssrc:1 label:audio_track_id_1\r\n" |
| 215 "m=video 9 RTP/SAVPF 120\r\n" | 215 "m=video 9 RTP/SAVPF 120\r\n" |
| 216 "c=IN IP4 0.0.0.0\r\n" | 216 "c=IN IP4 74.125.224.39\r\n" |
| 217 "a=rtcp:9 IN IP4 0.0.0.0\r\n" | 217 "a=rtcp:9 IN IP4 0.0.0.0\r\n" |
| 218 "a=ice-ufrag:ufrag_video\r\na=ice-pwd:pwd_video\r\n" | 218 "a=ice-ufrag:ufrag_video\r\na=ice-pwd:pwd_video\r\n" |
| 219 "a=mid:video_content_name\r\n" | 219 "a=mid:video_content_name\r\n" |
| 220 "a=sendrecv\r\n" | 220 "a=sendrecv\r\n" |
| 221 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 " | 221 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 " |
| 222 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32\r\n" | 222 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32\r\n" |
| 223 "a=rtpmap:120 VP8/90000\r\n" | 223 "a=rtpmap:120 VP8/90000\r\n" |
| 224 "a=ssrc-group:FEC 2 3\r\n" | 224 "a=ssrc-group:FEC 2 3\r\n" |
| 225 "a=ssrc:2 cname:stream_1_cname\r\n" | 225 "a=ssrc:2 cname:stream_1_cname\r\n" |
| 226 "a=ssrc:2 msid:local_stream_1 video_track_id_1\r\n" | 226 "a=ssrc:2 msid:local_stream_1 video_track_id_1\r\n" |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 868 webrtc::InitializeAndroidObjects(); | 868 webrtc::InitializeAndroidObjects(); |
| 869 #endif | 869 #endif |
| 870 // AudioContentDescription | 870 // AudioContentDescription |
| 871 audio_desc_ = CreateAudioContentDescription(); | 871 audio_desc_ = CreateAudioContentDescription(); |
| 872 StreamParams audio_stream; | 872 StreamParams audio_stream; |
| 873 audio_stream.id = kAudioTrackId1; | 873 audio_stream.id = kAudioTrackId1; |
| 874 audio_stream.cname = kStream1Cname; | 874 audio_stream.cname = kStream1Cname; |
| 875 audio_stream.sync_label = kStreamLabel1; | 875 audio_stream.sync_label = kStreamLabel1; |
| 876 audio_stream.ssrcs.push_back(kAudioTrack1Ssrc); | 876 audio_stream.ssrcs.push_back(kAudioTrack1Ssrc); |
| 877 audio_desc_->AddStream(audio_stream); | 877 audio_desc_->AddStream(audio_stream); |
| 878 rtc::SocketAddress audio_addr("74.125.127.126", 2345); | |
| 879 audio_desc_->set_connection_address(audio_addr); | |
|
Taylor Brandstetter
2017/03/18 00:46:07
This seems unnecessary since AddCandidate will do
Zhi Huang
2017/03/18 19:27:55
I thought about this and I think AddCandidate won'
| |
| 878 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_desc_); | 880 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_desc_); |
| 879 | 881 |
| 880 // VideoContentDescription | 882 // VideoContentDescription |
| 881 video_desc_ = CreateVideoContentDescription(); | 883 video_desc_ = CreateVideoContentDescription(); |
| 882 StreamParams video_stream; | 884 StreamParams video_stream; |
| 883 video_stream.id = kVideoTrackId1; | 885 video_stream.id = kVideoTrackId1; |
| 884 video_stream.cname = kStream1Cname; | 886 video_stream.cname = kStream1Cname; |
| 885 video_stream.sync_label = kStreamLabel1; | 887 video_stream.sync_label = kStreamLabel1; |
| 886 video_stream.ssrcs.push_back(kVideoTrack1Ssrc1); | 888 video_stream.ssrcs.push_back(kVideoTrack1Ssrc1); |
| 887 video_stream.ssrcs.push_back(kVideoTrack1Ssrc2); | 889 video_stream.ssrcs.push_back(kVideoTrack1Ssrc2); |
| 888 cricket::SsrcGroup ssrc_group(kFecSsrcGroupSemantics, video_stream.ssrcs); | 890 cricket::SsrcGroup ssrc_group(kFecSsrcGroupSemantics, video_stream.ssrcs); |
| 889 video_stream.ssrc_groups.push_back(ssrc_group); | 891 video_stream.ssrc_groups.push_back(ssrc_group); |
| 890 video_desc_->AddStream(video_stream); | 892 video_desc_->AddStream(video_stream); |
| 893 rtc::SocketAddress video_addr("74.125.224.39", 3457); | |
| 894 video_desc_->set_connection_address(video_addr); | |
| 891 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_desc_); | 895 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_desc_); |
| 892 | 896 |
| 893 // TransportInfo | 897 // TransportInfo |
| 894 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 898 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| 895 kAudioContentName, TransportDescription(kUfragVoice, kPwdVoice)))); | 899 kAudioContentName, TransportDescription(kUfragVoice, kPwdVoice)))); |
| 896 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 900 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| 897 kVideoContentName, TransportDescription(kUfragVideo, kPwdVideo)))); | 901 kVideoContentName, TransportDescription(kUfragVideo, kPwdVideo)))); |
| 898 | 902 |
| 899 // v4 host | 903 // v4 host |
| 900 int port = 1234; | 904 int port = 1234; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1072 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_desc_); | 1076 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_desc_); |
| 1073 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_desc_); | 1077 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_desc_); |
| 1074 | 1078 |
| 1075 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), | 1079 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), |
| 1076 jdesc_.session_version())); | 1080 jdesc_.session_version())); |
| 1077 } | 1081 } |
| 1078 | 1082 |
| 1079 // Turns the existing reference description into a unified plan description, | 1083 // Turns the existing reference description into a unified plan description, |
| 1080 // with 2 audio tracks and 3 video tracks. | 1084 // with 2 audio tracks and 3 video tracks. |
| 1081 void MakeUnifiedPlanDescription() { | 1085 void MakeUnifiedPlanDescription() { |
| 1086 // The connection address for the additional tracks. | |
| 1087 rtc::SocketAddress connection_address("0.0.0.0", 9); | |
|
Taylor Brandstetter
2017/03/18 00:46:08
This shouldn't be necessary if an unset address re
Zhi Huang
2017/03/18 19:27:55
Done.
| |
| 1088 | |
| 1082 // Audio track 2. | 1089 // Audio track 2. |
| 1083 AudioContentDescription* audio_desc_2 = CreateAudioContentDescription(); | 1090 AudioContentDescription* audio_desc_2 = CreateAudioContentDescription(); |
| 1084 StreamParams audio_track_2; | 1091 StreamParams audio_track_2; |
| 1085 audio_track_2.id = kAudioTrackId2; | 1092 audio_track_2.id = kAudioTrackId2; |
| 1086 audio_track_2.cname = kStream2Cname; | 1093 audio_track_2.cname = kStream2Cname; |
| 1087 audio_track_2.sync_label = kStreamLabel2; | 1094 audio_track_2.sync_label = kStreamLabel2; |
| 1088 audio_track_2.ssrcs.push_back(kAudioTrack2Ssrc); | 1095 audio_track_2.ssrcs.push_back(kAudioTrack2Ssrc); |
| 1089 audio_desc_2->AddStream(audio_track_2); | 1096 audio_desc_2->AddStream(audio_track_2); |
| 1097 audio_desc_2->set_connection_address(connection_address); | |
| 1090 desc_.AddContent(kAudioContentName2, NS_JINGLE_RTP, audio_desc_2); | 1098 desc_.AddContent(kAudioContentName2, NS_JINGLE_RTP, audio_desc_2); |
| 1091 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 1099 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| 1092 kAudioContentName2, TransportDescription(kUfragVoice2, kPwdVoice2)))); | 1100 kAudioContentName2, TransportDescription(kUfragVoice2, kPwdVoice2)))); |
| 1093 | |
| 1094 // Video track 2, in stream 2. | 1101 // Video track 2, in stream 2. |
| 1095 VideoContentDescription* video_desc_2 = CreateVideoContentDescription(); | 1102 VideoContentDescription* video_desc_2 = CreateVideoContentDescription(); |
| 1096 StreamParams video_track_2; | 1103 StreamParams video_track_2; |
| 1097 video_track_2.id = kVideoTrackId2; | 1104 video_track_2.id = kVideoTrackId2; |
| 1098 video_track_2.cname = kStream2Cname; | 1105 video_track_2.cname = kStream2Cname; |
| 1099 video_track_2.sync_label = kStreamLabel2; | 1106 video_track_2.sync_label = kStreamLabel2; |
| 1100 video_track_2.ssrcs.push_back(kVideoTrack2Ssrc); | 1107 video_track_2.ssrcs.push_back(kVideoTrack2Ssrc); |
| 1101 video_desc_2->AddStream(video_track_2); | 1108 video_desc_2->AddStream(video_track_2); |
| 1109 video_desc_2->set_connection_address(connection_address); | |
| 1102 desc_.AddContent(kVideoContentName2, NS_JINGLE_RTP, video_desc_2); | 1110 desc_.AddContent(kVideoContentName2, NS_JINGLE_RTP, video_desc_2); |
| 1103 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 1111 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| 1104 kVideoContentName2, TransportDescription(kUfragVideo2, kPwdVideo2)))); | 1112 kVideoContentName2, TransportDescription(kUfragVideo2, kPwdVideo2)))); |
| 1105 | 1113 |
| 1106 // Video track 3, in stream 2. | 1114 // Video track 3, in stream 2. |
| 1107 VideoContentDescription* video_desc_3 = CreateVideoContentDescription(); | 1115 VideoContentDescription* video_desc_3 = CreateVideoContentDescription(); |
| 1108 StreamParams video_track_3; | 1116 StreamParams video_track_3; |
| 1109 video_track_3.id = kVideoTrackId3; | 1117 video_track_3.id = kVideoTrackId3; |
| 1110 video_track_3.cname = kStream2Cname; | 1118 video_track_3.cname = kStream2Cname; |
| 1111 video_track_3.sync_label = kStreamLabel2; | 1119 video_track_3.sync_label = kStreamLabel2; |
| 1112 video_track_3.ssrcs.push_back(kVideoTrack3Ssrc); | 1120 video_track_3.ssrcs.push_back(kVideoTrack3Ssrc); |
| 1113 video_desc_3->AddStream(video_track_3); | 1121 video_desc_3->AddStream(video_track_3); |
| 1122 video_desc_3->set_connection_address(connection_address); | |
| 1114 desc_.AddContent(kVideoContentName3, NS_JINGLE_RTP, video_desc_3); | 1123 desc_.AddContent(kVideoContentName3, NS_JINGLE_RTP, video_desc_3); |
| 1115 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 1124 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| 1116 kVideoContentName3, TransportDescription(kUfragVideo3, kPwdVideo3)))); | 1125 kVideoContentName3, TransportDescription(kUfragVideo3, kPwdVideo3)))); |
| 1117 | 1126 |
| 1118 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), | 1127 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), |
| 1119 jdesc_.session_version())); | 1128 jdesc_.session_version())); |
| 1120 } | 1129 } |
| 1121 | 1130 |
| 1122 // Creates an audio content description with no streams, and some default | 1131 // Creates an audio content description with no streams, and some default |
| 1123 // configuration. | 1132 // configuration. |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1463 std::string message = webrtc::SdpSerialize(jdesc_, false); | 1472 std::string message = webrtc::SdpSerialize(jdesc_, false); |
| 1464 EXPECT_EQ(new_sdp, message); | 1473 EXPECT_EQ(new_sdp, message); |
| 1465 return true; | 1474 return true; |
| 1466 } | 1475 } |
| 1467 | 1476 |
| 1468 bool TestSerializeRejected(bool audio_rejected, bool video_rejected) { | 1477 bool TestSerializeRejected(bool audio_rejected, bool video_rejected) { |
| 1469 audio_desc_ = static_cast<AudioContentDescription*>( | 1478 audio_desc_ = static_cast<AudioContentDescription*>( |
| 1470 audio_desc_->Copy()); | 1479 audio_desc_->Copy()); |
| 1471 video_desc_ = static_cast<VideoContentDescription*>( | 1480 video_desc_ = static_cast<VideoContentDescription*>( |
| 1472 video_desc_->Copy()); | 1481 video_desc_->Copy()); |
| 1482 | |
| 1483 rtc::SocketAddress audio_addr("74.125.127.126", 9); | |
| 1484 rtc::SocketAddress video_addr("74.125.224.39", 9); | |
| 1485 audio_desc_->set_connection_address(audio_addr); | |
| 1486 video_desc_->set_connection_address(video_addr); | |
| 1487 | |
| 1473 desc_.RemoveContentByName(kAudioContentName); | 1488 desc_.RemoveContentByName(kAudioContentName); |
| 1474 desc_.RemoveContentByName(kVideoContentName); | 1489 desc_.RemoveContentByName(kVideoContentName); |
| 1475 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_rejected, | 1490 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_rejected, |
| 1476 audio_desc_); | 1491 audio_desc_); |
| 1477 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_rejected, | 1492 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_rejected, |
| 1478 video_desc_); | 1493 video_desc_); |
| 1479 SetIceUfragPwd(kAudioContentName, audio_rejected ? "" : kUfragVoice, | 1494 SetIceUfragPwd(kAudioContentName, audio_rejected ? "" : kUfragVoice, |
| 1480 audio_rejected ? "" : kPwdVoice); | 1495 audio_rejected ? "" : kPwdVoice); |
| 1481 SetIceUfragPwd(kVideoContentName, video_rejected ? "" : kUfragVideo, | 1496 SetIceUfragPwd(kVideoContentName, video_rejected ? "" : kUfragVideo, |
| 1482 video_rejected ? "" : kPwdVideo); | 1497 video_rejected ? "" : kPwdVideo); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1496 | 1511 |
| 1497 void AddSctpDataChannel(bool use_sctpmap) { | 1512 void AddSctpDataChannel(bool use_sctpmap) { |
| 1498 std::unique_ptr<DataContentDescription> data(new DataContentDescription()); | 1513 std::unique_ptr<DataContentDescription> data(new DataContentDescription()); |
| 1499 data_desc_ = data.get(); | 1514 data_desc_ = data.get(); |
| 1500 data_desc_->set_use_sctpmap(use_sctpmap); | 1515 data_desc_->set_use_sctpmap(use_sctpmap); |
| 1501 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp); | 1516 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp); |
| 1502 DataCodec codec(cricket::kGoogleSctpDataCodecPlType, | 1517 DataCodec codec(cricket::kGoogleSctpDataCodecPlType, |
| 1503 cricket::kGoogleSctpDataCodecName); | 1518 cricket::kGoogleSctpDataCodecName); |
| 1504 codec.SetParam(cricket::kCodecParamPort, kDefaultSctpPort); | 1519 codec.SetParam(cricket::kCodecParamPort, kDefaultSctpPort); |
| 1505 data_desc_->AddCodec(codec); | 1520 data_desc_->AddCodec(codec); |
| 1521 rtc::SocketAddress addr("0.0.0.0", 9); | |
| 1522 data_desc_->set_connection_address(addr); | |
| 1506 desc_.AddContent(kDataContentName, NS_JINGLE_DRAFT_SCTP, data.release()); | 1523 desc_.AddContent(kDataContentName, NS_JINGLE_DRAFT_SCTP, data.release()); |
| 1507 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 1524 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| 1508 kDataContentName, TransportDescription(kUfragData, kPwdData)))); | 1525 kDataContentName, TransportDescription(kUfragData, kPwdData)))); |
| 1509 } | 1526 } |
| 1510 | 1527 |
| 1511 void AddRtpDataChannel() { | 1528 void AddRtpDataChannel() { |
| 1512 std::unique_ptr<DataContentDescription> data(new DataContentDescription()); | 1529 std::unique_ptr<DataContentDescription> data(new DataContentDescription()); |
| 1513 data_desc_ = data.get(); | 1530 data_desc_ = data.get(); |
| 1514 | 1531 |
| 1515 data_desc_->AddCodec(DataCodec(101, "google-data")); | 1532 data_desc_->AddCodec(DataCodec(101, "google-data")); |
| 1516 StreamParams data_stream; | 1533 StreamParams data_stream; |
| 1517 data_stream.id = kDataChannelMsid; | 1534 data_stream.id = kDataChannelMsid; |
| 1518 data_stream.cname = kDataChannelCname; | 1535 data_stream.cname = kDataChannelCname; |
| 1519 data_stream.sync_label = kDataChannelLabel; | 1536 data_stream.sync_label = kDataChannelLabel; |
| 1520 data_stream.ssrcs.push_back(kDataChannelSsrc); | 1537 data_stream.ssrcs.push_back(kDataChannelSsrc); |
| 1521 data_desc_->AddStream(data_stream); | 1538 data_desc_->AddStream(data_stream); |
| 1522 data_desc_->AddCrypto(CryptoParams( | 1539 data_desc_->AddCrypto(CryptoParams( |
| 1523 1, "AES_CM_128_HMAC_SHA1_80", | 1540 1, "AES_CM_128_HMAC_SHA1_80", |
| 1524 "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5", "")); | 1541 "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5", "")); |
| 1525 data_desc_->set_protocol(cricket::kMediaProtocolSavpf); | 1542 data_desc_->set_protocol(cricket::kMediaProtocolSavpf); |
| 1543 rtc::SocketAddress addr("0.0.0.0", 9); | |
| 1544 data_desc_->set_connection_address(addr); | |
| 1526 desc_.AddContent(kDataContentName, NS_JINGLE_RTP, data.release()); | 1545 desc_.AddContent(kDataContentName, NS_JINGLE_RTP, data.release()); |
| 1527 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 1546 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| 1528 kDataContentName, TransportDescription(kUfragData, kPwdData)))); | 1547 kDataContentName, TransportDescription(kUfragData, kPwdData)))); |
| 1529 } | 1548 } |
| 1530 | 1549 |
| 1531 bool TestDeserializeDirection(cricket::MediaContentDirection direction) { | 1550 bool TestDeserializeDirection(cricket::MediaContentDirection direction) { |
| 1532 std::string new_sdp = kSdpFullString; | 1551 std::string new_sdp = kSdpFullString; |
| 1533 ReplaceDirection(direction, &new_sdp); | 1552 ReplaceDirection(direction, &new_sdp); |
| 1534 JsepSessionDescription new_jdesc(kDummyString); | 1553 JsepSessionDescription new_jdesc(kDummyString); |
| 1535 | 1554 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1794 // SessionDescription with desc and candidates. | 1813 // SessionDescription with desc and candidates. |
| 1795 std::string message = webrtc::SdpSerialize(jdesc_, false); | 1814 std::string message = webrtc::SdpSerialize(jdesc_, false); |
| 1796 TestMismatch(std::string(kSdpFullString), message); | 1815 TestMismatch(std::string(kSdpFullString), message); |
| 1797 } | 1816 } |
| 1798 | 1817 |
| 1799 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionEmpty) { | 1818 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionEmpty) { |
| 1800 JsepSessionDescription jdesc_empty(kDummyString); | 1819 JsepSessionDescription jdesc_empty(kDummyString); |
| 1801 EXPECT_EQ("", webrtc::SdpSerialize(jdesc_empty, false)); | 1820 EXPECT_EQ("", webrtc::SdpSerialize(jdesc_empty, false)); |
| 1802 } | 1821 } |
| 1803 | 1822 |
| 1804 // This tests serialization of SDP with only IPv6 candidates and verifies that | |
| 1805 // IPv6 is used as default address in c line according to preference. | |
| 1806 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithIPv6Only) { | |
| 1807 // Only test 1 m line. | |
| 1808 desc_.RemoveContentByName("video_content_name"); | |
| 1809 // Stun has a high preference than local host. | |
| 1810 cricket::Candidate candidate1( | |
| 1811 cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp", | |
| 1812 rtc::SocketAddress("::1", 1234), kCandidatePriority, "", "", | |
| 1813 cricket::STUN_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1); | |
| 1814 cricket::Candidate candidate2( | |
| 1815 cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp", | |
| 1816 rtc::SocketAddress("::2", 1235), kCandidatePriority, "", "", | |
| 1817 cricket::LOCAL_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1); | |
| 1818 JsepSessionDescription jdesc(kDummyString); | |
| 1819 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | |
| 1820 | |
| 1821 // Only add the candidates to audio m line. | |
| 1822 JsepIceCandidate jice1("audio_content_name", 0, candidate1); | |
| 1823 JsepIceCandidate jice2("audio_content_name", 0, candidate2); | |
| 1824 ASSERT_TRUE(jdesc.AddCandidate(&jice1)); | |
| 1825 ASSERT_TRUE(jdesc.AddCandidate(&jice2)); | |
| 1826 std::string message = webrtc::SdpSerialize(jdesc, false); | |
| 1827 | |
| 1828 // Audio line should have a c line like this one. | |
| 1829 EXPECT_NE(message.find("c=IN IP6 ::1"), std::string::npos); | |
| 1830 // Shouldn't have a IP4 c line. | |
| 1831 EXPECT_EQ(message.find("c=IN IP4"), std::string::npos); | |
| 1832 } | |
| 1833 | |
| 1834 // This tests serialization of SDP with both IPv4 and IPv6 candidates and | |
| 1835 // verifies that IPv4 is used as default address in c line even if the | |
| 1836 // preference of IPv4 is lower. | |
| 1837 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBothIPFamilies) { | |
| 1838 // Only test 1 m line. | |
| 1839 desc_.RemoveContentByName("video_content_name"); | |
| 1840 cricket::Candidate candidate_v4( | |
| 1841 cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp", | |
| 1842 rtc::SocketAddress("192.168.1.5", 1234), kCandidatePriority, "", "", | |
| 1843 cricket::STUN_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1); | |
| 1844 cricket::Candidate candidate_v6( | |
| 1845 cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp", | |
| 1846 rtc::SocketAddress("::1", 1234), kCandidatePriority, "", "", | |
| 1847 cricket::LOCAL_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1); | |
| 1848 JsepSessionDescription jdesc(kDummyString); | |
| 1849 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | |
| 1850 | |
| 1851 // Only add the candidates to audio m line. | |
| 1852 JsepIceCandidate jice_v4("audio_content_name", 0, candidate_v4); | |
| 1853 JsepIceCandidate jice_v6("audio_content_name", 0, candidate_v6); | |
| 1854 ASSERT_TRUE(jdesc.AddCandidate(&jice_v4)); | |
| 1855 ASSERT_TRUE(jdesc.AddCandidate(&jice_v6)); | |
| 1856 std::string message = webrtc::SdpSerialize(jdesc, false); | |
| 1857 | |
| 1858 // Audio line should have a c line like this one. | |
| 1859 EXPECT_NE(message.find("c=IN IP4 192.168.1.5"), std::string::npos); | |
| 1860 // Shouldn't have a IP6 c line. | |
| 1861 EXPECT_EQ(message.find("c=IN IP6"), std::string::npos); | |
| 1862 } | |
| 1863 | |
| 1864 // This tests serialization of SDP with both UDP and TCP candidates and | |
| 1865 // verifies that UDP is used as default address in c line even if the | |
| 1866 // preference of UDP is lower. | |
| 1867 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBothProtocols) { | |
| 1868 // Only test 1 m line. | |
| 1869 desc_.RemoveContentByName("video_content_name"); | |
| 1870 // Stun has a high preference than local host. | |
| 1871 cricket::Candidate candidate1( | |
| 1872 cricket::ICE_CANDIDATE_COMPONENT_RTP, "tcp", | |
| 1873 rtc::SocketAddress("::1", 1234), kCandidatePriority, "", "", | |
| 1874 cricket::STUN_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1); | |
| 1875 cricket::Candidate candidate2( | |
| 1876 cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp", | |
| 1877 rtc::SocketAddress("fe80::1234:5678:abcd:ef12", 1235), kCandidatePriority, | |
| 1878 "", "", cricket::LOCAL_PORT_TYPE, kCandidateGeneration, | |
| 1879 kCandidateFoundation1); | |
| 1880 JsepSessionDescription jdesc(kDummyString); | |
| 1881 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | |
| 1882 | |
| 1883 // Only add the candidates to audio m line. | |
| 1884 JsepIceCandidate jice1("audio_content_name", 0, candidate1); | |
| 1885 JsepIceCandidate jice2("audio_content_name", 0, candidate2); | |
| 1886 ASSERT_TRUE(jdesc.AddCandidate(&jice1)); | |
| 1887 ASSERT_TRUE(jdesc.AddCandidate(&jice2)); | |
| 1888 std::string message = webrtc::SdpSerialize(jdesc, false); | |
| 1889 | |
| 1890 // Audio line should have a c line like this one. | |
| 1891 EXPECT_NE(message.find("c=IN IP6 fe80::1234:5678:abcd:ef12"), | |
| 1892 std::string::npos); | |
| 1893 // Shouldn't have a IP4 c line. | |
| 1894 EXPECT_EQ(message.find("c=IN IP4"), std::string::npos); | |
| 1895 } | |
| 1896 | |
| 1897 // This tests serialization of SDP with only TCP candidates and verifies that | |
| 1898 // null IPv4 is used as default address in c line. | |
| 1899 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithTCPOnly) { | |
| 1900 // Only test 1 m line. | |
| 1901 desc_.RemoveContentByName("video_content_name"); | |
| 1902 // Stun has a high preference than local host. | |
| 1903 cricket::Candidate candidate1( | |
| 1904 cricket::ICE_CANDIDATE_COMPONENT_RTP, "tcp", | |
| 1905 rtc::SocketAddress("::1", 1234), kCandidatePriority, "", "", | |
| 1906 cricket::STUN_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1); | |
| 1907 cricket::Candidate candidate2( | |
| 1908 cricket::ICE_CANDIDATE_COMPONENT_RTP, "tcp", | |
| 1909 rtc::SocketAddress("::2", 1235), kCandidatePriority, "", "", | |
| 1910 cricket::LOCAL_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1); | |
| 1911 JsepSessionDescription jdesc(kDummyString); | |
| 1912 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | |
| 1913 | |
| 1914 // Only add the candidates to audio m line. | |
| 1915 JsepIceCandidate jice1("audio_content_name", 0, candidate1); | |
| 1916 JsepIceCandidate jice2("audio_content_name", 0, candidate2); | |
| 1917 ASSERT_TRUE(jdesc.AddCandidate(&jice1)); | |
| 1918 ASSERT_TRUE(jdesc.AddCandidate(&jice2)); | |
| 1919 std::string message = webrtc::SdpSerialize(jdesc, false); | |
| 1920 | |
| 1921 // Audio line should have a c line like this one when no any default exists. | |
| 1922 EXPECT_NE(message.find("c=IN IP4 0.0.0.0"), std::string::npos); | |
| 1923 } | |
| 1924 | |
| 1925 // This tests serialization of SDP with a=crypto and a=fingerprint, as would be | 1823 // This tests serialization of SDP with a=crypto and a=fingerprint, as would be |
| 1926 // the case in a DTLS offer. | 1824 // the case in a DTLS offer. |
| 1927 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprint) { | 1825 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprint) { |
| 1928 AddFingerprint(); | 1826 AddFingerprint(); |
| 1929 JsepSessionDescription jdesc_with_fingerprint(kDummyString); | 1827 JsepSessionDescription jdesc_with_fingerprint(kDummyString); |
| 1828 | |
| 1829 rtc::SocketAddress audio_addr("74.125.127.126", 9); | |
| 1830 rtc::SocketAddress video_addr("74.125.224.39", 9); | |
| 1831 audio_desc_->set_connection_address(audio_addr); | |
| 1832 video_desc_->set_connection_address(video_addr); | |
|
Taylor Brandstetter
2017/03/18 00:46:07
I'd suggest replacing this pattern with a method t
Zhi Huang
2017/03/18 19:27:55
Since I won't add this MakeDescriptionWIthoutCandi
| |
| 1930 ASSERT_TRUE(jdesc_with_fingerprint.Initialize(desc_.Copy(), | 1833 ASSERT_TRUE(jdesc_with_fingerprint.Initialize(desc_.Copy(), |
| 1931 kSessionId, kSessionVersion)); | 1834 kSessionId, kSessionVersion)); |
| 1932 std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint, false); | 1835 std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint, false); |
| 1933 | 1836 |
| 1934 std::string sdp_with_fingerprint = kSdpString; | 1837 std::string sdp_with_fingerprint = kSdpString; |
| 1935 InjectAfter(kAttributeIcePwdVoice, | 1838 InjectAfter(kAttributeIcePwdVoice, |
| 1936 kFingerprint, &sdp_with_fingerprint); | 1839 kFingerprint, &sdp_with_fingerprint); |
| 1937 InjectAfter(kAttributeIcePwdVideo, | 1840 InjectAfter(kAttributeIcePwdVideo, |
| 1938 kFingerprint, &sdp_with_fingerprint); | 1841 kFingerprint, &sdp_with_fingerprint); |
| 1939 | 1842 |
| 1940 EXPECT_EQ(sdp_with_fingerprint, message); | 1843 EXPECT_EQ(sdp_with_fingerprint, message); |
| 1941 } | 1844 } |
| 1942 | 1845 |
| 1943 // This tests serialization of SDP with a=fingerprint with no a=crypto, as would | 1846 // This tests serialization of SDP with a=fingerprint with no a=crypto, as would |
| 1944 // be the case in a DTLS answer. | 1847 // be the case in a DTLS answer. |
| 1945 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprintNoCryptos) { | 1848 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprintNoCryptos) { |
| 1946 AddFingerprint(); | 1849 AddFingerprint(); |
| 1947 RemoveCryptos(); | 1850 RemoveCryptos(); |
| 1948 JsepSessionDescription jdesc_with_fingerprint(kDummyString); | 1851 JsepSessionDescription jdesc_with_fingerprint(kDummyString); |
| 1852 | |
| 1853 rtc::SocketAddress audio_addr("74.125.127.126", 9); | |
| 1854 rtc::SocketAddress video_addr("74.125.224.39", 9); | |
| 1855 audio_desc_->set_connection_address(audio_addr); | |
| 1856 video_desc_->set_connection_address(video_addr); | |
| 1949 ASSERT_TRUE(jdesc_with_fingerprint.Initialize(desc_.Copy(), | 1857 ASSERT_TRUE(jdesc_with_fingerprint.Initialize(desc_.Copy(), |
| 1950 kSessionId, kSessionVersion)); | 1858 kSessionId, kSessionVersion)); |
| 1951 std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint, false); | 1859 std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint, false); |
| 1952 | 1860 |
| 1953 std::string sdp_with_fingerprint = kSdpString; | 1861 std::string sdp_with_fingerprint = kSdpString; |
| 1954 Replace(kAttributeCryptoVoice, "", &sdp_with_fingerprint); | 1862 Replace(kAttributeCryptoVoice, "", &sdp_with_fingerprint); |
| 1955 Replace(kAttributeCryptoVideo, "", &sdp_with_fingerprint); | 1863 Replace(kAttributeCryptoVideo, "", &sdp_with_fingerprint); |
| 1956 InjectAfter(kAttributeIcePwdVoice, | 1864 InjectAfter(kAttributeIcePwdVoice, |
| 1957 kFingerprint, &sdp_with_fingerprint); | 1865 kFingerprint, &sdp_with_fingerprint); |
| 1958 InjectAfter(kAttributeIcePwdVideo, | 1866 InjectAfter(kAttributeIcePwdVideo, |
| 1959 kFingerprint, &sdp_with_fingerprint); | 1867 kFingerprint, &sdp_with_fingerprint); |
| 1960 | 1868 |
| 1961 EXPECT_EQ(sdp_with_fingerprint, message); | 1869 EXPECT_EQ(sdp_with_fingerprint, message); |
| 1962 } | 1870 } |
| 1963 | 1871 |
| 1964 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithoutCandidates) { | 1872 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithoutCandidates) { |
| 1965 // JsepSessionDescription with desc but without candidates. | 1873 // JsepSessionDescription with desc but without candidates. |
| 1966 JsepSessionDescription jdesc_no_candidates(kDummyString); | 1874 JsepSessionDescription jdesc_no_candidates(kDummyString); |
| 1875 | |
| 1876 rtc::SocketAddress audio_addr("74.125.127.126", 9); | |
| 1877 rtc::SocketAddress video_addr("74.125.224.39", 9); | |
| 1878 audio_desc_->set_connection_address(audio_addr); | |
| 1879 video_desc_->set_connection_address(video_addr); | |
| 1967 ASSERT_TRUE(jdesc_no_candidates.Initialize(desc_.Copy(), kSessionId, | 1880 ASSERT_TRUE(jdesc_no_candidates.Initialize(desc_.Copy(), kSessionId, |
| 1968 kSessionVersion)); | 1881 kSessionVersion)); |
| 1969 std::string message = webrtc::SdpSerialize(jdesc_no_candidates, false); | 1882 std::string message = webrtc::SdpSerialize(jdesc_no_candidates, false); |
| 1970 EXPECT_EQ(std::string(kSdpString), message); | 1883 EXPECT_EQ(std::string(kSdpString), message); |
| 1971 } | 1884 } |
| 1972 | 1885 |
| 1973 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBundle) { | 1886 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBundle) { |
| 1974 ContentGroup group(cricket::GROUP_TYPE_BUNDLE); | 1887 ContentGroup group(cricket::GROUP_TYPE_BUNDLE); |
| 1975 group.AddContentName(kAudioContentName); | 1888 group.AddContentName(kAudioContentName); |
| 1976 group.AddContentName(kVideoContentName); | 1889 group.AddContentName(kVideoContentName); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2051 } | 1964 } |
| 2052 | 1965 |
| 2053 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithAudioVideoRejected) { | 1966 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithAudioVideoRejected) { |
| 2054 EXPECT_TRUE(TestSerializeRejected(true, true)); | 1967 EXPECT_TRUE(TestSerializeRejected(true, true)); |
| 2055 } | 1968 } |
| 2056 | 1969 |
| 2057 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithRtpDataChannel) { | 1970 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithRtpDataChannel) { |
| 2058 AddRtpDataChannel(); | 1971 AddRtpDataChannel(); |
| 2059 JsepSessionDescription jsep_desc(kDummyString); | 1972 JsepSessionDescription jsep_desc(kDummyString); |
| 2060 | 1973 |
| 1974 rtc::SocketAddress audio_addr("74.125.127.126", 9); | |
| 1975 rtc::SocketAddress video_addr("74.125.224.39", 9); | |
| 1976 audio_desc_->set_connection_address(audio_addr); | |
| 1977 video_desc_->set_connection_address(video_addr); | |
| 2061 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 1978 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
| 2062 std::string message = webrtc::SdpSerialize(jsep_desc, false); | 1979 std::string message = webrtc::SdpSerialize(jsep_desc, false); |
| 2063 | 1980 |
| 2064 std::string expected_sdp = kSdpString; | 1981 std::string expected_sdp = kSdpString; |
| 2065 expected_sdp.append(kSdpRtpDataChannelString); | 1982 expected_sdp.append(kSdpRtpDataChannelString); |
| 2066 EXPECT_EQ(expected_sdp, message); | 1983 EXPECT_EQ(expected_sdp, message); |
| 2067 } | 1984 } |
| 2068 | 1985 |
| 2069 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithSctpDataChannel) { | 1986 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithSctpDataChannel) { |
| 2070 bool use_sctpmap = true; | 1987 bool use_sctpmap = true; |
| 2071 AddSctpDataChannel(use_sctpmap); | 1988 AddSctpDataChannel(use_sctpmap); |
| 2072 JsepSessionDescription jsep_desc(kDummyString); | 1989 JsepSessionDescription jsep_desc(kDummyString); |
| 2073 | 1990 |
| 1991 rtc::SocketAddress audio_addr("74.125.127.126", 9); | |
| 1992 rtc::SocketAddress video_addr("74.125.224.39", 9); | |
| 1993 audio_desc_->set_connection_address(audio_addr); | |
| 1994 video_desc_->set_connection_address(video_addr); | |
| 2074 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 1995 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
| 2075 std::string message = webrtc::SdpSerialize(jsep_desc, false); | 1996 std::string message = webrtc::SdpSerialize(jsep_desc, false); |
| 2076 | 1997 |
| 2077 std::string expected_sdp = kSdpString; | 1998 std::string expected_sdp = kSdpString; |
| 2078 expected_sdp.append(kSdpSctpDataChannelString); | 1999 expected_sdp.append(kSdpSctpDataChannelString); |
| 2079 EXPECT_EQ(message, expected_sdp); | 2000 EXPECT_EQ(message, expected_sdp); |
| 2080 } | 2001 } |
| 2081 | 2002 |
| 2082 TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { | 2003 TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { |
| 2083 bool use_sctpmap = true; | 2004 bool use_sctpmap = true; |
| 2084 AddSctpDataChannel(use_sctpmap); | 2005 AddSctpDataChannel(use_sctpmap); |
| 2085 JsepSessionDescription jsep_desc(kDummyString); | 2006 JsepSessionDescription jsep_desc(kDummyString); |
| 2086 | 2007 |
| 2008 rtc::SocketAddress audio_addr("74.125.127.126", 9); | |
| 2009 rtc::SocketAddress video_addr("74.125.224.39", 9); | |
| 2010 audio_desc_->set_connection_address(audio_addr); | |
| 2011 video_desc_->set_connection_address(video_addr); | |
| 2087 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 2012 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
| 2088 DataContentDescription* dcdesc = static_cast<DataContentDescription*>( | 2013 DataContentDescription* dcdesc = static_cast<DataContentDescription*>( |
| 2089 jsep_desc.description()->GetContentDescriptionByName(kDataContentName)); | 2014 jsep_desc.description()->GetContentDescriptionByName(kDataContentName)); |
| 2090 | 2015 |
| 2091 const int kNewPort = 1234; | 2016 const int kNewPort = 1234; |
| 2092 cricket::DataCodec codec(cricket::kGoogleSctpDataCodecPlType, | 2017 cricket::DataCodec codec(cricket::kGoogleSctpDataCodecPlType, |
| 2093 cricket::kGoogleSctpDataCodecName); | 2018 cricket::kGoogleSctpDataCodecName); |
| 2094 codec.SetParam(cricket::kCodecParamPort, kNewPort); | 2019 codec.SetParam(cricket::kCodecParamPort, kNewPort); |
| 2095 dcdesc->AddOrReplaceCodec(codec); | 2020 dcdesc->AddOrReplaceCodec(codec); |
| 2096 | 2021 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2107 rtc::replace_substrs(default_portstr, strlen(default_portstr), | 2032 rtc::replace_substrs(default_portstr, strlen(default_portstr), |
| 2108 new_portstr, strlen(new_portstr), | 2033 new_portstr, strlen(new_portstr), |
| 2109 &expected_sdp); | 2034 &expected_sdp); |
| 2110 | 2035 |
| 2111 EXPECT_EQ(expected_sdp, message); | 2036 EXPECT_EQ(expected_sdp, message); |
| 2112 } | 2037 } |
| 2113 | 2038 |
| 2114 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) { | 2039 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) { |
| 2115 AddRtpDataChannel(); | 2040 AddRtpDataChannel(); |
| 2116 data_desc_->set_bandwidth(100*1000); | 2041 data_desc_->set_bandwidth(100*1000); |
| 2042 rtc::SocketAddress audio_addr("74.125.127.126", 9); | |
| 2043 rtc::SocketAddress video_addr("74.125.224.39", 9); | |
| 2044 audio_desc_->set_connection_address(audio_addr); | |
| 2045 video_desc_->set_connection_address(video_addr); | |
| 2117 JsepSessionDescription jsep_desc(kDummyString); | 2046 JsepSessionDescription jsep_desc(kDummyString); |
| 2118 | 2047 |
| 2119 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 2048 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
| 2120 std::string message = webrtc::SdpSerialize(jsep_desc, false); | 2049 std::string message = webrtc::SdpSerialize(jsep_desc, false); |
| 2121 | 2050 |
| 2122 std::string expected_sdp = kSdpString; | 2051 std::string expected_sdp = kSdpString; |
| 2123 expected_sdp.append(kSdpRtpDataChannelString); | 2052 expected_sdp.append(kSdpRtpDataChannelString); |
| 2124 // Serializing data content shouldn't ignore bandwidth settings. | 2053 // Serializing data content shouldn't ignore bandwidth settings. |
| 2125 InjectAfter("m=application 9 RTP/SAVPF 101\r\nc=IN IP4 0.0.0.0\r\n", | 2054 InjectAfter("m=application 9 RTP/SAVPF 101\r\nc=IN IP4 0.0.0.0\r\n", |
| 2126 "b=AS:100\r\n", | 2055 "b=AS:100\r\n", |
| 2127 &expected_sdp); | 2056 &expected_sdp); |
| 2128 EXPECT_EQ(expected_sdp, message); | 2057 EXPECT_EQ(expected_sdp, message); |
| 2129 } | 2058 } |
| 2130 | 2059 |
| 2131 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) { | 2060 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) { |
| 2132 AddExtmap(); | 2061 AddExtmap(); |
| 2133 JsepSessionDescription desc_with_extmap("dummy"); | 2062 JsepSessionDescription desc_with_extmap("dummy"); |
| 2063 rtc::SocketAddress audio_addr("74.125.127.126", 9); | |
| 2064 rtc::SocketAddress video_addr("74.125.224.39", 9); | |
| 2065 audio_desc_->set_connection_address(audio_addr); | |
| 2066 video_desc_->set_connection_address(video_addr); | |
| 2134 ASSERT_TRUE(desc_with_extmap.Initialize(desc_.Copy(), | 2067 ASSERT_TRUE(desc_with_extmap.Initialize(desc_.Copy(), |
| 2135 kSessionId, kSessionVersion)); | 2068 kSessionId, kSessionVersion)); |
| 2136 std::string message = webrtc::SdpSerialize(desc_with_extmap, false); | 2069 std::string message = webrtc::SdpSerialize(desc_with_extmap, false); |
| 2137 | 2070 |
| 2138 std::string sdp_with_extmap = kSdpString; | 2071 std::string sdp_with_extmap = kSdpString; |
| 2139 InjectAfter("a=mid:audio_content_name\r\n", | 2072 InjectAfter("a=mid:audio_content_name\r\n", |
| 2140 kExtmap, &sdp_with_extmap); | 2073 kExtmap, &sdp_with_extmap); |
| 2141 InjectAfter("a=mid:video_content_name\r\n", | 2074 InjectAfter("a=mid:video_content_name\r\n", |
| 2142 kExtmap, &sdp_with_extmap); | 2075 kExtmap, &sdp_with_extmap); |
| 2143 | 2076 |
| (...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3497 "s=-\r\n" | 3430 "s=-\r\n" |
| 3498 "t=0 0\r\n" | 3431 "t=0 0\r\n" |
| 3499 "m=audio 9 RTP/SAVPF 111\r\n" | 3432 "m=audio 9 RTP/SAVPF 111\r\n" |
| 3500 "c=IN IP4 0.0.0.0\r\n" | 3433 "c=IN IP4 0.0.0.0\r\n" |
| 3501 "a=rtpmap:111 opus/48000/2\r\n" | 3434 "a=rtpmap:111 opus/48000/2\r\n" |
| 3502 "a=msid: track_id\r\n"; | 3435 "a=msid: track_id\r\n"; |
| 3503 | 3436 |
| 3504 JsepSessionDescription jdesc_output(kDummyString); | 3437 JsepSessionDescription jdesc_output(kDummyString); |
| 3505 EXPECT_FALSE(SdpDeserialize(kSdpWithMissingStreamId, &jdesc_output)); | 3438 EXPECT_FALSE(SdpDeserialize(kSdpWithMissingStreamId, &jdesc_output)); |
| 3506 } | 3439 } |
| 3440 | |
| 3441 // Tests that if both session-level address and media-level address exist, use | |
| 3442 // the media-level address. | |
| 3443 TEST_F(WebRtcSdpTest, ParseConnectionData) { | |
| 3444 JsepSessionDescription jsep_desc(kDummyString); | |
| 3445 | |
| 3446 // Sesssion-level address. | |
| 3447 std::string sdp = kSdpFullString; | |
| 3448 InjectAfter("s=-\r\n", "c=IN IP4 192.168.0.3\r\n", &sdp); | |
| 3449 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3450 | |
| 3451 // Remove the media level addresses. | |
|
Taylor Brandstetter
2017/03/18 00:46:08
This comment can be removed.
Zhi Huang
2017/03/18 19:27:55
Done.
| |
| 3452 const auto& content1 = jsep_desc.description()->contents()[0]; | |
| 3453 EXPECT_EQ("74.125.127.126:2345", | |
| 3454 static_cast<cricket::MediaContentDescription*>(content1.description) | |
| 3455 ->connection_address() | |
| 3456 .ToString()); | |
| 3457 const auto& content2 = jsep_desc.description()->contents()[1]; | |
| 3458 EXPECT_EQ("74.125.224.39:3457", | |
| 3459 static_cast<cricket::MediaContentDescription*>(content2.description) | |
| 3460 ->connection_address() | |
| 3461 .ToString()); | |
| 3462 } | |
| 3463 | |
| 3464 // Tests that the session-level connection address will be used if the media | |
| 3465 // level-addresses are not specified. | |
| 3466 TEST_F(WebRtcSdpTest, ParseConnectionDataSessionLevelOnly) { | |
| 3467 JsepSessionDescription jsep_desc(kDummyString); | |
| 3468 | |
| 3469 // Sesssion-level address. | |
| 3470 std::string sdp = kSdpString; | |
| 3471 InjectAfter("s=-\r\n", "c=IN IP4 192.168.0.3\r\n", &sdp); | |
| 3472 Replace("c=IN IP4 74.125.127.126\r\n", "", &sdp); | |
| 3473 Replace("c=IN IP4 74.125.224.39\r\n", "", &sdp); | |
| 3474 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3475 | |
| 3476 // Remove the media level addresses. | |
|
Taylor Brandstetter
2017/03/18 00:46:08
This comment should be moved to above the "Replace
Zhi Huang
2017/03/18 19:27:55
Done.
| |
| 3477 const auto& content1 = jsep_desc.description()->contents()[0]; | |
| 3478 EXPECT_EQ("192.168.0.3:9", | |
| 3479 static_cast<cricket::MediaContentDescription*>(content1.description) | |
| 3480 ->connection_address() | |
| 3481 .ToString()); | |
| 3482 const auto& content2 = jsep_desc.description()->contents()[1]; | |
| 3483 EXPECT_EQ("192.168.0.3:9", | |
| 3484 static_cast<cricket::MediaContentDescription*>(content2.description) | |
| 3485 ->connection_address() | |
| 3486 .ToString()); | |
| 3487 } | |
| 3488 | |
| 3489 TEST_F(WebRtcSdpTest, ParseConnectionDataIPv6) { | |
| 3490 JsepSessionDescription jsep_desc(kDummyString); | |
| 3491 | |
| 3492 std::string sdp = kSdpString; | |
| 3493 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3494 Replace("c=IN IP4 74.125.127.126\r\n", | |
| 3495 "c=IN IP6 2001:0db8:85a3:0000:0000:8a2e:0370:7335\r\n", &sdp); | |
| 3496 Replace("c=IN IP4 74.125.224.39\r\n", | |
| 3497 "c=IN IP6 2001:0db8:85a3:0000:0000:8a2e:0370:7336\r\n", &sdp); | |
| 3498 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3499 const auto& content1 = jsep_desc.description()->contents()[0]; | |
| 3500 EXPECT_EQ("[2001:db8:85a3::8a2e:370:7335]:9", | |
| 3501 static_cast<cricket::MediaContentDescription*>(content1.description) | |
| 3502 ->connection_address() | |
| 3503 .ToString()); | |
| 3504 const auto& content2 = jsep_desc.description()->contents()[1]; | |
| 3505 EXPECT_EQ("[2001:db8:85a3::8a2e:370:7336]:9", | |
| 3506 static_cast<cricket::MediaContentDescription*>(content2.description) | |
| 3507 ->connection_address() | |
| 3508 .ToString()); | |
| 3509 } | |
| 3510 | |
| 3511 // Test that the invalid or unsupprted connection data cannot be parsed. | |
| 3512 TEST_F(WebRtcSdpTest, ParseConnectionDataFailure) { | |
| 3513 JsepSessionDescription jsep_desc(kDummyString); | |
| 3514 std::string sdp = kSdpString; | |
| 3515 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3516 | |
| 3517 // Unsupported multicast IPv4 address. | |
| 3518 sdp = kSdpFullString; | |
| 3519 Replace("c=IN IP4 74.125.224.39\r\n", "c=IN IP4 74.125.224.39/127\r\n", &sdp); | |
| 3520 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3521 | |
| 3522 // Unsupported multicast IPv6 address. | |
| 3523 sdp = kSdpFullString; | |
| 3524 Replace("c=IN IP4 74.125.224.39\r\n", "c=IN IP6 ::1/3\r\n", &sdp); | |
| 3525 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3526 | |
| 3527 // Mismatched address type. | |
| 3528 sdp = kSdpFullString; | |
| 3529 Replace("c=IN IP4 74.125.224.39\r\n", "c=IN IP6 74.125.224.39\r\n", &sdp); | |
| 3530 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3531 | |
| 3532 sdp = kSdpFullString; | |
| 3533 Replace("c=IN IP4 74.125.224.39\r\n", | |
| 3534 "c=IN IP4 2001:0db8:85a3:0000:0000:8a2e:0370:7334\r\n", &sdp); | |
| 3535 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3536 } | |
| 3537 | |
| 3538 TEST_F(WebRtcSdpTest, SerializeAndDeserializeWithConneceionAddress) { | |
|
Taylor Brandstetter
2017/03/18 00:46:08
Spelling of "connection"
Zhi Huang
2017/03/18 19:27:55
Done.
| |
| 3539 // Serialization. | |
| 3540 std::string message = webrtc::SdpSerialize(jdesc_, false); | |
| 3541 // Deserialization. | |
| 3542 JsepSessionDescription jdesc(kDummyString); | |
| 3543 EXPECT_TRUE(SdpDeserialize(message, &jdesc)); | |
| 3544 auto audio_desc = static_cast<cricket::MediaContentDescription*>( | |
| 3545 jdesc.description()->GetContentByName(kAudioContentName)->description); | |
| 3546 auto video_desc = static_cast<cricket::MediaContentDescription*>( | |
| 3547 jdesc.description()->GetContentByName(kVideoContentName)->description); | |
| 3548 EXPECT_EQ(audio_desc_->connection_address().ToString(), | |
| 3549 audio_desc->connection_address().ToString()); | |
| 3550 EXPECT_EQ(video_desc_->connection_address().ToString(), | |
| 3551 video_desc->connection_address().ToString()); | |
| 3552 } | |
| OLD | NEW |