OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 static const char kSdpTcpInvalidCandidate[] = | 389 static const char kSdpTcpInvalidCandidate[] = |
390 "candidate:a0+B/1 1 tcp 2130706432 192.168.1.5 9 typ host " | 390 "candidate:a0+B/1 1 tcp 2130706432 192.168.1.5 9 typ host " |
391 "tcptype invalid generation 2"; | 391 "tcptype invalid generation 2"; |
392 | 392 |
393 // One candidate reference string with IPV6 address. | 393 // One candidate reference string with IPV6 address. |
394 static const char kRawIPV6Candidate[] = | 394 static const char kRawIPV6Candidate[] = |
395 "candidate:a0+B/1 1 udp 2130706432 " | 395 "candidate:a0+B/1 1 udp 2130706432 " |
396 "abcd::abcd::abcd::abcd::abcd::abcd::abcd::abcd 1234 typ host generation 2"; | 396 "abcd::abcd::abcd::abcd::abcd::abcd::abcd::abcd 1234 typ host generation 2"; |
397 | 397 |
398 // One candidate reference string. | 398 // One candidate reference string. |
399 static const char kSdpOneCandidateOldFormat[] = | 399 static const char kSdpOneCandidateWithUfragPwd[] = |
400 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host network_name" | 400 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host network_name" |
401 " eth0 username user_rtp password password_rtp generation 2\r\n"; | 401 " eth0 ufrag user_rtp pwd password_rtp generation 2\r\n"; |
402 | 402 |
403 // Session id and version | 403 // Session id and version |
404 static const char kSessionId[] = "18446744069414584320"; | 404 static const char kSessionId[] = "18446744069414584320"; |
405 static const char kSessionVersion[] = "18446462598732840960"; | 405 static const char kSessionVersion[] = "18446462598732840960"; |
406 | 406 |
407 // Ice options | 407 // Ice options |
408 static const char kIceOption1[] = "iceoption1"; | 408 static const char kIceOption1[] = "iceoption1"; |
409 static const char kIceOption2[] = "iceoption2"; | 409 static const char kIceOption2[] = "iceoption2"; |
410 static const char kIceOption3[] = "iceoption3"; | 410 static const char kIceOption3[] = "iceoption3"; |
411 | 411 |
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1720 kExtmap, &sdp_with_extmap); | 1720 kExtmap, &sdp_with_extmap); |
1721 InjectAfter("a=mid:video_content_name\r\n", | 1721 InjectAfter("a=mid:video_content_name\r\n", |
1722 kExtmap, &sdp_with_extmap); | 1722 kExtmap, &sdp_with_extmap); |
1723 | 1723 |
1724 EXPECT_EQ(sdp_with_extmap, message); | 1724 EXPECT_EQ(sdp_with_extmap, message); |
1725 } | 1725 } |
1726 | 1726 |
1727 TEST_F(WebRtcSdpTest, SerializeCandidates) { | 1727 TEST_F(WebRtcSdpTest, SerializeCandidates) { |
1728 std::string message = webrtc::SdpSerializeCandidate(*jcandidate_); | 1728 std::string message = webrtc::SdpSerializeCandidate(*jcandidate_); |
1729 EXPECT_EQ(std::string(kRawCandidate), message); | 1729 EXPECT_EQ(std::string(kRawCandidate), message); |
| 1730 |
| 1731 Candidate candidate_with_ufrag(candidates_.front()); |
| 1732 candidate_with_ufrag.set_username("ABC"); |
| 1733 jcandidate_.reset(new JsepIceCandidate(std::string("audio_content_name"), 0, |
| 1734 candidate_with_ufrag)); |
| 1735 message = webrtc::SdpSerializeCandidate(*jcandidate_); |
| 1736 EXPECT_EQ(std::string(kRawCandidate) + " ufrag ABC", message); |
1730 } | 1737 } |
1731 | 1738 |
1732 // TODO(mallinath) : Enable this test once WebRTCSdp capable of parsing | 1739 // TODO(mallinath) : Enable this test once WebRTCSdp capable of parsing |
1733 // RFC 6544. | 1740 // RFC 6544. |
1734 TEST_F(WebRtcSdpTest, SerializeTcpCandidates) { | 1741 TEST_F(WebRtcSdpTest, SerializeTcpCandidates) { |
1735 Candidate candidate(ICE_CANDIDATE_COMPONENT_RTP, "tcp", | 1742 Candidate candidate(ICE_CANDIDATE_COMPONENT_RTP, "tcp", |
1736 rtc::SocketAddress("192.168.1.5", 9), kCandidatePriority, | 1743 rtc::SocketAddress("192.168.1.5", 9), kCandidatePriority, |
1737 "", "", LOCAL_PORT_TYPE, kCandidateGeneration, | 1744 "", "", LOCAL_PORT_TYPE, kCandidateGeneration, |
1738 kCandidateFoundation1); | 1745 kCandidateFoundation1); |
1739 candidate.set_tcptype(cricket::TCPTYPE_ACTIVE_STR); | 1746 candidate.set_tcptype(cricket::TCPTYPE_ACTIVE_STR); |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2316 Replace("udp", "unsupported_transport", &new_sdp); | 2323 Replace("udp", "unsupported_transport", &new_sdp); |
2317 EXPECT_FALSE(SdpDeserializeCandidate(new_sdp, &jcandidate)); | 2324 EXPECT_FALSE(SdpDeserializeCandidate(new_sdp, &jcandidate)); |
2318 new_sdp = kSdpOneCandidate; | 2325 new_sdp = kSdpOneCandidate; |
2319 Replace("udp", "uDP", &new_sdp); | 2326 Replace("udp", "uDP", &new_sdp); |
2320 EXPECT_TRUE(SdpDeserializeCandidate(new_sdp, &jcandidate)); | 2327 EXPECT_TRUE(SdpDeserializeCandidate(new_sdp, &jcandidate)); |
2321 EXPECT_EQ(kDummyMid, jcandidate.sdp_mid()); | 2328 EXPECT_EQ(kDummyMid, jcandidate.sdp_mid()); |
2322 EXPECT_EQ(kDummyIndex, jcandidate.sdp_mline_index()); | 2329 EXPECT_EQ(kDummyIndex, jcandidate.sdp_mline_index()); |
2323 EXPECT_TRUE(jcandidate.candidate().IsEquivalent(jcandidate_->candidate())); | 2330 EXPECT_TRUE(jcandidate.candidate().IsEquivalent(jcandidate_->candidate())); |
2324 } | 2331 } |
2325 | 2332 |
2326 TEST_F(WebRtcSdpTest, DeserializeCandidateOldFormat) { | 2333 TEST_F(WebRtcSdpTest, DeserializeCandidateWithUfragPwd) { |
2327 JsepIceCandidate jcandidate(kDummyMid, kDummyIndex); | 2334 JsepIceCandidate jcandidate(kDummyMid, kDummyIndex); |
2328 EXPECT_TRUE(SdpDeserializeCandidate(kSdpOneCandidateOldFormat,&jcandidate)); | 2335 EXPECT_TRUE( |
| 2336 SdpDeserializeCandidate(kSdpOneCandidateWithUfragPwd, &jcandidate)); |
2329 EXPECT_EQ(kDummyMid, jcandidate.sdp_mid()); | 2337 EXPECT_EQ(kDummyMid, jcandidate.sdp_mid()); |
2330 EXPECT_EQ(kDummyIndex, jcandidate.sdp_mline_index()); | 2338 EXPECT_EQ(kDummyIndex, jcandidate.sdp_mline_index()); |
2331 Candidate ref_candidate = jcandidate_->candidate(); | 2339 Candidate ref_candidate = jcandidate_->candidate(); |
2332 ref_candidate.set_username("user_rtp"); | 2340 ref_candidate.set_username("user_rtp"); |
2333 ref_candidate.set_password("password_rtp"); | 2341 ref_candidate.set_password("password_rtp"); |
2334 EXPECT_TRUE(jcandidate.candidate().IsEquivalent(ref_candidate)); | 2342 EXPECT_TRUE(jcandidate.candidate().IsEquivalent(ref_candidate)); |
2335 } | 2343 } |
2336 | 2344 |
2337 TEST_F(WebRtcSdpTest, DeserializeSdpWithConferenceFlag) { | 2345 TEST_F(WebRtcSdpTest, DeserializeSdpWithConferenceFlag) { |
2338 JsepSessionDescription jdesc(kDummyString); | 2346 JsepSessionDescription jdesc(kDummyString); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2707 const cricket::MediaContentDescription* mdesc = | 2715 const cricket::MediaContentDescription* mdesc = |
2708 static_cast<const cricket::MediaContentDescription*>( | 2716 static_cast<const cricket::MediaContentDescription*>( |
2709 desc->contents()[i].description); | 2717 desc->contents()[i].description); |
2710 EXPECT_EQ(media_types[media_content_in_sdp[i]], mdesc->type()); | 2718 EXPECT_EQ(media_types[media_content_in_sdp[i]], mdesc->type()); |
2711 } | 2719 } |
2712 | 2720 |
2713 std::string serialized_sdp = webrtc::SdpSerialize(jdesc); | 2721 std::string serialized_sdp = webrtc::SdpSerialize(jdesc); |
2714 EXPECT_EQ(sdp_string, serialized_sdp); | 2722 EXPECT_EQ(sdp_string, serialized_sdp); |
2715 } | 2723 } |
2716 } | 2724 } |
OLD | NEW |