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 857 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/20 18:29:58
nit (slash question): I still don't see that this
Zhi Huang
2017/03/21 03:43:12
The jdesc_ is initialized based on a copy of desc_
| |
| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1083 AudioContentDescription* audio_desc_2 = CreateAudioContentDescription(); | 1087 AudioContentDescription* audio_desc_2 = CreateAudioContentDescription(); |
| 1084 StreamParams audio_track_2; | 1088 StreamParams audio_track_2; |
| 1085 audio_track_2.id = kAudioTrackId2; | 1089 audio_track_2.id = kAudioTrackId2; |
| 1086 audio_track_2.cname = kStream2Cname; | 1090 audio_track_2.cname = kStream2Cname; |
| 1087 audio_track_2.sync_label = kStreamLabel2; | 1091 audio_track_2.sync_label = kStreamLabel2; |
| 1088 audio_track_2.ssrcs.push_back(kAudioTrack2Ssrc); | 1092 audio_track_2.ssrcs.push_back(kAudioTrack2Ssrc); |
| 1089 audio_desc_2->AddStream(audio_track_2); | 1093 audio_desc_2->AddStream(audio_track_2); |
| 1090 desc_.AddContent(kAudioContentName2, NS_JINGLE_RTP, audio_desc_2); | 1094 desc_.AddContent(kAudioContentName2, NS_JINGLE_RTP, audio_desc_2); |
| 1091 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 1095 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| 1092 kAudioContentName2, TransportDescription(kUfragVoice2, kPwdVoice2)))); | 1096 kAudioContentName2, TransportDescription(kUfragVoice2, kPwdVoice2)))); |
| 1093 | |
| 1094 // Video track 2, in stream 2. | 1097 // Video track 2, in stream 2. |
| 1095 VideoContentDescription* video_desc_2 = CreateVideoContentDescription(); | 1098 VideoContentDescription* video_desc_2 = CreateVideoContentDescription(); |
| 1096 StreamParams video_track_2; | 1099 StreamParams video_track_2; |
| 1097 video_track_2.id = kVideoTrackId2; | 1100 video_track_2.id = kVideoTrackId2; |
| 1098 video_track_2.cname = kStream2Cname; | 1101 video_track_2.cname = kStream2Cname; |
| 1099 video_track_2.sync_label = kStreamLabel2; | 1102 video_track_2.sync_label = kStreamLabel2; |
| 1100 video_track_2.ssrcs.push_back(kVideoTrack2Ssrc); | 1103 video_track_2.ssrcs.push_back(kVideoTrack2Ssrc); |
| 1101 video_desc_2->AddStream(video_track_2); | 1104 video_desc_2->AddStream(video_track_2); |
| 1102 desc_.AddContent(kVideoContentName2, NS_JINGLE_RTP, video_desc_2); | 1105 desc_.AddContent(kVideoContentName2, NS_JINGLE_RTP, video_desc_2); |
| 1103 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 1106 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1463 std::string message = webrtc::SdpSerialize(jdesc_, false); | 1466 std::string message = webrtc::SdpSerialize(jdesc_, false); |
| 1464 EXPECT_EQ(new_sdp, message); | 1467 EXPECT_EQ(new_sdp, message); |
| 1465 return true; | 1468 return true; |
| 1466 } | 1469 } |
| 1467 | 1470 |
| 1468 bool TestSerializeRejected(bool audio_rejected, bool video_rejected) { | 1471 bool TestSerializeRejected(bool audio_rejected, bool video_rejected) { |
| 1469 audio_desc_ = static_cast<AudioContentDescription*>( | 1472 audio_desc_ = static_cast<AudioContentDescription*>( |
| 1470 audio_desc_->Copy()); | 1473 audio_desc_->Copy()); |
| 1471 video_desc_ = static_cast<VideoContentDescription*>( | 1474 video_desc_ = static_cast<VideoContentDescription*>( |
| 1472 video_desc_->Copy()); | 1475 video_desc_->Copy()); |
| 1476 | |
| 1473 desc_.RemoveContentByName(kAudioContentName); | 1477 desc_.RemoveContentByName(kAudioContentName); |
| 1474 desc_.RemoveContentByName(kVideoContentName); | 1478 desc_.RemoveContentByName(kVideoContentName); |
| 1475 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_rejected, | 1479 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_rejected, |
| 1476 audio_desc_); | 1480 audio_desc_); |
| 1477 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_rejected, | 1481 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_rejected, |
| 1478 video_desc_); | 1482 video_desc_); |
| 1479 SetIceUfragPwd(kAudioContentName, audio_rejected ? "" : kUfragVoice, | 1483 SetIceUfragPwd(kAudioContentName, audio_rejected ? "" : kUfragVoice, |
| 1480 audio_rejected ? "" : kPwdVoice); | 1484 audio_rejected ? "" : kPwdVoice); |
| 1481 SetIceUfragPwd(kVideoContentName, video_rejected ? "" : kUfragVideo, | 1485 SetIceUfragPwd(kVideoContentName, video_rejected ? "" : kUfragVideo, |
| 1482 video_rejected ? "" : kPwdVideo); | 1486 video_rejected ? "" : kPwdVideo); |
| 1483 | 1487 |
| 1484 std::string new_sdp = kSdpString; | 1488 std::string new_sdp = kSdpString; |
| 1485 ReplaceRejected(audio_rejected, video_rejected, &new_sdp); | 1489 ReplaceRejected(audio_rejected, video_rejected, &new_sdp); |
| 1486 | 1490 |
| 1487 JsepSessionDescription jdesc_no_candidates(kDummyString); | 1491 JsepSessionDescription jdesc_no_candidates(kDummyString); |
| 1488 if (!jdesc_no_candidates.Initialize(desc_.Copy(), kSessionId, | 1492 MakeDescriptionWithoutCandidates(&jdesc_no_candidates); |
| 1489 kSessionVersion)) { | |
| 1490 return false; | |
| 1491 } | |
| 1492 std::string message = webrtc::SdpSerialize(jdesc_no_candidates, false); | 1493 std::string message = webrtc::SdpSerialize(jdesc_no_candidates, false); |
| 1493 EXPECT_EQ(new_sdp, message); | 1494 EXPECT_EQ(new_sdp, message); |
| 1494 return true; | 1495 return true; |
| 1495 } | 1496 } |
| 1496 | 1497 |
| 1497 void AddSctpDataChannel(bool use_sctpmap) { | 1498 void AddSctpDataChannel(bool use_sctpmap) { |
| 1498 std::unique_ptr<DataContentDescription> data(new DataContentDescription()); | 1499 std::unique_ptr<DataContentDescription> data(new DataContentDescription()); |
| 1499 data_desc_ = data.get(); | 1500 data_desc_ = data.get(); |
| 1500 data_desc_->set_use_sctpmap(use_sctpmap); | 1501 data_desc_->set_use_sctpmap(use_sctpmap); |
| 1501 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp); | 1502 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1759 // the serializer sufficiently. | 1760 // the serializer sufficiently. |
| 1760 void TestSerialize(const JsepSessionDescription& jdesc, | 1761 void TestSerialize(const JsepSessionDescription& jdesc, |
| 1761 bool unified_plan_sdp) { | 1762 bool unified_plan_sdp) { |
| 1762 std::string message = webrtc::SdpSerialize(jdesc, unified_plan_sdp); | 1763 std::string message = webrtc::SdpSerialize(jdesc, unified_plan_sdp); |
| 1763 JsepSessionDescription jdesc_output_des(kDummyString); | 1764 JsepSessionDescription jdesc_output_des(kDummyString); |
| 1764 SdpParseError error; | 1765 SdpParseError error; |
| 1765 EXPECT_TRUE(webrtc::SdpDeserialize(message, &jdesc_output_des, &error)); | 1766 EXPECT_TRUE(webrtc::SdpDeserialize(message, &jdesc_output_des, &error)); |
| 1766 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output_des)); | 1767 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output_des)); |
| 1767 } | 1768 } |
| 1768 | 1769 |
| 1770 void MakeDescriptionWithoutCandidates(JsepSessionDescription* jdesc) { | |
| 1771 rtc::SocketAddress audio_addr("0.0.0.0", 9); | |
|
Taylor Brandstetter
2017/03/20 18:29:58
nit: Could add a comment explaining this. "Calling
Zhi Huang
2017/03/21 03:43:12
Done.
| |
| 1772 rtc::SocketAddress video_addr("0.0.0.0", 9); | |
| 1773 audio_desc_->set_connection_address(audio_addr); | |
| 1774 video_desc_->set_connection_address(video_addr); | |
| 1775 ASSERT_TRUE(jdesc->Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | |
| 1776 } | |
| 1777 | |
| 1769 protected: | 1778 protected: |
| 1770 SessionDescription desc_; | 1779 SessionDescription desc_; |
| 1771 AudioContentDescription* audio_desc_; | 1780 AudioContentDescription* audio_desc_; |
| 1772 VideoContentDescription* video_desc_; | 1781 VideoContentDescription* video_desc_; |
| 1773 DataContentDescription* data_desc_; | 1782 DataContentDescription* data_desc_; |
| 1774 Candidates candidates_; | 1783 Candidates candidates_; |
| 1775 std::unique_ptr<IceCandidateInterface> jcandidate_; | 1784 std::unique_ptr<IceCandidateInterface> jcandidate_; |
| 1776 JsepSessionDescription jdesc_; | 1785 JsepSessionDescription jdesc_; |
| 1777 }; | 1786 }; |
| 1778 | 1787 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1794 // SessionDescription with desc and candidates. | 1803 // SessionDescription with desc and candidates. |
| 1795 std::string message = webrtc::SdpSerialize(jdesc_, false); | 1804 std::string message = webrtc::SdpSerialize(jdesc_, false); |
| 1796 TestMismatch(std::string(kSdpFullString), message); | 1805 TestMismatch(std::string(kSdpFullString), message); |
| 1797 } | 1806 } |
| 1798 | 1807 |
| 1799 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionEmpty) { | 1808 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionEmpty) { |
| 1800 JsepSessionDescription jdesc_empty(kDummyString); | 1809 JsepSessionDescription jdesc_empty(kDummyString); |
| 1801 EXPECT_EQ("", webrtc::SdpSerialize(jdesc_empty, false)); | 1810 EXPECT_EQ("", webrtc::SdpSerialize(jdesc_empty, false)); |
| 1802 } | 1811 } |
| 1803 | 1812 |
| 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 | 1813 // This tests serialization of SDP with a=crypto and a=fingerprint, as would be |
| 1926 // the case in a DTLS offer. | 1814 // the case in a DTLS offer. |
| 1927 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprint) { | 1815 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprint) { |
| 1928 AddFingerprint(); | 1816 AddFingerprint(); |
| 1929 JsepSessionDescription jdesc_with_fingerprint(kDummyString); | 1817 JsepSessionDescription jdesc_with_fingerprint(kDummyString); |
| 1930 ASSERT_TRUE(jdesc_with_fingerprint.Initialize(desc_.Copy(), | 1818 MakeDescriptionWithoutCandidates(&jdesc_with_fingerprint); |
| 1931 kSessionId, kSessionVersion)); | |
| 1932 std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint, false); | 1819 std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint, false); |
| 1933 | 1820 |
| 1934 std::string sdp_with_fingerprint = kSdpString; | 1821 std::string sdp_with_fingerprint = kSdpString; |
| 1935 InjectAfter(kAttributeIcePwdVoice, | 1822 InjectAfter(kAttributeIcePwdVoice, |
| 1936 kFingerprint, &sdp_with_fingerprint); | 1823 kFingerprint, &sdp_with_fingerprint); |
| 1937 InjectAfter(kAttributeIcePwdVideo, | 1824 InjectAfter(kAttributeIcePwdVideo, |
| 1938 kFingerprint, &sdp_with_fingerprint); | 1825 kFingerprint, &sdp_with_fingerprint); |
| 1939 | 1826 |
| 1940 EXPECT_EQ(sdp_with_fingerprint, message); | 1827 EXPECT_EQ(sdp_with_fingerprint, message); |
| 1941 } | 1828 } |
| 1942 | 1829 |
| 1943 // This tests serialization of SDP with a=fingerprint with no a=crypto, as would | 1830 // This tests serialization of SDP with a=fingerprint with no a=crypto, as would |
| 1944 // be the case in a DTLS answer. | 1831 // be the case in a DTLS answer. |
| 1945 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprintNoCryptos) { | 1832 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprintNoCryptos) { |
| 1946 AddFingerprint(); | 1833 AddFingerprint(); |
| 1947 RemoveCryptos(); | 1834 RemoveCryptos(); |
| 1948 JsepSessionDescription jdesc_with_fingerprint(kDummyString); | 1835 JsepSessionDescription jdesc_with_fingerprint(kDummyString); |
| 1949 ASSERT_TRUE(jdesc_with_fingerprint.Initialize(desc_.Copy(), | 1836 MakeDescriptionWithoutCandidates(&jdesc_with_fingerprint); |
| 1950 kSessionId, kSessionVersion)); | |
| 1951 std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint, false); | 1837 std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint, false); |
| 1952 | 1838 |
| 1953 std::string sdp_with_fingerprint = kSdpString; | 1839 std::string sdp_with_fingerprint = kSdpString; |
| 1954 Replace(kAttributeCryptoVoice, "", &sdp_with_fingerprint); | 1840 Replace(kAttributeCryptoVoice, "", &sdp_with_fingerprint); |
| 1955 Replace(kAttributeCryptoVideo, "", &sdp_with_fingerprint); | 1841 Replace(kAttributeCryptoVideo, "", &sdp_with_fingerprint); |
| 1956 InjectAfter(kAttributeIcePwdVoice, | 1842 InjectAfter(kAttributeIcePwdVoice, |
| 1957 kFingerprint, &sdp_with_fingerprint); | 1843 kFingerprint, &sdp_with_fingerprint); |
| 1958 InjectAfter(kAttributeIcePwdVideo, | 1844 InjectAfter(kAttributeIcePwdVideo, |
| 1959 kFingerprint, &sdp_with_fingerprint); | 1845 kFingerprint, &sdp_with_fingerprint); |
| 1960 | 1846 |
| 1961 EXPECT_EQ(sdp_with_fingerprint, message); | 1847 EXPECT_EQ(sdp_with_fingerprint, message); |
| 1962 } | 1848 } |
| 1963 | 1849 |
| 1964 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithoutCandidates) { | 1850 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithoutCandidates) { |
| 1965 // JsepSessionDescription with desc but without candidates. | 1851 // JsepSessionDescription with desc but without candidates. |
| 1966 JsepSessionDescription jdesc_no_candidates(kDummyString); | 1852 JsepSessionDescription jdesc_no_candidates(kDummyString); |
| 1967 ASSERT_TRUE(jdesc_no_candidates.Initialize(desc_.Copy(), kSessionId, | 1853 MakeDescriptionWithoutCandidates(&jdesc_no_candidates); |
| 1968 kSessionVersion)); | |
| 1969 std::string message = webrtc::SdpSerialize(jdesc_no_candidates, false); | 1854 std::string message = webrtc::SdpSerialize(jdesc_no_candidates, false); |
| 1970 EXPECT_EQ(std::string(kSdpString), message); | 1855 EXPECT_EQ(std::string(kSdpString), message); |
| 1971 } | 1856 } |
| 1972 | 1857 |
| 1973 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBundle) { | 1858 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBundle) { |
| 1974 ContentGroup group(cricket::GROUP_TYPE_BUNDLE); | 1859 ContentGroup group(cricket::GROUP_TYPE_BUNDLE); |
| 1975 group.AddContentName(kAudioContentName); | 1860 group.AddContentName(kAudioContentName); |
| 1976 group.AddContentName(kVideoContentName); | 1861 group.AddContentName(kVideoContentName); |
| 1977 desc_.AddGroup(group); | 1862 desc_.AddGroup(group); |
| 1978 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), | 1863 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2051 } | 1936 } |
| 2052 | 1937 |
| 2053 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithAudioVideoRejected) { | 1938 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithAudioVideoRejected) { |
| 2054 EXPECT_TRUE(TestSerializeRejected(true, true)); | 1939 EXPECT_TRUE(TestSerializeRejected(true, true)); |
| 2055 } | 1940 } |
| 2056 | 1941 |
| 2057 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithRtpDataChannel) { | 1942 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithRtpDataChannel) { |
| 2058 AddRtpDataChannel(); | 1943 AddRtpDataChannel(); |
| 2059 JsepSessionDescription jsep_desc(kDummyString); | 1944 JsepSessionDescription jsep_desc(kDummyString); |
| 2060 | 1945 |
| 2061 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 1946 MakeDescriptionWithoutCandidates(&jsep_desc); |
| 2062 std::string message = webrtc::SdpSerialize(jsep_desc, false); | 1947 std::string message = webrtc::SdpSerialize(jsep_desc, false); |
| 2063 | 1948 |
| 2064 std::string expected_sdp = kSdpString; | 1949 std::string expected_sdp = kSdpString; |
| 2065 expected_sdp.append(kSdpRtpDataChannelString); | 1950 expected_sdp.append(kSdpRtpDataChannelString); |
| 2066 EXPECT_EQ(expected_sdp, message); | 1951 EXPECT_EQ(expected_sdp, message); |
| 2067 } | 1952 } |
| 2068 | 1953 |
| 2069 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithSctpDataChannel) { | 1954 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithSctpDataChannel) { |
| 2070 bool use_sctpmap = true; | 1955 bool use_sctpmap = true; |
| 2071 AddSctpDataChannel(use_sctpmap); | 1956 AddSctpDataChannel(use_sctpmap); |
| 2072 JsepSessionDescription jsep_desc(kDummyString); | 1957 JsepSessionDescription jsep_desc(kDummyString); |
| 2073 | 1958 |
| 2074 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 1959 MakeDescriptionWithoutCandidates(&jsep_desc); |
| 2075 std::string message = webrtc::SdpSerialize(jsep_desc, false); | 1960 std::string message = webrtc::SdpSerialize(jsep_desc, false); |
| 2076 | 1961 |
| 2077 std::string expected_sdp = kSdpString; | 1962 std::string expected_sdp = kSdpString; |
| 2078 expected_sdp.append(kSdpSctpDataChannelString); | 1963 expected_sdp.append(kSdpSctpDataChannelString); |
| 2079 EXPECT_EQ(message, expected_sdp); | 1964 EXPECT_EQ(message, expected_sdp); |
| 2080 } | 1965 } |
| 2081 | 1966 |
| 2082 TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { | 1967 TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { |
| 2083 bool use_sctpmap = true; | 1968 bool use_sctpmap = true; |
| 2084 AddSctpDataChannel(use_sctpmap); | 1969 AddSctpDataChannel(use_sctpmap); |
| 2085 JsepSessionDescription jsep_desc(kDummyString); | 1970 JsepSessionDescription jsep_desc(kDummyString); |
| 2086 | 1971 MakeDescriptionWithoutCandidates(&jsep_desc); |
| 2087 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | |
| 2088 DataContentDescription* dcdesc = static_cast<DataContentDescription*>( | 1972 DataContentDescription* dcdesc = static_cast<DataContentDescription*>( |
| 2089 jsep_desc.description()->GetContentDescriptionByName(kDataContentName)); | 1973 jsep_desc.description()->GetContentDescriptionByName(kDataContentName)); |
| 2090 | 1974 |
| 2091 const int kNewPort = 1234; | 1975 const int kNewPort = 1234; |
| 2092 cricket::DataCodec codec(cricket::kGoogleSctpDataCodecPlType, | 1976 cricket::DataCodec codec(cricket::kGoogleSctpDataCodecPlType, |
| 2093 cricket::kGoogleSctpDataCodecName); | 1977 cricket::kGoogleSctpDataCodecName); |
| 2094 codec.SetParam(cricket::kCodecParamPort, kNewPort); | 1978 codec.SetParam(cricket::kCodecParamPort, kNewPort); |
| 2095 dcdesc->AddOrReplaceCodec(codec); | 1979 dcdesc->AddOrReplaceCodec(codec); |
| 2096 | 1980 |
| 2097 std::string message = webrtc::SdpSerialize(jsep_desc, false); | 1981 std::string message = webrtc::SdpSerialize(jsep_desc, false); |
| 2098 | 1982 |
| 2099 std::string expected_sdp = kSdpString; | 1983 std::string expected_sdp = kSdpString; |
| 2100 expected_sdp.append(kSdpSctpDataChannelString); | 1984 expected_sdp.append(kSdpSctpDataChannelString); |
| 2101 | 1985 |
| 2102 char default_portstr[16]; | 1986 char default_portstr[16]; |
| 2103 char new_portstr[16]; | 1987 char new_portstr[16]; |
| 2104 rtc::sprintfn(default_portstr, sizeof(default_portstr), "%d", | 1988 rtc::sprintfn(default_portstr, sizeof(default_portstr), "%d", |
| 2105 kDefaultSctpPort); | 1989 kDefaultSctpPort); |
| 2106 rtc::sprintfn(new_portstr, sizeof(new_portstr), "%d", kNewPort); | 1990 rtc::sprintfn(new_portstr, sizeof(new_portstr), "%d", kNewPort); |
| 2107 rtc::replace_substrs(default_portstr, strlen(default_portstr), | 1991 rtc::replace_substrs(default_portstr, strlen(default_portstr), |
| 2108 new_portstr, strlen(new_portstr), | 1992 new_portstr, strlen(new_portstr), |
| 2109 &expected_sdp); | 1993 &expected_sdp); |
| 2110 | 1994 |
| 2111 EXPECT_EQ(expected_sdp, message); | 1995 EXPECT_EQ(expected_sdp, message); |
| 2112 } | 1996 } |
| 2113 | 1997 |
| 2114 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) { | 1998 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) { |
| 1999 JsepSessionDescription jsep_desc(kDummyString); | |
| 2115 AddRtpDataChannel(); | 2000 AddRtpDataChannel(); |
| 2116 data_desc_->set_bandwidth(100*1000); | 2001 data_desc_->set_bandwidth(100*1000); |
| 2117 JsepSessionDescription jsep_desc(kDummyString); | 2002 MakeDescriptionWithoutCandidates(&jsep_desc); |
| 2118 | |
| 2119 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | |
| 2120 std::string message = webrtc::SdpSerialize(jsep_desc, false); | 2003 std::string message = webrtc::SdpSerialize(jsep_desc, false); |
| 2121 | 2004 |
| 2122 std::string expected_sdp = kSdpString; | 2005 std::string expected_sdp = kSdpString; |
| 2123 expected_sdp.append(kSdpRtpDataChannelString); | 2006 expected_sdp.append(kSdpRtpDataChannelString); |
| 2124 // Serializing data content shouldn't ignore bandwidth settings. | 2007 // 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", | 2008 InjectAfter("m=application 9 RTP/SAVPF 101\r\nc=IN IP4 0.0.0.0\r\n", |
| 2126 "b=AS:100\r\n", | 2009 "b=AS:100\r\n", |
| 2127 &expected_sdp); | 2010 &expected_sdp); |
| 2128 EXPECT_EQ(expected_sdp, message); | 2011 EXPECT_EQ(expected_sdp, message); |
| 2129 } | 2012 } |
| 2130 | 2013 |
| 2131 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) { | 2014 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) { |
| 2132 AddExtmap(); | 2015 AddExtmap(); |
| 2133 JsepSessionDescription desc_with_extmap("dummy"); | 2016 JsepSessionDescription desc_with_extmap("dummy"); |
| 2134 ASSERT_TRUE(desc_with_extmap.Initialize(desc_.Copy(), | 2017 MakeDescriptionWithoutCandidates(&desc_with_extmap); |
| 2135 kSessionId, kSessionVersion)); | |
| 2136 std::string message = webrtc::SdpSerialize(desc_with_extmap, false); | 2018 std::string message = webrtc::SdpSerialize(desc_with_extmap, false); |
| 2137 | 2019 |
| 2138 std::string sdp_with_extmap = kSdpString; | 2020 std::string sdp_with_extmap = kSdpString; |
| 2139 InjectAfter("a=mid:audio_content_name\r\n", | 2021 InjectAfter("a=mid:audio_content_name\r\n", |
| 2140 kExtmap, &sdp_with_extmap); | 2022 kExtmap, &sdp_with_extmap); |
| 2141 InjectAfter("a=mid:video_content_name\r\n", | 2023 InjectAfter("a=mid:video_content_name\r\n", |
| 2142 kExtmap, &sdp_with_extmap); | 2024 kExtmap, &sdp_with_extmap); |
| 2143 | 2025 |
| 2144 EXPECT_EQ(sdp_with_extmap, message); | 2026 EXPECT_EQ(sdp_with_extmap, message); |
| 2145 } | 2027 } |
| (...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3497 "s=-\r\n" | 3379 "s=-\r\n" |
| 3498 "t=0 0\r\n" | 3380 "t=0 0\r\n" |
| 3499 "m=audio 9 RTP/SAVPF 111\r\n" | 3381 "m=audio 9 RTP/SAVPF 111\r\n" |
| 3500 "c=IN IP4 0.0.0.0\r\n" | 3382 "c=IN IP4 0.0.0.0\r\n" |
| 3501 "a=rtpmap:111 opus/48000/2\r\n" | 3383 "a=rtpmap:111 opus/48000/2\r\n" |
| 3502 "a=msid: track_id\r\n"; | 3384 "a=msid: track_id\r\n"; |
| 3503 | 3385 |
| 3504 JsepSessionDescription jdesc_output(kDummyString); | 3386 JsepSessionDescription jdesc_output(kDummyString); |
| 3505 EXPECT_FALSE(SdpDeserialize(kSdpWithMissingStreamId, &jdesc_output)); | 3387 EXPECT_FALSE(SdpDeserialize(kSdpWithMissingStreamId, &jdesc_output)); |
| 3506 } | 3388 } |
| 3389 | |
| 3390 // Tests that if both session-level address and media-level address exist, use | |
| 3391 // the media-level address. | |
| 3392 TEST_F(WebRtcSdpTest, ParseConnectionData) { | |
| 3393 JsepSessionDescription jsep_desc(kDummyString); | |
| 3394 | |
| 3395 // Sesssion-level address. | |
| 3396 std::string sdp = kSdpFullString; | |
| 3397 InjectAfter("s=-\r\n", "c=IN IP4 192.168.0.3\r\n", &sdp); | |
| 3398 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3399 | |
| 3400 const auto& content1 = jsep_desc.description()->contents()[0]; | |
| 3401 EXPECT_EQ("74.125.127.126:2345", | |
| 3402 static_cast<cricket::MediaContentDescription*>(content1.description) | |
| 3403 ->connection_address() | |
| 3404 .ToString()); | |
| 3405 const auto& content2 = jsep_desc.description()->contents()[1]; | |
| 3406 EXPECT_EQ("74.125.224.39:3457", | |
| 3407 static_cast<cricket::MediaContentDescription*>(content2.description) | |
| 3408 ->connection_address() | |
| 3409 .ToString()); | |
| 3410 } | |
| 3411 | |
| 3412 // Tests that the session-level connection address will be used if the media | |
| 3413 // level-addresses are not specified. | |
| 3414 TEST_F(WebRtcSdpTest, ParseConnectionDataSessionLevelOnly) { | |
| 3415 JsepSessionDescription jsep_desc(kDummyString); | |
| 3416 | |
| 3417 // Sesssion-level address. | |
| 3418 std::string sdp = kSdpString; | |
| 3419 InjectAfter("s=-\r\n", "c=IN IP4 192.168.0.3\r\n", &sdp); | |
| 3420 // Remove the media level addresses. | |
| 3421 Replace("c=IN IP4 0.0.0.0\r\n", "", &sdp); | |
| 3422 Replace("c=IN IP4 0.0.0.0\r\n", "", &sdp); | |
| 3423 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3424 | |
| 3425 const auto& content1 = jsep_desc.description()->contents()[0]; | |
| 3426 EXPECT_EQ("192.168.0.3:9", | |
| 3427 static_cast<cricket::MediaContentDescription*>(content1.description) | |
| 3428 ->connection_address() | |
| 3429 .ToString()); | |
| 3430 const auto& content2 = jsep_desc.description()->contents()[1]; | |
| 3431 EXPECT_EQ("192.168.0.3:9", | |
| 3432 static_cast<cricket::MediaContentDescription*>(content2.description) | |
| 3433 ->connection_address() | |
| 3434 .ToString()); | |
| 3435 } | |
| 3436 | |
| 3437 TEST_F(WebRtcSdpTest, ParseConnectionDataIPv6) { | |
| 3438 JsepSessionDescription jsep_desc(kDummyString); | |
| 3439 | |
| 3440 std::string sdp = kSdpString; | |
| 3441 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3442 Replace("m=audio 9 RTP/SAVPF 111 103 104\r\nc=IN IP4 0.0.0.0\r\n", | |
| 3443 "m=audio 9 RTP/SAVPF 111 103 104\r\nc=IN IP6 " | |
| 3444 "2001:0db8:85a3:0000:0000:8a2e:0370:7335\r\n", | |
| 3445 &sdp); | |
| 3446 Replace("m=video 9 RTP/SAVPF 120\r\nc=IN IP4 0.0.0.0\r\n", | |
| 3447 "m=video 9 RTP/SAVPF 120\r\nc=IN IP6 " | |
| 3448 "2001:0db8:85a3:0000:0000:8a2e:0370:7336\r\n", | |
| 3449 &sdp); | |
| 3450 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3451 const auto& content1 = jsep_desc.description()->contents()[0]; | |
| 3452 EXPECT_EQ("[2001:db8:85a3::8a2e:370:7335]:9", | |
| 3453 static_cast<cricket::MediaContentDescription*>(content1.description) | |
| 3454 ->connection_address() | |
| 3455 .ToString()); | |
| 3456 const auto& content2 = jsep_desc.description()->contents()[1]; | |
| 3457 EXPECT_EQ("[2001:db8:85a3::8a2e:370:7336]:9", | |
| 3458 static_cast<cricket::MediaContentDescription*>(content2.description) | |
| 3459 ->connection_address() | |
| 3460 .ToString()); | |
| 3461 } | |
| 3462 | |
| 3463 // Test that the invalid or unsupprted connection data cannot be parsed. | |
| 3464 TEST_F(WebRtcSdpTest, ParseConnectionDataFailure) { | |
| 3465 JsepSessionDescription jsep_desc(kDummyString); | |
| 3466 std::string sdp = kSdpString; | |
| 3467 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3468 | |
| 3469 // Unsupported multicast IPv4 address. | |
| 3470 sdp = kSdpFullString; | |
| 3471 Replace("c=IN IP4 74.125.224.39\r\n", "c=IN IP4 74.125.224.39/127\r\n", &sdp); | |
| 3472 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3473 | |
| 3474 // Unsupported multicast IPv6 address. | |
| 3475 sdp = kSdpFullString; | |
| 3476 Replace("c=IN IP4 74.125.224.39\r\n", "c=IN IP6 ::1/3\r\n", &sdp); | |
| 3477 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3478 | |
| 3479 // Mismatched address type. | |
| 3480 sdp = kSdpFullString; | |
| 3481 Replace("c=IN IP4 74.125.224.39\r\n", "c=IN IP6 74.125.224.39\r\n", &sdp); | |
| 3482 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3483 | |
| 3484 sdp = kSdpFullString; | |
| 3485 Replace("c=IN IP4 74.125.224.39\r\n", | |
| 3486 "c=IN IP4 2001:0db8:85a3:0000:0000:8a2e:0370:7334\r\n", &sdp); | |
| 3487 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3488 } | |
| 3489 | |
| 3490 TEST_F(WebRtcSdpTest, SerializeAndDeserializeWithConnectionAddress) { | |
| 3491 JsepSessionDescription expected_jsep(kDummyString); | |
| 3492 MakeDescriptionWithoutCandidates(&expected_jsep); | |
| 3493 // Serialization. | |
| 3494 std::string message = webrtc::SdpSerialize(expected_jsep, false); | |
| 3495 // Deserialization. | |
| 3496 JsepSessionDescription jdesc(kDummyString); | |
| 3497 EXPECT_TRUE(SdpDeserialize(message, &jdesc)); | |
| 3498 auto audio_desc = static_cast<cricket::MediaContentDescription*>( | |
| 3499 jdesc.description()->GetContentByName(kAudioContentName)->description); | |
| 3500 auto video_desc = static_cast<cricket::MediaContentDescription*>( | |
| 3501 jdesc.description()->GetContentByName(kVideoContentName)->description); | |
| 3502 EXPECT_EQ(audio_desc_->connection_address().ToString(), | |
| 3503 audio_desc->connection_address().ToString()); | |
| 3504 EXPECT_EQ(video_desc_->connection_address().ToString(), | |
| 3505 video_desc->connection_address().ToString()); | |
| 3506 } | |
| OLD | NEW |