Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: webrtc/pc/mediasession_unittest.cc

Issue 1783263002: Replace scoped_ptr with unique_ptr in webrtc/pc/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/pc/mediasession.cc ('k') | webrtc/pc/planarfunctions_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include <memory>
11 #include <string> 12 #include <string>
12 #include <vector> 13 #include <vector>
13 14
14 #include "webrtc/base/fakesslidentity.h" 15 #include "webrtc/base/fakesslidentity.h"
15 #include "webrtc/base/gunit.h" 16 #include "webrtc/base/gunit.h"
16 #include "webrtc/base/messagedigest.h" 17 #include "webrtc/base/messagedigest.h"
17 #include "webrtc/base/ssladapter.h" 18 #include "webrtc/base/ssladapter.h"
18 #include "webrtc/media/base/codec.h" 19 #include "webrtc/media/base/codec.h"
19 #include "webrtc/media/base/testutils.h" 20 #include "webrtc/media/base/testutils.h"
20 #include "webrtc/p2p/base/p2pconstants.h" 21 #include "webrtc/p2p/base/p2pconstants.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 267 }
267 268
268 void TestTransportInfo(bool offer, const MediaSessionOptions& options, 269 void TestTransportInfo(bool offer, const MediaSessionOptions& options,
269 bool has_current_desc) { 270 bool has_current_desc) {
270 const std::string current_audio_ufrag = "current_audio_ufrag"; 271 const std::string current_audio_ufrag = "current_audio_ufrag";
271 const std::string current_audio_pwd = "current_audio_pwd"; 272 const std::string current_audio_pwd = "current_audio_pwd";
272 const std::string current_video_ufrag = "current_video_ufrag"; 273 const std::string current_video_ufrag = "current_video_ufrag";
273 const std::string current_video_pwd = "current_video_pwd"; 274 const std::string current_video_pwd = "current_video_pwd";
274 const std::string current_data_ufrag = "current_data_ufrag"; 275 const std::string current_data_ufrag = "current_data_ufrag";
275 const std::string current_data_pwd = "current_data_pwd"; 276 const std::string current_data_pwd = "current_data_pwd";
276 rtc::scoped_ptr<SessionDescription> current_desc; 277 std::unique_ptr<SessionDescription> current_desc;
277 rtc::scoped_ptr<SessionDescription> desc; 278 std::unique_ptr<SessionDescription> desc;
278 if (has_current_desc) { 279 if (has_current_desc) {
279 current_desc.reset(new SessionDescription()); 280 current_desc.reset(new SessionDescription());
280 EXPECT_TRUE(current_desc->AddTransportInfo( 281 EXPECT_TRUE(current_desc->AddTransportInfo(
281 TransportInfo("audio", 282 TransportInfo("audio",
282 TransportDescription(current_audio_ufrag, 283 TransportDescription(current_audio_ufrag,
283 current_audio_pwd)))); 284 current_audio_pwd))));
284 EXPECT_TRUE(current_desc->AddTransportInfo( 285 EXPECT_TRUE(current_desc->AddTransportInfo(
285 TransportInfo("video", 286 TransportInfo("video",
286 TransportDescription(current_video_ufrag, 287 TransportDescription(current_video_ufrag,
287 current_video_pwd)))); 288 current_video_pwd))));
288 EXPECT_TRUE(current_desc->AddTransportInfo( 289 EXPECT_TRUE(current_desc->AddTransportInfo(
289 TransportInfo("data", 290 TransportInfo("data",
290 TransportDescription(current_data_ufrag, 291 TransportDescription(current_data_ufrag,
291 current_data_pwd)))); 292 current_data_pwd))));
292 } 293 }
293 if (offer) { 294 if (offer) {
294 desc.reset(f1_.CreateOffer(options, current_desc.get())); 295 desc.reset(f1_.CreateOffer(options, current_desc.get()));
295 } else { 296 } else {
296 rtc::scoped_ptr<SessionDescription> offer; 297 std::unique_ptr<SessionDescription> offer;
297 offer.reset(f1_.CreateOffer(options, NULL)); 298 offer.reset(f1_.CreateOffer(options, NULL));
298 desc.reset(f1_.CreateAnswer(offer.get(), options, current_desc.get())); 299 desc.reset(f1_.CreateAnswer(offer.get(), options, current_desc.get()));
299 } 300 }
300 ASSERT_TRUE(desc.get() != NULL); 301 ASSERT_TRUE(desc.get() != NULL);
301 const TransportInfo* ti_audio = desc->GetTransportInfoByName("audio"); 302 const TransportInfo* ti_audio = desc->GetTransportInfoByName("audio");
302 if (options.has_audio()) { 303 if (options.has_audio()) {
303 EXPECT_TRUE(ti_audio != NULL); 304 EXPECT_TRUE(ti_audio != NULL);
304 if (has_current_desc) { 305 if (has_current_desc) {
305 EXPECT_EQ(current_audio_ufrag, ti_audio->description.ice_ufrag); 306 EXPECT_EQ(current_audio_ufrag, ti_audio->description.ice_ufrag);
306 EXPECT_EQ(current_audio_pwd, ti_audio->description.ice_pwd); 307 EXPECT_EQ(current_audio_pwd, ti_audio->description.ice_pwd);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 EXPECT_TRUE(ti_video == NULL); 360 EXPECT_TRUE(ti_video == NULL);
360 } 361 }
361 } 362 }
362 363
363 void TestCryptoWithBundle(bool offer) { 364 void TestCryptoWithBundle(bool offer) {
364 f1_.set_secure(SEC_ENABLED); 365 f1_.set_secure(SEC_ENABLED);
365 MediaSessionOptions options; 366 MediaSessionOptions options;
366 options.recv_audio = true; 367 options.recv_audio = true;
367 options.recv_video = true; 368 options.recv_video = true;
368 options.data_channel_type = cricket::DCT_RTP; 369 options.data_channel_type = cricket::DCT_RTP;
369 rtc::scoped_ptr<SessionDescription> ref_desc; 370 std::unique_ptr<SessionDescription> ref_desc;
370 rtc::scoped_ptr<SessionDescription> desc; 371 std::unique_ptr<SessionDescription> desc;
371 if (offer) { 372 if (offer) {
372 options.bundle_enabled = false; 373 options.bundle_enabled = false;
373 ref_desc.reset(f1_.CreateOffer(options, NULL)); 374 ref_desc.reset(f1_.CreateOffer(options, NULL));
374 options.bundle_enabled = true; 375 options.bundle_enabled = true;
375 desc.reset(f1_.CreateOffer(options, ref_desc.get())); 376 desc.reset(f1_.CreateOffer(options, ref_desc.get()));
376 } else { 377 } else {
377 options.bundle_enabled = true; 378 options.bundle_enabled = true;
378 ref_desc.reset(f1_.CreateOffer(options, NULL)); 379 ref_desc.reset(f1_.CreateOffer(options, NULL));
379 desc.reset(f1_.CreateAnswer(ref_desc.get(), options, NULL)); 380 desc.reset(f1_.CreateAnswer(ref_desc.get(), options, NULL));
380 } 381 }
(...skipping 29 matching lines...) Expand all
410 } 411 }
411 412
412 // This test that the audio and video media direction is set to 413 // This test that the audio and video media direction is set to
413 // |expected_direction_in_answer| in an answer if the offer direction is set 414 // |expected_direction_in_answer| in an answer if the offer direction is set
414 // to |direction_in_offer|. 415 // to |direction_in_offer|.
415 void TestMediaDirectionInAnswer( 416 void TestMediaDirectionInAnswer(
416 cricket::MediaContentDirection direction_in_offer, 417 cricket::MediaContentDirection direction_in_offer,
417 cricket::MediaContentDirection expected_direction_in_answer) { 418 cricket::MediaContentDirection expected_direction_in_answer) {
418 MediaSessionOptions opts; 419 MediaSessionOptions opts;
419 opts.recv_video = true; 420 opts.recv_video = true;
420 rtc::scoped_ptr<SessionDescription> offer( 421 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
421 f1_.CreateOffer(opts, NULL));
422 ASSERT_TRUE(offer.get() != NULL); 422 ASSERT_TRUE(offer.get() != NULL);
423 ContentInfo* ac_offer= offer->GetContentByName("audio"); 423 ContentInfo* ac_offer= offer->GetContentByName("audio");
424 ASSERT_TRUE(ac_offer != NULL); 424 ASSERT_TRUE(ac_offer != NULL);
425 AudioContentDescription* acd_offer = 425 AudioContentDescription* acd_offer =
426 static_cast<AudioContentDescription*>(ac_offer->description); 426 static_cast<AudioContentDescription*>(ac_offer->description);
427 acd_offer->set_direction(direction_in_offer); 427 acd_offer->set_direction(direction_in_offer);
428 ContentInfo* vc_offer= offer->GetContentByName("video"); 428 ContentInfo* vc_offer= offer->GetContentByName("video");
429 ASSERT_TRUE(vc_offer != NULL); 429 ASSERT_TRUE(vc_offer != NULL);
430 VideoContentDescription* vcd_offer = 430 VideoContentDescription* vcd_offer =
431 static_cast<VideoContentDescription*>(vc_offer->description); 431 static_cast<VideoContentDescription*>(vc_offer->description);
432 vcd_offer->set_direction(direction_in_offer); 432 vcd_offer->set_direction(direction_in_offer);
433 433
434 rtc::scoped_ptr<SessionDescription> answer( 434 std::unique_ptr<SessionDescription> answer(
435 f2_.CreateAnswer(offer.get(), opts, NULL)); 435 f2_.CreateAnswer(offer.get(), opts, NULL));
436 const AudioContentDescription* acd_answer = 436 const AudioContentDescription* acd_answer =
437 GetFirstAudioContentDescription(answer.get()); 437 GetFirstAudioContentDescription(answer.get());
438 EXPECT_EQ(expected_direction_in_answer, acd_answer->direction()); 438 EXPECT_EQ(expected_direction_in_answer, acd_answer->direction());
439 const VideoContentDescription* vcd_answer = 439 const VideoContentDescription* vcd_answer =
440 GetFirstVideoContentDescription(answer.get()); 440 GetFirstVideoContentDescription(answer.get());
441 EXPECT_EQ(expected_direction_in_answer, vcd_answer->direction()); 441 EXPECT_EQ(expected_direction_in_answer, vcd_answer->direction());
442 } 442 }
443 443
444 bool VerifyNoCNCodecs(const cricket::ContentInfo* content) { 444 bool VerifyNoCNCodecs(const cricket::ContentInfo* content) {
(...skipping 12 matching lines...) Expand all
457 protected: 457 protected:
458 MediaSessionDescriptionFactory f1_; 458 MediaSessionDescriptionFactory f1_;
459 MediaSessionDescriptionFactory f2_; 459 MediaSessionDescriptionFactory f2_;
460 TransportDescriptionFactory tdf1_; 460 TransportDescriptionFactory tdf1_;
461 TransportDescriptionFactory tdf2_; 461 TransportDescriptionFactory tdf2_;
462 }; 462 };
463 463
464 // Create a typical audio offer, and ensure it matches what we expect. 464 // Create a typical audio offer, and ensure it matches what we expect.
465 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOffer) { 465 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOffer) {
466 f1_.set_secure(SEC_ENABLED); 466 f1_.set_secure(SEC_ENABLED);
467 rtc::scoped_ptr<SessionDescription> offer( 467 std::unique_ptr<SessionDescription> offer(
468 f1_.CreateOffer(MediaSessionOptions(), NULL)); 468 f1_.CreateOffer(MediaSessionOptions(), NULL));
469 ASSERT_TRUE(offer.get() != NULL); 469 ASSERT_TRUE(offer.get() != NULL);
470 const ContentInfo* ac = offer->GetContentByName("audio"); 470 const ContentInfo* ac = offer->GetContentByName("audio");
471 const ContentInfo* vc = offer->GetContentByName("video"); 471 const ContentInfo* vc = offer->GetContentByName("video");
472 ASSERT_TRUE(ac != NULL); 472 ASSERT_TRUE(ac != NULL);
473 ASSERT_TRUE(vc == NULL); 473 ASSERT_TRUE(vc == NULL);
474 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); 474 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type);
475 const AudioContentDescription* acd = 475 const AudioContentDescription* acd =
476 static_cast<const AudioContentDescription*>(ac->description); 476 static_cast<const AudioContentDescription*>(ac->description);
477 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); 477 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
478 EXPECT_EQ(f1_.audio_codecs(), acd->codecs()); 478 EXPECT_EQ(f1_.audio_codecs(), acd->codecs());
479 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc 479 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc
480 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) 480 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto)
481 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on 481 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on
482 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); 482 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32);
483 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); 483 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol());
484 } 484 }
485 485
486 // Create a typical video offer, and ensure it matches what we expect. 486 // Create a typical video offer, and ensure it matches what we expect.
487 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoOffer) { 487 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoOffer) {
488 MediaSessionOptions opts; 488 MediaSessionOptions opts;
489 opts.recv_video = true; 489 opts.recv_video = true;
490 f1_.set_secure(SEC_ENABLED); 490 f1_.set_secure(SEC_ENABLED);
491 rtc::scoped_ptr<SessionDescription> 491 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
492 offer(f1_.CreateOffer(opts, NULL));
493 ASSERT_TRUE(offer.get() != NULL); 492 ASSERT_TRUE(offer.get() != NULL);
494 const ContentInfo* ac = offer->GetContentByName("audio"); 493 const ContentInfo* ac = offer->GetContentByName("audio");
495 const ContentInfo* vc = offer->GetContentByName("video"); 494 const ContentInfo* vc = offer->GetContentByName("video");
496 ASSERT_TRUE(ac != NULL); 495 ASSERT_TRUE(ac != NULL);
497 ASSERT_TRUE(vc != NULL); 496 ASSERT_TRUE(vc != NULL);
498 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); 497 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type);
499 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); 498 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type);
500 const AudioContentDescription* acd = 499 const AudioContentDescription* acd =
501 static_cast<const AudioContentDescription*>(ac->description); 500 static_cast<const AudioContentDescription*>(ac->description);
502 const VideoContentDescription* vcd = 501 const VideoContentDescription* vcd =
(...skipping 22 matching lines...) Expand all
525 const AudioCodec& offered_audio_codec = f2_.audio_codecs()[0]; 524 const AudioCodec& offered_audio_codec = f2_.audio_codecs()[0];
526 const DataCodec& offered_data_codec = f2_.data_codecs()[0]; 525 const DataCodec& offered_data_codec = f2_.data_codecs()[0];
527 ASSERT_EQ(offered_video_codec.id, offered_audio_codec.id); 526 ASSERT_EQ(offered_video_codec.id, offered_audio_codec.id);
528 ASSERT_EQ(offered_video_codec.id, offered_data_codec.id); 527 ASSERT_EQ(offered_video_codec.id, offered_data_codec.id);
529 528
530 MediaSessionOptions opts; 529 MediaSessionOptions opts;
531 opts.recv_audio = true; 530 opts.recv_audio = true;
532 opts.recv_video = true; 531 opts.recv_video = true;
533 opts.data_channel_type = cricket::DCT_RTP; 532 opts.data_channel_type = cricket::DCT_RTP;
534 opts.bundle_enabled = true; 533 opts.bundle_enabled = true;
535 rtc::scoped_ptr<SessionDescription> 534 std::unique_ptr<SessionDescription> offer(f2_.CreateOffer(opts, NULL));
536 offer(f2_.CreateOffer(opts, NULL));
537 const VideoContentDescription* vcd = 535 const VideoContentDescription* vcd =
538 GetFirstVideoContentDescription(offer.get()); 536 GetFirstVideoContentDescription(offer.get());
539 const AudioContentDescription* acd = 537 const AudioContentDescription* acd =
540 GetFirstAudioContentDescription(offer.get()); 538 GetFirstAudioContentDescription(offer.get());
541 const DataContentDescription* dcd = 539 const DataContentDescription* dcd =
542 GetFirstDataContentDescription(offer.get()); 540 GetFirstDataContentDescription(offer.get());
543 ASSERT_TRUE(NULL != vcd); 541 ASSERT_TRUE(NULL != vcd);
544 ASSERT_TRUE(NULL != acd); 542 ASSERT_TRUE(NULL != acd);
545 ASSERT_TRUE(NULL != dcd); 543 ASSERT_TRUE(NULL != dcd);
546 EXPECT_NE(vcd->codecs()[0].id, acd->codecs()[0].id); 544 EXPECT_NE(vcd->codecs()[0].id, acd->codecs()[0].id);
547 EXPECT_NE(vcd->codecs()[0].id, dcd->codecs()[0].id); 545 EXPECT_NE(vcd->codecs()[0].id, dcd->codecs()[0].id);
548 EXPECT_NE(acd->codecs()[0].id, dcd->codecs()[0].id); 546 EXPECT_NE(acd->codecs()[0].id, dcd->codecs()[0].id);
549 EXPECT_EQ(vcd->codecs()[0].name, offered_video_codec.name); 547 EXPECT_EQ(vcd->codecs()[0].name, offered_video_codec.name);
550 EXPECT_EQ(acd->codecs()[0].name, offered_audio_codec.name); 548 EXPECT_EQ(acd->codecs()[0].name, offered_audio_codec.name);
551 EXPECT_EQ(dcd->codecs()[0].name, offered_data_codec.name); 549 EXPECT_EQ(dcd->codecs()[0].name, offered_data_codec.name);
552 } 550 }
553 551
554 // Test creating an updated offer with with bundle, audio, video and data 552 // Test creating an updated offer with with bundle, audio, video and data
555 // after an audio only session has been negotiated. 553 // after an audio only session has been negotiated.
556 TEST_F(MediaSessionDescriptionFactoryTest, 554 TEST_F(MediaSessionDescriptionFactoryTest,
557 TestCreateUpdatedVideoOfferWithBundle) { 555 TestCreateUpdatedVideoOfferWithBundle) {
558 f1_.set_secure(SEC_ENABLED); 556 f1_.set_secure(SEC_ENABLED);
559 f2_.set_secure(SEC_ENABLED); 557 f2_.set_secure(SEC_ENABLED);
560 MediaSessionOptions opts; 558 MediaSessionOptions opts;
561 opts.recv_audio = true; 559 opts.recv_audio = true;
562 opts.recv_video = false; 560 opts.recv_video = false;
563 opts.data_channel_type = cricket::DCT_NONE; 561 opts.data_channel_type = cricket::DCT_NONE;
564 opts.bundle_enabled = true; 562 opts.bundle_enabled = true;
565 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 563 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
566 rtc::scoped_ptr<SessionDescription> answer( 564 std::unique_ptr<SessionDescription> answer(
567 f2_.CreateAnswer(offer.get(), opts, NULL)); 565 f2_.CreateAnswer(offer.get(), opts, NULL));
568 566
569 MediaSessionOptions updated_opts; 567 MediaSessionOptions updated_opts;
570 updated_opts.recv_audio = true; 568 updated_opts.recv_audio = true;
571 updated_opts.recv_video = true; 569 updated_opts.recv_video = true;
572 updated_opts.data_channel_type = cricket::DCT_RTP; 570 updated_opts.data_channel_type = cricket::DCT_RTP;
573 updated_opts.bundle_enabled = true; 571 updated_opts.bundle_enabled = true;
574 rtc::scoped_ptr<SessionDescription> updated_offer(f1_.CreateOffer( 572 std::unique_ptr<SessionDescription> updated_offer(
575 updated_opts, answer.get())); 573 f1_.CreateOffer(updated_opts, answer.get()));
576 574
577 const AudioContentDescription* acd = 575 const AudioContentDescription* acd =
578 GetFirstAudioContentDescription(updated_offer.get()); 576 GetFirstAudioContentDescription(updated_offer.get());
579 const VideoContentDescription* vcd = 577 const VideoContentDescription* vcd =
580 GetFirstVideoContentDescription(updated_offer.get()); 578 GetFirstVideoContentDescription(updated_offer.get());
581 const DataContentDescription* dcd = 579 const DataContentDescription* dcd =
582 GetFirstDataContentDescription(updated_offer.get()); 580 GetFirstDataContentDescription(updated_offer.get());
583 EXPECT_TRUE(NULL != vcd); 581 EXPECT_TRUE(NULL != vcd);
584 EXPECT_TRUE(NULL != acd); 582 EXPECT_TRUE(NULL != acd);
585 EXPECT_TRUE(NULL != dcd); 583 EXPECT_TRUE(NULL != dcd);
586 584
587 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_80); 585 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_80);
588 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); 586 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol());
589 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); 587 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80);
590 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); 588 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol());
591 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); 589 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80);
592 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); 590 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol());
593 } 591 }
594 592
595 // Create a RTP data offer, and ensure it matches what we expect. 593 // Create a RTP data offer, and ensure it matches what we expect.
596 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateRtpDataOffer) { 594 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateRtpDataOffer) {
597 MediaSessionOptions opts; 595 MediaSessionOptions opts;
598 opts.data_channel_type = cricket::DCT_RTP; 596 opts.data_channel_type = cricket::DCT_RTP;
599 f1_.set_secure(SEC_ENABLED); 597 f1_.set_secure(SEC_ENABLED);
600 rtc::scoped_ptr<SessionDescription> 598 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
601 offer(f1_.CreateOffer(opts, NULL));
602 ASSERT_TRUE(offer.get() != NULL); 599 ASSERT_TRUE(offer.get() != NULL);
603 const ContentInfo* ac = offer->GetContentByName("audio"); 600 const ContentInfo* ac = offer->GetContentByName("audio");
604 const ContentInfo* dc = offer->GetContentByName("data"); 601 const ContentInfo* dc = offer->GetContentByName("data");
605 ASSERT_TRUE(ac != NULL); 602 ASSERT_TRUE(ac != NULL);
606 ASSERT_TRUE(dc != NULL); 603 ASSERT_TRUE(dc != NULL);
607 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); 604 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type);
608 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); 605 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type);
609 const AudioContentDescription* acd = 606 const AudioContentDescription* acd =
610 static_cast<const AudioContentDescription*>(ac->description); 607 static_cast<const AudioContentDescription*>(ac->description);
611 const DataContentDescription* dcd = 608 const DataContentDescription* dcd =
(...skipping 15 matching lines...) Expand all
627 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); 624 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol());
628 } 625 }
629 626
630 // Create an SCTP data offer with bundle without error. 627 // Create an SCTP data offer with bundle without error.
631 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSctpDataOffer) { 628 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSctpDataOffer) {
632 MediaSessionOptions opts; 629 MediaSessionOptions opts;
633 opts.recv_audio = false; 630 opts.recv_audio = false;
634 opts.bundle_enabled = true; 631 opts.bundle_enabled = true;
635 opts.data_channel_type = cricket::DCT_SCTP; 632 opts.data_channel_type = cricket::DCT_SCTP;
636 f1_.set_secure(SEC_ENABLED); 633 f1_.set_secure(SEC_ENABLED);
637 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 634 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
638 EXPECT_TRUE(offer.get() != NULL); 635 EXPECT_TRUE(offer.get() != NULL);
639 EXPECT_TRUE(offer->GetContentByName("data") != NULL); 636 EXPECT_TRUE(offer->GetContentByName("data") != NULL);
640 } 637 }
641 638
642 // Test creating an sctp data channel from an already generated offer. 639 // Test creating an sctp data channel from an already generated offer.
643 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateImplicitSctpDataOffer) { 640 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateImplicitSctpDataOffer) {
644 MediaSessionOptions opts; 641 MediaSessionOptions opts;
645 opts.recv_audio = false; 642 opts.recv_audio = false;
646 opts.bundle_enabled = true; 643 opts.bundle_enabled = true;
647 opts.data_channel_type = cricket::DCT_SCTP; 644 opts.data_channel_type = cricket::DCT_SCTP;
648 f1_.set_secure(SEC_ENABLED); 645 f1_.set_secure(SEC_ENABLED);
649 rtc::scoped_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); 646 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL));
650 ASSERT_TRUE(offer1.get() != NULL); 647 ASSERT_TRUE(offer1.get() != NULL);
651 const ContentInfo* data = offer1->GetContentByName("data"); 648 const ContentInfo* data = offer1->GetContentByName("data");
652 ASSERT_TRUE(data != NULL); 649 ASSERT_TRUE(data != NULL);
653 const MediaContentDescription* mdesc = 650 const MediaContentDescription* mdesc =
654 static_cast<const MediaContentDescription*>(data->description); 651 static_cast<const MediaContentDescription*>(data->description);
655 ASSERT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol()); 652 ASSERT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol());
656 653
657 // Now set data_channel_type to 'none' (default) and make sure that the 654 // Now set data_channel_type to 'none' (default) and make sure that the
658 // datachannel type that gets generated from the previous offer, is of the 655 // datachannel type that gets generated from the previous offer, is of the
659 // same type. 656 // same type.
660 opts.data_channel_type = cricket::DCT_NONE; 657 opts.data_channel_type = cricket::DCT_NONE;
661 rtc::scoped_ptr<SessionDescription> offer2( 658 std::unique_ptr<SessionDescription> offer2(
662 f1_.CreateOffer(opts, offer1.get())); 659 f1_.CreateOffer(opts, offer1.get()));
663 data = offer2->GetContentByName("data"); 660 data = offer2->GetContentByName("data");
664 ASSERT_TRUE(data != NULL); 661 ASSERT_TRUE(data != NULL);
665 mdesc = static_cast<const MediaContentDescription*>(data->description); 662 mdesc = static_cast<const MediaContentDescription*>(data->description);
666 EXPECT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol()); 663 EXPECT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol());
667 } 664 }
668 665
669 // Create an audio, video offer without legacy StreamParams. 666 // Create an audio, video offer without legacy StreamParams.
670 TEST_F(MediaSessionDescriptionFactoryTest, 667 TEST_F(MediaSessionDescriptionFactoryTest,
671 TestCreateOfferWithoutLegacyStreams) { 668 TestCreateOfferWithoutLegacyStreams) {
672 MediaSessionOptions opts; 669 MediaSessionOptions opts;
673 opts.recv_video = true; 670 opts.recv_video = true;
674 f1_.set_add_legacy_streams(false); 671 f1_.set_add_legacy_streams(false);
675 rtc::scoped_ptr<SessionDescription> 672 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
676 offer(f1_.CreateOffer(opts, NULL));
677 ASSERT_TRUE(offer.get() != NULL); 673 ASSERT_TRUE(offer.get() != NULL);
678 const ContentInfo* ac = offer->GetContentByName("audio"); 674 const ContentInfo* ac = offer->GetContentByName("audio");
679 const ContentInfo* vc = offer->GetContentByName("video"); 675 const ContentInfo* vc = offer->GetContentByName("video");
680 ASSERT_TRUE(ac != NULL); 676 ASSERT_TRUE(ac != NULL);
681 ASSERT_TRUE(vc != NULL); 677 ASSERT_TRUE(vc != NULL);
682 const AudioContentDescription* acd = 678 const AudioContentDescription* acd =
683 static_cast<const AudioContentDescription*>(ac->description); 679 static_cast<const AudioContentDescription*>(ac->description);
684 const VideoContentDescription* vcd = 680 const VideoContentDescription* vcd =
685 static_cast<const VideoContentDescription*>(vc->description); 681 static_cast<const VideoContentDescription*>(vc->description);
686 682
687 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. 683 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams.
688 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. 684 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams.
689 } 685 }
690 686
691 // Creates an audio+video sendonly offer. 687 // Creates an audio+video sendonly offer.
692 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSendOnlyOffer) { 688 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSendOnlyOffer) {
693 MediaSessionOptions options; 689 MediaSessionOptions options;
694 options.recv_audio = false; 690 options.recv_audio = false;
695 options.recv_video = false; 691 options.recv_video = false;
696 options.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); 692 options.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1);
697 options.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); 693 options.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1);
698 694
699 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL)); 695 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL));
700 ASSERT_TRUE(offer.get() != NULL); 696 ASSERT_TRUE(offer.get() != NULL);
701 EXPECT_EQ(2u, offer->contents().size()); 697 EXPECT_EQ(2u, offer->contents().size());
702 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[0], MEDIA_TYPE_AUDIO)); 698 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[0], MEDIA_TYPE_AUDIO));
703 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[1], MEDIA_TYPE_VIDEO)); 699 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[1], MEDIA_TYPE_VIDEO));
704 700
705 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[0])); 701 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[0]));
706 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[1])); 702 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[1]));
707 } 703 }
708 704
709 // Verifies that the order of the media contents in the current 705 // Verifies that the order of the media contents in the current
710 // SessionDescription is preserved in the new SessionDescription. 706 // SessionDescription is preserved in the new SessionDescription.
711 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateOfferContentOrder) { 707 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateOfferContentOrder) {
712 MediaSessionOptions opts; 708 MediaSessionOptions opts;
713 opts.recv_audio = false; 709 opts.recv_audio = false;
714 opts.recv_video = false; 710 opts.recv_video = false;
715 opts.data_channel_type = cricket::DCT_SCTP; 711 opts.data_channel_type = cricket::DCT_SCTP;
716 712
717 rtc::scoped_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); 713 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL));
718 ASSERT_TRUE(offer1.get() != NULL); 714 ASSERT_TRUE(offer1.get() != NULL);
719 EXPECT_EQ(1u, offer1->contents().size()); 715 EXPECT_EQ(1u, offer1->contents().size());
720 EXPECT_TRUE(IsMediaContentOfType(&offer1->contents()[0], MEDIA_TYPE_DATA)); 716 EXPECT_TRUE(IsMediaContentOfType(&offer1->contents()[0], MEDIA_TYPE_DATA));
721 717
722 opts.recv_video = true; 718 opts.recv_video = true;
723 rtc::scoped_ptr<SessionDescription> offer2( 719 std::unique_ptr<SessionDescription> offer2(
724 f1_.CreateOffer(opts, offer1.get())); 720 f1_.CreateOffer(opts, offer1.get()));
725 ASSERT_TRUE(offer2.get() != NULL); 721 ASSERT_TRUE(offer2.get() != NULL);
726 EXPECT_EQ(2u, offer2->contents().size()); 722 EXPECT_EQ(2u, offer2->contents().size());
727 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[0], MEDIA_TYPE_DATA)); 723 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[0], MEDIA_TYPE_DATA));
728 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[1], MEDIA_TYPE_VIDEO)); 724 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[1], MEDIA_TYPE_VIDEO));
729 725
730 opts.recv_audio = true; 726 opts.recv_audio = true;
731 rtc::scoped_ptr<SessionDescription> offer3( 727 std::unique_ptr<SessionDescription> offer3(
732 f1_.CreateOffer(opts, offer2.get())); 728 f1_.CreateOffer(opts, offer2.get()));
733 ASSERT_TRUE(offer3.get() != NULL); 729 ASSERT_TRUE(offer3.get() != NULL);
734 EXPECT_EQ(3u, offer3->contents().size()); 730 EXPECT_EQ(3u, offer3->contents().size());
735 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[0], MEDIA_TYPE_DATA)); 731 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[0], MEDIA_TYPE_DATA));
736 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[1], MEDIA_TYPE_VIDEO)); 732 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[1], MEDIA_TYPE_VIDEO));
737 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[2], MEDIA_TYPE_AUDIO)); 733 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[2], MEDIA_TYPE_AUDIO));
738 734
739 // Verifies the default order is audio-video-data, so that the previous checks 735 // Verifies the default order is audio-video-data, so that the previous checks
740 // didn't pass by accident. 736 // didn't pass by accident.
741 rtc::scoped_ptr<SessionDescription> offer4(f1_.CreateOffer(opts, NULL)); 737 std::unique_ptr<SessionDescription> offer4(f1_.CreateOffer(opts, NULL));
742 ASSERT_TRUE(offer4.get() != NULL); 738 ASSERT_TRUE(offer4.get() != NULL);
743 EXPECT_EQ(3u, offer4->contents().size()); 739 EXPECT_EQ(3u, offer4->contents().size());
744 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[0], MEDIA_TYPE_AUDIO)); 740 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[0], MEDIA_TYPE_AUDIO));
745 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[1], MEDIA_TYPE_VIDEO)); 741 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[1], MEDIA_TYPE_VIDEO));
746 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[2], MEDIA_TYPE_DATA)); 742 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[2], MEDIA_TYPE_DATA));
747 } 743 }
748 744
749 // Create a typical audio answer, and ensure it matches what we expect. 745 // Create a typical audio answer, and ensure it matches what we expect.
750 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswer) { 746 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswer) {
751 f1_.set_secure(SEC_ENABLED); 747 f1_.set_secure(SEC_ENABLED);
752 f2_.set_secure(SEC_ENABLED); 748 f2_.set_secure(SEC_ENABLED);
753 rtc::scoped_ptr<SessionDescription> offer( 749 std::unique_ptr<SessionDescription> offer(
754 f1_.CreateOffer(MediaSessionOptions(), NULL)); 750 f1_.CreateOffer(MediaSessionOptions(), NULL));
755 ASSERT_TRUE(offer.get() != NULL); 751 ASSERT_TRUE(offer.get() != NULL);
756 rtc::scoped_ptr<SessionDescription> answer( 752 std::unique_ptr<SessionDescription> answer(
757 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); 753 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL));
758 const ContentInfo* ac = answer->GetContentByName("audio"); 754 const ContentInfo* ac = answer->GetContentByName("audio");
759 const ContentInfo* vc = answer->GetContentByName("video"); 755 const ContentInfo* vc = answer->GetContentByName("video");
760 ASSERT_TRUE(ac != NULL); 756 ASSERT_TRUE(ac != NULL);
761 ASSERT_TRUE(vc == NULL); 757 ASSERT_TRUE(vc == NULL);
762 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); 758 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type);
763 const AudioContentDescription* acd = 759 const AudioContentDescription* acd =
764 static_cast<const AudioContentDescription*>(ac->description); 760 static_cast<const AudioContentDescription*>(ac->description);
765 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); 761 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
766 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); 762 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs());
767 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc 763 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc
768 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw 764 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw
769 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux 765 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux
770 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); 766 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32);
771 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); 767 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol());
772 } 768 }
773 769
774 // Create a typical video answer, and ensure it matches what we expect. 770 // Create a typical video answer, and ensure it matches what we expect.
775 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswer) { 771 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswer) {
776 MediaSessionOptions opts; 772 MediaSessionOptions opts;
777 opts.recv_video = true; 773 opts.recv_video = true;
778 f1_.set_secure(SEC_ENABLED); 774 f1_.set_secure(SEC_ENABLED);
779 f2_.set_secure(SEC_ENABLED); 775 f2_.set_secure(SEC_ENABLED);
780 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 776 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
781 ASSERT_TRUE(offer.get() != NULL); 777 ASSERT_TRUE(offer.get() != NULL);
782 rtc::scoped_ptr<SessionDescription> answer( 778 std::unique_ptr<SessionDescription> answer(
783 f2_.CreateAnswer(offer.get(), opts, NULL)); 779 f2_.CreateAnswer(offer.get(), opts, NULL));
784 const ContentInfo* ac = answer->GetContentByName("audio"); 780 const ContentInfo* ac = answer->GetContentByName("audio");
785 const ContentInfo* vc = answer->GetContentByName("video"); 781 const ContentInfo* vc = answer->GetContentByName("video");
786 ASSERT_TRUE(ac != NULL); 782 ASSERT_TRUE(ac != NULL);
787 ASSERT_TRUE(vc != NULL); 783 ASSERT_TRUE(vc != NULL);
788 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); 784 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type);
789 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); 785 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type);
790 const AudioContentDescription* acd = 786 const AudioContentDescription* acd =
791 static_cast<const AudioContentDescription*>(ac->description); 787 static_cast<const AudioContentDescription*>(ac->description);
792 const VideoContentDescription* vcd = 788 const VideoContentDescription* vcd =
(...skipping 10 matching lines...) Expand all
803 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux 799 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux
804 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); 800 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80);
805 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); 801 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol());
806 } 802 }
807 803
808 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswer) { 804 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswer) {
809 MediaSessionOptions opts; 805 MediaSessionOptions opts;
810 opts.data_channel_type = cricket::DCT_RTP; 806 opts.data_channel_type = cricket::DCT_RTP;
811 f1_.set_secure(SEC_ENABLED); 807 f1_.set_secure(SEC_ENABLED);
812 f2_.set_secure(SEC_ENABLED); 808 f2_.set_secure(SEC_ENABLED);
813 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 809 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
814 ASSERT_TRUE(offer.get() != NULL); 810 ASSERT_TRUE(offer.get() != NULL);
815 rtc::scoped_ptr<SessionDescription> answer( 811 std::unique_ptr<SessionDescription> answer(
816 f2_.CreateAnswer(offer.get(), opts, NULL)); 812 f2_.CreateAnswer(offer.get(), opts, NULL));
817 const ContentInfo* ac = answer->GetContentByName("audio"); 813 const ContentInfo* ac = answer->GetContentByName("audio");
818 const ContentInfo* vc = answer->GetContentByName("data"); 814 const ContentInfo* vc = answer->GetContentByName("data");
819 ASSERT_TRUE(ac != NULL); 815 ASSERT_TRUE(ac != NULL);
820 ASSERT_TRUE(vc != NULL); 816 ASSERT_TRUE(vc != NULL);
821 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); 817 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type);
822 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); 818 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type);
823 const AudioContentDescription* acd = 819 const AudioContentDescription* acd =
824 static_cast<const AudioContentDescription*>(ac->description); 820 static_cast<const AudioContentDescription*>(ac->description);
825 const DataContentDescription* vcd = 821 const DataContentDescription* vcd =
(...skipping 13 matching lines...) Expand all
839 } 835 }
840 836
841 // Verifies that the order of the media contents in the offer is preserved in 837 // Verifies that the order of the media contents in the offer is preserved in
842 // the answer. 838 // the answer.
843 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerContentOrder) { 839 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerContentOrder) {
844 MediaSessionOptions opts; 840 MediaSessionOptions opts;
845 841
846 // Creates a data only offer. 842 // Creates a data only offer.
847 opts.recv_audio = false; 843 opts.recv_audio = false;
848 opts.data_channel_type = cricket::DCT_SCTP; 844 opts.data_channel_type = cricket::DCT_SCTP;
849 rtc::scoped_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); 845 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL));
850 ASSERT_TRUE(offer1.get() != NULL); 846 ASSERT_TRUE(offer1.get() != NULL);
851 847
852 // Appends audio to the offer. 848 // Appends audio to the offer.
853 opts.recv_audio = true; 849 opts.recv_audio = true;
854 rtc::scoped_ptr<SessionDescription> offer2( 850 std::unique_ptr<SessionDescription> offer2(
855 f1_.CreateOffer(opts, offer1.get())); 851 f1_.CreateOffer(opts, offer1.get()));
856 ASSERT_TRUE(offer2.get() != NULL); 852 ASSERT_TRUE(offer2.get() != NULL);
857 853
858 // Appends video to the offer. 854 // Appends video to the offer.
859 opts.recv_video = true; 855 opts.recv_video = true;
860 rtc::scoped_ptr<SessionDescription> offer3( 856 std::unique_ptr<SessionDescription> offer3(
861 f1_.CreateOffer(opts, offer2.get())); 857 f1_.CreateOffer(opts, offer2.get()));
862 ASSERT_TRUE(offer3.get() != NULL); 858 ASSERT_TRUE(offer3.get() != NULL);
863 859
864 rtc::scoped_ptr<SessionDescription> answer( 860 std::unique_ptr<SessionDescription> answer(
865 f2_.CreateAnswer(offer3.get(), opts, NULL)); 861 f2_.CreateAnswer(offer3.get(), opts, NULL));
866 ASSERT_TRUE(answer.get() != NULL); 862 ASSERT_TRUE(answer.get() != NULL);
867 EXPECT_EQ(3u, answer->contents().size()); 863 EXPECT_EQ(3u, answer->contents().size());
868 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[0], MEDIA_TYPE_DATA)); 864 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[0], MEDIA_TYPE_DATA));
869 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[1], MEDIA_TYPE_AUDIO)); 865 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[1], MEDIA_TYPE_AUDIO));
870 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[2], MEDIA_TYPE_VIDEO)); 866 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[2], MEDIA_TYPE_VIDEO));
871 } 867 }
872 868
873 // This test that the media direction is set to send/receive in an answer if 869 // This test that the media direction is set to send/receive in an answer if
874 // the offer is send receive. 870 // the offer is send receive.
(...skipping 20 matching lines...) Expand all
895 } 891 }
896 892
897 // Test that a data content with an unknown protocol is rejected in an answer. 893 // Test that a data content with an unknown protocol is rejected in an answer.
898 TEST_F(MediaSessionDescriptionFactoryTest, 894 TEST_F(MediaSessionDescriptionFactoryTest,
899 CreateDataAnswerToOfferWithUnknownProtocol) { 895 CreateDataAnswerToOfferWithUnknownProtocol) {
900 MediaSessionOptions opts; 896 MediaSessionOptions opts;
901 opts.data_channel_type = cricket::DCT_RTP; 897 opts.data_channel_type = cricket::DCT_RTP;
902 opts.recv_audio = false; 898 opts.recv_audio = false;
903 f1_.set_secure(SEC_ENABLED); 899 f1_.set_secure(SEC_ENABLED);
904 f2_.set_secure(SEC_ENABLED); 900 f2_.set_secure(SEC_ENABLED);
905 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 901 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
906 ContentInfo* dc_offer= offer->GetContentByName("data"); 902 ContentInfo* dc_offer= offer->GetContentByName("data");
907 ASSERT_TRUE(dc_offer != NULL); 903 ASSERT_TRUE(dc_offer != NULL);
908 DataContentDescription* dcd_offer = 904 DataContentDescription* dcd_offer =
909 static_cast<DataContentDescription*>(dc_offer->description); 905 static_cast<DataContentDescription*>(dc_offer->description);
910 ASSERT_TRUE(dcd_offer != NULL); 906 ASSERT_TRUE(dcd_offer != NULL);
911 std::string protocol = "a weird unknown protocol"; 907 std::string protocol = "a weird unknown protocol";
912 dcd_offer->set_protocol(protocol); 908 dcd_offer->set_protocol(protocol);
913 909
914 rtc::scoped_ptr<SessionDescription> answer( 910 std::unique_ptr<SessionDescription> answer(
915 f2_.CreateAnswer(offer.get(), opts, NULL)); 911 f2_.CreateAnswer(offer.get(), opts, NULL));
916 912
917 const ContentInfo* dc_answer = answer->GetContentByName("data"); 913 const ContentInfo* dc_answer = answer->GetContentByName("data");
918 ASSERT_TRUE(dc_answer != NULL); 914 ASSERT_TRUE(dc_answer != NULL);
919 EXPECT_TRUE(dc_answer->rejected); 915 EXPECT_TRUE(dc_answer->rejected);
920 const DataContentDescription* dcd_answer = 916 const DataContentDescription* dcd_answer =
921 static_cast<const DataContentDescription*>(dc_answer->description); 917 static_cast<const DataContentDescription*>(dc_answer->description);
922 ASSERT_TRUE(dcd_answer != NULL); 918 ASSERT_TRUE(dcd_answer != NULL);
923 EXPECT_EQ(protocol, dcd_answer->protocol()); 919 EXPECT_EQ(protocol, dcd_answer->protocol());
924 } 920 }
925 921
926 // Test that the media protocol is RTP/AVPF if DTLS and SDES are disabled. 922 // Test that the media protocol is RTP/AVPF if DTLS and SDES are disabled.
927 TEST_F(MediaSessionDescriptionFactoryTest, AudioOfferAnswerWithCryptoDisabled) { 923 TEST_F(MediaSessionDescriptionFactoryTest, AudioOfferAnswerWithCryptoDisabled) {
928 MediaSessionOptions opts; 924 MediaSessionOptions opts;
929 f1_.set_secure(SEC_DISABLED); 925 f1_.set_secure(SEC_DISABLED);
930 f2_.set_secure(SEC_DISABLED); 926 f2_.set_secure(SEC_DISABLED);
931 tdf1_.set_secure(SEC_DISABLED); 927 tdf1_.set_secure(SEC_DISABLED);
932 tdf2_.set_secure(SEC_DISABLED); 928 tdf2_.set_secure(SEC_DISABLED);
933 929
934 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 930 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
935 const AudioContentDescription* offer_acd = 931 const AudioContentDescription* offer_acd =
936 GetFirstAudioContentDescription(offer.get()); 932 GetFirstAudioContentDescription(offer.get());
937 ASSERT_TRUE(offer_acd != NULL); 933 ASSERT_TRUE(offer_acd != NULL);
938 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), offer_acd->protocol()); 934 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), offer_acd->protocol());
939 935
940 rtc::scoped_ptr<SessionDescription> answer( 936 std::unique_ptr<SessionDescription> answer(
941 f2_.CreateAnswer(offer.get(), opts, NULL)); 937 f2_.CreateAnswer(offer.get(), opts, NULL));
942 938
943 const ContentInfo* ac_answer = answer->GetContentByName("audio"); 939 const ContentInfo* ac_answer = answer->GetContentByName("audio");
944 ASSERT_TRUE(ac_answer != NULL); 940 ASSERT_TRUE(ac_answer != NULL);
945 EXPECT_FALSE(ac_answer->rejected); 941 EXPECT_FALSE(ac_answer->rejected);
946 942
947 const AudioContentDescription* answer_acd = 943 const AudioContentDescription* answer_acd =
948 GetFirstAudioContentDescription(answer.get()); 944 GetFirstAudioContentDescription(answer.get());
949 ASSERT_TRUE(answer_acd != NULL); 945 ASSERT_TRUE(answer_acd != NULL);
950 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), answer_acd->protocol()); 946 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), answer_acd->protocol());
951 } 947 }
952 948
953 // Create a video offer and answer and ensure the RTP header extensions 949 // Create a video offer and answer and ensure the RTP header extensions
954 // matches what we expect. 950 // matches what we expect.
955 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferAnswerWithRtpExtensions) { 951 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferAnswerWithRtpExtensions) {
956 MediaSessionOptions opts; 952 MediaSessionOptions opts;
957 opts.recv_video = true; 953 opts.recv_video = true;
958 954
959 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); 955 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1));
960 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); 956 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1));
961 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); 957 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2));
962 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); 958 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2));
963 959
964 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 960 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
965 ASSERT_TRUE(offer.get() != NULL); 961 ASSERT_TRUE(offer.get() != NULL);
966 rtc::scoped_ptr<SessionDescription> answer( 962 std::unique_ptr<SessionDescription> answer(
967 f2_.CreateAnswer(offer.get(), opts, NULL)); 963 f2_.CreateAnswer(offer.get(), opts, NULL));
968 964
969 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension1), 965 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension1),
970 GetFirstAudioContentDescription( 966 GetFirstAudioContentDescription(
971 offer.get())->rtp_header_extensions()); 967 offer.get())->rtp_header_extensions());
972 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtension1), 968 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtension1),
973 GetFirstVideoContentDescription( 969 GetFirstVideoContentDescription(
974 offer.get())->rtp_header_extensions()); 970 offer.get())->rtp_header_extensions());
975 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), 971 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer),
976 GetFirstAudioContentDescription( 972 GetFirstAudioContentDescription(
977 answer.get())->rtp_header_extensions()); 973 answer.get())->rtp_header_extensions());
978 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), 974 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer),
979 GetFirstVideoContentDescription( 975 GetFirstVideoContentDescription(
980 answer.get())->rtp_header_extensions()); 976 answer.get())->rtp_header_extensions());
981 } 977 }
982 978
983 // Create an audio, video, data answer without legacy StreamParams. 979 // Create an audio, video, data answer without legacy StreamParams.
984 TEST_F(MediaSessionDescriptionFactoryTest, 980 TEST_F(MediaSessionDescriptionFactoryTest,
985 TestCreateAnswerWithoutLegacyStreams) { 981 TestCreateAnswerWithoutLegacyStreams) {
986 MediaSessionOptions opts; 982 MediaSessionOptions opts;
987 opts.recv_video = true; 983 opts.recv_video = true;
988 opts.data_channel_type = cricket::DCT_RTP; 984 opts.data_channel_type = cricket::DCT_RTP;
989 f1_.set_add_legacy_streams(false); 985 f1_.set_add_legacy_streams(false);
990 f2_.set_add_legacy_streams(false); 986 f2_.set_add_legacy_streams(false);
991 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 987 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
992 ASSERT_TRUE(offer.get() != NULL); 988 ASSERT_TRUE(offer.get() != NULL);
993 rtc::scoped_ptr<SessionDescription> answer( 989 std::unique_ptr<SessionDescription> answer(
994 f2_.CreateAnswer(offer.get(), opts, NULL)); 990 f2_.CreateAnswer(offer.get(), opts, NULL));
995 const ContentInfo* ac = answer->GetContentByName("audio"); 991 const ContentInfo* ac = answer->GetContentByName("audio");
996 const ContentInfo* vc = answer->GetContentByName("video"); 992 const ContentInfo* vc = answer->GetContentByName("video");
997 const ContentInfo* dc = answer->GetContentByName("data"); 993 const ContentInfo* dc = answer->GetContentByName("data");
998 ASSERT_TRUE(ac != NULL); 994 ASSERT_TRUE(ac != NULL);
999 ASSERT_TRUE(vc != NULL); 995 ASSERT_TRUE(vc != NULL);
1000 const AudioContentDescription* acd = 996 const AudioContentDescription* acd =
1001 static_cast<const AudioContentDescription*>(ac->description); 997 static_cast<const AudioContentDescription*>(ac->description);
1002 const VideoContentDescription* vcd = 998 const VideoContentDescription* vcd =
1003 static_cast<const VideoContentDescription*>(vc->description); 999 static_cast<const VideoContentDescription*>(vc->description);
1004 const DataContentDescription* dcd = 1000 const DataContentDescription* dcd =
1005 static_cast<const DataContentDescription*>(dc->description); 1001 static_cast<const DataContentDescription*>(dc->description);
1006 1002
1007 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. 1003 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams.
1008 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. 1004 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams.
1009 EXPECT_FALSE(dcd->has_ssrcs()); // No StreamParams. 1005 EXPECT_FALSE(dcd->has_ssrcs()); // No StreamParams.
1010 } 1006 }
1011 1007
1012 TEST_F(MediaSessionDescriptionFactoryTest, TestPartial) { 1008 TEST_F(MediaSessionDescriptionFactoryTest, TestPartial) {
1013 MediaSessionOptions opts; 1009 MediaSessionOptions opts;
1014 opts.recv_video = true; 1010 opts.recv_video = true;
1015 opts.data_channel_type = cricket::DCT_RTP; 1011 opts.data_channel_type = cricket::DCT_RTP;
1016 f1_.set_secure(SEC_ENABLED); 1012 f1_.set_secure(SEC_ENABLED);
1017 rtc::scoped_ptr<SessionDescription> 1013 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1018 offer(f1_.CreateOffer(opts, NULL));
1019 ASSERT_TRUE(offer.get() != NULL); 1014 ASSERT_TRUE(offer.get() != NULL);
1020 const ContentInfo* ac = offer->GetContentByName("audio"); 1015 const ContentInfo* ac = offer->GetContentByName("audio");
1021 const ContentInfo* vc = offer->GetContentByName("video"); 1016 const ContentInfo* vc = offer->GetContentByName("video");
1022 const ContentInfo* dc = offer->GetContentByName("data"); 1017 const ContentInfo* dc = offer->GetContentByName("data");
1023 AudioContentDescription* acd = const_cast<AudioContentDescription*>( 1018 AudioContentDescription* acd = const_cast<AudioContentDescription*>(
1024 static_cast<const AudioContentDescription*>(ac->description)); 1019 static_cast<const AudioContentDescription*>(ac->description));
1025 VideoContentDescription* vcd = const_cast<VideoContentDescription*>( 1020 VideoContentDescription* vcd = const_cast<VideoContentDescription*>(
1026 static_cast<const VideoContentDescription*>(vc->description)); 1021 static_cast<const VideoContentDescription*>(vc->description));
1027 DataContentDescription* dcd = const_cast<DataContentDescription*>( 1022 DataContentDescription* dcd = const_cast<DataContentDescription*>(
1028 static_cast<const DataContentDescription*>(dc->description)); 1023 static_cast<const DataContentDescription*>(dc->description));
(...skipping 19 matching lines...) Expand all
1048 1043
1049 // Create a typical video answer, and ensure it matches what we expect. 1044 // Create a typical video answer, and ensure it matches what we expect.
1050 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerRtcpMux) { 1045 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerRtcpMux) {
1051 MediaSessionOptions offer_opts; 1046 MediaSessionOptions offer_opts;
1052 MediaSessionOptions answer_opts; 1047 MediaSessionOptions answer_opts;
1053 answer_opts.recv_video = true; 1048 answer_opts.recv_video = true;
1054 offer_opts.recv_video = true; 1049 offer_opts.recv_video = true;
1055 answer_opts.data_channel_type = cricket::DCT_RTP; 1050 answer_opts.data_channel_type = cricket::DCT_RTP;
1056 offer_opts.data_channel_type = cricket::DCT_RTP; 1051 offer_opts.data_channel_type = cricket::DCT_RTP;
1057 1052
1058 rtc::scoped_ptr<SessionDescription> offer; 1053 std::unique_ptr<SessionDescription> offer;
1059 rtc::scoped_ptr<SessionDescription> answer; 1054 std::unique_ptr<SessionDescription> answer;
1060 1055
1061 offer_opts.rtcp_mux_enabled = true; 1056 offer_opts.rtcp_mux_enabled = true;
1062 answer_opts.rtcp_mux_enabled = true; 1057 answer_opts.rtcp_mux_enabled = true;
1063 1058
1064 offer.reset(f1_.CreateOffer(offer_opts, NULL)); 1059 offer.reset(f1_.CreateOffer(offer_opts, NULL));
1065 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); 1060 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL));
1066 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); 1061 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get()));
1067 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); 1062 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get()));
1068 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); 1063 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get()));
1069 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); 1064 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get()));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 EXPECT_FALSE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); 1123 EXPECT_FALSE(GetFirstDataContentDescription(offer.get())->rtcp_mux());
1129 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); 1124 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux());
1130 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); 1125 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux());
1131 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); 1126 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux());
1132 } 1127 }
1133 1128
1134 // Create an audio-only answer to a video offer. 1129 // Create an audio-only answer to a video offer.
1135 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerToVideo) { 1130 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerToVideo) {
1136 MediaSessionOptions opts; 1131 MediaSessionOptions opts;
1137 opts.recv_video = true; 1132 opts.recv_video = true;
1138 rtc::scoped_ptr<SessionDescription> 1133 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1139 offer(f1_.CreateOffer(opts, NULL));
1140 ASSERT_TRUE(offer.get() != NULL); 1134 ASSERT_TRUE(offer.get() != NULL);
1141 rtc::scoped_ptr<SessionDescription> answer( 1135 std::unique_ptr<SessionDescription> answer(
1142 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); 1136 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL));
1143 const ContentInfo* ac = answer->GetContentByName("audio"); 1137 const ContentInfo* ac = answer->GetContentByName("audio");
1144 const ContentInfo* vc = answer->GetContentByName("video"); 1138 const ContentInfo* vc = answer->GetContentByName("video");
1145 ASSERT_TRUE(ac != NULL); 1139 ASSERT_TRUE(ac != NULL);
1146 ASSERT_TRUE(vc != NULL); 1140 ASSERT_TRUE(vc != NULL);
1147 ASSERT_TRUE(vc->description != NULL); 1141 ASSERT_TRUE(vc->description != NULL);
1148 EXPECT_TRUE(vc->rejected); 1142 EXPECT_TRUE(vc->rejected);
1149 } 1143 }
1150 1144
1151 // Create an audio-only answer to an offer with data. 1145 // Create an audio-only answer to an offer with data.
1152 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateNoDataAnswerToDataOffer) { 1146 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateNoDataAnswerToDataOffer) {
1153 MediaSessionOptions opts; 1147 MediaSessionOptions opts;
1154 opts.data_channel_type = cricket::DCT_RTP; 1148 opts.data_channel_type = cricket::DCT_RTP;
1155 rtc::scoped_ptr<SessionDescription> 1149 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1156 offer(f1_.CreateOffer(opts, NULL));
1157 ASSERT_TRUE(offer.get() != NULL); 1150 ASSERT_TRUE(offer.get() != NULL);
1158 rtc::scoped_ptr<SessionDescription> answer( 1151 std::unique_ptr<SessionDescription> answer(
1159 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); 1152 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL));
1160 const ContentInfo* ac = answer->GetContentByName("audio"); 1153 const ContentInfo* ac = answer->GetContentByName("audio");
1161 const ContentInfo* dc = answer->GetContentByName("data"); 1154 const ContentInfo* dc = answer->GetContentByName("data");
1162 ASSERT_TRUE(ac != NULL); 1155 ASSERT_TRUE(ac != NULL);
1163 ASSERT_TRUE(dc != NULL); 1156 ASSERT_TRUE(dc != NULL);
1164 ASSERT_TRUE(dc->description != NULL); 1157 ASSERT_TRUE(dc->description != NULL);
1165 EXPECT_TRUE(dc->rejected); 1158 EXPECT_TRUE(dc->rejected);
1166 } 1159 }
1167 1160
1168 // Create an answer that rejects the contents which are rejected in the offer. 1161 // Create an answer that rejects the contents which are rejected in the offer.
1169 TEST_F(MediaSessionDescriptionFactoryTest, 1162 TEST_F(MediaSessionDescriptionFactoryTest,
1170 CreateAnswerToOfferWithRejectedMedia) { 1163 CreateAnswerToOfferWithRejectedMedia) {
1171 MediaSessionOptions opts; 1164 MediaSessionOptions opts;
1172 opts.recv_video = true; 1165 opts.recv_video = true;
1173 opts.data_channel_type = cricket::DCT_RTP; 1166 opts.data_channel_type = cricket::DCT_RTP;
1174 rtc::scoped_ptr<SessionDescription> 1167 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1175 offer(f1_.CreateOffer(opts, NULL));
1176 ASSERT_TRUE(offer.get() != NULL); 1168 ASSERT_TRUE(offer.get() != NULL);
1177 ContentInfo* ac = offer->GetContentByName("audio"); 1169 ContentInfo* ac = offer->GetContentByName("audio");
1178 ContentInfo* vc = offer->GetContentByName("video"); 1170 ContentInfo* vc = offer->GetContentByName("video");
1179 ContentInfo* dc = offer->GetContentByName("data"); 1171 ContentInfo* dc = offer->GetContentByName("data");
1180 ASSERT_TRUE(ac != NULL); 1172 ASSERT_TRUE(ac != NULL);
1181 ASSERT_TRUE(vc != NULL); 1173 ASSERT_TRUE(vc != NULL);
1182 ASSERT_TRUE(dc != NULL); 1174 ASSERT_TRUE(dc != NULL);
1183 ac->rejected = true; 1175 ac->rejected = true;
1184 vc->rejected = true; 1176 vc->rejected = true;
1185 dc->rejected = true; 1177 dc->rejected = true;
1186 rtc::scoped_ptr<SessionDescription> answer( 1178 std::unique_ptr<SessionDescription> answer(
1187 f2_.CreateAnswer(offer.get(), opts, NULL)); 1179 f2_.CreateAnswer(offer.get(), opts, NULL));
1188 ac = answer->GetContentByName("audio"); 1180 ac = answer->GetContentByName("audio");
1189 vc = answer->GetContentByName("video"); 1181 vc = answer->GetContentByName("video");
1190 dc = answer->GetContentByName("data"); 1182 dc = answer->GetContentByName("data");
1191 ASSERT_TRUE(ac != NULL); 1183 ASSERT_TRUE(ac != NULL);
1192 ASSERT_TRUE(vc != NULL); 1184 ASSERT_TRUE(vc != NULL);
1193 ASSERT_TRUE(dc != NULL); 1185 ASSERT_TRUE(dc != NULL);
1194 EXPECT_TRUE(ac->rejected); 1186 EXPECT_TRUE(ac->rejected);
1195 EXPECT_TRUE(vc->rejected); 1187 EXPECT_TRUE(vc->rejected);
1196 EXPECT_TRUE(dc->rejected); 1188 EXPECT_TRUE(dc->rejected);
1197 } 1189 }
1198 1190
1199 // Create an audio and video offer with: 1191 // Create an audio and video offer with:
1200 // - one video track 1192 // - one video track
1201 // - two audio tracks 1193 // - two audio tracks
1202 // - two data tracks 1194 // - two data tracks
1203 // and ensure it matches what we expect. Also updates the initial offer by 1195 // and ensure it matches what we expect. Also updates the initial offer by
1204 // adding a new video track and replaces one of the audio tracks. 1196 // adding a new video track and replaces one of the audio tracks.
1205 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) { 1197 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) {
1206 MediaSessionOptions opts; 1198 MediaSessionOptions opts;
1207 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); 1199 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1);
1208 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); 1200 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1);
1209 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2, kMediaStream1); 1201 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2, kMediaStream1);
1210 opts.data_channel_type = cricket::DCT_RTP; 1202 opts.data_channel_type = cricket::DCT_RTP;
1211 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack1, kMediaStream1); 1203 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack1, kMediaStream1);
1212 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack2, kMediaStream1); 1204 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack2, kMediaStream1);
1213 1205
1214 f1_.set_secure(SEC_ENABLED); 1206 f1_.set_secure(SEC_ENABLED);
1215 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 1207 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1216 1208
1217 ASSERT_TRUE(offer.get() != NULL); 1209 ASSERT_TRUE(offer.get() != NULL);
1218 const ContentInfo* ac = offer->GetContentByName("audio"); 1210 const ContentInfo* ac = offer->GetContentByName("audio");
1219 const ContentInfo* vc = offer->GetContentByName("video"); 1211 const ContentInfo* vc = offer->GetContentByName("video");
1220 const ContentInfo* dc = offer->GetContentByName("data"); 1212 const ContentInfo* dc = offer->GetContentByName("data");
1221 ASSERT_TRUE(ac != NULL); 1213 ASSERT_TRUE(ac != NULL);
1222 ASSERT_TRUE(vc != NULL); 1214 ASSERT_TRUE(vc != NULL);
1223 ASSERT_TRUE(dc != NULL); 1215 ASSERT_TRUE(dc != NULL);
1224 const AudioContentDescription* acd = 1216 const AudioContentDescription* acd =
1225 static_cast<const AudioContentDescription*>(ac->description); 1217 static_cast<const AudioContentDescription*>(ac->description);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); 1267 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80);
1276 1268
1277 1269
1278 // Update the offer. Add a new video track that is not synched to the 1270 // Update the offer. Add a new video track that is not synched to the
1279 // other tracks and replace audio track 2 with audio track 3. 1271 // other tracks and replace audio track 2 with audio track 3.
1280 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack2, kMediaStream2); 1272 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack2, kMediaStream2);
1281 opts.RemoveSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2); 1273 opts.RemoveSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2);
1282 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack3, kMediaStream1); 1274 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack3, kMediaStream1);
1283 opts.RemoveSendStream(MEDIA_TYPE_DATA, kDataTrack2); 1275 opts.RemoveSendStream(MEDIA_TYPE_DATA, kDataTrack2);
1284 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack3, kMediaStream1); 1276 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack3, kMediaStream1);
1285 rtc::scoped_ptr<SessionDescription> 1277 std::unique_ptr<SessionDescription> updated_offer(
1286 updated_offer(f1_.CreateOffer(opts, offer.get())); 1278 f1_.CreateOffer(opts, offer.get()));
1287 1279
1288 ASSERT_TRUE(updated_offer.get() != NULL); 1280 ASSERT_TRUE(updated_offer.get() != NULL);
1289 ac = updated_offer->GetContentByName("audio"); 1281 ac = updated_offer->GetContentByName("audio");
1290 vc = updated_offer->GetContentByName("video"); 1282 vc = updated_offer->GetContentByName("video");
1291 dc = updated_offer->GetContentByName("data"); 1283 dc = updated_offer->GetContentByName("data");
1292 ASSERT_TRUE(ac != NULL); 1284 ASSERT_TRUE(ac != NULL);
1293 ASSERT_TRUE(vc != NULL); 1285 ASSERT_TRUE(vc != NULL);
1294 ASSERT_TRUE(dc != NULL); 1286 ASSERT_TRUE(dc != NULL);
1295 const AudioContentDescription* updated_acd = 1287 const AudioContentDescription* updated_acd =
1296 static_cast<const AudioContentDescription*>(ac->description); 1288 static_cast<const AudioContentDescription*>(ac->description);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 ASSERT_EQ(1U, updated_data_streams[1].ssrcs.size()); 1325 ASSERT_EQ(1U, updated_data_streams[1].ssrcs.size());
1334 EXPECT_NE(0U, updated_data_streams[1].ssrcs[0]); 1326 EXPECT_NE(0U, updated_data_streams[1].ssrcs[0]);
1335 EXPECT_EQ(updated_data_streams[0].cname, updated_data_streams[1].cname); 1327 EXPECT_EQ(updated_data_streams[0].cname, updated_data_streams[1].cname);
1336 } 1328 }
1337 1329
1338 // Create an offer with simulcast video stream. 1330 // Create an offer with simulcast video stream.
1339 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSimulcastVideoOffer) { 1331 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSimulcastVideoOffer) {
1340 MediaSessionOptions opts; 1332 MediaSessionOptions opts;
1341 const int num_sim_layers = 3; 1333 const int num_sim_layers = 3;
1342 opts.AddSendVideoStream(kVideoTrack1, kMediaStream1, num_sim_layers); 1334 opts.AddSendVideoStream(kVideoTrack1, kMediaStream1, num_sim_layers);
1343 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 1335 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1344 1336
1345 ASSERT_TRUE(offer.get() != NULL); 1337 ASSERT_TRUE(offer.get() != NULL);
1346 const ContentInfo* vc = offer->GetContentByName("video"); 1338 const ContentInfo* vc = offer->GetContentByName("video");
1347 ASSERT_TRUE(vc != NULL); 1339 ASSERT_TRUE(vc != NULL);
1348 const VideoContentDescription* vcd = 1340 const VideoContentDescription* vcd =
1349 static_cast<const VideoContentDescription*>(vc->description); 1341 static_cast<const VideoContentDescription*>(vc->description);
1350 1342
1351 const StreamParamsVec& video_streams = vcd->streams(); 1343 const StreamParamsVec& video_streams = vcd->streams();
1352 ASSERT_EQ(1U, video_streams.size()); 1344 ASSERT_EQ(1U, video_streams.size());
1353 EXPECT_EQ(kVideoTrack1, video_streams[0].id); 1345 EXPECT_EQ(kVideoTrack1, video_streams[0].id);
1354 const SsrcGroup* sim_ssrc_group = 1346 const SsrcGroup* sim_ssrc_group =
1355 video_streams[0].get_ssrc_group(cricket::kSimSsrcGroupSemantics); 1347 video_streams[0].get_ssrc_group(cricket::kSimSsrcGroupSemantics);
1356 ASSERT_TRUE(sim_ssrc_group != NULL); 1348 ASSERT_TRUE(sim_ssrc_group != NULL);
1357 EXPECT_EQ(static_cast<size_t>(num_sim_layers), sim_ssrc_group->ssrcs.size()); 1349 EXPECT_EQ(static_cast<size_t>(num_sim_layers), sim_ssrc_group->ssrcs.size());
1358 } 1350 }
1359 1351
1360 // Create an audio and video answer to a standard video offer with: 1352 // Create an audio and video answer to a standard video offer with:
1361 // - one video track 1353 // - one video track
1362 // - two audio tracks 1354 // - two audio tracks
1363 // - two data tracks 1355 // - two data tracks
1364 // and ensure it matches what we expect. Also updates the initial answer by 1356 // and ensure it matches what we expect. Also updates the initial answer by
1365 // adding a new video track and removes one of the audio tracks. 1357 // adding a new video track and removes one of the audio tracks.
1366 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) { 1358 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) {
1367 MediaSessionOptions offer_opts; 1359 MediaSessionOptions offer_opts;
1368 offer_opts.recv_video = true; 1360 offer_opts.recv_video = true;
1369 offer_opts.data_channel_type = cricket::DCT_RTP; 1361 offer_opts.data_channel_type = cricket::DCT_RTP;
1370 f1_.set_secure(SEC_ENABLED); 1362 f1_.set_secure(SEC_ENABLED);
1371 f2_.set_secure(SEC_ENABLED); 1363 f2_.set_secure(SEC_ENABLED);
1372 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(offer_opts, 1364 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(offer_opts, NULL));
1373 NULL));
1374 1365
1375 MediaSessionOptions opts; 1366 MediaSessionOptions opts;
1376 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); 1367 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1);
1377 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); 1368 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1);
1378 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2, kMediaStream1); 1369 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2, kMediaStream1);
1379 opts.data_channel_type = cricket::DCT_RTP; 1370 opts.data_channel_type = cricket::DCT_RTP;
1380 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack1, kMediaStream1); 1371 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack1, kMediaStream1);
1381 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack2, kMediaStream1); 1372 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack2, kMediaStream1);
1382 1373
1383 rtc::scoped_ptr<SessionDescription> 1374 std::unique_ptr<SessionDescription> answer(
1384 answer(f2_.CreateAnswer(offer.get(), opts, NULL)); 1375 f2_.CreateAnswer(offer.get(), opts, NULL));
1385 1376
1386 ASSERT_TRUE(answer.get() != NULL); 1377 ASSERT_TRUE(answer.get() != NULL);
1387 const ContentInfo* ac = answer->GetContentByName("audio"); 1378 const ContentInfo* ac = answer->GetContentByName("audio");
1388 const ContentInfo* vc = answer->GetContentByName("video"); 1379 const ContentInfo* vc = answer->GetContentByName("video");
1389 const ContentInfo* dc = answer->GetContentByName("data"); 1380 const ContentInfo* dc = answer->GetContentByName("data");
1390 ASSERT_TRUE(ac != NULL); 1381 ASSERT_TRUE(ac != NULL);
1391 ASSERT_TRUE(vc != NULL); 1382 ASSERT_TRUE(vc != NULL);
1392 ASSERT_TRUE(dc != NULL); 1383 ASSERT_TRUE(dc != NULL);
1393 const AudioContentDescription* acd = 1384 const AudioContentDescription* acd =
1394 static_cast<const AudioContentDescription*>(ac->description); 1385 static_cast<const AudioContentDescription*>(ac->description);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 1432
1442 EXPECT_EQ(cricket::kDataMaxBandwidth, 1433 EXPECT_EQ(cricket::kDataMaxBandwidth,
1443 dcd->bandwidth()); // default bandwidth (auto) 1434 dcd->bandwidth()); // default bandwidth (auto)
1444 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on 1435 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on
1445 1436
1446 // Update the answer. Add a new video track that is not synched to the 1437 // Update the answer. Add a new video track that is not synched to the
1447 // other traacks and remove 1 audio track. 1438 // other traacks and remove 1 audio track.
1448 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack2, kMediaStream2); 1439 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack2, kMediaStream2);
1449 opts.RemoveSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2); 1440 opts.RemoveSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2);
1450 opts.RemoveSendStream(MEDIA_TYPE_DATA, kDataTrack2); 1441 opts.RemoveSendStream(MEDIA_TYPE_DATA, kDataTrack2);
1451 rtc::scoped_ptr<SessionDescription> 1442 std::unique_ptr<SessionDescription> updated_answer(
1452 updated_answer(f2_.CreateAnswer(offer.get(), opts, answer.get())); 1443 f2_.CreateAnswer(offer.get(), opts, answer.get()));
1453 1444
1454 ASSERT_TRUE(updated_answer.get() != NULL); 1445 ASSERT_TRUE(updated_answer.get() != NULL);
1455 ac = updated_answer->GetContentByName("audio"); 1446 ac = updated_answer->GetContentByName("audio");
1456 vc = updated_answer->GetContentByName("video"); 1447 vc = updated_answer->GetContentByName("video");
1457 dc = updated_answer->GetContentByName("data"); 1448 dc = updated_answer->GetContentByName("data");
1458 ASSERT_TRUE(ac != NULL); 1449 ASSERT_TRUE(ac != NULL);
1459 ASSERT_TRUE(vc != NULL); 1450 ASSERT_TRUE(vc != NULL);
1460 ASSERT_TRUE(dc != NULL); 1451 ASSERT_TRUE(dc != NULL);
1461 const AudioContentDescription* updated_acd = 1452 const AudioContentDescription* updated_acd =
1462 static_cast<const AudioContentDescription*>(ac->description); 1453 static_cast<const AudioContentDescription*>(ac->description);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 1488
1498 // Create an updated offer after creating an answer to the original offer and 1489 // Create an updated offer after creating an answer to the original offer and
1499 // verify that the codecs that were part of the original answer are not changed 1490 // verify that the codecs that were part of the original answer are not changed
1500 // in the updated offer. 1491 // in the updated offer.
1501 TEST_F(MediaSessionDescriptionFactoryTest, 1492 TEST_F(MediaSessionDescriptionFactoryTest,
1502 RespondentCreatesOfferAfterCreatingAnswer) { 1493 RespondentCreatesOfferAfterCreatingAnswer) {
1503 MediaSessionOptions opts; 1494 MediaSessionOptions opts;
1504 opts.recv_audio = true; 1495 opts.recv_audio = true;
1505 opts.recv_video = true; 1496 opts.recv_video = true;
1506 1497
1507 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 1498 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1508 rtc::scoped_ptr<SessionDescription> answer( 1499 std::unique_ptr<SessionDescription> answer(
1509 f2_.CreateAnswer(offer.get(), opts, NULL)); 1500 f2_.CreateAnswer(offer.get(), opts, NULL));
1510 1501
1511 const AudioContentDescription* acd = 1502 const AudioContentDescription* acd =
1512 GetFirstAudioContentDescription(answer.get()); 1503 GetFirstAudioContentDescription(answer.get());
1513 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); 1504 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs());
1514 1505
1515 const VideoContentDescription* vcd = 1506 const VideoContentDescription* vcd =
1516 GetFirstVideoContentDescription(answer.get()); 1507 GetFirstVideoContentDescription(answer.get());
1517 EXPECT_EQ(MAKE_VECTOR(kVideoCodecsAnswer), vcd->codecs()); 1508 EXPECT_EQ(MAKE_VECTOR(kVideoCodecsAnswer), vcd->codecs());
1518 1509
1519 rtc::scoped_ptr<SessionDescription> updated_offer( 1510 std::unique_ptr<SessionDescription> updated_offer(
1520 f2_.CreateOffer(opts, answer.get())); 1511 f2_.CreateOffer(opts, answer.get()));
1521 1512
1522 // The expected audio codecs are the common audio codecs from the first 1513 // The expected audio codecs are the common audio codecs from the first
1523 // offer/answer exchange plus the audio codecs only |f2_| offer, sorted in 1514 // offer/answer exchange plus the audio codecs only |f2_| offer, sorted in
1524 // preference order. 1515 // preference order.
1525 // TODO(wu): |updated_offer| should not include the codec 1516 // TODO(wu): |updated_offer| should not include the codec
1526 // (i.e. |kAudioCodecs2[0]|) the other side doesn't support. 1517 // (i.e. |kAudioCodecs2[0]|) the other side doesn't support.
1527 const AudioCodec kUpdatedAudioCodecOffer[] = { 1518 const AudioCodec kUpdatedAudioCodecOffer[] = {
1528 kAudioCodecsAnswer[0], 1519 kAudioCodecsAnswer[0],
1529 kAudioCodecsAnswer[1], 1520 kAudioCodecsAnswer[1],
(...skipping 28 matching lines...) Expand all
1558 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); 1549 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1);
1559 // This creates rtx for H264 with the payload type |f1_| uses. 1550 // This creates rtx for H264 with the payload type |f1_| uses.
1560 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); 1551 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs);
1561 f1_.set_video_codecs(f1_codecs); 1552 f1_.set_video_codecs(f1_codecs);
1562 1553
1563 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); 1554 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2);
1564 // This creates rtx for H264 with the payload type |f2_| uses. 1555 // This creates rtx for H264 with the payload type |f2_| uses.
1565 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); 1556 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs);
1566 f2_.set_video_codecs(f2_codecs); 1557 f2_.set_video_codecs(f2_codecs);
1567 1558
1568 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 1559 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1569 ASSERT_TRUE(offer.get() != NULL); 1560 ASSERT_TRUE(offer.get() != NULL);
1570 rtc::scoped_ptr<SessionDescription> answer( 1561 std::unique_ptr<SessionDescription> answer(
1571 f2_.CreateAnswer(offer.get(), opts, NULL)); 1562 f2_.CreateAnswer(offer.get(), opts, NULL));
1572 1563
1573 const VideoContentDescription* vcd = 1564 const VideoContentDescription* vcd =
1574 GetFirstVideoContentDescription(answer.get()); 1565 GetFirstVideoContentDescription(answer.get());
1575 1566
1576 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); 1567 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer);
1577 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), 1568 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id),
1578 &expected_codecs); 1569 &expected_codecs);
1579 1570
1580 EXPECT_EQ(expected_codecs, vcd->codecs()); 1571 EXPECT_EQ(expected_codecs, vcd->codecs());
1581 1572
1582 // Now, make sure we get same result, except for the preference order, 1573 // Now, make sure we get same result, except for the preference order,
1583 // if |f2_| creates an updated offer even though the default payload types 1574 // if |f2_| creates an updated offer even though the default payload types
1584 // are different from |f1_|. 1575 // are different from |f1_|.
1585 expected_codecs[0].preference = f1_codecs[1].preference; 1576 expected_codecs[0].preference = f1_codecs[1].preference;
1586 1577
1587 rtc::scoped_ptr<SessionDescription> updated_offer( 1578 std::unique_ptr<SessionDescription> updated_offer(
1588 f2_.CreateOffer(opts, answer.get())); 1579 f2_.CreateOffer(opts, answer.get()));
1589 ASSERT_TRUE(updated_offer); 1580 ASSERT_TRUE(updated_offer);
1590 rtc::scoped_ptr<SessionDescription> updated_answer( 1581 std::unique_ptr<SessionDescription> updated_answer(
1591 f1_.CreateAnswer(updated_offer.get(), opts, answer.get())); 1582 f1_.CreateAnswer(updated_offer.get(), opts, answer.get()));
1592 1583
1593 const VideoContentDescription* updated_vcd = 1584 const VideoContentDescription* updated_vcd =
1594 GetFirstVideoContentDescription(updated_answer.get()); 1585 GetFirstVideoContentDescription(updated_answer.get());
1595 1586
1596 EXPECT_EQ(expected_codecs, updated_vcd->codecs()); 1587 EXPECT_EQ(expected_codecs, updated_vcd->codecs());
1597 } 1588 }
1598 1589
1599 // Create an updated offer that adds video after creating an audio only answer 1590 // Create an updated offer that adds video after creating an audio only answer
1600 // to the original offer. This test verifies that if a video codec and the RTX 1591 // to the original offer. This test verifies that if a video codec and the RTX
1601 // codec have the same default payload type as an audio codec that is already in 1592 // codec have the same default payload type as an audio codec that is already in
1602 // use, the added codecs payload types are changed. 1593 // use, the added codecs payload types are changed.
1603 TEST_F(MediaSessionDescriptionFactoryTest, 1594 TEST_F(MediaSessionDescriptionFactoryTest,
1604 RespondentCreatesOfferWithVideoAndRtxAfterCreatingAudioAnswer) { 1595 RespondentCreatesOfferWithVideoAndRtxAfterCreatingAudioAnswer) {
1605 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); 1596 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1);
1606 // This creates rtx for H264 with the payload type |f1_| uses. 1597 // This creates rtx for H264 with the payload type |f1_| uses.
1607 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); 1598 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs);
1608 f1_.set_video_codecs(f1_codecs); 1599 f1_.set_video_codecs(f1_codecs);
1609 1600
1610 MediaSessionOptions opts; 1601 MediaSessionOptions opts;
1611 opts.recv_audio = true; 1602 opts.recv_audio = true;
1612 opts.recv_video = false; 1603 opts.recv_video = false;
1613 1604
1614 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 1605 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1615 rtc::scoped_ptr<SessionDescription> answer( 1606 std::unique_ptr<SessionDescription> answer(
1616 f2_.CreateAnswer(offer.get(), opts, NULL)); 1607 f2_.CreateAnswer(offer.get(), opts, NULL));
1617 1608
1618 const AudioContentDescription* acd = 1609 const AudioContentDescription* acd =
1619 GetFirstAudioContentDescription(answer.get()); 1610 GetFirstAudioContentDescription(answer.get());
1620 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); 1611 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs());
1621 1612
1622 // Now - let |f2_| add video with RTX and let the payload type the RTX codec 1613 // Now - let |f2_| add video with RTX and let the payload type the RTX codec
1623 // reference be the same as an audio codec that was negotiated in the 1614 // reference be the same as an audio codec that was negotiated in the
1624 // first offer/answer exchange. 1615 // first offer/answer exchange.
1625 opts.recv_audio = true; 1616 opts.recv_audio = true;
1626 opts.recv_video = true; 1617 opts.recv_video = true;
1627 1618
1628 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); 1619 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2);
1629 int used_pl_type = acd->codecs()[0].id; 1620 int used_pl_type = acd->codecs()[0].id;
1630 f2_codecs[0].id = used_pl_type; // Set the payload type for H264. 1621 f2_codecs[0].id = used_pl_type; // Set the payload type for H264.
1631 AddRtxCodec(VideoCodec::CreateRtxCodec(125, used_pl_type), &f2_codecs); 1622 AddRtxCodec(VideoCodec::CreateRtxCodec(125, used_pl_type), &f2_codecs);
1632 f2_.set_video_codecs(f2_codecs); 1623 f2_.set_video_codecs(f2_codecs);
1633 1624
1634 rtc::scoped_ptr<SessionDescription> updated_offer( 1625 std::unique_ptr<SessionDescription> updated_offer(
1635 f2_.CreateOffer(opts, answer.get())); 1626 f2_.CreateOffer(opts, answer.get()));
1636 ASSERT_TRUE(updated_offer); 1627 ASSERT_TRUE(updated_offer);
1637 rtc::scoped_ptr<SessionDescription> updated_answer( 1628 std::unique_ptr<SessionDescription> updated_answer(
1638 f1_.CreateAnswer(updated_offer.get(), opts, answer.get())); 1629 f1_.CreateAnswer(updated_offer.get(), opts, answer.get()));
1639 1630
1640 const AudioContentDescription* updated_acd = 1631 const AudioContentDescription* updated_acd =
1641 GetFirstAudioContentDescription(answer.get()); 1632 GetFirstAudioContentDescription(answer.get());
1642 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), updated_acd->codecs()); 1633 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), updated_acd->codecs());
1643 1634
1644 const VideoContentDescription* updated_vcd = 1635 const VideoContentDescription* updated_vcd =
1645 GetFirstVideoContentDescription(updated_answer.get()); 1636 GetFirstVideoContentDescription(updated_answer.get());
1646 1637
1647 ASSERT_EQ("H264", updated_vcd->codecs()[0].name); 1638 ASSERT_EQ("H264", updated_vcd->codecs()[0].name);
(...skipping 13 matching lines...) Expand all
1661 RespondentCreatesOfferWithRtxAfterCreatingAnswerWithoutRtx) { 1652 RespondentCreatesOfferWithRtxAfterCreatingAnswerWithoutRtx) {
1662 MediaSessionOptions opts; 1653 MediaSessionOptions opts;
1663 opts.recv_video = true; 1654 opts.recv_video = true;
1664 opts.recv_audio = true; 1655 opts.recv_audio = true;
1665 1656
1666 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); 1657 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2);
1667 // This creates rtx for H264 with the payload type |f2_| uses. 1658 // This creates rtx for H264 with the payload type |f2_| uses.
1668 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); 1659 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs);
1669 f2_.set_video_codecs(f2_codecs); 1660 f2_.set_video_codecs(f2_codecs);
1670 1661
1671 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); 1662 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr));
1672 ASSERT_TRUE(offer.get() != nullptr); 1663 ASSERT_TRUE(offer.get() != nullptr);
1673 rtc::scoped_ptr<SessionDescription> answer( 1664 std::unique_ptr<SessionDescription> answer(
1674 f2_.CreateAnswer(offer.get(), opts, nullptr)); 1665 f2_.CreateAnswer(offer.get(), opts, nullptr));
1675 1666
1676 const VideoContentDescription* vcd = 1667 const VideoContentDescription* vcd =
1677 GetFirstVideoContentDescription(answer.get()); 1668 GetFirstVideoContentDescription(answer.get());
1678 1669
1679 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); 1670 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer);
1680 EXPECT_EQ(expected_codecs, vcd->codecs()); 1671 EXPECT_EQ(expected_codecs, vcd->codecs());
1681 1672
1682 // Now, ensure that the RTX codec is created correctly when |f2_| creates an 1673 // Now, ensure that the RTX codec is created correctly when |f2_| creates an
1683 // updated offer, even though the default payload types are different from 1674 // updated offer, even though the default payload types are different from
1684 // those of |f1_|. 1675 // those of |f1_|.
1685 rtc::scoped_ptr<SessionDescription> updated_offer( 1676 std::unique_ptr<SessionDescription> updated_offer(
1686 f2_.CreateOffer(opts, answer.get())); 1677 f2_.CreateOffer(opts, answer.get()));
1687 ASSERT_TRUE(updated_offer); 1678 ASSERT_TRUE(updated_offer);
1688 1679
1689 const VideoContentDescription* updated_vcd = 1680 const VideoContentDescription* updated_vcd =
1690 GetFirstVideoContentDescription(updated_offer.get()); 1681 GetFirstVideoContentDescription(updated_offer.get());
1691 1682
1692 // New offer should attempt to add H263, and RTX for H264. 1683 // New offer should attempt to add H263, and RTX for H264.
1693 expected_codecs.push_back(kVideoCodecs2[1]); 1684 expected_codecs.push_back(kVideoCodecs2[1]);
1694 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[1].id), 1685 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[1].id),
1695 &expected_codecs); 1686 &expected_codecs);
1696 EXPECT_EQ(expected_codecs, updated_vcd->codecs()); 1687 EXPECT_EQ(expected_codecs, updated_vcd->codecs());
1697 } 1688 }
1698 1689
1699 // Test that RTX is ignored when there is no associated payload type parameter. 1690 // Test that RTX is ignored when there is no associated payload type parameter.
1700 TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { 1691 TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) {
1701 MediaSessionOptions opts; 1692 MediaSessionOptions opts;
1702 opts.recv_video = true; 1693 opts.recv_video = true;
1703 opts.recv_audio = false; 1694 opts.recv_audio = false;
1704 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); 1695 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1);
1705 // This creates RTX without associated payload type parameter. 1696 // This creates RTX without associated payload type parameter.
1706 AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName, 0, 0, 0, 0), &f1_codecs); 1697 AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName, 0, 0, 0, 0), &f1_codecs);
1707 f1_.set_video_codecs(f1_codecs); 1698 f1_.set_video_codecs(f1_codecs);
1708 1699
1709 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); 1700 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2);
1710 // This creates RTX for H264 with the payload type |f2_| uses. 1701 // This creates RTX for H264 with the payload type |f2_| uses.
1711 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); 1702 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs);
1712 f2_.set_video_codecs(f2_codecs); 1703 f2_.set_video_codecs(f2_codecs);
1713 1704
1714 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 1705 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1715 ASSERT_TRUE(offer.get() != NULL); 1706 ASSERT_TRUE(offer.get() != NULL);
1716 // kCodecParamAssociatedPayloadType will always be added to the offer when RTX 1707 // kCodecParamAssociatedPayloadType will always be added to the offer when RTX
1717 // is selected. Manually remove kCodecParamAssociatedPayloadType so that it 1708 // is selected. Manually remove kCodecParamAssociatedPayloadType so that it
1718 // is possible to test that that RTX is dropped when 1709 // is possible to test that that RTX is dropped when
1719 // kCodecParamAssociatedPayloadType is missing in the offer. 1710 // kCodecParamAssociatedPayloadType is missing in the offer.
1720 VideoContentDescription* desc = 1711 VideoContentDescription* desc =
1721 static_cast<cricket::VideoContentDescription*>( 1712 static_cast<cricket::VideoContentDescription*>(
1722 offer->GetContentDescriptionByName(cricket::CN_VIDEO)); 1713 offer->GetContentDescriptionByName(cricket::CN_VIDEO));
1723 ASSERT_TRUE(desc != NULL); 1714 ASSERT_TRUE(desc != NULL);
1724 std::vector<VideoCodec> codecs = desc->codecs(); 1715 std::vector<VideoCodec> codecs = desc->codecs();
1725 for (std::vector<VideoCodec>::iterator iter = codecs.begin(); 1716 for (std::vector<VideoCodec>::iterator iter = codecs.begin();
1726 iter != codecs.end(); ++iter) { 1717 iter != codecs.end(); ++iter) {
1727 if (iter->name.find(cricket::kRtxCodecName) == 0) { 1718 if (iter->name.find(cricket::kRtxCodecName) == 0) {
1728 iter->params.clear(); 1719 iter->params.clear();
1729 } 1720 }
1730 } 1721 }
1731 desc->set_codecs(codecs); 1722 desc->set_codecs(codecs);
1732 1723
1733 rtc::scoped_ptr<SessionDescription> answer( 1724 std::unique_ptr<SessionDescription> answer(
1734 f2_.CreateAnswer(offer.get(), opts, NULL)); 1725 f2_.CreateAnswer(offer.get(), opts, NULL));
1735 1726
1736 std::vector<std::string> codec_names = 1727 std::vector<std::string> codec_names =
1737 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()); 1728 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs());
1738 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(), 1729 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(),
1739 cricket::kRtxCodecName)); 1730 cricket::kRtxCodecName));
1740 } 1731 }
1741 1732
1742 // Test that RTX will be filtered out in the answer if its associated payload 1733 // Test that RTX will be filtered out in the answer if its associated payload
1743 // type doesn't match the local value. 1734 // type doesn't match the local value.
1744 TEST_F(MediaSessionDescriptionFactoryTest, FilterOutRtxIfAptDoesntMatch) { 1735 TEST_F(MediaSessionDescriptionFactoryTest, FilterOutRtxIfAptDoesntMatch) {
1745 MediaSessionOptions opts; 1736 MediaSessionOptions opts;
1746 opts.recv_video = true; 1737 opts.recv_video = true;
1747 opts.recv_audio = false; 1738 opts.recv_audio = false;
1748 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); 1739 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1);
1749 // This creates RTX for H264 in sender. 1740 // This creates RTX for H264 in sender.
1750 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); 1741 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs);
1751 f1_.set_video_codecs(f1_codecs); 1742 f1_.set_video_codecs(f1_codecs);
1752 1743
1753 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); 1744 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2);
1754 // This creates RTX for H263 in receiver. 1745 // This creates RTX for H263 in receiver.
1755 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[1].id), &f2_codecs); 1746 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[1].id), &f2_codecs);
1756 f2_.set_video_codecs(f2_codecs); 1747 f2_.set_video_codecs(f2_codecs);
1757 1748
1758 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 1749 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1759 ASSERT_TRUE(offer.get() != NULL); 1750 ASSERT_TRUE(offer.get() != NULL);
1760 // Associated payload type doesn't match, therefore, RTX codec is removed in 1751 // Associated payload type doesn't match, therefore, RTX codec is removed in
1761 // the answer. 1752 // the answer.
1762 rtc::scoped_ptr<SessionDescription> answer( 1753 std::unique_ptr<SessionDescription> answer(
1763 f2_.CreateAnswer(offer.get(), opts, NULL)); 1754 f2_.CreateAnswer(offer.get(), opts, NULL));
1764 1755
1765 std::vector<std::string> codec_names = 1756 std::vector<std::string> codec_names =
1766 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()); 1757 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs());
1767 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(), 1758 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(),
1768 cricket::kRtxCodecName)); 1759 cricket::kRtxCodecName));
1769 } 1760 }
1770 1761
1771 // Test that when multiple RTX codecs are offered, only the matched RTX codec 1762 // Test that when multiple RTX codecs are offered, only the matched RTX codec
1772 // is added in the answer, and the unsupported RTX codec is filtered out. 1763 // is added in the answer, and the unsupported RTX codec is filtered out.
(...skipping 11 matching lines...) Expand all
1784 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); 1775 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs);
1785 f1_.set_video_codecs(f1_codecs); 1776 f1_.set_video_codecs(f1_codecs);
1786 1777
1787 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); 1778 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2);
1788 // This creates RTX for H264 in receiver. 1779 // This creates RTX for H264 in receiver.
1789 AddRtxCodec(VideoCodec::CreateRtxCodec(124, kVideoCodecs2[0].id), &f2_codecs); 1780 AddRtxCodec(VideoCodec::CreateRtxCodec(124, kVideoCodecs2[0].id), &f2_codecs);
1790 f2_.set_video_codecs(f2_codecs); 1781 f2_.set_video_codecs(f2_codecs);
1791 1782
1792 // H264-SVC codec is removed in the answer, therefore, associated RTX codec 1783 // H264-SVC codec is removed in the answer, therefore, associated RTX codec
1793 // for H264-SVC should also be removed. 1784 // for H264-SVC should also be removed.
1794 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 1785 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1795 ASSERT_TRUE(offer.get() != NULL); 1786 ASSERT_TRUE(offer.get() != NULL);
1796 rtc::scoped_ptr<SessionDescription> answer( 1787 std::unique_ptr<SessionDescription> answer(
1797 f2_.CreateAnswer(offer.get(), opts, NULL)); 1788 f2_.CreateAnswer(offer.get(), opts, NULL));
1798 const VideoContentDescription* vcd = 1789 const VideoContentDescription* vcd =
1799 GetFirstVideoContentDescription(answer.get()); 1790 GetFirstVideoContentDescription(answer.get());
1800 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); 1791 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer);
1801 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), 1792 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id),
1802 &expected_codecs); 1793 &expected_codecs);
1803 1794
1804 EXPECT_EQ(expected_codecs, vcd->codecs()); 1795 EXPECT_EQ(expected_codecs, vcd->codecs());
1805 } 1796 }
1806 1797
1807 // Test that after one RTX codec has been negotiated, a new offer can attempt 1798 // Test that after one RTX codec has been negotiated, a new offer can attempt
1808 // to add another. 1799 // to add another.
1809 TEST_F(MediaSessionDescriptionFactoryTest, AddSecondRtxInNewOffer) { 1800 TEST_F(MediaSessionDescriptionFactoryTest, AddSecondRtxInNewOffer) {
1810 MediaSessionOptions opts; 1801 MediaSessionOptions opts;
1811 opts.recv_video = true; 1802 opts.recv_video = true;
1812 opts.recv_audio = false; 1803 opts.recv_audio = false;
1813 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); 1804 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1);
1814 // This creates RTX for H264 for the offerer. 1805 // This creates RTX for H264 for the offerer.
1815 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); 1806 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs);
1816 f1_.set_video_codecs(f1_codecs); 1807 f1_.set_video_codecs(f1_codecs);
1817 1808
1818 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); 1809 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr));
1819 ASSERT_TRUE(offer); 1810 ASSERT_TRUE(offer);
1820 const VideoContentDescription* vcd = 1811 const VideoContentDescription* vcd =
1821 GetFirstVideoContentDescription(offer.get()); 1812 GetFirstVideoContentDescription(offer.get());
1822 1813
1823 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecs1); 1814 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecs1);
1824 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), 1815 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id),
1825 &expected_codecs); 1816 &expected_codecs);
1826 EXPECT_EQ(expected_codecs, vcd->codecs()); 1817 EXPECT_EQ(expected_codecs, vcd->codecs());
1827 1818
1828 // Now, attempt to add RTX for H264-SVC. 1819 // Now, attempt to add RTX for H264-SVC.
1829 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), &f1_codecs); 1820 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), &f1_codecs);
1830 f1_.set_video_codecs(f1_codecs); 1821 f1_.set_video_codecs(f1_codecs);
1831 1822
1832 rtc::scoped_ptr<SessionDescription> updated_offer( 1823 std::unique_ptr<SessionDescription> updated_offer(
1833 f1_.CreateOffer(opts, offer.get())); 1824 f1_.CreateOffer(opts, offer.get()));
1834 ASSERT_TRUE(updated_offer); 1825 ASSERT_TRUE(updated_offer);
1835 vcd = GetFirstVideoContentDescription(updated_offer.get()); 1826 vcd = GetFirstVideoContentDescription(updated_offer.get());
1836 1827
1837 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), 1828 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id),
1838 &expected_codecs); 1829 &expected_codecs);
1839 EXPECT_EQ(expected_codecs, vcd->codecs()); 1830 EXPECT_EQ(expected_codecs, vcd->codecs());
1840 } 1831 }
1841 1832
1842 // Test that when RTX is used in conjunction with simulcast, an RTX ssrc is 1833 // Test that when RTX is used in conjunction with simulcast, an RTX ssrc is
1843 // generated for each simulcast ssrc and correctly grouped. 1834 // generated for each simulcast ssrc and correctly grouped.
1844 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { 1835 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) {
1845 MediaSessionOptions opts; 1836 MediaSessionOptions opts;
1846 opts.recv_video = true; 1837 opts.recv_video = true;
1847 opts.recv_audio = false; 1838 opts.recv_audio = false;
1848 1839
1849 // Add simulcast streams. 1840 // Add simulcast streams.
1850 opts.AddSendVideoStream("stream1", "stream1label", 3); 1841 opts.AddSendVideoStream("stream1", "stream1label", 3);
1851 1842
1852 // Use a single real codec, and then add RTX for it. 1843 // Use a single real codec, and then add RTX for it.
1853 std::vector<VideoCodec> f1_codecs; 1844 std::vector<VideoCodec> f1_codecs;
1854 f1_codecs.push_back(VideoCodec(97, "H264", 320, 200, 30, 1)); 1845 f1_codecs.push_back(VideoCodec(97, "H264", 320, 200, 30, 1));
1855 AddRtxCodec(VideoCodec::CreateRtxCodec(125, 97), &f1_codecs); 1846 AddRtxCodec(VideoCodec::CreateRtxCodec(125, 97), &f1_codecs);
1856 f1_.set_video_codecs(f1_codecs); 1847 f1_.set_video_codecs(f1_codecs);
1857 1848
1858 // Ensure that the offer has an RTX ssrc for each regular ssrc, and that there 1849 // Ensure that the offer has an RTX ssrc for each regular ssrc, and that there
1859 // is a FID ssrc + grouping for each. 1850 // is a FID ssrc + grouping for each.
1860 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 1851 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1861 ASSERT_TRUE(offer.get() != NULL); 1852 ASSERT_TRUE(offer.get() != NULL);
1862 VideoContentDescription* desc = static_cast<VideoContentDescription*>( 1853 VideoContentDescription* desc = static_cast<VideoContentDescription*>(
1863 offer->GetContentDescriptionByName(cricket::CN_VIDEO)); 1854 offer->GetContentDescriptionByName(cricket::CN_VIDEO));
1864 ASSERT_TRUE(desc != NULL); 1855 ASSERT_TRUE(desc != NULL);
1865 EXPECT_TRUE(desc->multistream()); 1856 EXPECT_TRUE(desc->multistream());
1866 const StreamParamsVec& streams = desc->streams(); 1857 const StreamParamsVec& streams = desc->streams();
1867 // Single stream. 1858 // Single stream.
1868 ASSERT_EQ(1u, streams.size()); 1859 ASSERT_EQ(1u, streams.size());
1869 // Stream should have 6 ssrcs: 3 for video, 3 for RTX. 1860 // Stream should have 6 ssrcs: 3 for video, 3 for RTX.
1870 EXPECT_EQ(6u, streams[0].ssrcs.size()); 1861 EXPECT_EQ(6u, streams[0].ssrcs.size());
(...skipping 16 matching lines...) Expand all
1887 RespondentCreatesOfferAfterCreatingAnswerWithRtpExtensions) { 1878 RespondentCreatesOfferAfterCreatingAnswerWithRtpExtensions) {
1888 MediaSessionOptions opts; 1879 MediaSessionOptions opts;
1889 opts.recv_audio = true; 1880 opts.recv_audio = true;
1890 opts.recv_video = true; 1881 opts.recv_video = true;
1891 1882
1892 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); 1883 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1));
1893 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); 1884 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1));
1894 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); 1885 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2));
1895 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); 1886 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2));
1896 1887
1897 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 1888 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1898 rtc::scoped_ptr<SessionDescription> answer( 1889 std::unique_ptr<SessionDescription> answer(
1899 f2_.CreateAnswer(offer.get(), opts, NULL)); 1890 f2_.CreateAnswer(offer.get(), opts, NULL));
1900 1891
1901 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), 1892 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer),
1902 GetFirstAudioContentDescription( 1893 GetFirstAudioContentDescription(
1903 answer.get())->rtp_header_extensions()); 1894 answer.get())->rtp_header_extensions());
1904 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), 1895 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer),
1905 GetFirstVideoContentDescription( 1896 GetFirstVideoContentDescription(
1906 answer.get())->rtp_header_extensions()); 1897 answer.get())->rtp_header_extensions());
1907 1898
1908 rtc::scoped_ptr<SessionDescription> updated_offer( 1899 std::unique_ptr<SessionDescription> updated_offer(
1909 f2_.CreateOffer(opts, answer.get())); 1900 f2_.CreateOffer(opts, answer.get()));
1910 1901
1911 // The expected RTP header extensions in the new offer are the resulting 1902 // The expected RTP header extensions in the new offer are the resulting
1912 // extensions from the first offer/answer exchange plus the extensions only 1903 // extensions from the first offer/answer exchange plus the extensions only
1913 // |f2_| offer. 1904 // |f2_| offer.
1914 // Since the default local extension id |f2_| uses has already been used by 1905 // Since the default local extension id |f2_| uses has already been used by
1915 // |f1_| for another extensions, it is changed to 13. 1906 // |f1_| for another extensions, it is changed to 13.
1916 const RtpHeaderExtension kUpdatedAudioRtpExtensions[] = { 1907 const RtpHeaderExtension kUpdatedAudioRtpExtensions[] = {
1917 kAudioRtpExtensionAnswer[0], 1908 kAudioRtpExtensionAnswer[0],
1918 RtpHeaderExtension(kAudioRtpExtension2[1].uri, 13), 1909 RtpHeaderExtension(kAudioRtpExtension2[1].uri, 13),
(...skipping 24 matching lines...) Expand all
1943 // updated offer (this was previously a bug). 1934 // updated offer (this was previously a bug).
1944 TEST_F(MediaSessionDescriptionFactoryTest, 1935 TEST_F(MediaSessionDescriptionFactoryTest,
1945 RtpHeaderExtensionIdReused) { 1936 RtpHeaderExtensionIdReused) {
1946 MediaSessionOptions opts; 1937 MediaSessionOptions opts;
1947 opts.recv_audio = true; 1938 opts.recv_audio = true;
1948 opts.recv_video = true; 1939 opts.recv_video = true;
1949 1940
1950 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension3)); 1941 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension3));
1951 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension3)); 1942 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension3));
1952 1943
1953 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 1944 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1954 1945
1955 // Since the audio extensions used ID 3 for "both_audio_and_video", so should 1946 // Since the audio extensions used ID 3 for "both_audio_and_video", so should
1956 // the video extensions. 1947 // the video extensions.
1957 const RtpHeaderExtension kExpectedVideoRtpExtension[] = { 1948 const RtpHeaderExtension kExpectedVideoRtpExtension[] = {
1958 kVideoRtpExtension3[0], 1949 kVideoRtpExtension3[0],
1959 kAudioRtpExtension3[1], 1950 kAudioRtpExtension3[1],
1960 }; 1951 };
1961 1952
1962 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3), 1953 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3),
1963 GetFirstAudioContentDescription( 1954 GetFirstAudioContentDescription(
1964 offer.get())->rtp_header_extensions()); 1955 offer.get())->rtp_header_extensions());
1965 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension), 1956 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension),
1966 GetFirstVideoContentDescription( 1957 GetFirstVideoContentDescription(
1967 offer.get())->rtp_header_extensions()); 1958 offer.get())->rtp_header_extensions());
1968 1959
1969 // Nothing should change when creating a new offer 1960 // Nothing should change when creating a new offer
1970 rtc::scoped_ptr<SessionDescription> updated_offer( 1961 std::unique_ptr<SessionDescription> updated_offer(
1971 f1_.CreateOffer(opts, offer.get())); 1962 f1_.CreateOffer(opts, offer.get()));
1972 1963
1973 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3), 1964 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3),
1974 GetFirstAudioContentDescription( 1965 GetFirstAudioContentDescription(
1975 updated_offer.get())->rtp_header_extensions()); 1966 updated_offer.get())->rtp_header_extensions());
1976 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension), 1967 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension),
1977 GetFirstVideoContentDescription( 1968 GetFirstVideoContentDescription(
1978 updated_offer.get())->rtp_header_extensions()); 1969 updated_offer.get())->rtp_header_extensions());
1979 } 1970 }
1980 1971
1981 TEST(MediaSessionDescription, CopySessionDescription) { 1972 TEST(MediaSessionDescription, CopySessionDescription) {
1982 SessionDescription source; 1973 SessionDescription source;
1983 cricket::ContentGroup group(cricket::CN_AUDIO); 1974 cricket::ContentGroup group(cricket::CN_AUDIO);
1984 source.AddGroup(group); 1975 source.AddGroup(group);
1985 AudioContentDescription* acd(new AudioContentDescription()); 1976 AudioContentDescription* acd(new AudioContentDescription());
1986 acd->set_codecs(MAKE_VECTOR(kAudioCodecs1)); 1977 acd->set_codecs(MAKE_VECTOR(kAudioCodecs1));
1987 acd->AddLegacyStream(1); 1978 acd->AddLegacyStream(1);
1988 source.AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP, acd); 1979 source.AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP, acd);
1989 VideoContentDescription* vcd(new VideoContentDescription()); 1980 VideoContentDescription* vcd(new VideoContentDescription());
1990 vcd->set_codecs(MAKE_VECTOR(kVideoCodecs1)); 1981 vcd->set_codecs(MAKE_VECTOR(kVideoCodecs1));
1991 vcd->AddLegacyStream(2); 1982 vcd->AddLegacyStream(2);
1992 source.AddContent(cricket::CN_VIDEO, cricket::NS_JINGLE_RTP, vcd); 1983 source.AddContent(cricket::CN_VIDEO, cricket::NS_JINGLE_RTP, vcd);
1993 1984
1994 rtc::scoped_ptr<SessionDescription> copy(source.Copy()); 1985 std::unique_ptr<SessionDescription> copy(source.Copy());
1995 ASSERT_TRUE(copy.get() != NULL); 1986 ASSERT_TRUE(copy.get() != NULL);
1996 EXPECT_TRUE(copy->HasGroup(cricket::CN_AUDIO)); 1987 EXPECT_TRUE(copy->HasGroup(cricket::CN_AUDIO));
1997 const ContentInfo* ac = copy->GetContentByName("audio"); 1988 const ContentInfo* ac = copy->GetContentByName("audio");
1998 const ContentInfo* vc = copy->GetContentByName("video"); 1989 const ContentInfo* vc = copy->GetContentByName("video");
1999 ASSERT_TRUE(ac != NULL); 1990 ASSERT_TRUE(ac != NULL);
2000 ASSERT_TRUE(vc != NULL); 1991 ASSERT_TRUE(vc != NULL);
2001 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); 1992 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type);
2002 const AudioContentDescription* acd_copy = 1993 const AudioContentDescription* acd_copy =
2003 static_cast<const AudioContentDescription*>(ac->description); 1994 static_cast<const AudioContentDescription*>(ac->description);
2004 EXPECT_EQ(acd->codecs(), acd_copy->codecs()); 1995 EXPECT_EQ(acd->codecs(), acd_copy->codecs());
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 2115
2125 // Verifies that creating answer fails if the offer has UDP/TLS/RTP/SAVPF but 2116 // Verifies that creating answer fails if the offer has UDP/TLS/RTP/SAVPF but
2126 // DTLS is not enabled locally. 2117 // DTLS is not enabled locally.
2127 TEST_F(MediaSessionDescriptionFactoryTest, 2118 TEST_F(MediaSessionDescriptionFactoryTest,
2128 TestOfferDtlsSavpfWithoutDtlsFailed) { 2119 TestOfferDtlsSavpfWithoutDtlsFailed) {
2129 f1_.set_secure(SEC_ENABLED); 2120 f1_.set_secure(SEC_ENABLED);
2130 f2_.set_secure(SEC_ENABLED); 2121 f2_.set_secure(SEC_ENABLED);
2131 tdf1_.set_secure(SEC_DISABLED); 2122 tdf1_.set_secure(SEC_DISABLED);
2132 tdf2_.set_secure(SEC_DISABLED); 2123 tdf2_.set_secure(SEC_DISABLED);
2133 2124
2134 rtc::scoped_ptr<SessionDescription> offer( 2125 std::unique_ptr<SessionDescription> offer(
2135 f1_.CreateOffer(MediaSessionOptions(), NULL)); 2126 f1_.CreateOffer(MediaSessionOptions(), NULL));
2136 ASSERT_TRUE(offer.get() != NULL); 2127 ASSERT_TRUE(offer.get() != NULL);
2137 ContentInfo* offer_content = offer->GetContentByName("audio"); 2128 ContentInfo* offer_content = offer->GetContentByName("audio");
2138 ASSERT_TRUE(offer_content != NULL); 2129 ASSERT_TRUE(offer_content != NULL);
2139 AudioContentDescription* offer_audio_desc = 2130 AudioContentDescription* offer_audio_desc =
2140 static_cast<AudioContentDescription*>(offer_content->description); 2131 static_cast<AudioContentDescription*>(offer_content->description);
2141 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf); 2132 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf);
2142 2133
2143 rtc::scoped_ptr<SessionDescription> answer( 2134 std::unique_ptr<SessionDescription> answer(
2144 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); 2135 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL));
2145 ASSERT_TRUE(answer != NULL); 2136 ASSERT_TRUE(answer != NULL);
2146 ContentInfo* answer_content = answer->GetContentByName("audio"); 2137 ContentInfo* answer_content = answer->GetContentByName("audio");
2147 ASSERT_TRUE(answer_content != NULL); 2138 ASSERT_TRUE(answer_content != NULL);
2148 2139
2149 ASSERT_TRUE(answer_content->rejected); 2140 ASSERT_TRUE(answer_content->rejected);
2150 } 2141 }
2151 2142
2152 // Offers UDP/TLS/RTP/SAVPF and verifies the answer can be created and contains 2143 // Offers UDP/TLS/RTP/SAVPF and verifies the answer can be created and contains
2153 // UDP/TLS/RTP/SAVPF. 2144 // UDP/TLS/RTP/SAVPF.
2154 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) { 2145 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) {
2155 f1_.set_secure(SEC_ENABLED); 2146 f1_.set_secure(SEC_ENABLED);
2156 f2_.set_secure(SEC_ENABLED); 2147 f2_.set_secure(SEC_ENABLED);
2157 tdf1_.set_secure(SEC_ENABLED); 2148 tdf1_.set_secure(SEC_ENABLED);
2158 tdf2_.set_secure(SEC_ENABLED); 2149 tdf2_.set_secure(SEC_ENABLED);
2159 2150
2160 rtc::scoped_ptr<SessionDescription> offer( 2151 std::unique_ptr<SessionDescription> offer(
2161 f1_.CreateOffer(MediaSessionOptions(), NULL)); 2152 f1_.CreateOffer(MediaSessionOptions(), NULL));
2162 ASSERT_TRUE(offer.get() != NULL); 2153 ASSERT_TRUE(offer.get() != NULL);
2163 ContentInfo* offer_content = offer->GetContentByName("audio"); 2154 ContentInfo* offer_content = offer->GetContentByName("audio");
2164 ASSERT_TRUE(offer_content != NULL); 2155 ASSERT_TRUE(offer_content != NULL);
2165 AudioContentDescription* offer_audio_desc = 2156 AudioContentDescription* offer_audio_desc =
2166 static_cast<AudioContentDescription*>(offer_content->description); 2157 static_cast<AudioContentDescription*>(offer_content->description);
2167 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf); 2158 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf);
2168 2159
2169 rtc::scoped_ptr<SessionDescription> answer( 2160 std::unique_ptr<SessionDescription> answer(
2170 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); 2161 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL));
2171 ASSERT_TRUE(answer != NULL); 2162 ASSERT_TRUE(answer != NULL);
2172 2163
2173 const ContentInfo* answer_content = answer->GetContentByName("audio"); 2164 const ContentInfo* answer_content = answer->GetContentByName("audio");
2174 ASSERT_TRUE(answer_content != NULL); 2165 ASSERT_TRUE(answer_content != NULL);
2175 ASSERT_FALSE(answer_content->rejected); 2166 ASSERT_FALSE(answer_content->rejected);
2176 2167
2177 const AudioContentDescription* answer_audio_desc = 2168 const AudioContentDescription* answer_audio_desc =
2178 static_cast<const AudioContentDescription*>(answer_content->description); 2169 static_cast<const AudioContentDescription*>(answer_content->description);
2179 EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf), 2170 EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf),
2180 answer_audio_desc->protocol()); 2171 answer_audio_desc->protocol());
2181 } 2172 }
2182 2173
2183 // Test that we include both SDES and DTLS in the offer, but only include SDES 2174 // Test that we include both SDES and DTLS in the offer, but only include SDES
2184 // in the answer if DTLS isn't negotiated. 2175 // in the answer if DTLS isn't negotiated.
2185 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoDtls) { 2176 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoDtls) {
2186 f1_.set_secure(SEC_ENABLED); 2177 f1_.set_secure(SEC_ENABLED);
2187 f2_.set_secure(SEC_ENABLED); 2178 f2_.set_secure(SEC_ENABLED);
2188 tdf1_.set_secure(SEC_ENABLED); 2179 tdf1_.set_secure(SEC_ENABLED);
2189 tdf2_.set_secure(SEC_DISABLED); 2180 tdf2_.set_secure(SEC_DISABLED);
2190 MediaSessionOptions options; 2181 MediaSessionOptions options;
2191 options.recv_audio = true; 2182 options.recv_audio = true;
2192 options.recv_video = true; 2183 options.recv_video = true;
2193 rtc::scoped_ptr<SessionDescription> offer, answer; 2184 std::unique_ptr<SessionDescription> offer, answer;
2194 const cricket::MediaContentDescription* audio_media_desc; 2185 const cricket::MediaContentDescription* audio_media_desc;
2195 const cricket::MediaContentDescription* video_media_desc; 2186 const cricket::MediaContentDescription* video_media_desc;
2196 const cricket::TransportDescription* audio_trans_desc; 2187 const cricket::TransportDescription* audio_trans_desc;
2197 const cricket::TransportDescription* video_trans_desc; 2188 const cricket::TransportDescription* video_trans_desc;
2198 2189
2199 // Generate an offer with SDES and DTLS support. 2190 // Generate an offer with SDES and DTLS support.
2200 offer.reset(f1_.CreateOffer(options, NULL)); 2191 offer.reset(f1_.CreateOffer(options, NULL));
2201 ASSERT_TRUE(offer.get() != NULL); 2192 ASSERT_TRUE(offer.get() != NULL);
2202 2193
2203 audio_media_desc = static_cast<const cricket::MediaContentDescription*>( 2194 audio_media_desc = static_cast<const cricket::MediaContentDescription*>(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2284 2275
2285 // Test that an answer can't be created if cryptos are required but the offer is 2276 // Test that an answer can't be created if cryptos are required but the offer is
2286 // unsecure. 2277 // unsecure.
2287 TEST_F(MediaSessionDescriptionFactoryTest, TestSecureAnswerToUnsecureOffer) { 2278 TEST_F(MediaSessionDescriptionFactoryTest, TestSecureAnswerToUnsecureOffer) {
2288 MediaSessionOptions options; 2279 MediaSessionOptions options;
2289 f1_.set_secure(SEC_DISABLED); 2280 f1_.set_secure(SEC_DISABLED);
2290 tdf1_.set_secure(SEC_DISABLED); 2281 tdf1_.set_secure(SEC_DISABLED);
2291 f2_.set_secure(SEC_REQUIRED); 2282 f2_.set_secure(SEC_REQUIRED);
2292 tdf1_.set_secure(SEC_ENABLED); 2283 tdf1_.set_secure(SEC_ENABLED);
2293 2284
2294 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(options, 2285 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL));
2295 NULL));
2296 ASSERT_TRUE(offer.get() != NULL); 2286 ASSERT_TRUE(offer.get() != NULL);
2297 rtc::scoped_ptr<SessionDescription> answer( 2287 std::unique_ptr<SessionDescription> answer(
2298 f2_.CreateAnswer(offer.get(), options, NULL)); 2288 f2_.CreateAnswer(offer.get(), options, NULL));
2299 EXPECT_TRUE(answer.get() == NULL); 2289 EXPECT_TRUE(answer.get() == NULL);
2300 } 2290 }
2301 2291
2302 // Test that we accept a DTLS offer without SDES and create an appropriate 2292 // Test that we accept a DTLS offer without SDES and create an appropriate
2303 // answer. 2293 // answer.
2304 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoOfferDtlsButNotSdes) { 2294 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoOfferDtlsButNotSdes) {
2305 f1_.set_secure(SEC_DISABLED); 2295 f1_.set_secure(SEC_DISABLED);
2306 f2_.set_secure(SEC_ENABLED); 2296 f2_.set_secure(SEC_ENABLED);
2307 tdf1_.set_secure(SEC_ENABLED); 2297 tdf1_.set_secure(SEC_ENABLED);
2308 tdf2_.set_secure(SEC_ENABLED); 2298 tdf2_.set_secure(SEC_ENABLED);
2309 MediaSessionOptions options; 2299 MediaSessionOptions options;
2310 options.recv_audio = true; 2300 options.recv_audio = true;
2311 options.recv_video = true; 2301 options.recv_video = true;
2312 options.data_channel_type = cricket::DCT_RTP; 2302 options.data_channel_type = cricket::DCT_RTP;
2313 2303
2314 rtc::scoped_ptr<SessionDescription> offer, answer; 2304 std::unique_ptr<SessionDescription> offer, answer;
2315 2305
2316 // Generate an offer with DTLS but without SDES. 2306 // Generate an offer with DTLS but without SDES.
2317 offer.reset(f1_.CreateOffer(options, NULL)); 2307 offer.reset(f1_.CreateOffer(options, NULL));
2318 ASSERT_TRUE(offer.get() != NULL); 2308 ASSERT_TRUE(offer.get() != NULL);
2319 2309
2320 const AudioContentDescription* audio_offer = 2310 const AudioContentDescription* audio_offer =
2321 GetFirstAudioContentDescription(offer.get()); 2311 GetFirstAudioContentDescription(offer.get());
2322 ASSERT_TRUE(audio_offer->cryptos().empty()); 2312 ASSERT_TRUE(audio_offer->cryptos().empty());
2323 const VideoContentDescription* video_offer = 2313 const VideoContentDescription* video_offer =
2324 GetFirstVideoContentDescription(offer.get()); 2314 GetFirstVideoContentDescription(offer.get());
(...skipping 26 matching lines...) Expand all
2351 answer->GetTransportDescriptionByName("data"); 2341 answer->GetTransportDescriptionByName("data");
2352 EXPECT_TRUE(data_answer_trans_desc->identity_fingerprint.get() != NULL); 2342 EXPECT_TRUE(data_answer_trans_desc->identity_fingerprint.get() != NULL);
2353 } 2343 }
2354 2344
2355 // Verifies if vad_enabled option is set to false, CN codecs are not present in 2345 // Verifies if vad_enabled option is set to false, CN codecs are not present in
2356 // offer or answer. 2346 // offer or answer.
2357 TEST_F(MediaSessionDescriptionFactoryTest, TestVADEnableOption) { 2347 TEST_F(MediaSessionDescriptionFactoryTest, TestVADEnableOption) {
2358 MediaSessionOptions options; 2348 MediaSessionOptions options;
2359 options.recv_audio = true; 2349 options.recv_audio = true;
2360 options.recv_video = true; 2350 options.recv_video = true;
2361 rtc::scoped_ptr<SessionDescription> offer( 2351 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL));
2362 f1_.CreateOffer(options, NULL));
2363 ASSERT_TRUE(offer.get() != NULL); 2352 ASSERT_TRUE(offer.get() != NULL);
2364 const ContentInfo* audio_content = offer->GetContentByName("audio"); 2353 const ContentInfo* audio_content = offer->GetContentByName("audio");
2365 EXPECT_FALSE(VerifyNoCNCodecs(audio_content)); 2354 EXPECT_FALSE(VerifyNoCNCodecs(audio_content));
2366 2355
2367 options.vad_enabled = false; 2356 options.vad_enabled = false;
2368 offer.reset(f1_.CreateOffer(options, NULL)); 2357 offer.reset(f1_.CreateOffer(options, NULL));
2369 ASSERT_TRUE(offer.get() != NULL); 2358 ASSERT_TRUE(offer.get() != NULL);
2370 audio_content = offer->GetContentByName("audio"); 2359 audio_content = offer->GetContentByName("audio");
2371 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); 2360 EXPECT_TRUE(VerifyNoCNCodecs(audio_content));
2372 rtc::scoped_ptr<SessionDescription> answer( 2361 std::unique_ptr<SessionDescription> answer(
2373 f1_.CreateAnswer(offer.get(), options, NULL)); 2362 f1_.CreateAnswer(offer.get(), options, NULL));
2374 ASSERT_TRUE(answer.get() != NULL); 2363 ASSERT_TRUE(answer.get() != NULL);
2375 audio_content = answer->GetContentByName("audio"); 2364 audio_content = answer->GetContentByName("audio");
2376 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); 2365 EXPECT_TRUE(VerifyNoCNCodecs(audio_content));
2377 } 2366 }
2378 2367
2379 // Test that the content name ("mid" in SDP) is unchanged when creating a 2368 // Test that the content name ("mid" in SDP) is unchanged when creating a
2380 // new offer. 2369 // new offer.
2381 TEST_F(MediaSessionDescriptionFactoryTest, 2370 TEST_F(MediaSessionDescriptionFactoryTest,
2382 TestContentNameNotChangedInSubsequentOffers) { 2371 TestContentNameNotChangedInSubsequentOffers) {
2383 MediaSessionOptions opts; 2372 MediaSessionOptions opts;
2384 opts.recv_audio = true; 2373 opts.recv_audio = true;
2385 opts.recv_video = true; 2374 opts.recv_video = true;
2386 opts.data_channel_type = cricket::DCT_SCTP; 2375 opts.data_channel_type = cricket::DCT_SCTP;
2387 // Create offer and modify the default content names. 2376 // Create offer and modify the default content names.
2388 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); 2377 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr));
2389 for (ContentInfo& content : offer->contents()) { 2378 for (ContentInfo& content : offer->contents()) {
2390 content.name.append("_modified"); 2379 content.name.append("_modified");
2391 } 2380 }
2392 2381
2393 rtc::scoped_ptr<SessionDescription> updated_offer( 2382 std::unique_ptr<SessionDescription> updated_offer(
2394 f1_.CreateOffer(opts, offer.get())); 2383 f1_.CreateOffer(opts, offer.get()));
2395 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); 2384 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get());
2396 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); 2385 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get());
2397 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); 2386 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get());
2398 ASSERT_TRUE(audio_content != nullptr); 2387 ASSERT_TRUE(audio_content != nullptr);
2399 ASSERT_TRUE(video_content != nullptr); 2388 ASSERT_TRUE(video_content != nullptr);
2400 ASSERT_TRUE(data_content != nullptr); 2389 ASSERT_TRUE(data_content != nullptr);
2401 EXPECT_EQ("audio_modified", audio_content->name); 2390 EXPECT_EQ("audio_modified", audio_content->name);
2402 EXPECT_EQ("video_modified", video_content->name); 2391 EXPECT_EQ("video_modified", video_content->name);
2403 EXPECT_EQ("data_modified", data_content->name); 2392 EXPECT_EQ("data_modified", data_content->name);
2404 } 2393 }
OLDNEW
« no previous file with comments | « webrtc/pc/mediasession.cc ('k') | webrtc/pc/planarfunctions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698