Chromium Code Reviews| Index: webrtc/pc/webrtcsdp_unittest.cc |
| diff --git a/webrtc/pc/webrtcsdp_unittest.cc b/webrtc/pc/webrtcsdp_unittest.cc |
| index f5cac8921f3a3fddadf0672f372ce9f2c4713d1d..b4dcd574bfa65bea466fec766593dc8e59a0f9d1 100644 |
| --- a/webrtc/pc/webrtcsdp_unittest.cc |
| +++ b/webrtc/pc/webrtcsdp_unittest.cc |
| @@ -195,7 +195,7 @@ static const char kSdpString[] = |
| "t=0 0\r\n" |
| "a=msid-semantic: WMS local_stream_1\r\n" |
| "m=audio 9 RTP/SAVPF 111 103 104\r\n" |
| - "c=IN IP4 0.0.0.0\r\n" |
| + "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.
|
| "a=rtcp:9 IN IP4 0.0.0.0\r\n" |
| "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n" |
| "a=mid:audio_content_name\r\n" |
| @@ -213,7 +213,7 @@ static const char kSdpString[] = |
| "a=ssrc:1 mslabel:local_stream_1\r\n" |
| "a=ssrc:1 label:audio_track_id_1\r\n" |
| "m=video 9 RTP/SAVPF 120\r\n" |
| - "c=IN IP4 0.0.0.0\r\n" |
| + "c=IN IP4 74.125.224.39\r\n" |
| "a=rtcp:9 IN IP4 0.0.0.0\r\n" |
| "a=ice-ufrag:ufrag_video\r\na=ice-pwd:pwd_video\r\n" |
| "a=mid:video_content_name\r\n" |
| @@ -875,6 +875,8 @@ class WebRtcSdpTest : public testing::Test { |
| audio_stream.sync_label = kStreamLabel1; |
| audio_stream.ssrcs.push_back(kAudioTrack1Ssrc); |
| audio_desc_->AddStream(audio_stream); |
| + rtc::SocketAddress audio_addr("74.125.127.126", 2345); |
| + 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'
|
| desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_desc_); |
| // VideoContentDescription |
| @@ -888,6 +890,8 @@ class WebRtcSdpTest : public testing::Test { |
| cricket::SsrcGroup ssrc_group(kFecSsrcGroupSemantics, video_stream.ssrcs); |
| video_stream.ssrc_groups.push_back(ssrc_group); |
| video_desc_->AddStream(video_stream); |
| + rtc::SocketAddress video_addr("74.125.224.39", 3457); |
| + video_desc_->set_connection_address(video_addr); |
| desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_desc_); |
| // TransportInfo |
| @@ -1079,6 +1083,9 @@ class WebRtcSdpTest : public testing::Test { |
| // Turns the existing reference description into a unified plan description, |
| // with 2 audio tracks and 3 video tracks. |
| void MakeUnifiedPlanDescription() { |
| + // The connection address for the additional tracks. |
| + 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.
|
| + |
| // Audio track 2. |
| AudioContentDescription* audio_desc_2 = CreateAudioContentDescription(); |
| StreamParams audio_track_2; |
| @@ -1087,10 +1094,10 @@ class WebRtcSdpTest : public testing::Test { |
| audio_track_2.sync_label = kStreamLabel2; |
| audio_track_2.ssrcs.push_back(kAudioTrack2Ssrc); |
| audio_desc_2->AddStream(audio_track_2); |
| + audio_desc_2->set_connection_address(connection_address); |
| desc_.AddContent(kAudioContentName2, NS_JINGLE_RTP, audio_desc_2); |
| EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| kAudioContentName2, TransportDescription(kUfragVoice2, kPwdVoice2)))); |
| - |
| // Video track 2, in stream 2. |
| VideoContentDescription* video_desc_2 = CreateVideoContentDescription(); |
| StreamParams video_track_2; |
| @@ -1099,6 +1106,7 @@ class WebRtcSdpTest : public testing::Test { |
| video_track_2.sync_label = kStreamLabel2; |
| video_track_2.ssrcs.push_back(kVideoTrack2Ssrc); |
| video_desc_2->AddStream(video_track_2); |
| + video_desc_2->set_connection_address(connection_address); |
| desc_.AddContent(kVideoContentName2, NS_JINGLE_RTP, video_desc_2); |
| EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| kVideoContentName2, TransportDescription(kUfragVideo2, kPwdVideo2)))); |
| @@ -1111,6 +1119,7 @@ class WebRtcSdpTest : public testing::Test { |
| video_track_3.sync_label = kStreamLabel2; |
| video_track_3.ssrcs.push_back(kVideoTrack3Ssrc); |
| video_desc_3->AddStream(video_track_3); |
| + video_desc_3->set_connection_address(connection_address); |
| desc_.AddContent(kVideoContentName3, NS_JINGLE_RTP, video_desc_3); |
| EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| kVideoContentName3, TransportDescription(kUfragVideo3, kPwdVideo3)))); |
| @@ -1470,6 +1479,12 @@ class WebRtcSdpTest : public testing::Test { |
| audio_desc_->Copy()); |
| video_desc_ = static_cast<VideoContentDescription*>( |
| video_desc_->Copy()); |
| + |
| + rtc::SocketAddress audio_addr("74.125.127.126", 9); |
| + rtc::SocketAddress video_addr("74.125.224.39", 9); |
| + audio_desc_->set_connection_address(audio_addr); |
| + video_desc_->set_connection_address(video_addr); |
| + |
| desc_.RemoveContentByName(kAudioContentName); |
| desc_.RemoveContentByName(kVideoContentName); |
| desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_rejected, |
| @@ -1503,6 +1518,8 @@ class WebRtcSdpTest : public testing::Test { |
| cricket::kGoogleSctpDataCodecName); |
| codec.SetParam(cricket::kCodecParamPort, kDefaultSctpPort); |
| data_desc_->AddCodec(codec); |
| + rtc::SocketAddress addr("0.0.0.0", 9); |
| + data_desc_->set_connection_address(addr); |
| desc_.AddContent(kDataContentName, NS_JINGLE_DRAFT_SCTP, data.release()); |
| EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| kDataContentName, TransportDescription(kUfragData, kPwdData)))); |
| @@ -1523,6 +1540,8 @@ class WebRtcSdpTest : public testing::Test { |
| 1, "AES_CM_128_HMAC_SHA1_80", |
| "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5", "")); |
| data_desc_->set_protocol(cricket::kMediaProtocolSavpf); |
| + rtc::SocketAddress addr("0.0.0.0", 9); |
| + data_desc_->set_connection_address(addr); |
| desc_.AddContent(kDataContentName, NS_JINGLE_RTP, data.release()); |
| EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
| kDataContentName, TransportDescription(kUfragData, kPwdData)))); |
| @@ -1801,132 +1820,16 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionEmpty) { |
| EXPECT_EQ("", webrtc::SdpSerialize(jdesc_empty, false)); |
| } |
| -// This tests serialization of SDP with only IPv6 candidates and verifies that |
| -// IPv6 is used as default address in c line according to preference. |
| -TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithIPv6Only) { |
| - // Only test 1 m line. |
| - desc_.RemoveContentByName("video_content_name"); |
| - // Stun has a high preference than local host. |
| - cricket::Candidate candidate1( |
| - cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp", |
| - rtc::SocketAddress("::1", 1234), kCandidatePriority, "", "", |
| - cricket::STUN_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1); |
| - cricket::Candidate candidate2( |
| - cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp", |
| - rtc::SocketAddress("::2", 1235), kCandidatePriority, "", "", |
| - cricket::LOCAL_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1); |
| - JsepSessionDescription jdesc(kDummyString); |
| - ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
| - |
| - // Only add the candidates to audio m line. |
| - JsepIceCandidate jice1("audio_content_name", 0, candidate1); |
| - JsepIceCandidate jice2("audio_content_name", 0, candidate2); |
| - ASSERT_TRUE(jdesc.AddCandidate(&jice1)); |
| - ASSERT_TRUE(jdesc.AddCandidate(&jice2)); |
| - std::string message = webrtc::SdpSerialize(jdesc, false); |
| - |
| - // Audio line should have a c line like this one. |
| - EXPECT_NE(message.find("c=IN IP6 ::1"), std::string::npos); |
| - // Shouldn't have a IP4 c line. |
| - EXPECT_EQ(message.find("c=IN IP4"), std::string::npos); |
| -} |
| - |
| -// This tests serialization of SDP with both IPv4 and IPv6 candidates and |
| -// verifies that IPv4 is used as default address in c line even if the |
| -// preference of IPv4 is lower. |
| -TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBothIPFamilies) { |
| - // Only test 1 m line. |
| - desc_.RemoveContentByName("video_content_name"); |
| - cricket::Candidate candidate_v4( |
| - cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp", |
| - rtc::SocketAddress("192.168.1.5", 1234), kCandidatePriority, "", "", |
| - cricket::STUN_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1); |
| - cricket::Candidate candidate_v6( |
| - cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp", |
| - rtc::SocketAddress("::1", 1234), kCandidatePriority, "", "", |
| - cricket::LOCAL_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1); |
| - JsepSessionDescription jdesc(kDummyString); |
| - ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
| - |
| - // Only add the candidates to audio m line. |
| - JsepIceCandidate jice_v4("audio_content_name", 0, candidate_v4); |
| - JsepIceCandidate jice_v6("audio_content_name", 0, candidate_v6); |
| - ASSERT_TRUE(jdesc.AddCandidate(&jice_v4)); |
| - ASSERT_TRUE(jdesc.AddCandidate(&jice_v6)); |
| - std::string message = webrtc::SdpSerialize(jdesc, false); |
| - |
| - // Audio line should have a c line like this one. |
| - EXPECT_NE(message.find("c=IN IP4 192.168.1.5"), std::string::npos); |
| - // Shouldn't have a IP6 c line. |
| - EXPECT_EQ(message.find("c=IN IP6"), std::string::npos); |
| -} |
| - |
| -// This tests serialization of SDP with both UDP and TCP candidates and |
| -// verifies that UDP is used as default address in c line even if the |
| -// preference of UDP is lower. |
| -TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBothProtocols) { |
| - // Only test 1 m line. |
| - desc_.RemoveContentByName("video_content_name"); |
| - // Stun has a high preference than local host. |
| - cricket::Candidate candidate1( |
| - cricket::ICE_CANDIDATE_COMPONENT_RTP, "tcp", |
| - rtc::SocketAddress("::1", 1234), kCandidatePriority, "", "", |
| - cricket::STUN_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1); |
| - cricket::Candidate candidate2( |
| - cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp", |
| - rtc::SocketAddress("fe80::1234:5678:abcd:ef12", 1235), kCandidatePriority, |
| - "", "", cricket::LOCAL_PORT_TYPE, kCandidateGeneration, |
| - kCandidateFoundation1); |
| - JsepSessionDescription jdesc(kDummyString); |
| - ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
| - |
| - // Only add the candidates to audio m line. |
| - JsepIceCandidate jice1("audio_content_name", 0, candidate1); |
| - JsepIceCandidate jice2("audio_content_name", 0, candidate2); |
| - ASSERT_TRUE(jdesc.AddCandidate(&jice1)); |
| - ASSERT_TRUE(jdesc.AddCandidate(&jice2)); |
| - std::string message = webrtc::SdpSerialize(jdesc, false); |
| - |
| - // Audio line should have a c line like this one. |
| - EXPECT_NE(message.find("c=IN IP6 fe80::1234:5678:abcd:ef12"), |
| - std::string::npos); |
| - // Shouldn't have a IP4 c line. |
| - EXPECT_EQ(message.find("c=IN IP4"), std::string::npos); |
| -} |
| - |
| -// This tests serialization of SDP with only TCP candidates and verifies that |
| -// null IPv4 is used as default address in c line. |
| -TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithTCPOnly) { |
| - // Only test 1 m line. |
| - desc_.RemoveContentByName("video_content_name"); |
| - // Stun has a high preference than local host. |
| - cricket::Candidate candidate1( |
| - cricket::ICE_CANDIDATE_COMPONENT_RTP, "tcp", |
| - rtc::SocketAddress("::1", 1234), kCandidatePriority, "", "", |
| - cricket::STUN_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1); |
| - cricket::Candidate candidate2( |
| - cricket::ICE_CANDIDATE_COMPONENT_RTP, "tcp", |
| - rtc::SocketAddress("::2", 1235), kCandidatePriority, "", "", |
| - cricket::LOCAL_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1); |
| - JsepSessionDescription jdesc(kDummyString); |
| - ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
| - |
| - // Only add the candidates to audio m line. |
| - JsepIceCandidate jice1("audio_content_name", 0, candidate1); |
| - JsepIceCandidate jice2("audio_content_name", 0, candidate2); |
| - ASSERT_TRUE(jdesc.AddCandidate(&jice1)); |
| - ASSERT_TRUE(jdesc.AddCandidate(&jice2)); |
| - std::string message = webrtc::SdpSerialize(jdesc, false); |
| - |
| - // Audio line should have a c line like this one when no any default exists. |
| - EXPECT_NE(message.find("c=IN IP4 0.0.0.0"), std::string::npos); |
| -} |
| - |
| // This tests serialization of SDP with a=crypto and a=fingerprint, as would be |
| // the case in a DTLS offer. |
| TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprint) { |
| AddFingerprint(); |
| JsepSessionDescription jdesc_with_fingerprint(kDummyString); |
| + |
| + rtc::SocketAddress audio_addr("74.125.127.126", 9); |
| + rtc::SocketAddress video_addr("74.125.224.39", 9); |
| + audio_desc_->set_connection_address(audio_addr); |
| + 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
|
| ASSERT_TRUE(jdesc_with_fingerprint.Initialize(desc_.Copy(), |
| kSessionId, kSessionVersion)); |
| std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint, false); |
| @@ -1946,6 +1849,11 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprintNoCryptos) { |
| AddFingerprint(); |
| RemoveCryptos(); |
| JsepSessionDescription jdesc_with_fingerprint(kDummyString); |
| + |
| + rtc::SocketAddress audio_addr("74.125.127.126", 9); |
| + rtc::SocketAddress video_addr("74.125.224.39", 9); |
| + audio_desc_->set_connection_address(audio_addr); |
| + video_desc_->set_connection_address(video_addr); |
| ASSERT_TRUE(jdesc_with_fingerprint.Initialize(desc_.Copy(), |
| kSessionId, kSessionVersion)); |
| std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint, false); |
| @@ -1964,6 +1872,11 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprintNoCryptos) { |
| TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithoutCandidates) { |
| // JsepSessionDescription with desc but without candidates. |
| JsepSessionDescription jdesc_no_candidates(kDummyString); |
| + |
| + rtc::SocketAddress audio_addr("74.125.127.126", 9); |
| + rtc::SocketAddress video_addr("74.125.224.39", 9); |
| + audio_desc_->set_connection_address(audio_addr); |
| + video_desc_->set_connection_address(video_addr); |
| ASSERT_TRUE(jdesc_no_candidates.Initialize(desc_.Copy(), kSessionId, |
| kSessionVersion)); |
| std::string message = webrtc::SdpSerialize(jdesc_no_candidates, false); |
| @@ -2058,6 +1971,10 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithRtpDataChannel) { |
| AddRtpDataChannel(); |
| JsepSessionDescription jsep_desc(kDummyString); |
| + rtc::SocketAddress audio_addr("74.125.127.126", 9); |
| + rtc::SocketAddress video_addr("74.125.224.39", 9); |
| + audio_desc_->set_connection_address(audio_addr); |
| + video_desc_->set_connection_address(video_addr); |
| ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
| std::string message = webrtc::SdpSerialize(jsep_desc, false); |
| @@ -2071,6 +1988,10 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithSctpDataChannel) { |
| AddSctpDataChannel(use_sctpmap); |
| JsepSessionDescription jsep_desc(kDummyString); |
| + rtc::SocketAddress audio_addr("74.125.127.126", 9); |
| + rtc::SocketAddress video_addr("74.125.224.39", 9); |
| + audio_desc_->set_connection_address(audio_addr); |
| + video_desc_->set_connection_address(video_addr); |
| ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
| std::string message = webrtc::SdpSerialize(jsep_desc, false); |
| @@ -2084,6 +2005,10 @@ TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { |
| AddSctpDataChannel(use_sctpmap); |
| JsepSessionDescription jsep_desc(kDummyString); |
| + rtc::SocketAddress audio_addr("74.125.127.126", 9); |
| + rtc::SocketAddress video_addr("74.125.224.39", 9); |
| + audio_desc_->set_connection_address(audio_addr); |
| + video_desc_->set_connection_address(video_addr); |
| ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
| DataContentDescription* dcdesc = static_cast<DataContentDescription*>( |
| jsep_desc.description()->GetContentDescriptionByName(kDataContentName)); |
| @@ -2114,6 +2039,10 @@ TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { |
| TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) { |
| AddRtpDataChannel(); |
| data_desc_->set_bandwidth(100*1000); |
| + rtc::SocketAddress audio_addr("74.125.127.126", 9); |
| + rtc::SocketAddress video_addr("74.125.224.39", 9); |
| + audio_desc_->set_connection_address(audio_addr); |
| + video_desc_->set_connection_address(video_addr); |
| JsepSessionDescription jsep_desc(kDummyString); |
| ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
| @@ -2131,6 +2060,10 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) { |
| TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) { |
| AddExtmap(); |
| JsepSessionDescription desc_with_extmap("dummy"); |
| + rtc::SocketAddress audio_addr("74.125.127.126", 9); |
| + rtc::SocketAddress video_addr("74.125.224.39", 9); |
| + audio_desc_->set_connection_address(audio_addr); |
| + video_desc_->set_connection_address(video_addr); |
| ASSERT_TRUE(desc_with_extmap.Initialize(desc_.Copy(), |
| kSessionId, kSessionVersion)); |
| std::string message = webrtc::SdpSerialize(desc_with_extmap, false); |
| @@ -3504,3 +3437,116 @@ TEST_F(WebRtcSdpTest, DeserializeMsidAttributeWithMissingStreamId) { |
| JsepSessionDescription jdesc_output(kDummyString); |
| EXPECT_FALSE(SdpDeserialize(kSdpWithMissingStreamId, &jdesc_output)); |
| } |
| + |
| +// Tests that if both session-level address and media-level address exist, use |
| +// the media-level address. |
| +TEST_F(WebRtcSdpTest, ParseConnectionData) { |
| + JsepSessionDescription jsep_desc(kDummyString); |
| + |
| + // Sesssion-level address. |
| + std::string sdp = kSdpFullString; |
| + InjectAfter("s=-\r\n", "c=IN IP4 192.168.0.3\r\n", &sdp); |
| + EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); |
| + |
| + // 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.
|
| + const auto& content1 = jsep_desc.description()->contents()[0]; |
| + EXPECT_EQ("74.125.127.126:2345", |
| + static_cast<cricket::MediaContentDescription*>(content1.description) |
| + ->connection_address() |
| + .ToString()); |
| + const auto& content2 = jsep_desc.description()->contents()[1]; |
| + EXPECT_EQ("74.125.224.39:3457", |
| + static_cast<cricket::MediaContentDescription*>(content2.description) |
| + ->connection_address() |
| + .ToString()); |
| +} |
| + |
| +// Tests that the session-level connection address will be used if the media |
| +// level-addresses are not specified. |
| +TEST_F(WebRtcSdpTest, ParseConnectionDataSessionLevelOnly) { |
| + JsepSessionDescription jsep_desc(kDummyString); |
| + |
| + // Sesssion-level address. |
| + std::string sdp = kSdpString; |
| + InjectAfter("s=-\r\n", "c=IN IP4 192.168.0.3\r\n", &sdp); |
| + Replace("c=IN IP4 74.125.127.126\r\n", "", &sdp); |
| + Replace("c=IN IP4 74.125.224.39\r\n", "", &sdp); |
| + EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); |
| + |
| + // 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.
|
| + const auto& content1 = jsep_desc.description()->contents()[0]; |
| + EXPECT_EQ("192.168.0.3:9", |
| + static_cast<cricket::MediaContentDescription*>(content1.description) |
| + ->connection_address() |
| + .ToString()); |
| + const auto& content2 = jsep_desc.description()->contents()[1]; |
| + EXPECT_EQ("192.168.0.3:9", |
| + static_cast<cricket::MediaContentDescription*>(content2.description) |
| + ->connection_address() |
| + .ToString()); |
| +} |
| + |
| +TEST_F(WebRtcSdpTest, ParseConnectionDataIPv6) { |
| + JsepSessionDescription jsep_desc(kDummyString); |
| + |
| + std::string sdp = kSdpString; |
| + EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); |
| + Replace("c=IN IP4 74.125.127.126\r\n", |
| + "c=IN IP6 2001:0db8:85a3:0000:0000:8a2e:0370:7335\r\n", &sdp); |
| + Replace("c=IN IP4 74.125.224.39\r\n", |
| + "c=IN IP6 2001:0db8:85a3:0000:0000:8a2e:0370:7336\r\n", &sdp); |
| + EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); |
| + const auto& content1 = jsep_desc.description()->contents()[0]; |
| + EXPECT_EQ("[2001:db8:85a3::8a2e:370:7335]:9", |
| + static_cast<cricket::MediaContentDescription*>(content1.description) |
| + ->connection_address() |
| + .ToString()); |
| + const auto& content2 = jsep_desc.description()->contents()[1]; |
| + EXPECT_EQ("[2001:db8:85a3::8a2e:370:7336]:9", |
| + static_cast<cricket::MediaContentDescription*>(content2.description) |
| + ->connection_address() |
| + .ToString()); |
| +} |
| + |
| +// Test that the invalid or unsupprted connection data cannot be parsed. |
| +TEST_F(WebRtcSdpTest, ParseConnectionDataFailure) { |
| + JsepSessionDescription jsep_desc(kDummyString); |
| + std::string sdp = kSdpString; |
| + EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); |
| + |
| + // Unsupported multicast IPv4 address. |
| + sdp = kSdpFullString; |
| + Replace("c=IN IP4 74.125.224.39\r\n", "c=IN IP4 74.125.224.39/127\r\n", &sdp); |
| + EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); |
| + |
| + // Unsupported multicast IPv6 address. |
| + sdp = kSdpFullString; |
| + Replace("c=IN IP4 74.125.224.39\r\n", "c=IN IP6 ::1/3\r\n", &sdp); |
| + EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); |
| + |
| + // Mismatched address type. |
| + sdp = kSdpFullString; |
| + Replace("c=IN IP4 74.125.224.39\r\n", "c=IN IP6 74.125.224.39\r\n", &sdp); |
| + EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); |
| + |
| + sdp = kSdpFullString; |
| + Replace("c=IN IP4 74.125.224.39\r\n", |
| + "c=IN IP4 2001:0db8:85a3:0000:0000:8a2e:0370:7334\r\n", &sdp); |
| + EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); |
| +} |
| + |
| +TEST_F(WebRtcSdpTest, SerializeAndDeserializeWithConneceionAddress) { |
|
Taylor Brandstetter
2017/03/18 00:46:08
Spelling of "connection"
Zhi Huang
2017/03/18 19:27:55
Done.
|
| + // Serialization. |
| + std::string message = webrtc::SdpSerialize(jdesc_, false); |
| + // Deserialization. |
| + JsepSessionDescription jdesc(kDummyString); |
| + EXPECT_TRUE(SdpDeserialize(message, &jdesc)); |
| + auto audio_desc = static_cast<cricket::MediaContentDescription*>( |
| + jdesc.description()->GetContentByName(kAudioContentName)->description); |
| + auto video_desc = static_cast<cricket::MediaContentDescription*>( |
| + jdesc.description()->GetContentByName(kVideoContentName)->description); |
| + EXPECT_EQ(audio_desc_->connection_address().ToString(), |
| + audio_desc->connection_address().ToString()); |
| + EXPECT_EQ(video_desc_->connection_address().ToString(), |
| + video_desc->connection_address().ToString()); |
| +} |