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

Side by Side Diff: webrtc/api/peerconnectioninterface_unittest.cc

Issue 1930463002: Replace scoped_ptr with unique_ptr in webrtc/api/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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/api/peerconnectioninterface.h ('k') | webrtc/api/proxy.h » ('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 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 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 <utility> 13 #include <utility>
13 14
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "webrtc/api/audiotrack.h" 16 #include "webrtc/api/audiotrack.h"
16 #include "webrtc/api/jsepsessiondescription.h" 17 #include "webrtc/api/jsepsessiondescription.h"
17 #include "webrtc/api/mediastream.h" 18 #include "webrtc/api/mediastream.h"
18 #include "webrtc/api/mediastreaminterface.h" 19 #include "webrtc/api/mediastreaminterface.h"
19 #include "webrtc/api/peerconnection.h" 20 #include "webrtc/api/peerconnection.h"
20 #include "webrtc/api/peerconnectioninterface.h" 21 #include "webrtc/api/peerconnectioninterface.h"
21 #include "webrtc/api/rtpreceiverinterface.h" 22 #include "webrtc/api/rtpreceiverinterface.h"
22 #include "webrtc/api/rtpsenderinterface.h" 23 #include "webrtc/api/rtpsenderinterface.h"
23 #include "webrtc/api/streamcollection.h" 24 #include "webrtc/api/streamcollection.h"
24 #ifdef WEBRTC_ANDROID 25 #ifdef WEBRTC_ANDROID
25 #include "webrtc/api/test/androidtestinitializer.h" 26 #include "webrtc/api/test/androidtestinitializer.h"
26 #endif 27 #endif
27 #include "webrtc/api/test/fakeconstraints.h" 28 #include "webrtc/api/test/fakeconstraints.h"
28 #include "webrtc/api/test/fakedtlsidentitystore.h" 29 #include "webrtc/api/test/fakedtlsidentitystore.h"
29 #include "webrtc/api/test/fakevideotracksource.h" 30 #include "webrtc/api/test/fakevideotracksource.h"
30 #include "webrtc/api/test/mockpeerconnectionobservers.h" 31 #include "webrtc/api/test/mockpeerconnectionobservers.h"
31 #include "webrtc/api/test/testsdpstrings.h" 32 #include "webrtc/api/test/testsdpstrings.h"
32 #include "webrtc/api/videocapturertracksource.h" 33 #include "webrtc/api/videocapturertracksource.h"
33 #include "webrtc/api/videotrack.h" 34 #include "webrtc/api/videotrack.h"
34 #include "webrtc/base/gunit.h" 35 #include "webrtc/base/gunit.h"
35 #include "webrtc/base/scoped_ptr.h"
36 #include "webrtc/base/ssladapter.h" 36 #include "webrtc/base/ssladapter.h"
37 #include "webrtc/base/sslstreamadapter.h" 37 #include "webrtc/base/sslstreamadapter.h"
38 #include "webrtc/base/stringutils.h" 38 #include "webrtc/base/stringutils.h"
39 #include "webrtc/base/thread.h" 39 #include "webrtc/base/thread.h"
40 #include "webrtc/media/base/fakevideocapturer.h" 40 #include "webrtc/media/base/fakevideocapturer.h"
41 #include "webrtc/media/sctp/sctpdataengine.h" 41 #include "webrtc/media/sctp/sctpdataengine.h"
42 #include "webrtc/p2p/client/fakeportallocator.h" 42 #include "webrtc/p2p/client/fakeportallocator.h"
43 #include "webrtc/pc/mediasession.h" 43 #include "webrtc/pc/mediasession.h"
44 44
45 static const char kStreamLabel1[] = "local_stream_1"; 45 static const char kStreamLabel1[] = "local_stream_1";
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 static const char kSdpStringMs1Video1[] = 232 static const char kSdpStringMs1Video1[] =
233 "a=ssrc:4 cname:stream1\r\n" 233 "a=ssrc:4 cname:stream1\r\n"
234 "a=ssrc:4 msid:stream1 videotrack1\r\n"; 234 "a=ssrc:4 msid:stream1 videotrack1\r\n";
235 235
236 #define MAYBE_SKIP_TEST(feature) \ 236 #define MAYBE_SKIP_TEST(feature) \
237 if (!(feature())) { \ 237 if (!(feature())) { \
238 LOG(LS_INFO) << "Feature disabled... skipping"; \ 238 LOG(LS_INFO) << "Feature disabled... skipping"; \
239 return; \ 239 return; \
240 } 240 }
241 241
242 using rtc::scoped_ptr;
243 using rtc::scoped_refptr; 242 using rtc::scoped_refptr;
244 using ::testing::Exactly; 243 using ::testing::Exactly;
245 using webrtc::AudioSourceInterface; 244 using webrtc::AudioSourceInterface;
246 using webrtc::AudioTrack; 245 using webrtc::AudioTrack;
247 using webrtc::AudioTrackInterface; 246 using webrtc::AudioTrackInterface;
248 using webrtc::DataBuffer; 247 using webrtc::DataBuffer;
249 using webrtc::DataChannelInterface; 248 using webrtc::DataChannelInterface;
250 using webrtc::FakeConstraints; 249 using webrtc::FakeConstraints;
251 using webrtc::IceCandidateInterface; 250 using webrtc::IceCandidateInterface;
252 using webrtc::MediaConstraintsInterface; 251 using webrtc::MediaConstraintsInterface;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 return ""; 496 return "";
498 } 497 }
499 std::string GetLastRemovedStreamLabel() { 498 std::string GetLastRemovedStreamLabel() {
500 if (last_removed_stream_.get()) 499 if (last_removed_stream_.get())
501 return last_removed_stream_->label(); 500 return last_removed_stream_->label();
502 return ""; 501 return "";
503 } 502 }
504 503
505 scoped_refptr<PeerConnectionInterface> pc_; 504 scoped_refptr<PeerConnectionInterface> pc_;
506 PeerConnectionInterface::SignalingState state_; 505 PeerConnectionInterface::SignalingState state_;
507 scoped_ptr<IceCandidateInterface> last_candidate_; 506 std::unique_ptr<IceCandidateInterface> last_candidate_;
508 scoped_refptr<DataChannelInterface> last_datachannel_; 507 scoped_refptr<DataChannelInterface> last_datachannel_;
509 rtc::scoped_refptr<StreamCollection> remote_streams_; 508 rtc::scoped_refptr<StreamCollection> remote_streams_;
510 bool renegotiation_needed_ = false; 509 bool renegotiation_needed_ = false;
511 bool ice_complete_ = false; 510 bool ice_complete_ = false;
512 511
513 private: 512 private:
514 scoped_refptr<MediaStreamInterface> last_added_stream_; 513 scoped_refptr<MediaStreamInterface> last_added_stream_;
515 scoped_refptr<MediaStreamInterface> last_removed_stream_; 514 scoped_refptr<MediaStreamInterface> last_removed_stream_;
516 }; 515 };
517 516
(...skipping 26 matching lines...) Expand all
544 const std::string& password, 543 const std::string& password,
545 webrtc::MediaConstraintsInterface* constraints) { 544 webrtc::MediaConstraintsInterface* constraints) {
546 PeerConnectionInterface::RTCConfiguration config; 545 PeerConnectionInterface::RTCConfiguration config;
547 PeerConnectionInterface::IceServer server; 546 PeerConnectionInterface::IceServer server;
548 if (!uri.empty()) { 547 if (!uri.empty()) {
549 server.uri = uri; 548 server.uri = uri;
550 server.password = password; 549 server.password = password;
551 config.servers.push_back(server); 550 config.servers.push_back(server);
552 } 551 }
553 552
554 rtc::scoped_ptr<cricket::FakePortAllocator> port_allocator( 553 std::unique_ptr<cricket::FakePortAllocator> port_allocator(
555 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr)); 554 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
556 port_allocator_ = port_allocator.get(); 555 port_allocator_ = port_allocator.get();
557 556
558 // DTLS does not work in a loopback call, so is disabled for most of the 557 // DTLS does not work in a loopback call, so is disabled for most of the
559 // tests in this file. We only create a FakeIdentityService if the test 558 // tests in this file. We only create a FakeIdentityService if the test
560 // explicitly sets the constraint. 559 // explicitly sets the constraint.
561 FakeConstraints default_constraints; 560 FakeConstraints default_constraints;
562 if (!constraints) { 561 if (!constraints) {
563 constraints = &default_constraints; 562 constraints = &default_constraints;
564 563
565 default_constraints.AddMandatory( 564 default_constraints.AddMandatory(
566 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false); 565 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false);
567 } 566 }
568 567
569 scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store; 568 std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store;
570 bool dtls; 569 bool dtls;
571 if (FindConstraint(constraints, 570 if (FindConstraint(constraints,
572 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 571 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
573 &dtls, 572 &dtls,
574 nullptr) && dtls) { 573 nullptr) && dtls) {
575 dtls_identity_store.reset(new FakeDtlsIdentityStore()); 574 dtls_identity_store.reset(new FakeDtlsIdentityStore());
576 } 575 }
577 pc_ = pc_factory_->CreatePeerConnection( 576 pc_ = pc_factory_->CreatePeerConnection(
578 config, constraints, std::move(port_allocator), 577 config, constraints, std::move(port_allocator),
579 std::move(dtls_identity_store), &observer_); 578 std::move(dtls_identity_store), &observer_);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 scoped_refptr<VideoTrackInterface> video_track( 660 scoped_refptr<VideoTrackInterface> video_track(
662 pc_factory_->CreateVideoTrack( 661 pc_factory_->CreateVideoTrack(
663 video_track_label, 662 video_track_label,
664 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer()))); 663 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer())));
665 stream->AddTrack(video_track.get()); 664 stream->AddTrack(video_track.get());
666 EXPECT_TRUE(pc_->AddStream(stream)); 665 EXPECT_TRUE(pc_->AddStream(stream));
667 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); 666 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
668 observer_.renegotiation_needed_ = false; 667 observer_.renegotiation_needed_ = false;
669 } 668 }
670 669
671 bool DoCreateOfferAnswer(rtc::scoped_ptr<SessionDescriptionInterface>* desc, 670 bool DoCreateOfferAnswer(std::unique_ptr<SessionDescriptionInterface>* desc,
672 bool offer, 671 bool offer,
673 MediaConstraintsInterface* constraints) { 672 MediaConstraintsInterface* constraints) {
674 rtc::scoped_refptr<MockCreateSessionDescriptionObserver> 673 rtc::scoped_refptr<MockCreateSessionDescriptionObserver>
675 observer(new rtc::RefCountedObject< 674 observer(new rtc::RefCountedObject<
676 MockCreateSessionDescriptionObserver>()); 675 MockCreateSessionDescriptionObserver>());
677 if (offer) { 676 if (offer) {
678 pc_->CreateOffer(observer, constraints); 677 pc_->CreateOffer(observer, constraints);
679 } else { 678 } else {
680 pc_->CreateAnswer(observer, constraints); 679 pc_->CreateAnswer(observer, constraints);
681 } 680 }
682 EXPECT_EQ_WAIT(true, observer->called(), kTimeout); 681 EXPECT_EQ_WAIT(true, observer->called(), kTimeout);
683 desc->reset(observer->release_desc()); 682 desc->reset(observer->release_desc());
684 return observer->result(); 683 return observer->result();
685 } 684 }
686 685
687 bool DoCreateOffer(rtc::scoped_ptr<SessionDescriptionInterface>* desc, 686 bool DoCreateOffer(std::unique_ptr<SessionDescriptionInterface>* desc,
688 MediaConstraintsInterface* constraints) { 687 MediaConstraintsInterface* constraints) {
689 return DoCreateOfferAnswer(desc, true, constraints); 688 return DoCreateOfferAnswer(desc, true, constraints);
690 } 689 }
691 690
692 bool DoCreateAnswer(rtc::scoped_ptr<SessionDescriptionInterface>* desc, 691 bool DoCreateAnswer(std::unique_ptr<SessionDescriptionInterface>* desc,
693 MediaConstraintsInterface* constraints) { 692 MediaConstraintsInterface* constraints) {
694 return DoCreateOfferAnswer(desc, false, constraints); 693 return DoCreateOfferAnswer(desc, false, constraints);
695 } 694 }
696 695
697 bool DoSetSessionDescription(SessionDescriptionInterface* desc, bool local) { 696 bool DoSetSessionDescription(SessionDescriptionInterface* desc, bool local) {
698 rtc::scoped_refptr<MockSetSessionDescriptionObserver> 697 rtc::scoped_refptr<MockSetSessionDescriptionObserver>
699 observer(new rtc::RefCountedObject< 698 observer(new rtc::RefCountedObject<
700 MockSetSessionDescriptionObserver>()); 699 MockSetSessionDescriptionObserver>());
701 if (local) { 700 if (local) {
702 pc_->SetLocalDescription(observer, desc); 701 pc_->SetLocalDescription(observer, desc);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 ASSERT_TRUE(desc != NULL); 742 ASSERT_TRUE(desc != NULL);
744 EXPECT_GT(desc->rtp_header_extensions().size(), 0u); 743 EXPECT_GT(desc->rtp_header_extensions().size(), 0u);
745 744
746 desc = cricket::GetFirstVideoContentDescription( 745 desc = cricket::GetFirstVideoContentDescription(
747 pc_->remote_description()->description()); 746 pc_->remote_description()->description());
748 ASSERT_TRUE(desc != NULL); 747 ASSERT_TRUE(desc != NULL);
749 EXPECT_GT(desc->rtp_header_extensions().size(), 0u); 748 EXPECT_GT(desc->rtp_header_extensions().size(), 0u);
750 } 749 }
751 750
752 void CreateOfferAsRemoteDescription() { 751 void CreateOfferAsRemoteDescription() {
753 rtc::scoped_ptr<SessionDescriptionInterface> offer; 752 std::unique_ptr<SessionDescriptionInterface> offer;
754 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); 753 ASSERT_TRUE(DoCreateOffer(&offer, nullptr));
755 std::string sdp; 754 std::string sdp;
756 EXPECT_TRUE(offer->ToString(&sdp)); 755 EXPECT_TRUE(offer->ToString(&sdp));
757 SessionDescriptionInterface* remote_offer = 756 SessionDescriptionInterface* remote_offer =
758 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, 757 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer,
759 sdp, NULL); 758 sdp, NULL);
760 EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); 759 EXPECT_TRUE(DoSetRemoteDescription(remote_offer));
761 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_); 760 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_);
762 } 761 }
763 762
764 void CreateAndSetRemoteOffer(const std::string& sdp) { 763 void CreateAndSetRemoteOffer(const std::string& sdp) {
765 SessionDescriptionInterface* remote_offer = 764 SessionDescriptionInterface* remote_offer =
766 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, 765 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer,
767 sdp, nullptr); 766 sdp, nullptr);
768 EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); 767 EXPECT_TRUE(DoSetRemoteDescription(remote_offer));
769 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_); 768 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_);
770 } 769 }
771 770
772 void CreateAnswerAsLocalDescription() { 771 void CreateAnswerAsLocalDescription() {
773 scoped_ptr<SessionDescriptionInterface> answer; 772 std::unique_ptr<SessionDescriptionInterface> answer;
774 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); 773 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr));
775 774
776 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an 775 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an
777 // audio codec change, even if the parameter has nothing to do with 776 // audio codec change, even if the parameter has nothing to do with
778 // receiving. Not all parameters are serialized to SDP. 777 // receiving. Not all parameters are serialized to SDP.
779 // Since CreatePrAnswerAsLocalDescription serialize/deserialize 778 // Since CreatePrAnswerAsLocalDescription serialize/deserialize
780 // the SessionDescription, it is necessary to do that here to in order to 779 // the SessionDescription, it is necessary to do that here to in order to
781 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass. 780 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass.
782 // https://code.google.com/p/webrtc/issues/detail?id=1356 781 // https://code.google.com/p/webrtc/issues/detail?id=1356
783 std::string sdp; 782 std::string sdp;
784 EXPECT_TRUE(answer->ToString(&sdp)); 783 EXPECT_TRUE(answer->ToString(&sdp));
785 SessionDescriptionInterface* new_answer = 784 SessionDescriptionInterface* new_answer =
786 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer, 785 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer,
787 sdp, NULL); 786 sdp, NULL);
788 EXPECT_TRUE(DoSetLocalDescription(new_answer)); 787 EXPECT_TRUE(DoSetLocalDescription(new_answer));
789 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); 788 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_);
790 } 789 }
791 790
792 void CreatePrAnswerAsLocalDescription() { 791 void CreatePrAnswerAsLocalDescription() {
793 scoped_ptr<SessionDescriptionInterface> answer; 792 std::unique_ptr<SessionDescriptionInterface> answer;
794 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); 793 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr));
795 794
796 std::string sdp; 795 std::string sdp;
797 EXPECT_TRUE(answer->ToString(&sdp)); 796 EXPECT_TRUE(answer->ToString(&sdp));
798 SessionDescriptionInterface* pr_answer = 797 SessionDescriptionInterface* pr_answer =
799 webrtc::CreateSessionDescription(SessionDescriptionInterface::kPrAnswer, 798 webrtc::CreateSessionDescription(SessionDescriptionInterface::kPrAnswer,
800 sdp, NULL); 799 sdp, NULL);
801 EXPECT_TRUE(DoSetLocalDescription(pr_answer)); 800 EXPECT_TRUE(DoSetLocalDescription(pr_answer));
802 EXPECT_EQ(PeerConnectionInterface::kHaveLocalPrAnswer, observer_.state_); 801 EXPECT_EQ(PeerConnectionInterface::kHaveLocalPrAnswer, observer_.state_);
803 } 802 }
804 803
805 void CreateOfferReceiveAnswer() { 804 void CreateOfferReceiveAnswer() {
806 CreateOfferAsLocalDescription(); 805 CreateOfferAsLocalDescription();
807 std::string sdp; 806 std::string sdp;
808 EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); 807 EXPECT_TRUE(pc_->local_description()->ToString(&sdp));
809 CreateAnswerAsRemoteDescription(sdp); 808 CreateAnswerAsRemoteDescription(sdp);
810 } 809 }
811 810
812 void CreateOfferAsLocalDescription() { 811 void CreateOfferAsLocalDescription() {
813 rtc::scoped_ptr<SessionDescriptionInterface> offer; 812 std::unique_ptr<SessionDescriptionInterface> offer;
814 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); 813 ASSERT_TRUE(DoCreateOffer(&offer, nullptr));
815 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an 814 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an
816 // audio codec change, even if the parameter has nothing to do with 815 // audio codec change, even if the parameter has nothing to do with
817 // receiving. Not all parameters are serialized to SDP. 816 // receiving. Not all parameters are serialized to SDP.
818 // Since CreatePrAnswerAsLocalDescription serialize/deserialize 817 // Since CreatePrAnswerAsLocalDescription serialize/deserialize
819 // the SessionDescription, it is necessary to do that here to in order to 818 // the SessionDescription, it is necessary to do that here to in order to
820 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass. 819 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass.
821 // https://code.google.com/p/webrtc/issues/detail?id=1356 820 // https://code.google.com/p/webrtc/issues/detail?id=1356
822 std::string sdp; 821 std::string sdp;
823 EXPECT_TRUE(offer->ToString(&sdp)); 822 EXPECT_TRUE(offer->ToString(&sdp));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); 872 EXPECT_TRUE(pc_->local_description()->ToString(&sdp));
874 SetSsrcToZero(&sdp); 873 SetSsrcToZero(&sdp);
875 CreateAnswerAsRemoteDescription(sdp); 874 CreateAnswerAsRemoteDescription(sdp);
876 } 875 }
877 876
878 // This function creates a MediaStream with label kStreams[0] and 877 // This function creates a MediaStream with label kStreams[0] and
879 // |number_of_audio_tracks| and |number_of_video_tracks| tracks and the 878 // |number_of_audio_tracks| and |number_of_video_tracks| tracks and the
880 // corresponding SessionDescriptionInterface. The SessionDescriptionInterface 879 // corresponding SessionDescriptionInterface. The SessionDescriptionInterface
881 // is returned and the MediaStream is stored in 880 // is returned and the MediaStream is stored in
882 // |reference_collection_| 881 // |reference_collection_|
883 rtc::scoped_ptr<SessionDescriptionInterface> 882 std::unique_ptr<SessionDescriptionInterface>
884 CreateSessionDescriptionAndReference(size_t number_of_audio_tracks, 883 CreateSessionDescriptionAndReference(size_t number_of_audio_tracks,
885 size_t number_of_video_tracks) { 884 size_t number_of_video_tracks) {
886 EXPECT_LE(number_of_audio_tracks, 2u); 885 EXPECT_LE(number_of_audio_tracks, 2u);
887 EXPECT_LE(number_of_video_tracks, 2u); 886 EXPECT_LE(number_of_video_tracks, 2u);
888 887
889 reference_collection_ = StreamCollection::Create(); 888 reference_collection_ = StreamCollection::Create();
890 std::string sdp_ms1 = std::string(kSdpStringInit); 889 std::string sdp_ms1 = std::string(kSdpStringInit);
891 890
892 std::string mediastream_label = kStreams[0]; 891 std::string mediastream_label = kStreams[0];
893 892
(...skipping 14 matching lines...) Expand all
908 if (number_of_video_tracks > 0) { 907 if (number_of_video_tracks > 0) {
909 sdp_ms1 += std::string(kSdpStringVideo); 908 sdp_ms1 += std::string(kSdpStringVideo);
910 sdp_ms1 += std::string(kSdpStringMs1Video0); 909 sdp_ms1 += std::string(kSdpStringMs1Video0);
911 AddVideoTrack(kVideoTracks[0], stream); 910 AddVideoTrack(kVideoTracks[0], stream);
912 } 911 }
913 if (number_of_video_tracks > 1) { 912 if (number_of_video_tracks > 1) {
914 sdp_ms1 += kSdpStringMs1Video1; 913 sdp_ms1 += kSdpStringMs1Video1;
915 AddVideoTrack(kVideoTracks[1], stream); 914 AddVideoTrack(kVideoTracks[1], stream);
916 } 915 }
917 916
918 return rtc::scoped_ptr<SessionDescriptionInterface>( 917 return std::unique_ptr<SessionDescriptionInterface>(
919 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, 918 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer,
920 sdp_ms1, nullptr)); 919 sdp_ms1, nullptr));
921 } 920 }
922 921
923 void AddAudioTrack(const std::string& track_id, 922 void AddAudioTrack(const std::string& track_id,
924 MediaStreamInterface* stream) { 923 MediaStreamInterface* stream) {
925 rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track( 924 rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track(
926 webrtc::AudioTrack::Create(track_id, nullptr)); 925 webrtc::AudioTrack::Create(track_id, nullptr));
927 ASSERT_TRUE(stream->AddTrack(audio_track)); 926 ASSERT_TRUE(stream->AddTrack(audio_track));
928 } 927 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 972
974 // Remove the first stream. 973 // Remove the first stream.
975 pc_->RemoveStream(pc_->local_streams()->at(0)); 974 pc_->RemoveStream(pc_->local_streams()->at(0));
976 EXPECT_EQ(0u, pc_->local_streams()->count()); 975 EXPECT_EQ(0u, pc_->local_streams()->count());
977 } 976 }
978 977
979 // Test that the created offer includes streams we added. 978 // Test that the created offer includes streams we added.
980 TEST_F(PeerConnectionInterfaceTest, AddedStreamsPresentInOffer) { 979 TEST_F(PeerConnectionInterfaceTest, AddedStreamsPresentInOffer) {
981 CreatePeerConnection(); 980 CreatePeerConnection();
982 AddAudioVideoStream(kStreamLabel1, "audio_track", "video_track"); 981 AddAudioVideoStream(kStreamLabel1, "audio_track", "video_track");
983 scoped_ptr<SessionDescriptionInterface> offer; 982 std::unique_ptr<SessionDescriptionInterface> offer;
984 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); 983 ASSERT_TRUE(DoCreateOffer(&offer, nullptr));
985 984
986 const cricket::ContentInfo* audio_content = 985 const cricket::ContentInfo* audio_content =
987 cricket::GetFirstAudioContent(offer->description()); 986 cricket::GetFirstAudioContent(offer->description());
988 const cricket::AudioContentDescription* audio_desc = 987 const cricket::AudioContentDescription* audio_desc =
989 static_cast<const cricket::AudioContentDescription*>( 988 static_cast<const cricket::AudioContentDescription*>(
990 audio_content->description); 989 audio_content->description);
991 EXPECT_TRUE( 990 EXPECT_TRUE(
992 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track")); 991 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track"));
993 992
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 auto audio_sender = pc_->AddTrack(audio_track, stream_list); 1047 auto audio_sender = pc_->AddTrack(audio_track, stream_list);
1049 auto video_sender = pc_->AddTrack(video_track, stream_list); 1048 auto video_sender = pc_->AddTrack(video_track, stream_list);
1050 EXPECT_EQ(kStreamLabel1, audio_sender->stream_id()); 1049 EXPECT_EQ(kStreamLabel1, audio_sender->stream_id());
1051 EXPECT_EQ("audio_track", audio_sender->id()); 1050 EXPECT_EQ("audio_track", audio_sender->id());
1052 EXPECT_EQ(audio_track, audio_sender->track()); 1051 EXPECT_EQ(audio_track, audio_sender->track());
1053 EXPECT_EQ(kStreamLabel1, video_sender->stream_id()); 1052 EXPECT_EQ(kStreamLabel1, video_sender->stream_id());
1054 EXPECT_EQ("video_track", video_sender->id()); 1053 EXPECT_EQ("video_track", video_sender->id());
1055 EXPECT_EQ(video_track, video_sender->track()); 1054 EXPECT_EQ(video_track, video_sender->track());
1056 1055
1057 // Now create an offer and check for the senders. 1056 // Now create an offer and check for the senders.
1058 scoped_ptr<SessionDescriptionInterface> offer; 1057 std::unique_ptr<SessionDescriptionInterface> offer;
1059 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); 1058 ASSERT_TRUE(DoCreateOffer(&offer, nullptr));
1060 1059
1061 const cricket::ContentInfo* audio_content = 1060 const cricket::ContentInfo* audio_content =
1062 cricket::GetFirstAudioContent(offer->description()); 1061 cricket::GetFirstAudioContent(offer->description());
1063 const cricket::AudioContentDescription* audio_desc = 1062 const cricket::AudioContentDescription* audio_desc =
1064 static_cast<const cricket::AudioContentDescription*>( 1063 static_cast<const cricket::AudioContentDescription*>(
1065 audio_content->description); 1064 audio_content->description);
1066 EXPECT_TRUE( 1065 EXPECT_TRUE(
1067 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track")); 1066 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track"));
1068 1067
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 CreateOfferReceiveAnswer(); 1185 CreateOfferReceiveAnswer();
1187 EXPECT_EQ(0u, pc_->remote_streams()->count()); 1186 EXPECT_EQ(0u, pc_->remote_streams()->count());
1188 } 1187 }
1189 1188
1190 // Test that candidates are generated and that we can parse our own candidates. 1189 // Test that candidates are generated and that we can parse our own candidates.
1191 TEST_F(PeerConnectionInterfaceTest, IceCandidates) { 1190 TEST_F(PeerConnectionInterfaceTest, IceCandidates) {
1192 CreatePeerConnection(); 1191 CreatePeerConnection();
1193 1192
1194 EXPECT_FALSE(pc_->AddIceCandidate(observer_.last_candidate_.get())); 1193 EXPECT_FALSE(pc_->AddIceCandidate(observer_.last_candidate_.get()));
1195 // SetRemoteDescription takes ownership of offer. 1194 // SetRemoteDescription takes ownership of offer.
1196 rtc::scoped_ptr<SessionDescriptionInterface> offer; 1195 std::unique_ptr<SessionDescriptionInterface> offer;
1197 AddVideoStream(kStreamLabel1); 1196 AddVideoStream(kStreamLabel1);
1198 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); 1197 EXPECT_TRUE(DoCreateOffer(&offer, nullptr));
1199 EXPECT_TRUE(DoSetRemoteDescription(offer.release())); 1198 EXPECT_TRUE(DoSetRemoteDescription(offer.release()));
1200 1199
1201 // SetLocalDescription takes ownership of answer. 1200 // SetLocalDescription takes ownership of answer.
1202 rtc::scoped_ptr<SessionDescriptionInterface> answer; 1201 std::unique_ptr<SessionDescriptionInterface> answer;
1203 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); 1202 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr));
1204 EXPECT_TRUE(DoSetLocalDescription(answer.release())); 1203 EXPECT_TRUE(DoSetLocalDescription(answer.release()));
1205 1204
1206 EXPECT_TRUE_WAIT(observer_.last_candidate_.get() != NULL, kTimeout); 1205 EXPECT_TRUE_WAIT(observer_.last_candidate_.get() != NULL, kTimeout);
1207 EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout); 1206 EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout);
1208 1207
1209 EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate_.get())); 1208 EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate_.get()));
1210 } 1209 }
1211 1210
1212 // Test that CreateOffer and CreateAnswer will fail if the track labels are 1211 // Test that CreateOffer and CreateAnswer will fail if the track labels are
1213 // not unique. 1212 // not unique.
1214 TEST_F(PeerConnectionInterfaceTest, CreateOfferAnswerWithInvalidStream) { 1213 TEST_F(PeerConnectionInterfaceTest, CreateOfferAnswerWithInvalidStream) {
1215 CreatePeerConnection(); 1214 CreatePeerConnection();
1216 // Create a regular offer for the CreateAnswer test later. 1215 // Create a regular offer for the CreateAnswer test later.
1217 rtc::scoped_ptr<SessionDescriptionInterface> offer; 1216 std::unique_ptr<SessionDescriptionInterface> offer;
1218 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); 1217 EXPECT_TRUE(DoCreateOffer(&offer, nullptr));
1219 EXPECT_TRUE(offer); 1218 EXPECT_TRUE(offer);
1220 offer.reset(); 1219 offer.reset();
1221 1220
1222 // Create a local stream with audio&video tracks having same label. 1221 // Create a local stream with audio&video tracks having same label.
1223 AddAudioVideoStream(kStreamLabel1, "track_label", "track_label"); 1222 AddAudioVideoStream(kStreamLabel1, "track_label", "track_label");
1224 1223
1225 // Test CreateOffer 1224 // Test CreateOffer
1226 EXPECT_FALSE(DoCreateOffer(&offer, nullptr)); 1225 EXPECT_FALSE(DoCreateOffer(&offer, nullptr));
1227 1226
1228 // Test CreateAnswer 1227 // Test CreateAnswer
1229 rtc::scoped_ptr<SessionDescriptionInterface> answer; 1228 std::unique_ptr<SessionDescriptionInterface> answer;
1230 EXPECT_FALSE(DoCreateAnswer(&answer, nullptr)); 1229 EXPECT_FALSE(DoCreateAnswer(&answer, nullptr));
1231 } 1230 }
1232 1231
1233 // Test that we will get different SSRCs for each tracks in the offer and answer 1232 // Test that we will get different SSRCs for each tracks in the offer and answer
1234 // we created. 1233 // we created.
1235 TEST_F(PeerConnectionInterfaceTest, SsrcInOfferAnswer) { 1234 TEST_F(PeerConnectionInterfaceTest, SsrcInOfferAnswer) {
1236 CreatePeerConnection(); 1235 CreatePeerConnection();
1237 // Create a local stream with audio&video tracks having different labels. 1236 // Create a local stream with audio&video tracks having different labels.
1238 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); 1237 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label");
1239 1238
1240 // Test CreateOffer 1239 // Test CreateOffer
1241 scoped_ptr<SessionDescriptionInterface> offer; 1240 std::unique_ptr<SessionDescriptionInterface> offer;
1242 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); 1241 ASSERT_TRUE(DoCreateOffer(&offer, nullptr));
1243 int audio_ssrc = 0; 1242 int audio_ssrc = 0;
1244 int video_ssrc = 0; 1243 int video_ssrc = 0;
1245 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(offer->description()), 1244 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(offer->description()),
1246 &audio_ssrc)); 1245 &audio_ssrc));
1247 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(offer->description()), 1246 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(offer->description()),
1248 &video_ssrc)); 1247 &video_ssrc));
1249 EXPECT_NE(audio_ssrc, video_ssrc); 1248 EXPECT_NE(audio_ssrc, video_ssrc);
1250 1249
1251 // Test CreateAnswer 1250 // Test CreateAnswer
1252 EXPECT_TRUE(DoSetRemoteDescription(offer.release())); 1251 EXPECT_TRUE(DoSetRemoteDescription(offer.release()));
1253 scoped_ptr<SessionDescriptionInterface> answer; 1252 std::unique_ptr<SessionDescriptionInterface> answer;
1254 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); 1253 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr));
1255 audio_ssrc = 0; 1254 audio_ssrc = 0;
1256 video_ssrc = 0; 1255 video_ssrc = 0;
1257 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(answer->description()), 1256 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(answer->description()),
1258 &audio_ssrc)); 1257 &audio_ssrc));
1259 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(answer->description()), 1258 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(answer->description()),
1260 &video_ssrc)); 1259 &video_ssrc));
1261 EXPECT_NE(audio_ssrc, video_ssrc); 1260 EXPECT_NE(audio_ssrc, video_ssrc);
1262 } 1261 }
1263 1262
1264 // Test that it's possible to call AddTrack on a MediaStream after adding 1263 // Test that it's possible to call AddTrack on a MediaStream after adding
1265 // the stream to a PeerConnection. 1264 // the stream to a PeerConnection.
1266 // TODO(deadbeef): Remove this test once this behavior is no longer supported. 1265 // TODO(deadbeef): Remove this test once this behavior is no longer supported.
1267 TEST_F(PeerConnectionInterfaceTest, AddTrackAfterAddStream) { 1266 TEST_F(PeerConnectionInterfaceTest, AddTrackAfterAddStream) {
1268 CreatePeerConnection(); 1267 CreatePeerConnection();
1269 // Create audio stream and add to PeerConnection. 1268 // Create audio stream and add to PeerConnection.
1270 AddVoiceStream(kStreamLabel1); 1269 AddVoiceStream(kStreamLabel1);
1271 MediaStreamInterface* stream = pc_->local_streams()->at(0); 1270 MediaStreamInterface* stream = pc_->local_streams()->at(0);
1272 1271
1273 // Add video track to the audio-only stream. 1272 // Add video track to the audio-only stream.
1274 scoped_refptr<VideoTrackInterface> video_track(pc_factory_->CreateVideoTrack( 1273 scoped_refptr<VideoTrackInterface> video_track(pc_factory_->CreateVideoTrack(
1275 "video_label", 1274 "video_label",
1276 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer()))); 1275 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer())));
1277 stream->AddTrack(video_track.get()); 1276 stream->AddTrack(video_track.get());
1278 1277
1279 scoped_ptr<SessionDescriptionInterface> offer; 1278 std::unique_ptr<SessionDescriptionInterface> offer;
1280 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); 1279 ASSERT_TRUE(DoCreateOffer(&offer, nullptr));
1281 1280
1282 const cricket::MediaContentDescription* video_desc = 1281 const cricket::MediaContentDescription* video_desc =
1283 cricket::GetFirstVideoContentDescription(offer->description()); 1282 cricket::GetFirstVideoContentDescription(offer->description());
1284 EXPECT_TRUE(video_desc != nullptr); 1283 EXPECT_TRUE(video_desc != nullptr);
1285 } 1284 }
1286 1285
1287 // Test that it's possible to call RemoveTrack on a MediaStream after adding 1286 // Test that it's possible to call RemoveTrack on a MediaStream after adding
1288 // the stream to a PeerConnection. 1287 // the stream to a PeerConnection.
1289 // TODO(deadbeef): Remove this test once this behavior is no longer supported. 1288 // TODO(deadbeef): Remove this test once this behavior is no longer supported.
1290 TEST_F(PeerConnectionInterfaceTest, RemoveTrackAfterAddStream) { 1289 TEST_F(PeerConnectionInterfaceTest, RemoveTrackAfterAddStream) {
1291 CreatePeerConnection(); 1290 CreatePeerConnection();
1292 // Create audio/video stream and add to PeerConnection. 1291 // Create audio/video stream and add to PeerConnection.
1293 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); 1292 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label");
1294 MediaStreamInterface* stream = pc_->local_streams()->at(0); 1293 MediaStreamInterface* stream = pc_->local_streams()->at(0);
1295 1294
1296 // Remove the video track. 1295 // Remove the video track.
1297 stream->RemoveTrack(stream->GetVideoTracks()[0]); 1296 stream->RemoveTrack(stream->GetVideoTracks()[0]);
1298 1297
1299 scoped_ptr<SessionDescriptionInterface> offer; 1298 std::unique_ptr<SessionDescriptionInterface> offer;
1300 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); 1299 ASSERT_TRUE(DoCreateOffer(&offer, nullptr));
1301 1300
1302 const cricket::MediaContentDescription* video_desc = 1301 const cricket::MediaContentDescription* video_desc =
1303 cricket::GetFirstVideoContentDescription(offer->description()); 1302 cricket::GetFirstVideoContentDescription(offer->description());
1304 EXPECT_TRUE(video_desc == nullptr); 1303 EXPECT_TRUE(video_desc == nullptr);
1305 } 1304 }
1306 1305
1307 // Test creating a sender with a stream ID, and ensure the ID is populated 1306 // Test creating a sender with a stream ID, and ensure the ID is populated
1308 // in the offer. 1307 // in the offer.
1309 TEST_F(PeerConnectionInterfaceTest, CreateSenderWithStream) { 1308 TEST_F(PeerConnectionInterfaceTest, CreateSenderWithStream) {
1310 CreatePeerConnection(); 1309 CreatePeerConnection();
1311 pc_->CreateSender("video", kStreamLabel1); 1310 pc_->CreateSender("video", kStreamLabel1);
1312 1311
1313 scoped_ptr<SessionDescriptionInterface> offer; 1312 std::unique_ptr<SessionDescriptionInterface> offer;
1314 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); 1313 ASSERT_TRUE(DoCreateOffer(&offer, nullptr));
1315 1314
1316 const cricket::MediaContentDescription* video_desc = 1315 const cricket::MediaContentDescription* video_desc =
1317 cricket::GetFirstVideoContentDescription(offer->description()); 1316 cricket::GetFirstVideoContentDescription(offer->description());
1318 ASSERT_TRUE(video_desc != nullptr); 1317 ASSERT_TRUE(video_desc != nullptr);
1319 ASSERT_EQ(1u, video_desc->streams().size()); 1318 ASSERT_EQ(1u, video_desc->streams().size());
1320 EXPECT_EQ(kStreamLabel1, video_desc->streams()[0].sync_label); 1319 EXPECT_EQ(kStreamLabel1, video_desc->streams()[0].sync_label);
1321 } 1320 }
1322 1321
1323 // Test that we can specify a certain track that we want statistics about. 1322 // Test that we can specify a certain track that we want statistics about.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 // This test setup two RTP data channels in loop back. 1365 // This test setup two RTP data channels in loop back.
1367 TEST_F(PeerConnectionInterfaceTest, TestDataChannel) { 1366 TEST_F(PeerConnectionInterfaceTest, TestDataChannel) {
1368 FakeConstraints constraints; 1367 FakeConstraints constraints;
1369 constraints.SetAllowRtpDataChannels(); 1368 constraints.SetAllowRtpDataChannels();
1370 CreatePeerConnection(&constraints); 1369 CreatePeerConnection(&constraints);
1371 scoped_refptr<DataChannelInterface> data1 = 1370 scoped_refptr<DataChannelInterface> data1 =
1372 pc_->CreateDataChannel("test1", NULL); 1371 pc_->CreateDataChannel("test1", NULL);
1373 scoped_refptr<DataChannelInterface> data2 = 1372 scoped_refptr<DataChannelInterface> data2 =
1374 pc_->CreateDataChannel("test2", NULL); 1373 pc_->CreateDataChannel("test2", NULL);
1375 ASSERT_TRUE(data1 != NULL); 1374 ASSERT_TRUE(data1 != NULL);
1376 rtc::scoped_ptr<MockDataChannelObserver> observer1( 1375 std::unique_ptr<MockDataChannelObserver> observer1(
1377 new MockDataChannelObserver(data1)); 1376 new MockDataChannelObserver(data1));
1378 rtc::scoped_ptr<MockDataChannelObserver> observer2( 1377 std::unique_ptr<MockDataChannelObserver> observer2(
1379 new MockDataChannelObserver(data2)); 1378 new MockDataChannelObserver(data2));
1380 1379
1381 EXPECT_EQ(DataChannelInterface::kConnecting, data1->state()); 1380 EXPECT_EQ(DataChannelInterface::kConnecting, data1->state());
1382 EXPECT_EQ(DataChannelInterface::kConnecting, data2->state()); 1381 EXPECT_EQ(DataChannelInterface::kConnecting, data2->state());
1383 std::string data_to_send1 = "testing testing"; 1382 std::string data_to_send1 = "testing testing";
1384 std::string data_to_send2 = "testing something else"; 1383 std::string data_to_send2 = "testing something else";
1385 EXPECT_FALSE(data1->Send(DataBuffer(data_to_send1))); 1384 EXPECT_FALSE(data1->Send(DataBuffer(data_to_send1)));
1386 1385
1387 CreateOfferReceiveAnswer(); 1386 CreateOfferReceiveAnswer();
1388 EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout); 1387 EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout);
(...skipping 24 matching lines...) Expand all
1413 // fail. 1412 // fail.
1414 TEST_F(PeerConnectionInterfaceTest, TestSendBinaryOnRtpDataChannel) { 1413 TEST_F(PeerConnectionInterfaceTest, TestSendBinaryOnRtpDataChannel) {
1415 FakeConstraints constraints; 1414 FakeConstraints constraints;
1416 constraints.SetAllowRtpDataChannels(); 1415 constraints.SetAllowRtpDataChannels();
1417 CreatePeerConnection(&constraints); 1416 CreatePeerConnection(&constraints);
1418 scoped_refptr<DataChannelInterface> data1 = 1417 scoped_refptr<DataChannelInterface> data1 =
1419 pc_->CreateDataChannel("test1", NULL); 1418 pc_->CreateDataChannel("test1", NULL);
1420 scoped_refptr<DataChannelInterface> data2 = 1419 scoped_refptr<DataChannelInterface> data2 =
1421 pc_->CreateDataChannel("test2", NULL); 1420 pc_->CreateDataChannel("test2", NULL);
1422 ASSERT_TRUE(data1 != NULL); 1421 ASSERT_TRUE(data1 != NULL);
1423 rtc::scoped_ptr<MockDataChannelObserver> observer1( 1422 std::unique_ptr<MockDataChannelObserver> observer1(
1424 new MockDataChannelObserver(data1)); 1423 new MockDataChannelObserver(data1));
1425 rtc::scoped_ptr<MockDataChannelObserver> observer2( 1424 std::unique_ptr<MockDataChannelObserver> observer2(
1426 new MockDataChannelObserver(data2)); 1425 new MockDataChannelObserver(data2));
1427 1426
1428 EXPECT_EQ(DataChannelInterface::kConnecting, data1->state()); 1427 EXPECT_EQ(DataChannelInterface::kConnecting, data1->state());
1429 EXPECT_EQ(DataChannelInterface::kConnecting, data2->state()); 1428 EXPECT_EQ(DataChannelInterface::kConnecting, data2->state());
1430 1429
1431 CreateOfferReceiveAnswer(); 1430 CreateOfferReceiveAnswer();
1432 EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout); 1431 EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout);
1433 EXPECT_TRUE_WAIT(observer2->IsOpen(), kTimeout); 1432 EXPECT_TRUE_WAIT(observer2->IsOpen(), kTimeout);
1434 1433
1435 EXPECT_EQ(DataChannelInterface::kOpen, data1->state()); 1434 EXPECT_EQ(DataChannelInterface::kOpen, data1->state());
1436 EXPECT_EQ(DataChannelInterface::kOpen, data2->state()); 1435 EXPECT_EQ(DataChannelInterface::kOpen, data2->state());
1437 1436
1438 rtc::CopyOnWriteBuffer buffer("test", 4); 1437 rtc::CopyOnWriteBuffer buffer("test", 4);
1439 EXPECT_FALSE(data1->Send(DataBuffer(buffer, true))); 1438 EXPECT_FALSE(data1->Send(DataBuffer(buffer, true)));
1440 } 1439 }
1441 1440
1442 // This test setup a RTP data channels in loop back and test that a channel is 1441 // This test setup a RTP data channels in loop back and test that a channel is
1443 // opened even if the remote end answer with a zero SSRC. 1442 // opened even if the remote end answer with a zero SSRC.
1444 TEST_F(PeerConnectionInterfaceTest, TestSendOnlyDataChannel) { 1443 TEST_F(PeerConnectionInterfaceTest, TestSendOnlyDataChannel) {
1445 FakeConstraints constraints; 1444 FakeConstraints constraints;
1446 constraints.SetAllowRtpDataChannels(); 1445 constraints.SetAllowRtpDataChannels();
1447 CreatePeerConnection(&constraints); 1446 CreatePeerConnection(&constraints);
1448 scoped_refptr<DataChannelInterface> data1 = 1447 scoped_refptr<DataChannelInterface> data1 =
1449 pc_->CreateDataChannel("test1", NULL); 1448 pc_->CreateDataChannel("test1", NULL);
1450 rtc::scoped_ptr<MockDataChannelObserver> observer1( 1449 std::unique_ptr<MockDataChannelObserver> observer1(
1451 new MockDataChannelObserver(data1)); 1450 new MockDataChannelObserver(data1));
1452 1451
1453 CreateOfferReceiveAnswerWithoutSsrc(); 1452 CreateOfferReceiveAnswerWithoutSsrc();
1454 1453
1455 EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout); 1454 EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout);
1456 1455
1457 data1->Close(); 1456 data1->Close();
1458 EXPECT_EQ(DataChannelInterface::kClosing, data1->state()); 1457 EXPECT_EQ(DataChannelInterface::kClosing, data1->state());
1459 CreateOfferReceiveAnswerWithoutSsrc(); 1458 CreateOfferReceiveAnswerWithoutSsrc();
1460 EXPECT_EQ(DataChannelInterface::kClosed, data1->state()); 1459 EXPECT_EQ(DataChannelInterface::kClosed, data1->state());
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 TEST_F(PeerConnectionInterfaceTest, DataChannelCloseWhenPeerConnectionClose) { 1654 TEST_F(PeerConnectionInterfaceTest, DataChannelCloseWhenPeerConnectionClose) {
1656 FakeConstraints constraints; 1655 FakeConstraints constraints;
1657 constraints.SetAllowRtpDataChannels(); 1656 constraints.SetAllowRtpDataChannels();
1658 CreatePeerConnection(&constraints); 1657 CreatePeerConnection(&constraints);
1659 1658
1660 scoped_refptr<DataChannelInterface> data1 = 1659 scoped_refptr<DataChannelInterface> data1 =
1661 pc_->CreateDataChannel("test1", NULL); 1660 pc_->CreateDataChannel("test1", NULL);
1662 scoped_refptr<DataChannelInterface> data2 = 1661 scoped_refptr<DataChannelInterface> data2 =
1663 pc_->CreateDataChannel("test2", NULL); 1662 pc_->CreateDataChannel("test2", NULL);
1664 ASSERT_TRUE(data1 != NULL); 1663 ASSERT_TRUE(data1 != NULL);
1665 rtc::scoped_ptr<MockDataChannelObserver> observer1( 1664 std::unique_ptr<MockDataChannelObserver> observer1(
1666 new MockDataChannelObserver(data1)); 1665 new MockDataChannelObserver(data1));
1667 rtc::scoped_ptr<MockDataChannelObserver> observer2( 1666 std::unique_ptr<MockDataChannelObserver> observer2(
1668 new MockDataChannelObserver(data2)); 1667 new MockDataChannelObserver(data2));
1669 1668
1670 CreateOfferReceiveAnswer(); 1669 CreateOfferReceiveAnswer();
1671 EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout); 1670 EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout);
1672 EXPECT_TRUE_WAIT(observer2->IsOpen(), kTimeout); 1671 EXPECT_TRUE_WAIT(observer2->IsOpen(), kTimeout);
1673 1672
1674 ReleasePeerConnection(); 1673 ReleasePeerConnection();
1675 EXPECT_EQ(DataChannelInterface::kClosed, data1->state()); 1674 EXPECT_EQ(DataChannelInterface::kClosed, data1->state());
1676 EXPECT_EQ(DataChannelInterface::kClosed, data2->state()); 1675 EXPECT_EQ(DataChannelInterface::kClosed, data2->state());
1677 } 1676 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 TEST_F(PeerConnectionInterfaceTest, CreateSubsequentRecvOnlyOffer) { 1761 TEST_F(PeerConnectionInterfaceTest, CreateSubsequentRecvOnlyOffer) {
1763 FakeConstraints constraints; 1762 FakeConstraints constraints;
1764 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 1763 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
1765 true); 1764 true);
1766 CreatePeerConnection(&constraints); 1765 CreatePeerConnection(&constraints);
1767 CreateAndSetRemoteOffer(kSdpStringWithStream1); 1766 CreateAndSetRemoteOffer(kSdpStringWithStream1);
1768 CreateAnswerAsLocalDescription(); 1767 CreateAnswerAsLocalDescription();
1769 1768
1770 // At this point we should be receiving stream 1, but not sending anything. 1769 // At this point we should be receiving stream 1, but not sending anything.
1771 // A new offer should be recvonly. 1770 // A new offer should be recvonly.
1772 rtc::scoped_ptr<SessionDescriptionInterface> offer; 1771 std::unique_ptr<SessionDescriptionInterface> offer;
1773 DoCreateOffer(&offer, nullptr); 1772 DoCreateOffer(&offer, nullptr);
1774 1773
1775 const cricket::ContentInfo* video_content = 1774 const cricket::ContentInfo* video_content =
1776 cricket::GetFirstVideoContent(offer->description()); 1775 cricket::GetFirstVideoContent(offer->description());
1777 const cricket::VideoContentDescription* video_desc = 1776 const cricket::VideoContentDescription* video_desc =
1778 static_cast<const cricket::VideoContentDescription*>( 1777 static_cast<const cricket::VideoContentDescription*>(
1779 video_content->description); 1778 video_content->description);
1780 ASSERT_EQ(cricket::MD_RECVONLY, video_desc->direction()); 1779 ASSERT_EQ(cricket::MD_RECVONLY, video_desc->direction());
1781 1780
1782 const cricket::ContentInfo* audio_content = 1781 const cricket::ContentInfo* audio_content =
(...skipping 11 matching lines...) Expand all
1794 FakeConstraints constraints; 1793 FakeConstraints constraints;
1795 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 1794 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
1796 true); 1795 true);
1797 CreatePeerConnection(&constraints); 1796 CreatePeerConnection(&constraints);
1798 CreateAndSetRemoteOffer(kSdpStringWithStream1); 1797 CreateAndSetRemoteOffer(kSdpStringWithStream1);
1799 CreateAnswerAsLocalDescription(); 1798 CreateAnswerAsLocalDescription();
1800 1799
1801 // At this point we should be receiving stream 1, but not sending anything. 1800 // At this point we should be receiving stream 1, but not sending anything.
1802 // A new offer would be recvonly, but we'll set the "no receive" constraints 1801 // A new offer would be recvonly, but we'll set the "no receive" constraints
1803 // to make it inactive. 1802 // to make it inactive.
1804 rtc::scoped_ptr<SessionDescriptionInterface> offer; 1803 std::unique_ptr<SessionDescriptionInterface> offer;
1805 FakeConstraints offer_constraints; 1804 FakeConstraints offer_constraints;
1806 offer_constraints.AddMandatory( 1805 offer_constraints.AddMandatory(
1807 webrtc::MediaConstraintsInterface::kOfferToReceiveVideo, false); 1806 webrtc::MediaConstraintsInterface::kOfferToReceiveVideo, false);
1808 offer_constraints.AddMandatory( 1807 offer_constraints.AddMandatory(
1809 webrtc::MediaConstraintsInterface::kOfferToReceiveAudio, false); 1808 webrtc::MediaConstraintsInterface::kOfferToReceiveAudio, false);
1810 DoCreateOffer(&offer, &offer_constraints); 1809 DoCreateOffer(&offer, &offer_constraints);
1811 1810
1812 const cricket::ContentInfo* video_content = 1811 const cricket::ContentInfo* video_content =
1813 cricket::GetFirstVideoContent(offer->description()); 1812 cricket::GetFirstVideoContent(offer->description());
1814 const cricket::VideoContentDescription* video_desc = 1813 const cricket::VideoContentDescription* video_desc =
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 ASSERT_FALSE(local_stream->GetAudioTracks().empty()); 1888 ASSERT_FALSE(local_stream->GetAudioTracks().empty());
1890 rtc::scoped_refptr<webrtc::DtmfSenderInterface> dtmf_sender( 1889 rtc::scoped_refptr<webrtc::DtmfSenderInterface> dtmf_sender(
1891 pc_->CreateDtmfSender(local_stream->GetAudioTracks()[0])); 1890 pc_->CreateDtmfSender(local_stream->GetAudioTracks()[0]));
1892 EXPECT_TRUE(NULL == dtmf_sender); // local stream has been removed. 1891 EXPECT_TRUE(NULL == dtmf_sender); // local stream has been removed.
1893 1892
1894 EXPECT_TRUE(pc_->CreateDataChannel("test", NULL) == NULL); 1893 EXPECT_TRUE(pc_->CreateDataChannel("test", NULL) == NULL);
1895 1894
1896 EXPECT_TRUE(pc_->local_description() != NULL); 1895 EXPECT_TRUE(pc_->local_description() != NULL);
1897 EXPECT_TRUE(pc_->remote_description() != NULL); 1896 EXPECT_TRUE(pc_->remote_description() != NULL);
1898 1897
1899 rtc::scoped_ptr<SessionDescriptionInterface> offer; 1898 std::unique_ptr<SessionDescriptionInterface> offer;
1900 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); 1899 EXPECT_TRUE(DoCreateOffer(&offer, nullptr));
1901 rtc::scoped_ptr<SessionDescriptionInterface> answer; 1900 std::unique_ptr<SessionDescriptionInterface> answer;
1902 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); 1901 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr));
1903 1902
1904 std::string sdp; 1903 std::string sdp;
1905 ASSERT_TRUE(pc_->remote_description()->ToString(&sdp)); 1904 ASSERT_TRUE(pc_->remote_description()->ToString(&sdp));
1906 SessionDescriptionInterface* remote_offer = 1905 SessionDescriptionInterface* remote_offer =
1907 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, 1906 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer,
1908 sdp, NULL); 1907 sdp, NULL);
1909 EXPECT_FALSE(DoSetRemoteDescription(remote_offer)); 1908 EXPECT_FALSE(DoSetRemoteDescription(remote_offer));
1910 1909
1911 ASSERT_TRUE(pc_->local_description()->ToString(&sdp)); 1910 ASSERT_TRUE(pc_->local_description()->ToString(&sdp));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 } 1951 }
1953 1952
1954 // This test verifies that when remote tracks are added/removed from SDP, the 1953 // This test verifies that when remote tracks are added/removed from SDP, the
1955 // created remote streams are updated appropriately. 1954 // created remote streams are updated appropriately.
1956 TEST_F(PeerConnectionInterfaceTest, 1955 TEST_F(PeerConnectionInterfaceTest,
1957 AddRemoveTrackFromExistingRemoteMediaStream) { 1956 AddRemoveTrackFromExistingRemoteMediaStream) {
1958 FakeConstraints constraints; 1957 FakeConstraints constraints;
1959 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 1958 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
1960 true); 1959 true);
1961 CreatePeerConnection(&constraints); 1960 CreatePeerConnection(&constraints);
1962 rtc::scoped_ptr<SessionDescriptionInterface> desc_ms1 = 1961 std::unique_ptr<SessionDescriptionInterface> desc_ms1 =
1963 CreateSessionDescriptionAndReference(1, 1); 1962 CreateSessionDescriptionAndReference(1, 1);
1964 EXPECT_TRUE(DoSetRemoteDescription(desc_ms1.release())); 1963 EXPECT_TRUE(DoSetRemoteDescription(desc_ms1.release()));
1965 EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(), 1964 EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(),
1966 reference_collection_)); 1965 reference_collection_));
1967 1966
1968 // Add extra audio and video tracks to the same MediaStream. 1967 // Add extra audio and video tracks to the same MediaStream.
1969 rtc::scoped_ptr<SessionDescriptionInterface> desc_ms1_two_tracks = 1968 std::unique_ptr<SessionDescriptionInterface> desc_ms1_two_tracks =
1970 CreateSessionDescriptionAndReference(2, 2); 1969 CreateSessionDescriptionAndReference(2, 2);
1971 EXPECT_TRUE(DoSetRemoteDescription(desc_ms1_two_tracks.release())); 1970 EXPECT_TRUE(DoSetRemoteDescription(desc_ms1_two_tracks.release()));
1972 EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(), 1971 EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(),
1973 reference_collection_)); 1972 reference_collection_));
1974 scoped_refptr<AudioTrackInterface> audio_track2 = 1973 scoped_refptr<AudioTrackInterface> audio_track2 =
1975 observer_.remote_streams()->at(0)->GetAudioTracks()[1]; 1974 observer_.remote_streams()->at(0)->GetAudioTracks()[1];
1976 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, audio_track2->state()); 1975 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, audio_track2->state());
1977 scoped_refptr<VideoTrackInterface> video_track2 = 1976 scoped_refptr<VideoTrackInterface> video_track2 =
1978 observer_.remote_streams()->at(0)->GetVideoTracks()[1]; 1977 observer_.remote_streams()->at(0)->GetVideoTracks()[1];
1979 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, video_track2->state()); 1978 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, video_track2->state());
1980 1979
1981 // Remove the extra audio and video tracks. 1980 // Remove the extra audio and video tracks.
1982 rtc::scoped_ptr<SessionDescriptionInterface> desc_ms2 = 1981 std::unique_ptr<SessionDescriptionInterface> desc_ms2 =
1983 CreateSessionDescriptionAndReference(1, 1); 1982 CreateSessionDescriptionAndReference(1, 1);
1984 MockTrackObserver audio_track_observer(audio_track2); 1983 MockTrackObserver audio_track_observer(audio_track2);
1985 MockTrackObserver video_track_observer(video_track2); 1984 MockTrackObserver video_track_observer(video_track2);
1986 1985
1987 EXPECT_CALL(audio_track_observer, OnChanged()).Times(Exactly(1)); 1986 EXPECT_CALL(audio_track_observer, OnChanged()).Times(Exactly(1));
1988 EXPECT_CALL(video_track_observer, OnChanged()).Times(Exactly(1)); 1987 EXPECT_CALL(video_track_observer, OnChanged()).Times(Exactly(1));
1989 EXPECT_TRUE(DoSetRemoteDescription(desc_ms2.release())); 1988 EXPECT_TRUE(DoSetRemoteDescription(desc_ms2.release()));
1990 EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(), 1989 EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(),
1991 reference_collection_)); 1990 reference_collection_));
1992 // Track state may be updated asynchronously. 1991 // Track state may be updated asynchronously.
(...skipping 18 matching lines...) Expand all
2011 ASSERT_EQ(1u, remote_stream->GetVideoTracks().size()); 2010 ASSERT_EQ(1u, remote_stream->GetVideoTracks().size());
2012 ASSERT_EQ(1u, remote_stream->GetAudioTracks().size()); 2011 ASSERT_EQ(1u, remote_stream->GetAudioTracks().size());
2013 2012
2014 rtc::scoped_refptr<webrtc::VideoTrackInterface> remote_video = 2013 rtc::scoped_refptr<webrtc::VideoTrackInterface> remote_video =
2015 remote_stream->GetVideoTracks()[0]; 2014 remote_stream->GetVideoTracks()[0];
2016 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_video->state()); 2015 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_video->state());
2017 rtc::scoped_refptr<webrtc::AudioTrackInterface> remote_audio = 2016 rtc::scoped_refptr<webrtc::AudioTrackInterface> remote_audio =
2018 remote_stream->GetAudioTracks()[0]; 2017 remote_stream->GetAudioTracks()[0];
2019 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_audio->state()); 2018 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_audio->state());
2020 2019
2021 rtc::scoped_ptr<SessionDescriptionInterface> local_answer; 2020 std::unique_ptr<SessionDescriptionInterface> local_answer;
2022 EXPECT_TRUE(DoCreateAnswer(&local_answer, nullptr)); 2021 EXPECT_TRUE(DoCreateAnswer(&local_answer, nullptr));
2023 cricket::ContentInfo* video_info = 2022 cricket::ContentInfo* video_info =
2024 local_answer->description()->GetContentByName("video"); 2023 local_answer->description()->GetContentByName("video");
2025 video_info->rejected = true; 2024 video_info->rejected = true;
2026 EXPECT_TRUE(DoSetLocalDescription(local_answer.release())); 2025 EXPECT_TRUE(DoSetLocalDescription(local_answer.release()));
2027 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_video->state()); 2026 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_video->state());
2028 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_audio->state()); 2027 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_audio->state());
2029 2028
2030 // Now create an offer where we reject both video and audio. 2029 // Now create an offer where we reject both video and audio.
2031 rtc::scoped_ptr<SessionDescriptionInterface> local_offer; 2030 std::unique_ptr<SessionDescriptionInterface> local_offer;
2032 EXPECT_TRUE(DoCreateOffer(&local_offer, nullptr)); 2031 EXPECT_TRUE(DoCreateOffer(&local_offer, nullptr));
2033 video_info = local_offer->description()->GetContentByName("video"); 2032 video_info = local_offer->description()->GetContentByName("video");
2034 ASSERT_TRUE(video_info != nullptr); 2033 ASSERT_TRUE(video_info != nullptr);
2035 video_info->rejected = true; 2034 video_info->rejected = true;
2036 cricket::ContentInfo* audio_info = 2035 cricket::ContentInfo* audio_info =
2037 local_offer->description()->GetContentByName("audio"); 2036 local_offer->description()->GetContentByName("audio");
2038 ASSERT_TRUE(audio_info != nullptr); 2037 ASSERT_TRUE(audio_info != nullptr);
2039 audio_info->rejected = true; 2038 audio_info->rejected = true;
2040 EXPECT_TRUE(DoSetLocalDescription(local_offer.release())); 2039 EXPECT_TRUE(DoSetLocalDescription(local_offer.release()));
2041 // Track state may be updated asynchronously. 2040 // Track state may be updated asynchronously.
2042 EXPECT_EQ_WAIT(webrtc::MediaStreamTrackInterface::kEnded, 2041 EXPECT_EQ_WAIT(webrtc::MediaStreamTrackInterface::kEnded,
2043 remote_audio->state(), kTimeout); 2042 remote_audio->state(), kTimeout);
2044 EXPECT_EQ_WAIT(webrtc::MediaStreamTrackInterface::kEnded, 2043 EXPECT_EQ_WAIT(webrtc::MediaStreamTrackInterface::kEnded,
2045 remote_video->state(), kTimeout); 2044 remote_video->state(), kTimeout);
2046 } 2045 }
2047 2046
2048 // This tests that we won't crash if the remote track has been removed outside 2047 // This tests that we won't crash if the remote track has been removed outside
2049 // of PeerConnection and then PeerConnection tries to reject the track. 2048 // of PeerConnection and then PeerConnection tries to reject the track.
2050 TEST_F(PeerConnectionInterfaceTest, RemoveTrackThenRejectMediaContent) { 2049 TEST_F(PeerConnectionInterfaceTest, RemoveTrackThenRejectMediaContent) {
2051 FakeConstraints constraints; 2050 FakeConstraints constraints;
2052 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 2051 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
2053 true); 2052 true);
2054 CreatePeerConnection(&constraints); 2053 CreatePeerConnection(&constraints);
2055 CreateAndSetRemoteOffer(kSdpStringWithStream1); 2054 CreateAndSetRemoteOffer(kSdpStringWithStream1);
2056 MediaStreamInterface* remote_stream = observer_.remote_streams()->at(0); 2055 MediaStreamInterface* remote_stream = observer_.remote_streams()->at(0);
2057 remote_stream->RemoveTrack(remote_stream->GetVideoTracks()[0]); 2056 remote_stream->RemoveTrack(remote_stream->GetVideoTracks()[0]);
2058 remote_stream->RemoveTrack(remote_stream->GetAudioTracks()[0]); 2057 remote_stream->RemoveTrack(remote_stream->GetAudioTracks()[0]);
2059 2058
2060 rtc::scoped_ptr<SessionDescriptionInterface> local_answer( 2059 std::unique_ptr<SessionDescriptionInterface> local_answer(
2061 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer, 2060 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer,
2062 kSdpStringWithStream1, nullptr)); 2061 kSdpStringWithStream1, nullptr));
2063 cricket::ContentInfo* video_info = 2062 cricket::ContentInfo* video_info =
2064 local_answer->description()->GetContentByName("video"); 2063 local_answer->description()->GetContentByName("video");
2065 video_info->rejected = true; 2064 video_info->rejected = true;
2066 cricket::ContentInfo* audio_info = 2065 cricket::ContentInfo* audio_info =
2067 local_answer->description()->GetContentByName("audio"); 2066 local_answer->description()->GetContentByName("audio");
2068 audio_info->rejected = true; 2067 audio_info->rejected = true;
2069 EXPECT_TRUE(DoSetLocalDescription(local_answer.release())); 2068 EXPECT_TRUE(DoSetLocalDescription(local_answer.release()));
2070 2069
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2224 // after adding a local stream. 2223 // after adding a local stream.
2225 // TODO(deadbeef): This test and the one below it need to be updated when 2224 // TODO(deadbeef): This test and the one below it need to be updated when
2226 // an RtpSender's lifetime isn't determined by when a local description is set. 2225 // an RtpSender's lifetime isn't determined by when a local description is set.
2227 TEST_F(PeerConnectionInterfaceTest, LocalDescriptionChanged) { 2226 TEST_F(PeerConnectionInterfaceTest, LocalDescriptionChanged) {
2228 FakeConstraints constraints; 2227 FakeConstraints constraints;
2229 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 2228 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
2230 true); 2229 true);
2231 CreatePeerConnection(&constraints); 2230 CreatePeerConnection(&constraints);
2232 // Create an offer just to ensure we have an identity before we manually 2231 // Create an offer just to ensure we have an identity before we manually
2233 // call SetLocalDescription. 2232 // call SetLocalDescription.
2234 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; 2233 std::unique_ptr<SessionDescriptionInterface> throwaway;
2235 ASSERT_TRUE(DoCreateOffer(&throwaway, nullptr)); 2234 ASSERT_TRUE(DoCreateOffer(&throwaway, nullptr));
2236 2235
2237 rtc::scoped_ptr<SessionDescriptionInterface> desc_1 = 2236 std::unique_ptr<SessionDescriptionInterface> desc_1 =
2238 CreateSessionDescriptionAndReference(2, 2); 2237 CreateSessionDescriptionAndReference(2, 2);
2239 2238
2240 pc_->AddStream(reference_collection_->at(0)); 2239 pc_->AddStream(reference_collection_->at(0));
2241 EXPECT_TRUE(DoSetLocalDescription(desc_1.release())); 2240 EXPECT_TRUE(DoSetLocalDescription(desc_1.release()));
2242 auto senders = pc_->GetSenders(); 2241 auto senders = pc_->GetSenders();
2243 EXPECT_EQ(4u, senders.size()); 2242 EXPECT_EQ(4u, senders.size());
2244 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); 2243 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0]));
2245 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); 2244 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0]));
2246 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[1])); 2245 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[1]));
2247 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[1])); 2246 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[1]));
2248 2247
2249 // Remove an audio and video track. 2248 // Remove an audio and video track.
2250 pc_->RemoveStream(reference_collection_->at(0)); 2249 pc_->RemoveStream(reference_collection_->at(0));
2251 rtc::scoped_ptr<SessionDescriptionInterface> desc_2 = 2250 std::unique_ptr<SessionDescriptionInterface> desc_2 =
2252 CreateSessionDescriptionAndReference(1, 1); 2251 CreateSessionDescriptionAndReference(1, 1);
2253 pc_->AddStream(reference_collection_->at(0)); 2252 pc_->AddStream(reference_collection_->at(0));
2254 EXPECT_TRUE(DoSetLocalDescription(desc_2.release())); 2253 EXPECT_TRUE(DoSetLocalDescription(desc_2.release()));
2255 senders = pc_->GetSenders(); 2254 senders = pc_->GetSenders();
2256 EXPECT_EQ(2u, senders.size()); 2255 EXPECT_EQ(2u, senders.size());
2257 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); 2256 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0]));
2258 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); 2257 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0]));
2259 EXPECT_FALSE(ContainsSender(senders, kAudioTracks[1])); 2258 EXPECT_FALSE(ContainsSender(senders, kAudioTracks[1]));
2260 EXPECT_FALSE(ContainsSender(senders, kVideoTracks[1])); 2259 EXPECT_FALSE(ContainsSender(senders, kVideoTracks[1]));
2261 } 2260 }
2262 2261
2263 // This tests that an RtpSender is created when the local description is set 2262 // This tests that an RtpSender is created when the local description is set
2264 // before adding a local stream. 2263 // before adding a local stream.
2265 TEST_F(PeerConnectionInterfaceTest, 2264 TEST_F(PeerConnectionInterfaceTest,
2266 AddLocalStreamAfterLocalDescriptionChanged) { 2265 AddLocalStreamAfterLocalDescriptionChanged) {
2267 FakeConstraints constraints; 2266 FakeConstraints constraints;
2268 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 2267 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
2269 true); 2268 true);
2270 CreatePeerConnection(&constraints); 2269 CreatePeerConnection(&constraints);
2271 // Create an offer just to ensure we have an identity before we manually 2270 // Create an offer just to ensure we have an identity before we manually
2272 // call SetLocalDescription. 2271 // call SetLocalDescription.
2273 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; 2272 std::unique_ptr<SessionDescriptionInterface> throwaway;
2274 ASSERT_TRUE(DoCreateOffer(&throwaway, nullptr)); 2273 ASSERT_TRUE(DoCreateOffer(&throwaway, nullptr));
2275 2274
2276 rtc::scoped_ptr<SessionDescriptionInterface> desc_1 = 2275 std::unique_ptr<SessionDescriptionInterface> desc_1 =
2277 CreateSessionDescriptionAndReference(2, 2); 2276 CreateSessionDescriptionAndReference(2, 2);
2278 2277
2279 EXPECT_TRUE(DoSetLocalDescription(desc_1.release())); 2278 EXPECT_TRUE(DoSetLocalDescription(desc_1.release()));
2280 auto senders = pc_->GetSenders(); 2279 auto senders = pc_->GetSenders();
2281 EXPECT_EQ(0u, senders.size()); 2280 EXPECT_EQ(0u, senders.size());
2282 2281
2283 pc_->AddStream(reference_collection_->at(0)); 2282 pc_->AddStream(reference_collection_->at(0));
2284 senders = pc_->GetSenders(); 2283 senders = pc_->GetSenders();
2285 EXPECT_EQ(4u, senders.size()); 2284 EXPECT_EQ(4u, senders.size());
2286 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); 2285 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0]));
2287 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); 2286 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0]));
2288 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[1])); 2287 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[1]));
2289 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[1])); 2288 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[1]));
2290 } 2289 }
2291 2290
2292 // This tests that the expected behavior occurs if the SSRC on a local track is 2291 // This tests that the expected behavior occurs if the SSRC on a local track is
2293 // changed when SetLocalDescription is called. 2292 // changed when SetLocalDescription is called.
2294 TEST_F(PeerConnectionInterfaceTest, 2293 TEST_F(PeerConnectionInterfaceTest,
2295 ChangeSsrcOnTrackInLocalSessionDescription) { 2294 ChangeSsrcOnTrackInLocalSessionDescription) {
2296 FakeConstraints constraints; 2295 FakeConstraints constraints;
2297 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 2296 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
2298 true); 2297 true);
2299 CreatePeerConnection(&constraints); 2298 CreatePeerConnection(&constraints);
2300 // Create an offer just to ensure we have an identity before we manually 2299 // Create an offer just to ensure we have an identity before we manually
2301 // call SetLocalDescription. 2300 // call SetLocalDescription.
2302 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; 2301 std::unique_ptr<SessionDescriptionInterface> throwaway;
2303 ASSERT_TRUE(DoCreateOffer(&throwaway, nullptr)); 2302 ASSERT_TRUE(DoCreateOffer(&throwaway, nullptr));
2304 2303
2305 rtc::scoped_ptr<SessionDescriptionInterface> desc = 2304 std::unique_ptr<SessionDescriptionInterface> desc =
2306 CreateSessionDescriptionAndReference(1, 1); 2305 CreateSessionDescriptionAndReference(1, 1);
2307 std::string sdp; 2306 std::string sdp;
2308 desc->ToString(&sdp); 2307 desc->ToString(&sdp);
2309 2308
2310 pc_->AddStream(reference_collection_->at(0)); 2309 pc_->AddStream(reference_collection_->at(0));
2311 EXPECT_TRUE(DoSetLocalDescription(desc.release())); 2310 EXPECT_TRUE(DoSetLocalDescription(desc.release()));
2312 auto senders = pc_->GetSenders(); 2311 auto senders = pc_->GetSenders();
2313 EXPECT_EQ(2u, senders.size()); 2312 EXPECT_EQ(2u, senders.size());
2314 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); 2313 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0]));
2315 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); 2314 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0]));
2316 2315
2317 // Change the ssrc of the audio and video track. 2316 // Change the ssrc of the audio and video track.
2318 std::string ssrc_org = "a=ssrc:1"; 2317 std::string ssrc_org = "a=ssrc:1";
2319 std::string ssrc_to = "a=ssrc:97"; 2318 std::string ssrc_to = "a=ssrc:97";
2320 rtc::replace_substrs(ssrc_org.c_str(), ssrc_org.length(), ssrc_to.c_str(), 2319 rtc::replace_substrs(ssrc_org.c_str(), ssrc_org.length(), ssrc_to.c_str(),
2321 ssrc_to.length(), &sdp); 2320 ssrc_to.length(), &sdp);
2322 ssrc_org = "a=ssrc:2"; 2321 ssrc_org = "a=ssrc:2";
2323 ssrc_to = "a=ssrc:98"; 2322 ssrc_to = "a=ssrc:98";
2324 rtc::replace_substrs(ssrc_org.c_str(), ssrc_org.length(), ssrc_to.c_str(), 2323 rtc::replace_substrs(ssrc_org.c_str(), ssrc_org.length(), ssrc_to.c_str(),
2325 ssrc_to.length(), &sdp); 2324 ssrc_to.length(), &sdp);
2326 rtc::scoped_ptr<SessionDescriptionInterface> updated_desc( 2325 std::unique_ptr<SessionDescriptionInterface> updated_desc(
2327 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, sdp, 2326 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, sdp,
2328 nullptr)); 2327 nullptr));
2329 2328
2330 EXPECT_TRUE(DoSetLocalDescription(updated_desc.release())); 2329 EXPECT_TRUE(DoSetLocalDescription(updated_desc.release()));
2331 senders = pc_->GetSenders(); 2330 senders = pc_->GetSenders();
2332 EXPECT_EQ(2u, senders.size()); 2331 EXPECT_EQ(2u, senders.size());
2333 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); 2332 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0]));
2334 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); 2333 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0]));
2335 // TODO(deadbeef): Once RtpSenders expose parameters, check that the SSRC 2334 // TODO(deadbeef): Once RtpSenders expose parameters, check that the SSRC
2336 // changed. 2335 // changed.
2337 } 2336 }
2338 2337
2339 // This tests that the expected behavior occurs if a new session description is 2338 // This tests that the expected behavior occurs if a new session description is
2340 // set with the same tracks, but on a different MediaStream. 2339 // set with the same tracks, but on a different MediaStream.
2341 TEST_F(PeerConnectionInterfaceTest, 2340 TEST_F(PeerConnectionInterfaceTest,
2342 SignalSameTracksInSeparateMediaStream) { 2341 SignalSameTracksInSeparateMediaStream) {
2343 FakeConstraints constraints; 2342 FakeConstraints constraints;
2344 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 2343 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
2345 true); 2344 true);
2346 CreatePeerConnection(&constraints); 2345 CreatePeerConnection(&constraints);
2347 // Create an offer just to ensure we have an identity before we manually 2346 // Create an offer just to ensure we have an identity before we manually
2348 // call SetLocalDescription. 2347 // call SetLocalDescription.
2349 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; 2348 std::unique_ptr<SessionDescriptionInterface> throwaway;
2350 ASSERT_TRUE(DoCreateOffer(&throwaway, nullptr)); 2349 ASSERT_TRUE(DoCreateOffer(&throwaway, nullptr));
2351 2350
2352 rtc::scoped_ptr<SessionDescriptionInterface> desc = 2351 std::unique_ptr<SessionDescriptionInterface> desc =
2353 CreateSessionDescriptionAndReference(1, 1); 2352 CreateSessionDescriptionAndReference(1, 1);
2354 std::string sdp; 2353 std::string sdp;
2355 desc->ToString(&sdp); 2354 desc->ToString(&sdp);
2356 2355
2357 pc_->AddStream(reference_collection_->at(0)); 2356 pc_->AddStream(reference_collection_->at(0));
2358 EXPECT_TRUE(DoSetLocalDescription(desc.release())); 2357 EXPECT_TRUE(DoSetLocalDescription(desc.release()));
2359 auto senders = pc_->GetSenders(); 2358 auto senders = pc_->GetSenders();
2360 EXPECT_EQ(2u, senders.size()); 2359 EXPECT_EQ(2u, senders.size());
2361 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); 2360 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0]));
2362 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); 2361 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0]));
2363 2362
2364 // Add a new MediaStream but with the same tracks as in the first stream. 2363 // Add a new MediaStream but with the same tracks as in the first stream.
2365 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream_1( 2364 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream_1(
2366 webrtc::MediaStream::Create(kStreams[1])); 2365 webrtc::MediaStream::Create(kStreams[1]));
2367 stream_1->AddTrack(reference_collection_->at(0)->GetVideoTracks()[0]); 2366 stream_1->AddTrack(reference_collection_->at(0)->GetVideoTracks()[0]);
2368 stream_1->AddTrack(reference_collection_->at(0)->GetAudioTracks()[0]); 2367 stream_1->AddTrack(reference_collection_->at(0)->GetAudioTracks()[0]);
2369 pc_->AddStream(stream_1); 2368 pc_->AddStream(stream_1);
2370 2369
2371 // Replace msid in the original SDP. 2370 // Replace msid in the original SDP.
2372 rtc::replace_substrs(kStreams[0], strlen(kStreams[0]), kStreams[1], 2371 rtc::replace_substrs(kStreams[0], strlen(kStreams[0]), kStreams[1],
2373 strlen(kStreams[1]), &sdp); 2372 strlen(kStreams[1]), &sdp);
2374 2373
2375 rtc::scoped_ptr<SessionDescriptionInterface> updated_desc( 2374 std::unique_ptr<SessionDescriptionInterface> updated_desc(
2376 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, sdp, 2375 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, sdp,
2377 nullptr)); 2376 nullptr));
2378 2377
2379 EXPECT_TRUE(DoSetLocalDescription(updated_desc.release())); 2378 EXPECT_TRUE(DoSetLocalDescription(updated_desc.release()));
2380 senders = pc_->GetSenders(); 2379 senders = pc_->GetSenders();
2381 EXPECT_EQ(2u, senders.size()); 2380 EXPECT_EQ(2u, senders.size());
2382 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); 2381 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0]));
2383 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); 2382 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0]));
2384 } 2383 }
2385 2384
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
2662 FakeConstraints updated_answer_c; 2661 FakeConstraints updated_answer_c;
2663 answer_c.SetMandatoryReceiveAudio(false); 2662 answer_c.SetMandatoryReceiveAudio(false);
2664 answer_c.SetMandatoryReceiveVideo(false); 2663 answer_c.SetMandatoryReceiveVideo(false);
2665 2664
2666 cricket::MediaSessionOptions updated_answer_options; 2665 cricket::MediaSessionOptions updated_answer_options;
2667 EXPECT_TRUE( 2666 EXPECT_TRUE(
2668 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); 2667 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options));
2669 EXPECT_TRUE(updated_answer_options.has_audio()); 2668 EXPECT_TRUE(updated_answer_options.has_audio());
2670 EXPECT_TRUE(updated_answer_options.has_video()); 2669 EXPECT_TRUE(updated_answer_options.has_video());
2671 } 2670 }
OLDNEW
« no previous file with comments | « webrtc/api/peerconnectioninterface.h ('k') | webrtc/api/proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698