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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 "a=rtcp:9 IN IP4 0.0.0.0\r\n" | 324 "a=rtcp:9 IN IP4 0.0.0.0\r\n" |
325 "a=ice-ufrag:ufrag_video\r\na=ice-pwd:pwd_video\r\n" | 325 "a=ice-ufrag:ufrag_video\r\na=ice-pwd:pwd_video\r\n" |
326 "a=mid:video_content_name\r\n" | 326 "a=mid:video_content_name\r\n" |
327 "a=sendrecv\r\n" | 327 "a=sendrecv\r\n" |
328 "a=rtpmap:120 VP8/90000\r\n" | 328 "a=rtpmap:120 VP8/90000\r\n" |
329 "a=ssrc:2 cname:stream_1_cname\r\n" | 329 "a=ssrc:2 cname:stream_1_cname\r\n" |
330 "a=ssrc:2 msid:local_stream video_track_id_1\r\n" | 330 "a=ssrc:2 msid:local_stream video_track_id_1\r\n" |
331 "a=ssrc:2 mslabel:local_stream\r\n" | 331 "a=ssrc:2 mslabel:local_stream\r\n" |
332 "a=ssrc:2 label:video_track_id_1\r\n"; | 332 "a=ssrc:2 label:video_track_id_1\r\n"; |
333 | 333 |
334 // Reference sdp string using bundle-only. | |
335 static const char kBundleOnlySdpFullString[] = | |
336 "v=0\r\n" | |
337 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" | |
338 "s=-\r\n" | |
339 "t=0 0\r\n" | |
340 "a=group:BUNDLE audio_content_name video_content_name\r\n" | |
341 "a=msid-semantic: WMS local_stream_1\r\n" | |
342 "m=audio 2345 RTP/SAVPF 111 103 104\r\n" | |
343 "c=IN IP4 74.125.127.126\r\n" | |
344 "a=rtcp:2347 IN IP4 74.125.127.126\r\n" | |
345 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host " | |
346 "generation 2\r\n" | |
347 "a=candidate:a0+B/1 2 udp 2130706432 192.168.1.5 1235 typ host " | |
348 "generation 2\r\n" | |
349 "a=candidate:a0+B/2 1 udp 2130706432 ::1 1238 typ host " | |
350 "generation 2\r\n" | |
351 "a=candidate:a0+B/2 2 udp 2130706432 ::1 1239 typ host " | |
352 "generation 2\r\n" | |
353 "a=candidate:a0+B/3 1 udp 2130706432 74.125.127.126 2345 typ srflx " | |
354 "raddr 192.168.1.5 rport 2346 " | |
355 "generation 2\r\n" | |
356 "a=candidate:a0+B/3 2 udp 2130706432 74.125.127.126 2347 typ srflx " | |
357 "raddr 192.168.1.5 rport 2348 " | |
358 "generation 2\r\n" | |
359 "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n" | |
360 "a=mid:audio_content_name\r\n" | |
361 "a=sendrecv\r\n" | |
362 "a=rtcp-mux\r\n" | |
363 "a=rtcp-rsize\r\n" | |
364 "a=crypto:1 AES_CM_128_HMAC_SHA1_32 " | |
365 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 " | |
366 "dummy_session_params\r\n" | |
367 "a=rtpmap:111 opus/48000/2\r\n" | |
368 "a=rtpmap:103 ISAC/16000\r\n" | |
369 "a=rtpmap:104 ISAC/32000\r\n" | |
370 "a=ssrc:1 cname:stream_1_cname\r\n" | |
371 "a=ssrc:1 msid:local_stream_1 audio_track_id_1\r\n" | |
372 "a=ssrc:1 mslabel:local_stream_1\r\n" | |
373 "a=ssrc:1 label:audio_track_id_1\r\n" | |
374 "m=video 0 RTP/SAVPF 120\r\n" | |
375 "c=IN IP4 0.0.0.0\r\n" | |
376 "a=rtcp:9 IN IP4 0.0.0.0\r\n" | |
377 "a=bundle-only\r\n" | |
378 "a=mid:video_content_name\r\n" | |
379 "a=sendrecv\r\n" | |
380 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 " | |
381 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32\r\n" | |
382 "a=rtpmap:120 VP8/90000\r\n" | |
383 "a=ssrc-group:FEC 2 3\r\n" | |
384 "a=ssrc:2 cname:stream_1_cname\r\n" | |
385 "a=ssrc:2 msid:local_stream_1 video_track_id_1\r\n" | |
386 "a=ssrc:2 mslabel:local_stream_1\r\n" | |
387 "a=ssrc:2 label:video_track_id_1\r\n" | |
388 "a=ssrc:3 cname:stream_1_cname\r\n" | |
389 "a=ssrc:3 msid:local_stream_1 video_track_id_1\r\n" | |
390 "a=ssrc:3 mslabel:local_stream_1\r\n" | |
391 "a=ssrc:3 label:video_track_id_1\r\n"; | |
pthatcher1
2017/01/03 17:31:01
We should probably add a test for broken SDP from
| |
392 | |
334 // Plan B SDP reference string, with 2 streams, 2 audio tracks and 3 video | 393 // Plan B SDP reference string, with 2 streams, 2 audio tracks and 3 video |
335 // tracks. | 394 // tracks. |
336 static const char kPlanBSdpFullString[] = | 395 static const char kPlanBSdpFullString[] = |
337 "v=0\r\n" | 396 "v=0\r\n" |
338 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" | 397 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" |
339 "s=-\r\n" | 398 "s=-\r\n" |
340 "t=0 0\r\n" | 399 "t=0 0\r\n" |
341 "a=msid-semantic: WMS local_stream_1 local_stream_2\r\n" | 400 "a=msid-semantic: WMS local_stream_1 local_stream_2\r\n" |
342 "m=audio 2345 RTP/SAVPF 111 103 104\r\n" | 401 "m=audio 2345 RTP/SAVPF 111 103 104\r\n" |
343 "c=IN IP4 74.125.127.126\r\n" | 402 "c=IN IP4 74.125.127.126\r\n" |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
934 bool is_video = (i > 5); | 993 bool is_video = (i > 5); |
935 mline_id = is_video ? "video_content_name" : "audio_content_name"; | 994 mline_id = is_video ? "video_content_name" : "audio_content_name"; |
936 mline_index = is_video ? 1 : 0; | 995 mline_index = is_video ? 1 : 0; |
937 JsepIceCandidate jice(mline_id, | 996 JsepIceCandidate jice(mline_id, |
938 mline_index, | 997 mline_index, |
939 candidates_.at(i)); | 998 candidates_.at(i)); |
940 jdesc_.AddCandidate(&jice); | 999 jdesc_.AddCandidate(&jice); |
941 } | 1000 } |
942 } | 1001 } |
943 | 1002 |
1003 // Turns the existing reference description into a description using | |
1004 // a=bundle-only. This means no transport attributes and a 0 port value on | |
1005 // the m= sections not associated with the BUNDLE-tag. | |
1006 void MakeBundleOnlyDescription() { | |
1007 // Remove video candidates. JsepSessionDescription doesn't make it | |
1008 // simple. | |
1009 const IceCandidateCollection* video_candidates_collection = | |
1010 jdesc_.candidates(1); | |
1011 ASSERT_NE(nullptr, video_candidates_collection); | |
1012 std::vector<cricket::Candidate> video_candidates; | |
1013 for (size_t i = 0; i < video_candidates_collection->count(); ++i) { | |
1014 cricket::Candidate c = video_candidates_collection->at(i)->candidate(); | |
1015 c.set_transport_name("video_content_name"); | |
1016 video_candidates.push_back(c); | |
1017 } | |
1018 jdesc_.RemoveCandidates(video_candidates); | |
1019 | |
1020 // And the rest of the transport attributes. | |
1021 desc_.transport_infos()[1].description.ice_ufrag.clear(); | |
1022 desc_.transport_infos()[1].description.ice_pwd.clear(); | |
1023 desc_.transport_infos()[1].description.connection_role = | |
1024 cricket::CONNECTIONROLE_NONE; | |
1025 | |
1026 // Set bundle-only flag. | |
1027 desc_.contents()[1].bundle_only = true; | |
1028 | |
1029 // Add BUNDLE group. | |
1030 ContentGroup group(cricket::GROUP_TYPE_BUNDLE); | |
1031 group.AddContentName(kAudioContentName); | |
1032 group.AddContentName(kVideoContentName); | |
1033 desc_.AddGroup(group); | |
1034 | |
1035 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(), | |
1036 jdesc_.session_version())); | |
1037 } | |
1038 | |
944 // Turns the existing reference description into a plan B description, | 1039 // Turns the existing reference description into a plan B description, |
945 // with 2 audio tracks and 3 video tracks. | 1040 // with 2 audio tracks and 3 video tracks. |
946 void MakePlanBDescription() { | 1041 void MakePlanBDescription() { |
947 audio_desc_ = static_cast<AudioContentDescription*>(audio_desc_->Copy()); | 1042 audio_desc_ = static_cast<AudioContentDescription*>(audio_desc_->Copy()); |
948 video_desc_ = static_cast<VideoContentDescription*>(video_desc_->Copy()); | 1043 video_desc_ = static_cast<VideoContentDescription*>(video_desc_->Copy()); |
949 | 1044 |
950 StreamParams audio_track_2; | 1045 StreamParams audio_track_2; |
951 audio_track_2.id = kAudioTrackId2; | 1046 audio_track_2.id = kAudioTrackId2; |
952 audio_track_2.cname = kStream2Cname; | 1047 audio_track_2.cname = kStream2Cname; |
953 audio_track_2.sync_label = kStreamLabel2; | 1048 audio_track_2.sync_label = kStreamLabel2; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1118 void CompareSessionDescription(const SessionDescription& desc1, | 1213 void CompareSessionDescription(const SessionDescription& desc1, |
1119 const SessionDescription& desc2) { | 1214 const SessionDescription& desc2) { |
1120 // Compare content descriptions. | 1215 // Compare content descriptions. |
1121 if (desc1.contents().size() != desc2.contents().size()) { | 1216 if (desc1.contents().size() != desc2.contents().size()) { |
1122 ADD_FAILURE(); | 1217 ADD_FAILURE(); |
1123 return; | 1218 return; |
1124 } | 1219 } |
1125 for (size_t i = 0 ; i < desc1.contents().size(); ++i) { | 1220 for (size_t i = 0 ; i < desc1.contents().size(); ++i) { |
1126 const cricket::ContentInfo& c1 = desc1.contents().at(i); | 1221 const cricket::ContentInfo& c1 = desc1.contents().at(i); |
1127 const cricket::ContentInfo& c2 = desc2.contents().at(i); | 1222 const cricket::ContentInfo& c2 = desc2.contents().at(i); |
1128 // content name | 1223 // ContentInfo properties. |
1129 EXPECT_EQ(c1.name, c2.name); | 1224 EXPECT_EQ(c1.name, c2.name); |
1130 // content type | 1225 EXPECT_EQ(c1.type, c2.type); |
1131 // Note, ASSERT will return from the function, but will not stop the test. | 1226 EXPECT_EQ(c1.rejected, c2.rejected); |
1132 ASSERT_EQ(c1.type, c2.type); | 1227 EXPECT_EQ(c1.bundle_only, c2.bundle_only); |
1133 | 1228 |
1134 ASSERT_EQ(IsAudioContent(&c1), IsAudioContent(&c2)); | 1229 ASSERT_EQ(IsAudioContent(&c1), IsAudioContent(&c2)); |
1135 if (IsAudioContent(&c1)) { | 1230 if (IsAudioContent(&c1)) { |
1136 const AudioContentDescription* acd1 = | 1231 const AudioContentDescription* acd1 = |
1137 static_cast<const AudioContentDescription*>(c1.description); | 1232 static_cast<const AudioContentDescription*>(c1.description); |
1138 const AudioContentDescription* acd2 = | 1233 const AudioContentDescription* acd2 = |
1139 static_cast<const AudioContentDescription*>(c2.description); | 1234 static_cast<const AudioContentDescription*>(c2.description); |
1140 CompareMediaContentDescription<AudioContentDescription>(acd1, acd2); | 1235 CompareMediaContentDescription<AudioContentDescription>(acd1, acd2); |
1141 } | 1236 } |
1142 | 1237 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1220 const JsepSessionDescription& desc1, | 1315 const JsepSessionDescription& desc1, |
1221 const JsepSessionDescription& desc2) { | 1316 const JsepSessionDescription& desc2) { |
1222 EXPECT_EQ(desc1.session_id(), desc2.session_id()); | 1317 EXPECT_EQ(desc1.session_id(), desc2.session_id()); |
1223 EXPECT_EQ(desc1.session_version(), desc2.session_version()); | 1318 EXPECT_EQ(desc1.session_version(), desc2.session_version()); |
1224 CompareSessionDescription(*desc1.description(), *desc2.description()); | 1319 CompareSessionDescription(*desc1.description(), *desc2.description()); |
1225 if (desc1.number_of_mediasections() != desc2.number_of_mediasections()) | 1320 if (desc1.number_of_mediasections() != desc2.number_of_mediasections()) |
1226 return false; | 1321 return false; |
1227 for (size_t i = 0; i < desc1.number_of_mediasections(); ++i) { | 1322 for (size_t i = 0; i < desc1.number_of_mediasections(); ++i) { |
1228 const IceCandidateCollection* cc1 = desc1.candidates(i); | 1323 const IceCandidateCollection* cc1 = desc1.candidates(i); |
1229 const IceCandidateCollection* cc2 = desc2.candidates(i); | 1324 const IceCandidateCollection* cc2 = desc2.candidates(i); |
1230 if (cc1->count() != cc2->count()) | 1325 if (cc1->count() != cc2->count()) { |
1326 ADD_FAILURE(); | |
1231 return false; | 1327 return false; |
1328 } | |
1232 for (size_t j = 0; j < cc1->count(); ++j) { | 1329 for (size_t j = 0; j < cc1->count(); ++j) { |
1233 const IceCandidateInterface* c1 = cc1->at(j); | 1330 const IceCandidateInterface* c1 = cc1->at(j); |
1234 const IceCandidateInterface* c2 = cc2->at(j); | 1331 const IceCandidateInterface* c2 = cc2->at(j); |
1235 EXPECT_EQ(c1->sdp_mid(), c2->sdp_mid()); | 1332 EXPECT_EQ(c1->sdp_mid(), c2->sdp_mid()); |
1236 EXPECT_EQ(c1->sdp_mline_index(), c2->sdp_mline_index()); | 1333 EXPECT_EQ(c1->sdp_mline_index(), c2->sdp_mline_index()); |
1237 EXPECT_TRUE(c1->candidate().IsEquivalent(c2->candidate())); | 1334 EXPECT_TRUE(c1->candidate().IsEquivalent(c2->candidate())); |
1238 } | 1335 } |
1239 } | 1336 } |
1240 return true; | 1337 return true; |
1241 } | 1338 } |
(...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3132 static_cast<const cricket::MediaContentDescription*>( | 3229 static_cast<const cricket::MediaContentDescription*>( |
3133 desc->contents()[i].description); | 3230 desc->contents()[i].description); |
3134 EXPECT_EQ(media_types[media_content_in_sdp[i]], mdesc->type()); | 3231 EXPECT_EQ(media_types[media_content_in_sdp[i]], mdesc->type()); |
3135 } | 3232 } |
3136 | 3233 |
3137 std::string serialized_sdp = webrtc::SdpSerialize(jdesc, false); | 3234 std::string serialized_sdp = webrtc::SdpSerialize(jdesc, false); |
3138 EXPECT_EQ(sdp_string, serialized_sdp); | 3235 EXPECT_EQ(sdp_string, serialized_sdp); |
3139 } | 3236 } |
3140 } | 3237 } |
3141 | 3238 |
3239 TEST_F(WebRtcSdpTest, DeserializeBundleOnlyAttribute) { | |
3240 MakeBundleOnlyDescription(); | |
3241 JsepSessionDescription deserialized_description(kDummyString); | |
3242 EXPECT_TRUE( | |
3243 SdpDeserialize(kBundleOnlySdpFullString, &deserialized_description)); | |
3244 EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description)); | |
3245 } | |
3246 | |
3247 // "a=bundle-only" should only be used in combination with a 0 port on the m= | |
3248 // line. We should fail to parse anything else. | |
3249 TEST_F(WebRtcSdpTest, FailToDeserializeBundleOnlyWithNonzeroPort) { | |
3250 std::string bad_sdp = kBundleOnlySdpFullString; | |
3251 Replace("m=video 0", "m=video 9", &bad_sdp); | |
3252 ExpectParseFailure(bad_sdp, "a=bundle-only"); | |
3253 } | |
3254 | |
3255 TEST_F(WebRtcSdpTest, SerializeBundleOnlyAttribute) { | |
3256 MakeBundleOnlyDescription(); | |
3257 TestSerialize(jdesc_, false); | |
3258 } | |
3259 | |
3142 TEST_F(WebRtcSdpTest, DeserializePlanBSessionDescription) { | 3260 TEST_F(WebRtcSdpTest, DeserializePlanBSessionDescription) { |
3143 MakePlanBDescription(); | 3261 MakePlanBDescription(); |
3144 | 3262 |
3145 JsepSessionDescription deserialized_description(kDummyString); | 3263 JsepSessionDescription deserialized_description(kDummyString); |
3146 EXPECT_TRUE(SdpDeserialize(kPlanBSdpFullString, &deserialized_description)); | 3264 EXPECT_TRUE(SdpDeserialize(kPlanBSdpFullString, &deserialized_description)); |
3147 | 3265 |
3148 EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description)); | 3266 EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description)); |
3149 } | 3267 } |
3150 | 3268 |
3151 TEST_F(WebRtcSdpTest, SerializePlanBSessionDescription) { | 3269 TEST_F(WebRtcSdpTest, SerializePlanBSessionDescription) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3194 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" | 3312 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" |
3195 "s=-\r\n" | 3313 "s=-\r\n" |
3196 "t=0 0\r\n" | 3314 "t=0 0\r\n" |
3197 "m=video 9 UDP/DTLS/SCTP 120\r\n" | 3315 "m=video 9 UDP/DTLS/SCTP 120\r\n" |
3198 "a=sctp-port 5000\r\n" | 3316 "a=sctp-port 5000\r\n" |
3199 "a=fmtp:108 foo=10\r\n"; | 3317 "a=fmtp:108 foo=10\r\n"; |
3200 | 3318 |
3201 ExpectParseFailure(std::string(kSdpWithSctpPortInVideoDescription), | 3319 ExpectParseFailure(std::string(kSdpWithSctpPortInVideoDescription), |
3202 "sctp-port"); | 3320 "sctp-port"); |
3203 } | 3321 } |
OLD | NEW |