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/17 00:20:43
Since you changed the tests back to how they were
Zhi Huang
2017/03/17 23:42:07
Since the way of generating the c= line has been c
| |
| 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_; | |
| 879 audio_addr_.SetIP("74.125.127.126"); | |
| 880 audio_desc_->set_connection_address(audio_addr_); | |
| 878 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_desc_); | 881 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_desc_); |
| 879 | 882 |
| 880 // VideoContentDescription | 883 // VideoContentDescription |
| 881 video_desc_ = CreateVideoContentDescription(); | 884 video_desc_ = CreateVideoContentDescription(); |
| 882 StreamParams video_stream; | 885 StreamParams video_stream; |
| 883 video_stream.id = kVideoTrackId1; | 886 video_stream.id = kVideoTrackId1; |
| 884 video_stream.cname = kStream1Cname; | 887 video_stream.cname = kStream1Cname; |
| 885 video_stream.sync_label = kStreamLabel1; | 888 video_stream.sync_label = kStreamLabel1; |
| 886 video_stream.ssrcs.push_back(kVideoTrack1Ssrc1); | 889 video_stream.ssrcs.push_back(kVideoTrack1Ssrc1); |
| 887 video_stream.ssrcs.push_back(kVideoTrack1Ssrc2); | 890 video_stream.ssrcs.push_back(kVideoTrack1Ssrc2); |
| 888 cricket::SsrcGroup ssrc_group(kFecSsrcGroupSemantics, video_stream.ssrcs); | 891 cricket::SsrcGroup ssrc_group(kFecSsrcGroupSemantics, video_stream.ssrcs); |
| 889 video_stream.ssrc_groups.push_back(ssrc_group); | 892 video_stream.ssrc_groups.push_back(ssrc_group); |
| 890 video_desc_->AddStream(video_stream); | 893 video_desc_->AddStream(video_stream); |
| 894 rtc::SocketAddress video_addr_; | |
| 895 video_addr_.SetIP("74.125.224.39"); | |
| 896 video_desc_->set_connection_address(video_addr_); | |
| 891 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_desc_); | 897 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_desc_); |
| 892 | 898 |
| 893 // TransportInfo | 899 // TransportInfo |
| 894 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 900 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| 895 kAudioContentName, TransportDescription(kUfragVoice, kPwdVoice)))); | 901 kAudioContentName, TransportDescription(kUfragVoice, kPwdVoice)))); |
| 896 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 902 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| 897 kVideoContentName, TransportDescription(kUfragVideo, kPwdVideo)))); | 903 kVideoContentName, TransportDescription(kUfragVideo, kPwdVideo)))); |
| 898 | 904 |
| 899 // v4 host | 905 // v4 host |
| 900 int port = 1234; | 906 int port = 1234; |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1496 | 1502 |
| 1497 void AddSctpDataChannel(bool use_sctpmap) { | 1503 void AddSctpDataChannel(bool use_sctpmap) { |
| 1498 std::unique_ptr<DataContentDescription> data(new DataContentDescription()); | 1504 std::unique_ptr<DataContentDescription> data(new DataContentDescription()); |
| 1499 data_desc_ = data.get(); | 1505 data_desc_ = data.get(); |
| 1500 data_desc_->set_use_sctpmap(use_sctpmap); | 1506 data_desc_->set_use_sctpmap(use_sctpmap); |
| 1501 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp); | 1507 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp); |
| 1502 DataCodec codec(cricket::kGoogleSctpDataCodecPlType, | 1508 DataCodec codec(cricket::kGoogleSctpDataCodecPlType, |
| 1503 cricket::kGoogleSctpDataCodecName); | 1509 cricket::kGoogleSctpDataCodecName); |
| 1504 codec.SetParam(cricket::kCodecParamPort, kDefaultSctpPort); | 1510 codec.SetParam(cricket::kCodecParamPort, kDefaultSctpPort); |
| 1505 data_desc_->AddCodec(codec); | 1511 data_desc_->AddCodec(codec); |
| 1512 rtc::SocketAddress addr; | |
| 1513 addr.SetIP("0.0.0.0"); | |
| 1514 data_desc_->set_connection_address(addr); | |
| 1506 desc_.AddContent(kDataContentName, NS_JINGLE_DRAFT_SCTP, data.release()); | 1515 desc_.AddContent(kDataContentName, NS_JINGLE_DRAFT_SCTP, data.release()); |
| 1507 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 1516 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| 1508 kDataContentName, TransportDescription(kUfragData, kPwdData)))); | 1517 kDataContentName, TransportDescription(kUfragData, kPwdData)))); |
| 1509 } | 1518 } |
| 1510 | 1519 |
| 1511 void AddRtpDataChannel() { | 1520 void AddRtpDataChannel() { |
| 1512 std::unique_ptr<DataContentDescription> data(new DataContentDescription()); | 1521 std::unique_ptr<DataContentDescription> data(new DataContentDescription()); |
| 1513 data_desc_ = data.get(); | 1522 data_desc_ = data.get(); |
| 1514 | 1523 |
| 1515 data_desc_->AddCodec(DataCodec(101, "google-data")); | 1524 data_desc_->AddCodec(DataCodec(101, "google-data")); |
| 1516 StreamParams data_stream; | 1525 StreamParams data_stream; |
| 1517 data_stream.id = kDataChannelMsid; | 1526 data_stream.id = kDataChannelMsid; |
| 1518 data_stream.cname = kDataChannelCname; | 1527 data_stream.cname = kDataChannelCname; |
| 1519 data_stream.sync_label = kDataChannelLabel; | 1528 data_stream.sync_label = kDataChannelLabel; |
| 1520 data_stream.ssrcs.push_back(kDataChannelSsrc); | 1529 data_stream.ssrcs.push_back(kDataChannelSsrc); |
| 1521 data_desc_->AddStream(data_stream); | 1530 data_desc_->AddStream(data_stream); |
| 1522 data_desc_->AddCrypto(CryptoParams( | 1531 data_desc_->AddCrypto(CryptoParams( |
| 1523 1, "AES_CM_128_HMAC_SHA1_80", | 1532 1, "AES_CM_128_HMAC_SHA1_80", |
| 1524 "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5", "")); | 1533 "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5", "")); |
| 1525 data_desc_->set_protocol(cricket::kMediaProtocolSavpf); | 1534 data_desc_->set_protocol(cricket::kMediaProtocolSavpf); |
| 1535 rtc::SocketAddress addr; | |
| 1536 addr.SetIP("0.0.0.0"); | |
| 1537 data_desc_->set_connection_address(addr); | |
| 1526 desc_.AddContent(kDataContentName, NS_JINGLE_RTP, data.release()); | 1538 desc_.AddContent(kDataContentName, NS_JINGLE_RTP, data.release()); |
| 1527 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 1539 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| 1528 kDataContentName, TransportDescription(kUfragData, kPwdData)))); | 1540 kDataContentName, TransportDescription(kUfragData, kPwdData)))); |
| 1529 } | 1541 } |
| 1530 | 1542 |
| 1531 bool TestDeserializeDirection(cricket::MediaContentDirection direction) { | 1543 bool TestDeserializeDirection(cricket::MediaContentDirection direction) { |
| 1532 std::string new_sdp = kSdpFullString; | 1544 std::string new_sdp = kSdpFullString; |
| 1533 ReplaceDirection(direction, &new_sdp); | 1545 ReplaceDirection(direction, &new_sdp); |
| 1534 JsepSessionDescription new_jdesc(kDummyString); | 1546 JsepSessionDescription new_jdesc(kDummyString); |
| 1535 | 1547 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1794 // SessionDescription with desc and candidates. | 1806 // SessionDescription with desc and candidates. |
| 1795 std::string message = webrtc::SdpSerialize(jdesc_, false); | 1807 std::string message = webrtc::SdpSerialize(jdesc_, false); |
| 1796 TestMismatch(std::string(kSdpFullString), message); | 1808 TestMismatch(std::string(kSdpFullString), message); |
| 1797 } | 1809 } |
| 1798 | 1810 |
| 1799 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionEmpty) { | 1811 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionEmpty) { |
| 1800 JsepSessionDescription jdesc_empty(kDummyString); | 1812 JsepSessionDescription jdesc_empty(kDummyString); |
| 1801 EXPECT_EQ("", webrtc::SdpSerialize(jdesc_empty, false)); | 1813 EXPECT_EQ("", webrtc::SdpSerialize(jdesc_empty, false)); |
| 1802 } | 1814 } |
| 1803 | 1815 |
| 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 | 1816 // This tests serialization of SDP with a=crypto and a=fingerprint, as would be |
| 1926 // the case in a DTLS offer. | 1817 // the case in a DTLS offer. |
| 1927 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprint) { | 1818 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprint) { |
| 1928 AddFingerprint(); | 1819 AddFingerprint(); |
| 1929 JsepSessionDescription jdesc_with_fingerprint(kDummyString); | 1820 JsepSessionDescription jdesc_with_fingerprint(kDummyString); |
| 1930 ASSERT_TRUE(jdesc_with_fingerprint.Initialize(desc_.Copy(), | 1821 ASSERT_TRUE(jdesc_with_fingerprint.Initialize(desc_.Copy(), |
| 1931 kSessionId, kSessionVersion)); | 1822 kSessionId, kSessionVersion)); |
| 1932 std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint, false); | 1823 std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint, false); |
| 1933 | 1824 |
| 1934 std::string sdp_with_fingerprint = kSdpString; | 1825 std::string sdp_with_fingerprint = kSdpString; |
| (...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3497 "s=-\r\n" | 3388 "s=-\r\n" |
| 3498 "t=0 0\r\n" | 3389 "t=0 0\r\n" |
| 3499 "m=audio 9 RTP/SAVPF 111\r\n" | 3390 "m=audio 9 RTP/SAVPF 111\r\n" |
| 3500 "c=IN IP4 0.0.0.0\r\n" | 3391 "c=IN IP4 0.0.0.0\r\n" |
| 3501 "a=rtpmap:111 opus/48000/2\r\n" | 3392 "a=rtpmap:111 opus/48000/2\r\n" |
| 3502 "a=msid: track_id\r\n"; | 3393 "a=msid: track_id\r\n"; |
| 3503 | 3394 |
| 3504 JsepSessionDescription jdesc_output(kDummyString); | 3395 JsepSessionDescription jdesc_output(kDummyString); |
| 3505 EXPECT_FALSE(SdpDeserialize(kSdpWithMissingStreamId, &jdesc_output)); | 3396 EXPECT_FALSE(SdpDeserialize(kSdpWithMissingStreamId, &jdesc_output)); |
| 3506 } | 3397 } |
| 3398 | |
| 3399 // Tests that if both session-level address and media-level address exist, use | |
| 3400 // the media-level address. | |
| 3401 TEST_F(WebRtcSdpTest, ParseConnectionData) { | |
| 3402 JsepSessionDescription jsep_desc(kDummyString); | |
| 3403 | |
| 3404 // Sesssion-level address. | |
| 3405 std::string sdp = kSdpFullString; | |
| 3406 InjectAfter("s=-\r\n", "c=IN IP4 192.168.0.3\r\n", &sdp); | |
| 3407 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3408 | |
| 3409 // Remove the media level addresses. | |
| 3410 // The port is expected to be the default value 0. | |
|
Taylor Brandstetter
2017/03/17 00:20:43
This comment about the port can probably be remove
Zhi Huang
2017/03/17 23:42:07
Done.
| |
| 3411 const auto& content1 = jsep_desc.description()->contents()[0]; | |
| 3412 EXPECT_EQ("74.125.127.126:2345", | |
| 3413 static_cast<cricket::MediaContentDescription*>(content1.description) | |
| 3414 ->connection_address() | |
| 3415 .ToString()); | |
| 3416 const auto& content2 = jsep_desc.description()->contents()[1]; | |
| 3417 EXPECT_EQ("74.125.224.39:3457", | |
| 3418 static_cast<cricket::MediaContentDescription*>(content2.description) | |
| 3419 ->connection_address() | |
| 3420 .ToString()); | |
| 3421 } | |
| 3422 | |
| 3423 // Tests that the session-level connection address will be used if the media | |
| 3424 // level-addresses are not specified. | |
| 3425 TEST_F(WebRtcSdpTest, ParseConnectionDataSessionLevelOnly) { | |
| 3426 JsepSessionDescription jsep_desc(kDummyString); | |
| 3427 | |
| 3428 // Sesssion-level address. | |
| 3429 std::string sdp = kSdpString; | |
| 3430 InjectAfter("s=-\r\n", "c=IN IP4 192.168.0.3\r\n", &sdp); | |
| 3431 Replace("c=IN IP4 74.125.127.126\r\n", "", &sdp); | |
| 3432 Replace("c=IN IP4 74.125.224.39\r\n", "", &sdp); | |
| 3433 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3434 | |
| 3435 // Remove the media level addresses. | |
| 3436 // The port is expected to be the default value 0. | |
| 3437 const auto& content1 = jsep_desc.description()->contents()[0]; | |
| 3438 EXPECT_EQ("192.168.0.3:0", | |
|
Taylor Brandstetter
2017/03/17 00:20:43
These should actually expect a port, since there s
Zhi Huang
2017/03/17 23:42:06
Done.
| |
| 3439 static_cast<cricket::MediaContentDescription*>(content1.description) | |
| 3440 ->connection_address() | |
| 3441 .ToString()); | |
| 3442 const auto& content2 = jsep_desc.description()->contents()[1]; | |
| 3443 EXPECT_EQ("192.168.0.3:0", | |
| 3444 static_cast<cricket::MediaContentDescription*>(content2.description) | |
| 3445 ->connection_address() | |
| 3446 .ToString()); | |
| 3447 } | |
| 3448 | |
| 3449 TEST_F(WebRtcSdpTest, ParseConnectionDataIPv6) { | |
| 3450 JsepSessionDescription jsep_desc(kDummyString); | |
| 3451 | |
| 3452 std::string sdp = kSdpString; | |
| 3453 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3454 Replace("c=IN IP4 74.125.127.126\r\n", | |
| 3455 "c=IN IP6 2001:0db8:85a3:0000:0000:8a2e:0370:7335\r\n", &sdp); | |
| 3456 Replace("c=IN IP4 74.125.224.39\r\n", | |
| 3457 "c=IN IP6 2001:0db8:85a3:0000:0000:8a2e:0370:7336\r\n", &sdp); | |
| 3458 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3459 const auto& content3 = jsep_desc.description()->contents()[0]; | |
| 3460 EXPECT_EQ("[2001:db8:85a3::8a2e:370:7335]:2345", | |
| 3461 static_cast<cricket::MediaContentDescription*>(content3.description) | |
| 3462 ->connection_address() | |
| 3463 .ToString()); | |
| 3464 const auto& content4 = jsep_desc.description()->contents()[1]; | |
| 3465 EXPECT_EQ("[2001:db8:85a3::8a2e:370:7336]:3457", | |
| 3466 static_cast<cricket::MediaContentDescription*>(content4.description) | |
| 3467 ->connection_address() | |
| 3468 .ToString()); | |
| 3469 } | |
| 3470 | |
| 3471 // Test that the invalid or unsupprted connection data cannot be parsed. | |
| 3472 TEST_F(WebRtcSdpTest, ParseConnectionDataFailure) { | |
| 3473 JsepSessionDescription jsep_desc(kDummyString); | |
| 3474 std::string sdp = kSdpString; | |
| 3475 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3476 | |
| 3477 // unsupported IPv4 address. | |
|
Taylor Brandstetter
2017/03/17 00:20:43
nit: Capitalize first word of comments
Zhi Huang
2017/03/17 23:42:06
Done.
| |
| 3478 sdp = kSdpFullString; | |
| 3479 Replace("c=IN IP4 74.125.224.39\r\n", "c=IN IP4 74.125.224.39/127\r\n", &sdp); | |
| 3480 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3481 | |
| 3482 // unsupported IPv6 address. | |
| 3483 sdp = kSdpFullString; | |
| 3484 Replace("c=IN IP4 74.125.224.39\r\n", "c=IN IP6 a/3\r\n", &sdp); | |
| 3485 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3486 | |
| 3487 // mismatched address type. | |
| 3488 sdp = kSdpFullString; | |
| 3489 Replace("c=IN IP4 74.125.224.39\r\n", "c=IN IP6 74.125.224.39\r\n", &sdp); | |
| 3490 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3491 | |
| 3492 sdp = kSdpFullString; | |
|
Taylor Brandstetter
2017/03/17 00:20:43
nit: Is this also "unsupported IPv6 address"? Migh
Zhi Huang
2017/03/17 23:42:07
Done.
| |
| 3493 Replace("c=IN IP4 74.125.224.39\r\n", | |
| 3494 "c=IN IP4 2001:0db8:85a3:0000:0000:8a2e:0370:7334/3\r\n", &sdp); | |
| 3495 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3496 } | |
|
Taylor Brandstetter
2017/03/17 00:20:43
There should also be a test for the serialization.
Zhi Huang
2017/03/17 23:42:07
Done.
| |
| OLD | NEW |