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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 using webrtc::JsepIceCandidate; | 58 using webrtc::JsepIceCandidate; |
59 using webrtc::JsepSessionDescription; | 59 using webrtc::JsepSessionDescription; |
60 using webrtc::RtpExtension; | 60 using webrtc::RtpExtension; |
61 using webrtc::SdpParseError; | 61 using webrtc::SdpParseError; |
62 using webrtc::SessionDescriptionInterface; | 62 using webrtc::SessionDescriptionInterface; |
63 | 63 |
64 typedef std::vector<AudioCodec> AudioCodecs; | 64 typedef std::vector<AudioCodec> AudioCodecs; |
65 typedef std::vector<Candidate> Candidates; | 65 typedef std::vector<Candidate> Candidates; |
66 | 66 |
67 static const uint32_t kDefaultSctpPort = 5000; | 67 static const uint32_t kDefaultSctpPort = 5000; |
| 68 static const char kDefaultSctpPortStr[] = "5000"; |
| 69 static const uint16_t kUnusualSctpPort = 9556; |
| 70 static const char kUnusualSctpPortStr[] = "9556"; |
68 static const char kSessionTime[] = "t=0 0\r\n"; | 71 static const char kSessionTime[] = "t=0 0\r\n"; |
69 static const uint32_t kCandidatePriority = 2130706432U; // pref = 1.0 | 72 static const uint32_t kCandidatePriority = 2130706432U; // pref = 1.0 |
70 static const char kAttributeIceUfragVoice[] = "a=ice-ufrag:ufrag_voice\r\n"; | 73 static const char kAttributeIceUfragVoice[] = "a=ice-ufrag:ufrag_voice\r\n"; |
71 static const char kAttributeIcePwdVoice[] = "a=ice-pwd:pwd_voice\r\n"; | 74 static const char kAttributeIcePwdVoice[] = "a=ice-pwd:pwd_voice\r\n"; |
72 static const char kAttributeIceUfragVideo[] = "a=ice-ufrag:ufrag_video\r\n"; | 75 static const char kAttributeIceUfragVideo[] = "a=ice-ufrag:ufrag_video\r\n"; |
73 static const char kAttributeIcePwdVideo[] = "a=ice-pwd:pwd_video\r\n"; | 76 static const char kAttributeIcePwdVideo[] = "a=ice-pwd:pwd_video\r\n"; |
74 static const uint32_t kCandidateGeneration = 2; | 77 static const uint32_t kCandidateGeneration = 2; |
75 static const char kCandidateFoundation1[] = "a0+B/1"; | 78 static const char kCandidateFoundation1[] = "a0+B/1"; |
76 static const char kCandidateFoundation2[] = "a0+B/2"; | 79 static const char kCandidateFoundation2[] = "a0+B/2"; |
77 static const char kCandidateFoundation3[] = "a0+B/3"; | 80 static const char kCandidateFoundation3[] = "a0+B/3"; |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 ASSERT_EQ(cd1->rtp_header_extensions().size(), | 1206 ASSERT_EQ(cd1->rtp_header_extensions().size(), |
1204 cd2->rtp_header_extensions().size()); | 1207 cd2->rtp_header_extensions().size()); |
1205 for (size_t i = 0; i< cd1->rtp_header_extensions().size(); ++i) { | 1208 for (size_t i = 0; i< cd1->rtp_header_extensions().size(); ++i) { |
1206 const RtpExtension ext1 = cd1->rtp_header_extensions().at(i); | 1209 const RtpExtension ext1 = cd1->rtp_header_extensions().at(i); |
1207 const RtpExtension ext2 = cd2->rtp_header_extensions().at(i); | 1210 const RtpExtension ext2 = cd2->rtp_header_extensions().at(i); |
1208 EXPECT_EQ(ext1.uri, ext2.uri); | 1211 EXPECT_EQ(ext1.uri, ext2.uri); |
1209 EXPECT_EQ(ext1.id, ext2.id); | 1212 EXPECT_EQ(ext1.id, ext2.id); |
1210 } | 1213 } |
1211 } | 1214 } |
1212 | 1215 |
| 1216 void CompareDataContentDescription(const DataContentDescription* dcd1, |
| 1217 const DataContentDescription* dcd2) { |
| 1218 EXPECT_EQ(dcd1->use_sctpmap(), dcd2->use_sctpmap()); |
| 1219 CompareMediaContentDescription<DataContentDescription>(dcd1, dcd2); |
| 1220 } |
1213 | 1221 |
1214 void CompareSessionDescription(const SessionDescription& desc1, | 1222 void CompareSessionDescription(const SessionDescription& desc1, |
1215 const SessionDescription& desc2) { | 1223 const SessionDescription& desc2) { |
1216 // Compare content descriptions. | 1224 // Compare content descriptions. |
1217 if (desc1.contents().size() != desc2.contents().size()) { | 1225 if (desc1.contents().size() != desc2.contents().size()) { |
1218 ADD_FAILURE(); | 1226 ADD_FAILURE(); |
1219 return; | 1227 return; |
1220 } | 1228 } |
1221 for (size_t i = 0 ; i < desc1.contents().size(); ++i) { | 1229 for (size_t i = 0 ; i < desc1.contents().size(); ++i) { |
1222 const cricket::ContentInfo& c1 = desc1.contents().at(i); | 1230 const cricket::ContentInfo& c1 = desc1.contents().at(i); |
(...skipping 21 matching lines...) Expand all Loading... |
1244 static_cast<const VideoContentDescription*>(c2.description); | 1252 static_cast<const VideoContentDescription*>(c2.description); |
1245 CompareMediaContentDescription<VideoContentDescription>(vcd1, vcd2); | 1253 CompareMediaContentDescription<VideoContentDescription>(vcd1, vcd2); |
1246 } | 1254 } |
1247 | 1255 |
1248 ASSERT_EQ(IsDataContent(&c1), IsDataContent(&c2)); | 1256 ASSERT_EQ(IsDataContent(&c1), IsDataContent(&c2)); |
1249 if (IsDataContent(&c1)) { | 1257 if (IsDataContent(&c1)) { |
1250 const DataContentDescription* dcd1 = | 1258 const DataContentDescription* dcd1 = |
1251 static_cast<const DataContentDescription*>(c1.description); | 1259 static_cast<const DataContentDescription*>(c1.description); |
1252 const DataContentDescription* dcd2 = | 1260 const DataContentDescription* dcd2 = |
1253 static_cast<const DataContentDescription*>(c2.description); | 1261 static_cast<const DataContentDescription*>(c2.description); |
1254 CompareMediaContentDescription<DataContentDescription>(dcd1, dcd2); | 1262 CompareDataContentDescription(dcd1, dcd2); |
1255 } | 1263 } |
1256 } | 1264 } |
1257 | 1265 |
1258 // group | 1266 // group |
1259 const cricket::ContentGroups groups1 = desc1.groups(); | 1267 const cricket::ContentGroups groups1 = desc1.groups(); |
1260 const cricket::ContentGroups groups2 = desc2.groups(); | 1268 const cricket::ContentGroups groups2 = desc2.groups(); |
1261 EXPECT_EQ(groups1.size(), groups1.size()); | 1269 EXPECT_EQ(groups1.size(), groups1.size()); |
1262 if (groups1.size() != groups2.size()) { | 1270 if (groups1.size() != groups2.size()) { |
1263 ADD_FAILURE(); | 1271 ADD_FAILURE(); |
1264 return; | 1272 return; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1479 JsepSessionDescription jdesc_no_candidates(kDummyString); | 1487 JsepSessionDescription jdesc_no_candidates(kDummyString); |
1480 if (!jdesc_no_candidates.Initialize(desc_.Copy(), kSessionId, | 1488 if (!jdesc_no_candidates.Initialize(desc_.Copy(), kSessionId, |
1481 kSessionVersion)) { | 1489 kSessionVersion)) { |
1482 return false; | 1490 return false; |
1483 } | 1491 } |
1484 std::string message = webrtc::SdpSerialize(jdesc_no_candidates, false); | 1492 std::string message = webrtc::SdpSerialize(jdesc_no_candidates, false); |
1485 EXPECT_EQ(new_sdp, message); | 1493 EXPECT_EQ(new_sdp, message); |
1486 return true; | 1494 return true; |
1487 } | 1495 } |
1488 | 1496 |
1489 void AddSctpDataChannel() { | 1497 void AddSctpDataChannel(bool use_sctpmap) { |
1490 std::unique_ptr<DataContentDescription> data(new DataContentDescription()); | 1498 std::unique_ptr<DataContentDescription> data(new DataContentDescription()); |
1491 data_desc_ = data.get(); | 1499 data_desc_ = data.get(); |
| 1500 data_desc_->set_use_sctpmap(use_sctpmap); |
1492 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp); | 1501 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp); |
1493 DataCodec codec(cricket::kGoogleSctpDataCodecPlType, | 1502 DataCodec codec(cricket::kGoogleSctpDataCodecPlType, |
1494 cricket::kGoogleSctpDataCodecName); | 1503 cricket::kGoogleSctpDataCodecName); |
1495 codec.SetParam(cricket::kCodecParamPort, kDefaultSctpPort); | 1504 codec.SetParam(cricket::kCodecParamPort, kDefaultSctpPort); |
1496 data_desc_->AddCodec(codec); | 1505 data_desc_->AddCodec(codec); |
1497 desc_.AddContent(kDataContentName, NS_JINGLE_DRAFT_SCTP, data.release()); | 1506 desc_.AddContent(kDataContentName, NS_JINGLE_DRAFT_SCTP, data.release()); |
1498 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( | 1507 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo( |
1499 kDataContentName, TransportDescription(kUfragData, kPwdData)))); | 1508 kDataContentName, TransportDescription(kUfragData, kPwdData)))); |
1500 } | 1509 } |
1501 | 1510 |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2051 | 2060 |
2052 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 2061 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
2053 std::string message = webrtc::SdpSerialize(jsep_desc, false); | 2062 std::string message = webrtc::SdpSerialize(jsep_desc, false); |
2054 | 2063 |
2055 std::string expected_sdp = kSdpString; | 2064 std::string expected_sdp = kSdpString; |
2056 expected_sdp.append(kSdpRtpDataChannelString); | 2065 expected_sdp.append(kSdpRtpDataChannelString); |
2057 EXPECT_EQ(expected_sdp, message); | 2066 EXPECT_EQ(expected_sdp, message); |
2058 } | 2067 } |
2059 | 2068 |
2060 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithSctpDataChannel) { | 2069 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithSctpDataChannel) { |
2061 AddSctpDataChannel(); | 2070 bool use_sctpmap = true; |
| 2071 AddSctpDataChannel(use_sctpmap); |
2062 JsepSessionDescription jsep_desc(kDummyString); | 2072 JsepSessionDescription jsep_desc(kDummyString); |
2063 | 2073 |
2064 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 2074 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
2065 std::string message = webrtc::SdpSerialize(jsep_desc, false); | 2075 std::string message = webrtc::SdpSerialize(jsep_desc, false); |
2066 | 2076 |
2067 std::string expected_sdp = kSdpString; | 2077 std::string expected_sdp = kSdpString; |
2068 expected_sdp.append(kSdpSctpDataChannelString); | 2078 expected_sdp.append(kSdpSctpDataChannelString); |
2069 EXPECT_EQ(message, expected_sdp); | 2079 EXPECT_EQ(message, expected_sdp); |
2070 } | 2080 } |
2071 | 2081 |
2072 TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { | 2082 TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { |
2073 AddSctpDataChannel(); | 2083 bool use_sctpmap = true; |
| 2084 AddSctpDataChannel(use_sctpmap); |
2074 JsepSessionDescription jsep_desc(kDummyString); | 2085 JsepSessionDescription jsep_desc(kDummyString); |
2075 | 2086 |
2076 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 2087 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
2077 DataContentDescription* dcdesc = static_cast<DataContentDescription*>( | 2088 DataContentDescription* dcdesc = static_cast<DataContentDescription*>( |
2078 jsep_desc.description()->GetContentDescriptionByName(kDataContentName)); | 2089 jsep_desc.description()->GetContentDescriptionByName(kDataContentName)); |
2079 | 2090 |
2080 const int kNewPort = 1234; | 2091 const int kNewPort = 1234; |
2081 cricket::DataCodec codec(cricket::kGoogleSctpDataCodecPlType, | 2092 cricket::DataCodec codec(cricket::kGoogleSctpDataCodecPlType, |
2082 cricket::kGoogleSctpDataCodecName); | 2093 cricket::kGoogleSctpDataCodecName); |
2083 codec.SetParam(cricket::kCodecParamPort, kNewPort); | 2094 codec.SetParam(cricket::kCodecParamPort, kNewPort); |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2563 sdp_with_data.append(kSdpRtpDataChannelString); | 2574 sdp_with_data.append(kSdpRtpDataChannelString); |
2564 JsepSessionDescription jdesc_output(kDummyString); | 2575 JsepSessionDescription jdesc_output(kDummyString); |
2565 | 2576 |
2566 // Deserialize | 2577 // Deserialize |
2567 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); | 2578 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); |
2568 // Verify | 2579 // Verify |
2569 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); | 2580 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); |
2570 } | 2581 } |
2571 | 2582 |
2572 TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannels) { | 2583 TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannels) { |
2573 AddSctpDataChannel(); | 2584 bool use_sctpmap = true; |
| 2585 AddSctpDataChannel(use_sctpmap); |
2574 JsepSessionDescription jdesc(kDummyString); | 2586 JsepSessionDescription jdesc(kDummyString); |
2575 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 2587 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
2576 | 2588 |
2577 std::string sdp_with_data = kSdpString; | 2589 std::string sdp_with_data = kSdpString; |
2578 sdp_with_data.append(kSdpSctpDataChannelString); | 2590 sdp_with_data.append(kSdpSctpDataChannelString); |
2579 JsepSessionDescription jdesc_output(kDummyString); | 2591 JsepSessionDescription jdesc_output(kDummyString); |
2580 | 2592 |
2581 // Verify with DTLS/SCTP (already in kSdpSctpDataChannelString). | 2593 // Verify with DTLS/SCTP (already in kSdpSctpDataChannelString). |
2582 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); | 2594 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); |
2583 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); | 2595 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); |
2584 | 2596 |
2585 // Verify with UDP/DTLS/SCTP. | 2597 // Verify with UDP/DTLS/SCTP. |
2586 sdp_with_data.replace(sdp_with_data.find(kDtlsSctp), | 2598 sdp_with_data.replace(sdp_with_data.find(kDtlsSctp), |
2587 strlen(kDtlsSctp), kUdpDtlsSctp); | 2599 strlen(kDtlsSctp), kUdpDtlsSctp); |
2588 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); | 2600 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); |
2589 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); | 2601 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); |
2590 | 2602 |
2591 // Verify with TCP/DTLS/SCTP. | 2603 // Verify with TCP/DTLS/SCTP. |
2592 sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp), | 2604 sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp), |
2593 strlen(kUdpDtlsSctp), kTcpDtlsSctp); | 2605 strlen(kUdpDtlsSctp), kTcpDtlsSctp); |
2594 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); | 2606 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); |
2595 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); | 2607 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); |
2596 } | 2608 } |
2597 | 2609 |
2598 TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsWithSctpPort) { | 2610 TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsWithSctpPort) { |
2599 AddSctpDataChannel(); | 2611 bool use_sctpmap = false; |
| 2612 AddSctpDataChannel(use_sctpmap); |
2600 JsepSessionDescription jdesc(kDummyString); | 2613 JsepSessionDescription jdesc(kDummyString); |
2601 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 2614 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
2602 | 2615 |
2603 std::string sdp_with_data = kSdpString; | 2616 std::string sdp_with_data = kSdpString; |
2604 sdp_with_data.append(kSdpSctpDataChannelStringWithSctpPort); | 2617 sdp_with_data.append(kSdpSctpDataChannelStringWithSctpPort); |
2605 JsepSessionDescription jdesc_output(kDummyString); | 2618 JsepSessionDescription jdesc_output(kDummyString); |
2606 | 2619 |
2607 // Verify with DTLS/SCTP (already in kSdpSctpDataChannelStringWithSctpPort). | 2620 // Verify with DTLS/SCTP (already in kSdpSctpDataChannelStringWithSctpPort). |
2608 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); | 2621 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); |
2609 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); | 2622 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); |
2610 | 2623 |
2611 // Verify with UDP/DTLS/SCTP. | 2624 // Verify with UDP/DTLS/SCTP. |
2612 sdp_with_data.replace(sdp_with_data.find(kDtlsSctp), | 2625 sdp_with_data.replace(sdp_with_data.find(kDtlsSctp), |
2613 strlen(kDtlsSctp), kUdpDtlsSctp); | 2626 strlen(kDtlsSctp), kUdpDtlsSctp); |
2614 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); | 2627 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); |
2615 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); | 2628 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); |
2616 | 2629 |
2617 // Verify with TCP/DTLS/SCTP. | 2630 // Verify with TCP/DTLS/SCTP. |
2618 sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp), | 2631 sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp), |
2619 strlen(kUdpDtlsSctp), kTcpDtlsSctp); | 2632 strlen(kUdpDtlsSctp), kTcpDtlsSctp); |
2620 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); | 2633 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); |
2621 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); | 2634 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); |
2622 } | 2635 } |
2623 | 2636 |
2624 TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsWithSctpColonPort) { | 2637 TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsWithSctpColonPort) { |
2625 AddSctpDataChannel(); | 2638 bool use_sctpmap = false; |
| 2639 AddSctpDataChannel(use_sctpmap); |
2626 JsepSessionDescription jdesc(kDummyString); | 2640 JsepSessionDescription jdesc(kDummyString); |
2627 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 2641 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
2628 | 2642 |
2629 std::string sdp_with_data = kSdpString; | 2643 std::string sdp_with_data = kSdpString; |
2630 sdp_with_data.append(kSdpSctpDataChannelStringWithSctpColonPort); | 2644 sdp_with_data.append(kSdpSctpDataChannelStringWithSctpColonPort); |
2631 JsepSessionDescription jdesc_output(kDummyString); | 2645 JsepSessionDescription jdesc_output(kDummyString); |
2632 | 2646 |
2633 // Verify with DTLS/SCTP. | 2647 // Verify with DTLS/SCTP. |
2634 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); | 2648 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); |
2635 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); | 2649 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); |
2636 | 2650 |
2637 // Verify with UDP/DTLS/SCTP. | 2651 // Verify with UDP/DTLS/SCTP. |
2638 sdp_with_data.replace(sdp_with_data.find(kDtlsSctp), | 2652 sdp_with_data.replace(sdp_with_data.find(kDtlsSctp), |
2639 strlen(kDtlsSctp), kUdpDtlsSctp); | 2653 strlen(kDtlsSctp), kUdpDtlsSctp); |
2640 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); | 2654 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); |
2641 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); | 2655 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); |
2642 | 2656 |
2643 // Verify with TCP/DTLS/SCTP. | 2657 // Verify with TCP/DTLS/SCTP. |
2644 sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp), | 2658 sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp), |
2645 strlen(kUdpDtlsSctp), kTcpDtlsSctp); | 2659 strlen(kUdpDtlsSctp), kTcpDtlsSctp); |
2646 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); | 2660 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); |
2647 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); | 2661 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); |
2648 } | 2662 } |
2649 | 2663 |
2650 // Test to check the behaviour if sctp-port is specified | 2664 // Test to check the behaviour if sctp-port is specified |
2651 // on the m= line and in a=sctp-port. | 2665 // on the m= line and in a=sctp-port. |
2652 TEST_F(WebRtcSdpTest, DeserializeSdpWithMultiSctpPort) { | 2666 TEST_F(WebRtcSdpTest, DeserializeSdpWithMultiSctpPort) { |
2653 AddSctpDataChannel(); | 2667 bool use_sctpmap = true; |
| 2668 AddSctpDataChannel(use_sctpmap); |
2654 JsepSessionDescription jdesc(kDummyString); | 2669 JsepSessionDescription jdesc(kDummyString); |
2655 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 2670 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
2656 | 2671 |
2657 std::string sdp_with_data = kSdpString; | 2672 std::string sdp_with_data = kSdpString; |
2658 // Append m= attributes | 2673 // Append m= attributes |
2659 sdp_with_data.append(kSdpSctpDataChannelString); | 2674 sdp_with_data.append(kSdpSctpDataChannelString); |
2660 // Append a=sctp-port attribute | 2675 // Append a=sctp-port attribute |
2661 sdp_with_data.append("a=sctp-port 5000\r\n"); | 2676 sdp_with_data.append("a=sctp-port 5000\r\n"); |
2662 JsepSessionDescription jdesc_output(kDummyString); | 2677 JsepSessionDescription jdesc_output(kDummyString); |
2663 | 2678 |
2664 EXPECT_FALSE(SdpDeserialize(sdp_with_data, &jdesc_output)); | 2679 EXPECT_FALSE(SdpDeserialize(sdp_with_data, &jdesc_output)); |
2665 } | 2680 } |
2666 | 2681 |
2667 // For crbug/344475. | 2682 // For crbug/344475. |
2668 TEST_F(WebRtcSdpTest, DeserializeSdpWithCorruptedSctpDataChannels) { | 2683 TEST_F(WebRtcSdpTest, DeserializeSdpWithCorruptedSctpDataChannels) { |
2669 std::string sdp_with_data = kSdpString; | 2684 std::string sdp_with_data = kSdpString; |
2670 sdp_with_data.append(kSdpSctpDataChannelString); | 2685 sdp_with_data.append(kSdpSctpDataChannelString); |
2671 // Remove the "\n" at the end. | 2686 // Remove the "\n" at the end. |
2672 sdp_with_data = sdp_with_data.substr(0, sdp_with_data.size() - 1); | 2687 sdp_with_data = sdp_with_data.substr(0, sdp_with_data.size() - 1); |
2673 JsepSessionDescription jdesc_output(kDummyString); | 2688 JsepSessionDescription jdesc_output(kDummyString); |
2674 | 2689 |
2675 EXPECT_FALSE(SdpDeserialize(sdp_with_data, &jdesc_output)); | 2690 EXPECT_FALSE(SdpDeserialize(sdp_with_data, &jdesc_output)); |
2676 // No crash is a pass. | 2691 // No crash is a pass. |
2677 } | 2692 } |
2678 | 2693 |
2679 TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelAndNewPort) { | 2694 void MutateJsepSctpPort(JsepSessionDescription& jdesc, |
2680 AddSctpDataChannel(); | 2695 const SessionDescription& desc) { |
2681 const uint16_t kUnusualSctpPort = 9556; | |
2682 char default_portstr[16]; | |
2683 char unusual_portstr[16]; | |
2684 rtc::sprintfn(default_portstr, sizeof(default_portstr), "%d", | |
2685 kDefaultSctpPort); | |
2686 rtc::sprintfn(unusual_portstr, sizeof(unusual_portstr), "%d", | |
2687 kUnusualSctpPort); | |
2688 | |
2689 // First setup the expected JsepSessionDescription. | |
2690 JsepSessionDescription jdesc(kDummyString); | |
2691 // take our pre-built session description and change the SCTP port. | 2696 // take our pre-built session description and change the SCTP port. |
2692 cricket::SessionDescription* mutant = desc_.Copy(); | 2697 cricket::SessionDescription* mutant = desc.Copy(); |
2693 DataContentDescription* dcdesc = static_cast<DataContentDescription*>( | 2698 DataContentDescription* dcdesc = static_cast<DataContentDescription*>( |
2694 mutant->GetContentDescriptionByName(kDataContentName)); | 2699 mutant->GetContentDescriptionByName(kDataContentName)); |
2695 std::vector<cricket::DataCodec> codecs(dcdesc->codecs()); | 2700 std::vector<cricket::DataCodec> codecs(dcdesc->codecs()); |
2696 EXPECT_EQ(1U, codecs.size()); | 2701 EXPECT_EQ(1U, codecs.size()); |
2697 EXPECT_EQ(cricket::kGoogleSctpDataCodecPlType, codecs[0].id); | 2702 EXPECT_EQ(cricket::kGoogleSctpDataCodecPlType, codecs[0].id); |
2698 codecs[0].SetParam(cricket::kCodecParamPort, kUnusualSctpPort); | 2703 codecs[0].SetParam(cricket::kCodecParamPort, kUnusualSctpPort); |
2699 dcdesc->set_codecs(codecs); | 2704 dcdesc->set_codecs(codecs); |
2700 | 2705 |
2701 // note: mutant's owned by jdesc now. | 2706 // note: mutant's owned by jdesc now. |
2702 ASSERT_TRUE(jdesc.Initialize(mutant, kSessionId, kSessionVersion)); | 2707 ASSERT_TRUE(jdesc.Initialize(mutant, kSessionId, kSessionVersion)); |
2703 mutant = NULL; | 2708 mutant = NULL; |
| 2709 } |
| 2710 |
| 2711 TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelAndUnusualPort) { |
| 2712 bool use_sctpmap = true; |
| 2713 AddSctpDataChannel(use_sctpmap); |
| 2714 |
| 2715 // First setup the expected JsepSessionDescription. |
| 2716 JsepSessionDescription jdesc(kDummyString); |
| 2717 MutateJsepSctpPort(jdesc, desc_); |
2704 | 2718 |
2705 // Then get the deserialized JsepSessionDescription. | 2719 // Then get the deserialized JsepSessionDescription. |
2706 std::string sdp_with_data = kSdpString; | 2720 std::string sdp_with_data = kSdpString; |
2707 sdp_with_data.append(kSdpSctpDataChannelString); | 2721 sdp_with_data.append(kSdpSctpDataChannelString); |
2708 rtc::replace_substrs(default_portstr, strlen(default_portstr), | 2722 rtc::replace_substrs(kDefaultSctpPortStr, strlen(kDefaultSctpPortStr), |
2709 unusual_portstr, strlen(unusual_portstr), | 2723 kUnusualSctpPortStr, strlen(kUnusualSctpPortStr), |
2710 &sdp_with_data); | 2724 &sdp_with_data); |
2711 JsepSessionDescription jdesc_output(kDummyString); | 2725 JsepSessionDescription jdesc_output(kDummyString); |
2712 | 2726 |
2713 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); | 2727 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); |
2714 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); | 2728 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); |
| 2729 } |
| 2730 |
| 2731 TEST_F(WebRtcSdpTest, |
| 2732 DeserializeSdpWithSctpDataChannelAndUnusualPortInAttribute) { |
| 2733 bool use_sctpmap = false; |
| 2734 AddSctpDataChannel(use_sctpmap); |
| 2735 |
| 2736 JsepSessionDescription jdesc(kDummyString); |
| 2737 MutateJsepSctpPort(jdesc, desc_); |
2715 | 2738 |
2716 // We need to test the deserialized JsepSessionDescription from | 2739 // We need to test the deserialized JsepSessionDescription from |
2717 // kSdpSctpDataChannelStringWithSctpPort for | 2740 // kSdpSctpDataChannelStringWithSctpPort for |
2718 // draft-ietf-mmusic-sctp-sdp-07 | 2741 // draft-ietf-mmusic-sctp-sdp-07 |
2719 // a=sctp-port | 2742 // a=sctp-port |
2720 sdp_with_data = kSdpString; | 2743 std::string sdp_with_data = kSdpString; |
2721 sdp_with_data.append(kSdpSctpDataChannelStringWithSctpPort); | 2744 sdp_with_data.append(kSdpSctpDataChannelStringWithSctpPort); |
2722 rtc::replace_substrs(default_portstr, strlen(default_portstr), | 2745 rtc::replace_substrs(kDefaultSctpPortStr, strlen(kDefaultSctpPortStr), |
2723 unusual_portstr, strlen(unusual_portstr), | 2746 kUnusualSctpPortStr, strlen(kUnusualSctpPortStr), |
2724 &sdp_with_data); | 2747 &sdp_with_data); |
| 2748 JsepSessionDescription jdesc_output(kDummyString); |
2725 | 2749 |
2726 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); | 2750 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); |
2727 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); | 2751 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); |
2728 } | 2752 } |
2729 | 2753 |
2730 TEST_F(WebRtcSdpTest, DeserializeSdpWithRtpDataChannelsAndBandwidth) { | 2754 TEST_F(WebRtcSdpTest, DeserializeSdpWithRtpDataChannelsAndBandwidth) { |
2731 // We want to test that deserializing data content limits bandwidth | 2755 // We want to test that deserializing data content limits bandwidth |
2732 // settings (it should never be greater than the default). | 2756 // settings (it should never be greater than the default). |
2733 // This should prevent someone from using unlimited data bandwidth through | 2757 // This should prevent someone from using unlimited data bandwidth through |
2734 // JS and "breaking the Internet". | 2758 // JS and "breaking the Internet". |
2735 // See: https://code.google.com/p/chromium/issues/detail?id=280726 | 2759 // See: https://code.google.com/p/chromium/issues/detail?id=280726 |
2736 std::string sdp_with_bandwidth = kSdpString; | 2760 std::string sdp_with_bandwidth = kSdpString; |
2737 sdp_with_bandwidth.append(kSdpRtpDataChannelString); | 2761 sdp_with_bandwidth.append(kSdpRtpDataChannelString); |
2738 InjectAfter("a=mid:data_content_name\r\n", | 2762 InjectAfter("a=mid:data_content_name\r\n", |
2739 "b=AS:100\r\n", | 2763 "b=AS:100\r\n", |
2740 &sdp_with_bandwidth); | 2764 &sdp_with_bandwidth); |
2741 JsepSessionDescription jdesc_with_bandwidth(kDummyString); | 2765 JsepSessionDescription jdesc_with_bandwidth(kDummyString); |
2742 | 2766 |
2743 EXPECT_FALSE(SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth)); | 2767 EXPECT_FALSE(SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth)); |
2744 } | 2768 } |
2745 | 2769 |
2746 TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsAndBandwidth) { | 2770 TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsAndBandwidth) { |
2747 AddSctpDataChannel(); | 2771 bool use_sctpmap = true; |
| 2772 AddSctpDataChannel(use_sctpmap); |
2748 JsepSessionDescription jdesc(kDummyString); | 2773 JsepSessionDescription jdesc(kDummyString); |
2749 DataContentDescription* dcd = static_cast<DataContentDescription*>( | 2774 DataContentDescription* dcd = static_cast<DataContentDescription*>( |
2750 GetFirstDataContent(&desc_)->description); | 2775 GetFirstDataContent(&desc_)->description); |
2751 dcd->set_bandwidth(100 * 1000); | 2776 dcd->set_bandwidth(100 * 1000); |
2752 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); | 2777 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); |
2753 | 2778 |
2754 std::string sdp_with_bandwidth = kSdpString; | 2779 std::string sdp_with_bandwidth = kSdpString; |
2755 sdp_with_bandwidth.append(kSdpSctpDataChannelString); | 2780 sdp_with_bandwidth.append(kSdpSctpDataChannelString); |
2756 InjectAfter("a=mid:data_content_name\r\n", | 2781 InjectAfter("a=mid:data_content_name\r\n", |
2757 "b=AS:100\r\n", | 2782 "b=AS:100\r\n", |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3472 "s=-\r\n" | 3497 "s=-\r\n" |
3473 "t=0 0\r\n" | 3498 "t=0 0\r\n" |
3474 "m=audio 9 RTP/SAVPF 111\r\n" | 3499 "m=audio 9 RTP/SAVPF 111\r\n" |
3475 "c=IN IP4 0.0.0.0\r\n" | 3500 "c=IN IP4 0.0.0.0\r\n" |
3476 "a=rtpmap:111 opus/48000/2\r\n" | 3501 "a=rtpmap:111 opus/48000/2\r\n" |
3477 "a=msid: track_id\r\n"; | 3502 "a=msid: track_id\r\n"; |
3478 | 3503 |
3479 JsepSessionDescription jdesc_output(kDummyString); | 3504 JsepSessionDescription jdesc_output(kDummyString); |
3480 EXPECT_FALSE(SdpDeserialize(kSdpWithMissingStreamId, &jdesc_output)); | 3505 EXPECT_FALSE(SdpDeserialize(kSdpWithMissingStreamId, &jdesc_output)); |
3481 } | 3506 } |
OLD | NEW |