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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 current_video_pwd)))); | 293 current_video_pwd)))); |
294 EXPECT_TRUE(current_desc->AddTransportInfo( | 294 EXPECT_TRUE(current_desc->AddTransportInfo( |
295 TransportInfo("data", | 295 TransportInfo("data", |
296 TransportDescription(current_data_ufrag, | 296 TransportDescription(current_data_ufrag, |
297 current_data_pwd)))); | 297 current_data_pwd)))); |
298 } | 298 } |
299 if (offer) { | 299 if (offer) { |
300 desc.reset(f1_.CreateOffer(options, current_desc.get())); | 300 desc.reset(f1_.CreateOffer(options, current_desc.get())); |
301 } else { | 301 } else { |
302 std::unique_ptr<SessionDescription> offer; | 302 std::unique_ptr<SessionDescription> offer; |
303 offer.reset(f1_.CreateOffer(options, NULL)); | 303 offer.reset(f1_.CreateOffer(options, nullptr)); |
304 desc.reset(f1_.CreateAnswer(offer.get(), options, current_desc.get())); | 304 desc.reset(f1_.CreateAnswer(offer.get(), options, current_desc.get())); |
305 } | 305 } |
306 ASSERT_TRUE(desc.get() != NULL); | 306 ASSERT_TRUE(desc.get() != nullptr); |
307 const TransportInfo* ti_audio = desc->GetTransportInfoByName("audio"); | 307 const TransportInfo* ti_audio = desc->GetTransportInfoByName("audio"); |
308 if (options.has_audio()) { | 308 if (options.has_audio()) { |
309 EXPECT_TRUE(ti_audio != NULL); | 309 EXPECT_TRUE(ti_audio != nullptr); |
310 if (has_current_desc) { | 310 if (has_current_desc) { |
311 EXPECT_EQ(current_audio_ufrag, ti_audio->description.ice_ufrag); | 311 EXPECT_EQ(current_audio_ufrag, ti_audio->description.ice_ufrag); |
312 EXPECT_EQ(current_audio_pwd, ti_audio->description.ice_pwd); | 312 EXPECT_EQ(current_audio_pwd, ti_audio->description.ice_pwd); |
313 } else { | 313 } else { |
314 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), | 314 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), |
315 ti_audio->description.ice_ufrag.size()); | 315 ti_audio->description.ice_ufrag.size()); |
316 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), | 316 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), |
317 ti_audio->description.ice_pwd.size()); | 317 ti_audio->description.ice_pwd.size()); |
318 } | 318 } |
319 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_audio)); | 319 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_audio)); |
320 | 320 |
321 } else { | 321 } else { |
322 EXPECT_TRUE(ti_audio == NULL); | 322 EXPECT_TRUE(ti_audio == nullptr); |
323 } | 323 } |
324 const TransportInfo* ti_video = desc->GetTransportInfoByName("video"); | 324 const TransportInfo* ti_video = desc->GetTransportInfoByName("video"); |
325 if (options.has_video()) { | 325 if (options.has_video()) { |
326 EXPECT_TRUE(ti_video != NULL); | 326 EXPECT_TRUE(ti_video != nullptr); |
327 if (options.bundle_enabled) { | 327 if (options.bundle_enabled) { |
328 EXPECT_EQ(ti_audio->description.ice_ufrag, | 328 EXPECT_EQ(ti_audio->description.ice_ufrag, |
329 ti_video->description.ice_ufrag); | 329 ti_video->description.ice_ufrag); |
330 EXPECT_EQ(ti_audio->description.ice_pwd, | 330 EXPECT_EQ(ti_audio->description.ice_pwd, |
331 ti_video->description.ice_pwd); | 331 ti_video->description.ice_pwd); |
332 } else { | 332 } else { |
333 if (has_current_desc) { | 333 if (has_current_desc) { |
334 EXPECT_EQ(current_video_ufrag, ti_video->description.ice_ufrag); | 334 EXPECT_EQ(current_video_ufrag, ti_video->description.ice_ufrag); |
335 EXPECT_EQ(current_video_pwd, ti_video->description.ice_pwd); | 335 EXPECT_EQ(current_video_pwd, ti_video->description.ice_pwd); |
336 } else { | 336 } else { |
337 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), | 337 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), |
338 ti_video->description.ice_ufrag.size()); | 338 ti_video->description.ice_ufrag.size()); |
339 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), | 339 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), |
340 ti_video->description.ice_pwd.size()); | 340 ti_video->description.ice_pwd.size()); |
341 } | 341 } |
342 } | 342 } |
343 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_video)); | 343 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_video)); |
344 } else { | 344 } else { |
345 EXPECT_TRUE(ti_video == NULL); | 345 EXPECT_TRUE(ti_video == nullptr); |
346 } | 346 } |
347 const TransportInfo* ti_data = desc->GetTransportInfoByName("data"); | 347 const TransportInfo* ti_data = desc->GetTransportInfoByName("data"); |
348 if (options.has_data()) { | 348 if (options.has_data()) { |
349 EXPECT_TRUE(ti_data != NULL); | 349 EXPECT_TRUE(ti_data != nullptr); |
350 if (options.bundle_enabled) { | 350 if (options.bundle_enabled) { |
351 EXPECT_EQ(ti_audio->description.ice_ufrag, | 351 EXPECT_EQ(ti_audio->description.ice_ufrag, |
352 ti_data->description.ice_ufrag); | 352 ti_data->description.ice_ufrag); |
353 EXPECT_EQ(ti_audio->description.ice_pwd, | 353 EXPECT_EQ(ti_audio->description.ice_pwd, |
354 ti_data->description.ice_pwd); | 354 ti_data->description.ice_pwd); |
355 } else { | 355 } else { |
356 if (has_current_desc) { | 356 if (has_current_desc) { |
357 EXPECT_EQ(current_data_ufrag, ti_data->description.ice_ufrag); | 357 EXPECT_EQ(current_data_ufrag, ti_data->description.ice_ufrag); |
358 EXPECT_EQ(current_data_pwd, ti_data->description.ice_pwd); | 358 EXPECT_EQ(current_data_pwd, ti_data->description.ice_pwd); |
359 } else { | 359 } else { |
360 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), | 360 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), |
361 ti_data->description.ice_ufrag.size()); | 361 ti_data->description.ice_ufrag.size()); |
362 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), | 362 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), |
363 ti_data->description.ice_pwd.size()); | 363 ti_data->description.ice_pwd.size()); |
364 } | 364 } |
365 } | 365 } |
366 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_data)); | 366 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_data)); |
367 | 367 |
368 } else { | 368 } else { |
369 EXPECT_TRUE(ti_video == NULL); | 369 EXPECT_TRUE(ti_video == nullptr); |
370 } | 370 } |
371 } | 371 } |
372 | 372 |
373 void TestCryptoWithBundle(bool offer) { | 373 void TestCryptoWithBundle(bool offer) { |
374 f1_.set_secure(SEC_ENABLED); | 374 f1_.set_secure(SEC_ENABLED); |
375 MediaSessionOptions options; | 375 MediaSessionOptions options; |
376 options.recv_audio = true; | 376 options.recv_audio = true; |
377 options.recv_video = true; | 377 options.recv_video = true; |
378 options.data_channel_type = cricket::DCT_RTP; | 378 options.data_channel_type = cricket::DCT_RTP; |
379 std::unique_ptr<SessionDescription> ref_desc; | 379 std::unique_ptr<SessionDescription> ref_desc; |
380 std::unique_ptr<SessionDescription> desc; | 380 std::unique_ptr<SessionDescription> desc; |
381 if (offer) { | 381 if (offer) { |
382 options.bundle_enabled = false; | 382 options.bundle_enabled = false; |
383 ref_desc.reset(f1_.CreateOffer(options, NULL)); | 383 ref_desc.reset(f1_.CreateOffer(options, nullptr)); |
384 options.bundle_enabled = true; | 384 options.bundle_enabled = true; |
385 desc.reset(f1_.CreateOffer(options, ref_desc.get())); | 385 desc.reset(f1_.CreateOffer(options, ref_desc.get())); |
386 } else { | 386 } else { |
387 options.bundle_enabled = true; | 387 options.bundle_enabled = true; |
388 ref_desc.reset(f1_.CreateOffer(options, NULL)); | 388 ref_desc.reset(f1_.CreateOffer(options, nullptr)); |
389 desc.reset(f1_.CreateAnswer(ref_desc.get(), options, NULL)); | 389 desc.reset(f1_.CreateAnswer(ref_desc.get(), options, nullptr)); |
390 } | 390 } |
391 ASSERT_TRUE(desc.get() != NULL); | 391 ASSERT_TRUE(desc.get() != nullptr); |
392 const cricket::MediaContentDescription* audio_media_desc = | 392 const cricket::MediaContentDescription* audio_media_desc = |
393 static_cast<const cricket::MediaContentDescription*>( | 393 static_cast<const cricket::MediaContentDescription*>( |
394 desc.get()->GetContentDescriptionByName("audio")); | 394 desc.get()->GetContentDescriptionByName("audio")); |
395 ASSERT_TRUE(audio_media_desc != NULL); | 395 ASSERT_TRUE(audio_media_desc != nullptr); |
396 const cricket::MediaContentDescription* video_media_desc = | 396 const cricket::MediaContentDescription* video_media_desc = |
397 static_cast<const cricket::MediaContentDescription*>( | 397 static_cast<const cricket::MediaContentDescription*>( |
398 desc.get()->GetContentDescriptionByName("video")); | 398 desc.get()->GetContentDescriptionByName("video")); |
399 ASSERT_TRUE(video_media_desc != NULL); | 399 ASSERT_TRUE(video_media_desc != nullptr); |
400 EXPECT_TRUE(CompareCryptoParams(audio_media_desc->cryptos(), | 400 EXPECT_TRUE(CompareCryptoParams(audio_media_desc->cryptos(), |
401 video_media_desc->cryptos())); | 401 video_media_desc->cryptos())); |
402 EXPECT_EQ(1u, audio_media_desc->cryptos().size()); | 402 EXPECT_EQ(1u, audio_media_desc->cryptos().size()); |
403 EXPECT_EQ(std::string(CS_AES_CM_128_HMAC_SHA1_80), | 403 EXPECT_EQ(std::string(CS_AES_CM_128_HMAC_SHA1_80), |
404 audio_media_desc->cryptos()[0].cipher_suite); | 404 audio_media_desc->cryptos()[0].cipher_suite); |
405 | 405 |
406 // Verify the selected crypto is one from the reference audio | 406 // Verify the selected crypto is one from the reference audio |
407 // media content. | 407 // media content. |
408 const cricket::MediaContentDescription* ref_audio_media_desc = | 408 const cricket::MediaContentDescription* ref_audio_media_desc = |
409 static_cast<const cricket::MediaContentDescription*>( | 409 static_cast<const cricket::MediaContentDescription*>( |
(...skipping 10 matching lines...) Expand all Loading... |
420 } | 420 } |
421 | 421 |
422 // This test that the audio and video media direction is set to | 422 // This test that the audio and video media direction is set to |
423 // |expected_direction_in_answer| in an answer if the offer direction is set | 423 // |expected_direction_in_answer| in an answer if the offer direction is set |
424 // to |direction_in_offer|. | 424 // to |direction_in_offer|. |
425 void TestMediaDirectionInAnswer( | 425 void TestMediaDirectionInAnswer( |
426 cricket::MediaContentDirection direction_in_offer, | 426 cricket::MediaContentDirection direction_in_offer, |
427 cricket::MediaContentDirection expected_direction_in_answer) { | 427 cricket::MediaContentDirection expected_direction_in_answer) { |
428 MediaSessionOptions opts; | 428 MediaSessionOptions opts; |
429 opts.recv_video = true; | 429 opts.recv_video = true; |
430 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 430 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
431 ASSERT_TRUE(offer.get() != NULL); | 431 ASSERT_TRUE(offer.get() != nullptr); |
432 ContentInfo* ac_offer = offer->GetContentByName("audio"); | 432 ContentInfo* ac_offer = offer->GetContentByName("audio"); |
433 ASSERT_TRUE(ac_offer != NULL); | 433 ASSERT_TRUE(ac_offer != nullptr); |
434 AudioContentDescription* acd_offer = | 434 AudioContentDescription* acd_offer = |
435 static_cast<AudioContentDescription*>(ac_offer->description); | 435 static_cast<AudioContentDescription*>(ac_offer->description); |
436 acd_offer->set_direction(direction_in_offer); | 436 acd_offer->set_direction(direction_in_offer); |
437 ContentInfo* vc_offer = offer->GetContentByName("video"); | 437 ContentInfo* vc_offer = offer->GetContentByName("video"); |
438 ASSERT_TRUE(vc_offer != NULL); | 438 ASSERT_TRUE(vc_offer != nullptr); |
439 VideoContentDescription* vcd_offer = | 439 VideoContentDescription* vcd_offer = |
440 static_cast<VideoContentDescription*>(vc_offer->description); | 440 static_cast<VideoContentDescription*>(vc_offer->description); |
441 vcd_offer->set_direction(direction_in_offer); | 441 vcd_offer->set_direction(direction_in_offer); |
442 | 442 |
443 std::unique_ptr<SessionDescription> answer( | 443 std::unique_ptr<SessionDescription> answer( |
444 f2_.CreateAnswer(offer.get(), opts, NULL)); | 444 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
445 const AudioContentDescription* acd_answer = | 445 const AudioContentDescription* acd_answer = |
446 GetFirstAudioContentDescription(answer.get()); | 446 GetFirstAudioContentDescription(answer.get()); |
447 EXPECT_EQ(expected_direction_in_answer, acd_answer->direction()); | 447 EXPECT_EQ(expected_direction_in_answer, acd_answer->direction()); |
448 const VideoContentDescription* vcd_answer = | 448 const VideoContentDescription* vcd_answer = |
449 GetFirstVideoContentDescription(answer.get()); | 449 GetFirstVideoContentDescription(answer.get()); |
450 EXPECT_EQ(expected_direction_in_answer, vcd_answer->direction()); | 450 EXPECT_EQ(expected_direction_in_answer, vcd_answer->direction()); |
451 } | 451 } |
452 | 452 |
453 bool VerifyNoCNCodecs(const cricket::ContentInfo* content) { | 453 bool VerifyNoCNCodecs(const cricket::ContentInfo* content) { |
454 const cricket::ContentDescription* description = content->description; | 454 const cricket::ContentDescription* description = content->description; |
455 RTC_CHECK(description != NULL); | 455 RTC_CHECK(description != nullptr); |
456 const cricket::AudioContentDescription* audio_content_desc = | 456 const cricket::AudioContentDescription* audio_content_desc = |
457 static_cast<const cricket::AudioContentDescription*>(description); | 457 static_cast<const cricket::AudioContentDescription*>(description); |
458 RTC_CHECK(audio_content_desc != NULL); | 458 RTC_CHECK(audio_content_desc != nullptr); |
459 for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) { | 459 for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) { |
460 if (audio_content_desc->codecs()[i].name == "CN") | 460 if (audio_content_desc->codecs()[i].name == "CN") |
461 return false; | 461 return false; |
462 } | 462 } |
463 return true; | 463 return true; |
464 } | 464 } |
465 | 465 |
466 void TestVideoGcmCipher(bool gcm_offer, bool gcm_answer) { | 466 void TestVideoGcmCipher(bool gcm_offer, bool gcm_answer) { |
467 MediaSessionOptions offer_opts; | 467 MediaSessionOptions offer_opts; |
468 offer_opts.recv_video = true; | 468 offer_opts.recv_video = true; |
469 offer_opts.crypto_options.enable_gcm_crypto_suites = gcm_offer; | 469 offer_opts.crypto_options.enable_gcm_crypto_suites = gcm_offer; |
470 MediaSessionOptions answer_opts; | 470 MediaSessionOptions answer_opts; |
471 answer_opts.recv_video = true; | 471 answer_opts.recv_video = true; |
472 answer_opts.crypto_options.enable_gcm_crypto_suites = gcm_answer; | 472 answer_opts.crypto_options.enable_gcm_crypto_suites = gcm_answer; |
473 f1_.set_secure(SEC_ENABLED); | 473 f1_.set_secure(SEC_ENABLED); |
474 f2_.set_secure(SEC_ENABLED); | 474 f2_.set_secure(SEC_ENABLED); |
475 std::unique_ptr<SessionDescription> offer( | 475 std::unique_ptr<SessionDescription> offer( |
476 f1_.CreateOffer(offer_opts, NULL)); | 476 f1_.CreateOffer(offer_opts, nullptr)); |
477 ASSERT_TRUE(offer.get() != NULL); | 477 ASSERT_TRUE(offer.get() != nullptr); |
478 std::unique_ptr<SessionDescription> answer( | 478 std::unique_ptr<SessionDescription> answer( |
479 f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 479 f2_.CreateAnswer(offer.get(), answer_opts, nullptr)); |
480 const ContentInfo* ac = answer->GetContentByName("audio"); | 480 const ContentInfo* ac = answer->GetContentByName("audio"); |
481 const ContentInfo* vc = answer->GetContentByName("video"); | 481 const ContentInfo* vc = answer->GetContentByName("video"); |
482 ASSERT_TRUE(ac != NULL); | 482 ASSERT_TRUE(ac != nullptr); |
483 ASSERT_TRUE(vc != NULL); | 483 ASSERT_TRUE(vc != nullptr); |
484 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 484 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
485 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 485 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); |
486 const AudioContentDescription* acd = | 486 const AudioContentDescription* acd = |
487 static_cast<const AudioContentDescription*>(ac->description); | 487 static_cast<const AudioContentDescription*>(ac->description); |
488 const VideoContentDescription* vcd = | 488 const VideoContentDescription* vcd = |
489 static_cast<const VideoContentDescription*>(vc->description); | 489 static_cast<const VideoContentDescription*>(vc->description); |
490 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 490 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
491 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 491 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
492 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 492 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
493 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 493 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc |
(...skipping 19 matching lines...) Expand all Loading... |
513 MediaSessionDescriptionFactory f1_; | 513 MediaSessionDescriptionFactory f1_; |
514 MediaSessionDescriptionFactory f2_; | 514 MediaSessionDescriptionFactory f2_; |
515 TransportDescriptionFactory tdf1_; | 515 TransportDescriptionFactory tdf1_; |
516 TransportDescriptionFactory tdf2_; | 516 TransportDescriptionFactory tdf2_; |
517 }; | 517 }; |
518 | 518 |
519 // Create a typical audio offer, and ensure it matches what we expect. | 519 // Create a typical audio offer, and ensure it matches what we expect. |
520 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOffer) { | 520 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOffer) { |
521 f1_.set_secure(SEC_ENABLED); | 521 f1_.set_secure(SEC_ENABLED); |
522 std::unique_ptr<SessionDescription> offer( | 522 std::unique_ptr<SessionDescription> offer( |
523 f1_.CreateOffer(MediaSessionOptions(), NULL)); | 523 f1_.CreateOffer(MediaSessionOptions(), nullptr)); |
524 ASSERT_TRUE(offer.get() != NULL); | 524 ASSERT_TRUE(offer.get() != nullptr); |
525 const ContentInfo* ac = offer->GetContentByName("audio"); | 525 const ContentInfo* ac = offer->GetContentByName("audio"); |
526 const ContentInfo* vc = offer->GetContentByName("video"); | 526 const ContentInfo* vc = offer->GetContentByName("video"); |
527 ASSERT_TRUE(ac != NULL); | 527 ASSERT_TRUE(ac != nullptr); |
528 ASSERT_TRUE(vc == NULL); | 528 ASSERT_TRUE(vc == nullptr); |
529 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 529 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
530 const AudioContentDescription* acd = | 530 const AudioContentDescription* acd = |
531 static_cast<const AudioContentDescription*>(ac->description); | 531 static_cast<const AudioContentDescription*>(ac->description); |
532 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 532 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
533 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); | 533 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); |
534 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 534 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc |
535 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) | 535 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) |
536 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on | 536 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on |
537 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); | 537 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); |
538 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 538 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
539 } | 539 } |
540 | 540 |
541 // Create a typical video offer, and ensure it matches what we expect. | 541 // Create a typical video offer, and ensure it matches what we expect. |
542 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoOffer) { | 542 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoOffer) { |
543 MediaSessionOptions opts; | 543 MediaSessionOptions opts; |
544 opts.recv_video = true; | 544 opts.recv_video = true; |
545 f1_.set_secure(SEC_ENABLED); | 545 f1_.set_secure(SEC_ENABLED); |
546 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 546 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
547 ASSERT_TRUE(offer.get() != NULL); | 547 ASSERT_TRUE(offer.get() != nullptr); |
548 const ContentInfo* ac = offer->GetContentByName("audio"); | 548 const ContentInfo* ac = offer->GetContentByName("audio"); |
549 const ContentInfo* vc = offer->GetContentByName("video"); | 549 const ContentInfo* vc = offer->GetContentByName("video"); |
550 ASSERT_TRUE(ac != NULL); | 550 ASSERT_TRUE(ac != nullptr); |
551 ASSERT_TRUE(vc != NULL); | 551 ASSERT_TRUE(vc != nullptr); |
552 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 552 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
553 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 553 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); |
554 const AudioContentDescription* acd = | 554 const AudioContentDescription* acd = |
555 static_cast<const AudioContentDescription*>(ac->description); | 555 static_cast<const AudioContentDescription*>(ac->description); |
556 const VideoContentDescription* vcd = | 556 const VideoContentDescription* vcd = |
557 static_cast<const VideoContentDescription*>(vc->description); | 557 static_cast<const VideoContentDescription*>(vc->description); |
558 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 558 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
559 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); | 559 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); |
560 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 560 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc |
561 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) | 561 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) |
(...skipping 17 matching lines...) Expand all Loading... |
579 const AudioCodec& offered_audio_codec = f2_.audio_sendrecv_codecs()[0]; | 579 const AudioCodec& offered_audio_codec = f2_.audio_sendrecv_codecs()[0]; |
580 const DataCodec& offered_data_codec = f2_.data_codecs()[0]; | 580 const DataCodec& offered_data_codec = f2_.data_codecs()[0]; |
581 ASSERT_EQ(offered_video_codec.id, offered_audio_codec.id); | 581 ASSERT_EQ(offered_video_codec.id, offered_audio_codec.id); |
582 ASSERT_EQ(offered_video_codec.id, offered_data_codec.id); | 582 ASSERT_EQ(offered_video_codec.id, offered_data_codec.id); |
583 | 583 |
584 MediaSessionOptions opts; | 584 MediaSessionOptions opts; |
585 opts.recv_audio = true; | 585 opts.recv_audio = true; |
586 opts.recv_video = true; | 586 opts.recv_video = true; |
587 opts.data_channel_type = cricket::DCT_RTP; | 587 opts.data_channel_type = cricket::DCT_RTP; |
588 opts.bundle_enabled = true; | 588 opts.bundle_enabled = true; |
589 std::unique_ptr<SessionDescription> offer(f2_.CreateOffer(opts, NULL)); | 589 std::unique_ptr<SessionDescription> offer(f2_.CreateOffer(opts, nullptr)); |
590 const VideoContentDescription* vcd = | 590 const VideoContentDescription* vcd = |
591 GetFirstVideoContentDescription(offer.get()); | 591 GetFirstVideoContentDescription(offer.get()); |
592 const AudioContentDescription* acd = | 592 const AudioContentDescription* acd = |
593 GetFirstAudioContentDescription(offer.get()); | 593 GetFirstAudioContentDescription(offer.get()); |
594 const DataContentDescription* dcd = | 594 const DataContentDescription* dcd = |
595 GetFirstDataContentDescription(offer.get()); | 595 GetFirstDataContentDescription(offer.get()); |
596 ASSERT_TRUE(NULL != vcd); | 596 ASSERT_TRUE(nullptr != vcd); |
597 ASSERT_TRUE(NULL != acd); | 597 ASSERT_TRUE(nullptr != acd); |
598 ASSERT_TRUE(NULL != dcd); | 598 ASSERT_TRUE(nullptr != dcd); |
599 EXPECT_NE(vcd->codecs()[0].id, acd->codecs()[0].id); | 599 EXPECT_NE(vcd->codecs()[0].id, acd->codecs()[0].id); |
600 EXPECT_NE(vcd->codecs()[0].id, dcd->codecs()[0].id); | 600 EXPECT_NE(vcd->codecs()[0].id, dcd->codecs()[0].id); |
601 EXPECT_NE(acd->codecs()[0].id, dcd->codecs()[0].id); | 601 EXPECT_NE(acd->codecs()[0].id, dcd->codecs()[0].id); |
602 EXPECT_EQ(vcd->codecs()[0].name, offered_video_codec.name); | 602 EXPECT_EQ(vcd->codecs()[0].name, offered_video_codec.name); |
603 EXPECT_EQ(acd->codecs()[0].name, offered_audio_codec.name); | 603 EXPECT_EQ(acd->codecs()[0].name, offered_audio_codec.name); |
604 EXPECT_EQ(dcd->codecs()[0].name, offered_data_codec.name); | 604 EXPECT_EQ(dcd->codecs()[0].name, offered_data_codec.name); |
605 } | 605 } |
606 | 606 |
607 // Test creating an updated offer with with bundle, audio, video and data | 607 // Test creating an updated offer with with bundle, audio, video and data |
608 // after an audio only session has been negotiated. | 608 // after an audio only session has been negotiated. |
609 TEST_F(MediaSessionDescriptionFactoryTest, | 609 TEST_F(MediaSessionDescriptionFactoryTest, |
610 TestCreateUpdatedVideoOfferWithBundle) { | 610 TestCreateUpdatedVideoOfferWithBundle) { |
611 f1_.set_secure(SEC_ENABLED); | 611 f1_.set_secure(SEC_ENABLED); |
612 f2_.set_secure(SEC_ENABLED); | 612 f2_.set_secure(SEC_ENABLED); |
613 MediaSessionOptions opts; | 613 MediaSessionOptions opts; |
614 opts.recv_audio = true; | 614 opts.recv_audio = true; |
615 opts.recv_video = false; | 615 opts.recv_video = false; |
616 opts.data_channel_type = cricket::DCT_NONE; | 616 opts.data_channel_type = cricket::DCT_NONE; |
617 opts.bundle_enabled = true; | 617 opts.bundle_enabled = true; |
618 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 618 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
619 std::unique_ptr<SessionDescription> answer( | 619 std::unique_ptr<SessionDescription> answer( |
620 f2_.CreateAnswer(offer.get(), opts, NULL)); | 620 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
621 | 621 |
622 MediaSessionOptions updated_opts; | 622 MediaSessionOptions updated_opts; |
623 updated_opts.recv_audio = true; | 623 updated_opts.recv_audio = true; |
624 updated_opts.recv_video = true; | 624 updated_opts.recv_video = true; |
625 updated_opts.data_channel_type = cricket::DCT_RTP; | 625 updated_opts.data_channel_type = cricket::DCT_RTP; |
626 updated_opts.bundle_enabled = true; | 626 updated_opts.bundle_enabled = true; |
627 std::unique_ptr<SessionDescription> updated_offer( | 627 std::unique_ptr<SessionDescription> updated_offer( |
628 f1_.CreateOffer(updated_opts, answer.get())); | 628 f1_.CreateOffer(updated_opts, answer.get())); |
629 | 629 |
630 const AudioContentDescription* acd = | 630 const AudioContentDescription* acd = |
631 GetFirstAudioContentDescription(updated_offer.get()); | 631 GetFirstAudioContentDescription(updated_offer.get()); |
632 const VideoContentDescription* vcd = | 632 const VideoContentDescription* vcd = |
633 GetFirstVideoContentDescription(updated_offer.get()); | 633 GetFirstVideoContentDescription(updated_offer.get()); |
634 const DataContentDescription* dcd = | 634 const DataContentDescription* dcd = |
635 GetFirstDataContentDescription(updated_offer.get()); | 635 GetFirstDataContentDescription(updated_offer.get()); |
636 EXPECT_TRUE(NULL != vcd); | 636 EXPECT_TRUE(nullptr != vcd); |
637 EXPECT_TRUE(NULL != acd); | 637 EXPECT_TRUE(nullptr != acd); |
638 EXPECT_TRUE(NULL != dcd); | 638 EXPECT_TRUE(nullptr != dcd); |
639 | 639 |
640 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 640 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
641 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 641 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
642 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 642 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
643 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); | 643 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); |
644 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 644 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
645 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); | 645 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); |
646 } | 646 } |
647 | 647 |
648 // Create a RTP data offer, and ensure it matches what we expect. | 648 // Create a RTP data offer, and ensure it matches what we expect. |
649 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateRtpDataOffer) { | 649 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateRtpDataOffer) { |
650 MediaSessionOptions opts; | 650 MediaSessionOptions opts; |
651 opts.data_channel_type = cricket::DCT_RTP; | 651 opts.data_channel_type = cricket::DCT_RTP; |
652 f1_.set_secure(SEC_ENABLED); | 652 f1_.set_secure(SEC_ENABLED); |
653 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 653 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
654 ASSERT_TRUE(offer.get() != NULL); | 654 ASSERT_TRUE(offer.get() != nullptr); |
655 const ContentInfo* ac = offer->GetContentByName("audio"); | 655 const ContentInfo* ac = offer->GetContentByName("audio"); |
656 const ContentInfo* dc = offer->GetContentByName("data"); | 656 const ContentInfo* dc = offer->GetContentByName("data"); |
657 ASSERT_TRUE(ac != NULL); | 657 ASSERT_TRUE(ac != nullptr); |
658 ASSERT_TRUE(dc != NULL); | 658 ASSERT_TRUE(dc != nullptr); |
659 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 659 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
660 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); | 660 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); |
661 const AudioContentDescription* acd = | 661 const AudioContentDescription* acd = |
662 static_cast<const AudioContentDescription*>(ac->description); | 662 static_cast<const AudioContentDescription*>(ac->description); |
663 const DataContentDescription* dcd = | 663 const DataContentDescription* dcd = |
664 static_cast<const DataContentDescription*>(dc->description); | 664 static_cast<const DataContentDescription*>(dc->description); |
665 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 665 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
666 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); | 666 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); |
667 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 667 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc |
668 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) | 668 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) |
(...skipping 10 matching lines...) Expand all Loading... |
679 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); | 679 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); |
680 } | 680 } |
681 | 681 |
682 // Create an SCTP data offer with bundle without error. | 682 // Create an SCTP data offer with bundle without error. |
683 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSctpDataOffer) { | 683 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSctpDataOffer) { |
684 MediaSessionOptions opts; | 684 MediaSessionOptions opts; |
685 opts.recv_audio = false; | 685 opts.recv_audio = false; |
686 opts.bundle_enabled = true; | 686 opts.bundle_enabled = true; |
687 opts.data_channel_type = cricket::DCT_SCTP; | 687 opts.data_channel_type = cricket::DCT_SCTP; |
688 f1_.set_secure(SEC_ENABLED); | 688 f1_.set_secure(SEC_ENABLED); |
689 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 689 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
690 EXPECT_TRUE(offer.get() != NULL); | 690 EXPECT_TRUE(offer.get() != nullptr); |
691 EXPECT_TRUE(offer->GetContentByName("data") != NULL); | 691 EXPECT_TRUE(offer->GetContentByName("data") != nullptr); |
692 } | 692 } |
693 | 693 |
694 // Test creating an sctp data channel from an already generated offer. | 694 // Test creating an sctp data channel from an already generated offer. |
695 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateImplicitSctpDataOffer) { | 695 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateImplicitSctpDataOffer) { |
696 MediaSessionOptions opts; | 696 MediaSessionOptions opts; |
697 opts.recv_audio = false; | 697 opts.recv_audio = false; |
698 opts.bundle_enabled = true; | 698 opts.bundle_enabled = true; |
699 opts.data_channel_type = cricket::DCT_SCTP; | 699 opts.data_channel_type = cricket::DCT_SCTP; |
700 f1_.set_secure(SEC_ENABLED); | 700 f1_.set_secure(SEC_ENABLED); |
701 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); | 701 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, nullptr)); |
702 ASSERT_TRUE(offer1.get() != NULL); | 702 ASSERT_TRUE(offer1.get() != nullptr); |
703 const ContentInfo* data = offer1->GetContentByName("data"); | 703 const ContentInfo* data = offer1->GetContentByName("data"); |
704 ASSERT_TRUE(data != NULL); | 704 ASSERT_TRUE(data != nullptr); |
705 const MediaContentDescription* mdesc = | 705 const MediaContentDescription* mdesc = |
706 static_cast<const MediaContentDescription*>(data->description); | 706 static_cast<const MediaContentDescription*>(data->description); |
707 ASSERT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol()); | 707 ASSERT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol()); |
708 | 708 |
709 // Now set data_channel_type to 'none' (default) and make sure that the | 709 // Now set data_channel_type to 'none' (default) and make sure that the |
710 // datachannel type that gets generated from the previous offer, is of the | 710 // datachannel type that gets generated from the previous offer, is of the |
711 // same type. | 711 // same type. |
712 opts.data_channel_type = cricket::DCT_NONE; | 712 opts.data_channel_type = cricket::DCT_NONE; |
713 std::unique_ptr<SessionDescription> offer2( | 713 std::unique_ptr<SessionDescription> offer2( |
714 f1_.CreateOffer(opts, offer1.get())); | 714 f1_.CreateOffer(opts, offer1.get())); |
715 data = offer2->GetContentByName("data"); | 715 data = offer2->GetContentByName("data"); |
716 ASSERT_TRUE(data != NULL); | 716 ASSERT_TRUE(data != nullptr); |
717 mdesc = static_cast<const MediaContentDescription*>(data->description); | 717 mdesc = static_cast<const MediaContentDescription*>(data->description); |
718 EXPECT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol()); | 718 EXPECT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol()); |
719 } | 719 } |
720 | 720 |
721 // Create an audio, video offer without legacy StreamParams. | 721 // Create an audio, video offer without legacy StreamParams. |
722 TEST_F(MediaSessionDescriptionFactoryTest, | 722 TEST_F(MediaSessionDescriptionFactoryTest, |
723 TestCreateOfferWithoutLegacyStreams) { | 723 TestCreateOfferWithoutLegacyStreams) { |
724 MediaSessionOptions opts; | 724 MediaSessionOptions opts; |
725 opts.recv_video = true; | 725 opts.recv_video = true; |
726 f1_.set_add_legacy_streams(false); | 726 f1_.set_add_legacy_streams(false); |
727 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 727 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
728 ASSERT_TRUE(offer.get() != NULL); | 728 ASSERT_TRUE(offer.get() != nullptr); |
729 const ContentInfo* ac = offer->GetContentByName("audio"); | 729 const ContentInfo* ac = offer->GetContentByName("audio"); |
730 const ContentInfo* vc = offer->GetContentByName("video"); | 730 const ContentInfo* vc = offer->GetContentByName("video"); |
731 ASSERT_TRUE(ac != NULL); | 731 ASSERT_TRUE(ac != nullptr); |
732 ASSERT_TRUE(vc != NULL); | 732 ASSERT_TRUE(vc != nullptr); |
733 const AudioContentDescription* acd = | 733 const AudioContentDescription* acd = |
734 static_cast<const AudioContentDescription*>(ac->description); | 734 static_cast<const AudioContentDescription*>(ac->description); |
735 const VideoContentDescription* vcd = | 735 const VideoContentDescription* vcd = |
736 static_cast<const VideoContentDescription*>(vc->description); | 736 static_cast<const VideoContentDescription*>(vc->description); |
737 | 737 |
738 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. | 738 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. |
739 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. | 739 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. |
740 } | 740 } |
741 | 741 |
742 // Creates an audio+video sendonly offer. | 742 // Creates an audio+video sendonly offer. |
743 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSendOnlyOffer) { | 743 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSendOnlyOffer) { |
744 MediaSessionOptions options; | 744 MediaSessionOptions options; |
745 options.recv_audio = false; | 745 options.recv_audio = false; |
746 options.recv_video = false; | 746 options.recv_video = false; |
747 options.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); | 747 options.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); |
748 options.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 748 options.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); |
749 | 749 |
750 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL)); | 750 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, nullptr)); |
751 ASSERT_TRUE(offer.get() != NULL); | 751 ASSERT_TRUE(offer.get() != nullptr); |
752 EXPECT_EQ(2u, offer->contents().size()); | 752 EXPECT_EQ(2u, offer->contents().size()); |
753 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[0], MEDIA_TYPE_AUDIO)); | 753 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[0], MEDIA_TYPE_AUDIO)); |
754 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[1], MEDIA_TYPE_VIDEO)); | 754 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[1], MEDIA_TYPE_VIDEO)); |
755 | 755 |
756 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[0])); | 756 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[0])); |
757 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[1])); | 757 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[1])); |
758 } | 758 } |
759 | 759 |
760 // Verifies that the order of the media contents in the current | 760 // Verifies that the order of the media contents in the current |
761 // SessionDescription is preserved in the new SessionDescription. | 761 // SessionDescription is preserved in the new SessionDescription. |
762 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateOfferContentOrder) { | 762 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateOfferContentOrder) { |
763 MediaSessionOptions opts; | 763 MediaSessionOptions opts; |
764 opts.recv_audio = false; | 764 opts.recv_audio = false; |
765 opts.recv_video = false; | 765 opts.recv_video = false; |
766 opts.data_channel_type = cricket::DCT_SCTP; | 766 opts.data_channel_type = cricket::DCT_SCTP; |
767 | 767 |
768 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); | 768 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, nullptr)); |
769 ASSERT_TRUE(offer1.get() != NULL); | 769 ASSERT_TRUE(offer1.get() != nullptr); |
770 EXPECT_EQ(1u, offer1->contents().size()); | 770 EXPECT_EQ(1u, offer1->contents().size()); |
771 EXPECT_TRUE(IsMediaContentOfType(&offer1->contents()[0], MEDIA_TYPE_DATA)); | 771 EXPECT_TRUE(IsMediaContentOfType(&offer1->contents()[0], MEDIA_TYPE_DATA)); |
772 | 772 |
773 opts.recv_video = true; | 773 opts.recv_video = true; |
774 std::unique_ptr<SessionDescription> offer2( | 774 std::unique_ptr<SessionDescription> offer2( |
775 f1_.CreateOffer(opts, offer1.get())); | 775 f1_.CreateOffer(opts, offer1.get())); |
776 ASSERT_TRUE(offer2.get() != NULL); | 776 ASSERT_TRUE(offer2.get() != nullptr); |
777 EXPECT_EQ(2u, offer2->contents().size()); | 777 EXPECT_EQ(2u, offer2->contents().size()); |
778 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[0], MEDIA_TYPE_DATA)); | 778 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[0], MEDIA_TYPE_DATA)); |
779 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[1], MEDIA_TYPE_VIDEO)); | 779 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[1], MEDIA_TYPE_VIDEO)); |
780 | 780 |
781 opts.recv_audio = true; | 781 opts.recv_audio = true; |
782 std::unique_ptr<SessionDescription> offer3( | 782 std::unique_ptr<SessionDescription> offer3( |
783 f1_.CreateOffer(opts, offer2.get())); | 783 f1_.CreateOffer(opts, offer2.get())); |
784 ASSERT_TRUE(offer3.get() != NULL); | 784 ASSERT_TRUE(offer3.get() != nullptr); |
785 EXPECT_EQ(3u, offer3->contents().size()); | 785 EXPECT_EQ(3u, offer3->contents().size()); |
786 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[0], MEDIA_TYPE_DATA)); | 786 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[0], MEDIA_TYPE_DATA)); |
787 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[1], MEDIA_TYPE_VIDEO)); | 787 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[1], MEDIA_TYPE_VIDEO)); |
788 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[2], MEDIA_TYPE_AUDIO)); | 788 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[2], MEDIA_TYPE_AUDIO)); |
789 | 789 |
790 // Verifies the default order is audio-video-data, so that the previous checks | 790 // Verifies the default order is audio-video-data, so that the previous checks |
791 // didn't pass by accident. | 791 // didn't pass by accident. |
792 std::unique_ptr<SessionDescription> offer4(f1_.CreateOffer(opts, NULL)); | 792 std::unique_ptr<SessionDescription> offer4(f1_.CreateOffer(opts, nullptr)); |
793 ASSERT_TRUE(offer4.get() != NULL); | 793 ASSERT_TRUE(offer4.get() != nullptr); |
794 EXPECT_EQ(3u, offer4->contents().size()); | 794 EXPECT_EQ(3u, offer4->contents().size()); |
795 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[0], MEDIA_TYPE_AUDIO)); | 795 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[0], MEDIA_TYPE_AUDIO)); |
796 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[1], MEDIA_TYPE_VIDEO)); | 796 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[1], MEDIA_TYPE_VIDEO)); |
797 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[2], MEDIA_TYPE_DATA)); | 797 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[2], MEDIA_TYPE_DATA)); |
798 } | 798 } |
799 | 799 |
800 // Create a typical audio answer, and ensure it matches what we expect. | 800 // Create a typical audio answer, and ensure it matches what we expect. |
801 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswer) { | 801 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswer) { |
802 f1_.set_secure(SEC_ENABLED); | 802 f1_.set_secure(SEC_ENABLED); |
803 f2_.set_secure(SEC_ENABLED); | 803 f2_.set_secure(SEC_ENABLED); |
804 std::unique_ptr<SessionDescription> offer( | 804 std::unique_ptr<SessionDescription> offer( |
805 f1_.CreateOffer(MediaSessionOptions(), NULL)); | 805 f1_.CreateOffer(MediaSessionOptions(), nullptr)); |
806 ASSERT_TRUE(offer.get() != NULL); | 806 ASSERT_TRUE(offer.get() != nullptr); |
807 std::unique_ptr<SessionDescription> answer( | 807 std::unique_ptr<SessionDescription> answer( |
808 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 808 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), nullptr)); |
809 const ContentInfo* ac = answer->GetContentByName("audio"); | 809 const ContentInfo* ac = answer->GetContentByName("audio"); |
810 const ContentInfo* vc = answer->GetContentByName("video"); | 810 const ContentInfo* vc = answer->GetContentByName("video"); |
811 ASSERT_TRUE(ac != NULL); | 811 ASSERT_TRUE(ac != nullptr); |
812 ASSERT_TRUE(vc == NULL); | 812 ASSERT_TRUE(vc == nullptr); |
813 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 813 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
814 const AudioContentDescription* acd = | 814 const AudioContentDescription* acd = |
815 static_cast<const AudioContentDescription*>(ac->description); | 815 static_cast<const AudioContentDescription*>(ac->description); |
816 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 816 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
817 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 817 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
818 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 818 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc |
819 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 819 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
820 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 820 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
821 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); | 821 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); |
822 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 822 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
823 } | 823 } |
824 | 824 |
825 // Create a typical audio answer with GCM ciphers enabled, and ensure it | 825 // Create a typical audio answer with GCM ciphers enabled, and ensure it |
826 // matches what we expect. | 826 // matches what we expect. |
827 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerGcm) { | 827 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerGcm) { |
828 f1_.set_secure(SEC_ENABLED); | 828 f1_.set_secure(SEC_ENABLED); |
829 f2_.set_secure(SEC_ENABLED); | 829 f2_.set_secure(SEC_ENABLED); |
830 MediaSessionOptions options; | 830 MediaSessionOptions options; |
831 options.crypto_options.enable_gcm_crypto_suites = true; | 831 options.crypto_options.enable_gcm_crypto_suites = true; |
832 std::unique_ptr<SessionDescription> offer( | 832 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, nullptr)); |
833 f1_.CreateOffer(options, NULL)); | 833 ASSERT_TRUE(offer.get() != nullptr); |
834 ASSERT_TRUE(offer.get() != NULL); | |
835 std::unique_ptr<SessionDescription> answer( | 834 std::unique_ptr<SessionDescription> answer( |
836 f2_.CreateAnswer(offer.get(), options, NULL)); | 835 f2_.CreateAnswer(offer.get(), options, nullptr)); |
837 const ContentInfo* ac = answer->GetContentByName("audio"); | 836 const ContentInfo* ac = answer->GetContentByName("audio"); |
838 const ContentInfo* vc = answer->GetContentByName("video"); | 837 const ContentInfo* vc = answer->GetContentByName("video"); |
839 ASSERT_TRUE(ac != NULL); | 838 ASSERT_TRUE(ac != nullptr); |
840 ASSERT_TRUE(vc == NULL); | 839 ASSERT_TRUE(vc == nullptr); |
841 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 840 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
842 const AudioContentDescription* acd = | 841 const AudioContentDescription* acd = |
843 static_cast<const AudioContentDescription*>(ac->description); | 842 static_cast<const AudioContentDescription*>(ac->description); |
844 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 843 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
845 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 844 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
846 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 845 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc |
847 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 846 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
848 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 847 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
849 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); | 848 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); |
850 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 849 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
851 } | 850 } |
852 | 851 |
853 // Create a typical video answer, and ensure it matches what we expect. | 852 // Create a typical video answer, and ensure it matches what we expect. |
854 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswer) { | 853 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswer) { |
855 MediaSessionOptions opts; | 854 MediaSessionOptions opts; |
856 opts.recv_video = true; | 855 opts.recv_video = true; |
857 f1_.set_secure(SEC_ENABLED); | 856 f1_.set_secure(SEC_ENABLED); |
858 f2_.set_secure(SEC_ENABLED); | 857 f2_.set_secure(SEC_ENABLED); |
859 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 858 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
860 ASSERT_TRUE(offer.get() != NULL); | 859 ASSERT_TRUE(offer.get() != nullptr); |
861 std::unique_ptr<SessionDescription> answer( | 860 std::unique_ptr<SessionDescription> answer( |
862 f2_.CreateAnswer(offer.get(), opts, NULL)); | 861 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
863 const ContentInfo* ac = answer->GetContentByName("audio"); | 862 const ContentInfo* ac = answer->GetContentByName("audio"); |
864 const ContentInfo* vc = answer->GetContentByName("video"); | 863 const ContentInfo* vc = answer->GetContentByName("video"); |
865 ASSERT_TRUE(ac != NULL); | 864 ASSERT_TRUE(ac != nullptr); |
866 ASSERT_TRUE(vc != NULL); | 865 ASSERT_TRUE(vc != nullptr); |
867 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 866 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
868 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 867 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); |
869 const AudioContentDescription* acd = | 868 const AudioContentDescription* acd = |
870 static_cast<const AudioContentDescription*>(ac->description); | 869 static_cast<const AudioContentDescription*>(ac->description); |
871 const VideoContentDescription* vcd = | 870 const VideoContentDescription* vcd = |
872 static_cast<const VideoContentDescription*>(vc->description); | 871 static_cast<const VideoContentDescription*>(vc->description); |
873 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 872 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
874 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 873 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
875 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 874 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
876 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 875 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc |
(...skipping 23 matching lines...) Expand all Loading... |
900 // and ensure it matches what we expect. | 899 // and ensure it matches what we expect. |
901 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerGcmAnswer) { | 900 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerGcmAnswer) { |
902 TestVideoGcmCipher(false, true); | 901 TestVideoGcmCipher(false, true); |
903 } | 902 } |
904 | 903 |
905 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswer) { | 904 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswer) { |
906 MediaSessionOptions opts; | 905 MediaSessionOptions opts; |
907 opts.data_channel_type = cricket::DCT_RTP; | 906 opts.data_channel_type = cricket::DCT_RTP; |
908 f1_.set_secure(SEC_ENABLED); | 907 f1_.set_secure(SEC_ENABLED); |
909 f2_.set_secure(SEC_ENABLED); | 908 f2_.set_secure(SEC_ENABLED); |
910 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 909 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
911 ASSERT_TRUE(offer.get() != NULL); | 910 ASSERT_TRUE(offer.get() != nullptr); |
912 std::unique_ptr<SessionDescription> answer( | 911 std::unique_ptr<SessionDescription> answer( |
913 f2_.CreateAnswer(offer.get(), opts, NULL)); | 912 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
914 const ContentInfo* ac = answer->GetContentByName("audio"); | 913 const ContentInfo* ac = answer->GetContentByName("audio"); |
915 const ContentInfo* vc = answer->GetContentByName("data"); | 914 const ContentInfo* vc = answer->GetContentByName("data"); |
916 ASSERT_TRUE(ac != NULL); | 915 ASSERT_TRUE(ac != nullptr); |
917 ASSERT_TRUE(vc != NULL); | 916 ASSERT_TRUE(vc != nullptr); |
918 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 917 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
919 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 918 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); |
920 const AudioContentDescription* acd = | 919 const AudioContentDescription* acd = |
921 static_cast<const AudioContentDescription*>(ac->description); | 920 static_cast<const AudioContentDescription*>(ac->description); |
922 const DataContentDescription* vcd = | 921 const DataContentDescription* vcd = |
923 static_cast<const DataContentDescription*>(vc->description); | 922 static_cast<const DataContentDescription*>(vc->description); |
924 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 923 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
925 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 924 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
926 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 925 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
927 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 926 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc |
928 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 927 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
929 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); | 928 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); |
930 EXPECT_EQ(MEDIA_TYPE_DATA, vcd->type()); | 929 EXPECT_EQ(MEDIA_TYPE_DATA, vcd->type()); |
931 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), vcd->codecs()); | 930 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), vcd->codecs()); |
932 EXPECT_NE(0U, vcd->first_ssrc()); // a random nonzero ssrc | 931 EXPECT_NE(0U, vcd->first_ssrc()); // a random nonzero ssrc |
933 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux | 932 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux |
934 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 933 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
935 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); | 934 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); |
936 } | 935 } |
937 | 936 |
938 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerGcm) { | 937 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerGcm) { |
939 MediaSessionOptions opts; | 938 MediaSessionOptions opts; |
940 opts.data_channel_type = cricket::DCT_RTP; | 939 opts.data_channel_type = cricket::DCT_RTP; |
941 opts.crypto_options.enable_gcm_crypto_suites = true; | 940 opts.crypto_options.enable_gcm_crypto_suites = true; |
942 f1_.set_secure(SEC_ENABLED); | 941 f1_.set_secure(SEC_ENABLED); |
943 f2_.set_secure(SEC_ENABLED); | 942 f2_.set_secure(SEC_ENABLED); |
944 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 943 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
945 ASSERT_TRUE(offer.get() != NULL); | 944 ASSERT_TRUE(offer.get() != nullptr); |
946 std::unique_ptr<SessionDescription> answer( | 945 std::unique_ptr<SessionDescription> answer( |
947 f2_.CreateAnswer(offer.get(), opts, NULL)); | 946 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
948 const ContentInfo* ac = answer->GetContentByName("audio"); | 947 const ContentInfo* ac = answer->GetContentByName("audio"); |
949 const ContentInfo* vc = answer->GetContentByName("data"); | 948 const ContentInfo* vc = answer->GetContentByName("data"); |
950 ASSERT_TRUE(ac != NULL); | 949 ASSERT_TRUE(ac != nullptr); |
951 ASSERT_TRUE(vc != NULL); | 950 ASSERT_TRUE(vc != nullptr); |
952 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 951 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
953 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 952 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); |
954 const AudioContentDescription* acd = | 953 const AudioContentDescription* acd = |
955 static_cast<const AudioContentDescription*>(ac->description); | 954 static_cast<const AudioContentDescription*>(ac->description); |
956 const DataContentDescription* vcd = | 955 const DataContentDescription* vcd = |
957 static_cast<const DataContentDescription*>(vc->description); | 956 static_cast<const DataContentDescription*>(vc->description); |
958 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 957 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
959 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 958 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
960 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 959 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
961 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 960 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc |
962 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 961 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
963 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); | 962 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); |
964 EXPECT_EQ(MEDIA_TYPE_DATA, vcd->type()); | 963 EXPECT_EQ(MEDIA_TYPE_DATA, vcd->type()); |
965 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), vcd->codecs()); | 964 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), vcd->codecs()); |
966 EXPECT_NE(0U, vcd->first_ssrc()); // a random nonzero ssrc | 965 EXPECT_NE(0U, vcd->first_ssrc()); // a random nonzero ssrc |
967 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux | 966 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux |
968 ASSERT_CRYPTO(vcd, 1U, CS_AEAD_AES_256_GCM); | 967 ASSERT_CRYPTO(vcd, 1U, CS_AEAD_AES_256_GCM); |
969 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); | 968 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); |
970 } | 969 } |
971 | 970 |
972 // Verifies that the order of the media contents in the offer is preserved in | 971 // Verifies that the order of the media contents in the offer is preserved in |
973 // the answer. | 972 // the answer. |
974 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerContentOrder) { | 973 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerContentOrder) { |
975 MediaSessionOptions opts; | 974 MediaSessionOptions opts; |
976 | 975 |
977 // Creates a data only offer. | 976 // Creates a data only offer. |
978 opts.recv_audio = false; | 977 opts.recv_audio = false; |
979 opts.data_channel_type = cricket::DCT_SCTP; | 978 opts.data_channel_type = cricket::DCT_SCTP; |
980 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); | 979 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, nullptr)); |
981 ASSERT_TRUE(offer1.get() != NULL); | 980 ASSERT_TRUE(offer1.get() != nullptr); |
982 | 981 |
983 // Appends audio to the offer. | 982 // Appends audio to the offer. |
984 opts.recv_audio = true; | 983 opts.recv_audio = true; |
985 std::unique_ptr<SessionDescription> offer2( | 984 std::unique_ptr<SessionDescription> offer2( |
986 f1_.CreateOffer(opts, offer1.get())); | 985 f1_.CreateOffer(opts, offer1.get())); |
987 ASSERT_TRUE(offer2.get() != NULL); | 986 ASSERT_TRUE(offer2.get() != nullptr); |
988 | 987 |
989 // Appends video to the offer. | 988 // Appends video to the offer. |
990 opts.recv_video = true; | 989 opts.recv_video = true; |
991 std::unique_ptr<SessionDescription> offer3( | 990 std::unique_ptr<SessionDescription> offer3( |
992 f1_.CreateOffer(opts, offer2.get())); | 991 f1_.CreateOffer(opts, offer2.get())); |
993 ASSERT_TRUE(offer3.get() != NULL); | 992 ASSERT_TRUE(offer3.get() != nullptr); |
994 | 993 |
995 std::unique_ptr<SessionDescription> answer( | 994 std::unique_ptr<SessionDescription> answer( |
996 f2_.CreateAnswer(offer3.get(), opts, NULL)); | 995 f2_.CreateAnswer(offer3.get(), opts, nullptr)); |
997 ASSERT_TRUE(answer.get() != NULL); | 996 ASSERT_TRUE(answer.get() != nullptr); |
998 EXPECT_EQ(3u, answer->contents().size()); | 997 EXPECT_EQ(3u, answer->contents().size()); |
999 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[0], MEDIA_TYPE_DATA)); | 998 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[0], MEDIA_TYPE_DATA)); |
1000 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[1], MEDIA_TYPE_AUDIO)); | 999 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[1], MEDIA_TYPE_AUDIO)); |
1001 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[2], MEDIA_TYPE_VIDEO)); | 1000 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[2], MEDIA_TYPE_VIDEO)); |
1002 } | 1001 } |
1003 | 1002 |
1004 // TODO(deadbeef): Extend these tests to ensure the correct direction with other | 1003 // TODO(deadbeef): Extend these tests to ensure the correct direction with other |
1005 // answerer settings. | 1004 // answerer settings. |
1006 | 1005 |
1007 // This test that the media direction is set to send/receive in an answer if | 1006 // This test that the media direction is set to send/receive in an answer if |
(...skipping 21 matching lines...) Expand all Loading... |
1029 } | 1028 } |
1030 | 1029 |
1031 // Test that a data content with an unknown protocol is rejected in an answer. | 1030 // Test that a data content with an unknown protocol is rejected in an answer. |
1032 TEST_F(MediaSessionDescriptionFactoryTest, | 1031 TEST_F(MediaSessionDescriptionFactoryTest, |
1033 CreateDataAnswerToOfferWithUnknownProtocol) { | 1032 CreateDataAnswerToOfferWithUnknownProtocol) { |
1034 MediaSessionOptions opts; | 1033 MediaSessionOptions opts; |
1035 opts.data_channel_type = cricket::DCT_RTP; | 1034 opts.data_channel_type = cricket::DCT_RTP; |
1036 opts.recv_audio = false; | 1035 opts.recv_audio = false; |
1037 f1_.set_secure(SEC_ENABLED); | 1036 f1_.set_secure(SEC_ENABLED); |
1038 f2_.set_secure(SEC_ENABLED); | 1037 f2_.set_secure(SEC_ENABLED); |
1039 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1038 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1040 ContentInfo* dc_offer = offer->GetContentByName("data"); | 1039 ContentInfo* dc_offer = offer->GetContentByName("data"); |
1041 ASSERT_TRUE(dc_offer != NULL); | 1040 ASSERT_TRUE(dc_offer != nullptr); |
1042 DataContentDescription* dcd_offer = | 1041 DataContentDescription* dcd_offer = |
1043 static_cast<DataContentDescription*>(dc_offer->description); | 1042 static_cast<DataContentDescription*>(dc_offer->description); |
1044 ASSERT_TRUE(dcd_offer != NULL); | 1043 ASSERT_TRUE(dcd_offer != nullptr); |
1045 std::string protocol = "a weird unknown protocol"; | 1044 std::string protocol = "a weird unknown protocol"; |
1046 dcd_offer->set_protocol(protocol); | 1045 dcd_offer->set_protocol(protocol); |
1047 | 1046 |
1048 std::unique_ptr<SessionDescription> answer( | 1047 std::unique_ptr<SessionDescription> answer( |
1049 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1048 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
1050 | 1049 |
1051 const ContentInfo* dc_answer = answer->GetContentByName("data"); | 1050 const ContentInfo* dc_answer = answer->GetContentByName("data"); |
1052 ASSERT_TRUE(dc_answer != NULL); | 1051 ASSERT_TRUE(dc_answer != nullptr); |
1053 EXPECT_TRUE(dc_answer->rejected); | 1052 EXPECT_TRUE(dc_answer->rejected); |
1054 const DataContentDescription* dcd_answer = | 1053 const DataContentDescription* dcd_answer = |
1055 static_cast<const DataContentDescription*>(dc_answer->description); | 1054 static_cast<const DataContentDescription*>(dc_answer->description); |
1056 ASSERT_TRUE(dcd_answer != NULL); | 1055 ASSERT_TRUE(dcd_answer != nullptr); |
1057 EXPECT_EQ(protocol, dcd_answer->protocol()); | 1056 EXPECT_EQ(protocol, dcd_answer->protocol()); |
1058 } | 1057 } |
1059 | 1058 |
1060 // Test that the media protocol is RTP/AVPF if DTLS and SDES are disabled. | 1059 // Test that the media protocol is RTP/AVPF if DTLS and SDES are disabled. |
1061 TEST_F(MediaSessionDescriptionFactoryTest, AudioOfferAnswerWithCryptoDisabled) { | 1060 TEST_F(MediaSessionDescriptionFactoryTest, AudioOfferAnswerWithCryptoDisabled) { |
1062 MediaSessionOptions opts; | 1061 MediaSessionOptions opts; |
1063 f1_.set_secure(SEC_DISABLED); | 1062 f1_.set_secure(SEC_DISABLED); |
1064 f2_.set_secure(SEC_DISABLED); | 1063 f2_.set_secure(SEC_DISABLED); |
1065 tdf1_.set_secure(SEC_DISABLED); | 1064 tdf1_.set_secure(SEC_DISABLED); |
1066 tdf2_.set_secure(SEC_DISABLED); | 1065 tdf2_.set_secure(SEC_DISABLED); |
1067 | 1066 |
1068 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1067 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1069 const AudioContentDescription* offer_acd = | 1068 const AudioContentDescription* offer_acd = |
1070 GetFirstAudioContentDescription(offer.get()); | 1069 GetFirstAudioContentDescription(offer.get()); |
1071 ASSERT_TRUE(offer_acd != NULL); | 1070 ASSERT_TRUE(offer_acd != nullptr); |
1072 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), offer_acd->protocol()); | 1071 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), offer_acd->protocol()); |
1073 | 1072 |
1074 std::unique_ptr<SessionDescription> answer( | 1073 std::unique_ptr<SessionDescription> answer( |
1075 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1074 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
1076 | 1075 |
1077 const ContentInfo* ac_answer = answer->GetContentByName("audio"); | 1076 const ContentInfo* ac_answer = answer->GetContentByName("audio"); |
1078 ASSERT_TRUE(ac_answer != NULL); | 1077 ASSERT_TRUE(ac_answer != nullptr); |
1079 EXPECT_FALSE(ac_answer->rejected); | 1078 EXPECT_FALSE(ac_answer->rejected); |
1080 | 1079 |
1081 const AudioContentDescription* answer_acd = | 1080 const AudioContentDescription* answer_acd = |
1082 GetFirstAudioContentDescription(answer.get()); | 1081 GetFirstAudioContentDescription(answer.get()); |
1083 ASSERT_TRUE(answer_acd != NULL); | 1082 ASSERT_TRUE(answer_acd != nullptr); |
1084 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), answer_acd->protocol()); | 1083 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), answer_acd->protocol()); |
1085 } | 1084 } |
1086 | 1085 |
1087 // Create a video offer and answer and ensure the RTP header extensions | 1086 // Create a video offer and answer and ensure the RTP header extensions |
1088 // matches what we expect. | 1087 // matches what we expect. |
1089 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferAnswerWithRtpExtensions) { | 1088 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferAnswerWithRtpExtensions) { |
1090 MediaSessionOptions opts; | 1089 MediaSessionOptions opts; |
1091 opts.recv_video = true; | 1090 opts.recv_video = true; |
1092 | 1091 |
1093 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); | 1092 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); |
1094 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); | 1093 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); |
1095 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); | 1094 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); |
1096 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); | 1095 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); |
1097 | 1096 |
1098 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1097 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1099 ASSERT_TRUE(offer.get() != NULL); | 1098 ASSERT_TRUE(offer.get() != nullptr); |
1100 std::unique_ptr<SessionDescription> answer( | 1099 std::unique_ptr<SessionDescription> answer( |
1101 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1100 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
1102 | 1101 |
1103 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension1), | 1102 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension1), |
1104 GetFirstAudioContentDescription( | 1103 GetFirstAudioContentDescription( |
1105 offer.get())->rtp_header_extensions()); | 1104 offer.get())->rtp_header_extensions()); |
1106 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtension1), | 1105 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtension1), |
1107 GetFirstVideoContentDescription( | 1106 GetFirstVideoContentDescription( |
1108 offer.get())->rtp_header_extensions()); | 1107 offer.get())->rtp_header_extensions()); |
1109 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), | 1108 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), |
1110 GetFirstAudioContentDescription( | 1109 GetFirstAudioContentDescription( |
1111 answer.get())->rtp_header_extensions()); | 1110 answer.get())->rtp_header_extensions()); |
1112 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), | 1111 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), |
1113 GetFirstVideoContentDescription( | 1112 GetFirstVideoContentDescription( |
1114 answer.get())->rtp_header_extensions()); | 1113 answer.get())->rtp_header_extensions()); |
1115 } | 1114 } |
1116 | 1115 |
1117 // Create an audio, video, data answer without legacy StreamParams. | 1116 // Create an audio, video, data answer without legacy StreamParams. |
1118 TEST_F(MediaSessionDescriptionFactoryTest, | 1117 TEST_F(MediaSessionDescriptionFactoryTest, |
1119 TestCreateAnswerWithoutLegacyStreams) { | 1118 TestCreateAnswerWithoutLegacyStreams) { |
1120 MediaSessionOptions opts; | 1119 MediaSessionOptions opts; |
1121 opts.recv_video = true; | 1120 opts.recv_video = true; |
1122 opts.data_channel_type = cricket::DCT_RTP; | 1121 opts.data_channel_type = cricket::DCT_RTP; |
1123 f1_.set_add_legacy_streams(false); | 1122 f1_.set_add_legacy_streams(false); |
1124 f2_.set_add_legacy_streams(false); | 1123 f2_.set_add_legacy_streams(false); |
1125 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1124 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1126 ASSERT_TRUE(offer.get() != NULL); | 1125 ASSERT_TRUE(offer.get() != nullptr); |
1127 std::unique_ptr<SessionDescription> answer( | 1126 std::unique_ptr<SessionDescription> answer( |
1128 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1127 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
1129 const ContentInfo* ac = answer->GetContentByName("audio"); | 1128 const ContentInfo* ac = answer->GetContentByName("audio"); |
1130 const ContentInfo* vc = answer->GetContentByName("video"); | 1129 const ContentInfo* vc = answer->GetContentByName("video"); |
1131 const ContentInfo* dc = answer->GetContentByName("data"); | 1130 const ContentInfo* dc = answer->GetContentByName("data"); |
1132 ASSERT_TRUE(ac != NULL); | 1131 ASSERT_TRUE(ac != nullptr); |
1133 ASSERT_TRUE(vc != NULL); | 1132 ASSERT_TRUE(vc != nullptr); |
1134 const AudioContentDescription* acd = | 1133 const AudioContentDescription* acd = |
1135 static_cast<const AudioContentDescription*>(ac->description); | 1134 static_cast<const AudioContentDescription*>(ac->description); |
1136 const VideoContentDescription* vcd = | 1135 const VideoContentDescription* vcd = |
1137 static_cast<const VideoContentDescription*>(vc->description); | 1136 static_cast<const VideoContentDescription*>(vc->description); |
1138 const DataContentDescription* dcd = | 1137 const DataContentDescription* dcd = |
1139 static_cast<const DataContentDescription*>(dc->description); | 1138 static_cast<const DataContentDescription*>(dc->description); |
1140 | 1139 |
1141 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. | 1140 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. |
1142 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. | 1141 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. |
1143 EXPECT_FALSE(dcd->has_ssrcs()); // No StreamParams. | 1142 EXPECT_FALSE(dcd->has_ssrcs()); // No StreamParams. |
1144 } | 1143 } |
1145 | 1144 |
1146 TEST_F(MediaSessionDescriptionFactoryTest, TestPartial) { | 1145 TEST_F(MediaSessionDescriptionFactoryTest, TestPartial) { |
1147 MediaSessionOptions opts; | 1146 MediaSessionOptions opts; |
1148 opts.recv_video = true; | 1147 opts.recv_video = true; |
1149 opts.data_channel_type = cricket::DCT_RTP; | 1148 opts.data_channel_type = cricket::DCT_RTP; |
1150 f1_.set_secure(SEC_ENABLED); | 1149 f1_.set_secure(SEC_ENABLED); |
1151 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1150 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1152 ASSERT_TRUE(offer.get() != NULL); | 1151 ASSERT_TRUE(offer.get() != nullptr); |
1153 const ContentInfo* ac = offer->GetContentByName("audio"); | 1152 const ContentInfo* ac = offer->GetContentByName("audio"); |
1154 const ContentInfo* vc = offer->GetContentByName("video"); | 1153 const ContentInfo* vc = offer->GetContentByName("video"); |
1155 const ContentInfo* dc = offer->GetContentByName("data"); | 1154 const ContentInfo* dc = offer->GetContentByName("data"); |
1156 AudioContentDescription* acd = const_cast<AudioContentDescription*>( | 1155 AudioContentDescription* acd = const_cast<AudioContentDescription*>( |
1157 static_cast<const AudioContentDescription*>(ac->description)); | 1156 static_cast<const AudioContentDescription*>(ac->description)); |
1158 VideoContentDescription* vcd = const_cast<VideoContentDescription*>( | 1157 VideoContentDescription* vcd = const_cast<VideoContentDescription*>( |
1159 static_cast<const VideoContentDescription*>(vc->description)); | 1158 static_cast<const VideoContentDescription*>(vc->description)); |
1160 DataContentDescription* dcd = const_cast<DataContentDescription*>( | 1159 DataContentDescription* dcd = const_cast<DataContentDescription*>( |
1161 static_cast<const DataContentDescription*>(dc->description)); | 1160 static_cast<const DataContentDescription*>(dc->description)); |
1162 | 1161 |
(...skipping 24 matching lines...) Expand all Loading... |
1187 offer_opts.recv_video = true; | 1186 offer_opts.recv_video = true; |
1188 answer_opts.data_channel_type = cricket::DCT_RTP; | 1187 answer_opts.data_channel_type = cricket::DCT_RTP; |
1189 offer_opts.data_channel_type = cricket::DCT_RTP; | 1188 offer_opts.data_channel_type = cricket::DCT_RTP; |
1190 | 1189 |
1191 std::unique_ptr<SessionDescription> offer; | 1190 std::unique_ptr<SessionDescription> offer; |
1192 std::unique_ptr<SessionDescription> answer; | 1191 std::unique_ptr<SessionDescription> answer; |
1193 | 1192 |
1194 offer_opts.rtcp_mux_enabled = true; | 1193 offer_opts.rtcp_mux_enabled = true; |
1195 answer_opts.rtcp_mux_enabled = true; | 1194 answer_opts.rtcp_mux_enabled = true; |
1196 | 1195 |
1197 offer.reset(f1_.CreateOffer(offer_opts, NULL)); | 1196 offer.reset(f1_.CreateOffer(offer_opts, nullptr)); |
1198 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 1197 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, nullptr)); |
1199 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); | 1198 ASSERT_TRUE(nullptr != GetFirstAudioContentDescription(offer.get())); |
1200 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); | 1199 ASSERT_TRUE(nullptr != GetFirstVideoContentDescription(offer.get())); |
1201 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); | 1200 ASSERT_TRUE(nullptr != GetFirstDataContentDescription(offer.get())); |
1202 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); | 1201 ASSERT_TRUE(nullptr != GetFirstAudioContentDescription(answer.get())); |
1203 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); | 1202 ASSERT_TRUE(nullptr != GetFirstVideoContentDescription(answer.get())); |
1204 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); | 1203 ASSERT_TRUE(nullptr != GetFirstDataContentDescription(answer.get())); |
1205 EXPECT_TRUE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); | 1204 EXPECT_TRUE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); |
1206 EXPECT_TRUE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); | 1205 EXPECT_TRUE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); |
1207 EXPECT_TRUE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); | 1206 EXPECT_TRUE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); |
1208 EXPECT_TRUE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); | 1207 EXPECT_TRUE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); |
1209 EXPECT_TRUE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); | 1208 EXPECT_TRUE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); |
1210 EXPECT_TRUE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); | 1209 EXPECT_TRUE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); |
1211 | 1210 |
1212 offer_opts.rtcp_mux_enabled = true; | 1211 offer_opts.rtcp_mux_enabled = true; |
1213 answer_opts.rtcp_mux_enabled = false; | 1212 answer_opts.rtcp_mux_enabled = false; |
1214 | 1213 |
1215 offer.reset(f1_.CreateOffer(offer_opts, NULL)); | 1214 offer.reset(f1_.CreateOffer(offer_opts, nullptr)); |
1216 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 1215 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, nullptr)); |
1217 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); | 1216 ASSERT_TRUE(nullptr != GetFirstAudioContentDescription(offer.get())); |
1218 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); | 1217 ASSERT_TRUE(nullptr != GetFirstVideoContentDescription(offer.get())); |
1219 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); | 1218 ASSERT_TRUE(nullptr != GetFirstDataContentDescription(offer.get())); |
1220 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); | 1219 ASSERT_TRUE(nullptr != GetFirstAudioContentDescription(answer.get())); |
1221 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); | 1220 ASSERT_TRUE(nullptr != GetFirstVideoContentDescription(answer.get())); |
1222 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); | 1221 ASSERT_TRUE(nullptr != GetFirstDataContentDescription(answer.get())); |
1223 EXPECT_TRUE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); | 1222 EXPECT_TRUE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); |
1224 EXPECT_TRUE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); | 1223 EXPECT_TRUE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); |
1225 EXPECT_TRUE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); | 1224 EXPECT_TRUE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); |
1226 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); | 1225 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); |
1227 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); | 1226 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); |
1228 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); | 1227 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); |
1229 | 1228 |
1230 offer_opts.rtcp_mux_enabled = false; | 1229 offer_opts.rtcp_mux_enabled = false; |
1231 answer_opts.rtcp_mux_enabled = true; | 1230 answer_opts.rtcp_mux_enabled = true; |
1232 | 1231 |
1233 offer.reset(f1_.CreateOffer(offer_opts, NULL)); | 1232 offer.reset(f1_.CreateOffer(offer_opts, nullptr)); |
1234 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 1233 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, nullptr)); |
1235 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); | 1234 ASSERT_TRUE(nullptr != GetFirstAudioContentDescription(offer.get())); |
1236 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); | 1235 ASSERT_TRUE(nullptr != GetFirstVideoContentDescription(offer.get())); |
1237 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); | 1236 ASSERT_TRUE(nullptr != GetFirstDataContentDescription(offer.get())); |
1238 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); | 1237 ASSERT_TRUE(nullptr != GetFirstAudioContentDescription(answer.get())); |
1239 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); | 1238 ASSERT_TRUE(nullptr != GetFirstVideoContentDescription(answer.get())); |
1240 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); | 1239 ASSERT_TRUE(nullptr != GetFirstDataContentDescription(answer.get())); |
1241 EXPECT_FALSE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); | 1240 EXPECT_FALSE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); |
1242 EXPECT_FALSE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); | 1241 EXPECT_FALSE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); |
1243 EXPECT_FALSE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); | 1242 EXPECT_FALSE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); |
1244 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); | 1243 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); |
1245 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); | 1244 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); |
1246 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); | 1245 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); |
1247 | 1246 |
1248 offer_opts.rtcp_mux_enabled = false; | 1247 offer_opts.rtcp_mux_enabled = false; |
1249 answer_opts.rtcp_mux_enabled = false; | 1248 answer_opts.rtcp_mux_enabled = false; |
1250 | 1249 |
1251 offer.reset(f1_.CreateOffer(offer_opts, NULL)); | 1250 offer.reset(f1_.CreateOffer(offer_opts, nullptr)); |
1252 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 1251 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, nullptr)); |
1253 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); | 1252 ASSERT_TRUE(nullptr != GetFirstAudioContentDescription(offer.get())); |
1254 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); | 1253 ASSERT_TRUE(nullptr != GetFirstVideoContentDescription(offer.get())); |
1255 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); | 1254 ASSERT_TRUE(nullptr != GetFirstDataContentDescription(offer.get())); |
1256 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); | 1255 ASSERT_TRUE(nullptr != GetFirstAudioContentDescription(answer.get())); |
1257 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); | 1256 ASSERT_TRUE(nullptr != GetFirstVideoContentDescription(answer.get())); |
1258 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); | 1257 ASSERT_TRUE(nullptr != GetFirstDataContentDescription(answer.get())); |
1259 EXPECT_FALSE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); | 1258 EXPECT_FALSE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); |
1260 EXPECT_FALSE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); | 1259 EXPECT_FALSE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); |
1261 EXPECT_FALSE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); | 1260 EXPECT_FALSE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); |
1262 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); | 1261 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); |
1263 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); | 1262 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); |
1264 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); | 1263 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); |
1265 } | 1264 } |
1266 | 1265 |
1267 // Create an audio-only answer to a video offer. | 1266 // Create an audio-only answer to a video offer. |
1268 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerToVideo) { | 1267 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerToVideo) { |
1269 MediaSessionOptions opts; | 1268 MediaSessionOptions opts; |
1270 opts.recv_video = true; | 1269 opts.recv_video = true; |
1271 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1270 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1272 ASSERT_TRUE(offer.get() != NULL); | 1271 ASSERT_TRUE(offer.get() != nullptr); |
1273 std::unique_ptr<SessionDescription> answer( | 1272 std::unique_ptr<SessionDescription> answer( |
1274 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 1273 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), nullptr)); |
1275 const ContentInfo* ac = answer->GetContentByName("audio"); | 1274 const ContentInfo* ac = answer->GetContentByName("audio"); |
1276 const ContentInfo* vc = answer->GetContentByName("video"); | 1275 const ContentInfo* vc = answer->GetContentByName("video"); |
1277 ASSERT_TRUE(ac != NULL); | 1276 ASSERT_TRUE(ac != nullptr); |
1278 ASSERT_TRUE(vc != NULL); | 1277 ASSERT_TRUE(vc != nullptr); |
1279 ASSERT_TRUE(vc->description != NULL); | 1278 ASSERT_TRUE(vc->description != nullptr); |
1280 EXPECT_TRUE(vc->rejected); | 1279 EXPECT_TRUE(vc->rejected); |
1281 } | 1280 } |
1282 | 1281 |
1283 // Create an audio-only answer to an offer with data. | 1282 // Create an audio-only answer to an offer with data. |
1284 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateNoDataAnswerToDataOffer) { | 1283 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateNoDataAnswerToDataOffer) { |
1285 MediaSessionOptions opts; | 1284 MediaSessionOptions opts; |
1286 opts.data_channel_type = cricket::DCT_RTP; | 1285 opts.data_channel_type = cricket::DCT_RTP; |
1287 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1286 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1288 ASSERT_TRUE(offer.get() != NULL); | 1287 ASSERT_TRUE(offer.get() != nullptr); |
1289 std::unique_ptr<SessionDescription> answer( | 1288 std::unique_ptr<SessionDescription> answer( |
1290 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 1289 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), nullptr)); |
1291 const ContentInfo* ac = answer->GetContentByName("audio"); | 1290 const ContentInfo* ac = answer->GetContentByName("audio"); |
1292 const ContentInfo* dc = answer->GetContentByName("data"); | 1291 const ContentInfo* dc = answer->GetContentByName("data"); |
1293 ASSERT_TRUE(ac != NULL); | 1292 ASSERT_TRUE(ac != nullptr); |
1294 ASSERT_TRUE(dc != NULL); | 1293 ASSERT_TRUE(dc != nullptr); |
1295 ASSERT_TRUE(dc->description != NULL); | 1294 ASSERT_TRUE(dc->description != nullptr); |
1296 EXPECT_TRUE(dc->rejected); | 1295 EXPECT_TRUE(dc->rejected); |
1297 } | 1296 } |
1298 | 1297 |
1299 // Create an answer that rejects the contents which are rejected in the offer. | 1298 // Create an answer that rejects the contents which are rejected in the offer. |
1300 TEST_F(MediaSessionDescriptionFactoryTest, | 1299 TEST_F(MediaSessionDescriptionFactoryTest, |
1301 CreateAnswerToOfferWithRejectedMedia) { | 1300 CreateAnswerToOfferWithRejectedMedia) { |
1302 MediaSessionOptions opts; | 1301 MediaSessionOptions opts; |
1303 opts.recv_video = true; | 1302 opts.recv_video = true; |
1304 opts.data_channel_type = cricket::DCT_RTP; | 1303 opts.data_channel_type = cricket::DCT_RTP; |
1305 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1304 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1306 ASSERT_TRUE(offer.get() != NULL); | 1305 ASSERT_TRUE(offer.get() != nullptr); |
1307 ContentInfo* ac = offer->GetContentByName("audio"); | 1306 ContentInfo* ac = offer->GetContentByName("audio"); |
1308 ContentInfo* vc = offer->GetContentByName("video"); | 1307 ContentInfo* vc = offer->GetContentByName("video"); |
1309 ContentInfo* dc = offer->GetContentByName("data"); | 1308 ContentInfo* dc = offer->GetContentByName("data"); |
1310 ASSERT_TRUE(ac != NULL); | 1309 ASSERT_TRUE(ac != nullptr); |
1311 ASSERT_TRUE(vc != NULL); | 1310 ASSERT_TRUE(vc != nullptr); |
1312 ASSERT_TRUE(dc != NULL); | 1311 ASSERT_TRUE(dc != nullptr); |
1313 ac->rejected = true; | 1312 ac->rejected = true; |
1314 vc->rejected = true; | 1313 vc->rejected = true; |
1315 dc->rejected = true; | 1314 dc->rejected = true; |
1316 std::unique_ptr<SessionDescription> answer( | 1315 std::unique_ptr<SessionDescription> answer( |
1317 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1316 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
1318 ac = answer->GetContentByName("audio"); | 1317 ac = answer->GetContentByName("audio"); |
1319 vc = answer->GetContentByName("video"); | 1318 vc = answer->GetContentByName("video"); |
1320 dc = answer->GetContentByName("data"); | 1319 dc = answer->GetContentByName("data"); |
1321 ASSERT_TRUE(ac != NULL); | 1320 ASSERT_TRUE(ac != nullptr); |
1322 ASSERT_TRUE(vc != NULL); | 1321 ASSERT_TRUE(vc != nullptr); |
1323 ASSERT_TRUE(dc != NULL); | 1322 ASSERT_TRUE(dc != nullptr); |
1324 EXPECT_TRUE(ac->rejected); | 1323 EXPECT_TRUE(ac->rejected); |
1325 EXPECT_TRUE(vc->rejected); | 1324 EXPECT_TRUE(vc->rejected); |
1326 EXPECT_TRUE(dc->rejected); | 1325 EXPECT_TRUE(dc->rejected); |
1327 } | 1326 } |
1328 | 1327 |
1329 // Create an audio and video offer with: | 1328 // Create an audio and video offer with: |
1330 // - one video track | 1329 // - one video track |
1331 // - two audio tracks | 1330 // - two audio tracks |
1332 // - two data tracks | 1331 // - two data tracks |
1333 // and ensure it matches what we expect. Also updates the initial offer by | 1332 // and ensure it matches what we expect. Also updates the initial offer by |
1334 // adding a new video track and replaces one of the audio tracks. | 1333 // adding a new video track and replaces one of the audio tracks. |
1335 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) { | 1334 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) { |
1336 MediaSessionOptions opts; | 1335 MediaSessionOptions opts; |
1337 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); | 1336 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); |
1338 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 1337 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); |
1339 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2, kMediaStream1); | 1338 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2, kMediaStream1); |
1340 opts.data_channel_type = cricket::DCT_RTP; | 1339 opts.data_channel_type = cricket::DCT_RTP; |
1341 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack1, kMediaStream1); | 1340 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack1, kMediaStream1); |
1342 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack2, kMediaStream1); | 1341 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack2, kMediaStream1); |
1343 | 1342 |
1344 f1_.set_secure(SEC_ENABLED); | 1343 f1_.set_secure(SEC_ENABLED); |
1345 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1344 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1346 | 1345 |
1347 ASSERT_TRUE(offer.get() != NULL); | 1346 ASSERT_TRUE(offer.get() != nullptr); |
1348 const ContentInfo* ac = offer->GetContentByName("audio"); | 1347 const ContentInfo* ac = offer->GetContentByName("audio"); |
1349 const ContentInfo* vc = offer->GetContentByName("video"); | 1348 const ContentInfo* vc = offer->GetContentByName("video"); |
1350 const ContentInfo* dc = offer->GetContentByName("data"); | 1349 const ContentInfo* dc = offer->GetContentByName("data"); |
1351 ASSERT_TRUE(ac != NULL); | 1350 ASSERT_TRUE(ac != nullptr); |
1352 ASSERT_TRUE(vc != NULL); | 1351 ASSERT_TRUE(vc != nullptr); |
1353 ASSERT_TRUE(dc != NULL); | 1352 ASSERT_TRUE(dc != nullptr); |
1354 const AudioContentDescription* acd = | 1353 const AudioContentDescription* acd = |
1355 static_cast<const AudioContentDescription*>(ac->description); | 1354 static_cast<const AudioContentDescription*>(ac->description); |
1356 const VideoContentDescription* vcd = | 1355 const VideoContentDescription* vcd = |
1357 static_cast<const VideoContentDescription*>(vc->description); | 1356 static_cast<const VideoContentDescription*>(vc->description); |
1358 const DataContentDescription* dcd = | 1357 const DataContentDescription* dcd = |
1359 static_cast<const DataContentDescription*>(dc->description); | 1358 static_cast<const DataContentDescription*>(dc->description); |
1360 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 1359 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
1361 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); | 1360 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); |
1362 | 1361 |
1363 const StreamParamsVec& audio_streams = acd->streams(); | 1362 const StreamParamsVec& audio_streams = acd->streams(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 // Update the offer. Add a new video track that is not synched to the | 1407 // Update the offer. Add a new video track that is not synched to the |
1409 // other tracks and replace audio track 2 with audio track 3. | 1408 // other tracks and replace audio track 2 with audio track 3. |
1410 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack2, kMediaStream2); | 1409 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack2, kMediaStream2); |
1411 opts.RemoveSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2); | 1410 opts.RemoveSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2); |
1412 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack3, kMediaStream1); | 1411 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack3, kMediaStream1); |
1413 opts.RemoveSendStream(MEDIA_TYPE_DATA, kDataTrack2); | 1412 opts.RemoveSendStream(MEDIA_TYPE_DATA, kDataTrack2); |
1414 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack3, kMediaStream1); | 1413 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack3, kMediaStream1); |
1415 std::unique_ptr<SessionDescription> updated_offer( | 1414 std::unique_ptr<SessionDescription> updated_offer( |
1416 f1_.CreateOffer(opts, offer.get())); | 1415 f1_.CreateOffer(opts, offer.get())); |
1417 | 1416 |
1418 ASSERT_TRUE(updated_offer.get() != NULL); | 1417 ASSERT_TRUE(updated_offer.get() != nullptr); |
1419 ac = updated_offer->GetContentByName("audio"); | 1418 ac = updated_offer->GetContentByName("audio"); |
1420 vc = updated_offer->GetContentByName("video"); | 1419 vc = updated_offer->GetContentByName("video"); |
1421 dc = updated_offer->GetContentByName("data"); | 1420 dc = updated_offer->GetContentByName("data"); |
1422 ASSERT_TRUE(ac != NULL); | 1421 ASSERT_TRUE(ac != nullptr); |
1423 ASSERT_TRUE(vc != NULL); | 1422 ASSERT_TRUE(vc != nullptr); |
1424 ASSERT_TRUE(dc != NULL); | 1423 ASSERT_TRUE(dc != nullptr); |
1425 const AudioContentDescription* updated_acd = | 1424 const AudioContentDescription* updated_acd = |
1426 static_cast<const AudioContentDescription*>(ac->description); | 1425 static_cast<const AudioContentDescription*>(ac->description); |
1427 const VideoContentDescription* updated_vcd = | 1426 const VideoContentDescription* updated_vcd = |
1428 static_cast<const VideoContentDescription*>(vc->description); | 1427 static_cast<const VideoContentDescription*>(vc->description); |
1429 const DataContentDescription* updated_dcd = | 1428 const DataContentDescription* updated_dcd = |
1430 static_cast<const DataContentDescription*>(dc->description); | 1429 static_cast<const DataContentDescription*>(dc->description); |
1431 | 1430 |
1432 EXPECT_EQ(acd->type(), updated_acd->type()); | 1431 EXPECT_EQ(acd->type(), updated_acd->type()); |
1433 EXPECT_EQ(acd->codecs(), updated_acd->codecs()); | 1432 EXPECT_EQ(acd->codecs(), updated_acd->codecs()); |
1434 EXPECT_EQ(vcd->type(), updated_vcd->type()); | 1433 EXPECT_EQ(vcd->type(), updated_vcd->type()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 // The Expected RTCP CNAME is the default one as we are using the default | 1467 // The Expected RTCP CNAME is the default one as we are using the default |
1469 // MediaSessionOptions. | 1468 // MediaSessionOptions. |
1470 EXPECT_EQ(updated_data_streams[0].cname, cricket::kDefaultRtcpCname); | 1469 EXPECT_EQ(updated_data_streams[0].cname, cricket::kDefaultRtcpCname); |
1471 } | 1470 } |
1472 | 1471 |
1473 // Create an offer with simulcast video stream. | 1472 // Create an offer with simulcast video stream. |
1474 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSimulcastVideoOffer) { | 1473 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSimulcastVideoOffer) { |
1475 MediaSessionOptions opts; | 1474 MediaSessionOptions opts; |
1476 const int num_sim_layers = 3; | 1475 const int num_sim_layers = 3; |
1477 opts.AddSendVideoStream(kVideoTrack1, kMediaStream1, num_sim_layers); | 1476 opts.AddSendVideoStream(kVideoTrack1, kMediaStream1, num_sim_layers); |
1478 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1477 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1479 | 1478 |
1480 ASSERT_TRUE(offer.get() != NULL); | 1479 ASSERT_TRUE(offer.get() != nullptr); |
1481 const ContentInfo* vc = offer->GetContentByName("video"); | 1480 const ContentInfo* vc = offer->GetContentByName("video"); |
1482 ASSERT_TRUE(vc != NULL); | 1481 ASSERT_TRUE(vc != nullptr); |
1483 const VideoContentDescription* vcd = | 1482 const VideoContentDescription* vcd = |
1484 static_cast<const VideoContentDescription*>(vc->description); | 1483 static_cast<const VideoContentDescription*>(vc->description); |
1485 | 1484 |
1486 const StreamParamsVec& video_streams = vcd->streams(); | 1485 const StreamParamsVec& video_streams = vcd->streams(); |
1487 ASSERT_EQ(1U, video_streams.size()); | 1486 ASSERT_EQ(1U, video_streams.size()); |
1488 EXPECT_EQ(kVideoTrack1, video_streams[0].id); | 1487 EXPECT_EQ(kVideoTrack1, video_streams[0].id); |
1489 const SsrcGroup* sim_ssrc_group = | 1488 const SsrcGroup* sim_ssrc_group = |
1490 video_streams[0].get_ssrc_group(cricket::kSimSsrcGroupSemantics); | 1489 video_streams[0].get_ssrc_group(cricket::kSimSsrcGroupSemantics); |
1491 ASSERT_TRUE(sim_ssrc_group != NULL); | 1490 ASSERT_TRUE(sim_ssrc_group != nullptr); |
1492 EXPECT_EQ(static_cast<size_t>(num_sim_layers), sim_ssrc_group->ssrcs.size()); | 1491 EXPECT_EQ(static_cast<size_t>(num_sim_layers), sim_ssrc_group->ssrcs.size()); |
1493 } | 1492 } |
1494 | 1493 |
1495 // Create an audio and video answer to a standard video offer with: | 1494 // Create an audio and video answer to a standard video offer with: |
1496 // - one video track | 1495 // - one video track |
1497 // - two audio tracks | 1496 // - two audio tracks |
1498 // - two data tracks | 1497 // - two data tracks |
1499 // and ensure it matches what we expect. Also updates the initial answer by | 1498 // and ensure it matches what we expect. Also updates the initial answer by |
1500 // adding a new video track and removes one of the audio tracks. | 1499 // adding a new video track and removes one of the audio tracks. |
1501 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) { | 1500 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) { |
1502 MediaSessionOptions offer_opts; | 1501 MediaSessionOptions offer_opts; |
1503 offer_opts.recv_video = true; | 1502 offer_opts.recv_video = true; |
1504 offer_opts.data_channel_type = cricket::DCT_RTP; | 1503 offer_opts.data_channel_type = cricket::DCT_RTP; |
1505 f1_.set_secure(SEC_ENABLED); | 1504 f1_.set_secure(SEC_ENABLED); |
1506 f2_.set_secure(SEC_ENABLED); | 1505 f2_.set_secure(SEC_ENABLED); |
1507 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(offer_opts, NULL)); | 1506 std::unique_ptr<SessionDescription> offer( |
| 1507 f1_.CreateOffer(offer_opts, nullptr)); |
1508 | 1508 |
1509 MediaSessionOptions opts; | 1509 MediaSessionOptions opts; |
1510 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); | 1510 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); |
1511 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 1511 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); |
1512 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2, kMediaStream1); | 1512 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2, kMediaStream1); |
1513 opts.data_channel_type = cricket::DCT_RTP; | 1513 opts.data_channel_type = cricket::DCT_RTP; |
1514 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack1, kMediaStream1); | 1514 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack1, kMediaStream1); |
1515 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack2, kMediaStream1); | 1515 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack2, kMediaStream1); |
1516 | 1516 |
1517 std::unique_ptr<SessionDescription> answer( | 1517 std::unique_ptr<SessionDescription> answer( |
1518 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1518 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
1519 | 1519 |
1520 ASSERT_TRUE(answer.get() != NULL); | 1520 ASSERT_TRUE(answer.get() != nullptr); |
1521 const ContentInfo* ac = answer->GetContentByName("audio"); | 1521 const ContentInfo* ac = answer->GetContentByName("audio"); |
1522 const ContentInfo* vc = answer->GetContentByName("video"); | 1522 const ContentInfo* vc = answer->GetContentByName("video"); |
1523 const ContentInfo* dc = answer->GetContentByName("data"); | 1523 const ContentInfo* dc = answer->GetContentByName("data"); |
1524 ASSERT_TRUE(ac != NULL); | 1524 ASSERT_TRUE(ac != nullptr); |
1525 ASSERT_TRUE(vc != NULL); | 1525 ASSERT_TRUE(vc != nullptr); |
1526 ASSERT_TRUE(dc != NULL); | 1526 ASSERT_TRUE(dc != nullptr); |
1527 const AudioContentDescription* acd = | 1527 const AudioContentDescription* acd = |
1528 static_cast<const AudioContentDescription*>(ac->description); | 1528 static_cast<const AudioContentDescription*>(ac->description); |
1529 const VideoContentDescription* vcd = | 1529 const VideoContentDescription* vcd = |
1530 static_cast<const VideoContentDescription*>(vc->description); | 1530 static_cast<const VideoContentDescription*>(vc->description); |
1531 const DataContentDescription* dcd = | 1531 const DataContentDescription* dcd = |
1532 static_cast<const DataContentDescription*>(dc->description); | 1532 static_cast<const DataContentDescription*>(dc->description); |
1533 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); | 1533 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); |
1534 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 1534 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
1535 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 1535 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
1536 | 1536 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1578 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on | 1578 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on |
1579 | 1579 |
1580 // Update the answer. Add a new video track that is not synched to the | 1580 // Update the answer. Add a new video track that is not synched to the |
1581 // other tracks and remove 1 audio track. | 1581 // other tracks and remove 1 audio track. |
1582 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack2, kMediaStream2); | 1582 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack2, kMediaStream2); |
1583 opts.RemoveSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2); | 1583 opts.RemoveSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2); |
1584 opts.RemoveSendStream(MEDIA_TYPE_DATA, kDataTrack2); | 1584 opts.RemoveSendStream(MEDIA_TYPE_DATA, kDataTrack2); |
1585 std::unique_ptr<SessionDescription> updated_answer( | 1585 std::unique_ptr<SessionDescription> updated_answer( |
1586 f2_.CreateAnswer(offer.get(), opts, answer.get())); | 1586 f2_.CreateAnswer(offer.get(), opts, answer.get())); |
1587 | 1587 |
1588 ASSERT_TRUE(updated_answer.get() != NULL); | 1588 ASSERT_TRUE(updated_answer.get() != nullptr); |
1589 ac = updated_answer->GetContentByName("audio"); | 1589 ac = updated_answer->GetContentByName("audio"); |
1590 vc = updated_answer->GetContentByName("video"); | 1590 vc = updated_answer->GetContentByName("video"); |
1591 dc = updated_answer->GetContentByName("data"); | 1591 dc = updated_answer->GetContentByName("data"); |
1592 ASSERT_TRUE(ac != NULL); | 1592 ASSERT_TRUE(ac != nullptr); |
1593 ASSERT_TRUE(vc != NULL); | 1593 ASSERT_TRUE(vc != nullptr); |
1594 ASSERT_TRUE(dc != NULL); | 1594 ASSERT_TRUE(dc != nullptr); |
1595 const AudioContentDescription* updated_acd = | 1595 const AudioContentDescription* updated_acd = |
1596 static_cast<const AudioContentDescription*>(ac->description); | 1596 static_cast<const AudioContentDescription*>(ac->description); |
1597 const VideoContentDescription* updated_vcd = | 1597 const VideoContentDescription* updated_vcd = |
1598 static_cast<const VideoContentDescription*>(vc->description); | 1598 static_cast<const VideoContentDescription*>(vc->description); |
1599 const DataContentDescription* updated_dcd = | 1599 const DataContentDescription* updated_dcd = |
1600 static_cast<const DataContentDescription*>(dc->description); | 1600 static_cast<const DataContentDescription*>(dc->description); |
1601 | 1601 |
1602 ASSERT_CRYPTO(updated_acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); | 1602 ASSERT_CRYPTO(updated_acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); |
1603 EXPECT_TRUE(CompareCryptoParams(acd->cryptos(), updated_acd->cryptos())); | 1603 EXPECT_TRUE(CompareCryptoParams(acd->cryptos(), updated_acd->cryptos())); |
1604 ASSERT_CRYPTO(updated_vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 1604 ASSERT_CRYPTO(updated_vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
(...skipping 26 matching lines...) Expand all Loading... |
1631 | 1631 |
1632 // Create an updated offer after creating an answer to the original offer and | 1632 // Create an updated offer after creating an answer to the original offer and |
1633 // verify that the codecs that were part of the original answer are not changed | 1633 // verify that the codecs that were part of the original answer are not changed |
1634 // in the updated offer. | 1634 // in the updated offer. |
1635 TEST_F(MediaSessionDescriptionFactoryTest, | 1635 TEST_F(MediaSessionDescriptionFactoryTest, |
1636 RespondentCreatesOfferAfterCreatingAnswer) { | 1636 RespondentCreatesOfferAfterCreatingAnswer) { |
1637 MediaSessionOptions opts; | 1637 MediaSessionOptions opts; |
1638 opts.recv_audio = true; | 1638 opts.recv_audio = true; |
1639 opts.recv_video = true; | 1639 opts.recv_video = true; |
1640 | 1640 |
1641 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1641 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1642 std::unique_ptr<SessionDescription> answer( | 1642 std::unique_ptr<SessionDescription> answer( |
1643 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1643 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
1644 | 1644 |
1645 const AudioContentDescription* acd = | 1645 const AudioContentDescription* acd = |
1646 GetFirstAudioContentDescription(answer.get()); | 1646 GetFirstAudioContentDescription(answer.get()); |
1647 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 1647 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
1648 | 1648 |
1649 const VideoContentDescription* vcd = | 1649 const VideoContentDescription* vcd = |
1650 GetFirstVideoContentDescription(answer.get()); | 1650 GetFirstVideoContentDescription(answer.get()); |
1651 EXPECT_EQ(MAKE_VECTOR(kVideoCodecsAnswer), vcd->codecs()); | 1651 EXPECT_EQ(MAKE_VECTOR(kVideoCodecsAnswer), vcd->codecs()); |
1652 | 1652 |
1653 std::unique_ptr<SessionDescription> updated_offer( | 1653 std::unique_ptr<SessionDescription> updated_offer( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1692 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 1692 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
1693 // This creates rtx for H264 with the payload type |f1_| uses. | 1693 // This creates rtx for H264 with the payload type |f1_| uses. |
1694 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); | 1694 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
1695 f1_.set_video_codecs(f1_codecs); | 1695 f1_.set_video_codecs(f1_codecs); |
1696 | 1696 |
1697 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 1697 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
1698 // This creates rtx for H264 with the payload type |f2_| uses. | 1698 // This creates rtx for H264 with the payload type |f2_| uses. |
1699 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); | 1699 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); |
1700 f2_.set_video_codecs(f2_codecs); | 1700 f2_.set_video_codecs(f2_codecs); |
1701 | 1701 |
1702 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1702 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1703 ASSERT_TRUE(offer.get() != NULL); | 1703 ASSERT_TRUE(offer.get() != nullptr); |
1704 std::unique_ptr<SessionDescription> answer( | 1704 std::unique_ptr<SessionDescription> answer( |
1705 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1705 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
1706 | 1706 |
1707 const VideoContentDescription* vcd = | 1707 const VideoContentDescription* vcd = |
1708 GetFirstVideoContentDescription(answer.get()); | 1708 GetFirstVideoContentDescription(answer.get()); |
1709 | 1709 |
1710 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); | 1710 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); |
1711 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), | 1711 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), |
1712 &expected_codecs); | 1712 &expected_codecs); |
1713 | 1713 |
1714 EXPECT_EQ(expected_codecs, vcd->codecs()); | 1714 EXPECT_EQ(expected_codecs, vcd->codecs()); |
1715 | 1715 |
(...skipping 20 matching lines...) Expand all Loading... |
1736 RespondentCreatesOfferWithVideoAndRtxAfterCreatingAudioAnswer) { | 1736 RespondentCreatesOfferWithVideoAndRtxAfterCreatingAudioAnswer) { |
1737 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 1737 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
1738 // This creates rtx for H264 with the payload type |f1_| uses. | 1738 // This creates rtx for H264 with the payload type |f1_| uses. |
1739 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); | 1739 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
1740 f1_.set_video_codecs(f1_codecs); | 1740 f1_.set_video_codecs(f1_codecs); |
1741 | 1741 |
1742 MediaSessionOptions opts; | 1742 MediaSessionOptions opts; |
1743 opts.recv_audio = true; | 1743 opts.recv_audio = true; |
1744 opts.recv_video = false; | 1744 opts.recv_video = false; |
1745 | 1745 |
1746 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1746 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1747 std::unique_ptr<SessionDescription> answer( | 1747 std::unique_ptr<SessionDescription> answer( |
1748 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1748 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
1749 | 1749 |
1750 const AudioContentDescription* acd = | 1750 const AudioContentDescription* acd = |
1751 GetFirstAudioContentDescription(answer.get()); | 1751 GetFirstAudioContentDescription(answer.get()); |
1752 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 1752 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
1753 | 1753 |
1754 // Now - let |f2_| add video with RTX and let the payload type the RTX codec | 1754 // Now - let |f2_| add video with RTX and let the payload type the RTX codec |
1755 // reference be the same as an audio codec that was negotiated in the | 1755 // reference be the same as an audio codec that was negotiated in the |
1756 // first offer/answer exchange. | 1756 // first offer/answer exchange. |
1757 opts.recv_audio = true; | 1757 opts.recv_audio = true; |
1758 opts.recv_video = true; | 1758 opts.recv_video = true; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1836 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 1836 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
1837 // This creates RTX without associated payload type parameter. | 1837 // This creates RTX without associated payload type parameter. |
1838 AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName), &f1_codecs); | 1838 AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName), &f1_codecs); |
1839 f1_.set_video_codecs(f1_codecs); | 1839 f1_.set_video_codecs(f1_codecs); |
1840 | 1840 |
1841 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 1841 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
1842 // This creates RTX for H264 with the payload type |f2_| uses. | 1842 // This creates RTX for H264 with the payload type |f2_| uses. |
1843 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); | 1843 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); |
1844 f2_.set_video_codecs(f2_codecs); | 1844 f2_.set_video_codecs(f2_codecs); |
1845 | 1845 |
1846 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1846 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1847 ASSERT_TRUE(offer.get() != NULL); | 1847 ASSERT_TRUE(offer.get() != nullptr); |
1848 // kCodecParamAssociatedPayloadType will always be added to the offer when RTX | 1848 // kCodecParamAssociatedPayloadType will always be added to the offer when RTX |
1849 // is selected. Manually remove kCodecParamAssociatedPayloadType so that it | 1849 // is selected. Manually remove kCodecParamAssociatedPayloadType so that it |
1850 // is possible to test that that RTX is dropped when | 1850 // is possible to test that that RTX is dropped when |
1851 // kCodecParamAssociatedPayloadType is missing in the offer. | 1851 // kCodecParamAssociatedPayloadType is missing in the offer. |
1852 VideoContentDescription* desc = | 1852 VideoContentDescription* desc = |
1853 static_cast<cricket::VideoContentDescription*>( | 1853 static_cast<cricket::VideoContentDescription*>( |
1854 offer->GetContentDescriptionByName(cricket::CN_VIDEO)); | 1854 offer->GetContentDescriptionByName(cricket::CN_VIDEO)); |
1855 ASSERT_TRUE(desc != NULL); | 1855 ASSERT_TRUE(desc != nullptr); |
1856 std::vector<VideoCodec> codecs = desc->codecs(); | 1856 std::vector<VideoCodec> codecs = desc->codecs(); |
1857 for (std::vector<VideoCodec>::iterator iter = codecs.begin(); | 1857 for (std::vector<VideoCodec>::iterator iter = codecs.begin(); |
1858 iter != codecs.end(); ++iter) { | 1858 iter != codecs.end(); ++iter) { |
1859 if (iter->name.find(cricket::kRtxCodecName) == 0) { | 1859 if (iter->name.find(cricket::kRtxCodecName) == 0) { |
1860 iter->params.clear(); | 1860 iter->params.clear(); |
1861 } | 1861 } |
1862 } | 1862 } |
1863 desc->set_codecs(codecs); | 1863 desc->set_codecs(codecs); |
1864 | 1864 |
1865 std::unique_ptr<SessionDescription> answer( | 1865 std::unique_ptr<SessionDescription> answer( |
1866 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1866 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
1867 | 1867 |
1868 std::vector<std::string> codec_names = | 1868 std::vector<std::string> codec_names = |
1869 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()); | 1869 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()); |
1870 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(), | 1870 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(), |
1871 cricket::kRtxCodecName)); | 1871 cricket::kRtxCodecName)); |
1872 } | 1872 } |
1873 | 1873 |
1874 // Test that RTX will be filtered out in the answer if its associated payload | 1874 // Test that RTX will be filtered out in the answer if its associated payload |
1875 // type doesn't match the local value. | 1875 // type doesn't match the local value. |
1876 TEST_F(MediaSessionDescriptionFactoryTest, FilterOutRtxIfAptDoesntMatch) { | 1876 TEST_F(MediaSessionDescriptionFactoryTest, FilterOutRtxIfAptDoesntMatch) { |
1877 MediaSessionOptions opts; | 1877 MediaSessionOptions opts; |
1878 opts.recv_video = true; | 1878 opts.recv_video = true; |
1879 opts.recv_audio = false; | 1879 opts.recv_audio = false; |
1880 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 1880 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
1881 // This creates RTX for H264 in sender. | 1881 // This creates RTX for H264 in sender. |
1882 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); | 1882 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
1883 f1_.set_video_codecs(f1_codecs); | 1883 f1_.set_video_codecs(f1_codecs); |
1884 | 1884 |
1885 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 1885 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
1886 // This creates RTX for H263 in receiver. | 1886 // This creates RTX for H263 in receiver. |
1887 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[1].id), &f2_codecs); | 1887 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[1].id), &f2_codecs); |
1888 f2_.set_video_codecs(f2_codecs); | 1888 f2_.set_video_codecs(f2_codecs); |
1889 | 1889 |
1890 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1890 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1891 ASSERT_TRUE(offer.get() != NULL); | 1891 ASSERT_TRUE(offer.get() != nullptr); |
1892 // Associated payload type doesn't match, therefore, RTX codec is removed in | 1892 // Associated payload type doesn't match, therefore, RTX codec is removed in |
1893 // the answer. | 1893 // the answer. |
1894 std::unique_ptr<SessionDescription> answer( | 1894 std::unique_ptr<SessionDescription> answer( |
1895 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1895 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
1896 | 1896 |
1897 std::vector<std::string> codec_names = | 1897 std::vector<std::string> codec_names = |
1898 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()); | 1898 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()); |
1899 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(), | 1899 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(), |
1900 cricket::kRtxCodecName)); | 1900 cricket::kRtxCodecName)); |
1901 } | 1901 } |
1902 | 1902 |
1903 // Test that when multiple RTX codecs are offered, only the matched RTX codec | 1903 // Test that when multiple RTX codecs are offered, only the matched RTX codec |
1904 // is added in the answer, and the unsupported RTX codec is filtered out. | 1904 // is added in the answer, and the unsupported RTX codec is filtered out. |
1905 TEST_F(MediaSessionDescriptionFactoryTest, | 1905 TEST_F(MediaSessionDescriptionFactoryTest, |
(...skipping 10 matching lines...) Expand all Loading... |
1916 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); | 1916 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
1917 f1_.set_video_codecs(f1_codecs); | 1917 f1_.set_video_codecs(f1_codecs); |
1918 | 1918 |
1919 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 1919 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
1920 // This creates RTX for H264 in receiver. | 1920 // This creates RTX for H264 in receiver. |
1921 AddRtxCodec(VideoCodec::CreateRtxCodec(124, kVideoCodecs2[0].id), &f2_codecs); | 1921 AddRtxCodec(VideoCodec::CreateRtxCodec(124, kVideoCodecs2[0].id), &f2_codecs); |
1922 f2_.set_video_codecs(f2_codecs); | 1922 f2_.set_video_codecs(f2_codecs); |
1923 | 1923 |
1924 // H264-SVC codec is removed in the answer, therefore, associated RTX codec | 1924 // H264-SVC codec is removed in the answer, therefore, associated RTX codec |
1925 // for H264-SVC should also be removed. | 1925 // for H264-SVC should also be removed. |
1926 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1926 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1927 ASSERT_TRUE(offer.get() != NULL); | 1927 ASSERT_TRUE(offer.get() != nullptr); |
1928 std::unique_ptr<SessionDescription> answer( | 1928 std::unique_ptr<SessionDescription> answer( |
1929 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1929 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
1930 const VideoContentDescription* vcd = | 1930 const VideoContentDescription* vcd = |
1931 GetFirstVideoContentDescription(answer.get()); | 1931 GetFirstVideoContentDescription(answer.get()); |
1932 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); | 1932 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); |
1933 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), | 1933 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), |
1934 &expected_codecs); | 1934 &expected_codecs); |
1935 | 1935 |
1936 EXPECT_EQ(expected_codecs, vcd->codecs()); | 1936 EXPECT_EQ(expected_codecs, vcd->codecs()); |
1937 } | 1937 } |
1938 | 1938 |
1939 // Test that after one RTX codec has been negotiated, a new offer can attempt | 1939 // Test that after one RTX codec has been negotiated, a new offer can attempt |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1982 opts.AddSendVideoStream("stream1", "stream1label", 3); | 1982 opts.AddSendVideoStream("stream1", "stream1label", 3); |
1983 | 1983 |
1984 // Use a single real codec, and then add RTX for it. | 1984 // Use a single real codec, and then add RTX for it. |
1985 std::vector<VideoCodec> f1_codecs; | 1985 std::vector<VideoCodec> f1_codecs; |
1986 f1_codecs.push_back(VideoCodec(97, "H264")); | 1986 f1_codecs.push_back(VideoCodec(97, "H264")); |
1987 AddRtxCodec(VideoCodec::CreateRtxCodec(125, 97), &f1_codecs); | 1987 AddRtxCodec(VideoCodec::CreateRtxCodec(125, 97), &f1_codecs); |
1988 f1_.set_video_codecs(f1_codecs); | 1988 f1_.set_video_codecs(f1_codecs); |
1989 | 1989 |
1990 // Ensure that the offer has an RTX ssrc for each regular ssrc, and that there | 1990 // Ensure that the offer has an RTX ssrc for each regular ssrc, and that there |
1991 // is a FID ssrc + grouping for each. | 1991 // is a FID ssrc + grouping for each. |
1992 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1992 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
1993 ASSERT_TRUE(offer.get() != NULL); | 1993 ASSERT_TRUE(offer.get() != nullptr); |
1994 VideoContentDescription* desc = static_cast<VideoContentDescription*>( | 1994 VideoContentDescription* desc = static_cast<VideoContentDescription*>( |
1995 offer->GetContentDescriptionByName(cricket::CN_VIDEO)); | 1995 offer->GetContentDescriptionByName(cricket::CN_VIDEO)); |
1996 ASSERT_TRUE(desc != NULL); | 1996 ASSERT_TRUE(desc != nullptr); |
1997 EXPECT_TRUE(desc->multistream()); | 1997 EXPECT_TRUE(desc->multistream()); |
1998 const StreamParamsVec& streams = desc->streams(); | 1998 const StreamParamsVec& streams = desc->streams(); |
1999 // Single stream. | 1999 // Single stream. |
2000 ASSERT_EQ(1u, streams.size()); | 2000 ASSERT_EQ(1u, streams.size()); |
2001 // Stream should have 6 ssrcs: 3 for video, 3 for RTX. | 2001 // Stream should have 6 ssrcs: 3 for video, 3 for RTX. |
2002 EXPECT_EQ(6u, streams[0].ssrcs.size()); | 2002 EXPECT_EQ(6u, streams[0].ssrcs.size()); |
2003 // And should have a SIM group for the simulcast. | 2003 // And should have a SIM group for the simulcast. |
2004 EXPECT_TRUE(streams[0].has_ssrc_group("SIM")); | 2004 EXPECT_TRUE(streams[0].has_ssrc_group("SIM")); |
2005 // And a FID group for RTX. | 2005 // And a FID group for RTX. |
2006 EXPECT_TRUE(streams[0].has_ssrc_group("FID")); | 2006 EXPECT_TRUE(streams[0].has_ssrc_group("FID")); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2101 RespondentCreatesOfferAfterCreatingAnswerWithRtpExtensions) { | 2101 RespondentCreatesOfferAfterCreatingAnswerWithRtpExtensions) { |
2102 MediaSessionOptions opts; | 2102 MediaSessionOptions opts; |
2103 opts.recv_audio = true; | 2103 opts.recv_audio = true; |
2104 opts.recv_video = true; | 2104 opts.recv_video = true; |
2105 | 2105 |
2106 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); | 2106 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); |
2107 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); | 2107 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); |
2108 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); | 2108 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); |
2109 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); | 2109 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); |
2110 | 2110 |
2111 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 2111 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
2112 std::unique_ptr<SessionDescription> answer( | 2112 std::unique_ptr<SessionDescription> answer( |
2113 f2_.CreateAnswer(offer.get(), opts, NULL)); | 2113 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
2114 | 2114 |
2115 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), | 2115 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), |
2116 GetFirstAudioContentDescription( | 2116 GetFirstAudioContentDescription( |
2117 answer.get())->rtp_header_extensions()); | 2117 answer.get())->rtp_header_extensions()); |
2118 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), | 2118 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), |
2119 GetFirstVideoContentDescription( | 2119 GetFirstVideoContentDescription( |
2120 answer.get())->rtp_header_extensions()); | 2120 answer.get())->rtp_header_extensions()); |
2121 | 2121 |
2122 std::unique_ptr<SessionDescription> updated_offer( | 2122 std::unique_ptr<SessionDescription> updated_offer( |
2123 f2_.CreateOffer(opts, answer.get())); | 2123 f2_.CreateOffer(opts, answer.get())); |
(...skipping 30 matching lines...) Expand all Loading... |
2154 // same ID is used. Also verify that the ID isn't changed when creating an | 2154 // same ID is used. Also verify that the ID isn't changed when creating an |
2155 // updated offer (this was previously a bug). | 2155 // updated offer (this was previously a bug). |
2156 TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReused) { | 2156 TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReused) { |
2157 MediaSessionOptions opts; | 2157 MediaSessionOptions opts; |
2158 opts.recv_audio = true; | 2158 opts.recv_audio = true; |
2159 opts.recv_video = true; | 2159 opts.recv_video = true; |
2160 | 2160 |
2161 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension3)); | 2161 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension3)); |
2162 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension3)); | 2162 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension3)); |
2163 | 2163 |
2164 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 2164 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
2165 | 2165 |
2166 // Since the audio extensions used ID 3 for "both_audio_and_video", so should | 2166 // Since the audio extensions used ID 3 for "both_audio_and_video", so should |
2167 // the video extensions. | 2167 // the video extensions. |
2168 const RtpExtension kExpectedVideoRtpExtension[] = { | 2168 const RtpExtension kExpectedVideoRtpExtension[] = { |
2169 kVideoRtpExtension3[0], kAudioRtpExtension3[1], | 2169 kVideoRtpExtension3[0], kAudioRtpExtension3[1], |
2170 }; | 2170 }; |
2171 | 2171 |
2172 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3), | 2172 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3), |
2173 GetFirstAudioContentDescription( | 2173 GetFirstAudioContentDescription( |
2174 offer.get())->rtp_header_extensions()); | 2174 offer.get())->rtp_header_extensions()); |
(...skipping 20 matching lines...) Expand all Loading... |
2195 AudioContentDescription* acd(new AudioContentDescription()); | 2195 AudioContentDescription* acd(new AudioContentDescription()); |
2196 acd->set_codecs(MAKE_VECTOR(kAudioCodecs1)); | 2196 acd->set_codecs(MAKE_VECTOR(kAudioCodecs1)); |
2197 acd->AddLegacyStream(1); | 2197 acd->AddLegacyStream(1); |
2198 source.AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP, acd); | 2198 source.AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP, acd); |
2199 VideoContentDescription* vcd(new VideoContentDescription()); | 2199 VideoContentDescription* vcd(new VideoContentDescription()); |
2200 vcd->set_codecs(MAKE_VECTOR(kVideoCodecs1)); | 2200 vcd->set_codecs(MAKE_VECTOR(kVideoCodecs1)); |
2201 vcd->AddLegacyStream(2); | 2201 vcd->AddLegacyStream(2); |
2202 source.AddContent(cricket::CN_VIDEO, cricket::NS_JINGLE_RTP, vcd); | 2202 source.AddContent(cricket::CN_VIDEO, cricket::NS_JINGLE_RTP, vcd); |
2203 | 2203 |
2204 std::unique_ptr<SessionDescription> copy(source.Copy()); | 2204 std::unique_ptr<SessionDescription> copy(source.Copy()); |
2205 ASSERT_TRUE(copy.get() != NULL); | 2205 ASSERT_TRUE(copy.get() != nullptr); |
2206 EXPECT_TRUE(copy->HasGroup(cricket::CN_AUDIO)); | 2206 EXPECT_TRUE(copy->HasGroup(cricket::CN_AUDIO)); |
2207 const ContentInfo* ac = copy->GetContentByName("audio"); | 2207 const ContentInfo* ac = copy->GetContentByName("audio"); |
2208 const ContentInfo* vc = copy->GetContentByName("video"); | 2208 const ContentInfo* vc = copy->GetContentByName("video"); |
2209 ASSERT_TRUE(ac != NULL); | 2209 ASSERT_TRUE(ac != nullptr); |
2210 ASSERT_TRUE(vc != NULL); | 2210 ASSERT_TRUE(vc != nullptr); |
2211 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 2211 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
2212 const AudioContentDescription* acd_copy = | 2212 const AudioContentDescription* acd_copy = |
2213 static_cast<const AudioContentDescription*>(ac->description); | 2213 static_cast<const AudioContentDescription*>(ac->description); |
2214 EXPECT_EQ(acd->codecs(), acd_copy->codecs()); | 2214 EXPECT_EQ(acd->codecs(), acd_copy->codecs()); |
2215 EXPECT_EQ(1u, acd->first_ssrc()); | 2215 EXPECT_EQ(1u, acd->first_ssrc()); |
2216 | 2216 |
2217 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 2217 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); |
2218 const VideoContentDescription* vcd_copy = | 2218 const VideoContentDescription* vcd_copy = |
2219 static_cast<const VideoContentDescription*>(vc->description); | 2219 static_cast<const VideoContentDescription*>(vc->description); |
2220 EXPECT_EQ(vcd->codecs(), vcd_copy->codecs()); | 2220 EXPECT_EQ(vcd->codecs(), vcd_copy->codecs()); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2349 // Verifies that creating answer fails if the offer has UDP/TLS/RTP/SAVPF but | 2349 // Verifies that creating answer fails if the offer has UDP/TLS/RTP/SAVPF but |
2350 // DTLS is not enabled locally. | 2350 // DTLS is not enabled locally. |
2351 TEST_F(MediaSessionDescriptionFactoryTest, | 2351 TEST_F(MediaSessionDescriptionFactoryTest, |
2352 TestOfferDtlsSavpfWithoutDtlsFailed) { | 2352 TestOfferDtlsSavpfWithoutDtlsFailed) { |
2353 f1_.set_secure(SEC_ENABLED); | 2353 f1_.set_secure(SEC_ENABLED); |
2354 f2_.set_secure(SEC_ENABLED); | 2354 f2_.set_secure(SEC_ENABLED); |
2355 tdf1_.set_secure(SEC_DISABLED); | 2355 tdf1_.set_secure(SEC_DISABLED); |
2356 tdf2_.set_secure(SEC_DISABLED); | 2356 tdf2_.set_secure(SEC_DISABLED); |
2357 | 2357 |
2358 std::unique_ptr<SessionDescription> offer( | 2358 std::unique_ptr<SessionDescription> offer( |
2359 f1_.CreateOffer(MediaSessionOptions(), NULL)); | 2359 f1_.CreateOffer(MediaSessionOptions(), nullptr)); |
2360 ASSERT_TRUE(offer.get() != NULL); | 2360 ASSERT_TRUE(offer.get() != nullptr); |
2361 ContentInfo* offer_content = offer->GetContentByName("audio"); | 2361 ContentInfo* offer_content = offer->GetContentByName("audio"); |
2362 ASSERT_TRUE(offer_content != NULL); | 2362 ASSERT_TRUE(offer_content != nullptr); |
2363 AudioContentDescription* offer_audio_desc = | 2363 AudioContentDescription* offer_audio_desc = |
2364 static_cast<AudioContentDescription*>(offer_content->description); | 2364 static_cast<AudioContentDescription*>(offer_content->description); |
2365 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf); | 2365 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf); |
2366 | 2366 |
2367 std::unique_ptr<SessionDescription> answer( | 2367 std::unique_ptr<SessionDescription> answer( |
2368 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 2368 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), nullptr)); |
2369 ASSERT_TRUE(answer != NULL); | 2369 ASSERT_TRUE(answer != nullptr); |
2370 ContentInfo* answer_content = answer->GetContentByName("audio"); | 2370 ContentInfo* answer_content = answer->GetContentByName("audio"); |
2371 ASSERT_TRUE(answer_content != NULL); | 2371 ASSERT_TRUE(answer_content != nullptr); |
2372 | 2372 |
2373 ASSERT_TRUE(answer_content->rejected); | 2373 ASSERT_TRUE(answer_content->rejected); |
2374 } | 2374 } |
2375 | 2375 |
2376 // Offers UDP/TLS/RTP/SAVPF and verifies the answer can be created and contains | 2376 // Offers UDP/TLS/RTP/SAVPF and verifies the answer can be created and contains |
2377 // UDP/TLS/RTP/SAVPF. | 2377 // UDP/TLS/RTP/SAVPF. |
2378 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) { | 2378 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) { |
2379 f1_.set_secure(SEC_ENABLED); | 2379 f1_.set_secure(SEC_ENABLED); |
2380 f2_.set_secure(SEC_ENABLED); | 2380 f2_.set_secure(SEC_ENABLED); |
2381 tdf1_.set_secure(SEC_ENABLED); | 2381 tdf1_.set_secure(SEC_ENABLED); |
2382 tdf2_.set_secure(SEC_ENABLED); | 2382 tdf2_.set_secure(SEC_ENABLED); |
2383 | 2383 |
2384 std::unique_ptr<SessionDescription> offer( | 2384 std::unique_ptr<SessionDescription> offer( |
2385 f1_.CreateOffer(MediaSessionOptions(), NULL)); | 2385 f1_.CreateOffer(MediaSessionOptions(), nullptr)); |
2386 ASSERT_TRUE(offer.get() != NULL); | 2386 ASSERT_TRUE(offer.get() != nullptr); |
2387 ContentInfo* offer_content = offer->GetContentByName("audio"); | 2387 ContentInfo* offer_content = offer->GetContentByName("audio"); |
2388 ASSERT_TRUE(offer_content != NULL); | 2388 ASSERT_TRUE(offer_content != nullptr); |
2389 AudioContentDescription* offer_audio_desc = | 2389 AudioContentDescription* offer_audio_desc = |
2390 static_cast<AudioContentDescription*>(offer_content->description); | 2390 static_cast<AudioContentDescription*>(offer_content->description); |
2391 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf); | 2391 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf); |
2392 | 2392 |
2393 std::unique_ptr<SessionDescription> answer( | 2393 std::unique_ptr<SessionDescription> answer( |
2394 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 2394 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), nullptr)); |
2395 ASSERT_TRUE(answer != NULL); | 2395 ASSERT_TRUE(answer != nullptr); |
2396 | 2396 |
2397 const ContentInfo* answer_content = answer->GetContentByName("audio"); | 2397 const ContentInfo* answer_content = answer->GetContentByName("audio"); |
2398 ASSERT_TRUE(answer_content != NULL); | 2398 ASSERT_TRUE(answer_content != nullptr); |
2399 ASSERT_FALSE(answer_content->rejected); | 2399 ASSERT_FALSE(answer_content->rejected); |
2400 | 2400 |
2401 const AudioContentDescription* answer_audio_desc = | 2401 const AudioContentDescription* answer_audio_desc = |
2402 static_cast<const AudioContentDescription*>(answer_content->description); | 2402 static_cast<const AudioContentDescription*>(answer_content->description); |
2403 EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf), | 2403 EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf), |
2404 answer_audio_desc->protocol()); | 2404 answer_audio_desc->protocol()); |
2405 } | 2405 } |
2406 | 2406 |
2407 // Test that we include both SDES and DTLS in the offer, but only include SDES | 2407 // Test that we include both SDES and DTLS in the offer, but only include SDES |
2408 // in the answer if DTLS isn't negotiated. | 2408 // in the answer if DTLS isn't negotiated. |
2409 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoDtls) { | 2409 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoDtls) { |
2410 f1_.set_secure(SEC_ENABLED); | 2410 f1_.set_secure(SEC_ENABLED); |
2411 f2_.set_secure(SEC_ENABLED); | 2411 f2_.set_secure(SEC_ENABLED); |
2412 tdf1_.set_secure(SEC_ENABLED); | 2412 tdf1_.set_secure(SEC_ENABLED); |
2413 tdf2_.set_secure(SEC_DISABLED); | 2413 tdf2_.set_secure(SEC_DISABLED); |
2414 MediaSessionOptions options; | 2414 MediaSessionOptions options; |
2415 options.recv_audio = true; | 2415 options.recv_audio = true; |
2416 options.recv_video = true; | 2416 options.recv_video = true; |
2417 std::unique_ptr<SessionDescription> offer, answer; | 2417 std::unique_ptr<SessionDescription> offer, answer; |
2418 const cricket::MediaContentDescription* audio_media_desc; | 2418 const cricket::MediaContentDescription* audio_media_desc; |
2419 const cricket::MediaContentDescription* video_media_desc; | 2419 const cricket::MediaContentDescription* video_media_desc; |
2420 const cricket::TransportDescription* audio_trans_desc; | 2420 const cricket::TransportDescription* audio_trans_desc; |
2421 const cricket::TransportDescription* video_trans_desc; | 2421 const cricket::TransportDescription* video_trans_desc; |
2422 | 2422 |
2423 // Generate an offer with SDES and DTLS support. | 2423 // Generate an offer with SDES and DTLS support. |
2424 offer.reset(f1_.CreateOffer(options, NULL)); | 2424 offer.reset(f1_.CreateOffer(options, nullptr)); |
2425 ASSERT_TRUE(offer.get() != NULL); | 2425 ASSERT_TRUE(offer.get() != nullptr); |
2426 | 2426 |
2427 audio_media_desc = static_cast<const cricket::MediaContentDescription*>( | 2427 audio_media_desc = static_cast<const cricket::MediaContentDescription*>( |
2428 offer->GetContentDescriptionByName("audio")); | 2428 offer->GetContentDescriptionByName("audio")); |
2429 ASSERT_TRUE(audio_media_desc != NULL); | 2429 ASSERT_TRUE(audio_media_desc != nullptr); |
2430 video_media_desc = static_cast<const cricket::MediaContentDescription*>( | 2430 video_media_desc = static_cast<const cricket::MediaContentDescription*>( |
2431 offer->GetContentDescriptionByName("video")); | 2431 offer->GetContentDescriptionByName("video")); |
2432 ASSERT_TRUE(video_media_desc != NULL); | 2432 ASSERT_TRUE(video_media_desc != nullptr); |
2433 EXPECT_EQ(2u, audio_media_desc->cryptos().size()); | 2433 EXPECT_EQ(2u, audio_media_desc->cryptos().size()); |
2434 EXPECT_EQ(1u, video_media_desc->cryptos().size()); | 2434 EXPECT_EQ(1u, video_media_desc->cryptos().size()); |
2435 | 2435 |
2436 audio_trans_desc = offer->GetTransportDescriptionByName("audio"); | 2436 audio_trans_desc = offer->GetTransportDescriptionByName("audio"); |
2437 ASSERT_TRUE(audio_trans_desc != NULL); | 2437 ASSERT_TRUE(audio_trans_desc != nullptr); |
2438 video_trans_desc = offer->GetTransportDescriptionByName("video"); | 2438 video_trans_desc = offer->GetTransportDescriptionByName("video"); |
2439 ASSERT_TRUE(video_trans_desc != NULL); | 2439 ASSERT_TRUE(video_trans_desc != nullptr); |
2440 ASSERT_TRUE(audio_trans_desc->identity_fingerprint.get() != NULL); | 2440 ASSERT_TRUE(audio_trans_desc->identity_fingerprint.get() != nullptr); |
2441 ASSERT_TRUE(video_trans_desc->identity_fingerprint.get() != NULL); | 2441 ASSERT_TRUE(video_trans_desc->identity_fingerprint.get() != nullptr); |
2442 | 2442 |
2443 // Generate an answer with only SDES support, since tdf2 has crypto disabled. | 2443 // Generate an answer with only SDES support, since tdf2 has crypto disabled. |
2444 answer.reset(f2_.CreateAnswer(offer.get(), options, NULL)); | 2444 answer.reset(f2_.CreateAnswer(offer.get(), options, nullptr)); |
2445 ASSERT_TRUE(answer.get() != NULL); | 2445 ASSERT_TRUE(answer.get() != nullptr); |
2446 | 2446 |
2447 audio_media_desc = static_cast<const cricket::MediaContentDescription*>( | 2447 audio_media_desc = static_cast<const cricket::MediaContentDescription*>( |
2448 answer->GetContentDescriptionByName("audio")); | 2448 answer->GetContentDescriptionByName("audio")); |
2449 ASSERT_TRUE(audio_media_desc != NULL); | 2449 ASSERT_TRUE(audio_media_desc != nullptr); |
2450 video_media_desc = static_cast<const cricket::MediaContentDescription*>( | 2450 video_media_desc = static_cast<const cricket::MediaContentDescription*>( |
2451 answer->GetContentDescriptionByName("video")); | 2451 answer->GetContentDescriptionByName("video")); |
2452 ASSERT_TRUE(video_media_desc != NULL); | 2452 ASSERT_TRUE(video_media_desc != nullptr); |
2453 EXPECT_EQ(1u, audio_media_desc->cryptos().size()); | 2453 EXPECT_EQ(1u, audio_media_desc->cryptos().size()); |
2454 EXPECT_EQ(1u, video_media_desc->cryptos().size()); | 2454 EXPECT_EQ(1u, video_media_desc->cryptos().size()); |
2455 | 2455 |
2456 audio_trans_desc = answer->GetTransportDescriptionByName("audio"); | 2456 audio_trans_desc = answer->GetTransportDescriptionByName("audio"); |
2457 ASSERT_TRUE(audio_trans_desc != NULL); | 2457 ASSERT_TRUE(audio_trans_desc != nullptr); |
2458 video_trans_desc = answer->GetTransportDescriptionByName("video"); | 2458 video_trans_desc = answer->GetTransportDescriptionByName("video"); |
2459 ASSERT_TRUE(video_trans_desc != NULL); | 2459 ASSERT_TRUE(video_trans_desc != nullptr); |
2460 ASSERT_TRUE(audio_trans_desc->identity_fingerprint.get() == NULL); | 2460 ASSERT_TRUE(audio_trans_desc->identity_fingerprint.get() == nullptr); |
2461 ASSERT_TRUE(video_trans_desc->identity_fingerprint.get() == NULL); | 2461 ASSERT_TRUE(video_trans_desc->identity_fingerprint.get() == nullptr); |
2462 | 2462 |
2463 // Enable DTLS; the answer should now only have DTLS support. | 2463 // Enable DTLS; the answer should now only have DTLS support. |
2464 tdf2_.set_secure(SEC_ENABLED); | 2464 tdf2_.set_secure(SEC_ENABLED); |
2465 answer.reset(f2_.CreateAnswer(offer.get(), options, NULL)); | 2465 answer.reset(f2_.CreateAnswer(offer.get(), options, nullptr)); |
2466 ASSERT_TRUE(answer.get() != NULL); | 2466 ASSERT_TRUE(answer.get() != nullptr); |
2467 | 2467 |
2468 audio_media_desc = static_cast<const cricket::MediaContentDescription*>( | 2468 audio_media_desc = static_cast<const cricket::MediaContentDescription*>( |
2469 answer->GetContentDescriptionByName("audio")); | 2469 answer->GetContentDescriptionByName("audio")); |
2470 ASSERT_TRUE(audio_media_desc != NULL); | 2470 ASSERT_TRUE(audio_media_desc != nullptr); |
2471 video_media_desc = static_cast<const cricket::MediaContentDescription*>( | 2471 video_media_desc = static_cast<const cricket::MediaContentDescription*>( |
2472 answer->GetContentDescriptionByName("video")); | 2472 answer->GetContentDescriptionByName("video")); |
2473 ASSERT_TRUE(video_media_desc != NULL); | 2473 ASSERT_TRUE(video_media_desc != nullptr); |
2474 EXPECT_TRUE(audio_media_desc->cryptos().empty()); | 2474 EXPECT_TRUE(audio_media_desc->cryptos().empty()); |
2475 EXPECT_TRUE(video_media_desc->cryptos().empty()); | 2475 EXPECT_TRUE(video_media_desc->cryptos().empty()); |
2476 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), | 2476 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), |
2477 audio_media_desc->protocol()); | 2477 audio_media_desc->protocol()); |
2478 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), | 2478 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), |
2479 video_media_desc->protocol()); | 2479 video_media_desc->protocol()); |
2480 | 2480 |
2481 audio_trans_desc = answer->GetTransportDescriptionByName("audio"); | 2481 audio_trans_desc = answer->GetTransportDescriptionByName("audio"); |
2482 ASSERT_TRUE(audio_trans_desc != NULL); | 2482 ASSERT_TRUE(audio_trans_desc != nullptr); |
2483 video_trans_desc = answer->GetTransportDescriptionByName("video"); | 2483 video_trans_desc = answer->GetTransportDescriptionByName("video"); |
2484 ASSERT_TRUE(video_trans_desc != NULL); | 2484 ASSERT_TRUE(video_trans_desc != nullptr); |
2485 ASSERT_TRUE(audio_trans_desc->identity_fingerprint.get() != NULL); | 2485 ASSERT_TRUE(audio_trans_desc->identity_fingerprint.get() != nullptr); |
2486 ASSERT_TRUE(video_trans_desc->identity_fingerprint.get() != NULL); | 2486 ASSERT_TRUE(video_trans_desc->identity_fingerprint.get() != nullptr); |
2487 | 2487 |
2488 // Try creating offer again. DTLS enabled now, crypto's should be empty | 2488 // Try creating offer again. DTLS enabled now, crypto's should be empty |
2489 // in new offer. | 2489 // in new offer. |
2490 offer.reset(f1_.CreateOffer(options, offer.get())); | 2490 offer.reset(f1_.CreateOffer(options, offer.get())); |
2491 ASSERT_TRUE(offer.get() != NULL); | 2491 ASSERT_TRUE(offer.get() != nullptr); |
2492 audio_media_desc = static_cast<const cricket::MediaContentDescription*>( | 2492 audio_media_desc = static_cast<const cricket::MediaContentDescription*>( |
2493 offer->GetContentDescriptionByName("audio")); | 2493 offer->GetContentDescriptionByName("audio")); |
2494 ASSERT_TRUE(audio_media_desc != NULL); | 2494 ASSERT_TRUE(audio_media_desc != nullptr); |
2495 video_media_desc = static_cast<const cricket::MediaContentDescription*>( | 2495 video_media_desc = static_cast<const cricket::MediaContentDescription*>( |
2496 offer->GetContentDescriptionByName("video")); | 2496 offer->GetContentDescriptionByName("video")); |
2497 ASSERT_TRUE(video_media_desc != NULL); | 2497 ASSERT_TRUE(video_media_desc != nullptr); |
2498 EXPECT_TRUE(audio_media_desc->cryptos().empty()); | 2498 EXPECT_TRUE(audio_media_desc->cryptos().empty()); |
2499 EXPECT_TRUE(video_media_desc->cryptos().empty()); | 2499 EXPECT_TRUE(video_media_desc->cryptos().empty()); |
2500 | 2500 |
2501 audio_trans_desc = offer->GetTransportDescriptionByName("audio"); | 2501 audio_trans_desc = offer->GetTransportDescriptionByName("audio"); |
2502 ASSERT_TRUE(audio_trans_desc != NULL); | 2502 ASSERT_TRUE(audio_trans_desc != nullptr); |
2503 video_trans_desc = offer->GetTransportDescriptionByName("video"); | 2503 video_trans_desc = offer->GetTransportDescriptionByName("video"); |
2504 ASSERT_TRUE(video_trans_desc != NULL); | 2504 ASSERT_TRUE(video_trans_desc != nullptr); |
2505 ASSERT_TRUE(audio_trans_desc->identity_fingerprint.get() != NULL); | 2505 ASSERT_TRUE(audio_trans_desc->identity_fingerprint.get() != nullptr); |
2506 ASSERT_TRUE(video_trans_desc->identity_fingerprint.get() != NULL); | 2506 ASSERT_TRUE(video_trans_desc->identity_fingerprint.get() != nullptr); |
2507 } | 2507 } |
2508 | 2508 |
2509 // Test that an answer can't be created if cryptos are required but the offer is | 2509 // Test that an answer can't be created if cryptos are required but the offer is |
2510 // unsecure. | 2510 // unsecure. |
2511 TEST_F(MediaSessionDescriptionFactoryTest, TestSecureAnswerToUnsecureOffer) { | 2511 TEST_F(MediaSessionDescriptionFactoryTest, TestSecureAnswerToUnsecureOffer) { |
2512 MediaSessionOptions options; | 2512 MediaSessionOptions options; |
2513 f1_.set_secure(SEC_DISABLED); | 2513 f1_.set_secure(SEC_DISABLED); |
2514 tdf1_.set_secure(SEC_DISABLED); | 2514 tdf1_.set_secure(SEC_DISABLED); |
2515 f2_.set_secure(SEC_REQUIRED); | 2515 f2_.set_secure(SEC_REQUIRED); |
2516 tdf1_.set_secure(SEC_ENABLED); | 2516 tdf1_.set_secure(SEC_ENABLED); |
2517 | 2517 |
2518 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL)); | 2518 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, nullptr)); |
2519 ASSERT_TRUE(offer.get() != NULL); | 2519 ASSERT_TRUE(offer.get() != nullptr); |
2520 std::unique_ptr<SessionDescription> answer( | 2520 std::unique_ptr<SessionDescription> answer( |
2521 f2_.CreateAnswer(offer.get(), options, NULL)); | 2521 f2_.CreateAnswer(offer.get(), options, nullptr)); |
2522 EXPECT_TRUE(answer.get() == NULL); | 2522 EXPECT_TRUE(answer.get() == nullptr); |
2523 } | 2523 } |
2524 | 2524 |
2525 // Test that we accept a DTLS offer without SDES and create an appropriate | 2525 // Test that we accept a DTLS offer without SDES and create an appropriate |
2526 // answer. | 2526 // answer. |
2527 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoOfferDtlsButNotSdes) { | 2527 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoOfferDtlsButNotSdes) { |
2528 f1_.set_secure(SEC_DISABLED); | 2528 f1_.set_secure(SEC_DISABLED); |
2529 f2_.set_secure(SEC_ENABLED); | 2529 f2_.set_secure(SEC_ENABLED); |
2530 tdf1_.set_secure(SEC_ENABLED); | 2530 tdf1_.set_secure(SEC_ENABLED); |
2531 tdf2_.set_secure(SEC_ENABLED); | 2531 tdf2_.set_secure(SEC_ENABLED); |
2532 MediaSessionOptions options; | 2532 MediaSessionOptions options; |
2533 options.recv_audio = true; | 2533 options.recv_audio = true; |
2534 options.recv_video = true; | 2534 options.recv_video = true; |
2535 options.data_channel_type = cricket::DCT_RTP; | 2535 options.data_channel_type = cricket::DCT_RTP; |
2536 | 2536 |
2537 std::unique_ptr<SessionDescription> offer, answer; | 2537 std::unique_ptr<SessionDescription> offer, answer; |
2538 | 2538 |
2539 // Generate an offer with DTLS but without SDES. | 2539 // Generate an offer with DTLS but without SDES. |
2540 offer.reset(f1_.CreateOffer(options, NULL)); | 2540 offer.reset(f1_.CreateOffer(options, nullptr)); |
2541 ASSERT_TRUE(offer.get() != NULL); | 2541 ASSERT_TRUE(offer.get() != nullptr); |
2542 | 2542 |
2543 const AudioContentDescription* audio_offer = | 2543 const AudioContentDescription* audio_offer = |
2544 GetFirstAudioContentDescription(offer.get()); | 2544 GetFirstAudioContentDescription(offer.get()); |
2545 ASSERT_TRUE(audio_offer->cryptos().empty()); | 2545 ASSERT_TRUE(audio_offer->cryptos().empty()); |
2546 const VideoContentDescription* video_offer = | 2546 const VideoContentDescription* video_offer = |
2547 GetFirstVideoContentDescription(offer.get()); | 2547 GetFirstVideoContentDescription(offer.get()); |
2548 ASSERT_TRUE(video_offer->cryptos().empty()); | 2548 ASSERT_TRUE(video_offer->cryptos().empty()); |
2549 const DataContentDescription* data_offer = | 2549 const DataContentDescription* data_offer = |
2550 GetFirstDataContentDescription(offer.get()); | 2550 GetFirstDataContentDescription(offer.get()); |
2551 ASSERT_TRUE(data_offer->cryptos().empty()); | 2551 ASSERT_TRUE(data_offer->cryptos().empty()); |
2552 | 2552 |
2553 const cricket::TransportDescription* audio_offer_trans_desc = | 2553 const cricket::TransportDescription* audio_offer_trans_desc = |
2554 offer->GetTransportDescriptionByName("audio"); | 2554 offer->GetTransportDescriptionByName("audio"); |
2555 ASSERT_TRUE(audio_offer_trans_desc->identity_fingerprint.get() != NULL); | 2555 ASSERT_TRUE(audio_offer_trans_desc->identity_fingerprint.get() != nullptr); |
2556 const cricket::TransportDescription* video_offer_trans_desc = | 2556 const cricket::TransportDescription* video_offer_trans_desc = |
2557 offer->GetTransportDescriptionByName("video"); | 2557 offer->GetTransportDescriptionByName("video"); |
2558 ASSERT_TRUE(video_offer_trans_desc->identity_fingerprint.get() != NULL); | 2558 ASSERT_TRUE(video_offer_trans_desc->identity_fingerprint.get() != nullptr); |
2559 const cricket::TransportDescription* data_offer_trans_desc = | 2559 const cricket::TransportDescription* data_offer_trans_desc = |
2560 offer->GetTransportDescriptionByName("data"); | 2560 offer->GetTransportDescriptionByName("data"); |
2561 ASSERT_TRUE(data_offer_trans_desc->identity_fingerprint.get() != NULL); | 2561 ASSERT_TRUE(data_offer_trans_desc->identity_fingerprint.get() != nullptr); |
2562 | 2562 |
2563 // Generate an answer with DTLS. | 2563 // Generate an answer with DTLS. |
2564 answer.reset(f2_.CreateAnswer(offer.get(), options, NULL)); | 2564 answer.reset(f2_.CreateAnswer(offer.get(), options, nullptr)); |
2565 ASSERT_TRUE(answer.get() != NULL); | 2565 ASSERT_TRUE(answer.get() != nullptr); |
2566 | 2566 |
2567 const cricket::TransportDescription* audio_answer_trans_desc = | 2567 const cricket::TransportDescription* audio_answer_trans_desc = |
2568 answer->GetTransportDescriptionByName("audio"); | 2568 answer->GetTransportDescriptionByName("audio"); |
2569 EXPECT_TRUE(audio_answer_trans_desc->identity_fingerprint.get() != NULL); | 2569 EXPECT_TRUE(audio_answer_trans_desc->identity_fingerprint.get() != nullptr); |
2570 const cricket::TransportDescription* video_answer_trans_desc = | 2570 const cricket::TransportDescription* video_answer_trans_desc = |
2571 answer->GetTransportDescriptionByName("video"); | 2571 answer->GetTransportDescriptionByName("video"); |
2572 EXPECT_TRUE(video_answer_trans_desc->identity_fingerprint.get() != NULL); | 2572 EXPECT_TRUE(video_answer_trans_desc->identity_fingerprint.get() != nullptr); |
2573 const cricket::TransportDescription* data_answer_trans_desc = | 2573 const cricket::TransportDescription* data_answer_trans_desc = |
2574 answer->GetTransportDescriptionByName("data"); | 2574 answer->GetTransportDescriptionByName("data"); |
2575 EXPECT_TRUE(data_answer_trans_desc->identity_fingerprint.get() != NULL); | 2575 EXPECT_TRUE(data_answer_trans_desc->identity_fingerprint.get() != nullptr); |
2576 } | 2576 } |
2577 | 2577 |
2578 // Verifies if vad_enabled option is set to false, CN codecs are not present in | 2578 // Verifies if vad_enabled option is set to false, CN codecs are not present in |
2579 // offer or answer. | 2579 // offer or answer. |
2580 TEST_F(MediaSessionDescriptionFactoryTest, TestVADEnableOption) { | 2580 TEST_F(MediaSessionDescriptionFactoryTest, TestVADEnableOption) { |
2581 MediaSessionOptions options; | 2581 MediaSessionOptions options; |
2582 options.recv_audio = true; | 2582 options.recv_audio = true; |
2583 options.recv_video = true; | 2583 options.recv_video = true; |
2584 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL)); | 2584 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, nullptr)); |
2585 ASSERT_TRUE(offer.get() != NULL); | 2585 ASSERT_TRUE(offer.get() != nullptr); |
2586 const ContentInfo* audio_content = offer->GetContentByName("audio"); | 2586 const ContentInfo* audio_content = offer->GetContentByName("audio"); |
2587 EXPECT_FALSE(VerifyNoCNCodecs(audio_content)); | 2587 EXPECT_FALSE(VerifyNoCNCodecs(audio_content)); |
2588 | 2588 |
2589 options.vad_enabled = false; | 2589 options.vad_enabled = false; |
2590 offer.reset(f1_.CreateOffer(options, NULL)); | 2590 offer.reset(f1_.CreateOffer(options, nullptr)); |
2591 ASSERT_TRUE(offer.get() != NULL); | 2591 ASSERT_TRUE(offer.get() != nullptr); |
2592 audio_content = offer->GetContentByName("audio"); | 2592 audio_content = offer->GetContentByName("audio"); |
2593 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); | 2593 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); |
2594 std::unique_ptr<SessionDescription> answer( | 2594 std::unique_ptr<SessionDescription> answer( |
2595 f1_.CreateAnswer(offer.get(), options, NULL)); | 2595 f1_.CreateAnswer(offer.get(), options, nullptr)); |
2596 ASSERT_TRUE(answer.get() != NULL); | 2596 ASSERT_TRUE(answer.get() != nullptr); |
2597 audio_content = answer->GetContentByName("audio"); | 2597 audio_content = answer->GetContentByName("audio"); |
2598 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); | 2598 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); |
2599 } | 2599 } |
2600 | 2600 |
2601 // Test that the content name ("mid" in SDP) is unchanged when creating a | 2601 // Test that the content name ("mid" in SDP) is unchanged when creating a |
2602 // new offer. | 2602 // new offer. |
2603 TEST_F(MediaSessionDescriptionFactoryTest, | 2603 TEST_F(MediaSessionDescriptionFactoryTest, |
2604 TestContentNameNotChangedInSubsequentOffers) { | 2604 TestContentNameNotChangedInSubsequentOffers) { |
2605 MediaSessionOptions opts; | 2605 MediaSessionOptions opts; |
2606 opts.recv_audio = true; | 2606 opts.recv_audio = true; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2750 sf.set_audio_codecs(send_codecs, recv_codecs); | 2750 sf.set_audio_codecs(send_codecs, recv_codecs); |
2751 sf.set_add_legacy_streams(add_legacy_stream); | 2751 sf.set_add_legacy_streams(add_legacy_stream); |
2752 | 2752 |
2753 MediaSessionOptions opts; | 2753 MediaSessionOptions opts; |
2754 opts.recv_audio = (direction == cricket::MD_RECVONLY || | 2754 opts.recv_audio = (direction == cricket::MD_RECVONLY || |
2755 direction == cricket::MD_SENDRECV); | 2755 direction == cricket::MD_SENDRECV); |
2756 opts.recv_video = false; | 2756 opts.recv_video = false; |
2757 if (direction == cricket::MD_SENDONLY || direction == cricket::MD_SENDRECV) | 2757 if (direction == cricket::MD_SENDONLY || direction == cricket::MD_SENDRECV) |
2758 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 2758 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); |
2759 | 2759 |
2760 std::unique_ptr<SessionDescription> offer(sf.CreateOffer(opts, NULL)); | 2760 std::unique_ptr<SessionDescription> offer(sf.CreateOffer(opts, nullptr)); |
2761 ASSERT_TRUE(offer.get() != NULL); | 2761 ASSERT_TRUE(offer.get() != nullptr); |
2762 const ContentInfo* ac = offer->GetContentByName("audio"); | 2762 const ContentInfo* ac = offer->GetContentByName("audio"); |
2763 | 2763 |
2764 // If the factory didn't add any audio content to the offer, we cannot check | 2764 // If the factory didn't add any audio content to the offer, we cannot check |
2765 // that the codecs put in are right. This happens when we neither want to send | 2765 // that the codecs put in are right. This happens when we neither want to send |
2766 // nor receive audio. The checks are still in place if at some point we'd | 2766 // nor receive audio. The checks are still in place if at some point we'd |
2767 // instead create an inactive stream. | 2767 // instead create an inactive stream. |
2768 if (ac) { | 2768 if (ac) { |
2769 AudioContentDescription* acd = | 2769 AudioContentDescription* acd = |
2770 static_cast<AudioContentDescription*>(ac->description); | 2770 static_cast<AudioContentDescription*>(ac->description); |
2771 // sendrecv and inactive should both present lists as if the channel was to | 2771 // sendrecv and inactive should both present lists as if the channel was to |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2855 MediaSessionOptions offer_opts; | 2855 MediaSessionOptions offer_opts; |
2856 offer_opts.recv_audio = (offer_direction == cricket::MD_RECVONLY || | 2856 offer_opts.recv_audio = (offer_direction == cricket::MD_RECVONLY || |
2857 offer_direction == cricket::MD_SENDRECV); | 2857 offer_direction == cricket::MD_SENDRECV); |
2858 offer_opts.recv_video = false; | 2858 offer_opts.recv_video = false; |
2859 if (offer_direction == cricket::MD_SENDONLY || | 2859 if (offer_direction == cricket::MD_SENDONLY || |
2860 offer_direction == cricket::MD_SENDRECV) { | 2860 offer_direction == cricket::MD_SENDRECV) { |
2861 offer_opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 2861 offer_opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); |
2862 } | 2862 } |
2863 | 2863 |
2864 std::unique_ptr<SessionDescription> offer( | 2864 std::unique_ptr<SessionDescription> offer( |
2865 offer_factory.CreateOffer(offer_opts, NULL)); | 2865 offer_factory.CreateOffer(offer_opts, nullptr)); |
2866 ASSERT_TRUE(offer.get() != NULL); | 2866 ASSERT_TRUE(offer.get() != nullptr); |
2867 | 2867 |
2868 MediaSessionOptions answer_opts; | 2868 MediaSessionOptions answer_opts; |
2869 answer_opts.recv_audio = (answer_direction == cricket::MD_RECVONLY || | 2869 answer_opts.recv_audio = (answer_direction == cricket::MD_RECVONLY || |
2870 answer_direction == cricket::MD_SENDRECV); | 2870 answer_direction == cricket::MD_SENDRECV); |
2871 answer_opts.recv_video = false; | 2871 answer_opts.recv_video = false; |
2872 if (answer_direction == cricket::MD_SENDONLY || | 2872 if (answer_direction == cricket::MD_SENDONLY || |
2873 answer_direction == cricket::MD_SENDRECV) { | 2873 answer_direction == cricket::MD_SENDRECV) { |
2874 answer_opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 2874 answer_opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); |
2875 } | 2875 } |
2876 std::unique_ptr<SessionDescription> answer( | 2876 std::unique_ptr<SessionDescription> answer( |
2877 answer_factory.CreateAnswer(offer.get(), answer_opts, NULL)); | 2877 answer_factory.CreateAnswer(offer.get(), answer_opts, nullptr)); |
2878 const ContentInfo* ac = answer->GetContentByName("audio"); | 2878 const ContentInfo* ac = answer->GetContentByName("audio"); |
2879 | 2879 |
2880 // If the factory didn't add any audio content to the answer, we cannot check | 2880 // If the factory didn't add any audio content to the answer, we cannot check |
2881 // that the codecs put in are right. This happens when we neither want to send | 2881 // that the codecs put in are right. This happens when we neither want to send |
2882 // nor receive audio. The checks are still in place if at some point we'd | 2882 // nor receive audio. The checks are still in place if at some point we'd |
2883 // instead create an inactive stream. | 2883 // instead create an inactive stream. |
2884 if (ac) { | 2884 if (ac) { |
2885 const AudioContentDescription* acd = | 2885 const AudioContentDescription* acd = |
2886 static_cast<const AudioContentDescription*>(ac->description); | 2886 static_cast<const AudioContentDescription*>(ac->description); |
2887 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 2887 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2980 ::testing::Combine( | 2980 ::testing::Combine( |
2981 ::testing::Values(cricket::MD_SENDONLY, | 2981 ::testing::Values(cricket::MD_SENDONLY, |
2982 cricket::MD_RECVONLY, | 2982 cricket::MD_RECVONLY, |
2983 cricket::MD_SENDRECV, | 2983 cricket::MD_SENDRECV, |
2984 cricket::MD_INACTIVE), | 2984 cricket::MD_INACTIVE), |
2985 ::testing::Values(cricket::MD_SENDONLY, | 2985 ::testing::Values(cricket::MD_SENDONLY, |
2986 cricket::MD_RECVONLY, | 2986 cricket::MD_RECVONLY, |
2987 cricket::MD_SENDRECV, | 2987 cricket::MD_SENDRECV, |
2988 cricket::MD_INACTIVE), | 2988 cricket::MD_INACTIVE), |
2989 ::testing::Bool())); | 2989 ::testing::Bool())); |
OLD | NEW |