OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2004 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 16 matching lines...) Expand all Loading... | |
27 | 27 |
28 #define ASSERT_CRYPTO(cd, s, cs) \ | 28 #define ASSERT_CRYPTO(cd, s, cs) \ |
29 ASSERT_EQ(s, cd->cryptos().size()); \ | 29 ASSERT_EQ(s, cd->cryptos().size()); \ |
30 ASSERT_EQ(std::string(cs), cd->cryptos()[0].cipher_suite) | 30 ASSERT_EQ(std::string(cs), cd->cryptos()[0].cipher_suite) |
31 | 31 |
32 typedef std::vector<cricket::Candidate> Candidates; | 32 typedef std::vector<cricket::Candidate> Candidates; |
33 | 33 |
34 using cricket::MediaContentDescription; | 34 using cricket::MediaContentDescription; |
35 using cricket::MediaSessionDescriptionFactory; | 35 using cricket::MediaSessionDescriptionFactory; |
36 using cricket::MediaContentDirection; | 36 using cricket::MediaContentDirection; |
37 using cricket::MediaDescriptionOptions; | |
37 using cricket::MediaSessionOptions; | 38 using cricket::MediaSessionOptions; |
38 using cricket::MediaType; | 39 using cricket::MediaType; |
39 using cricket::SessionDescription; | 40 using cricket::SessionDescription; |
40 using cricket::SsrcGroup; | 41 using cricket::SsrcGroup; |
41 using cricket::StreamParams; | 42 using cricket::StreamParams; |
42 using cricket::StreamParamsVec; | 43 using cricket::StreamParamsVec; |
43 using cricket::TransportDescription; | 44 using cricket::TransportDescription; |
44 using cricket::TransportDescriptionFactory; | 45 using cricket::TransportDescriptionFactory; |
45 using cricket::TransportInfo; | 46 using cricket::TransportInfo; |
46 using cricket::ContentInfo; | 47 using cricket::ContentInfo; |
(...skipping 11 matching lines...) Expand all Loading... | |
58 using cricket::AudioCodec; | 59 using cricket::AudioCodec; |
59 using cricket::VideoCodec; | 60 using cricket::VideoCodec; |
60 using cricket::DataCodec; | 61 using cricket::DataCodec; |
61 using cricket::NS_JINGLE_RTP; | 62 using cricket::NS_JINGLE_RTP; |
62 using cricket::MEDIA_TYPE_AUDIO; | 63 using cricket::MEDIA_TYPE_AUDIO; |
63 using cricket::MEDIA_TYPE_VIDEO; | 64 using cricket::MEDIA_TYPE_VIDEO; |
64 using cricket::MEDIA_TYPE_DATA; | 65 using cricket::MEDIA_TYPE_DATA; |
65 using cricket::SEC_DISABLED; | 66 using cricket::SEC_DISABLED; |
66 using cricket::SEC_ENABLED; | 67 using cricket::SEC_ENABLED; |
67 using cricket::SEC_REQUIRED; | 68 using cricket::SEC_REQUIRED; |
69 using cricket::RtpTransceiverDirection; | |
68 using rtc::CS_AES_CM_128_HMAC_SHA1_32; | 70 using rtc::CS_AES_CM_128_HMAC_SHA1_32; |
69 using rtc::CS_AES_CM_128_HMAC_SHA1_80; | 71 using rtc::CS_AES_CM_128_HMAC_SHA1_80; |
70 using rtc::CS_AEAD_AES_128_GCM; | 72 using rtc::CS_AEAD_AES_128_GCM; |
71 using rtc::CS_AEAD_AES_256_GCM; | 73 using rtc::CS_AEAD_AES_256_GCM; |
72 using webrtc::RtpExtension; | 74 using webrtc::RtpExtension; |
73 | 75 |
74 static const AudioCodec kAudioCodecs1[] = { | 76 static const AudioCodec kAudioCodecs1[] = { |
75 AudioCodec(103, "ISAC", 16000, -1, 1), | 77 AudioCodec(103, "ISAC", 16000, -1, 1), |
76 AudioCodec(102, "iLBC", 8000, 13300, 1), | 78 AudioCodec(102, "iLBC", 8000, 13300, 1), |
77 AudioCodec(0, "PCMU", 8000, 64000, 1), | 79 AudioCodec(0, "PCMU", 8000, 64000, 1), |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 static const char kDataTrack1[] = "data_1"; | 203 static const char kDataTrack1[] = "data_1"; |
202 static const char kDataTrack2[] = "data_2"; | 204 static const char kDataTrack2[] = "data_2"; |
203 static const char kDataTrack3[] = "data_3"; | 205 static const char kDataTrack3[] = "data_3"; |
204 | 206 |
205 static const char* kMediaProtocols[] = {"RTP/AVP", "RTP/SAVP", "RTP/AVPF", | 207 static const char* kMediaProtocols[] = {"RTP/AVP", "RTP/SAVP", "RTP/AVPF", |
206 "RTP/SAVPF"}; | 208 "RTP/SAVPF"}; |
207 static const char* kMediaProtocolsDtls[] = { | 209 static const char* kMediaProtocolsDtls[] = { |
208 "TCP/TLS/RTP/SAVPF", "TCP/TLS/RTP/SAVP", "UDP/TLS/RTP/SAVPF", | 210 "TCP/TLS/RTP/SAVPF", "TCP/TLS/RTP/SAVP", "UDP/TLS/RTP/SAVPF", |
209 "UDP/TLS/RTP/SAVP"}; | 211 "UDP/TLS/RTP/SAVP"}; |
210 | 212 |
213 static constexpr bool kStopped = true; | |
214 | |
211 static bool IsMediaContentOfType(const ContentInfo* content, | 215 static bool IsMediaContentOfType(const ContentInfo* content, |
212 MediaType media_type) { | 216 MediaType media_type) { |
213 const MediaContentDescription* mdesc = | 217 const MediaContentDescription* mdesc = |
214 static_cast<const MediaContentDescription*>(content->description); | 218 static_cast<const MediaContentDescription*>(content->description); |
215 return mdesc && mdesc->type() == media_type; | 219 return mdesc && mdesc->type() == media_type; |
216 } | 220 } |
217 | 221 |
218 static cricket::MediaContentDirection | 222 static cricket::MediaContentDirection |
219 GetMediaDirection(const ContentInfo* content) { | 223 GetMediaDirection(const ContentInfo* content) { |
220 cricket::MediaContentDescription* desc = | 224 cricket::MediaContentDescription* desc = |
221 reinterpret_cast<cricket::MediaContentDescription*>(content->description); | 225 reinterpret_cast<cricket::MediaContentDescription*>(content->description); |
222 return desc->direction(); | 226 return desc->direction(); |
223 } | 227 } |
224 | 228 |
225 static void AddRtxCodec(const VideoCodec& rtx_codec, | 229 static void AddRtxCodec(const VideoCodec& rtx_codec, |
226 std::vector<VideoCodec>* codecs) { | 230 std::vector<VideoCodec>* codecs) { |
227 ASSERT_FALSE(cricket::FindCodecById(*codecs, rtx_codec.id)); | 231 ASSERT_FALSE(cricket::FindCodecById(*codecs, rtx_codec.id)); |
228 codecs->push_back(rtx_codec); | 232 codecs->push_back(rtx_codec); |
229 } | 233 } |
230 | 234 |
231 template <class T> | 235 template <class T> |
232 static std::vector<std::string> GetCodecNames(const std::vector<T>& codecs) { | 236 static std::vector<std::string> GetCodecNames(const std::vector<T>& codecs) { |
233 std::vector<std::string> codec_names; | 237 std::vector<std::string> codec_names; |
234 for (const auto& codec : codecs) { | 238 for (const auto& codec : codecs) { |
235 codec_names.push_back(codec.name); | 239 codec_names.push_back(codec.name); |
236 } | 240 } |
237 return codec_names; | 241 return codec_names; |
238 } | 242 } |
239 | 243 |
244 // MIDs are not the identification of the MediaDescriptionOptions. | |
Taylor Brandstetter
2017/08/03 00:24:48
Can you explain what this comment means?
Zhi Huang
2017/08/04 18:38:25
Done.
| |
245 std::vector<MediaDescriptionOptions>::iterator FindFirstMediaDescriptionByMid( | |
246 const std::string& mid, | |
247 MediaSessionOptions* opts) { | |
248 return std::find_if( | |
249 opts->media_description_options.begin(), | |
250 opts->media_description_options.end(), | |
251 [mid](const MediaDescriptionOptions& t) { return t.mid == mid; }); | |
252 } | |
253 | |
254 // Add a media section to the |session_options|. | |
255 static void AddMediaSection(MediaType type, | |
256 const std::string& mid, | |
257 MediaContentDirection direction, | |
258 bool stopped, | |
259 MediaSessionOptions* opts) { | |
260 opts->media_description_options.push_back(MediaDescriptionOptions( | |
261 type, mid, | |
262 cricket::RtpTransceiverDirection::FromMediaContentDirection(direction), | |
263 stopped)); | |
264 } | |
265 | |
266 static void AddAudioVideoSections(MediaContentDirection direction, | |
267 MediaSessionOptions* opts) { | |
268 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", direction, !kStopped, opts); | |
269 AddMediaSection(MEDIA_TYPE_VIDEO, "video", direction, !kStopped, opts); | |
270 } | |
271 | |
272 static void AddDataSection(cricket::DataChannelType dct, | |
273 MediaContentDirection direction, | |
274 MediaSessionOptions* opts) { | |
275 opts->data_channel_type = dct; | |
276 AddMediaSection(MEDIA_TYPE_DATA, "data", direction, !kStopped, opts); | |
277 } | |
278 | |
279 static void AttachSenderToMediaSection(const std::string& mid, | |
280 MediaType type, | |
281 const std::string& track_id, | |
282 const std::string& stream_id, | |
283 int num_sim_layer, | |
284 MediaSessionOptions* session_options) { | |
285 auto it = FindFirstMediaDescriptionByMid(mid, session_options); | |
286 switch (type) { | |
287 case MEDIA_TYPE_AUDIO: | |
288 it->AddAudioSender(track_id, stream_id); | |
289 break; | |
290 case MEDIA_TYPE_VIDEO: | |
291 it->AddVideoSender(track_id, stream_id, num_sim_layer); | |
292 break; | |
293 case MEDIA_TYPE_DATA: | |
294 it->AddRtpDataChannel(track_id, stream_id); | |
295 break; | |
296 default: | |
297 RTC_NOTREACHED(); | |
298 } | |
299 } | |
300 | |
301 static void DetachSenderFromMediaSection(const std::string& mid, | |
302 const std::string& track_id, | |
303 MediaSessionOptions* session_options) { | |
304 auto it = FindFirstMediaDescriptionByMid(mid, session_options); | |
305 auto sender_it = it->sender_options.begin(); | |
306 for (; sender_it != it->sender_options.end(); ++sender_it) { | |
307 if (sender_it->track_id == track_id) { | |
308 it->sender_options.erase(sender_it); | |
309 return; | |
310 } | |
311 } | |
312 RTC_NOTREACHED(); | |
313 } | |
314 | |
315 // Helper function used to create a default MediaSessionOptions for Plan B SDP. | |
316 // (https://tools.ietf.org/html/draft-uberti-rtcweb-plan-00). | |
317 static MediaSessionOptions CreatePlanBMediaSessionOptions() { | |
318 MediaSessionOptions session_options; | |
319 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, !kStopped, | |
320 &session_options); | |
321 return session_options; | |
322 } | |
323 | |
324 // TODO(zhihuang): Most of these tests were written while MediaSessionOptions | |
325 // was designed for Plan B SDP, where only one audio "m=" section and one video | |
326 // "m=" section could be generated, and ordering couldn't be controlled. Many of | |
327 // these tests may be obsolete as a result, and should be refactored or removed. | |
240 class MediaSessionDescriptionFactoryTest : public testing::Test { | 328 class MediaSessionDescriptionFactoryTest : public testing::Test { |
241 public: | 329 public: |
242 MediaSessionDescriptionFactoryTest() | 330 MediaSessionDescriptionFactoryTest() : f1_(&tdf1_), f2_(&tdf2_) { |
243 : f1_(&tdf1_), | |
244 f2_(&tdf2_) { | |
245 f1_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs1), | 331 f1_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs1), |
246 MAKE_VECTOR(kAudioCodecs1)); | 332 MAKE_VECTOR(kAudioCodecs1)); |
247 f1_.set_video_codecs(MAKE_VECTOR(kVideoCodecs1)); | 333 f1_.set_video_codecs(MAKE_VECTOR(kVideoCodecs1)); |
248 f1_.set_data_codecs(MAKE_VECTOR(kDataCodecs1)); | 334 f1_.set_data_codecs(MAKE_VECTOR(kDataCodecs1)); |
249 f2_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs2), | 335 f2_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs2), |
250 MAKE_VECTOR(kAudioCodecs2)); | 336 MAKE_VECTOR(kAudioCodecs2)); |
251 f2_.set_video_codecs(MAKE_VECTOR(kVideoCodecs2)); | 337 f2_.set_video_codecs(MAKE_VECTOR(kVideoCodecs2)); |
252 f2_.set_data_codecs(MAKE_VECTOR(kDataCodecs2)); | 338 f2_.set_data_codecs(MAKE_VECTOR(kDataCodecs2)); |
253 tdf1_.set_certificate(rtc::RTCCertificate::Create( | 339 tdf1_.set_certificate(rtc::RTCCertificate::Create( |
254 std::unique_ptr<rtc::SSLIdentity>(new rtc::FakeSSLIdentity("id1")))); | 340 std::unique_ptr<rtc::SSLIdentity>(new rtc::FakeSSLIdentity("id1")))); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 // Returns true if the transport info contains "renomination" as an | 384 // Returns true if the transport info contains "renomination" as an |
299 // ICE option. | 385 // ICE option. |
300 bool GetIceRenomination(const TransportInfo* transport_info) { | 386 bool GetIceRenomination(const TransportInfo* transport_info) { |
301 const std::vector<std::string>& ice_options = | 387 const std::vector<std::string>& ice_options = |
302 transport_info->description.transport_options; | 388 transport_info->description.transport_options; |
303 auto iter = | 389 auto iter = |
304 std::find(ice_options.begin(), ice_options.end(), "renomination"); | 390 std::find(ice_options.begin(), ice_options.end(), "renomination"); |
305 return iter != ice_options.end(); | 391 return iter != ice_options.end(); |
306 } | 392 } |
307 | 393 |
308 void TestTransportInfo(bool offer, const MediaSessionOptions& options, | 394 void TestTransportInfo(bool offer, |
395 MediaSessionOptions& options, | |
309 bool has_current_desc) { | 396 bool has_current_desc) { |
310 const std::string current_audio_ufrag = "current_audio_ufrag"; | 397 const std::string current_audio_ufrag = "current_audio_ufrag"; |
311 const std::string current_audio_pwd = "current_audio_pwd"; | 398 const std::string current_audio_pwd = "current_audio_pwd"; |
312 const std::string current_video_ufrag = "current_video_ufrag"; | 399 const std::string current_video_ufrag = "current_video_ufrag"; |
313 const std::string current_video_pwd = "current_video_pwd"; | 400 const std::string current_video_pwd = "current_video_pwd"; |
314 const std::string current_data_ufrag = "current_data_ufrag"; | 401 const std::string current_data_ufrag = "current_data_ufrag"; |
315 const std::string current_data_pwd = "current_data_pwd"; | 402 const std::string current_data_pwd = "current_data_pwd"; |
316 std::unique_ptr<SessionDescription> current_desc; | 403 std::unique_ptr<SessionDescription> current_desc; |
317 std::unique_ptr<SessionDescription> desc; | 404 std::unique_ptr<SessionDescription> desc; |
318 if (has_current_desc) { | 405 if (has_current_desc) { |
(...skipping 24 matching lines...) Expand all Loading... | |
343 EXPECT_TRUE(ti_audio != NULL); | 430 EXPECT_TRUE(ti_audio != NULL); |
344 if (has_current_desc) { | 431 if (has_current_desc) { |
345 EXPECT_EQ(current_audio_ufrag, ti_audio->description.ice_ufrag); | 432 EXPECT_EQ(current_audio_ufrag, ti_audio->description.ice_ufrag); |
346 EXPECT_EQ(current_audio_pwd, ti_audio->description.ice_pwd); | 433 EXPECT_EQ(current_audio_pwd, ti_audio->description.ice_pwd); |
347 } else { | 434 } else { |
348 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), | 435 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), |
349 ti_audio->description.ice_ufrag.size()); | 436 ti_audio->description.ice_ufrag.size()); |
350 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), | 437 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), |
351 ti_audio->description.ice_pwd.size()); | 438 ti_audio->description.ice_pwd.size()); |
352 } | 439 } |
353 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_audio)); | 440 auto media_desc_options_it = |
441 FindFirstMediaDescriptionByMid("audio", &options); | |
442 EXPECT_EQ( | |
443 media_desc_options_it->transport_options.enable_ice_renomination, | |
444 GetIceRenomination(ti_audio)); | |
354 | 445 |
355 } else { | 446 } else { |
356 EXPECT_TRUE(ti_audio == NULL); | 447 EXPECT_TRUE(ti_audio == NULL); |
357 } | 448 } |
358 const TransportInfo* ti_video = desc->GetTransportInfoByName("video"); | 449 const TransportInfo* ti_video = desc->GetTransportInfoByName("video"); |
359 if (options.has_video()) { | 450 if (options.has_video()) { |
360 EXPECT_TRUE(ti_video != NULL); | 451 EXPECT_TRUE(ti_video != NULL); |
361 if (options.bundle_enabled) { | 452 if (options.bundle_enabled) { |
362 EXPECT_EQ(ti_audio->description.ice_ufrag, | 453 EXPECT_EQ(ti_audio->description.ice_ufrag, |
363 ti_video->description.ice_ufrag); | 454 ti_video->description.ice_ufrag); |
364 EXPECT_EQ(ti_audio->description.ice_pwd, | 455 EXPECT_EQ(ti_audio->description.ice_pwd, |
365 ti_video->description.ice_pwd); | 456 ti_video->description.ice_pwd); |
366 } else { | 457 } else { |
367 if (has_current_desc) { | 458 if (has_current_desc) { |
368 EXPECT_EQ(current_video_ufrag, ti_video->description.ice_ufrag); | 459 EXPECT_EQ(current_video_ufrag, ti_video->description.ice_ufrag); |
369 EXPECT_EQ(current_video_pwd, ti_video->description.ice_pwd); | 460 EXPECT_EQ(current_video_pwd, ti_video->description.ice_pwd); |
370 } else { | 461 } else { |
371 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), | 462 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), |
372 ti_video->description.ice_ufrag.size()); | 463 ti_video->description.ice_ufrag.size()); |
373 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), | 464 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), |
374 ti_video->description.ice_pwd.size()); | 465 ti_video->description.ice_pwd.size()); |
375 } | 466 } |
376 } | 467 } |
377 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_video)); | 468 auto media_desc_options_it = |
469 FindFirstMediaDescriptionByMid("video", &options); | |
470 EXPECT_EQ( | |
471 media_desc_options_it->transport_options.enable_ice_renomination, | |
472 GetIceRenomination(ti_video)); | |
378 } else { | 473 } else { |
379 EXPECT_TRUE(ti_video == NULL); | 474 EXPECT_TRUE(ti_video == NULL); |
380 } | 475 } |
381 const TransportInfo* ti_data = desc->GetTransportInfoByName("data"); | 476 const TransportInfo* ti_data = desc->GetTransportInfoByName("data"); |
382 if (options.has_data()) { | 477 if (options.has_data()) { |
383 EXPECT_TRUE(ti_data != NULL); | 478 EXPECT_TRUE(ti_data != NULL); |
384 if (options.bundle_enabled) { | 479 if (options.bundle_enabled) { |
385 EXPECT_EQ(ti_audio->description.ice_ufrag, | 480 EXPECT_EQ(ti_audio->description.ice_ufrag, |
386 ti_data->description.ice_ufrag); | 481 ti_data->description.ice_ufrag); |
387 EXPECT_EQ(ti_audio->description.ice_pwd, | 482 EXPECT_EQ(ti_audio->description.ice_pwd, |
388 ti_data->description.ice_pwd); | 483 ti_data->description.ice_pwd); |
389 } else { | 484 } else { |
390 if (has_current_desc) { | 485 if (has_current_desc) { |
391 EXPECT_EQ(current_data_ufrag, ti_data->description.ice_ufrag); | 486 EXPECT_EQ(current_data_ufrag, ti_data->description.ice_ufrag); |
392 EXPECT_EQ(current_data_pwd, ti_data->description.ice_pwd); | 487 EXPECT_EQ(current_data_pwd, ti_data->description.ice_pwd); |
393 } else { | 488 } else { |
394 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), | 489 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), |
395 ti_data->description.ice_ufrag.size()); | 490 ti_data->description.ice_ufrag.size()); |
396 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), | 491 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), |
397 ti_data->description.ice_pwd.size()); | 492 ti_data->description.ice_pwd.size()); |
398 } | 493 } |
399 } | 494 } |
400 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_data)); | 495 auto media_desc_options_it = |
496 FindFirstMediaDescriptionByMid("data", &options); | |
497 EXPECT_EQ( | |
498 media_desc_options_it->transport_options.enable_ice_renomination, | |
499 GetIceRenomination(ti_data)); | |
401 | 500 |
402 } else { | 501 } else { |
403 EXPECT_TRUE(ti_video == NULL); | 502 EXPECT_TRUE(ti_video == NULL); |
404 } | 503 } |
405 } | 504 } |
406 | 505 |
407 void TestCryptoWithBundle(bool offer) { | 506 void TestCryptoWithBundle(bool offer) { |
408 f1_.set_secure(SEC_ENABLED); | 507 f1_.set_secure(SEC_ENABLED); |
409 MediaSessionOptions options; | 508 MediaSessionOptions options; |
410 options.recv_audio = true; | 509 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
411 options.recv_video = true; | 510 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
412 options.data_channel_type = cricket::DCT_RTP; | |
413 std::unique_ptr<SessionDescription> ref_desc; | 511 std::unique_ptr<SessionDescription> ref_desc; |
414 std::unique_ptr<SessionDescription> desc; | 512 std::unique_ptr<SessionDescription> desc; |
415 if (offer) { | 513 if (offer) { |
416 options.bundle_enabled = false; | 514 options.bundle_enabled = false; |
417 ref_desc.reset(f1_.CreateOffer(options, NULL)); | 515 ref_desc.reset(f1_.CreateOffer(options, NULL)); |
418 options.bundle_enabled = true; | 516 options.bundle_enabled = true; |
419 desc.reset(f1_.CreateOffer(options, ref_desc.get())); | 517 desc.reset(f1_.CreateOffer(options, ref_desc.get())); |
420 } else { | 518 } else { |
421 options.bundle_enabled = true; | 519 options.bundle_enabled = true; |
422 ref_desc.reset(f1_.CreateOffer(options, NULL)); | 520 ref_desc.reset(f1_.CreateOffer(options, NULL)); |
(...skipping 25 matching lines...) Expand all Loading... | |
448 audio_media_desc->cryptos()[0])) { | 546 audio_media_desc->cryptos()[0])) { |
449 found = true; | 547 found = true; |
450 break; | 548 break; |
451 } | 549 } |
452 } | 550 } |
453 EXPECT_TRUE(found); | 551 EXPECT_TRUE(found); |
454 } | 552 } |
455 | 553 |
456 // This test that the audio and video media direction is set to | 554 // This test that the audio and video media direction is set to |
457 // |expected_direction_in_answer| in an answer if the offer direction is set | 555 // |expected_direction_in_answer| in an answer if the offer direction is set |
458 // to |direction_in_offer|. | 556 // to |direction_in_offer| and the answer is willing to both send and receive. |
459 void TestMediaDirectionInAnswer( | 557 void TestMediaDirectionInAnswer( |
460 cricket::MediaContentDirection direction_in_offer, | 558 cricket::MediaContentDirection direction_in_offer, |
461 cricket::MediaContentDirection expected_direction_in_answer) { | 559 cricket::MediaContentDirection expected_direction_in_answer) { |
462 MediaSessionOptions opts; | 560 MediaSessionOptions offer_opts; |
463 opts.recv_video = true; | 561 AddAudioVideoSections(direction_in_offer, &offer_opts); |
464 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 562 |
563 std::unique_ptr<SessionDescription> offer( | |
564 f1_.CreateOffer(offer_opts, NULL)); | |
465 ASSERT_TRUE(offer.get() != NULL); | 565 ASSERT_TRUE(offer.get() != NULL); |
466 ContentInfo* ac_offer = offer->GetContentByName("audio"); | 566 ContentInfo* ac_offer = offer->GetContentByName("audio"); |
467 ASSERT_TRUE(ac_offer != NULL); | 567 ASSERT_TRUE(ac_offer != NULL); |
468 AudioContentDescription* acd_offer = | |
469 static_cast<AudioContentDescription*>(ac_offer->description); | |
470 acd_offer->set_direction(direction_in_offer); | |
471 ContentInfo* vc_offer = offer->GetContentByName("video"); | 568 ContentInfo* vc_offer = offer->GetContentByName("video"); |
472 ASSERT_TRUE(vc_offer != NULL); | 569 ASSERT_TRUE(vc_offer != NULL); |
473 VideoContentDescription* vcd_offer = | |
474 static_cast<VideoContentDescription*>(vc_offer->description); | |
475 vcd_offer->set_direction(direction_in_offer); | |
476 | 570 |
571 MediaSessionOptions answer_opts; | |
572 AddAudioVideoSections(cricket::MD_SENDRECV, &answer_opts); | |
477 std::unique_ptr<SessionDescription> answer( | 573 std::unique_ptr<SessionDescription> answer( |
478 f2_.CreateAnswer(offer.get(), opts, NULL)); | 574 f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
479 const AudioContentDescription* acd_answer = | 575 const AudioContentDescription* acd_answer = |
480 GetFirstAudioContentDescription(answer.get()); | 576 GetFirstAudioContentDescription(answer.get()); |
481 EXPECT_EQ(expected_direction_in_answer, acd_answer->direction()); | 577 EXPECT_EQ(expected_direction_in_answer, acd_answer->direction()); |
482 const VideoContentDescription* vcd_answer = | 578 const VideoContentDescription* vcd_answer = |
483 GetFirstVideoContentDescription(answer.get()); | 579 GetFirstVideoContentDescription(answer.get()); |
484 EXPECT_EQ(expected_direction_in_answer, vcd_answer->direction()); | 580 EXPECT_EQ(expected_direction_in_answer, vcd_answer->direction()); |
485 } | 581 } |
486 | 582 |
487 bool VerifyNoCNCodecs(const cricket::ContentInfo* content) { | 583 bool VerifyNoCNCodecs(const cricket::ContentInfo* content) { |
488 const cricket::ContentDescription* description = content->description; | 584 const cricket::ContentDescription* description = content->description; |
489 RTC_CHECK(description != NULL); | 585 RTC_CHECK(description != NULL); |
490 const cricket::AudioContentDescription* audio_content_desc = | 586 const cricket::AudioContentDescription* audio_content_desc = |
491 static_cast<const cricket::AudioContentDescription*>(description); | 587 static_cast<const cricket::AudioContentDescription*>(description); |
492 RTC_CHECK(audio_content_desc != NULL); | 588 RTC_CHECK(audio_content_desc != NULL); |
493 for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) { | 589 for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) { |
494 if (audio_content_desc->codecs()[i].name == "CN") | 590 if (audio_content_desc->codecs()[i].name == "CN") |
495 return false; | 591 return false; |
496 } | 592 } |
497 return true; | 593 return true; |
498 } | 594 } |
499 | 595 |
500 void TestVideoGcmCipher(bool gcm_offer, bool gcm_answer) { | 596 void TestVideoGcmCipher(bool gcm_offer, bool gcm_answer) { |
501 MediaSessionOptions offer_opts; | 597 MediaSessionOptions offer_opts; |
502 offer_opts.recv_video = true; | 598 AddAudioVideoSections(cricket::MD_RECVONLY, &offer_opts); |
503 offer_opts.crypto_options.enable_gcm_crypto_suites = gcm_offer; | 599 offer_opts.crypto_options.enable_gcm_crypto_suites = gcm_offer; |
600 | |
504 MediaSessionOptions answer_opts; | 601 MediaSessionOptions answer_opts; |
505 answer_opts.recv_video = true; | 602 AddAudioVideoSections(cricket::MD_RECVONLY, &answer_opts); |
506 answer_opts.crypto_options.enable_gcm_crypto_suites = gcm_answer; | 603 answer_opts.crypto_options.enable_gcm_crypto_suites = gcm_answer; |
604 | |
507 f1_.set_secure(SEC_ENABLED); | 605 f1_.set_secure(SEC_ENABLED); |
508 f2_.set_secure(SEC_ENABLED); | 606 f2_.set_secure(SEC_ENABLED); |
509 std::unique_ptr<SessionDescription> offer( | 607 std::unique_ptr<SessionDescription> offer( |
510 f1_.CreateOffer(offer_opts, NULL)); | 608 f1_.CreateOffer(offer_opts, NULL)); |
511 ASSERT_TRUE(offer.get() != NULL); | 609 ASSERT_TRUE(offer.get() != NULL); |
512 std::unique_ptr<SessionDescription> answer( | 610 std::unique_ptr<SessionDescription> answer( |
513 f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 611 f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
514 const ContentInfo* ac = answer->GetContentByName("audio"); | 612 const ContentInfo* ac = answer->GetContentByName("audio"); |
515 const ContentInfo* vc = answer->GetContentByName("video"); | 613 const ContentInfo* vc = answer->GetContentByName("video"); |
516 ASSERT_TRUE(ac != NULL); | 614 ASSERT_TRUE(ac != NULL); |
517 ASSERT_TRUE(vc != NULL); | 615 ASSERT_TRUE(vc != NULL); |
518 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 616 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
519 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 617 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); |
520 const AudioContentDescription* acd = | 618 const AudioContentDescription* acd = |
521 static_cast<const AudioContentDescription*>(ac->description); | 619 static_cast<const AudioContentDescription*>(ac->description); |
522 const VideoContentDescription* vcd = | 620 const VideoContentDescription* vcd = |
523 static_cast<const VideoContentDescription*>(vc->description); | 621 static_cast<const VideoContentDescription*>(vc->description); |
524 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 622 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
525 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 623 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
526 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 624 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
527 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 625 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached |
528 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 626 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
529 if (gcm_offer && gcm_answer) { | 627 if (gcm_offer && gcm_answer) { |
530 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); | 628 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); |
531 } else { | 629 } else { |
532 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); | 630 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); |
533 } | 631 } |
534 EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); | 632 EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); |
535 EXPECT_EQ(MAKE_VECTOR(kVideoCodecsAnswer), vcd->codecs()); | 633 EXPECT_EQ(MAKE_VECTOR(kVideoCodecsAnswer), vcd->codecs()); |
536 EXPECT_NE(0U, vcd->first_ssrc()); // a random nonzero ssrc | 634 EXPECT_EQ(0U, vcd->first_ssrc()); // no sender is attached |
537 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux | 635 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux |
538 if (gcm_offer && gcm_answer) { | 636 if (gcm_offer && gcm_answer) { |
539 ASSERT_CRYPTO(vcd, 1U, CS_AEAD_AES_256_GCM); | 637 ASSERT_CRYPTO(vcd, 1U, CS_AEAD_AES_256_GCM); |
540 } else { | 638 } else { |
541 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 639 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
542 } | 640 } |
543 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); | 641 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); |
544 } | 642 } |
545 | 643 |
546 protected: | 644 protected: |
547 MediaSessionDescriptionFactory f1_; | 645 MediaSessionDescriptionFactory f1_; |
548 MediaSessionDescriptionFactory f2_; | 646 MediaSessionDescriptionFactory f2_; |
549 TransportDescriptionFactory tdf1_; | 647 TransportDescriptionFactory tdf1_; |
550 TransportDescriptionFactory tdf2_; | 648 TransportDescriptionFactory tdf2_; |
551 }; | 649 }; |
552 | 650 |
553 // Create a typical audio offer, and ensure it matches what we expect. | 651 // Create a typical audio offer, and ensure it matches what we expect. |
554 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOffer) { | 652 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOffer) { |
555 f1_.set_secure(SEC_ENABLED); | 653 f1_.set_secure(SEC_ENABLED); |
556 std::unique_ptr<SessionDescription> offer( | 654 std::unique_ptr<SessionDescription> offer( |
557 f1_.CreateOffer(MediaSessionOptions(), NULL)); | 655 f1_.CreateOffer(CreatePlanBMediaSessionOptions(), NULL)); |
558 ASSERT_TRUE(offer.get() != NULL); | 656 ASSERT_TRUE(offer.get() != NULL); |
559 const ContentInfo* ac = offer->GetContentByName("audio"); | 657 const ContentInfo* ac = offer->GetContentByName("audio"); |
560 const ContentInfo* vc = offer->GetContentByName("video"); | 658 const ContentInfo* vc = offer->GetContentByName("video"); |
561 ASSERT_TRUE(ac != NULL); | 659 ASSERT_TRUE(ac != NULL); |
562 ASSERT_TRUE(vc == NULL); | 660 ASSERT_TRUE(vc == NULL); |
563 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 661 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
564 const AudioContentDescription* acd = | 662 const AudioContentDescription* acd = |
565 static_cast<const AudioContentDescription*>(ac->description); | 663 static_cast<const AudioContentDescription*>(ac->description); |
566 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 664 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
567 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); | 665 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); |
568 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 666 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached. |
569 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) | 667 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) |
570 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on | 668 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on |
571 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); | 669 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); |
572 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 670 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
573 } | 671 } |
574 | 672 |
575 // Create a typical video offer, and ensure it matches what we expect. | 673 // Create a typical video offer, and ensure it matches what we expect. |
576 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoOffer) { | 674 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoOffer) { |
577 MediaSessionOptions opts; | 675 MediaSessionOptions opts; |
578 opts.recv_video = true; | 676 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
579 f1_.set_secure(SEC_ENABLED); | 677 f1_.set_secure(SEC_ENABLED); |
580 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 678 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
581 ASSERT_TRUE(offer.get() != NULL); | 679 ASSERT_TRUE(offer.get() != NULL); |
582 const ContentInfo* ac = offer->GetContentByName("audio"); | 680 const ContentInfo* ac = offer->GetContentByName("audio"); |
583 const ContentInfo* vc = offer->GetContentByName("video"); | 681 const ContentInfo* vc = offer->GetContentByName("video"); |
584 ASSERT_TRUE(ac != NULL); | 682 ASSERT_TRUE(ac != NULL); |
585 ASSERT_TRUE(vc != NULL); | 683 ASSERT_TRUE(vc != NULL); |
586 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 684 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
587 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 685 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); |
588 const AudioContentDescription* acd = | 686 const AudioContentDescription* acd = |
589 static_cast<const AudioContentDescription*>(ac->description); | 687 static_cast<const AudioContentDescription*>(ac->description); |
590 const VideoContentDescription* vcd = | 688 const VideoContentDescription* vcd = |
591 static_cast<const VideoContentDescription*>(vc->description); | 689 static_cast<const VideoContentDescription*>(vc->description); |
592 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 690 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
593 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); | 691 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); |
594 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 692 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached |
595 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) | 693 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) |
596 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on | 694 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on |
597 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); | 695 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); |
598 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 696 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
599 EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); | 697 EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); |
600 EXPECT_EQ(f1_.video_codecs(), vcd->codecs()); | 698 EXPECT_EQ(f1_.video_codecs(), vcd->codecs()); |
601 EXPECT_NE(0U, vcd->first_ssrc()); // a random nonzero ssrc | 699 EXPECT_EQ(0U, vcd->first_ssrc()); // no sender is attached |
602 EXPECT_EQ(kAutoBandwidth, vcd->bandwidth()); // default bandwidth (auto) | 700 EXPECT_EQ(kAutoBandwidth, vcd->bandwidth()); // default bandwidth (auto) |
603 EXPECT_TRUE(vcd->rtcp_mux()); // rtcp-mux defaults on | 701 EXPECT_TRUE(vcd->rtcp_mux()); // rtcp-mux defaults on |
604 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 702 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
605 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); | 703 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); |
606 } | 704 } |
607 | 705 |
608 // Test creating an offer with bundle where the Codecs have the same dynamic | 706 // Test creating an offer with bundle where the Codecs have the same dynamic |
609 // RTP playlod type. The test verifies that the offer don't contain the | 707 // RTP playlod type. The test verifies that the offer don't contain the |
610 // duplicate RTP payload types. | 708 // duplicate RTP payload types. |
611 TEST_F(MediaSessionDescriptionFactoryTest, TestBundleOfferWithSameCodecPlType) { | 709 TEST_F(MediaSessionDescriptionFactoryTest, TestBundleOfferWithSameCodecPlType) { |
612 const VideoCodec& offered_video_codec = f2_.video_codecs()[0]; | 710 const VideoCodec& offered_video_codec = f2_.video_codecs()[0]; |
613 const AudioCodec& offered_audio_codec = f2_.audio_sendrecv_codecs()[0]; | 711 const AudioCodec& offered_audio_codec = f2_.audio_sendrecv_codecs()[0]; |
614 const DataCodec& offered_data_codec = f2_.data_codecs()[0]; | 712 const DataCodec& offered_data_codec = f2_.data_codecs()[0]; |
615 ASSERT_EQ(offered_video_codec.id, offered_audio_codec.id); | 713 ASSERT_EQ(offered_video_codec.id, offered_audio_codec.id); |
616 ASSERT_EQ(offered_video_codec.id, offered_data_codec.id); | 714 ASSERT_EQ(offered_video_codec.id, offered_data_codec.id); |
617 | 715 |
618 MediaSessionOptions opts; | 716 MediaSessionOptions opts; |
619 opts.recv_audio = true; | 717 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
620 opts.recv_video = true; | 718 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
621 opts.data_channel_type = cricket::DCT_RTP; | |
622 opts.bundle_enabled = true; | 719 opts.bundle_enabled = true; |
623 std::unique_ptr<SessionDescription> offer(f2_.CreateOffer(opts, NULL)); | 720 std::unique_ptr<SessionDescription> offer(f2_.CreateOffer(opts, NULL)); |
624 const VideoContentDescription* vcd = | 721 const VideoContentDescription* vcd = |
625 GetFirstVideoContentDescription(offer.get()); | 722 GetFirstVideoContentDescription(offer.get()); |
626 const AudioContentDescription* acd = | 723 const AudioContentDescription* acd = |
627 GetFirstAudioContentDescription(offer.get()); | 724 GetFirstAudioContentDescription(offer.get()); |
628 const DataContentDescription* dcd = | 725 const DataContentDescription* dcd = |
629 GetFirstDataContentDescription(offer.get()); | 726 GetFirstDataContentDescription(offer.get()); |
630 ASSERT_TRUE(NULL != vcd); | 727 ASSERT_TRUE(NULL != vcd); |
631 ASSERT_TRUE(NULL != acd); | 728 ASSERT_TRUE(NULL != acd); |
632 ASSERT_TRUE(NULL != dcd); | 729 ASSERT_TRUE(NULL != dcd); |
633 EXPECT_NE(vcd->codecs()[0].id, acd->codecs()[0].id); | 730 EXPECT_NE(vcd->codecs()[0].id, acd->codecs()[0].id); |
634 EXPECT_NE(vcd->codecs()[0].id, dcd->codecs()[0].id); | 731 EXPECT_NE(vcd->codecs()[0].id, dcd->codecs()[0].id); |
635 EXPECT_NE(acd->codecs()[0].id, dcd->codecs()[0].id); | 732 EXPECT_NE(acd->codecs()[0].id, dcd->codecs()[0].id); |
636 EXPECT_EQ(vcd->codecs()[0].name, offered_video_codec.name); | 733 EXPECT_EQ(vcd->codecs()[0].name, offered_video_codec.name); |
637 EXPECT_EQ(acd->codecs()[0].name, offered_audio_codec.name); | 734 EXPECT_EQ(acd->codecs()[0].name, offered_audio_codec.name); |
638 EXPECT_EQ(dcd->codecs()[0].name, offered_data_codec.name); | 735 EXPECT_EQ(dcd->codecs()[0].name, offered_data_codec.name); |
639 } | 736 } |
640 | 737 |
641 // Test creating an updated offer with with bundle, audio, video and data | 738 // Test creating an updated offer with with bundle, audio, video and data |
642 // after an audio only session has been negotiated. | 739 // after an audio only session has been negotiated. |
643 TEST_F(MediaSessionDescriptionFactoryTest, | 740 TEST_F(MediaSessionDescriptionFactoryTest, |
644 TestCreateUpdatedVideoOfferWithBundle) { | 741 TestCreateUpdatedVideoOfferWithBundle) { |
645 f1_.set_secure(SEC_ENABLED); | 742 f1_.set_secure(SEC_ENABLED); |
646 f2_.set_secure(SEC_ENABLED); | 743 f2_.set_secure(SEC_ENABLED); |
647 MediaSessionOptions opts; | 744 MediaSessionOptions opts; |
648 opts.recv_audio = true; | 745 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, !kStopped, |
649 opts.recv_video = false; | 746 &opts); |
747 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_INACTIVE, kStopped, | |
748 &opts); | |
650 opts.data_channel_type = cricket::DCT_NONE; | 749 opts.data_channel_type = cricket::DCT_NONE; |
651 opts.bundle_enabled = true; | 750 opts.bundle_enabled = true; |
652 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 751 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
653 std::unique_ptr<SessionDescription> answer( | 752 std::unique_ptr<SessionDescription> answer( |
654 f2_.CreateAnswer(offer.get(), opts, NULL)); | 753 f2_.CreateAnswer(offer.get(), opts, NULL)); |
655 | 754 |
656 MediaSessionOptions updated_opts; | 755 MediaSessionOptions updated_opts; |
657 updated_opts.recv_audio = true; | 756 AddAudioVideoSections(cricket::MD_RECVONLY, &updated_opts); |
658 updated_opts.recv_video = true; | 757 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &updated_opts); |
659 updated_opts.data_channel_type = cricket::DCT_RTP; | |
660 updated_opts.bundle_enabled = true; | 758 updated_opts.bundle_enabled = true; |
661 std::unique_ptr<SessionDescription> updated_offer( | 759 std::unique_ptr<SessionDescription> updated_offer( |
662 f1_.CreateOffer(updated_opts, answer.get())); | 760 f1_.CreateOffer(updated_opts, answer.get())); |
663 | 761 |
664 const AudioContentDescription* acd = | 762 const AudioContentDescription* acd = |
665 GetFirstAudioContentDescription(updated_offer.get()); | 763 GetFirstAudioContentDescription(updated_offer.get()); |
666 const VideoContentDescription* vcd = | 764 const VideoContentDescription* vcd = |
667 GetFirstVideoContentDescription(updated_offer.get()); | 765 GetFirstVideoContentDescription(updated_offer.get()); |
668 const DataContentDescription* dcd = | 766 const DataContentDescription* dcd = |
669 GetFirstDataContentDescription(updated_offer.get()); | 767 GetFirstDataContentDescription(updated_offer.get()); |
670 EXPECT_TRUE(NULL != vcd); | 768 EXPECT_TRUE(NULL != vcd); |
671 EXPECT_TRUE(NULL != acd); | 769 EXPECT_TRUE(NULL != acd); |
672 EXPECT_TRUE(NULL != dcd); | 770 EXPECT_TRUE(NULL != dcd); |
673 | 771 |
674 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 772 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
675 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 773 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
676 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 774 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
677 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); | 775 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); |
678 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 776 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
679 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); | 777 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); |
680 } | 778 } |
681 | 779 |
682 // Create a RTP data offer, and ensure it matches what we expect. | 780 // Create a RTP data offer, and ensure it matches what we expect. |
683 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateRtpDataOffer) { | 781 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateRtpDataOffer) { |
684 MediaSessionOptions opts; | 782 MediaSessionOptions opts; |
685 opts.data_channel_type = cricket::DCT_RTP; | 783 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
784 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); | |
686 f1_.set_secure(SEC_ENABLED); | 785 f1_.set_secure(SEC_ENABLED); |
687 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 786 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
688 ASSERT_TRUE(offer.get() != NULL); | 787 ASSERT_TRUE(offer.get() != NULL); |
689 const ContentInfo* ac = offer->GetContentByName("audio"); | 788 const ContentInfo* ac = offer->GetContentByName("audio"); |
690 const ContentInfo* dc = offer->GetContentByName("data"); | 789 const ContentInfo* dc = offer->GetContentByName("data"); |
691 ASSERT_TRUE(ac != NULL); | 790 ASSERT_TRUE(ac != NULL); |
692 ASSERT_TRUE(dc != NULL); | 791 ASSERT_TRUE(dc != NULL); |
693 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 792 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
694 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); | 793 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); |
695 const AudioContentDescription* acd = | 794 const AudioContentDescription* acd = |
696 static_cast<const AudioContentDescription*>(ac->description); | 795 static_cast<const AudioContentDescription*>(ac->description); |
697 const DataContentDescription* dcd = | 796 const DataContentDescription* dcd = |
698 static_cast<const DataContentDescription*>(dc->description); | 797 static_cast<const DataContentDescription*>(dc->description); |
699 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 798 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
700 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); | 799 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); |
701 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 800 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attched. |
702 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) | 801 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) |
703 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on | 802 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on |
704 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); | 803 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); |
705 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 804 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
706 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); | 805 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); |
707 EXPECT_EQ(f1_.data_codecs(), dcd->codecs()); | 806 EXPECT_EQ(f1_.data_codecs(), dcd->codecs()); |
708 EXPECT_NE(0U, dcd->first_ssrc()); // a random nonzero ssrc | 807 EXPECT_EQ(0U, dcd->first_ssrc()); // no sender is attached. |
709 EXPECT_EQ(cricket::kDataMaxBandwidth, | 808 EXPECT_EQ(cricket::kDataMaxBandwidth, |
710 dcd->bandwidth()); // default bandwidth (auto) | 809 dcd->bandwidth()); // default bandwidth (auto) |
711 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on | 810 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on |
712 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 811 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
713 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); | 812 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); |
714 } | 813 } |
715 | 814 |
716 // Create an SCTP data offer with bundle without error. | 815 // Create an SCTP data offer with bundle without error. |
717 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSctpDataOffer) { | 816 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSctpDataOffer) { |
718 MediaSessionOptions opts; | 817 MediaSessionOptions opts; |
719 opts.recv_audio = false; | |
720 opts.bundle_enabled = true; | 818 opts.bundle_enabled = true; |
721 opts.data_channel_type = cricket::DCT_SCTP; | 819 AddDataSection(cricket::DCT_SCTP, cricket::MD_SENDRECV, &opts); |
722 f1_.set_secure(SEC_ENABLED); | 820 f1_.set_secure(SEC_ENABLED); |
723 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 821 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
724 EXPECT_TRUE(offer.get() != NULL); | 822 EXPECT_TRUE(offer.get() != NULL); |
725 EXPECT_TRUE(offer->GetContentByName("data") != NULL); | 823 EXPECT_TRUE(offer->GetContentByName("data") != NULL); |
726 } | 824 } |
727 | 825 |
728 // Test creating an sctp data channel from an already generated offer. | 826 // Test creating an sctp data channel from an already generated offer. |
729 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateImplicitSctpDataOffer) { | 827 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateImplicitSctpDataOffer) { |
730 MediaSessionOptions opts; | 828 MediaSessionOptions opts; |
731 opts.recv_audio = false; | |
732 opts.bundle_enabled = true; | 829 opts.bundle_enabled = true; |
733 opts.data_channel_type = cricket::DCT_SCTP; | 830 AddDataSection(cricket::DCT_SCTP, cricket::MD_SENDRECV, &opts); |
734 f1_.set_secure(SEC_ENABLED); | 831 f1_.set_secure(SEC_ENABLED); |
735 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); | 832 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); |
736 ASSERT_TRUE(offer1.get() != NULL); | 833 ASSERT_TRUE(offer1.get() != NULL); |
737 const ContentInfo* data = offer1->GetContentByName("data"); | 834 const ContentInfo* data = offer1->GetContentByName("data"); |
738 ASSERT_TRUE(data != NULL); | 835 ASSERT_TRUE(data != NULL); |
739 const MediaContentDescription* mdesc = | 836 const MediaContentDescription* mdesc = |
740 static_cast<const MediaContentDescription*>(data->description); | 837 static_cast<const MediaContentDescription*>(data->description); |
741 ASSERT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol()); | 838 ASSERT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol()); |
742 | 839 |
743 // Now set data_channel_type to 'none' (default) and make sure that the | 840 // Now set data_channel_type to 'none' (default) and make sure that the |
744 // datachannel type that gets generated from the previous offer, is of the | 841 // datachannel type that gets generated from the previous offer, is of the |
745 // same type. | 842 // same type. |
746 opts.data_channel_type = cricket::DCT_NONE; | 843 opts.data_channel_type = cricket::DCT_NONE; |
747 std::unique_ptr<SessionDescription> offer2( | 844 std::unique_ptr<SessionDescription> offer2( |
748 f1_.CreateOffer(opts, offer1.get())); | 845 f1_.CreateOffer(opts, offer1.get())); |
749 data = offer2->GetContentByName("data"); | 846 data = offer2->GetContentByName("data"); |
750 ASSERT_TRUE(data != NULL); | 847 ASSERT_TRUE(data != NULL); |
751 mdesc = static_cast<const MediaContentDescription*>(data->description); | 848 mdesc = static_cast<const MediaContentDescription*>(data->description); |
752 EXPECT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol()); | 849 EXPECT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol()); |
753 } | 850 } |
754 | 851 |
755 // Create an audio, video offer without legacy StreamParams. | 852 // Create an audio, video offer without legacy StreamParams. |
756 TEST_F(MediaSessionDescriptionFactoryTest, | 853 TEST_F(MediaSessionDescriptionFactoryTest, |
757 TestCreateOfferWithoutLegacyStreams) { | 854 TestCreateOfferWithoutLegacyStreams) { |
758 MediaSessionOptions opts; | 855 MediaSessionOptions opts; |
759 opts.recv_video = true; | 856 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
760 f1_.set_add_legacy_streams(false); | |
761 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 857 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
762 ASSERT_TRUE(offer.get() != NULL); | 858 ASSERT_TRUE(offer.get() != NULL); |
763 const ContentInfo* ac = offer->GetContentByName("audio"); | 859 const ContentInfo* ac = offer->GetContentByName("audio"); |
764 const ContentInfo* vc = offer->GetContentByName("video"); | 860 const ContentInfo* vc = offer->GetContentByName("video"); |
765 ASSERT_TRUE(ac != NULL); | 861 ASSERT_TRUE(ac != NULL); |
766 ASSERT_TRUE(vc != NULL); | 862 ASSERT_TRUE(vc != NULL); |
767 const AudioContentDescription* acd = | 863 const AudioContentDescription* acd = |
768 static_cast<const AudioContentDescription*>(ac->description); | 864 static_cast<const AudioContentDescription*>(ac->description); |
769 const VideoContentDescription* vcd = | 865 const VideoContentDescription* vcd = |
770 static_cast<const VideoContentDescription*>(vc->description); | 866 static_cast<const VideoContentDescription*>(vc->description); |
771 | 867 |
772 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. | 868 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. |
773 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. | 869 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. |
774 } | 870 } |
775 | 871 |
776 // Creates an audio+video sendonly offer. | 872 // Creates an audio+video sendonly offer. |
777 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSendOnlyOffer) { | 873 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSendOnlyOffer) { |
778 MediaSessionOptions options; | 874 MediaSessionOptions opts; |
779 options.recv_audio = false; | 875 AddAudioVideoSections(cricket::MD_SENDONLY, &opts); |
780 options.recv_video = false; | 876 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, kVideoTrack1, |
781 options.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); | 877 kMediaStream1, 1, &opts); |
782 options.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 878 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1, |
879 kMediaStream1, 1, &opts); | |
783 | 880 |
784 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL)); | 881 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
785 ASSERT_TRUE(offer.get() != NULL); | 882 ASSERT_TRUE(offer.get() != NULL); |
786 EXPECT_EQ(2u, offer->contents().size()); | 883 EXPECT_EQ(2u, offer->contents().size()); |
787 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[0], MEDIA_TYPE_AUDIO)); | 884 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[0], MEDIA_TYPE_AUDIO)); |
788 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[1], MEDIA_TYPE_VIDEO)); | 885 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[1], MEDIA_TYPE_VIDEO)); |
789 | 886 |
790 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[0])); | 887 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[0])); |
791 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[1])); | 888 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[1])); |
792 } | 889 } |
793 | 890 |
794 // Verifies that the order of the media contents in the current | 891 // Verifies that the order of the media contents in the current |
795 // SessionDescription is preserved in the new SessionDescription. | 892 // SessionDescription is preserved in the new SessionDescription. |
796 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateOfferContentOrder) { | 893 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateOfferContentOrder) { |
797 MediaSessionOptions opts; | 894 MediaSessionOptions opts; |
798 opts.recv_audio = false; | 895 AddDataSection(cricket::DCT_SCTP, cricket::MD_SENDRECV, &opts); |
799 opts.recv_video = false; | |
800 opts.data_channel_type = cricket::DCT_SCTP; | |
801 | 896 |
802 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); | 897 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); |
803 ASSERT_TRUE(offer1.get() != NULL); | 898 ASSERT_TRUE(offer1.get() != NULL); |
804 EXPECT_EQ(1u, offer1->contents().size()); | 899 EXPECT_EQ(1u, offer1->contents().size()); |
805 EXPECT_TRUE(IsMediaContentOfType(&offer1->contents()[0], MEDIA_TYPE_DATA)); | 900 EXPECT_TRUE(IsMediaContentOfType(&offer1->contents()[0], MEDIA_TYPE_DATA)); |
806 | 901 |
807 opts.recv_video = true; | 902 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, !kStopped, |
903 &opts); | |
808 std::unique_ptr<SessionDescription> offer2( | 904 std::unique_ptr<SessionDescription> offer2( |
809 f1_.CreateOffer(opts, offer1.get())); | 905 f1_.CreateOffer(opts, offer1.get())); |
810 ASSERT_TRUE(offer2.get() != NULL); | 906 ASSERT_TRUE(offer2.get() != NULL); |
811 EXPECT_EQ(2u, offer2->contents().size()); | 907 EXPECT_EQ(2u, offer2->contents().size()); |
812 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[0], MEDIA_TYPE_DATA)); | 908 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[0], MEDIA_TYPE_DATA)); |
813 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[1], MEDIA_TYPE_VIDEO)); | 909 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[1], MEDIA_TYPE_VIDEO)); |
814 | 910 |
815 opts.recv_audio = true; | 911 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, !kStopped, |
912 &opts); | |
816 std::unique_ptr<SessionDescription> offer3( | 913 std::unique_ptr<SessionDescription> offer3( |
817 f1_.CreateOffer(opts, offer2.get())); | 914 f1_.CreateOffer(opts, offer2.get())); |
818 ASSERT_TRUE(offer3.get() != NULL); | 915 ASSERT_TRUE(offer3.get() != NULL); |
819 EXPECT_EQ(3u, offer3->contents().size()); | 916 EXPECT_EQ(3u, offer3->contents().size()); |
820 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[0], MEDIA_TYPE_DATA)); | 917 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[0], MEDIA_TYPE_DATA)); |
821 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[1], MEDIA_TYPE_VIDEO)); | 918 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[1], MEDIA_TYPE_VIDEO)); |
822 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[2], MEDIA_TYPE_AUDIO)); | 919 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[2], MEDIA_TYPE_AUDIO)); |
823 | |
824 // Verifies the default order is audio-video-data, so that the previous checks | |
825 // didn't pass by accident. | |
826 std::unique_ptr<SessionDescription> offer4(f1_.CreateOffer(opts, NULL)); | |
827 ASSERT_TRUE(offer4.get() != NULL); | |
828 EXPECT_EQ(3u, offer4->contents().size()); | |
829 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[0], MEDIA_TYPE_AUDIO)); | |
830 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[1], MEDIA_TYPE_VIDEO)); | |
831 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[2], MEDIA_TYPE_DATA)); | |
832 } | 920 } |
833 | 921 |
834 // Create a typical audio answer, and ensure it matches what we expect. | 922 // Create a typical audio answer, and ensure it matches what we expect. |
835 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswer) { | 923 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswer) { |
836 f1_.set_secure(SEC_ENABLED); | 924 f1_.set_secure(SEC_ENABLED); |
837 f2_.set_secure(SEC_ENABLED); | 925 f2_.set_secure(SEC_ENABLED); |
838 std::unique_ptr<SessionDescription> offer( | 926 std::unique_ptr<SessionDescription> offer( |
839 f1_.CreateOffer(MediaSessionOptions(), NULL)); | 927 f1_.CreateOffer(CreatePlanBMediaSessionOptions(), NULL)); |
840 ASSERT_TRUE(offer.get() != NULL); | 928 ASSERT_TRUE(offer.get() != NULL); |
841 std::unique_ptr<SessionDescription> answer( | 929 std::unique_ptr<SessionDescription> answer( |
842 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 930 f2_.CreateAnswer(offer.get(), CreatePlanBMediaSessionOptions(), NULL)); |
843 const ContentInfo* ac = answer->GetContentByName("audio"); | 931 const ContentInfo* ac = answer->GetContentByName("audio"); |
844 const ContentInfo* vc = answer->GetContentByName("video"); | 932 const ContentInfo* vc = answer->GetContentByName("video"); |
845 ASSERT_TRUE(ac != NULL); | 933 ASSERT_TRUE(ac != NULL); |
846 ASSERT_TRUE(vc == NULL); | 934 ASSERT_TRUE(vc == NULL); |
847 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 935 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
848 const AudioContentDescription* acd = | 936 const AudioContentDescription* acd = |
849 static_cast<const AudioContentDescription*>(ac->description); | 937 static_cast<const AudioContentDescription*>(ac->description); |
850 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 938 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
851 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 939 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
852 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 940 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached |
853 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 941 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
854 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 942 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
855 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); | 943 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); |
856 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 944 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
857 } | 945 } |
858 | 946 |
859 // Create a typical audio answer with GCM ciphers enabled, and ensure it | 947 // Create a typical audio answer with GCM ciphers enabled, and ensure it |
860 // matches what we expect. | 948 // matches what we expect. |
861 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerGcm) { | 949 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerGcm) { |
862 f1_.set_secure(SEC_ENABLED); | 950 f1_.set_secure(SEC_ENABLED); |
863 f2_.set_secure(SEC_ENABLED); | 951 f2_.set_secure(SEC_ENABLED); |
864 MediaSessionOptions options; | 952 MediaSessionOptions opts; |
865 options.crypto_options.enable_gcm_crypto_suites = true; | 953 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kStopped, |
866 std::unique_ptr<SessionDescription> offer( | 954 &opts); |
867 f1_.CreateOffer(options, NULL)); | 955 opts.crypto_options.enable_gcm_crypto_suites = true; |
956 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | |
868 ASSERT_TRUE(offer.get() != NULL); | 957 ASSERT_TRUE(offer.get() != NULL); |
869 std::unique_ptr<SessionDescription> answer( | 958 std::unique_ptr<SessionDescription> answer( |
870 f2_.CreateAnswer(offer.get(), options, NULL)); | 959 f2_.CreateAnswer(offer.get(), opts, NULL)); |
871 const ContentInfo* ac = answer->GetContentByName("audio"); | 960 const ContentInfo* ac = answer->GetContentByName("audio"); |
872 const ContentInfo* vc = answer->GetContentByName("video"); | 961 const ContentInfo* vc = answer->GetContentByName("video"); |
873 ASSERT_TRUE(ac != NULL); | 962 ASSERT_TRUE(ac != NULL); |
874 ASSERT_TRUE(vc == NULL); | 963 ASSERT_TRUE(vc == NULL); |
875 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 964 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
876 const AudioContentDescription* acd = | 965 const AudioContentDescription* acd = |
877 static_cast<const AudioContentDescription*>(ac->description); | 966 static_cast<const AudioContentDescription*>(ac->description); |
878 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 967 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
879 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 968 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
880 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 969 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached |
881 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 970 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
882 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 971 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
883 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); | 972 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); |
884 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 973 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
885 } | 974 } |
886 | 975 |
887 // Create a typical video answer, and ensure it matches what we expect. | 976 // Create a typical video answer, and ensure it matches what we expect. |
888 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswer) { | 977 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswer) { |
889 MediaSessionOptions opts; | 978 MediaSessionOptions opts; |
890 opts.recv_video = true; | 979 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
891 f1_.set_secure(SEC_ENABLED); | 980 f1_.set_secure(SEC_ENABLED); |
892 f2_.set_secure(SEC_ENABLED); | 981 f2_.set_secure(SEC_ENABLED); |
893 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 982 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
894 ASSERT_TRUE(offer.get() != NULL); | 983 ASSERT_TRUE(offer.get() != NULL); |
895 std::unique_ptr<SessionDescription> answer( | 984 std::unique_ptr<SessionDescription> answer( |
896 f2_.CreateAnswer(offer.get(), opts, NULL)); | 985 f2_.CreateAnswer(offer.get(), opts, NULL)); |
897 const ContentInfo* ac = answer->GetContentByName("audio"); | 986 const ContentInfo* ac = answer->GetContentByName("audio"); |
898 const ContentInfo* vc = answer->GetContentByName("video"); | 987 const ContentInfo* vc = answer->GetContentByName("video"); |
899 ASSERT_TRUE(ac != NULL); | 988 ASSERT_TRUE(ac != NULL); |
900 ASSERT_TRUE(vc != NULL); | 989 ASSERT_TRUE(vc != NULL); |
901 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 990 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
902 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 991 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); |
903 const AudioContentDescription* acd = | 992 const AudioContentDescription* acd = |
904 static_cast<const AudioContentDescription*>(ac->description); | 993 static_cast<const AudioContentDescription*>(ac->description); |
905 const VideoContentDescription* vcd = | 994 const VideoContentDescription* vcd = |
906 static_cast<const VideoContentDescription*>(vc->description); | 995 static_cast<const VideoContentDescription*>(vc->description); |
907 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 996 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
908 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 997 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
909 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 998 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
910 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 999 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached |
911 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 1000 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
912 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); | 1001 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); |
913 EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); | 1002 EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); |
914 EXPECT_EQ(MAKE_VECTOR(kVideoCodecsAnswer), vcd->codecs()); | 1003 EXPECT_EQ(MAKE_VECTOR(kVideoCodecsAnswer), vcd->codecs()); |
915 EXPECT_NE(0U, vcd->first_ssrc()); // a random nonzero ssrc | 1004 EXPECT_EQ(0U, vcd->first_ssrc()); // no sender is attached |
916 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux | 1005 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux |
917 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 1006 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
918 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); | 1007 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); |
919 } | 1008 } |
920 | 1009 |
921 // Create a typical video answer with GCM ciphers enabled, and ensure it | 1010 // Create a typical video answer with GCM ciphers enabled, and ensure it |
922 // matches what we expect. | 1011 // matches what we expect. |
923 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerGcm) { | 1012 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerGcm) { |
924 TestVideoGcmCipher(true, true); | 1013 TestVideoGcmCipher(true, true); |
925 } | 1014 } |
926 | 1015 |
927 // Create a typical video answer with GCM ciphers enabled for the offer only, | 1016 // Create a typical video answer with GCM ciphers enabled for the offer only, |
928 // and ensure it matches what we expect. | 1017 // and ensure it matches what we expect. |
929 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerGcmOffer) { | 1018 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerGcmOffer) { |
930 TestVideoGcmCipher(true, false); | 1019 TestVideoGcmCipher(true, false); |
931 } | 1020 } |
932 | 1021 |
933 // Create a typical video answer with GCM ciphers enabled for the answer only, | 1022 // Create a typical video answer with GCM ciphers enabled for the answer only, |
934 // and ensure it matches what we expect. | 1023 // and ensure it matches what we expect. |
935 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerGcmAnswer) { | 1024 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerGcmAnswer) { |
936 TestVideoGcmCipher(false, true); | 1025 TestVideoGcmCipher(false, true); |
937 } | 1026 } |
938 | 1027 |
939 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswer) { | 1028 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswer) { |
940 MediaSessionOptions opts; | 1029 MediaSessionOptions opts = CreatePlanBMediaSessionOptions(); |
941 opts.data_channel_type = cricket::DCT_RTP; | 1030 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
942 f1_.set_secure(SEC_ENABLED); | 1031 f1_.set_secure(SEC_ENABLED); |
943 f2_.set_secure(SEC_ENABLED); | 1032 f2_.set_secure(SEC_ENABLED); |
944 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1033 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
945 ASSERT_TRUE(offer.get() != NULL); | 1034 ASSERT_TRUE(offer.get() != NULL); |
946 std::unique_ptr<SessionDescription> answer( | 1035 std::unique_ptr<SessionDescription> answer( |
947 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1036 f2_.CreateAnswer(offer.get(), opts, NULL)); |
948 const ContentInfo* ac = answer->GetContentByName("audio"); | 1037 const ContentInfo* ac = answer->GetContentByName("audio"); |
949 const ContentInfo* dc = answer->GetContentByName("data"); | 1038 const ContentInfo* dc = answer->GetContentByName("data"); |
950 ASSERT_TRUE(ac != NULL); | 1039 ASSERT_TRUE(ac != NULL); |
951 ASSERT_TRUE(dc != NULL); | 1040 ASSERT_TRUE(dc != NULL); |
952 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 1041 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
953 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); | 1042 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); |
954 const AudioContentDescription* acd = | 1043 const AudioContentDescription* acd = |
955 static_cast<const AudioContentDescription*>(ac->description); | 1044 static_cast<const AudioContentDescription*>(ac->description); |
956 const DataContentDescription* dcd = | 1045 const DataContentDescription* dcd = |
957 static_cast<const DataContentDescription*>(dc->description); | 1046 static_cast<const DataContentDescription*>(dc->description); |
958 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 1047 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
959 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 1048 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
960 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 1049 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
961 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 1050 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached |
962 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 1051 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
963 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); | 1052 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); |
964 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); | 1053 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); |
965 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), dcd->codecs()); | 1054 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), dcd->codecs()); |
966 EXPECT_NE(0U, dcd->first_ssrc()); // a random nonzero ssrc | 1055 EXPECT_EQ(0U, dcd->first_ssrc()); // no sender is attached |
967 EXPECT_TRUE(dcd->rtcp_mux()); // negotiated rtcp-mux | 1056 EXPECT_TRUE(dcd->rtcp_mux()); // negotiated rtcp-mux |
968 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 1057 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
969 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); | 1058 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); |
970 } | 1059 } |
971 | 1060 |
972 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerGcm) { | 1061 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerGcm) { |
973 MediaSessionOptions opts; | 1062 MediaSessionOptions opts = CreatePlanBMediaSessionOptions(); |
974 opts.data_channel_type = cricket::DCT_RTP; | 1063 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
975 opts.crypto_options.enable_gcm_crypto_suites = true; | 1064 opts.crypto_options.enable_gcm_crypto_suites = true; |
976 f1_.set_secure(SEC_ENABLED); | 1065 f1_.set_secure(SEC_ENABLED); |
977 f2_.set_secure(SEC_ENABLED); | 1066 f2_.set_secure(SEC_ENABLED); |
978 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1067 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
979 ASSERT_TRUE(offer.get() != NULL); | 1068 ASSERT_TRUE(offer.get() != NULL); |
980 std::unique_ptr<SessionDescription> answer( | 1069 std::unique_ptr<SessionDescription> answer( |
981 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1070 f2_.CreateAnswer(offer.get(), opts, NULL)); |
982 const ContentInfo* ac = answer->GetContentByName("audio"); | 1071 const ContentInfo* ac = answer->GetContentByName("audio"); |
983 const ContentInfo* dc = answer->GetContentByName("data"); | 1072 const ContentInfo* dc = answer->GetContentByName("data"); |
984 ASSERT_TRUE(ac != NULL); | 1073 ASSERT_TRUE(ac != NULL); |
985 ASSERT_TRUE(dc != NULL); | 1074 ASSERT_TRUE(dc != NULL); |
986 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 1075 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
987 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); | 1076 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); |
988 const AudioContentDescription* acd = | 1077 const AudioContentDescription* acd = |
989 static_cast<const AudioContentDescription*>(ac->description); | 1078 static_cast<const AudioContentDescription*>(ac->description); |
990 const DataContentDescription* dcd = | 1079 const DataContentDescription* dcd = |
991 static_cast<const DataContentDescription*>(dc->description); | 1080 static_cast<const DataContentDescription*>(dc->description); |
992 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 1081 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
993 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 1082 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
994 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 1083 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
995 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 1084 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached |
996 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 1085 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
997 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); | 1086 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); |
998 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); | 1087 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); |
999 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), dcd->codecs()); | 1088 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), dcd->codecs()); |
1000 EXPECT_NE(0U, dcd->first_ssrc()); // a random nonzero ssrc | 1089 EXPECT_EQ(0U, dcd->first_ssrc()); // no sender is attached |
1001 EXPECT_TRUE(dcd->rtcp_mux()); // negotiated rtcp-mux | 1090 EXPECT_TRUE(dcd->rtcp_mux()); // negotiated rtcp-mux |
1002 ASSERT_CRYPTO(dcd, 1U, CS_AEAD_AES_256_GCM); | 1091 ASSERT_CRYPTO(dcd, 1U, CS_AEAD_AES_256_GCM); |
1003 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); | 1092 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); |
1004 } | 1093 } |
1005 | 1094 |
1006 // The use_sctpmap flag should be set in a DataContentDescription by default. | 1095 // The use_sctpmap flag should be set in a DataContentDescription by default. |
1007 // The answer's use_sctpmap flag should match the offer's. | 1096 // The answer's use_sctpmap flag should match the offer's. |
1008 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerUsesSctpmap) { | 1097 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerUsesSctpmap) { |
1009 MediaSessionOptions opts; | 1098 MediaSessionOptions opts; |
1010 opts.data_channel_type = cricket::DCT_SCTP; | 1099 AddDataSection(cricket::DCT_SCTP, cricket::MD_SENDRECV, &opts); |
1011 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1100 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
1012 ASSERT_TRUE(offer.get() != NULL); | 1101 ASSERT_TRUE(offer.get() != NULL); |
1013 ContentInfo* dc_offer = offer->GetContentByName("data"); | 1102 ContentInfo* dc_offer = offer->GetContentByName("data"); |
1014 ASSERT_TRUE(dc_offer != NULL); | 1103 ASSERT_TRUE(dc_offer != NULL); |
1015 DataContentDescription* dcd_offer = | 1104 DataContentDescription* dcd_offer = |
1016 static_cast<DataContentDescription*>(dc_offer->description); | 1105 static_cast<DataContentDescription*>(dc_offer->description); |
1017 EXPECT_TRUE(dcd_offer->use_sctpmap()); | 1106 EXPECT_TRUE(dcd_offer->use_sctpmap()); |
1018 | 1107 |
1019 std::unique_ptr<SessionDescription> answer( | 1108 std::unique_ptr<SessionDescription> answer( |
1020 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1109 f2_.CreateAnswer(offer.get(), opts, NULL)); |
1021 const ContentInfo* dc_answer = answer->GetContentByName("data"); | 1110 const ContentInfo* dc_answer = answer->GetContentByName("data"); |
1022 ASSERT_TRUE(dc_answer != NULL); | 1111 ASSERT_TRUE(dc_answer != NULL); |
1023 const DataContentDescription* dcd_answer = | 1112 const DataContentDescription* dcd_answer = |
1024 static_cast<const DataContentDescription*>(dc_answer->description); | 1113 static_cast<const DataContentDescription*>(dc_answer->description); |
1025 EXPECT_TRUE(dcd_answer->use_sctpmap()); | 1114 EXPECT_TRUE(dcd_answer->use_sctpmap()); |
1026 } | 1115 } |
1027 | 1116 |
1028 // The answer's use_sctpmap flag should match the offer's. | 1117 // The answer's use_sctpmap flag should match the offer's. |
1029 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerWithoutSctpmap) { | 1118 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerWithoutSctpmap) { |
1030 MediaSessionOptions opts; | 1119 MediaSessionOptions opts; |
1031 opts.data_channel_type = cricket::DCT_SCTP; | 1120 AddDataSection(cricket::DCT_SCTP, cricket::MD_SENDRECV, &opts); |
1032 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1121 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
1033 ASSERT_TRUE(offer.get() != NULL); | 1122 ASSERT_TRUE(offer.get() != NULL); |
1034 ContentInfo* dc_offer = offer->GetContentByName("data"); | 1123 ContentInfo* dc_offer = offer->GetContentByName("data"); |
1035 ASSERT_TRUE(dc_offer != NULL); | 1124 ASSERT_TRUE(dc_offer != NULL); |
1036 DataContentDescription* dcd_offer = | 1125 DataContentDescription* dcd_offer = |
1037 static_cast<DataContentDescription*>(dc_offer->description); | 1126 static_cast<DataContentDescription*>(dc_offer->description); |
1038 dcd_offer->set_use_sctpmap(false); | 1127 dcd_offer->set_use_sctpmap(false); |
1039 | 1128 |
1040 std::unique_ptr<SessionDescription> answer( | 1129 std::unique_ptr<SessionDescription> answer( |
1041 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1130 f2_.CreateAnswer(offer.get(), opts, NULL)); |
1042 const ContentInfo* dc_answer = answer->GetContentByName("data"); | 1131 const ContentInfo* dc_answer = answer->GetContentByName("data"); |
1043 ASSERT_TRUE(dc_answer != NULL); | 1132 ASSERT_TRUE(dc_answer != NULL); |
1044 const DataContentDescription* dcd_answer = | 1133 const DataContentDescription* dcd_answer = |
1045 static_cast<const DataContentDescription*>(dc_answer->description); | 1134 static_cast<const DataContentDescription*>(dc_answer->description); |
1046 EXPECT_FALSE(dcd_answer->use_sctpmap()); | 1135 EXPECT_FALSE(dcd_answer->use_sctpmap()); |
1047 } | 1136 } |
1048 | 1137 |
1049 // Test that a valid answer will be created for "DTLS/SCTP", "UDP/DTLS/SCTP" | 1138 // Test that a valid answer will be created for "DTLS/SCTP", "UDP/DTLS/SCTP" |
1050 // and "TCP/DTLS/SCTP" offers. | 1139 // and "TCP/DTLS/SCTP" offers. |
1051 TEST_F(MediaSessionDescriptionFactoryTest, | 1140 TEST_F(MediaSessionDescriptionFactoryTest, |
1052 TestCreateDataAnswerToDifferentOfferedProtos) { | 1141 TestCreateDataAnswerToDifferentOfferedProtos) { |
1053 // Need to enable DTLS offer/answer generation (disabled by default in this | 1142 // Need to enable DTLS offer/answer generation (disabled by default in this |
1054 // test). | 1143 // test). |
1055 f1_.set_secure(SEC_ENABLED); | 1144 f1_.set_secure(SEC_ENABLED); |
1056 f2_.set_secure(SEC_ENABLED); | 1145 f2_.set_secure(SEC_ENABLED); |
1057 tdf1_.set_secure(SEC_ENABLED); | 1146 tdf1_.set_secure(SEC_ENABLED); |
1058 tdf2_.set_secure(SEC_ENABLED); | 1147 tdf2_.set_secure(SEC_ENABLED); |
1059 | 1148 |
1060 MediaSessionOptions opts; | 1149 MediaSessionOptions opts; |
1061 opts.data_channel_type = cricket::DCT_SCTP; | 1150 AddDataSection(cricket::DCT_SCTP, cricket::MD_SENDRECV, &opts); |
1062 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | 1151 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1063 ASSERT_TRUE(offer.get() != nullptr); | 1152 ASSERT_TRUE(offer.get() != nullptr); |
1064 ContentInfo* dc_offer = offer->GetContentByName("data"); | 1153 ContentInfo* dc_offer = offer->GetContentByName("data"); |
1065 ASSERT_TRUE(dc_offer != nullptr); | 1154 ASSERT_TRUE(dc_offer != nullptr); |
1066 DataContentDescription* dcd_offer = | 1155 DataContentDescription* dcd_offer = |
1067 static_cast<DataContentDescription*>(dc_offer->description); | 1156 static_cast<DataContentDescription*>(dc_offer->description); |
1068 | 1157 |
1069 std::vector<std::string> protos = {"DTLS/SCTP", "UDP/DTLS/SCTP", | 1158 std::vector<std::string> protos = {"DTLS/SCTP", "UDP/DTLS/SCTP", |
1070 "TCP/DTLS/SCTP"}; | 1159 "TCP/DTLS/SCTP"}; |
1071 for (const std::string& proto : protos) { | 1160 for (const std::string& proto : protos) { |
1072 dcd_offer->set_protocol(proto); | 1161 dcd_offer->set_protocol(proto); |
1073 std::unique_ptr<SessionDescription> answer( | 1162 std::unique_ptr<SessionDescription> answer( |
1074 f2_.CreateAnswer(offer.get(), opts, nullptr)); | 1163 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
1075 const ContentInfo* dc_answer = answer->GetContentByName("data"); | 1164 const ContentInfo* dc_answer = answer->GetContentByName("data"); |
1076 ASSERT_TRUE(dc_answer != nullptr); | 1165 ASSERT_TRUE(dc_answer != nullptr); |
1077 const DataContentDescription* dcd_answer = | 1166 const DataContentDescription* dcd_answer = |
1078 static_cast<const DataContentDescription*>(dc_answer->description); | 1167 static_cast<const DataContentDescription*>(dc_answer->description); |
1079 EXPECT_FALSE(dc_answer->rejected); | 1168 EXPECT_FALSE(dc_answer->rejected); |
1080 EXPECT_EQ(proto, dcd_answer->protocol()); | 1169 EXPECT_EQ(proto, dcd_answer->protocol()); |
1081 } | 1170 } |
1082 } | 1171 } |
1083 | 1172 |
1084 // Verifies that the order of the media contents in the offer is preserved in | 1173 // Verifies that the order of the media contents in the offer is preserved in |
1085 // the answer. | 1174 // the answer. |
1086 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerContentOrder) { | 1175 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerContentOrder) { |
1087 MediaSessionOptions opts; | 1176 MediaSessionOptions opts; |
1088 | 1177 |
1089 // Creates a data only offer. | 1178 // Creates a data only offer. |
1090 opts.recv_audio = false; | 1179 AddDataSection(cricket::DCT_SCTP, cricket::MD_SENDRECV, &opts); |
1091 opts.data_channel_type = cricket::DCT_SCTP; | |
1092 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); | 1180 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); |
1093 ASSERT_TRUE(offer1.get() != NULL); | 1181 ASSERT_TRUE(offer1.get() != NULL); |
1094 | 1182 |
1095 // Appends audio to the offer. | 1183 // Appends audio to the offer. |
1096 opts.recv_audio = true; | 1184 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, !kStopped, |
1185 &opts); | |
1097 std::unique_ptr<SessionDescription> offer2( | 1186 std::unique_ptr<SessionDescription> offer2( |
1098 f1_.CreateOffer(opts, offer1.get())); | 1187 f1_.CreateOffer(opts, offer1.get())); |
1099 ASSERT_TRUE(offer2.get() != NULL); | 1188 ASSERT_TRUE(offer2.get() != NULL); |
1100 | 1189 |
1101 // Appends video to the offer. | 1190 // Appends video to the offer. |
1102 opts.recv_video = true; | 1191 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, !kStopped, |
1192 &opts); | |
1103 std::unique_ptr<SessionDescription> offer3( | 1193 std::unique_ptr<SessionDescription> offer3( |
1104 f1_.CreateOffer(opts, offer2.get())); | 1194 f1_.CreateOffer(opts, offer2.get())); |
1105 ASSERT_TRUE(offer3.get() != NULL); | 1195 ASSERT_TRUE(offer3.get() != NULL); |
1106 | 1196 |
1107 std::unique_ptr<SessionDescription> answer( | 1197 std::unique_ptr<SessionDescription> answer( |
1108 f2_.CreateAnswer(offer3.get(), opts, NULL)); | 1198 f2_.CreateAnswer(offer3.get(), opts, NULL)); |
1109 ASSERT_TRUE(answer.get() != NULL); | 1199 ASSERT_TRUE(answer.get() != NULL); |
1110 EXPECT_EQ(3u, answer->contents().size()); | 1200 EXPECT_EQ(3u, answer->contents().size()); |
1111 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[0], MEDIA_TYPE_DATA)); | 1201 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[0], MEDIA_TYPE_DATA)); |
1112 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[1], MEDIA_TYPE_AUDIO)); | 1202 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[1], MEDIA_TYPE_AUDIO)); |
(...skipping 24 matching lines...) Expand all Loading... | |
1137 // This test that the media direction is set to inactive in an answer if | 1227 // This test that the media direction is set to inactive in an answer if |
1138 // the offer is inactive. | 1228 // the offer is inactive. |
1139 TEST_F(MediaSessionDescriptionFactoryTest, CreateAnswerToInactiveOffer) { | 1229 TEST_F(MediaSessionDescriptionFactoryTest, CreateAnswerToInactiveOffer) { |
1140 TestMediaDirectionInAnswer(cricket::MD_INACTIVE, cricket::MD_INACTIVE); | 1230 TestMediaDirectionInAnswer(cricket::MD_INACTIVE, cricket::MD_INACTIVE); |
1141 } | 1231 } |
1142 | 1232 |
1143 // Test that a data content with an unknown protocol is rejected in an answer. | 1233 // Test that a data content with an unknown protocol is rejected in an answer. |
1144 TEST_F(MediaSessionDescriptionFactoryTest, | 1234 TEST_F(MediaSessionDescriptionFactoryTest, |
1145 CreateDataAnswerToOfferWithUnknownProtocol) { | 1235 CreateDataAnswerToOfferWithUnknownProtocol) { |
1146 MediaSessionOptions opts; | 1236 MediaSessionOptions opts; |
1147 opts.data_channel_type = cricket::DCT_RTP; | 1237 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
1148 opts.recv_audio = false; | |
1149 f1_.set_secure(SEC_ENABLED); | 1238 f1_.set_secure(SEC_ENABLED); |
1150 f2_.set_secure(SEC_ENABLED); | 1239 f2_.set_secure(SEC_ENABLED); |
1151 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1240 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
1152 ContentInfo* dc_offer = offer->GetContentByName("data"); | 1241 ContentInfo* dc_offer = offer->GetContentByName("data"); |
1153 ASSERT_TRUE(dc_offer != NULL); | 1242 ASSERT_TRUE(dc_offer != NULL); |
1154 DataContentDescription* dcd_offer = | 1243 DataContentDescription* dcd_offer = |
1155 static_cast<DataContentDescription*>(dc_offer->description); | 1244 static_cast<DataContentDescription*>(dc_offer->description); |
1156 ASSERT_TRUE(dcd_offer != NULL); | 1245 ASSERT_TRUE(dcd_offer != NULL); |
1157 std::string protocol = "a weird unknown protocol"; | 1246 std::string protocol = "a weird unknown protocol"; |
1158 dcd_offer->set_protocol(protocol); | 1247 dcd_offer->set_protocol(protocol); |
1159 | 1248 |
1160 std::unique_ptr<SessionDescription> answer( | 1249 std::unique_ptr<SessionDescription> answer( |
1161 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1250 f2_.CreateAnswer(offer.get(), opts, NULL)); |
1162 | 1251 |
1163 const ContentInfo* dc_answer = answer->GetContentByName("data"); | 1252 const ContentInfo* dc_answer = answer->GetContentByName("data"); |
1164 ASSERT_TRUE(dc_answer != NULL); | 1253 ASSERT_TRUE(dc_answer != NULL); |
1165 EXPECT_TRUE(dc_answer->rejected); | 1254 EXPECT_TRUE(dc_answer->rejected); |
1166 const DataContentDescription* dcd_answer = | 1255 const DataContentDescription* dcd_answer = |
1167 static_cast<const DataContentDescription*>(dc_answer->description); | 1256 static_cast<const DataContentDescription*>(dc_answer->description); |
1168 ASSERT_TRUE(dcd_answer != NULL); | 1257 ASSERT_TRUE(dcd_answer != NULL); |
1169 EXPECT_EQ(protocol, dcd_answer->protocol()); | 1258 EXPECT_EQ(protocol, dcd_answer->protocol()); |
1170 } | 1259 } |
1171 | 1260 |
1172 // Test that the media protocol is RTP/AVPF if DTLS and SDES are disabled. | 1261 // Test that the media protocol is RTP/AVPF if DTLS and SDES are disabled. |
1173 TEST_F(MediaSessionDescriptionFactoryTest, AudioOfferAnswerWithCryptoDisabled) { | 1262 TEST_F(MediaSessionDescriptionFactoryTest, AudioOfferAnswerWithCryptoDisabled) { |
1174 MediaSessionOptions opts; | 1263 MediaSessionOptions opts = CreatePlanBMediaSessionOptions(); |
1175 f1_.set_secure(SEC_DISABLED); | 1264 f1_.set_secure(SEC_DISABLED); |
1176 f2_.set_secure(SEC_DISABLED); | 1265 f2_.set_secure(SEC_DISABLED); |
1177 tdf1_.set_secure(SEC_DISABLED); | 1266 tdf1_.set_secure(SEC_DISABLED); |
1178 tdf2_.set_secure(SEC_DISABLED); | 1267 tdf2_.set_secure(SEC_DISABLED); |
1179 | 1268 |
1180 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1269 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
1181 const AudioContentDescription* offer_acd = | 1270 const AudioContentDescription* offer_acd = |
1182 GetFirstAudioContentDescription(offer.get()); | 1271 GetFirstAudioContentDescription(offer.get()); |
1183 ASSERT_TRUE(offer_acd != NULL); | 1272 ASSERT_TRUE(offer_acd != NULL); |
1184 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), offer_acd->protocol()); | 1273 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), offer_acd->protocol()); |
1185 | 1274 |
1186 std::unique_ptr<SessionDescription> answer( | 1275 std::unique_ptr<SessionDescription> answer( |
1187 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1276 f2_.CreateAnswer(offer.get(), opts, NULL)); |
1188 | 1277 |
1189 const ContentInfo* ac_answer = answer->GetContentByName("audio"); | 1278 const ContentInfo* ac_answer = answer->GetContentByName("audio"); |
1190 ASSERT_TRUE(ac_answer != NULL); | 1279 ASSERT_TRUE(ac_answer != NULL); |
1191 EXPECT_FALSE(ac_answer->rejected); | 1280 EXPECT_FALSE(ac_answer->rejected); |
1192 | 1281 |
1193 const AudioContentDescription* answer_acd = | 1282 const AudioContentDescription* answer_acd = |
1194 GetFirstAudioContentDescription(answer.get()); | 1283 GetFirstAudioContentDescription(answer.get()); |
1195 ASSERT_TRUE(answer_acd != NULL); | 1284 ASSERT_TRUE(answer_acd != NULL); |
1196 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), answer_acd->protocol()); | 1285 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), answer_acd->protocol()); |
1197 } | 1286 } |
1198 | 1287 |
1199 // Create a video offer and answer and ensure the RTP header extensions | 1288 // Create a video offer and answer and ensure the RTP header extensions |
1200 // matches what we expect. | 1289 // matches what we expect. |
1201 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferAnswerWithRtpExtensions) { | 1290 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferAnswerWithRtpExtensions) { |
1202 MediaSessionOptions opts; | 1291 MediaSessionOptions opts; |
1203 opts.recv_video = true; | 1292 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
1204 | |
1205 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); | 1293 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); |
1206 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); | 1294 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); |
1207 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); | 1295 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); |
1208 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); | 1296 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); |
1209 | 1297 |
1210 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1298 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
1211 ASSERT_TRUE(offer.get() != NULL); | 1299 ASSERT_TRUE(offer.get() != NULL); |
1212 std::unique_ptr<SessionDescription> answer( | 1300 std::unique_ptr<SessionDescription> answer( |
1213 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1301 f2_.CreateAnswer(offer.get(), opts, NULL)); |
1214 | 1302 |
1215 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension1), | 1303 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension1), |
1216 GetFirstAudioContentDescription( | 1304 GetFirstAudioContentDescription( |
1217 offer.get())->rtp_header_extensions()); | 1305 offer.get())->rtp_header_extensions()); |
1218 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtension1), | 1306 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtension1), |
1219 GetFirstVideoContentDescription( | 1307 GetFirstVideoContentDescription( |
1220 offer.get())->rtp_header_extensions()); | 1308 offer.get())->rtp_header_extensions()); |
1221 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), | 1309 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), |
1222 GetFirstAudioContentDescription( | 1310 GetFirstAudioContentDescription( |
1223 answer.get())->rtp_header_extensions()); | 1311 answer.get())->rtp_header_extensions()); |
1224 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), | 1312 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), |
1225 GetFirstVideoContentDescription( | 1313 GetFirstVideoContentDescription( |
1226 answer.get())->rtp_header_extensions()); | 1314 answer.get())->rtp_header_extensions()); |
1227 } | 1315 } |
1228 | 1316 |
1229 TEST_F(MediaSessionDescriptionFactoryTest, | 1317 TEST_F(MediaSessionDescriptionFactoryTest, |
1230 TestOfferAnswerWithEncryptedRtpExtensionsBoth) { | 1318 TestOfferAnswerWithEncryptedRtpExtensionsBoth) { |
1231 MediaSessionOptions opts; | 1319 MediaSessionOptions opts; |
1232 opts.recv_video = true; | 1320 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
1233 | 1321 |
1234 f1_.set_enable_encrypted_rtp_header_extensions(true); | 1322 f1_.set_enable_encrypted_rtp_header_extensions(true); |
1235 f2_.set_enable_encrypted_rtp_header_extensions(true); | 1323 f2_.set_enable_encrypted_rtp_header_extensions(true); |
1236 | 1324 |
1237 f1_.set_audio_rtp_header_extensions( | 1325 f1_.set_audio_rtp_header_extensions( |
1238 MAKE_VECTOR(kAudioRtpExtension1)); | 1326 MAKE_VECTOR(kAudioRtpExtension1)); |
1239 f1_.set_video_rtp_header_extensions( | 1327 f1_.set_video_rtp_header_extensions( |
1240 MAKE_VECTOR(kVideoRtpExtension1)); | 1328 MAKE_VECTOR(kVideoRtpExtension1)); |
1241 f2_.set_audio_rtp_header_extensions( | 1329 f2_.set_audio_rtp_header_extensions( |
1242 MAKE_VECTOR(kAudioRtpExtension2)); | 1330 MAKE_VECTOR(kAudioRtpExtension2)); |
(...skipping 15 matching lines...) Expand all Loading... | |
1258 GetFirstAudioContentDescription( | 1346 GetFirstAudioContentDescription( |
1259 answer.get())->rtp_header_extensions()); | 1347 answer.get())->rtp_header_extensions()); |
1260 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionEncryptedAnswer), | 1348 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionEncryptedAnswer), |
1261 GetFirstVideoContentDescription( | 1349 GetFirstVideoContentDescription( |
1262 answer.get())->rtp_header_extensions()); | 1350 answer.get())->rtp_header_extensions()); |
1263 } | 1351 } |
1264 | 1352 |
1265 TEST_F(MediaSessionDescriptionFactoryTest, | 1353 TEST_F(MediaSessionDescriptionFactoryTest, |
1266 TestOfferAnswerWithEncryptedRtpExtensionsOffer) { | 1354 TestOfferAnswerWithEncryptedRtpExtensionsOffer) { |
1267 MediaSessionOptions opts; | 1355 MediaSessionOptions opts; |
1268 opts.recv_video = true; | 1356 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
1269 | 1357 |
1270 f1_.set_enable_encrypted_rtp_header_extensions(true); | 1358 f1_.set_enable_encrypted_rtp_header_extensions(true); |
1271 | 1359 |
1272 f1_.set_audio_rtp_header_extensions( | 1360 f1_.set_audio_rtp_header_extensions( |
1273 MAKE_VECTOR(kAudioRtpExtension1)); | 1361 MAKE_VECTOR(kAudioRtpExtension1)); |
1274 f1_.set_video_rtp_header_extensions( | 1362 f1_.set_video_rtp_header_extensions( |
1275 MAKE_VECTOR(kVideoRtpExtension1)); | 1363 MAKE_VECTOR(kVideoRtpExtension1)); |
1276 f2_.set_audio_rtp_header_extensions( | 1364 f2_.set_audio_rtp_header_extensions( |
1277 MAKE_VECTOR(kAudioRtpExtension2)); | 1365 MAKE_VECTOR(kAudioRtpExtension2)); |
1278 f2_.set_video_rtp_header_extensions( | 1366 f2_.set_video_rtp_header_extensions( |
(...skipping 14 matching lines...) Expand all Loading... | |
1293 GetFirstAudioContentDescription( | 1381 GetFirstAudioContentDescription( |
1294 answer.get())->rtp_header_extensions()); | 1382 answer.get())->rtp_header_extensions()); |
1295 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), | 1383 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), |
1296 GetFirstVideoContentDescription( | 1384 GetFirstVideoContentDescription( |
1297 answer.get())->rtp_header_extensions()); | 1385 answer.get())->rtp_header_extensions()); |
1298 } | 1386 } |
1299 | 1387 |
1300 TEST_F(MediaSessionDescriptionFactoryTest, | 1388 TEST_F(MediaSessionDescriptionFactoryTest, |
1301 TestOfferAnswerWithEncryptedRtpExtensionsAnswer) { | 1389 TestOfferAnswerWithEncryptedRtpExtensionsAnswer) { |
1302 MediaSessionOptions opts; | 1390 MediaSessionOptions opts; |
1303 opts.recv_video = true; | 1391 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
1304 | 1392 |
1305 f2_.set_enable_encrypted_rtp_header_extensions(true); | 1393 f2_.set_enable_encrypted_rtp_header_extensions(true); |
1306 | 1394 |
1307 f1_.set_audio_rtp_header_extensions( | 1395 f1_.set_audio_rtp_header_extensions( |
1308 MAKE_VECTOR(kAudioRtpExtension1)); | 1396 MAKE_VECTOR(kAudioRtpExtension1)); |
1309 f1_.set_video_rtp_header_extensions( | 1397 f1_.set_video_rtp_header_extensions( |
1310 MAKE_VECTOR(kVideoRtpExtension1)); | 1398 MAKE_VECTOR(kVideoRtpExtension1)); |
1311 f2_.set_audio_rtp_header_extensions( | 1399 f2_.set_audio_rtp_header_extensions( |
1312 MAKE_VECTOR(kAudioRtpExtension2)); | 1400 MAKE_VECTOR(kAudioRtpExtension2)); |
1313 f2_.set_video_rtp_header_extensions( | 1401 f2_.set_video_rtp_header_extensions( |
(...skipping 15 matching lines...) Expand all Loading... | |
1329 answer.get())->rtp_header_extensions()); | 1417 answer.get())->rtp_header_extensions()); |
1330 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), | 1418 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), |
1331 GetFirstVideoContentDescription( | 1419 GetFirstVideoContentDescription( |
1332 answer.get())->rtp_header_extensions()); | 1420 answer.get())->rtp_header_extensions()); |
1333 } | 1421 } |
1334 | 1422 |
1335 // Create an audio, video, data answer without legacy StreamParams. | 1423 // Create an audio, video, data answer without legacy StreamParams. |
1336 TEST_F(MediaSessionDescriptionFactoryTest, | 1424 TEST_F(MediaSessionDescriptionFactoryTest, |
1337 TestCreateAnswerWithoutLegacyStreams) { | 1425 TestCreateAnswerWithoutLegacyStreams) { |
1338 MediaSessionOptions opts; | 1426 MediaSessionOptions opts; |
1339 opts.recv_video = true; | 1427 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
1340 opts.data_channel_type = cricket::DCT_RTP; | 1428 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
1341 f1_.set_add_legacy_streams(false); | |
1342 f2_.set_add_legacy_streams(false); | |
1343 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1429 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
1344 ASSERT_TRUE(offer.get() != NULL); | 1430 ASSERT_TRUE(offer.get() != NULL); |
1345 std::unique_ptr<SessionDescription> answer( | 1431 std::unique_ptr<SessionDescription> answer( |
1346 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1432 f2_.CreateAnswer(offer.get(), opts, NULL)); |
1347 const ContentInfo* ac = answer->GetContentByName("audio"); | 1433 const ContentInfo* ac = answer->GetContentByName("audio"); |
1348 const ContentInfo* vc = answer->GetContentByName("video"); | 1434 const ContentInfo* vc = answer->GetContentByName("video"); |
1349 const ContentInfo* dc = answer->GetContentByName("data"); | 1435 const ContentInfo* dc = answer->GetContentByName("data"); |
1350 ASSERT_TRUE(ac != NULL); | 1436 ASSERT_TRUE(ac != NULL); |
1351 ASSERT_TRUE(vc != NULL); | 1437 ASSERT_TRUE(vc != NULL); |
1352 const AudioContentDescription* acd = | 1438 const AudioContentDescription* acd = |
1353 static_cast<const AudioContentDescription*>(ac->description); | 1439 static_cast<const AudioContentDescription*>(ac->description); |
1354 const VideoContentDescription* vcd = | 1440 const VideoContentDescription* vcd = |
1355 static_cast<const VideoContentDescription*>(vc->description); | 1441 static_cast<const VideoContentDescription*>(vc->description); |
1356 const DataContentDescription* dcd = | 1442 const DataContentDescription* dcd = |
1357 static_cast<const DataContentDescription*>(dc->description); | 1443 static_cast<const DataContentDescription*>(dc->description); |
1358 | 1444 |
1359 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. | 1445 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. |
1360 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. | 1446 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. |
1361 EXPECT_FALSE(dcd->has_ssrcs()); // No StreamParams. | 1447 EXPECT_FALSE(dcd->has_ssrcs()); // No StreamParams. |
1362 } | 1448 } |
1363 | 1449 |
1364 TEST_F(MediaSessionDescriptionFactoryTest, TestPartial) { | 1450 TEST_F(MediaSessionDescriptionFactoryTest, TestPartial) { |
1365 MediaSessionOptions opts; | 1451 MediaSessionOptions opts; |
1366 opts.recv_video = true; | 1452 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
1367 opts.data_channel_type = cricket::DCT_RTP; | 1453 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
1368 f1_.set_secure(SEC_ENABLED); | 1454 f1_.set_secure(SEC_ENABLED); |
1369 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1455 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
1370 ASSERT_TRUE(offer.get() != NULL); | 1456 ASSERT_TRUE(offer.get() != NULL); |
1371 const ContentInfo* ac = offer->GetContentByName("audio"); | 1457 const ContentInfo* ac = offer->GetContentByName("audio"); |
1372 const ContentInfo* vc = offer->GetContentByName("video"); | 1458 const ContentInfo* vc = offer->GetContentByName("video"); |
1373 const ContentInfo* dc = offer->GetContentByName("data"); | 1459 const ContentInfo* dc = offer->GetContentByName("data"); |
1374 AudioContentDescription* acd = const_cast<AudioContentDescription*>( | 1460 AudioContentDescription* acd = const_cast<AudioContentDescription*>( |
1375 static_cast<const AudioContentDescription*>(ac->description)); | 1461 static_cast<const AudioContentDescription*>(ac->description)); |
1376 VideoContentDescription* vcd = const_cast<VideoContentDescription*>( | 1462 VideoContentDescription* vcd = const_cast<VideoContentDescription*>( |
1377 static_cast<const VideoContentDescription*>(vc->description)); | 1463 static_cast<const VideoContentDescription*>(vc->description)); |
(...skipping 15 matching lines...) Expand all Loading... | |
1393 EXPECT_FALSE(dcd->partial()); // default is false. | 1479 EXPECT_FALSE(dcd->partial()); // default is false. |
1394 dcd->set_partial(true); | 1480 dcd->set_partial(true); |
1395 EXPECT_TRUE(dcd->partial()); | 1481 EXPECT_TRUE(dcd->partial()); |
1396 dcd->set_partial(false); | 1482 dcd->set_partial(false); |
1397 EXPECT_FALSE(dcd->partial()); | 1483 EXPECT_FALSE(dcd->partial()); |
1398 } | 1484 } |
1399 | 1485 |
1400 // Create a typical video answer, and ensure it matches what we expect. | 1486 // Create a typical video answer, and ensure it matches what we expect. |
1401 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerRtcpMux) { | 1487 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerRtcpMux) { |
1402 MediaSessionOptions offer_opts; | 1488 MediaSessionOptions offer_opts; |
1489 AddAudioVideoSections(cricket::MD_SENDRECV, &offer_opts); | |
1490 AddDataSection(cricket::DCT_RTP, cricket::MD_SENDRECV, &offer_opts); | |
1491 | |
1403 MediaSessionOptions answer_opts; | 1492 MediaSessionOptions answer_opts; |
1404 answer_opts.recv_video = true; | 1493 AddAudioVideoSections(cricket::MD_SENDRECV, &answer_opts); |
1405 offer_opts.recv_video = true; | 1494 AddDataSection(cricket::DCT_RTP, cricket::MD_SENDRECV, &answer_opts); |
1406 answer_opts.data_channel_type = cricket::DCT_RTP; | |
1407 offer_opts.data_channel_type = cricket::DCT_RTP; | |
1408 | 1495 |
1409 std::unique_ptr<SessionDescription> offer; | 1496 std::unique_ptr<SessionDescription> offer; |
1410 std::unique_ptr<SessionDescription> answer; | 1497 std::unique_ptr<SessionDescription> answer; |
1411 | 1498 |
1412 offer_opts.rtcp_mux_enabled = true; | 1499 offer_opts.rtcp_mux_enabled = true; |
1413 answer_opts.rtcp_mux_enabled = true; | 1500 answer_opts.rtcp_mux_enabled = true; |
1414 | |
1415 offer.reset(f1_.CreateOffer(offer_opts, NULL)); | 1501 offer.reset(f1_.CreateOffer(offer_opts, NULL)); |
1416 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 1502 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
1417 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); | 1503 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); |
1418 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); | 1504 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); |
1419 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); | 1505 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); |
1420 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); | 1506 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); |
1421 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); | 1507 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); |
1422 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); | 1508 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); |
1423 EXPECT_TRUE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); | 1509 EXPECT_TRUE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); |
1424 EXPECT_TRUE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); | 1510 EXPECT_TRUE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); |
1425 EXPECT_TRUE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); | 1511 EXPECT_TRUE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); |
1426 EXPECT_TRUE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); | 1512 EXPECT_TRUE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); |
1427 EXPECT_TRUE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); | 1513 EXPECT_TRUE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); |
1428 EXPECT_TRUE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); | 1514 EXPECT_TRUE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); |
1429 | 1515 |
1430 offer_opts.rtcp_mux_enabled = true; | 1516 offer_opts.rtcp_mux_enabled = true; |
1431 answer_opts.rtcp_mux_enabled = false; | 1517 answer_opts.rtcp_mux_enabled = false; |
1432 | |
1433 offer.reset(f1_.CreateOffer(offer_opts, NULL)); | 1518 offer.reset(f1_.CreateOffer(offer_opts, NULL)); |
1434 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 1519 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
1435 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); | 1520 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); |
1436 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); | 1521 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); |
1437 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); | 1522 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); |
1438 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); | 1523 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); |
1439 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); | 1524 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); |
1440 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); | 1525 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); |
1441 EXPECT_TRUE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); | 1526 EXPECT_TRUE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); |
1442 EXPECT_TRUE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); | 1527 EXPECT_TRUE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); |
1443 EXPECT_TRUE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); | 1528 EXPECT_TRUE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); |
1444 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); | 1529 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); |
1445 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); | 1530 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); |
1446 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); | 1531 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); |
1447 | 1532 |
1448 offer_opts.rtcp_mux_enabled = false; | 1533 offer_opts.rtcp_mux_enabled = false; |
1449 answer_opts.rtcp_mux_enabled = true; | 1534 answer_opts.rtcp_mux_enabled = true; |
1450 | |
1451 offer.reset(f1_.CreateOffer(offer_opts, NULL)); | 1535 offer.reset(f1_.CreateOffer(offer_opts, NULL)); |
1452 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 1536 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
1453 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); | 1537 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); |
1454 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); | 1538 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); |
1455 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); | 1539 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); |
1456 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); | 1540 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); |
1457 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); | 1541 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); |
1458 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); | 1542 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); |
1459 EXPECT_FALSE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); | 1543 EXPECT_FALSE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); |
1460 EXPECT_FALSE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); | 1544 EXPECT_FALSE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); |
1461 EXPECT_FALSE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); | 1545 EXPECT_FALSE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); |
1462 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); | 1546 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); |
1463 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); | 1547 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); |
1464 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); | 1548 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); |
1465 | 1549 |
1466 offer_opts.rtcp_mux_enabled = false; | 1550 offer_opts.rtcp_mux_enabled = false; |
1467 answer_opts.rtcp_mux_enabled = false; | 1551 answer_opts.rtcp_mux_enabled = false; |
1468 | |
1469 offer.reset(f1_.CreateOffer(offer_opts, NULL)); | 1552 offer.reset(f1_.CreateOffer(offer_opts, NULL)); |
1470 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 1553 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
1471 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); | 1554 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); |
1472 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); | 1555 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); |
1473 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); | 1556 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); |
1474 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); | 1557 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); |
1475 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); | 1558 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); |
1476 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); | 1559 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); |
1477 EXPECT_FALSE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); | 1560 EXPECT_FALSE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); |
1478 EXPECT_FALSE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); | 1561 EXPECT_FALSE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); |
1479 EXPECT_FALSE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); | 1562 EXPECT_FALSE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); |
1480 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); | 1563 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); |
1481 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); | 1564 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); |
1482 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); | 1565 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); |
1483 } | 1566 } |
1484 | 1567 |
1485 // Create an audio-only answer to a video offer. | 1568 // Create an audio-only answer to a video offer. |
1486 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerToVideo) { | 1569 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerToVideo) { |
1487 MediaSessionOptions opts; | 1570 MediaSessionOptions offer_opts; |
1488 opts.recv_video = true; | 1571 AddAudioVideoSections(cricket::MD_RECVONLY, &offer_opts); |
1489 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1572 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(offer_opts, NULL)); |
1490 ASSERT_TRUE(offer.get() != NULL); | 1573 ASSERT_TRUE(offer.get() != NULL); |
1574 | |
1575 MediaSessionOptions answer_opts; | |
1576 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, !kStopped, | |
1577 &answer_opts); | |
1578 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_INACTIVE, kStopped, | |
1579 &answer_opts); | |
1491 std::unique_ptr<SessionDescription> answer( | 1580 std::unique_ptr<SessionDescription> answer( |
1492 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 1581 f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
1493 const ContentInfo* ac = answer->GetContentByName("audio"); | 1582 const ContentInfo* ac = answer->GetContentByName("audio"); |
1494 const ContentInfo* vc = answer->GetContentByName("video"); | 1583 const ContentInfo* vc = answer->GetContentByName("video"); |
1495 ASSERT_TRUE(ac != NULL); | 1584 ASSERT_TRUE(ac != NULL); |
1496 ASSERT_TRUE(vc != NULL); | 1585 ASSERT_TRUE(vc != NULL); |
1497 ASSERT_TRUE(vc->description != NULL); | 1586 ASSERT_TRUE(vc->description != NULL); |
1498 EXPECT_TRUE(vc->rejected); | 1587 EXPECT_TRUE(vc->rejected); |
1499 } | 1588 } |
1500 | 1589 |
1501 // Create an audio-only answer to an offer with data. | 1590 // Create an audio-only answer to an offer with data. |
1502 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateNoDataAnswerToDataOffer) { | 1591 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateNoDataAnswerToDataOffer) { |
1503 MediaSessionOptions opts; | 1592 MediaSessionOptions offer_opts = CreatePlanBMediaSessionOptions(); |
1504 opts.data_channel_type = cricket::DCT_RTP; | 1593 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &offer_opts); |
1505 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1594 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(offer_opts, NULL)); |
1506 ASSERT_TRUE(offer.get() != NULL); | 1595 ASSERT_TRUE(offer.get() != NULL); |
1596 | |
1597 MediaSessionOptions answer_opts = CreatePlanBMediaSessionOptions(); | |
1598 answer_opts.data_channel_type = cricket::DCT_RTP; | |
1599 AddMediaSection(MEDIA_TYPE_DATA, "data", cricket::MD_INACTIVE, kStopped, | |
1600 &answer_opts); | |
1507 std::unique_ptr<SessionDescription> answer( | 1601 std::unique_ptr<SessionDescription> answer( |
1508 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 1602 f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
1509 const ContentInfo* ac = answer->GetContentByName("audio"); | 1603 const ContentInfo* ac = answer->GetContentByName("audio"); |
1510 const ContentInfo* dc = answer->GetContentByName("data"); | 1604 const ContentInfo* dc = answer->GetContentByName("data"); |
1511 ASSERT_TRUE(ac != NULL); | 1605 ASSERT_TRUE(ac != NULL); |
1512 ASSERT_TRUE(dc != NULL); | 1606 ASSERT_TRUE(dc != NULL); |
1513 ASSERT_TRUE(dc->description != NULL); | 1607 ASSERT_TRUE(dc->description != NULL); |
1514 EXPECT_TRUE(dc->rejected); | 1608 EXPECT_TRUE(dc->rejected); |
1515 } | 1609 } |
1516 | 1610 |
1517 // Create an answer that rejects the contents which are rejected in the offer. | 1611 // Create an answer that rejects the contents which are rejected in the offer. |
1518 TEST_F(MediaSessionDescriptionFactoryTest, | 1612 TEST_F(MediaSessionDescriptionFactoryTest, |
1519 CreateAnswerToOfferWithRejectedMedia) { | 1613 CreateAnswerToOfferWithRejectedMedia) { |
1520 MediaSessionOptions opts; | 1614 MediaSessionOptions opts; |
1521 opts.recv_video = true; | 1615 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
1522 opts.data_channel_type = cricket::DCT_RTP; | 1616 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
1523 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1617 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
1524 ASSERT_TRUE(offer.get() != NULL); | 1618 ASSERT_TRUE(offer.get() != NULL); |
1525 ContentInfo* ac = offer->GetContentByName("audio"); | 1619 ContentInfo* ac = offer->GetContentByName("audio"); |
1526 ContentInfo* vc = offer->GetContentByName("video"); | 1620 ContentInfo* vc = offer->GetContentByName("video"); |
1527 ContentInfo* dc = offer->GetContentByName("data"); | 1621 ContentInfo* dc = offer->GetContentByName("data"); |
1528 ASSERT_TRUE(ac != NULL); | 1622 ASSERT_TRUE(ac != NULL); |
1529 ASSERT_TRUE(vc != NULL); | 1623 ASSERT_TRUE(vc != NULL); |
1530 ASSERT_TRUE(dc != NULL); | 1624 ASSERT_TRUE(dc != NULL); |
1531 ac->rejected = true; | 1625 ac->rejected = true; |
1532 vc->rejected = true; | 1626 vc->rejected = true; |
(...skipping 12 matching lines...) Expand all Loading... | |
1545 } | 1639 } |
1546 | 1640 |
1547 // Create an audio and video offer with: | 1641 // Create an audio and video offer with: |
1548 // - one video track | 1642 // - one video track |
1549 // - two audio tracks | 1643 // - two audio tracks |
1550 // - two data tracks | 1644 // - two data tracks |
1551 // and ensure it matches what we expect. Also updates the initial offer by | 1645 // and ensure it matches what we expect. Also updates the initial offer by |
1552 // adding a new video track and replaces one of the audio tracks. | 1646 // adding a new video track and replaces one of the audio tracks. |
1553 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) { | 1647 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) { |
1554 MediaSessionOptions opts; | 1648 MediaSessionOptions opts; |
1555 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); | 1649 AddAudioVideoSections(cricket::MD_SENDRECV, &opts); |
1556 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 1650 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, kVideoTrack1, |
1557 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2, kMediaStream1); | 1651 kMediaStream1, 1, &opts); |
1558 opts.data_channel_type = cricket::DCT_RTP; | 1652 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1, |
1559 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack1, kMediaStream1); | 1653 kMediaStream1, 1, &opts); |
1560 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack2, kMediaStream1); | 1654 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack2, |
1655 kMediaStream1, 1, &opts); | |
1656 | |
1657 AddDataSection(cricket::DCT_RTP, cricket::MD_SENDRECV, &opts); | |
1658 AttachSenderToMediaSection("data", MEDIA_TYPE_DATA, kDataTrack1, | |
1659 kMediaStream1, 1, &opts); | |
1660 AttachSenderToMediaSection("data", MEDIA_TYPE_DATA, kDataTrack2, | |
1661 kMediaStream1, 1, &opts); | |
1561 | 1662 |
1562 f1_.set_secure(SEC_ENABLED); | 1663 f1_.set_secure(SEC_ENABLED); |
1563 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1664 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
1564 | 1665 |
1565 ASSERT_TRUE(offer.get() != NULL); | 1666 ASSERT_TRUE(offer.get() != NULL); |
1566 const ContentInfo* ac = offer->GetContentByName("audio"); | 1667 const ContentInfo* ac = offer->GetContentByName("audio"); |
1567 const ContentInfo* vc = offer->GetContentByName("video"); | 1668 const ContentInfo* vc = offer->GetContentByName("video"); |
1568 const ContentInfo* dc = offer->GetContentByName("data"); | 1669 const ContentInfo* dc = offer->GetContentByName("data"); |
1569 ASSERT_TRUE(ac != NULL); | 1670 ASSERT_TRUE(ac != NULL); |
1570 ASSERT_TRUE(vc != NULL); | 1671 ASSERT_TRUE(vc != NULL); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1615 EXPECT_NE(0U, data_streams[0].ssrcs[0]); | 1716 EXPECT_NE(0U, data_streams[0].ssrcs[0]); |
1616 EXPECT_EQ(kDataTrack2, data_streams[1].id); | 1717 EXPECT_EQ(kDataTrack2, data_streams[1].id); |
1617 ASSERT_EQ(1U, data_streams[1].ssrcs.size()); | 1718 ASSERT_EQ(1U, data_streams[1].ssrcs.size()); |
1618 EXPECT_NE(0U, data_streams[1].ssrcs[0]); | 1719 EXPECT_NE(0U, data_streams[1].ssrcs[0]); |
1619 | 1720 |
1620 EXPECT_EQ(cricket::kDataMaxBandwidth, | 1721 EXPECT_EQ(cricket::kDataMaxBandwidth, |
1621 dcd->bandwidth()); // default bandwidth (auto) | 1722 dcd->bandwidth()); // default bandwidth (auto) |
1622 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on | 1723 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on |
1623 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 1724 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
1624 | 1725 |
1625 | |
1626 // Update the offer. Add a new video track that is not synched to the | 1726 // Update the offer. Add a new video track that is not synched to the |
1627 // other tracks and replace audio track 2 with audio track 3. | 1727 // other tracks and replace audio track 2 with audio track 3. |
1628 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack2, kMediaStream2); | 1728 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, kVideoTrack2, |
1629 opts.RemoveSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2); | 1729 kMediaStream2, 1, &opts); |
1630 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack3, kMediaStream1); | 1730 DetachSenderFromMediaSection("audio", kAudioTrack2, &opts); |
1631 opts.RemoveSendStream(MEDIA_TYPE_DATA, kDataTrack2); | 1731 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack3, |
1632 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack3, kMediaStream1); | 1732 kMediaStream1, 1, &opts); |
1733 DetachSenderFromMediaSection("data", kDataTrack2, &opts); | |
1734 AttachSenderToMediaSection("data", MEDIA_TYPE_DATA, kDataTrack3, | |
1735 kMediaStream1, 1, &opts); | |
1633 std::unique_ptr<SessionDescription> updated_offer( | 1736 std::unique_ptr<SessionDescription> updated_offer( |
1634 f1_.CreateOffer(opts, offer.get())); | 1737 f1_.CreateOffer(opts, offer.get())); |
1635 | 1738 |
1636 ASSERT_TRUE(updated_offer.get() != NULL); | 1739 ASSERT_TRUE(updated_offer.get() != NULL); |
1637 ac = updated_offer->GetContentByName("audio"); | 1740 ac = updated_offer->GetContentByName("audio"); |
1638 vc = updated_offer->GetContentByName("video"); | 1741 vc = updated_offer->GetContentByName("video"); |
1639 dc = updated_offer->GetContentByName("data"); | 1742 dc = updated_offer->GetContentByName("data"); |
1640 ASSERT_TRUE(ac != NULL); | 1743 ASSERT_TRUE(ac != NULL); |
1641 ASSERT_TRUE(vc != NULL); | 1744 ASSERT_TRUE(vc != NULL); |
1642 ASSERT_TRUE(dc != NULL); | 1745 ASSERT_TRUE(dc != NULL); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1684 EXPECT_EQ(updated_data_streams[0].cname, updated_data_streams[1].cname); | 1787 EXPECT_EQ(updated_data_streams[0].cname, updated_data_streams[1].cname); |
1685 // The stream correctly got the CNAME from the MediaSessionOptions. | 1788 // The stream correctly got the CNAME from the MediaSessionOptions. |
1686 // The Expected RTCP CNAME is the default one as we are using the default | 1789 // The Expected RTCP CNAME is the default one as we are using the default |
1687 // MediaSessionOptions. | 1790 // MediaSessionOptions. |
1688 EXPECT_EQ(updated_data_streams[0].cname, cricket::kDefaultRtcpCname); | 1791 EXPECT_EQ(updated_data_streams[0].cname, cricket::kDefaultRtcpCname); |
1689 } | 1792 } |
1690 | 1793 |
1691 // Create an offer with simulcast video stream. | 1794 // Create an offer with simulcast video stream. |
1692 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSimulcastVideoOffer) { | 1795 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSimulcastVideoOffer) { |
1693 MediaSessionOptions opts; | 1796 MediaSessionOptions opts; |
1797 AddAudioVideoSections(cricket::MD_SENDRECV, &opts); | |
1694 const int num_sim_layers = 3; | 1798 const int num_sim_layers = 3; |
1695 opts.AddSendVideoStream(kVideoTrack1, kMediaStream1, num_sim_layers); | 1799 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, kVideoTrack1, |
1800 kMediaStream1, num_sim_layers, &opts); | |
1696 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1801 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
1697 | 1802 |
1698 ASSERT_TRUE(offer.get() != NULL); | 1803 ASSERT_TRUE(offer.get() != NULL); |
1699 const ContentInfo* vc = offer->GetContentByName("video"); | 1804 const ContentInfo* vc = offer->GetContentByName("video"); |
1700 ASSERT_TRUE(vc != NULL); | 1805 ASSERT_TRUE(vc != NULL); |
1701 const VideoContentDescription* vcd = | 1806 const VideoContentDescription* vcd = |
1702 static_cast<const VideoContentDescription*>(vc->description); | 1807 static_cast<const VideoContentDescription*>(vc->description); |
1703 | 1808 |
1704 const StreamParamsVec& video_streams = vcd->streams(); | 1809 const StreamParamsVec& video_streams = vcd->streams(); |
1705 ASSERT_EQ(1U, video_streams.size()); | 1810 ASSERT_EQ(1U, video_streams.size()); |
1706 EXPECT_EQ(kVideoTrack1, video_streams[0].id); | 1811 EXPECT_EQ(kVideoTrack1, video_streams[0].id); |
1707 const SsrcGroup* sim_ssrc_group = | 1812 const SsrcGroup* sim_ssrc_group = |
1708 video_streams[0].get_ssrc_group(cricket::kSimSsrcGroupSemantics); | 1813 video_streams[0].get_ssrc_group(cricket::kSimSsrcGroupSemantics); |
1709 ASSERT_TRUE(sim_ssrc_group != NULL); | 1814 ASSERT_TRUE(sim_ssrc_group != NULL); |
1710 EXPECT_EQ(static_cast<size_t>(num_sim_layers), sim_ssrc_group->ssrcs.size()); | 1815 EXPECT_EQ(static_cast<size_t>(num_sim_layers), sim_ssrc_group->ssrcs.size()); |
1711 } | 1816 } |
1712 | 1817 |
1713 // Create an audio and video answer to a standard video offer with: | 1818 // Create an audio and video answer to a standard video offer with: |
1714 // - one video track | 1819 // - one video track |
1715 // - two audio tracks | 1820 // - two audio tracks |
1716 // - two data tracks | 1821 // - two data tracks |
1717 // and ensure it matches what we expect. Also updates the initial answer by | 1822 // and ensure it matches what we expect. Also updates the initial answer by |
1718 // adding a new video track and removes one of the audio tracks. | 1823 // adding a new video track and removes one of the audio tracks. |
1719 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) { | 1824 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) { |
1720 MediaSessionOptions offer_opts; | 1825 MediaSessionOptions offer_opts; |
1721 offer_opts.recv_video = true; | 1826 AddAudioVideoSections(cricket::MD_RECVONLY, &offer_opts); |
1722 offer_opts.data_channel_type = cricket::DCT_RTP; | 1827 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &offer_opts); |
1723 f1_.set_secure(SEC_ENABLED); | 1828 f1_.set_secure(SEC_ENABLED); |
1724 f2_.set_secure(SEC_ENABLED); | 1829 f2_.set_secure(SEC_ENABLED); |
1725 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(offer_opts, NULL)); | 1830 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(offer_opts, NULL)); |
1726 | 1831 |
1727 MediaSessionOptions opts; | 1832 MediaSessionOptions answer_opts; |
1728 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); | 1833 AddAudioVideoSections(cricket::MD_SENDRECV, &answer_opts); |
1729 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 1834 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, kVideoTrack1, |
1730 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2, kMediaStream1); | 1835 kMediaStream1, 1, &answer_opts); |
1731 opts.data_channel_type = cricket::DCT_RTP; | 1836 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1, |
1732 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack1, kMediaStream1); | 1837 kMediaStream1, 1, &answer_opts); |
1733 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack2, kMediaStream1); | 1838 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack2, |
1839 kMediaStream1, 1, &answer_opts); | |
1840 | |
1841 AddDataSection(cricket::DCT_RTP, cricket::MD_SENDRECV, &answer_opts); | |
1842 AttachSenderToMediaSection("data", MEDIA_TYPE_DATA, kDataTrack1, | |
1843 kMediaStream1, 1, &answer_opts); | |
1844 AttachSenderToMediaSection("data", MEDIA_TYPE_DATA, kDataTrack2, | |
1845 kMediaStream1, 1, &answer_opts); | |
1734 | 1846 |
1735 std::unique_ptr<SessionDescription> answer( | 1847 std::unique_ptr<SessionDescription> answer( |
1736 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1848 f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
1737 | 1849 |
1738 ASSERT_TRUE(answer.get() != NULL); | 1850 ASSERT_TRUE(answer.get() != NULL); |
1739 const ContentInfo* ac = answer->GetContentByName("audio"); | 1851 const ContentInfo* ac = answer->GetContentByName("audio"); |
1740 const ContentInfo* vc = answer->GetContentByName("video"); | 1852 const ContentInfo* vc = answer->GetContentByName("video"); |
1741 const ContentInfo* dc = answer->GetContentByName("data"); | 1853 const ContentInfo* dc = answer->GetContentByName("data"); |
1742 ASSERT_TRUE(ac != NULL); | 1854 ASSERT_TRUE(ac != NULL); |
1743 ASSERT_TRUE(vc != NULL); | 1855 ASSERT_TRUE(vc != NULL); |
1744 ASSERT_TRUE(dc != NULL); | 1856 ASSERT_TRUE(dc != NULL); |
1745 const AudioContentDescription* acd = | 1857 const AudioContentDescription* acd = |
1746 static_cast<const AudioContentDescription*>(ac->description); | 1858 static_cast<const AudioContentDescription*>(ac->description); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1790 EXPECT_EQ(kDataTrack2, data_streams[1].id); | 1902 EXPECT_EQ(kDataTrack2, data_streams[1].id); |
1791 ASSERT_EQ(1U, data_streams[1].ssrcs.size()); | 1903 ASSERT_EQ(1U, data_streams[1].ssrcs.size()); |
1792 EXPECT_NE(0U, data_streams[1].ssrcs[0]); | 1904 EXPECT_NE(0U, data_streams[1].ssrcs[0]); |
1793 | 1905 |
1794 EXPECT_EQ(cricket::kDataMaxBandwidth, | 1906 EXPECT_EQ(cricket::kDataMaxBandwidth, |
1795 dcd->bandwidth()); // default bandwidth (auto) | 1907 dcd->bandwidth()); // default bandwidth (auto) |
1796 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on | 1908 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on |
1797 | 1909 |
1798 // Update the answer. Add a new video track that is not synched to the | 1910 // Update the answer. Add a new video track that is not synched to the |
1799 // other tracks and remove 1 audio track. | 1911 // other tracks and remove 1 audio track. |
1800 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack2, kMediaStream2); | 1912 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, kVideoTrack2, |
1801 opts.RemoveSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2); | 1913 kMediaStream2, 1, &answer_opts); |
1802 opts.RemoveSendStream(MEDIA_TYPE_DATA, kDataTrack2); | 1914 DetachSenderFromMediaSection("audio", kAudioTrack2, &answer_opts); |
1915 DetachSenderFromMediaSection("data", kDataTrack2, &answer_opts); | |
1803 std::unique_ptr<SessionDescription> updated_answer( | 1916 std::unique_ptr<SessionDescription> updated_answer( |
1804 f2_.CreateAnswer(offer.get(), opts, answer.get())); | 1917 f2_.CreateAnswer(offer.get(), answer_opts, answer.get())); |
1805 | 1918 |
1806 ASSERT_TRUE(updated_answer.get() != NULL); | 1919 ASSERT_TRUE(updated_answer.get() != NULL); |
1807 ac = updated_answer->GetContentByName("audio"); | 1920 ac = updated_answer->GetContentByName("audio"); |
1808 vc = updated_answer->GetContentByName("video"); | 1921 vc = updated_answer->GetContentByName("video"); |
1809 dc = updated_answer->GetContentByName("data"); | 1922 dc = updated_answer->GetContentByName("data"); |
1810 ASSERT_TRUE(ac != NULL); | 1923 ASSERT_TRUE(ac != NULL); |
1811 ASSERT_TRUE(vc != NULL); | 1924 ASSERT_TRUE(vc != NULL); |
1812 ASSERT_TRUE(dc != NULL); | 1925 ASSERT_TRUE(dc != NULL); |
1813 const AudioContentDescription* updated_acd = | 1926 const AudioContentDescription* updated_acd = |
1814 static_cast<const AudioContentDescription*>(ac->description); | 1927 static_cast<const AudioContentDescription*>(ac->description); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1846 ASSERT_EQ(1U, updated_data_streams.size()); | 1959 ASSERT_EQ(1U, updated_data_streams.size()); |
1847 EXPECT_TRUE(data_streams[0] == updated_data_streams[0]); | 1960 EXPECT_TRUE(data_streams[0] == updated_data_streams[0]); |
1848 } | 1961 } |
1849 | 1962 |
1850 // Create an updated offer after creating an answer to the original offer and | 1963 // Create an updated offer after creating an answer to the original offer and |
1851 // verify that the codecs that were part of the original answer are not changed | 1964 // verify that the codecs that were part of the original answer are not changed |
1852 // in the updated offer. | 1965 // in the updated offer. |
1853 TEST_F(MediaSessionDescriptionFactoryTest, | 1966 TEST_F(MediaSessionDescriptionFactoryTest, |
1854 RespondentCreatesOfferAfterCreatingAnswer) { | 1967 RespondentCreatesOfferAfterCreatingAnswer) { |
1855 MediaSessionOptions opts; | 1968 MediaSessionOptions opts; |
1856 opts.recv_audio = true; | 1969 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
1857 opts.recv_video = true; | |
1858 | 1970 |
1859 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1971 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
1860 std::unique_ptr<SessionDescription> answer( | 1972 std::unique_ptr<SessionDescription> answer( |
1861 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1973 f2_.CreateAnswer(offer.get(), opts, NULL)); |
1862 | 1974 |
1863 const AudioContentDescription* acd = | 1975 const AudioContentDescription* acd = |
1864 GetFirstAudioContentDescription(answer.get()); | 1976 GetFirstAudioContentDescription(answer.get()); |
1865 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 1977 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
1866 | 1978 |
1867 const VideoContentDescription* vcd = | 1979 const VideoContentDescription* vcd = |
(...skipping 30 matching lines...) Expand all Loading... | |
1898 GetFirstVideoContentDescription(updated_offer.get()); | 2010 GetFirstVideoContentDescription(updated_offer.get()); |
1899 EXPECT_EQ(MAKE_VECTOR(kUpdatedVideoCodecOffer), updated_vcd->codecs()); | 2011 EXPECT_EQ(MAKE_VECTOR(kUpdatedVideoCodecOffer), updated_vcd->codecs()); |
1900 } | 2012 } |
1901 | 2013 |
1902 // Create an updated offer after creating an answer to the original offer and | 2014 // Create an updated offer after creating an answer to the original offer and |
1903 // verify that the codecs that were part of the original answer are not changed | 2015 // verify that the codecs that were part of the original answer are not changed |
1904 // in the updated offer. In this test Rtx is enabled. | 2016 // in the updated offer. In this test Rtx is enabled. |
1905 TEST_F(MediaSessionDescriptionFactoryTest, | 2017 TEST_F(MediaSessionDescriptionFactoryTest, |
1906 RespondentCreatesOfferAfterCreatingAnswerWithRtx) { | 2018 RespondentCreatesOfferAfterCreatingAnswerWithRtx) { |
1907 MediaSessionOptions opts; | 2019 MediaSessionOptions opts; |
1908 opts.recv_video = true; | 2020 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, !kStopped, |
1909 opts.recv_audio = false; | 2021 &opts); |
1910 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 2022 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
1911 // This creates rtx for H264 with the payload type |f1_| uses. | 2023 // This creates rtx for H264 with the payload type |f1_| uses. |
1912 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); | 2024 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
1913 f1_.set_video_codecs(f1_codecs); | 2025 f1_.set_video_codecs(f1_codecs); |
1914 | 2026 |
1915 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 2027 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
1916 // This creates rtx for H264 with the payload type |f2_| uses. | 2028 // This creates rtx for H264 with the payload type |f2_| uses. |
1917 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); | 2029 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); |
1918 f2_.set_video_codecs(f2_codecs); | 2030 f2_.set_video_codecs(f2_codecs); |
1919 | 2031 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1951 // codec have the same default payload type as an audio codec that is already in | 2063 // codec have the same default payload type as an audio codec that is already in |
1952 // use, the added codecs payload types are changed. | 2064 // use, the added codecs payload types are changed. |
1953 TEST_F(MediaSessionDescriptionFactoryTest, | 2065 TEST_F(MediaSessionDescriptionFactoryTest, |
1954 RespondentCreatesOfferWithVideoAndRtxAfterCreatingAudioAnswer) { | 2066 RespondentCreatesOfferWithVideoAndRtxAfterCreatingAudioAnswer) { |
1955 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 2067 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
1956 // This creates rtx for H264 with the payload type |f1_| uses. | 2068 // This creates rtx for H264 with the payload type |f1_| uses. |
1957 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); | 2069 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
1958 f1_.set_video_codecs(f1_codecs); | 2070 f1_.set_video_codecs(f1_codecs); |
1959 | 2071 |
1960 MediaSessionOptions opts; | 2072 MediaSessionOptions opts; |
1961 opts.recv_audio = true; | 2073 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, !kStopped, |
1962 opts.recv_video = false; | 2074 &opts); |
1963 | 2075 |
1964 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 2076 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
1965 std::unique_ptr<SessionDescription> answer( | 2077 std::unique_ptr<SessionDescription> answer( |
1966 f2_.CreateAnswer(offer.get(), opts, NULL)); | 2078 f2_.CreateAnswer(offer.get(), opts, NULL)); |
1967 | 2079 |
1968 const AudioContentDescription* acd = | 2080 const AudioContentDescription* acd = |
1969 GetFirstAudioContentDescription(answer.get()); | 2081 GetFirstAudioContentDescription(answer.get()); |
1970 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 2082 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
1971 | 2083 |
1972 // Now - let |f2_| add video with RTX and let the payload type the RTX codec | 2084 // Now - let |f2_| add video with RTX and let the payload type the RTX codec |
1973 // reference be the same as an audio codec that was negotiated in the | 2085 // reference be the same as an audio codec that was negotiated in the |
1974 // first offer/answer exchange. | 2086 // first offer/answer exchange. |
1975 opts.recv_audio = true; | 2087 opts.media_description_options.clear(); |
1976 opts.recv_video = true; | 2088 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
1977 | 2089 |
1978 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 2090 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
1979 int used_pl_type = acd->codecs()[0].id; | 2091 int used_pl_type = acd->codecs()[0].id; |
1980 f2_codecs[0].id = used_pl_type; // Set the payload type for H264. | 2092 f2_codecs[0].id = used_pl_type; // Set the payload type for H264. |
1981 AddRtxCodec(VideoCodec::CreateRtxCodec(125, used_pl_type), &f2_codecs); | 2093 AddRtxCodec(VideoCodec::CreateRtxCodec(125, used_pl_type), &f2_codecs); |
1982 f2_.set_video_codecs(f2_codecs); | 2094 f2_.set_video_codecs(f2_codecs); |
1983 | 2095 |
1984 std::unique_ptr<SessionDescription> updated_offer( | 2096 std::unique_ptr<SessionDescription> updated_offer( |
1985 f2_.CreateOffer(opts, answer.get())); | 2097 f2_.CreateOffer(opts, answer.get())); |
1986 ASSERT_TRUE(updated_offer); | 2098 ASSERT_TRUE(updated_offer); |
(...skipping 16 matching lines...) Expand all Loading... | |
2003 rtx.params[cricket::kCodecParamAssociatedPayloadType]); | 2115 rtx.params[cricket::kCodecParamAssociatedPayloadType]); |
2004 EXPECT_EQ(new_h264_pl_type, pt_referenced_by_rtx); | 2116 EXPECT_EQ(new_h264_pl_type, pt_referenced_by_rtx); |
2005 } | 2117 } |
2006 | 2118 |
2007 // Create an updated offer with RTX after creating an answer to an offer | 2119 // Create an updated offer with RTX after creating an answer to an offer |
2008 // without RTX, and with different default payload types. | 2120 // without RTX, and with different default payload types. |
2009 // Verify that the added RTX codec references the correct payload type. | 2121 // Verify that the added RTX codec references the correct payload type. |
2010 TEST_F(MediaSessionDescriptionFactoryTest, | 2122 TEST_F(MediaSessionDescriptionFactoryTest, |
2011 RespondentCreatesOfferWithRtxAfterCreatingAnswerWithoutRtx) { | 2123 RespondentCreatesOfferWithRtxAfterCreatingAnswerWithoutRtx) { |
2012 MediaSessionOptions opts; | 2124 MediaSessionOptions opts; |
2013 opts.recv_video = true; | 2125 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
2014 opts.recv_audio = true; | |
2015 | 2126 |
2016 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 2127 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
2017 // This creates rtx for H264 with the payload type |f2_| uses. | 2128 // This creates rtx for H264 with the payload type |f2_| uses. |
2018 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); | 2129 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); |
2019 f2_.set_video_codecs(f2_codecs); | 2130 f2_.set_video_codecs(f2_codecs); |
2020 | 2131 |
2021 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | 2132 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
2022 ASSERT_TRUE(offer.get() != nullptr); | 2133 ASSERT_TRUE(offer.get() != nullptr); |
2023 std::unique_ptr<SessionDescription> answer( | 2134 std::unique_ptr<SessionDescription> answer( |
2024 f2_.CreateAnswer(offer.get(), opts, nullptr)); | 2135 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
(...skipping 17 matching lines...) Expand all Loading... | |
2042 // New offer should attempt to add H263, and RTX for H264. | 2153 // New offer should attempt to add H263, and RTX for H264. |
2043 expected_codecs.push_back(kVideoCodecs2[1]); | 2154 expected_codecs.push_back(kVideoCodecs2[1]); |
2044 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[1].id), | 2155 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[1].id), |
2045 &expected_codecs); | 2156 &expected_codecs); |
2046 EXPECT_EQ(expected_codecs, updated_vcd->codecs()); | 2157 EXPECT_EQ(expected_codecs, updated_vcd->codecs()); |
2047 } | 2158 } |
2048 | 2159 |
2049 // Test that RTX is ignored when there is no associated payload type parameter. | 2160 // Test that RTX is ignored when there is no associated payload type parameter. |
2050 TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { | 2161 TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { |
2051 MediaSessionOptions opts; | 2162 MediaSessionOptions opts; |
2052 opts.recv_video = true; | 2163 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, !kStopped, |
2053 opts.recv_audio = false; | 2164 &opts); |
2054 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 2165 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
2055 // This creates RTX without associated payload type parameter. | 2166 // This creates RTX without associated payload type parameter. |
2056 AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName), &f1_codecs); | 2167 AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName), &f1_codecs); |
2057 f1_.set_video_codecs(f1_codecs); | 2168 f1_.set_video_codecs(f1_codecs); |
2058 | 2169 |
2059 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 2170 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
2060 // This creates RTX for H264 with the payload type |f2_| uses. | 2171 // This creates RTX for H264 with the payload type |f2_| uses. |
2061 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); | 2172 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); |
2062 f2_.set_video_codecs(f2_codecs); | 2173 f2_.set_video_codecs(f2_codecs); |
2063 | 2174 |
(...skipping 22 matching lines...) Expand all Loading... | |
2086 std::vector<std::string> codec_names = | 2197 std::vector<std::string> codec_names = |
2087 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()); | 2198 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()); |
2088 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(), | 2199 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(), |
2089 cricket::kRtxCodecName)); | 2200 cricket::kRtxCodecName)); |
2090 } | 2201 } |
2091 | 2202 |
2092 // Test that RTX will be filtered out in the answer if its associated payload | 2203 // Test that RTX will be filtered out in the answer if its associated payload |
2093 // type doesn't match the local value. | 2204 // type doesn't match the local value. |
2094 TEST_F(MediaSessionDescriptionFactoryTest, FilterOutRtxIfAptDoesntMatch) { | 2205 TEST_F(MediaSessionDescriptionFactoryTest, FilterOutRtxIfAptDoesntMatch) { |
2095 MediaSessionOptions opts; | 2206 MediaSessionOptions opts; |
2096 opts.recv_video = true; | 2207 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, !kStopped, |
2097 opts.recv_audio = false; | 2208 &opts); |
2098 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 2209 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
2099 // This creates RTX for H264 in sender. | 2210 // This creates RTX for H264 in sender. |
2100 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); | 2211 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
2101 f1_.set_video_codecs(f1_codecs); | 2212 f1_.set_video_codecs(f1_codecs); |
2102 | 2213 |
2103 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 2214 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
2104 // This creates RTX for H263 in receiver. | 2215 // This creates RTX for H263 in receiver. |
2105 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[1].id), &f2_codecs); | 2216 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[1].id), &f2_codecs); |
2106 f2_.set_video_codecs(f2_codecs); | 2217 f2_.set_video_codecs(f2_codecs); |
2107 | 2218 |
2108 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 2219 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
2109 ASSERT_TRUE(offer.get() != NULL); | 2220 ASSERT_TRUE(offer.get() != NULL); |
2110 // Associated payload type doesn't match, therefore, RTX codec is removed in | 2221 // Associated payload type doesn't match, therefore, RTX codec is removed in |
2111 // the answer. | 2222 // the answer. |
2112 std::unique_ptr<SessionDescription> answer( | 2223 std::unique_ptr<SessionDescription> answer( |
2113 f2_.CreateAnswer(offer.get(), opts, NULL)); | 2224 f2_.CreateAnswer(offer.get(), opts, NULL)); |
2114 | 2225 |
2115 std::vector<std::string> codec_names = | 2226 std::vector<std::string> codec_names = |
2116 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()); | 2227 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()); |
2117 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(), | 2228 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(), |
2118 cricket::kRtxCodecName)); | 2229 cricket::kRtxCodecName)); |
2119 } | 2230 } |
2120 | 2231 |
2121 // Test that when multiple RTX codecs are offered, only the matched RTX codec | 2232 // Test that when multiple RTX codecs are offered, only the matched RTX codec |
2122 // is added in the answer, and the unsupported RTX codec is filtered out. | 2233 // is added in the answer, and the unsupported RTX codec is filtered out. |
2123 TEST_F(MediaSessionDescriptionFactoryTest, | 2234 TEST_F(MediaSessionDescriptionFactoryTest, |
2124 FilterOutUnsupportedRtxWhenCreatingAnswer) { | 2235 FilterOutUnsupportedRtxWhenCreatingAnswer) { |
2125 MediaSessionOptions opts; | 2236 MediaSessionOptions opts; |
2126 opts.recv_video = true; | 2237 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, !kStopped, |
2127 opts.recv_audio = false; | 2238 &opts); |
2128 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 2239 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
2129 // This creates RTX for H264-SVC in sender. | 2240 // This creates RTX for H264-SVC in sender. |
2130 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), &f1_codecs); | 2241 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), &f1_codecs); |
2131 f1_.set_video_codecs(f1_codecs); | 2242 f1_.set_video_codecs(f1_codecs); |
2132 | 2243 |
2133 // This creates RTX for H264 in sender. | 2244 // This creates RTX for H264 in sender. |
2134 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); | 2245 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
2135 f1_.set_video_codecs(f1_codecs); | 2246 f1_.set_video_codecs(f1_codecs); |
2136 | 2247 |
2137 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 2248 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
(...skipping 13 matching lines...) Expand all Loading... | |
2151 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), | 2262 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), |
2152 &expected_codecs); | 2263 &expected_codecs); |
2153 | 2264 |
2154 EXPECT_EQ(expected_codecs, vcd->codecs()); | 2265 EXPECT_EQ(expected_codecs, vcd->codecs()); |
2155 } | 2266 } |
2156 | 2267 |
2157 // Test that after one RTX codec has been negotiated, a new offer can attempt | 2268 // Test that after one RTX codec has been negotiated, a new offer can attempt |
2158 // to add another. | 2269 // to add another. |
2159 TEST_F(MediaSessionDescriptionFactoryTest, AddSecondRtxInNewOffer) { | 2270 TEST_F(MediaSessionDescriptionFactoryTest, AddSecondRtxInNewOffer) { |
2160 MediaSessionOptions opts; | 2271 MediaSessionOptions opts; |
2161 opts.recv_video = true; | 2272 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, !kStopped, |
2162 opts.recv_audio = false; | 2273 &opts); |
2163 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 2274 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
2164 // This creates RTX for H264 for the offerer. | 2275 // This creates RTX for H264 for the offerer. |
2165 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); | 2276 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
2166 f1_.set_video_codecs(f1_codecs); | 2277 f1_.set_video_codecs(f1_codecs); |
2167 | 2278 |
2168 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | 2279 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
2169 ASSERT_TRUE(offer); | 2280 ASSERT_TRUE(offer); |
2170 const VideoContentDescription* vcd = | 2281 const VideoContentDescription* vcd = |
2171 GetFirstVideoContentDescription(offer.get()); | 2282 GetFirstVideoContentDescription(offer.get()); |
2172 | 2283 |
(...skipping 13 matching lines...) Expand all Loading... | |
2186 | 2297 |
2187 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), | 2298 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), |
2188 &expected_codecs); | 2299 &expected_codecs); |
2189 EXPECT_EQ(expected_codecs, vcd->codecs()); | 2300 EXPECT_EQ(expected_codecs, vcd->codecs()); |
2190 } | 2301 } |
2191 | 2302 |
2192 // Test that when RTX is used in conjunction with simulcast, an RTX ssrc is | 2303 // Test that when RTX is used in conjunction with simulcast, an RTX ssrc is |
2193 // generated for each simulcast ssrc and correctly grouped. | 2304 // generated for each simulcast ssrc and correctly grouped. |
2194 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { | 2305 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { |
2195 MediaSessionOptions opts; | 2306 MediaSessionOptions opts; |
2196 opts.recv_video = true; | 2307 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_SENDRECV, !kStopped, |
2197 opts.recv_audio = false; | 2308 &opts); |
2198 | |
2199 // Add simulcast streams. | 2309 // Add simulcast streams. |
2200 opts.AddSendVideoStream("stream1", "stream1label", 3); | 2310 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, "stream1", |
2311 "stream1label", 3, &opts); | |
2201 | 2312 |
2202 // Use a single real codec, and then add RTX for it. | 2313 // Use a single real codec, and then add RTX for it. |
2203 std::vector<VideoCodec> f1_codecs; | 2314 std::vector<VideoCodec> f1_codecs; |
2204 f1_codecs.push_back(VideoCodec(97, "H264")); | 2315 f1_codecs.push_back(VideoCodec(97, "H264")); |
2205 AddRtxCodec(VideoCodec::CreateRtxCodec(125, 97), &f1_codecs); | 2316 AddRtxCodec(VideoCodec::CreateRtxCodec(125, 97), &f1_codecs); |
2206 f1_.set_video_codecs(f1_codecs); | 2317 f1_.set_video_codecs(f1_codecs); |
2207 | 2318 |
2208 // Ensure that the offer has an RTX ssrc for each regular ssrc, and that there | 2319 // Ensure that the offer has an RTX ssrc for each regular ssrc, and that there |
2209 // is a FID ssrc + grouping for each. | 2320 // is a FID ssrc + grouping for each. |
2210 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 2321 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
(...skipping 16 matching lines...) Expand all Loading... | |
2227 EXPECT_EQ(3u, primary_ssrcs.size()); | 2338 EXPECT_EQ(3u, primary_ssrcs.size()); |
2228 std::vector<uint32_t> fid_ssrcs; | 2339 std::vector<uint32_t> fid_ssrcs; |
2229 streams[0].GetFidSsrcs(primary_ssrcs, &fid_ssrcs); | 2340 streams[0].GetFidSsrcs(primary_ssrcs, &fid_ssrcs); |
2230 EXPECT_EQ(3u, fid_ssrcs.size()); | 2341 EXPECT_EQ(3u, fid_ssrcs.size()); |
2231 } | 2342 } |
2232 | 2343 |
2233 // Test that, when the FlexFEC codec is added, a FlexFEC ssrc is created | 2344 // Test that, when the FlexFEC codec is added, a FlexFEC ssrc is created |
2234 // together with a FEC-FR grouping. | 2345 // together with a FEC-FR grouping. |
2235 TEST_F(MediaSessionDescriptionFactoryTest, GenerateFlexfecSsrc) { | 2346 TEST_F(MediaSessionDescriptionFactoryTest, GenerateFlexfecSsrc) { |
2236 MediaSessionOptions opts; | 2347 MediaSessionOptions opts; |
2237 opts.recv_video = true; | 2348 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_SENDRECV, !kStopped, |
2238 opts.recv_audio = false; | 2349 &opts); |
2239 | |
2240 // Add single stream. | 2350 // Add single stream. |
2241 opts.AddSendVideoStream("stream1", "stream1label", 1); | 2351 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, "stream1", |
2352 "stream1label", 1, &opts); | |
2242 | 2353 |
2243 // Use a single real codec, and then add FlexFEC for it. | 2354 // Use a single real codec, and then add FlexFEC for it. |
2244 std::vector<VideoCodec> f1_codecs; | 2355 std::vector<VideoCodec> f1_codecs; |
2245 f1_codecs.push_back(VideoCodec(97, "H264")); | 2356 f1_codecs.push_back(VideoCodec(97, "H264")); |
2246 f1_codecs.push_back(VideoCodec(118, "flexfec-03")); | 2357 f1_codecs.push_back(VideoCodec(118, "flexfec-03")); |
2247 f1_.set_video_codecs(f1_codecs); | 2358 f1_.set_video_codecs(f1_codecs); |
2248 | 2359 |
2249 // Ensure that the offer has a single FlexFEC ssrc and that | 2360 // Ensure that the offer has a single FlexFEC ssrc and that |
2250 // there is no FEC-FR ssrc + grouping for each. | 2361 // there is no FEC-FR ssrc + grouping for each. |
2251 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | 2362 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
(...skipping 15 matching lines...) Expand all Loading... | |
2267 uint32_t flexfec_ssrc; | 2378 uint32_t flexfec_ssrc; |
2268 EXPECT_TRUE(streams[0].GetFecFrSsrc(primary_ssrcs[0], &flexfec_ssrc)); | 2379 EXPECT_TRUE(streams[0].GetFecFrSsrc(primary_ssrcs[0], &flexfec_ssrc)); |
2269 EXPECT_NE(flexfec_ssrc, 0u); | 2380 EXPECT_NE(flexfec_ssrc, 0u); |
2270 } | 2381 } |
2271 | 2382 |
2272 // Test that FlexFEC is disabled for simulcast. | 2383 // Test that FlexFEC is disabled for simulcast. |
2273 // TODO(brandtr): Remove this test when we support simulcast, either through | 2384 // TODO(brandtr): Remove this test when we support simulcast, either through |
2274 // multiple FlexfecSenders, or through multistream protection. | 2385 // multiple FlexfecSenders, or through multistream protection. |
2275 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateNoFlexfecSsrcs) { | 2386 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateNoFlexfecSsrcs) { |
2276 MediaSessionOptions opts; | 2387 MediaSessionOptions opts; |
2277 opts.recv_video = true; | 2388 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_SENDRECV, !kStopped, |
2278 opts.recv_audio = false; | 2389 &opts); |
2279 | |
2280 // Add simulcast streams. | 2390 // Add simulcast streams. |
2281 opts.AddSendVideoStream("stream1", "stream1label", 3); | 2391 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, "stream1", |
2392 "stream1label", 3, &opts); | |
2282 | 2393 |
2283 // Use a single real codec, and then add FlexFEC for it. | 2394 // Use a single real codec, and then add FlexFEC for it. |
2284 std::vector<VideoCodec> f1_codecs; | 2395 std::vector<VideoCodec> f1_codecs; |
2285 f1_codecs.push_back(VideoCodec(97, "H264")); | 2396 f1_codecs.push_back(VideoCodec(97, "H264")); |
2286 f1_codecs.push_back(VideoCodec(118, "flexfec-03")); | 2397 f1_codecs.push_back(VideoCodec(118, "flexfec-03")); |
2287 f1_.set_video_codecs(f1_codecs); | 2398 f1_.set_video_codecs(f1_codecs); |
2288 | 2399 |
2289 // Ensure that the offer has no FlexFEC ssrcs for each regular ssrc, and that | 2400 // Ensure that the offer has no FlexFEC ssrcs for each regular ssrc, and that |
2290 // there is no FEC-FR ssrc + grouping for each. | 2401 // there is no FEC-FR ssrc + grouping for each. |
2291 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | 2402 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
(...skipping 19 matching lines...) Expand all Loading... | |
2311 EXPECT_FALSE(streams[0].GetFecFrSsrc(primary_ssrc, &flexfec_ssrc)); | 2422 EXPECT_FALSE(streams[0].GetFecFrSsrc(primary_ssrc, &flexfec_ssrc)); |
2312 } | 2423 } |
2313 } | 2424 } |
2314 | 2425 |
2315 // Create an updated offer after creating an answer to the original offer and | 2426 // Create an updated offer after creating an answer to the original offer and |
2316 // verify that the RTP header extensions that were part of the original answer | 2427 // verify that the RTP header extensions that were part of the original answer |
2317 // are not changed in the updated offer. | 2428 // are not changed in the updated offer. |
2318 TEST_F(MediaSessionDescriptionFactoryTest, | 2429 TEST_F(MediaSessionDescriptionFactoryTest, |
2319 RespondentCreatesOfferAfterCreatingAnswerWithRtpExtensions) { | 2430 RespondentCreatesOfferAfterCreatingAnswerWithRtpExtensions) { |
2320 MediaSessionOptions opts; | 2431 MediaSessionOptions opts; |
2321 opts.recv_audio = true; | 2432 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
2322 opts.recv_video = true; | |
2323 | 2433 |
2324 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); | 2434 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); |
2325 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); | 2435 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); |
2326 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); | 2436 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); |
2327 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); | 2437 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); |
2328 | 2438 |
2329 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 2439 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
2330 std::unique_ptr<SessionDescription> answer( | 2440 std::unique_ptr<SessionDescription> answer( |
2331 f2_.CreateAnswer(offer.get(), opts, NULL)); | 2441 f2_.CreateAnswer(offer.get(), opts, NULL)); |
2332 | 2442 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2366 GetFirstVideoContentDescription(updated_offer.get()); | 2476 GetFirstVideoContentDescription(updated_offer.get()); |
2367 EXPECT_EQ(MAKE_VECTOR(kUpdatedVideoRtpExtensions), | 2477 EXPECT_EQ(MAKE_VECTOR(kUpdatedVideoRtpExtensions), |
2368 updated_vcd->rtp_header_extensions()); | 2478 updated_vcd->rtp_header_extensions()); |
2369 } | 2479 } |
2370 | 2480 |
2371 // Verify that if the same RTP extension URI is used for audio and video, the | 2481 // Verify that if the same RTP extension URI is used for audio and video, the |
2372 // same ID is used. Also verify that the ID isn't changed when creating an | 2482 // same ID is used. Also verify that the ID isn't changed when creating an |
2373 // updated offer (this was previously a bug). | 2483 // updated offer (this was previously a bug). |
2374 TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReused) { | 2484 TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReused) { |
2375 MediaSessionOptions opts; | 2485 MediaSessionOptions opts; |
2376 opts.recv_audio = true; | 2486 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
2377 opts.recv_video = true; | |
2378 | 2487 |
2379 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension3)); | 2488 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension3)); |
2380 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension3)); | 2489 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension3)); |
2381 | 2490 |
2382 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 2491 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
2383 | 2492 |
2384 // Since the audio extensions used ID 3 for "both_audio_and_video", so should | 2493 // Since the audio extensions used ID 3 for "both_audio_and_video", so should |
2385 // the video extensions. | 2494 // the video extensions. |
2386 const RtpExtension kExpectedVideoRtpExtension[] = { | 2495 const RtpExtension kExpectedVideoRtpExtension[] = { |
2387 kVideoRtpExtension3[0], kAudioRtpExtension3[1], | 2496 kVideoRtpExtension3[0], kAudioRtpExtension3[1], |
(...skipping 14 matching lines...) Expand all Loading... | |
2402 GetFirstAudioContentDescription( | 2511 GetFirstAudioContentDescription( |
2403 updated_offer.get())->rtp_header_extensions()); | 2512 updated_offer.get())->rtp_header_extensions()); |
2404 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension), | 2513 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension), |
2405 GetFirstVideoContentDescription( | 2514 GetFirstVideoContentDescription( |
2406 updated_offer.get())->rtp_header_extensions()); | 2515 updated_offer.get())->rtp_header_extensions()); |
2407 } | 2516 } |
2408 | 2517 |
2409 // Same as "RtpExtensionIdReused" above for encrypted RTP extensions. | 2518 // Same as "RtpExtensionIdReused" above for encrypted RTP extensions. |
2410 TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReusedEncrypted) { | 2519 TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReusedEncrypted) { |
2411 MediaSessionOptions opts; | 2520 MediaSessionOptions opts; |
2412 opts.recv_audio = true; | 2521 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
2413 opts.recv_video = true; | |
2414 | 2522 |
2415 f1_.set_enable_encrypted_rtp_header_extensions(true); | 2523 f1_.set_enable_encrypted_rtp_header_extensions(true); |
2416 f2_.set_enable_encrypted_rtp_header_extensions(true); | 2524 f2_.set_enable_encrypted_rtp_header_extensions(true); |
2417 | 2525 |
2418 f1_.set_audio_rtp_header_extensions( | 2526 f1_.set_audio_rtp_header_extensions( |
2419 MAKE_VECTOR(kAudioRtpExtension3ForEncryption)); | 2527 MAKE_VECTOR(kAudioRtpExtension3ForEncryption)); |
2420 f1_.set_video_rtp_header_extensions( | 2528 f1_.set_video_rtp_header_extensions( |
2421 MAKE_VECTOR(kVideoRtpExtension3ForEncryption)); | 2529 MAKE_VECTOR(kVideoRtpExtension3ForEncryption)); |
2422 | 2530 |
2423 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 2531 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2479 const VideoContentDescription* vcd_copy = | 2587 const VideoContentDescription* vcd_copy = |
2480 static_cast<const VideoContentDescription*>(vc->description); | 2588 static_cast<const VideoContentDescription*>(vc->description); |
2481 EXPECT_EQ(vcd->codecs(), vcd_copy->codecs()); | 2589 EXPECT_EQ(vcd->codecs(), vcd_copy->codecs()); |
2482 EXPECT_EQ(2u, vcd->first_ssrc()); | 2590 EXPECT_EQ(2u, vcd->first_ssrc()); |
2483 } | 2591 } |
2484 | 2592 |
2485 // The below TestTransportInfoXXX tests create different offers/answers, and | 2593 // The below TestTransportInfoXXX tests create different offers/answers, and |
2486 // ensure the TransportInfo in the SessionDescription matches what we expect. | 2594 // ensure the TransportInfo in the SessionDescription matches what we expect. |
2487 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudio) { | 2595 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudio) { |
2488 MediaSessionOptions options; | 2596 MediaSessionOptions options; |
2489 options.recv_audio = true; | 2597 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, !kStopped, |
2598 &options); | |
2490 TestTransportInfo(true, options, false); | 2599 TestTransportInfo(true, options, false); |
2491 } | 2600 } |
2492 | 2601 |
2493 TEST_F(MediaSessionDescriptionFactoryTest, | 2602 TEST_F(MediaSessionDescriptionFactoryTest, |
2494 TestTransportInfoOfferIceRenomination) { | 2603 TestTransportInfoOfferIceRenomination) { |
2495 MediaSessionOptions options; | 2604 MediaSessionOptions options; |
2496 options.enable_ice_renomination = true; | 2605 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, !kStopped, |
2606 &options); | |
2607 auto media_desc_options_it = | |
2608 FindFirstMediaDescriptionByMid("audio", &options); | |
2609 media_desc_options_it->transport_options.enable_ice_renomination = true; | |
2497 TestTransportInfo(true, options, false); | 2610 TestTransportInfo(true, options, false); |
2498 } | 2611 } |
2499 | 2612 |
2500 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudioCurrent) { | 2613 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudioCurrent) { |
2501 MediaSessionOptions options; | 2614 MediaSessionOptions options; |
2502 options.recv_audio = true; | 2615 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, !kStopped, |
2616 &options); | |
2503 TestTransportInfo(true, options, true); | 2617 TestTransportInfo(true, options, true); |
2504 } | 2618 } |
2505 | 2619 |
2506 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferMultimedia) { | 2620 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferMultimedia) { |
2507 MediaSessionOptions options; | 2621 MediaSessionOptions options; |
2508 options.recv_audio = true; | 2622 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
2509 options.recv_video = true; | 2623 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
2510 options.data_channel_type = cricket::DCT_RTP; | |
2511 TestTransportInfo(true, options, false); | 2624 TestTransportInfo(true, options, false); |
2512 } | 2625 } |
2513 | 2626 |
2514 TEST_F(MediaSessionDescriptionFactoryTest, | 2627 TEST_F(MediaSessionDescriptionFactoryTest, |
2515 TestTransportInfoOfferMultimediaCurrent) { | 2628 TestTransportInfoOfferMultimediaCurrent) { |
2516 MediaSessionOptions options; | 2629 MediaSessionOptions options; |
2517 options.recv_audio = true; | 2630 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
2518 options.recv_video = true; | 2631 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
2519 options.data_channel_type = cricket::DCT_RTP; | |
2520 TestTransportInfo(true, options, true); | 2632 TestTransportInfo(true, options, true); |
2521 } | 2633 } |
2522 | 2634 |
2523 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferBundle) { | 2635 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferBundle) { |
2524 MediaSessionOptions options; | 2636 MediaSessionOptions options; |
2525 options.recv_audio = true; | 2637 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
2526 options.recv_video = true; | 2638 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
2527 options.data_channel_type = cricket::DCT_RTP; | |
2528 options.bundle_enabled = true; | 2639 options.bundle_enabled = true; |
2529 TestTransportInfo(true, options, false); | 2640 TestTransportInfo(true, options, false); |
2530 } | 2641 } |
2531 | 2642 |
2532 TEST_F(MediaSessionDescriptionFactoryTest, | 2643 TEST_F(MediaSessionDescriptionFactoryTest, |
2533 TestTransportInfoOfferBundleCurrent) { | 2644 TestTransportInfoOfferBundleCurrent) { |
2534 MediaSessionOptions options; | 2645 MediaSessionOptions options; |
2535 options.recv_audio = true; | 2646 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
2536 options.recv_video = true; | 2647 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
2537 options.data_channel_type = cricket::DCT_RTP; | |
2538 options.bundle_enabled = true; | 2648 options.bundle_enabled = true; |
2539 TestTransportInfo(true, options, true); | 2649 TestTransportInfo(true, options, true); |
2540 } | 2650 } |
2541 | 2651 |
2542 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerAudio) { | 2652 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerAudio) { |
2543 MediaSessionOptions options; | 2653 MediaSessionOptions options; |
2544 options.recv_audio = true; | 2654 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, !kStopped, |
2655 &options); | |
2545 TestTransportInfo(false, options, false); | 2656 TestTransportInfo(false, options, false); |
2546 } | 2657 } |
2547 | 2658 |
2548 TEST_F(MediaSessionDescriptionFactoryTest, | 2659 TEST_F(MediaSessionDescriptionFactoryTest, |
2549 TestTransportInfoAnswerIceRenomination) { | 2660 TestTransportInfoAnswerIceRenomination) { |
2550 MediaSessionOptions options; | 2661 MediaSessionOptions options; |
2551 options.enable_ice_renomination = true; | 2662 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, !kStopped, |
2663 &options); | |
2664 auto media_desc_options_it = | |
2665 FindFirstMediaDescriptionByMid("audio", &options); | |
2666 media_desc_options_it->transport_options.enable_ice_renomination = true; | |
2552 TestTransportInfo(false, options, false); | 2667 TestTransportInfo(false, options, false); |
2553 } | 2668 } |
2554 | 2669 |
2555 TEST_F(MediaSessionDescriptionFactoryTest, | 2670 TEST_F(MediaSessionDescriptionFactoryTest, |
2556 TestTransportInfoAnswerAudioCurrent) { | 2671 TestTransportInfoAnswerAudioCurrent) { |
2557 MediaSessionOptions options; | 2672 MediaSessionOptions options; |
2558 options.recv_audio = true; | 2673 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, !kStopped, |
2674 &options); | |
2559 TestTransportInfo(false, options, true); | 2675 TestTransportInfo(false, options, true); |
2560 } | 2676 } |
2561 | 2677 |
2562 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerMultimedia) { | 2678 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerMultimedia) { |
2563 MediaSessionOptions options; | 2679 MediaSessionOptions options; |
2564 options.recv_audio = true; | 2680 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
2565 options.recv_video = true; | 2681 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
2566 options.data_channel_type = cricket::DCT_RTP; | |
2567 TestTransportInfo(false, options, false); | 2682 TestTransportInfo(false, options, false); |
2568 } | 2683 } |
2569 | 2684 |
2570 TEST_F(MediaSessionDescriptionFactoryTest, | 2685 TEST_F(MediaSessionDescriptionFactoryTest, |
2571 TestTransportInfoAnswerMultimediaCurrent) { | 2686 TestTransportInfoAnswerMultimediaCurrent) { |
2572 MediaSessionOptions options; | 2687 MediaSessionOptions options; |
2573 options.recv_audio = true; | 2688 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
2574 options.recv_video = true; | 2689 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
2575 options.data_channel_type = cricket::DCT_RTP; | |
2576 TestTransportInfo(false, options, true); | 2690 TestTransportInfo(false, options, true); |
2577 } | 2691 } |
2578 | 2692 |
2579 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerBundle) { | 2693 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerBundle) { |
2580 MediaSessionOptions options; | 2694 MediaSessionOptions options; |
2581 options.recv_audio = true; | 2695 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
2582 options.recv_video = true; | 2696 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
2583 options.data_channel_type = cricket::DCT_RTP; | |
2584 options.bundle_enabled = true; | 2697 options.bundle_enabled = true; |
2585 TestTransportInfo(false, options, false); | 2698 TestTransportInfo(false, options, false); |
2586 } | 2699 } |
2587 | 2700 |
2588 TEST_F(MediaSessionDescriptionFactoryTest, | 2701 TEST_F(MediaSessionDescriptionFactoryTest, |
2589 TestTransportInfoAnswerBundleCurrent) { | 2702 TestTransportInfoAnswerBundleCurrent) { |
2590 MediaSessionOptions options; | 2703 MediaSessionOptions options; |
2591 options.recv_audio = true; | 2704 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
2592 options.recv_video = true; | 2705 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
2593 options.data_channel_type = cricket::DCT_RTP; | |
2594 options.bundle_enabled = true; | 2706 options.bundle_enabled = true; |
2595 TestTransportInfo(false, options, true); | 2707 TestTransportInfo(false, options, true); |
2596 } | 2708 } |
2597 | 2709 |
2598 // Create an offer with bundle enabled and verify the crypto parameters are | 2710 // Create an offer with bundle enabled and verify the crypto parameters are |
2599 // the common set of the available cryptos. | 2711 // the common set of the available cryptos. |
2600 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoWithOfferBundle) { | 2712 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoWithOfferBundle) { |
2601 TestCryptoWithBundle(true); | 2713 TestCryptoWithBundle(true); |
2602 } | 2714 } |
2603 | 2715 |
2604 // Create an answer with bundle enabled and verify the crypto parameters are | 2716 // Create an answer with bundle enabled and verify the crypto parameters are |
2605 // the common set of the available cryptos. | 2717 // the common set of the available cryptos. |
2606 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoWithAnswerBundle) { | 2718 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoWithAnswerBundle) { |
2607 TestCryptoWithBundle(false); | 2719 TestCryptoWithBundle(false); |
2608 } | 2720 } |
2609 | 2721 |
2610 // Verifies that creating answer fails if the offer has UDP/TLS/RTP/SAVPF but | 2722 // Verifies that creating answer fails if the offer has UDP/TLS/RTP/SAVPF but |
2611 // DTLS is not enabled locally. | 2723 // DTLS is not enabled locally. |
2612 TEST_F(MediaSessionDescriptionFactoryTest, | 2724 TEST_F(MediaSessionDescriptionFactoryTest, |
2613 TestOfferDtlsSavpfWithoutDtlsFailed) { | 2725 TestOfferDtlsSavpfWithoutDtlsFailed) { |
2614 f1_.set_secure(SEC_ENABLED); | 2726 f1_.set_secure(SEC_ENABLED); |
2615 f2_.set_secure(SEC_ENABLED); | 2727 f2_.set_secure(SEC_ENABLED); |
2616 tdf1_.set_secure(SEC_DISABLED); | 2728 tdf1_.set_secure(SEC_DISABLED); |
2617 tdf2_.set_secure(SEC_DISABLED); | 2729 tdf2_.set_secure(SEC_DISABLED); |
2618 | 2730 |
2619 std::unique_ptr<SessionDescription> offer( | 2731 std::unique_ptr<SessionDescription> offer( |
2620 f1_.CreateOffer(MediaSessionOptions(), NULL)); | 2732 f1_.CreateOffer(CreatePlanBMediaSessionOptions(), NULL)); |
2621 ASSERT_TRUE(offer.get() != NULL); | 2733 ASSERT_TRUE(offer.get() != NULL); |
2622 ContentInfo* offer_content = offer->GetContentByName("audio"); | 2734 ContentInfo* offer_content = offer->GetContentByName("audio"); |
2623 ASSERT_TRUE(offer_content != NULL); | 2735 ASSERT_TRUE(offer_content != NULL); |
2624 AudioContentDescription* offer_audio_desc = | 2736 AudioContentDescription* offer_audio_desc = |
2625 static_cast<AudioContentDescription*>(offer_content->description); | 2737 static_cast<AudioContentDescription*>(offer_content->description); |
2626 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf); | 2738 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf); |
2627 | 2739 |
2628 std::unique_ptr<SessionDescription> answer( | 2740 std::unique_ptr<SessionDescription> answer( |
2629 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 2741 f2_.CreateAnswer(offer.get(), CreatePlanBMediaSessionOptions(), NULL)); |
2630 ASSERT_TRUE(answer != NULL); | 2742 ASSERT_TRUE(answer != NULL); |
2631 ContentInfo* answer_content = answer->GetContentByName("audio"); | 2743 ContentInfo* answer_content = answer->GetContentByName("audio"); |
2632 ASSERT_TRUE(answer_content != NULL); | 2744 ASSERT_TRUE(answer_content != NULL); |
2633 | 2745 |
2634 ASSERT_TRUE(answer_content->rejected); | 2746 ASSERT_TRUE(answer_content->rejected); |
2635 } | 2747 } |
2636 | 2748 |
2637 // Offers UDP/TLS/RTP/SAVPF and verifies the answer can be created and contains | 2749 // Offers UDP/TLS/RTP/SAVPF and verifies the answer can be created and contains |
2638 // UDP/TLS/RTP/SAVPF. | 2750 // UDP/TLS/RTP/SAVPF. |
2639 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) { | 2751 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) { |
2640 f1_.set_secure(SEC_ENABLED); | 2752 f1_.set_secure(SEC_ENABLED); |
2641 f2_.set_secure(SEC_ENABLED); | 2753 f2_.set_secure(SEC_ENABLED); |
2642 tdf1_.set_secure(SEC_ENABLED); | 2754 tdf1_.set_secure(SEC_ENABLED); |
2643 tdf2_.set_secure(SEC_ENABLED); | 2755 tdf2_.set_secure(SEC_ENABLED); |
2644 | 2756 |
2645 std::unique_ptr<SessionDescription> offer( | 2757 std::unique_ptr<SessionDescription> offer( |
2646 f1_.CreateOffer(MediaSessionOptions(), NULL)); | 2758 f1_.CreateOffer(CreatePlanBMediaSessionOptions(), NULL)); |
2647 ASSERT_TRUE(offer.get() != NULL); | 2759 ASSERT_TRUE(offer.get() != NULL); |
2648 ContentInfo* offer_content = offer->GetContentByName("audio"); | 2760 ContentInfo* offer_content = offer->GetContentByName("audio"); |
2649 ASSERT_TRUE(offer_content != NULL); | 2761 ASSERT_TRUE(offer_content != NULL); |
2650 AudioContentDescription* offer_audio_desc = | 2762 AudioContentDescription* offer_audio_desc = |
2651 static_cast<AudioContentDescription*>(offer_content->description); | 2763 static_cast<AudioContentDescription*>(offer_content->description); |
2652 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf); | 2764 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf); |
2653 | 2765 |
2654 std::unique_ptr<SessionDescription> answer( | 2766 std::unique_ptr<SessionDescription> answer( |
2655 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 2767 f2_.CreateAnswer(offer.get(), CreatePlanBMediaSessionOptions(), NULL)); |
2656 ASSERT_TRUE(answer != NULL); | 2768 ASSERT_TRUE(answer != NULL); |
2657 | 2769 |
2658 const ContentInfo* answer_content = answer->GetContentByName("audio"); | 2770 const ContentInfo* answer_content = answer->GetContentByName("audio"); |
2659 ASSERT_TRUE(answer_content != NULL); | 2771 ASSERT_TRUE(answer_content != NULL); |
2660 ASSERT_FALSE(answer_content->rejected); | 2772 ASSERT_FALSE(answer_content->rejected); |
2661 | 2773 |
2662 const AudioContentDescription* answer_audio_desc = | 2774 const AudioContentDescription* answer_audio_desc = |
2663 static_cast<const AudioContentDescription*>(answer_content->description); | 2775 static_cast<const AudioContentDescription*>(answer_content->description); |
2664 EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf), | 2776 EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf), |
2665 answer_audio_desc->protocol()); | 2777 answer_audio_desc->protocol()); |
2666 } | 2778 } |
2667 | 2779 |
2668 // Test that we include both SDES and DTLS in the offer, but only include SDES | 2780 // Test that we include both SDES and DTLS in the offer, but only include SDES |
2669 // in the answer if DTLS isn't negotiated. | 2781 // in the answer if DTLS isn't negotiated. |
2670 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoDtls) { | 2782 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoDtls) { |
2671 f1_.set_secure(SEC_ENABLED); | 2783 f1_.set_secure(SEC_ENABLED); |
2672 f2_.set_secure(SEC_ENABLED); | 2784 f2_.set_secure(SEC_ENABLED); |
2673 tdf1_.set_secure(SEC_ENABLED); | 2785 tdf1_.set_secure(SEC_ENABLED); |
2674 tdf2_.set_secure(SEC_DISABLED); | 2786 tdf2_.set_secure(SEC_DISABLED); |
2675 MediaSessionOptions options; | 2787 MediaSessionOptions options; |
2676 options.recv_audio = true; | 2788 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
2677 options.recv_video = true; | |
2678 std::unique_ptr<SessionDescription> offer, answer; | 2789 std::unique_ptr<SessionDescription> offer, answer; |
2679 const cricket::MediaContentDescription* audio_media_desc; | 2790 const cricket::MediaContentDescription* audio_media_desc; |
2680 const cricket::MediaContentDescription* video_media_desc; | 2791 const cricket::MediaContentDescription* video_media_desc; |
2681 const cricket::TransportDescription* audio_trans_desc; | 2792 const cricket::TransportDescription* audio_trans_desc; |
2682 const cricket::TransportDescription* video_trans_desc; | 2793 const cricket::TransportDescription* video_trans_desc; |
2683 | 2794 |
2684 // Generate an offer with SDES and DTLS support. | 2795 // Generate an offer with SDES and DTLS support. |
2685 offer.reset(f1_.CreateOffer(options, NULL)); | 2796 offer.reset(f1_.CreateOffer(options, NULL)); |
2686 ASSERT_TRUE(offer.get() != NULL); | 2797 ASSERT_TRUE(offer.get() != NULL); |
2687 | 2798 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2763 ASSERT_TRUE(audio_trans_desc != NULL); | 2874 ASSERT_TRUE(audio_trans_desc != NULL); |
2764 video_trans_desc = offer->GetTransportDescriptionByName("video"); | 2875 video_trans_desc = offer->GetTransportDescriptionByName("video"); |
2765 ASSERT_TRUE(video_trans_desc != NULL); | 2876 ASSERT_TRUE(video_trans_desc != NULL); |
2766 ASSERT_TRUE(audio_trans_desc->identity_fingerprint.get() != NULL); | 2877 ASSERT_TRUE(audio_trans_desc->identity_fingerprint.get() != NULL); |
2767 ASSERT_TRUE(video_trans_desc->identity_fingerprint.get() != NULL); | 2878 ASSERT_TRUE(video_trans_desc->identity_fingerprint.get() != NULL); |
2768 } | 2879 } |
2769 | 2880 |
2770 // Test that an answer can't be created if cryptos are required but the offer is | 2881 // Test that an answer can't be created if cryptos are required but the offer is |
2771 // unsecure. | 2882 // unsecure. |
2772 TEST_F(MediaSessionDescriptionFactoryTest, TestSecureAnswerToUnsecureOffer) { | 2883 TEST_F(MediaSessionDescriptionFactoryTest, TestSecureAnswerToUnsecureOffer) { |
2773 MediaSessionOptions options; | 2884 MediaSessionOptions options = CreatePlanBMediaSessionOptions(); |
2774 f1_.set_secure(SEC_DISABLED); | 2885 f1_.set_secure(SEC_DISABLED); |
2775 tdf1_.set_secure(SEC_DISABLED); | 2886 tdf1_.set_secure(SEC_DISABLED); |
2776 f2_.set_secure(SEC_REQUIRED); | 2887 f2_.set_secure(SEC_REQUIRED); |
2777 tdf1_.set_secure(SEC_ENABLED); | 2888 tdf1_.set_secure(SEC_ENABLED); |
2778 | 2889 |
2779 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL)); | 2890 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL)); |
2780 ASSERT_TRUE(offer.get() != NULL); | 2891 ASSERT_TRUE(offer.get() != NULL); |
2781 std::unique_ptr<SessionDescription> answer( | 2892 std::unique_ptr<SessionDescription> answer( |
2782 f2_.CreateAnswer(offer.get(), options, NULL)); | 2893 f2_.CreateAnswer(offer.get(), options, NULL)); |
2783 EXPECT_TRUE(answer.get() == NULL); | 2894 EXPECT_TRUE(answer.get() == NULL); |
2784 } | 2895 } |
2785 | 2896 |
2786 // Test that we accept a DTLS offer without SDES and create an appropriate | 2897 // Test that we accept a DTLS offer without SDES and create an appropriate |
2787 // answer. | 2898 // answer. |
2788 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoOfferDtlsButNotSdes) { | 2899 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoOfferDtlsButNotSdes) { |
2789 f1_.set_secure(SEC_DISABLED); | 2900 f1_.set_secure(SEC_DISABLED); |
2790 f2_.set_secure(SEC_ENABLED); | 2901 f2_.set_secure(SEC_ENABLED); |
2791 tdf1_.set_secure(SEC_ENABLED); | 2902 tdf1_.set_secure(SEC_ENABLED); |
2792 tdf2_.set_secure(SEC_ENABLED); | 2903 tdf2_.set_secure(SEC_ENABLED); |
2793 MediaSessionOptions options; | 2904 MediaSessionOptions options; |
2794 options.recv_audio = true; | 2905 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
2795 options.recv_video = true; | 2906 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
2796 options.data_channel_type = cricket::DCT_RTP; | |
2797 | 2907 |
2798 std::unique_ptr<SessionDescription> offer, answer; | 2908 std::unique_ptr<SessionDescription> offer, answer; |
2799 | 2909 |
2800 // Generate an offer with DTLS but without SDES. | 2910 // Generate an offer with DTLS but without SDES. |
2801 offer.reset(f1_.CreateOffer(options, NULL)); | 2911 offer.reset(f1_.CreateOffer(options, NULL)); |
2802 ASSERT_TRUE(offer.get() != NULL); | 2912 ASSERT_TRUE(offer.get() != NULL); |
2803 | 2913 |
2804 const AudioContentDescription* audio_offer = | 2914 const AudioContentDescription* audio_offer = |
2805 GetFirstAudioContentDescription(offer.get()); | 2915 GetFirstAudioContentDescription(offer.get()); |
2806 ASSERT_TRUE(audio_offer->cryptos().empty()); | 2916 ASSERT_TRUE(audio_offer->cryptos().empty()); |
(...skipping 26 matching lines...) Expand all Loading... | |
2833 EXPECT_TRUE(video_answer_trans_desc->identity_fingerprint.get() != NULL); | 2943 EXPECT_TRUE(video_answer_trans_desc->identity_fingerprint.get() != NULL); |
2834 const cricket::TransportDescription* data_answer_trans_desc = | 2944 const cricket::TransportDescription* data_answer_trans_desc = |
2835 answer->GetTransportDescriptionByName("data"); | 2945 answer->GetTransportDescriptionByName("data"); |
2836 EXPECT_TRUE(data_answer_trans_desc->identity_fingerprint.get() != NULL); | 2946 EXPECT_TRUE(data_answer_trans_desc->identity_fingerprint.get() != NULL); |
2837 } | 2947 } |
2838 | 2948 |
2839 // Verifies if vad_enabled option is set to false, CN codecs are not present in | 2949 // Verifies if vad_enabled option is set to false, CN codecs are not present in |
2840 // offer or answer. | 2950 // offer or answer. |
2841 TEST_F(MediaSessionDescriptionFactoryTest, TestVADEnableOption) { | 2951 TEST_F(MediaSessionDescriptionFactoryTest, TestVADEnableOption) { |
2842 MediaSessionOptions options; | 2952 MediaSessionOptions options; |
2843 options.recv_audio = true; | 2953 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
2844 options.recv_video = true; | |
2845 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL)); | 2954 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL)); |
2846 ASSERT_TRUE(offer.get() != NULL); | 2955 ASSERT_TRUE(offer.get() != NULL); |
2847 const ContentInfo* audio_content = offer->GetContentByName("audio"); | 2956 const ContentInfo* audio_content = offer->GetContentByName("audio"); |
2848 EXPECT_FALSE(VerifyNoCNCodecs(audio_content)); | 2957 EXPECT_FALSE(VerifyNoCNCodecs(audio_content)); |
2849 | 2958 |
2850 options.vad_enabled = false; | 2959 options.vad_enabled = false; |
2851 offer.reset(f1_.CreateOffer(options, NULL)); | 2960 offer.reset(f1_.CreateOffer(options, NULL)); |
2852 ASSERT_TRUE(offer.get() != NULL); | 2961 ASSERT_TRUE(offer.get() != NULL); |
2853 audio_content = offer->GetContentByName("audio"); | 2962 audio_content = offer->GetContentByName("audio"); |
2854 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); | 2963 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); |
2855 std::unique_ptr<SessionDescription> answer( | 2964 std::unique_ptr<SessionDescription> answer( |
2856 f1_.CreateAnswer(offer.get(), options, NULL)); | 2965 f1_.CreateAnswer(offer.get(), options, NULL)); |
2857 ASSERT_TRUE(answer.get() != NULL); | 2966 ASSERT_TRUE(answer.get() != NULL); |
2858 audio_content = answer->GetContentByName("audio"); | 2967 audio_content = answer->GetContentByName("audio"); |
2859 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); | 2968 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); |
2860 } | 2969 } |
2861 | 2970 |
2862 // Test that the content name ("mid" in SDP) is unchanged when creating a | 2971 // Test that the generated MIDs match the existing offer. |
2863 // new offer. | 2972 TEST_F(MediaSessionDescriptionFactoryTest, TestMIDsMatchesExistingOffer) { |
2864 TEST_F(MediaSessionDescriptionFactoryTest, | |
2865 TestContentNameNotChangedInSubsequentOffers) { | |
2866 MediaSessionOptions opts; | 2973 MediaSessionOptions opts; |
2867 opts.recv_audio = true; | 2974 AddMediaSection(MEDIA_TYPE_AUDIO, "audio_modified", cricket::MD_RECVONLY, |
2868 opts.recv_video = true; | 2975 !kStopped, &opts); |
2976 AddMediaSection(MEDIA_TYPE_VIDEO, "video_modified", cricket::MD_RECVONLY, | |
2977 !kStopped, &opts); | |
2869 opts.data_channel_type = cricket::DCT_SCTP; | 2978 opts.data_channel_type = cricket::DCT_SCTP; |
2870 // Create offer and modify the default content names. | 2979 AddMediaSection(MEDIA_TYPE_DATA, "data_modified", cricket::MD_SENDRECV, |
2980 !kStopped, &opts); | |
2981 // Create offer. | |
2871 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | 2982 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
2872 for (ContentInfo& content : offer->contents()) { | |
2873 content.name.append("_modified"); | |
2874 } | |
2875 | |
2876 std::unique_ptr<SessionDescription> updated_offer( | 2983 std::unique_ptr<SessionDescription> updated_offer( |
2877 f1_.CreateOffer(opts, offer.get())); | 2984 f1_.CreateOffer(opts, offer.get())); |
2985 | |
2878 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); | 2986 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); |
2879 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); | 2987 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); |
2880 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); | 2988 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); |
2881 ASSERT_TRUE(audio_content != nullptr); | 2989 ASSERT_TRUE(audio_content != nullptr); |
2882 ASSERT_TRUE(video_content != nullptr); | 2990 ASSERT_TRUE(video_content != nullptr); |
2883 ASSERT_TRUE(data_content != nullptr); | 2991 ASSERT_TRUE(data_content != nullptr); |
2884 EXPECT_EQ("audio_modified", audio_content->name); | 2992 EXPECT_EQ("audio_modified", audio_content->name); |
2885 EXPECT_EQ("video_modified", video_content->name); | 2993 EXPECT_EQ("video_modified", video_content->name); |
2886 EXPECT_EQ("data_modified", data_content->name); | 2994 EXPECT_EQ("data_modified", data_content->name); |
2887 } | 2995 } |
(...skipping 21 matching lines...) Expand all Loading... | |
2909 | 3017 |
2910 protected: | 3018 protected: |
2911 MediaSessionDescriptionFactory f1_; | 3019 MediaSessionDescriptionFactory f1_; |
2912 MediaSessionDescriptionFactory f2_; | 3020 MediaSessionDescriptionFactory f2_; |
2913 TransportDescriptionFactory tdf1_; | 3021 TransportDescriptionFactory tdf1_; |
2914 TransportDescriptionFactory tdf2_; | 3022 TransportDescriptionFactory tdf2_; |
2915 }; | 3023 }; |
2916 | 3024 |
2917 TEST_P(MediaProtocolTest, TestAudioVideoAcceptance) { | 3025 TEST_P(MediaProtocolTest, TestAudioVideoAcceptance) { |
2918 MediaSessionOptions opts; | 3026 MediaSessionOptions opts; |
2919 opts.recv_video = true; | 3027 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
2920 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | 3028 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
2921 ASSERT_TRUE(offer.get() != nullptr); | 3029 ASSERT_TRUE(offer.get() != nullptr); |
2922 // Set the protocol for all the contents. | 3030 // Set the protocol for all the contents. |
2923 for (auto content : offer.get()->contents()) { | 3031 for (auto content : offer.get()->contents()) { |
2924 static_cast<MediaContentDescription*>(content.description) | 3032 static_cast<MediaContentDescription*>(content.description) |
2925 ->set_protocol(GetParam()); | 3033 ->set_protocol(GetParam()); |
2926 } | 3034 } |
2927 std::unique_ptr<SessionDescription> answer( | 3035 std::unique_ptr<SessionDescription> answer( |
2928 f2_.CreateAnswer(offer.get(), opts, nullptr)); | 3036 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
2929 const ContentInfo* ac = answer->GetContentByName("audio"); | 3037 const ContentInfo* ac = answer->GetContentByName("audio"); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2969 // Alter iLBC send codec to have zero channels, to test that that is handled | 3077 // Alter iLBC send codec to have zero channels, to test that that is handled |
2970 // properly. | 3078 // properly. |
2971 send_codecs[1].channels = 0; | 3079 send_codecs[1].channels = 0; |
2972 | 3080 |
2973 // Alther iLBC receive codec to be lowercase, to test that case conversions | 3081 // Alther iLBC receive codec to be lowercase, to test that case conversions |
2974 // are handled properly. | 3082 // are handled properly. |
2975 recv_codecs[2].name = "ilbc"; | 3083 recv_codecs[2].name = "ilbc"; |
2976 | 3084 |
2977 // Test proper merge | 3085 // Test proper merge |
2978 sf.set_audio_codecs(send_codecs, recv_codecs); | 3086 sf.set_audio_codecs(send_codecs, recv_codecs); |
2979 EXPECT_TRUE(sf.audio_send_codecs() == send_codecs); | 3087 EXPECT_EQ(send_codecs, sf.audio_send_codecs()); |
2980 EXPECT_TRUE(sf.audio_recv_codecs() == recv_codecs); | 3088 EXPECT_EQ(recv_codecs, sf.audio_recv_codecs()); |
2981 EXPECT_TRUE(sf.audio_sendrecv_codecs() == sendrecv_codecs); | 3089 EXPECT_EQ(sendrecv_codecs, sf.audio_sendrecv_codecs()); |
2982 | 3090 |
2983 // Test empty send codecs list | 3091 // Test empty send codecs list |
2984 sf.set_audio_codecs(no_codecs, recv_codecs); | 3092 sf.set_audio_codecs(no_codecs, recv_codecs); |
2985 EXPECT_TRUE(sf.audio_send_codecs() == no_codecs); | 3093 EXPECT_EQ(no_codecs, sf.audio_send_codecs()); |
2986 EXPECT_TRUE(sf.audio_recv_codecs() == recv_codecs); | 3094 EXPECT_EQ(recv_codecs, sf.audio_recv_codecs()); |
2987 EXPECT_TRUE(sf.audio_sendrecv_codecs() == no_codecs); | 3095 EXPECT_EQ(no_codecs, sf.audio_sendrecv_codecs()); |
2988 | 3096 |
2989 // Test empty recv codecs list | 3097 // Test empty recv codecs list |
2990 sf.set_audio_codecs(send_codecs, no_codecs); | 3098 sf.set_audio_codecs(send_codecs, no_codecs); |
2991 EXPECT_TRUE(sf.audio_send_codecs() == send_codecs); | 3099 EXPECT_EQ(send_codecs, sf.audio_send_codecs()); |
2992 EXPECT_TRUE(sf.audio_recv_codecs() == no_codecs); | 3100 EXPECT_EQ(no_codecs, sf.audio_recv_codecs()); |
2993 EXPECT_TRUE(sf.audio_sendrecv_codecs() == no_codecs); | 3101 EXPECT_EQ(no_codecs, sf.audio_sendrecv_codecs()); |
2994 | 3102 |
2995 // Test all empty codec lists | 3103 // Test all empty codec lists |
2996 sf.set_audio_codecs(no_codecs, no_codecs); | 3104 sf.set_audio_codecs(no_codecs, no_codecs); |
2997 EXPECT_TRUE(sf.audio_send_codecs() == no_codecs); | 3105 EXPECT_EQ(no_codecs, sf.audio_send_codecs()); |
2998 EXPECT_TRUE(sf.audio_recv_codecs() == no_codecs); | 3106 EXPECT_EQ(no_codecs, sf.audio_recv_codecs()); |
2999 EXPECT_TRUE(sf.audio_sendrecv_codecs() == no_codecs); | 3107 EXPECT_EQ(no_codecs, sf.audio_sendrecv_codecs()); |
3000 } | 3108 } |
3001 | 3109 |
3002 namespace { | 3110 namespace { |
3003 void TestAudioCodecsOffer(MediaContentDirection direction, | 3111 void TestAudioCodecsOffer(MediaContentDirection direction) { |
3004 bool add_legacy_stream) { | |
3005 TransportDescriptionFactory tdf; | 3112 TransportDescriptionFactory tdf; |
3006 MediaSessionDescriptionFactory sf(&tdf); | 3113 MediaSessionDescriptionFactory sf(&tdf); |
3007 const std::vector<AudioCodec> send_codecs = MAKE_VECTOR(kAudioCodecs1); | 3114 const std::vector<AudioCodec> send_codecs = MAKE_VECTOR(kAudioCodecs1); |
3008 const std::vector<AudioCodec> recv_codecs = MAKE_VECTOR(kAudioCodecs2); | 3115 const std::vector<AudioCodec> recv_codecs = MAKE_VECTOR(kAudioCodecs2); |
3009 const std::vector<AudioCodec> sendrecv_codecs = | 3116 const std::vector<AudioCodec> sendrecv_codecs = |
3010 MAKE_VECTOR(kAudioCodecsAnswer); | 3117 MAKE_VECTOR(kAudioCodecsAnswer); |
3011 sf.set_audio_codecs(send_codecs, recv_codecs); | 3118 sf.set_audio_codecs(send_codecs, recv_codecs); |
3012 sf.set_add_legacy_streams(add_legacy_stream); | |
3013 | 3119 |
3014 MediaSessionOptions opts; | 3120 MediaSessionOptions opts; |
3015 opts.recv_audio = (direction == cricket::MD_RECVONLY || | 3121 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", direction, !kStopped, &opts); |
3016 direction == cricket::MD_SENDRECV); | 3122 |
3017 opts.recv_video = false; | 3123 if (RtpTransceiverDirection::FromMediaContentDirection(direction).send) { |
3018 if (direction == cricket::MD_SENDONLY || direction == cricket::MD_SENDRECV) | 3124 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1, |
3019 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 3125 kMediaStream1, 1, &opts); |
3126 } | |
3020 | 3127 |
3021 std::unique_ptr<SessionDescription> offer(sf.CreateOffer(opts, NULL)); | 3128 std::unique_ptr<SessionDescription> offer(sf.CreateOffer(opts, NULL)); |
3022 ASSERT_TRUE(offer.get() != NULL); | 3129 ASSERT_TRUE(offer.get() != NULL); |
3023 const ContentInfo* ac = offer->GetContentByName("audio"); | 3130 const ContentInfo* ac = offer->GetContentByName("audio"); |
3024 | 3131 |
3025 // If the factory didn't add any audio content to the offer, we cannot check | 3132 // If the factory didn't add any audio content to the offer, we cannot check |
3026 // that the codecs put in are right. This happens when we neither want to send | 3133 // that the codecs put in are right. This happens when we neither want to send |
3027 // nor receive audio. The checks are still in place if at some point we'd | 3134 // nor receive audio. The checks are still in place if at some point we'd |
3028 // instead create an inactive stream. | 3135 // instead create an inactive stream. |
3029 if (ac) { | 3136 if (ac) { |
3030 AudioContentDescription* acd = | 3137 AudioContentDescription* acd = |
3031 static_cast<AudioContentDescription*>(ac->description); | 3138 static_cast<AudioContentDescription*>(ac->description); |
3032 // sendrecv and inactive should both present lists as if the channel was to | 3139 // sendrecv and inactive should both present lists as if the channel was to |
3033 // be used for sending and receiving. Inactive essentially means it might | 3140 // be used for sending and receiving. Inactive essentially means it might |
3034 // eventually be used anything, but we don't know more at this moment. | 3141 // eventually be used anything, but we don't know more at this moment. |
3035 if (acd->direction() == cricket::MD_SENDONLY) { | 3142 if (acd->direction() == cricket::MD_SENDONLY) { |
3036 EXPECT_TRUE(acd->codecs() == send_codecs); | 3143 EXPECT_EQ(send_codecs, acd->codecs()); |
3037 } else if (acd->direction() == cricket::MD_RECVONLY) { | 3144 } else if (acd->direction() == cricket::MD_RECVONLY) { |
3038 EXPECT_TRUE(acd->codecs() == recv_codecs); | 3145 EXPECT_EQ(recv_codecs, acd->codecs()); |
3039 } else { | 3146 } else { |
3040 EXPECT_TRUE(acd->codecs() == sendrecv_codecs); | 3147 EXPECT_EQ(sendrecv_codecs, acd->codecs()); |
3041 } | 3148 } |
3042 } | 3149 } |
3043 } | 3150 } |
3044 | 3151 |
3045 static const AudioCodec kOfferAnswerCodecs[] = { | 3152 static const AudioCodec kOfferAnswerCodecs[] = { |
3046 AudioCodec(0, "codec0", 16000, -1, 1), | 3153 AudioCodec(0, "codec0", 16000, -1, 1), |
3047 AudioCodec(1, "codec1", 8000, 13300, 1), | 3154 AudioCodec(1, "codec1", 8000, 13300, 1), |
3048 AudioCodec(2, "codec2", 8000, 64000, 1), | 3155 AudioCodec(2, "codec2", 8000, 64000, 1), |
3049 AudioCodec(3, "codec3", 8000, 64000, 1), | 3156 AudioCodec(3, "codec3", 8000, 64000, 1), |
3050 AudioCodec(4, "codec4", 8000, 0, 2), | 3157 AudioCodec(4, "codec4", 8000, 0, 2), |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3102 TransportDescriptionFactory answer_tdf; | 3209 TransportDescriptionFactory answer_tdf; |
3103 MediaSessionDescriptionFactory offer_factory(&offer_tdf); | 3210 MediaSessionDescriptionFactory offer_factory(&offer_tdf); |
3104 MediaSessionDescriptionFactory answer_factory(&answer_tdf); | 3211 MediaSessionDescriptionFactory answer_factory(&answer_tdf); |
3105 offer_factory.set_audio_codecs( | 3212 offer_factory.set_audio_codecs( |
3106 VectorFromIndices(kOfferAnswerCodecs, kOfferSendCodecs), | 3213 VectorFromIndices(kOfferAnswerCodecs, kOfferSendCodecs), |
3107 VectorFromIndices(kOfferAnswerCodecs, kOfferRecvCodecs)); | 3214 VectorFromIndices(kOfferAnswerCodecs, kOfferRecvCodecs)); |
3108 answer_factory.set_audio_codecs( | 3215 answer_factory.set_audio_codecs( |
3109 VectorFromIndices(kOfferAnswerCodecs, kAnswerSendCodecs), | 3216 VectorFromIndices(kOfferAnswerCodecs, kAnswerSendCodecs), |
3110 VectorFromIndices(kOfferAnswerCodecs, kAnswerRecvCodecs)); | 3217 VectorFromIndices(kOfferAnswerCodecs, kAnswerRecvCodecs)); |
3111 | 3218 |
3112 // Never add a legacy stream to offer - we want to control the offer | |
3113 // parameters exactly. | |
3114 offer_factory.set_add_legacy_streams(false); | |
3115 answer_factory.set_add_legacy_streams(add_legacy_stream); | |
3116 MediaSessionOptions offer_opts; | 3219 MediaSessionOptions offer_opts; |
3117 offer_opts.recv_audio = (offer_direction == cricket::MD_RECVONLY || | 3220 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", offer_direction, !kStopped, |
3118 offer_direction == cricket::MD_SENDRECV); | 3221 &offer_opts); |
3119 offer_opts.recv_video = false; | 3222 |
3120 if (offer_direction == cricket::MD_SENDONLY || | 3223 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_INACTIVE, kStopped, |
3121 offer_direction == cricket::MD_SENDRECV) { | 3224 &offer_opts); |
3122 offer_opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 3225 |
3226 if (RtpTransceiverDirection::FromMediaContentDirection(offer_direction) | |
3227 .send) { | |
3228 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1, | |
3229 kMediaStream1, 1, &offer_opts); | |
3123 } | 3230 } |
3124 | 3231 |
3125 std::unique_ptr<SessionDescription> offer( | 3232 std::unique_ptr<SessionDescription> offer( |
3126 offer_factory.CreateOffer(offer_opts, NULL)); | 3233 offer_factory.CreateOffer(offer_opts, NULL)); |
3127 ASSERT_TRUE(offer.get() != NULL); | 3234 ASSERT_TRUE(offer.get() != NULL); |
3128 | 3235 |
3129 MediaSessionOptions answer_opts; | 3236 MediaSessionOptions answer_opts; |
3130 answer_opts.recv_audio = (answer_direction == cricket::MD_RECVONLY || | 3237 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", answer_direction, !kStopped, |
3131 answer_direction == cricket::MD_SENDRECV); | 3238 &answer_opts); |
3132 answer_opts.recv_video = false; | 3239 |
3133 if (answer_direction == cricket::MD_SENDONLY || | 3240 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_INACTIVE, kStopped, |
3134 answer_direction == cricket::MD_SENDRECV) { | 3241 &answer_opts); |
3135 answer_opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 3242 |
3243 if (RtpTransceiverDirection::FromMediaContentDirection(answer_direction) | |
3244 .send) { | |
3245 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1, | |
3246 kMediaStream1, 1, &answer_opts); | |
3136 } | 3247 } |
3137 std::unique_ptr<SessionDescription> answer( | 3248 std::unique_ptr<SessionDescription> answer( |
3138 answer_factory.CreateAnswer(offer.get(), answer_opts, NULL)); | 3249 answer_factory.CreateAnswer(offer.get(), answer_opts, NULL)); |
3139 const ContentInfo* ac = answer->GetContentByName("audio"); | 3250 const ContentInfo* ac = answer->GetContentByName("audio"); |
3140 | 3251 |
3141 // If the factory didn't add any audio content to the answer, we cannot check | 3252 // If the factory didn't add any audio content to the answer, we cannot check |
3142 // that the codecs put in are right. This happens when we neither want to send | 3253 // that the codecs put in are right. This happens when we neither want to send |
3143 // nor receive audio. The checks are still in place if at some point we'd | 3254 // nor receive audio. The checks are still in place if at some point we'd |
3144 // instead create an inactive stream. | 3255 // instead create an inactive stream. |
3145 if (ac) { | 3256 if (ac) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3199 << "; got: " << MediaContentDirectionToString(acd->direction()); | 3310 << "; got: " << MediaContentDirectionToString(acd->direction()); |
3200 } else { | 3311 } else { |
3201 EXPECT_EQ(offer_direction, cricket::MD_INACTIVE) | 3312 EXPECT_EQ(offer_direction, cricket::MD_INACTIVE) |
3202 << "Only inactive offers are allowed to not generate any audio content"; | 3313 << "Only inactive offers are allowed to not generate any audio content"; |
3203 } | 3314 } |
3204 } | 3315 } |
3205 | 3316 |
3206 } // namespace | 3317 } // namespace |
3207 | 3318 |
3208 class AudioCodecsOfferTest | 3319 class AudioCodecsOfferTest |
3209 : public ::testing::TestWithParam<::testing::tuple<MediaContentDirection, | 3320 : public ::testing::TestWithParam<MediaContentDirection> {}; |
3210 bool>> { | |
3211 }; | |
3212 | 3321 |
3213 TEST_P(AudioCodecsOfferTest, TestCodecsInOffer) { | 3322 TEST_P(AudioCodecsOfferTest, TestCodecsInOffer) { |
3214 TestAudioCodecsOffer(::testing::get<0>(GetParam()), | 3323 TestAudioCodecsOffer(GetParam()); |
3215 ::testing::get<1>(GetParam())); | |
3216 } | 3324 } |
3217 | 3325 |
3218 INSTANTIATE_TEST_CASE_P(MediaSessionDescriptionFactoryTest, | 3326 INSTANTIATE_TEST_CASE_P(MediaSessionDescriptionFactoryTest, |
3219 AudioCodecsOfferTest, | 3327 AudioCodecsOfferTest, |
3220 ::testing::Combine( | 3328 ::testing::Values(cricket::MD_SENDONLY, |
3221 ::testing::Values(cricket::MD_SENDONLY, | 3329 cricket::MD_RECVONLY, |
3222 cricket::MD_RECVONLY, | 3330 cricket::MD_SENDRECV, |
3223 cricket::MD_SENDRECV, | 3331 cricket::MD_INACTIVE)); |
3224 cricket::MD_INACTIVE), | |
3225 ::testing::Bool())); | |
3226 | 3332 |
3227 class AudioCodecsAnswerTest | 3333 class AudioCodecsAnswerTest |
3228 : public ::testing::TestWithParam<::testing::tuple<MediaContentDirection, | 3334 : public ::testing::TestWithParam<::testing::tuple<MediaContentDirection, |
3229 MediaContentDirection, | 3335 MediaContentDirection, |
3230 bool>> { | 3336 bool>> { |
3231 }; | 3337 }; |
3232 | 3338 |
3233 TEST_P(AudioCodecsAnswerTest, TestCodecsInAnswer) { | 3339 TEST_P(AudioCodecsAnswerTest, TestCodecsInAnswer) { |
3234 TestAudioCodecsAnswer(::testing::get<0>(GetParam()), | 3340 TestAudioCodecsAnswer(::testing::get<0>(GetParam()), |
3235 ::testing::get<1>(GetParam()), | 3341 ::testing::get<1>(GetParam()), |
3236 ::testing::get<2>(GetParam())); | 3342 ::testing::get<2>(GetParam())); |
3237 } | 3343 } |
3238 | 3344 |
3239 INSTANTIATE_TEST_CASE_P(MediaSessionDescriptionFactoryTest, | 3345 INSTANTIATE_TEST_CASE_P(MediaSessionDescriptionFactoryTest, |
3240 AudioCodecsAnswerTest, | 3346 AudioCodecsAnswerTest, |
3241 ::testing::Combine( | 3347 ::testing::Combine( |
3242 ::testing::Values(cricket::MD_SENDONLY, | 3348 ::testing::Values(cricket::MD_SENDONLY, |
3243 cricket::MD_RECVONLY, | 3349 cricket::MD_RECVONLY, |
3244 cricket::MD_SENDRECV, | 3350 cricket::MD_SENDRECV, |
3245 cricket::MD_INACTIVE), | 3351 cricket::MD_INACTIVE), |
3246 ::testing::Values(cricket::MD_SENDONLY, | 3352 ::testing::Values(cricket::MD_SENDONLY, |
3247 cricket::MD_RECVONLY, | 3353 cricket::MD_RECVONLY, |
3248 cricket::MD_SENDRECV, | 3354 cricket::MD_SENDRECV, |
3249 cricket::MD_INACTIVE), | 3355 cricket::MD_INACTIVE), |
3250 ::testing::Bool())); | 3356 ::testing::Bool())); |
OLD | NEW |