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

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

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright 2009 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2009 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 if (network_is_worker == NetworkIsWorker::Yes) { 113 if (network_is_worker == NetworkIsWorker::Yes) {
114 network_thread_ = rtc::Thread::Current(); 114 network_thread_ = rtc::Thread::Current();
115 } else { 115 } else {
116 network_thread_keeper_ = rtc::Thread::Create(); 116 network_thread_keeper_ = rtc::Thread::Create();
117 network_thread_keeper_->SetName("Network", nullptr); 117 network_thread_keeper_->SetName("Network", nullptr);
118 network_thread_ = network_thread_keeper_.get(); 118 network_thread_ = network_thread_keeper_.get();
119 } 119 }
120 } 120 }
121 121
122 void CreateChannels(int flags1, int flags2) { 122 void CreateChannels(int flags1, int flags2) {
123 CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()), 123 CreateChannels(new typename T::MediaChannel(nullptr, typename T::Options()),
124 new typename T::MediaChannel(NULL, typename T::Options()), 124 new typename T::MediaChannel(nullptr, typename T::Options()),
125 flags1, flags2); 125 flags1, flags2);
126 } 126 }
127 void CreateChannels(typename T::MediaChannel* ch1, 127 void CreateChannels(typename T::MediaChannel* ch1,
128 typename T::MediaChannel* ch2, 128 typename T::MediaChannel* ch2,
129 int flags1, 129 int flags1,
130 int flags2) { 130 int flags2) {
131 // Network thread is started in CreateChannels, to allow the test to 131 // Network thread is started in CreateChannels, to allow the test to
132 // configure a fake clock before any threads are spawned and attempt to 132 // configure a fake clock before any threads are spawned and attempt to
133 // access the time. 133 // access the time.
134 if (network_thread_keeper_) { 134 if (network_thread_keeper_) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 rtc::CryptoOptions crypto_options; 266 rtc::CryptoOptions crypto_options;
267 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; 267 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0;
268 channel->SetCryptoOptions(crypto_options); 268 channel->SetCryptoOptions(crypto_options);
269 if (!channel->NeedsRtcpTransport()) { 269 if (!channel->NeedsRtcpTransport()) {
270 fake_rtcp_dtls_transport = nullptr; 270 fake_rtcp_dtls_transport = nullptr;
271 } 271 }
272 if (!channel->Init_w(fake_rtp_dtls_transport, fake_rtcp_dtls_transport, 272 if (!channel->Init_w(fake_rtp_dtls_transport, fake_rtcp_dtls_transport,
273 fake_rtp_packet_transport, 273 fake_rtp_packet_transport,
274 fake_rtcp_packet_transport)) { 274 fake_rtcp_packet_transport)) {
275 delete channel; 275 delete channel;
276 channel = NULL; 276 channel = nullptr;
277 } 277 }
278 return channel; 278 return channel;
279 } 279 }
280 280
281 void ConnectFakeTransports() { 281 void ConnectFakeTransports() {
282 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { 282 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
283 bool asymmetric = false; 283 bool asymmetric = false;
284 // Depending on test flags, could be using DTLS or raw packet transport. 284 // Depending on test flags, could be using DTLS or raw packet transport.
285 if (fake_rtp_dtls_transport1_ && fake_rtp_dtls_transport2_) { 285 if (fake_rtp_dtls_transport1_ && fake_rtp_dtls_transport2_) {
286 fake_rtp_dtls_transport1_->SetDestination( 286 fake_rtp_dtls_transport1_->SetDestination(
287 fake_rtp_dtls_transport2_.get(), asymmetric); 287 fake_rtp_dtls_transport2_.get(), asymmetric);
288 } 288 }
289 if (fake_rtcp_dtls_transport1_ && fake_rtcp_dtls_transport2_) { 289 if (fake_rtcp_dtls_transport1_ && fake_rtcp_dtls_transport2_) {
290 fake_rtcp_dtls_transport1_->SetDestination( 290 fake_rtcp_dtls_transport1_->SetDestination(
291 fake_rtcp_dtls_transport2_.get(), asymmetric); 291 fake_rtcp_dtls_transport2_.get(), asymmetric);
292 } 292 }
293 if (fake_rtp_packet_transport1_ && fake_rtp_packet_transport2_) { 293 if (fake_rtp_packet_transport1_ && fake_rtp_packet_transport2_) {
294 fake_rtp_packet_transport1_->SetDestination( 294 fake_rtp_packet_transport1_->SetDestination(
295 fake_rtp_packet_transport2_.get(), asymmetric); 295 fake_rtp_packet_transport2_.get(), asymmetric);
296 } 296 }
297 if (fake_rtcp_packet_transport1_ && fake_rtcp_packet_transport2_) { 297 if (fake_rtcp_packet_transport1_ && fake_rtcp_packet_transport2_) {
298 fake_rtcp_packet_transport1_->SetDestination( 298 fake_rtcp_packet_transport1_->SetDestination(
299 fake_rtcp_packet_transport2_.get(), asymmetric); 299 fake_rtcp_packet_transport2_.get(), asymmetric);
300 } 300 }
301 }); 301 });
302 } 302 }
303 303
304 bool SendInitiate() { 304 bool SendInitiate() {
305 bool result = channel1_->SetLocalContent(&local_media_content1_, 305 bool result =
306 CA_OFFER, NULL); 306 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, nullptr);
307 if (result) { 307 if (result) {
308 channel1_->Enable(true); 308 channel1_->Enable(true);
309 result = channel2_->SetRemoteContent(&remote_media_content1_, 309 result = channel2_->SetRemoteContent(&remote_media_content1_, CA_OFFER,
310 CA_OFFER, NULL); 310 nullptr);
311 if (result) { 311 if (result) {
312 ConnectFakeTransports(); 312 ConnectFakeTransports();
313 result = channel2_->SetLocalContent(&local_media_content2_, 313 result = channel2_->SetLocalContent(&local_media_content2_, CA_ANSWER,
314 CA_ANSWER, NULL); 314 nullptr);
315 } 315 }
316 } 316 }
317 return result; 317 return result;
318 } 318 }
319 319
320 bool SendAccept() { 320 bool SendAccept() {
321 channel2_->Enable(true); 321 channel2_->Enable(true);
322 return channel1_->SetRemoteContent(&remote_media_content2_, 322 return channel1_->SetRemoteContent(&remote_media_content2_, CA_ANSWER,
323 CA_ANSWER, NULL); 323 nullptr);
324 } 324 }
325 325
326 bool SendOffer() { 326 bool SendOffer() {
327 bool result = channel1_->SetLocalContent(&local_media_content1_, 327 bool result =
328 CA_OFFER, NULL); 328 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, nullptr);
329 if (result) { 329 if (result) {
330 channel1_->Enable(true); 330 channel1_->Enable(true);
331 result = channel2_->SetRemoteContent(&remote_media_content1_, 331 result = channel2_->SetRemoteContent(&remote_media_content1_, CA_OFFER,
332 CA_OFFER, NULL); 332 nullptr);
333 } 333 }
334 return result; 334 return result;
335 } 335 }
336 336
337 bool SendProvisionalAnswer() { 337 bool SendProvisionalAnswer() {
338 bool result = channel2_->SetLocalContent(&local_media_content2_, 338 bool result = channel2_->SetLocalContent(&local_media_content2_,
339 CA_PRANSWER, NULL); 339 CA_PRANSWER, nullptr);
340 if (result) { 340 if (result) {
341 channel2_->Enable(true); 341 channel2_->Enable(true);
342 result = channel1_->SetRemoteContent(&remote_media_content2_, 342 result = channel1_->SetRemoteContent(&remote_media_content2_, CA_PRANSWER,
343 CA_PRANSWER, NULL); 343 nullptr);
344 ConnectFakeTransports(); 344 ConnectFakeTransports();
345 } 345 }
346 return result; 346 return result;
347 } 347 }
348 348
349 bool SendFinalAnswer() { 349 bool SendFinalAnswer() {
350 bool result = channel2_->SetLocalContent(&local_media_content2_, 350 bool result =
351 CA_ANSWER, NULL); 351 channel2_->SetLocalContent(&local_media_content2_, CA_ANSWER, nullptr);
352 if (result) 352 if (result)
353 result = channel1_->SetRemoteContent(&remote_media_content2_, 353 result = channel1_->SetRemoteContent(&remote_media_content2_, CA_ANSWER,
354 CA_ANSWER, NULL); 354 nullptr);
355 return result; 355 return result;
356 } 356 }
357 357
358 bool Terminate() { 358 bool Terminate() {
359 channel1_.reset(); 359 channel1_.reset();
360 channel2_.reset(); 360 channel2_.reset();
361 fake_rtp_dtls_transport1_.reset(); 361 fake_rtp_dtls_transport1_.reset();
362 fake_rtcp_dtls_transport1_.reset(); 362 fake_rtcp_dtls_transport1_.reset();
363 fake_rtp_dtls_transport2_.reset(); 363 fake_rtp_dtls_transport2_.reset();
364 fake_rtcp_dtls_transport2_.reset(); 364 fake_rtcp_dtls_transport2_.reset();
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 EXPECT_TRUE(media_channel1_->rtp_packets().empty()); 580 EXPECT_TRUE(media_channel1_->rtp_packets().empty());
581 EXPECT_TRUE(media_channel1_->rtcp_packets().empty()); 581 EXPECT_TRUE(media_channel1_->rtcp_packets().empty());
582 } 582 }
583 583
584 // Test that SetLocalContent and SetRemoteContent properly configure 584 // Test that SetLocalContent and SetRemoteContent properly configure
585 // the codecs. 585 // the codecs.
586 void TestSetContents() { 586 void TestSetContents() {
587 CreateChannels(0, 0); 587 CreateChannels(0, 0);
588 typename T::Content content; 588 typename T::Content content;
589 CreateContent(0, kPcmuCodec, kH264Codec, &content); 589 CreateContent(0, kPcmuCodec, kH264Codec, &content);
590 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); 590 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, nullptr));
591 EXPECT_EQ(0U, media_channel1_->codecs().size()); 591 EXPECT_EQ(0U, media_channel1_->codecs().size());
592 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); 592 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, nullptr));
593 ASSERT_EQ(1U, media_channel1_->codecs().size()); 593 ASSERT_EQ(1U, media_channel1_->codecs().size());
594 EXPECT_TRUE(CodecMatches(content.codecs()[0], 594 EXPECT_TRUE(CodecMatches(content.codecs()[0],
595 media_channel1_->codecs()[0])); 595 media_channel1_->codecs()[0]));
596 } 596 }
597 597
598 // Test that SetLocalContent and SetRemoteContent properly deals 598 // Test that SetLocalContent and SetRemoteContent properly deals
599 // with an empty offer. 599 // with an empty offer.
600 void TestSetContentsNullOffer() { 600 void TestSetContentsNullOffer() {
601 CreateChannels(0, 0); 601 CreateChannels(0, 0);
602 typename T::Content content; 602 typename T::Content content;
603 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); 603 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, nullptr));
604 CreateContent(0, kPcmuCodec, kH264Codec, &content); 604 CreateContent(0, kPcmuCodec, kH264Codec, &content);
605 EXPECT_EQ(0U, media_channel1_->codecs().size()); 605 EXPECT_EQ(0U, media_channel1_->codecs().size());
606 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); 606 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, nullptr));
607 ASSERT_EQ(1U, media_channel1_->codecs().size()); 607 ASSERT_EQ(1U, media_channel1_->codecs().size());
608 EXPECT_TRUE(CodecMatches(content.codecs()[0], 608 EXPECT_TRUE(CodecMatches(content.codecs()[0],
609 media_channel1_->codecs()[0])); 609 media_channel1_->codecs()[0]));
610 } 610 }
611 611
612 // Test that SetLocalContent and SetRemoteContent properly set RTCP 612 // Test that SetLocalContent and SetRemoteContent properly set RTCP
613 // mux. 613 // mux.
614 void TestSetContentsRtcpMux() { 614 void TestSetContentsRtcpMux() {
615 CreateChannels(0, 0); 615 CreateChannels(0, 0);
616 typename T::Content content; 616 typename T::Content content;
617 CreateContent(0, kPcmuCodec, kH264Codec, &content); 617 CreateContent(0, kPcmuCodec, kH264Codec, &content);
618 // Both sides agree on mux. Should no longer be a separate RTCP channel. 618 // Both sides agree on mux. Should no longer be a separate RTCP channel.
619 content.set_rtcp_mux(true); 619 content.set_rtcp_mux(true);
620 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); 620 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, nullptr));
621 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); 621 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, nullptr));
622 // Only initiator supports mux. Should still have a separate RTCP channel. 622 // Only initiator supports mux. Should still have a separate RTCP channel.
623 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL)); 623 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, nullptr));
624 content.set_rtcp_mux(false); 624 content.set_rtcp_mux(false);
625 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL)); 625 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, nullptr));
626 } 626 }
627 627
628 // Test that SetLocalContent and SetRemoteContent properly set RTCP 628 // Test that SetLocalContent and SetRemoteContent properly set RTCP
629 // mux when a provisional answer is received. 629 // mux when a provisional answer is received.
630 void TestSetContentsRtcpMuxWithPrAnswer() { 630 void TestSetContentsRtcpMuxWithPrAnswer() {
631 CreateChannels(0, 0); 631 CreateChannels(0, 0);
632 typename T::Content content; 632 typename T::Content content;
633 CreateContent(0, kPcmuCodec, kH264Codec, &content); 633 CreateContent(0, kPcmuCodec, kH264Codec, &content);
634 content.set_rtcp_mux(true); 634 content.set_rtcp_mux(true);
635 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); 635 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, nullptr));
636 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_PRANSWER, NULL)); 636 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_PRANSWER, nullptr));
637 // Both sides agree on mux. Should signal RTCP mux as fully activated. 637 // Both sides agree on mux. Should signal RTCP mux as fully activated.
638 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_); 638 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_);
639 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); 639 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, nullptr));
640 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_); 640 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_);
641 // Only initiator supports mux. Should still have a separate RTCP channel. 641 // Only initiator supports mux. Should still have a separate RTCP channel.
642 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL)); 642 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, nullptr));
643 content.set_rtcp_mux(false); 643 content.set_rtcp_mux(false);
644 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_PRANSWER, NULL)); 644 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_PRANSWER, nullptr));
645 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL)); 645 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, nullptr));
646 EXPECT_EQ(0, rtcp_mux_activated_callbacks2_); 646 EXPECT_EQ(0, rtcp_mux_activated_callbacks2_);
647 } 647 }
648 648
649 // Test that SetRemoteContent properly deals with a content update. 649 // Test that SetRemoteContent properly deals with a content update.
650 void TestSetRemoteContentUpdate() { 650 void TestSetRemoteContentUpdate() {
651 CreateChannels(0, 0); 651 CreateChannels(0, 0);
652 typename T::Content content; 652 typename T::Content content;
653 CreateContent(RTCP_MUX | SECURE, kPcmuCodec, kH264Codec, &content); 653 CreateContent(RTCP_MUX | SECURE, kPcmuCodec, kH264Codec, &content);
654 EXPECT_EQ(0U, media_channel1_->codecs().size()); 654 EXPECT_EQ(0U, media_channel1_->codecs().size());
655 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); 655 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, nullptr));
656 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); 656 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, nullptr));
657 ASSERT_EQ(1U, media_channel1_->codecs().size()); 657 ASSERT_EQ(1U, media_channel1_->codecs().size());
658 EXPECT_TRUE(CodecMatches(content.codecs()[0], 658 EXPECT_TRUE(CodecMatches(content.codecs()[0],
659 media_channel1_->codecs()[0])); 659 media_channel1_->codecs()[0]));
660 // Now update with other codecs. 660 // Now update with other codecs.
661 typename T::Content update_content; 661 typename T::Content update_content;
662 update_content.set_partial(true); 662 update_content.set_partial(true);
663 CreateContent(0, kIsacCodec, kH264SvcCodec, 663 CreateContent(0, kIsacCodec, kH264SvcCodec,
664 &update_content); 664 &update_content);
665 EXPECT_TRUE(channel1_->SetRemoteContent(&update_content, CA_UPDATE, NULL)); 665 EXPECT_TRUE(
666 channel1_->SetRemoteContent(&update_content, CA_UPDATE, nullptr));
666 ASSERT_EQ(1U, media_channel1_->codecs().size()); 667 ASSERT_EQ(1U, media_channel1_->codecs().size());
667 EXPECT_TRUE(CodecMatches(update_content.codecs()[0], 668 EXPECT_TRUE(CodecMatches(update_content.codecs()[0],
668 media_channel1_->codecs()[0])); 669 media_channel1_->codecs()[0]));
669 // Now update without any codecs. This is ignored. 670 // Now update without any codecs. This is ignored.
670 typename T::Content empty_content; 671 typename T::Content empty_content;
671 empty_content.set_partial(true); 672 empty_content.set_partial(true);
672 EXPECT_TRUE(channel1_->SetRemoteContent(&empty_content, CA_UPDATE, NULL)); 673 EXPECT_TRUE(
674 channel1_->SetRemoteContent(&empty_content, CA_UPDATE, nullptr));
673 ASSERT_EQ(1U, media_channel1_->codecs().size()); 675 ASSERT_EQ(1U, media_channel1_->codecs().size());
674 EXPECT_TRUE(CodecMatches(update_content.codecs()[0], 676 EXPECT_TRUE(CodecMatches(update_content.codecs()[0],
675 media_channel1_->codecs()[0])); 677 media_channel1_->codecs()[0]));
676 } 678 }
677 679
678 // Test that Add/RemoveStream properly forward to the media channel. 680 // Test that Add/RemoveStream properly forward to the media channel.
679 void TestStreams() { 681 void TestStreams() {
680 CreateChannels(0, 0); 682 CreateChannels(0, 0);
681 EXPECT_TRUE(AddStream1(1)); 683 EXPECT_TRUE(AddStream1(1));
682 EXPECT_TRUE(AddStream1(2)); 684 EXPECT_TRUE(AddStream1(2));
(...skipping 25 matching lines...) Expand all
708 stream3.groupid = "group3"; 710 stream3.groupid = "group3";
709 stream3.id = "stream3"; 711 stream3.id = "stream3";
710 stream3.ssrcs.push_back(kSsrc3); 712 stream3.ssrcs.push_back(kSsrc3);
711 stream3.cname = "stream3_cname"; 713 stream3.cname = "stream3_cname";
712 714
713 CreateChannels(0, 0); 715 CreateChannels(0, 0);
714 typename T::Content content1; 716 typename T::Content content1;
715 CreateContent(0, kPcmuCodec, kH264Codec, &content1); 717 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
716 content1.AddStream(stream1); 718 content1.AddStream(stream1);
717 EXPECT_EQ(0u, media_channel1_->send_streams().size()); 719 EXPECT_EQ(0u, media_channel1_->send_streams().size());
718 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); 720 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, nullptr));
719 721
720 ASSERT_EQ(1u, media_channel1_->send_streams().size()); 722 ASSERT_EQ(1u, media_channel1_->send_streams().size());
721 EXPECT_EQ(stream1, media_channel1_->send_streams()[0]); 723 EXPECT_EQ(stream1, media_channel1_->send_streams()[0]);
722 724
723 // Update the local streams by adding another sending stream. 725 // Update the local streams by adding another sending stream.
724 // Use a partial updated session description. 726 // Use a partial updated session description.
725 typename T::Content content2; 727 typename T::Content content2;
726 content2.AddStream(stream2); 728 content2.AddStream(stream2);
727 content2.AddStream(stream3); 729 content2.AddStream(stream3);
728 content2.set_partial(true); 730 content2.set_partial(true);
729 EXPECT_TRUE(channel1_->SetLocalContent(&content2, CA_UPDATE, NULL)); 731 EXPECT_TRUE(channel1_->SetLocalContent(&content2, CA_UPDATE, nullptr));
730 ASSERT_EQ(3u, media_channel1_->send_streams().size()); 732 ASSERT_EQ(3u, media_channel1_->send_streams().size());
731 EXPECT_EQ(stream1, media_channel1_->send_streams()[0]); 733 EXPECT_EQ(stream1, media_channel1_->send_streams()[0]);
732 EXPECT_EQ(stream2, media_channel1_->send_streams()[1]); 734 EXPECT_EQ(stream2, media_channel1_->send_streams()[1]);
733 EXPECT_EQ(stream3, media_channel1_->send_streams()[2]); 735 EXPECT_EQ(stream3, media_channel1_->send_streams()[2]);
734 736
735 // Update the local streams by removing the first sending stream. 737 // Update the local streams by removing the first sending stream.
736 // This is done by removing all SSRCS for this particular stream. 738 // This is done by removing all SSRCS for this particular stream.
737 typename T::Content content3; 739 typename T::Content content3;
738 stream1.ssrcs.clear(); 740 stream1.ssrcs.clear();
739 content3.AddStream(stream1); 741 content3.AddStream(stream1);
740 content3.set_partial(true); 742 content3.set_partial(true);
741 EXPECT_TRUE(channel1_->SetLocalContent(&content3, CA_UPDATE, NULL)); 743 EXPECT_TRUE(channel1_->SetLocalContent(&content3, CA_UPDATE, nullptr));
742 ASSERT_EQ(2u, media_channel1_->send_streams().size()); 744 ASSERT_EQ(2u, media_channel1_->send_streams().size());
743 EXPECT_EQ(stream2, media_channel1_->send_streams()[0]); 745 EXPECT_EQ(stream2, media_channel1_->send_streams()[0]);
744 EXPECT_EQ(stream3, media_channel1_->send_streams()[1]); 746 EXPECT_EQ(stream3, media_channel1_->send_streams()[1]);
745 747
746 // Update the local streams with a stream that does not change. 748 // Update the local streams with a stream that does not change.
747 // THe update is ignored. 749 // THe update is ignored.
748 typename T::Content content4; 750 typename T::Content content4;
749 content4.AddStream(stream2); 751 content4.AddStream(stream2);
750 content4.set_partial(true); 752 content4.set_partial(true);
751 EXPECT_TRUE(channel1_->SetLocalContent(&content4, CA_UPDATE, NULL)); 753 EXPECT_TRUE(channel1_->SetLocalContent(&content4, CA_UPDATE, nullptr));
752 ASSERT_EQ(2u, media_channel1_->send_streams().size()); 754 ASSERT_EQ(2u, media_channel1_->send_streams().size());
753 EXPECT_EQ(stream2, media_channel1_->send_streams()[0]); 755 EXPECT_EQ(stream2, media_channel1_->send_streams()[0]);
754 EXPECT_EQ(stream3, media_channel1_->send_streams()[1]); 756 EXPECT_EQ(stream3, media_channel1_->send_streams()[1]);
755 } 757 }
756 758
757 // Test that SetRemoteContent properly handles adding and removing 759 // Test that SetRemoteContent properly handles adding and removing
758 // StreamParams to the remote content description. 760 // StreamParams to the remote content description.
759 // This test uses the CA_UPDATE action that don't require a full 761 // This test uses the CA_UPDATE action that don't require a full
760 // MediaContentDescription to do an update. 762 // MediaContentDescription to do an update.
761 void TestUpdateStreamsInRemoteContent() { 763 void TestUpdateStreamsInRemoteContent() {
(...skipping 13 matching lines...) Expand all
775 stream3.id = "Stream3"; 777 stream3.id = "Stream3";
776 stream3.groupid = "3"; 778 stream3.groupid = "3";
777 stream3.ssrcs.push_back(kSsrc3); 779 stream3.ssrcs.push_back(kSsrc3);
778 stream3.cname = "stream3_cname"; 780 stream3.cname = "stream3_cname";
779 781
780 CreateChannels(0, 0); 782 CreateChannels(0, 0);
781 typename T::Content content1; 783 typename T::Content content1;
782 CreateContent(0, kPcmuCodec, kH264Codec, &content1); 784 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
783 content1.AddStream(stream1); 785 content1.AddStream(stream1);
784 EXPECT_EQ(0u, media_channel1_->recv_streams().size()); 786 EXPECT_EQ(0u, media_channel1_->recv_streams().size());
785 EXPECT_TRUE(channel1_->SetRemoteContent(&content1, CA_OFFER, NULL)); 787 EXPECT_TRUE(channel1_->SetRemoteContent(&content1, CA_OFFER, nullptr));
786 788
787 ASSERT_EQ(1u, media_channel1_->codecs().size()); 789 ASSERT_EQ(1u, media_channel1_->codecs().size());
788 ASSERT_EQ(1u, media_channel1_->recv_streams().size()); 790 ASSERT_EQ(1u, media_channel1_->recv_streams().size());
789 EXPECT_EQ(stream1, media_channel1_->recv_streams()[0]); 791 EXPECT_EQ(stream1, media_channel1_->recv_streams()[0]);
790 792
791 // Update the remote streams by adding another sending stream. 793 // Update the remote streams by adding another sending stream.
792 // Use a partial updated session description. 794 // Use a partial updated session description.
793 typename T::Content content2; 795 typename T::Content content2;
794 content2.AddStream(stream2); 796 content2.AddStream(stream2);
795 content2.AddStream(stream3); 797 content2.AddStream(stream3);
796 content2.set_partial(true); 798 content2.set_partial(true);
797 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_UPDATE, NULL)); 799 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_UPDATE, nullptr));
798 ASSERT_EQ(3u, media_channel1_->recv_streams().size()); 800 ASSERT_EQ(3u, media_channel1_->recv_streams().size());
799 EXPECT_EQ(stream1, media_channel1_->recv_streams()[0]); 801 EXPECT_EQ(stream1, media_channel1_->recv_streams()[0]);
800 EXPECT_EQ(stream2, media_channel1_->recv_streams()[1]); 802 EXPECT_EQ(stream2, media_channel1_->recv_streams()[1]);
801 EXPECT_EQ(stream3, media_channel1_->recv_streams()[2]); 803 EXPECT_EQ(stream3, media_channel1_->recv_streams()[2]);
802 804
803 // Update the remote streams by removing the first stream. 805 // Update the remote streams by removing the first stream.
804 // This is done by removing all SSRCS for this particular stream. 806 // This is done by removing all SSRCS for this particular stream.
805 typename T::Content content3; 807 typename T::Content content3;
806 stream1.ssrcs.clear(); 808 stream1.ssrcs.clear();
807 content3.AddStream(stream1); 809 content3.AddStream(stream1);
808 content3.set_partial(true); 810 content3.set_partial(true);
809 EXPECT_TRUE(channel1_->SetRemoteContent(&content3, CA_UPDATE, NULL)); 811 EXPECT_TRUE(channel1_->SetRemoteContent(&content3, CA_UPDATE, nullptr));
810 ASSERT_EQ(2u, media_channel1_->recv_streams().size()); 812 ASSERT_EQ(2u, media_channel1_->recv_streams().size());
811 EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]); 813 EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]);
812 EXPECT_EQ(stream3, media_channel1_->recv_streams()[1]); 814 EXPECT_EQ(stream3, media_channel1_->recv_streams()[1]);
813 815
814 // Update the remote streams with a stream that does not change. 816 // Update the remote streams with a stream that does not change.
815 // The update is ignored. 817 // The update is ignored.
816 typename T::Content content4; 818 typename T::Content content4;
817 content4.AddStream(stream2); 819 content4.AddStream(stream2);
818 content4.set_partial(true); 820 content4.set_partial(true);
819 EXPECT_TRUE(channel1_->SetRemoteContent(&content4, CA_UPDATE, NULL)); 821 EXPECT_TRUE(channel1_->SetRemoteContent(&content4, CA_UPDATE, nullptr));
820 ASSERT_EQ(2u, media_channel1_->recv_streams().size()); 822 ASSERT_EQ(2u, media_channel1_->recv_streams().size());
821 EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]); 823 EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]);
822 EXPECT_EQ(stream3, media_channel1_->recv_streams()[1]); 824 EXPECT_EQ(stream3, media_channel1_->recv_streams()[1]);
823 } 825 }
824 826
825 // Test that SetLocalContent and SetRemoteContent properly 827 // Test that SetLocalContent and SetRemoteContent properly
826 // handles adding and removing StreamParams when the action is a full 828 // handles adding and removing StreamParams when the action is a full
827 // CA_OFFER / CA_ANSWER. 829 // CA_OFFER / CA_ANSWER.
828 void TestChangeStreamParamsInContent() { 830 void TestChangeStreamParamsInContent() {
829 cricket::StreamParams stream1; 831 cricket::StreamParams stream1;
830 stream1.groupid = "group1"; 832 stream1.groupid = "group1";
831 stream1.id = "stream1"; 833 stream1.id = "stream1";
832 stream1.ssrcs.push_back(kSsrc1); 834 stream1.ssrcs.push_back(kSsrc1);
833 stream1.cname = "stream1_cname"; 835 stream1.cname = "stream1_cname";
834 836
835 cricket::StreamParams stream2; 837 cricket::StreamParams stream2;
836 stream2.groupid = "group1"; 838 stream2.groupid = "group1";
837 stream2.id = "stream2"; 839 stream2.id = "stream2";
838 stream2.ssrcs.push_back(kSsrc2); 840 stream2.ssrcs.push_back(kSsrc2);
839 stream2.cname = "stream2_cname"; 841 stream2.cname = "stream2_cname";
840 842
841 // Setup a call where channel 1 send |stream1| to channel 2. 843 // Setup a call where channel 1 send |stream1| to channel 2.
842 CreateChannels(0, 0); 844 CreateChannels(0, 0);
843 typename T::Content content1; 845 typename T::Content content1;
844 CreateContent(0, kPcmuCodec, kH264Codec, &content1); 846 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
845 content1.AddStream(stream1); 847 content1.AddStream(stream1);
846 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); 848 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, nullptr));
847 EXPECT_TRUE(channel1_->Enable(true)); 849 EXPECT_TRUE(channel1_->Enable(true));
848 EXPECT_EQ(1u, media_channel1_->send_streams().size()); 850 EXPECT_EQ(1u, media_channel1_->send_streams().size());
849 851
850 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); 852 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, nullptr));
851 EXPECT_EQ(1u, media_channel2_->recv_streams().size()); 853 EXPECT_EQ(1u, media_channel2_->recv_streams().size());
852 ConnectFakeTransports(); 854 ConnectFakeTransports();
853 855
854 // Channel 2 do not send anything. 856 // Channel 2 do not send anything.
855 typename T::Content content2; 857 typename T::Content content2;
856 CreateContent(0, kPcmuCodec, kH264Codec, &content2); 858 CreateContent(0, kPcmuCodec, kH264Codec, &content2);
857 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL)); 859 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, nullptr));
858 EXPECT_EQ(0u, media_channel1_->recv_streams().size()); 860 EXPECT_EQ(0u, media_channel1_->recv_streams().size());
859 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL)); 861 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, nullptr));
860 EXPECT_TRUE(channel2_->Enable(true)); 862 EXPECT_TRUE(channel2_->Enable(true));
861 EXPECT_EQ(0u, media_channel2_->send_streams().size()); 863 EXPECT_EQ(0u, media_channel2_->send_streams().size());
862 864
863 SendCustomRtp1(kSsrc1, 0); 865 SendCustomRtp1(kSsrc1, 0);
864 WaitForThreads(); 866 WaitForThreads();
865 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, 0)); 867 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, 0));
866 868
867 // Let channel 2 update the content by sending |stream2| and enable SRTP. 869 // Let channel 2 update the content by sending |stream2| and enable SRTP.
868 typename T::Content content3; 870 typename T::Content content3;
869 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content3); 871 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content3);
870 content3.AddStream(stream2); 872 content3.AddStream(stream2);
871 EXPECT_TRUE(channel2_->SetLocalContent(&content3, CA_OFFER, NULL)); 873 EXPECT_TRUE(channel2_->SetLocalContent(&content3, CA_OFFER, nullptr));
872 ASSERT_EQ(1u, media_channel2_->send_streams().size()); 874 ASSERT_EQ(1u, media_channel2_->send_streams().size());
873 EXPECT_EQ(stream2, media_channel2_->send_streams()[0]); 875 EXPECT_EQ(stream2, media_channel2_->send_streams()[0]);
874 876
875 EXPECT_TRUE(channel1_->SetRemoteContent(&content3, CA_OFFER, NULL)); 877 EXPECT_TRUE(channel1_->SetRemoteContent(&content3, CA_OFFER, nullptr));
876 ASSERT_EQ(1u, media_channel1_->recv_streams().size()); 878 ASSERT_EQ(1u, media_channel1_->recv_streams().size());
877 EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]); 879 EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]);
878 880
879 // Channel 1 replies but stop sending stream1. 881 // Channel 1 replies but stop sending stream1.
880 typename T::Content content4; 882 typename T::Content content4;
881 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content4); 883 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content4);
882 EXPECT_TRUE(channel1_->SetLocalContent(&content4, CA_ANSWER, NULL)); 884 EXPECT_TRUE(channel1_->SetLocalContent(&content4, CA_ANSWER, nullptr));
883 EXPECT_EQ(0u, media_channel1_->send_streams().size()); 885 EXPECT_EQ(0u, media_channel1_->send_streams().size());
884 886
885 EXPECT_TRUE(channel2_->SetRemoteContent(&content4, CA_ANSWER, NULL)); 887 EXPECT_TRUE(channel2_->SetRemoteContent(&content4, CA_ANSWER, nullptr));
886 EXPECT_EQ(0u, media_channel2_->recv_streams().size()); 888 EXPECT_EQ(0u, media_channel2_->recv_streams().size());
887 889
888 EXPECT_TRUE(channel1_->secure()); 890 EXPECT_TRUE(channel1_->secure());
889 EXPECT_TRUE(channel2_->secure()); 891 EXPECT_TRUE(channel2_->secure());
890 SendCustomRtp2(kSsrc2, 0); 892 SendCustomRtp2(kSsrc2, 0);
891 WaitForThreads(); 893 WaitForThreads();
892 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, 0)); 894 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, 0));
893 } 895 }
894 896
895 // Test that we only start playout and sending at the right times. 897 // Test that we only start playout and sending at the right times.
896 void TestPlayoutAndSendingStates() { 898 void TestPlayoutAndSendingStates() {
897 CreateChannels(0, 0); 899 CreateChannels(0, 0);
898 if (verify_playout_) { 900 if (verify_playout_) {
899 EXPECT_FALSE(media_channel1_->playout()); 901 EXPECT_FALSE(media_channel1_->playout());
900 } 902 }
901 EXPECT_FALSE(media_channel1_->sending()); 903 EXPECT_FALSE(media_channel1_->sending());
902 if (verify_playout_) { 904 if (verify_playout_) {
903 EXPECT_FALSE(media_channel2_->playout()); 905 EXPECT_FALSE(media_channel2_->playout());
904 } 906 }
905 EXPECT_FALSE(media_channel2_->sending()); 907 EXPECT_FALSE(media_channel2_->sending());
906 EXPECT_TRUE(channel1_->Enable(true)); 908 EXPECT_TRUE(channel1_->Enable(true));
907 if (verify_playout_) { 909 if (verify_playout_) {
908 EXPECT_FALSE(media_channel1_->playout()); 910 EXPECT_FALSE(media_channel1_->playout());
909 } 911 }
910 EXPECT_FALSE(media_channel1_->sending()); 912 EXPECT_FALSE(media_channel1_->sending());
911 EXPECT_TRUE(channel1_->SetLocalContent(&local_media_content1_, 913 EXPECT_TRUE(
912 CA_OFFER, NULL)); 914 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, nullptr));
913 if (verify_playout_) { 915 if (verify_playout_) {
914 EXPECT_TRUE(media_channel1_->playout()); 916 EXPECT_TRUE(media_channel1_->playout());
915 } 917 }
916 EXPECT_FALSE(media_channel1_->sending()); 918 EXPECT_FALSE(media_channel1_->sending());
917 EXPECT_TRUE(channel2_->SetRemoteContent(&local_media_content1_, 919 EXPECT_TRUE(
918 CA_OFFER, NULL)); 920 channel2_->SetRemoteContent(&local_media_content1_, CA_OFFER, nullptr));
919 if (verify_playout_) { 921 if (verify_playout_) {
920 EXPECT_FALSE(media_channel2_->playout()); 922 EXPECT_FALSE(media_channel2_->playout());
921 } 923 }
922 EXPECT_FALSE(media_channel2_->sending()); 924 EXPECT_FALSE(media_channel2_->sending());
923 EXPECT_TRUE(channel2_->SetLocalContent(&local_media_content2_, 925 EXPECT_TRUE(
924 CA_ANSWER, NULL)); 926 channel2_->SetLocalContent(&local_media_content2_, CA_ANSWER, nullptr));
925 if (verify_playout_) { 927 if (verify_playout_) {
926 EXPECT_FALSE(media_channel2_->playout()); 928 EXPECT_FALSE(media_channel2_->playout());
927 } 929 }
928 EXPECT_FALSE(media_channel2_->sending()); 930 EXPECT_FALSE(media_channel2_->sending());
929 ConnectFakeTransports(); 931 ConnectFakeTransports();
930 if (verify_playout_) { 932 if (verify_playout_) {
931 EXPECT_TRUE(media_channel1_->playout()); 933 EXPECT_TRUE(media_channel1_->playout());
932 } 934 }
933 EXPECT_FALSE(media_channel1_->sending()); 935 EXPECT_FALSE(media_channel1_->sending());
934 if (verify_playout_) { 936 if (verify_playout_) {
935 EXPECT_FALSE(media_channel2_->playout()); 937 EXPECT_FALSE(media_channel2_->playout());
936 } 938 }
937 EXPECT_FALSE(media_channel2_->sending()); 939 EXPECT_FALSE(media_channel2_->sending());
938 EXPECT_TRUE(channel2_->Enable(true)); 940 EXPECT_TRUE(channel2_->Enable(true));
939 if (verify_playout_) { 941 if (verify_playout_) {
940 EXPECT_TRUE(media_channel2_->playout()); 942 EXPECT_TRUE(media_channel2_->playout());
941 } 943 }
942 EXPECT_TRUE(media_channel2_->sending()); 944 EXPECT_TRUE(media_channel2_->sending());
943 EXPECT_TRUE(channel1_->SetRemoteContent(&local_media_content2_, 945 EXPECT_TRUE(channel1_->SetRemoteContent(&local_media_content2_, CA_ANSWER,
944 CA_ANSWER, NULL)); 946 nullptr));
945 if (verify_playout_) { 947 if (verify_playout_) {
946 EXPECT_TRUE(media_channel1_->playout()); 948 EXPECT_TRUE(media_channel1_->playout());
947 } 949 }
948 EXPECT_TRUE(media_channel1_->sending()); 950 EXPECT_TRUE(media_channel1_->sending());
949 } 951 }
950 952
951 // Test that changing the MediaContentDirection in the local and remote 953 // Test that changing the MediaContentDirection in the local and remote
952 // session description start playout and sending at the right time. 954 // session description start playout and sending at the right time.
953 void TestMediaContentDirection() { 955 void TestMediaContentDirection() {
954 CreateChannels(0, 0); 956 CreateChannels(0, 0);
955 typename T::Content content1; 957 typename T::Content content1;
956 CreateContent(0, kPcmuCodec, kH264Codec, &content1); 958 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
957 typename T::Content content2; 959 typename T::Content content2;
958 CreateContent(0, kPcmuCodec, kH264Codec, &content2); 960 CreateContent(0, kPcmuCodec, kH264Codec, &content2);
959 // Set |content2| to be InActive. 961 // Set |content2| to be InActive.
960 content2.set_direction(cricket::MD_INACTIVE); 962 content2.set_direction(cricket::MD_INACTIVE);
961 963
962 EXPECT_TRUE(channel1_->Enable(true)); 964 EXPECT_TRUE(channel1_->Enable(true));
963 EXPECT_TRUE(channel2_->Enable(true)); 965 EXPECT_TRUE(channel2_->Enable(true));
964 if (verify_playout_) { 966 if (verify_playout_) {
965 EXPECT_FALSE(media_channel1_->playout()); 967 EXPECT_FALSE(media_channel1_->playout());
966 } 968 }
967 EXPECT_FALSE(media_channel1_->sending()); 969 EXPECT_FALSE(media_channel1_->sending());
968 if (verify_playout_) { 970 if (verify_playout_) {
969 EXPECT_FALSE(media_channel2_->playout()); 971 EXPECT_FALSE(media_channel2_->playout());
970 } 972 }
971 EXPECT_FALSE(media_channel2_->sending()); 973 EXPECT_FALSE(media_channel2_->sending());
972 974
973 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); 975 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, nullptr));
974 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); 976 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, nullptr));
975 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL)); 977 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, nullptr));
976 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL)); 978 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, nullptr));
977 ConnectFakeTransports(); 979 ConnectFakeTransports();
978 980
979 if (verify_playout_) { 981 if (verify_playout_) {
980 EXPECT_TRUE(media_channel1_->playout()); 982 EXPECT_TRUE(media_channel1_->playout());
981 } 983 }
982 EXPECT_FALSE(media_channel1_->sending()); // remote InActive 984 EXPECT_FALSE(media_channel1_->sending()); // remote InActive
983 if (verify_playout_) { 985 if (verify_playout_) {
984 EXPECT_FALSE(media_channel2_->playout()); // local InActive 986 EXPECT_FALSE(media_channel2_->playout()); // local InActive
985 } 987 }
986 EXPECT_FALSE(media_channel2_->sending()); // local InActive 988 EXPECT_FALSE(media_channel2_->sending()); // local InActive
987 989
988 // Update |content2| to be RecvOnly. 990 // Update |content2| to be RecvOnly.
989 content2.set_direction(cricket::MD_RECVONLY); 991 content2.set_direction(cricket::MD_RECVONLY);
990 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL)); 992 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, nullptr));
991 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL)); 993 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, nullptr));
992 994
993 if (verify_playout_) { 995 if (verify_playout_) {
994 EXPECT_TRUE(media_channel1_->playout()); 996 EXPECT_TRUE(media_channel1_->playout());
995 } 997 }
996 EXPECT_TRUE(media_channel1_->sending()); 998 EXPECT_TRUE(media_channel1_->sending());
997 if (verify_playout_) { 999 if (verify_playout_) {
998 EXPECT_TRUE(media_channel2_->playout()); // local RecvOnly 1000 EXPECT_TRUE(media_channel2_->playout()); // local RecvOnly
999 } 1001 }
1000 EXPECT_FALSE(media_channel2_->sending()); // local RecvOnly 1002 EXPECT_FALSE(media_channel2_->sending()); // local RecvOnly
1001 1003
1002 // Update |content2| to be SendRecv. 1004 // Update |content2| to be SendRecv.
1003 content2.set_direction(cricket::MD_SENDRECV); 1005 content2.set_direction(cricket::MD_SENDRECV);
1004 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL)); 1006 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, nullptr));
1005 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL)); 1007 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, nullptr));
1006 1008
1007 if (verify_playout_) { 1009 if (verify_playout_) {
1008 EXPECT_TRUE(media_channel1_->playout()); 1010 EXPECT_TRUE(media_channel1_->playout());
1009 } 1011 }
1010 EXPECT_TRUE(media_channel1_->sending()); 1012 EXPECT_TRUE(media_channel1_->sending());
1011 if (verify_playout_) { 1013 if (verify_playout_) {
1012 EXPECT_TRUE(media_channel2_->playout()); 1014 EXPECT_TRUE(media_channel2_->playout());
1013 } 1015 }
1014 EXPECT_TRUE(media_channel2_->sending()); 1016 EXPECT_TRUE(media_channel2_->sending());
1015 } 1017 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 EXPECT_EQ(1U, media_channel2_->codecs().size()); 1086 EXPECT_EQ(1U, media_channel2_->codecs().size());
1085 } 1087 }
1086 1088
1087 // Test that we don't crash if packets are sent during call teardown 1089 // Test that we don't crash if packets are sent during call teardown
1088 // when RTCP mux is enabled. This is a regression test against a specific 1090 // when RTCP mux is enabled. This is a regression test against a specific
1089 // race condition that would only occur when a RTCP packet was sent during 1091 // race condition that would only occur when a RTCP packet was sent during
1090 // teardown of a channel on which RTCP mux was enabled. 1092 // teardown of a channel on which RTCP mux was enabled.
1091 void TestCallTeardownRtcpMux() { 1093 void TestCallTeardownRtcpMux() {
1092 class LastWordMediaChannel : public T::MediaChannel { 1094 class LastWordMediaChannel : public T::MediaChannel {
1093 public: 1095 public:
1094 LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {} 1096 LastWordMediaChannel()
1097 : T::MediaChannel(nullptr, typename T::Options()) {}
1095 ~LastWordMediaChannel() { 1098 ~LastWordMediaChannel() {
1096 T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame), 1099 T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame),
1097 rtc::PacketOptions()); 1100 rtc::PacketOptions());
1098 T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport)); 1101 T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport));
1099 } 1102 }
1100 }; 1103 };
1101 CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(), 1104 CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(),
1102 RTCP_MUX, RTCP_MUX); 1105 RTCP_MUX, RTCP_MUX);
1103 EXPECT_TRUE(SendInitiate()); 1106 EXPECT_TRUE(SendInitiate());
1104 EXPECT_TRUE(SendAccept()); 1107 EXPECT_TRUE(SendAccept());
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 WaitForThreads(); 1925 WaitForThreads();
1923 EXPECT_TRUE(media_channel1_->ready_to_send()); 1926 EXPECT_TRUE(media_channel1_->ready_to_send());
1924 } 1927 }
1925 1928
1926 void TestOnReadyToSendWithRtcpMux() { 1929 void TestOnReadyToSendWithRtcpMux() {
1927 CreateChannels(0, 0); 1930 CreateChannels(0, 0);
1928 typename T::Content content; 1931 typename T::Content content;
1929 CreateContent(0, kPcmuCodec, kH264Codec, &content); 1932 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1930 // Both sides agree on mux. Should signal that RTCP mux is fully active. 1933 // Both sides agree on mux. Should signal that RTCP mux is fully active.
1931 content.set_rtcp_mux(true); 1934 content.set_rtcp_mux(true);
1932 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); 1935 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, nullptr));
1933 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_); 1936 EXPECT_EQ(0, rtcp_mux_activated_callbacks1_);
1934 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); 1937 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, nullptr));
1935 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_); 1938 EXPECT_EQ(1, rtcp_mux_activated_callbacks1_);
1936 cricket::FakeDtlsTransport* rtp = fake_rtp_dtls_transport1_.get(); 1939 cricket::FakeDtlsTransport* rtp = fake_rtp_dtls_transport1_.get();
1937 EXPECT_FALSE(media_channel1_->ready_to_send()); 1940 EXPECT_FALSE(media_channel1_->ready_to_send());
1938 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel 1941 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel
1939 // should trigger the MediaChannel's OnReadyToSend. 1942 // should trigger the MediaChannel's OnReadyToSend.
1940 network_thread_->Invoke<void>(RTC_FROM_HERE, 1943 network_thread_->Invoke<void>(RTC_FROM_HERE,
1941 [rtp] { rtp->SignalReadyToSend(rtp); }); 1944 [rtp] { rtp->SignalReadyToSend(rtp); });
1942 WaitForThreads(); 1945 WaitForThreads();
1943 EXPECT_TRUE(media_channel1_->ready_to_send()); 1946 EXPECT_TRUE(media_channel1_->ready_to_send());
1944 1947
1945 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { 1948 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1946 channel1_->SetTransportChannelReadyToSend(false, false); 1949 channel1_->SetTransportChannelReadyToSend(false, false);
1947 }); 1950 });
1948 WaitForThreads(); 1951 WaitForThreads();
1949 EXPECT_FALSE(media_channel1_->ready_to_send()); 1952 EXPECT_FALSE(media_channel1_->ready_to_send());
1950 } 1953 }
1951 1954
1952 bool SetRemoteContentWithBitrateLimit(int remote_limit) { 1955 bool SetRemoteContentWithBitrateLimit(int remote_limit) {
1953 typename T::Content content; 1956 typename T::Content content;
1954 CreateContent(0, kPcmuCodec, kH264Codec, &content); 1957 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1955 content.set_bandwidth(remote_limit); 1958 content.set_bandwidth(remote_limit);
1956 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL); 1959 return channel1_->SetRemoteContent(&content, CA_OFFER, nullptr);
1957 } 1960 }
1958 1961
1959 webrtc::RtpParameters BitrateLimitedParameters(rtc::Optional<int> limit) { 1962 webrtc::RtpParameters BitrateLimitedParameters(rtc::Optional<int> limit) {
1960 webrtc::RtpParameters parameters; 1963 webrtc::RtpParameters parameters;
1961 webrtc::RtpEncodingParameters encoding; 1964 webrtc::RtpEncodingParameters encoding;
1962 encoding.max_bitrate_bps = limit; 1965 encoding.max_bitrate_bps = limit;
1963 parameters.encodings.push_back(encoding); 1966 parameters.encodings.push_back(encoding);
1964 return parameters; 1967 return parameters;
1965 } 1968 }
1966 1969
1967 void VerifyMaxBitrate(const webrtc::RtpParameters& parameters, 1970 void VerifyMaxBitrate(const webrtc::RtpParameters& parameters,
1968 rtc::Optional<int> expected_bitrate) { 1971 rtc::Optional<int> expected_bitrate) {
1969 EXPECT_EQ(1UL, parameters.encodings.size()); 1972 EXPECT_EQ(1UL, parameters.encodings.size());
1970 EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps); 1973 EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps);
1971 } 1974 }
1972 1975
1973 void DefaultMaxBitrateIsUnlimited() { 1976 void DefaultMaxBitrateIsUnlimited() {
1974 CreateChannels(0, 0); 1977 CreateChannels(0, 0);
1975 EXPECT_TRUE( 1978 EXPECT_TRUE(
1976 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); 1979 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, nullptr));
1977 EXPECT_EQ(media_channel1_->max_bps(), -1); 1980 EXPECT_EQ(media_channel1_->max_bps(), -1);
1978 VerifyMaxBitrate(media_channel1_->GetRtpSendParameters(kSsrc1), 1981 VerifyMaxBitrate(media_channel1_->GetRtpSendParameters(kSsrc1),
1979 rtc::Optional<int>()); 1982 rtc::Optional<int>());
1980 } 1983 }
1981 1984
1982 void CanChangeMaxBitrate() { 1985 void CanChangeMaxBitrate() {
1983 CreateChannels(0, 0); 1986 CreateChannels(0, 0);
1984 EXPECT_TRUE( 1987 EXPECT_TRUE(
1985 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); 1988 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, nullptr));
1986 1989
1987 EXPECT_TRUE(channel1_->SetRtpSendParameters( 1990 EXPECT_TRUE(channel1_->SetRtpSendParameters(
1988 kSsrc1, BitrateLimitedParameters(rtc::Optional<int>(1000)))); 1991 kSsrc1, BitrateLimitedParameters(rtc::Optional<int>(1000))));
1989 VerifyMaxBitrate(channel1_->GetRtpSendParameters(kSsrc1), 1992 VerifyMaxBitrate(channel1_->GetRtpSendParameters(kSsrc1),
1990 rtc::Optional<int>(1000)); 1993 rtc::Optional<int>(1000));
1991 VerifyMaxBitrate(media_channel1_->GetRtpSendParameters(kSsrc1), 1994 VerifyMaxBitrate(media_channel1_->GetRtpSendParameters(kSsrc1),
1992 rtc::Optional<int>(1000)); 1995 rtc::Optional<int>(1000));
1993 EXPECT_EQ(-1, media_channel1_->max_bps()); 1996 EXPECT_EQ(-1, media_channel1_->max_bps());
1994 1997
1995 EXPECT_TRUE(channel1_->SetRtpSendParameters( 1998 EXPECT_TRUE(channel1_->SetRtpSendParameters(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::Yes) {} 2104 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::Yes) {}
2102 }; 2105 };
2103 2106
2104 class VoiceChannelDoubleThreadTest : public ChannelTest<VoiceTraits> { 2107 class VoiceChannelDoubleThreadTest : public ChannelTest<VoiceTraits> {
2105 public: 2108 public:
2106 typedef ChannelTest<VoiceTraits> Base; 2109 typedef ChannelTest<VoiceTraits> Base;
2107 VoiceChannelDoubleThreadTest() 2110 VoiceChannelDoubleThreadTest()
2108 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::No) {} 2111 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::No) {}
2109 }; 2112 };
2110 2113
2111 // override to add NULL parameter 2114 // override to add null parameter
2112 template <> 2115 template <>
2113 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( 2116 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel(
2114 rtc::Thread* worker_thread, 2117 rtc::Thread* worker_thread,
2115 rtc::Thread* network_thread, 2118 rtc::Thread* network_thread,
2116 cricket::MediaEngineInterface* engine, 2119 cricket::MediaEngineInterface* engine,
2117 cricket::FakeVideoMediaChannel* ch, 2120 cricket::FakeVideoMediaChannel* ch,
2118 cricket::DtlsTransportInternal* fake_rtp_dtls_transport, 2121 cricket::DtlsTransportInternal* fake_rtp_dtls_transport,
2119 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport, 2122 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport,
2120 rtc::PacketTransportInternal* fake_rtp_packet_transport, 2123 rtc::PacketTransportInternal* fake_rtp_packet_transport,
2121 rtc::PacketTransportInternal* fake_rtcp_packet_transport, 2124 rtc::PacketTransportInternal* fake_rtcp_packet_transport,
2122 int flags) { 2125 int flags) {
2123 rtc::Thread* signaling_thread = rtc::Thread::Current(); 2126 rtc::Thread* signaling_thread = rtc::Thread::Current();
2124 cricket::VideoChannel* channel = new cricket::VideoChannel( 2127 cricket::VideoChannel* channel = new cricket::VideoChannel(
2125 worker_thread, network_thread, signaling_thread, ch, cricket::CN_VIDEO, 2128 worker_thread, network_thread, signaling_thread, ch, cricket::CN_VIDEO,
2126 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); 2129 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0);
2127 rtc::CryptoOptions crypto_options; 2130 rtc::CryptoOptions crypto_options;
2128 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; 2131 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0;
2129 channel->SetCryptoOptions(crypto_options); 2132 channel->SetCryptoOptions(crypto_options);
2130 if (!channel->NeedsRtcpTransport()) { 2133 if (!channel->NeedsRtcpTransport()) {
2131 fake_rtcp_dtls_transport = nullptr; 2134 fake_rtcp_dtls_transport = nullptr;
2132 } 2135 }
2133 if (!channel->Init_w(fake_rtp_dtls_transport, fake_rtcp_dtls_transport, 2136 if (!channel->Init_w(fake_rtp_dtls_transport, fake_rtcp_dtls_transport,
2134 fake_rtp_packet_transport, fake_rtcp_packet_transport)) { 2137 fake_rtp_packet_transport, fake_rtcp_packet_transport)) {
2135 delete channel; 2138 delete channel;
2136 channel = NULL; 2139 channel = nullptr;
2137 } 2140 }
2138 return channel; 2141 return channel;
2139 } 2142 }
2140 2143
2141 // override to add 0 parameter 2144 // override to add 0 parameter
2142 template<> 2145 template<>
2143 bool ChannelTest<VideoTraits>::AddStream1(int id) { 2146 bool ChannelTest<VideoTraits>::AddStream1(int id) {
2144 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); 2147 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id));
2145 } 2148 }
2146 2149
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
3364 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); 3367 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0);
3365 rtc::CryptoOptions crypto_options; 3368 rtc::CryptoOptions crypto_options;
3366 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; 3369 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0;
3367 channel->SetCryptoOptions(crypto_options); 3370 channel->SetCryptoOptions(crypto_options);
3368 if (!channel->NeedsRtcpTransport()) { 3371 if (!channel->NeedsRtcpTransport()) {
3369 fake_rtcp_dtls_transport = nullptr; 3372 fake_rtcp_dtls_transport = nullptr;
3370 } 3373 }
3371 if (!channel->Init_w(fake_rtp_dtls_transport, fake_rtcp_dtls_transport, 3374 if (!channel->Init_w(fake_rtp_dtls_transport, fake_rtcp_dtls_transport,
3372 fake_rtp_packet_transport, fake_rtcp_packet_transport)) { 3375 fake_rtp_packet_transport, fake_rtcp_packet_transport)) {
3373 delete channel; 3376 delete channel;
3374 channel = NULL; 3377 channel = nullptr;
3375 } 3378 }
3376 return channel; 3379 return channel;
3377 } 3380 }
3378 3381
3379 template <> 3382 template <>
3380 void ChannelTest<DataTraits>::CreateContent( 3383 void ChannelTest<DataTraits>::CreateContent(
3381 int flags, 3384 int flags,
3382 const cricket::AudioCodec& audio_codec, 3385 const cricket::AudioCodec& audio_codec,
3383 const cricket::VideoCodec& video_codec, 3386 const cricket::VideoCodec& video_codec,
3384 cricket::DataContentDescription* data) { 3387 cricket::DataContentDescription* data) {
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
3779 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_, 3782 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_,
3780 &fake_rtcp_dtls_transport_)); 3783 &fake_rtcp_dtls_transport_));
3781 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_, 3784 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_,
3782 &fake_rtp_dtls_transport_), 3785 &fake_rtp_dtls_transport_),
3783 ""); 3786 "");
3784 } 3787 }
3785 3788
3786 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 3789 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
3787 3790
3788 // TODO(pthatcher): TestSetReceiver? 3791 // TODO(pthatcher): TestSetReceiver?
OLDNEW
« webrtc/base/event.cc ('K') | « webrtc/pc/channel.cc ('k') | webrtc/pc/channelmanager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698