| OLD | NEW |
| 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 |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 void ReleasePeerConnection() { | 794 void ReleasePeerConnection() { |
| 795 pc_ = NULL; | 795 pc_ = NULL; |
| 796 observer_.SetPeerConnectionInterface(NULL); | 796 observer_.SetPeerConnectionInterface(NULL); |
| 797 } | 797 } |
| 798 | 798 |
| 799 void AddVideoStream(const std::string& label) { | 799 void AddVideoStream(const std::string& label) { |
| 800 // Create a local stream. | 800 // Create a local stream. |
| 801 rtc::scoped_refptr<MediaStreamInterface> stream( | 801 rtc::scoped_refptr<MediaStreamInterface> stream( |
| 802 pc_factory_->CreateLocalMediaStream(label)); | 802 pc_factory_->CreateLocalMediaStream(label)); |
| 803 rtc::scoped_refptr<VideoTrackSourceInterface> video_source( | 803 rtc::scoped_refptr<VideoTrackSourceInterface> video_source( |
| 804 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer(), NULL)); | 804 pc_factory_->CreateVideoSource(std::unique_ptr<cricket::VideoCapturer>( |
| 805 new cricket::FakeVideoCapturer()), |
| 806 NULL)); |
| 805 rtc::scoped_refptr<VideoTrackInterface> video_track( | 807 rtc::scoped_refptr<VideoTrackInterface> video_track( |
| 806 pc_factory_->CreateVideoTrack(label + "v0", video_source)); | 808 pc_factory_->CreateVideoTrack(label + "v0", video_source)); |
| 807 stream->AddTrack(video_track.get()); | 809 stream->AddTrack(video_track.get()); |
| 808 EXPECT_TRUE(pc_->AddStream(stream)); | 810 EXPECT_TRUE(pc_->AddStream(stream)); |
| 809 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); | 811 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); |
| 810 observer_.renegotiation_needed_ = false; | 812 observer_.renegotiation_needed_ = false; |
| 811 } | 813 } |
| 812 | 814 |
| 813 void AddVoiceStream(const std::string& label) { | 815 void AddVoiceStream(const std::string& label) { |
| 814 // Create a local stream. | 816 // Create a local stream. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 827 const std::string& video_track_label) { | 829 const std::string& video_track_label) { |
| 828 // Create a local stream. | 830 // Create a local stream. |
| 829 rtc::scoped_refptr<MediaStreamInterface> stream( | 831 rtc::scoped_refptr<MediaStreamInterface> stream( |
| 830 pc_factory_->CreateLocalMediaStream(stream_label)); | 832 pc_factory_->CreateLocalMediaStream(stream_label)); |
| 831 rtc::scoped_refptr<AudioTrackInterface> audio_track( | 833 rtc::scoped_refptr<AudioTrackInterface> audio_track( |
| 832 pc_factory_->CreateAudioTrack( | 834 pc_factory_->CreateAudioTrack( |
| 833 audio_track_label, static_cast<AudioSourceInterface*>(NULL))); | 835 audio_track_label, static_cast<AudioSourceInterface*>(NULL))); |
| 834 stream->AddTrack(audio_track.get()); | 836 stream->AddTrack(audio_track.get()); |
| 835 rtc::scoped_refptr<VideoTrackInterface> video_track( | 837 rtc::scoped_refptr<VideoTrackInterface> video_track( |
| 836 pc_factory_->CreateVideoTrack( | 838 pc_factory_->CreateVideoTrack( |
| 837 video_track_label, | 839 video_track_label, pc_factory_->CreateVideoSource( |
| 838 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer()))); | 840 std::unique_ptr<cricket::VideoCapturer>( |
| 841 new cricket::FakeVideoCapturer())))); |
| 839 stream->AddTrack(video_track.get()); | 842 stream->AddTrack(video_track.get()); |
| 840 EXPECT_TRUE(pc_->AddStream(stream)); | 843 EXPECT_TRUE(pc_->AddStream(stream)); |
| 841 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); | 844 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); |
| 842 observer_.renegotiation_needed_ = false; | 845 observer_.renegotiation_needed_ = false; |
| 843 } | 846 } |
| 844 | 847 |
| 845 bool DoCreateOfferAnswer(std::unique_ptr<SessionDescriptionInterface>* desc, | 848 bool DoCreateOfferAnswer(std::unique_ptr<SessionDescriptionInterface>* desc, |
| 846 bool offer, | 849 bool offer, |
| 847 MediaConstraintsInterface* constraints) { | 850 MediaConstraintsInterface* constraints) { |
| 848 rtc::scoped_refptr<MockCreateSessionDescriptionObserver> | 851 rtc::scoped_refptr<MockCreateSessionDescriptionObserver> |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1378 CreatePeerConnectionWithoutDtls(); | 1381 CreatePeerConnectionWithoutDtls(); |
| 1379 // Create a dummy stream, so tracks share a stream label. | 1382 // Create a dummy stream, so tracks share a stream label. |
| 1380 rtc::scoped_refptr<MediaStreamInterface> stream( | 1383 rtc::scoped_refptr<MediaStreamInterface> stream( |
| 1381 pc_factory_->CreateLocalMediaStream(kStreamLabel1)); | 1384 pc_factory_->CreateLocalMediaStream(kStreamLabel1)); |
| 1382 std::vector<MediaStreamInterface*> stream_list; | 1385 std::vector<MediaStreamInterface*> stream_list; |
| 1383 stream_list.push_back(stream.get()); | 1386 stream_list.push_back(stream.get()); |
| 1384 rtc::scoped_refptr<AudioTrackInterface> audio_track( | 1387 rtc::scoped_refptr<AudioTrackInterface> audio_track( |
| 1385 pc_factory_->CreateAudioTrack("audio_track", nullptr)); | 1388 pc_factory_->CreateAudioTrack("audio_track", nullptr)); |
| 1386 rtc::scoped_refptr<VideoTrackInterface> video_track( | 1389 rtc::scoped_refptr<VideoTrackInterface> video_track( |
| 1387 pc_factory_->CreateVideoTrack( | 1390 pc_factory_->CreateVideoTrack( |
| 1388 "video_track", | 1391 "video_track", pc_factory_->CreateVideoSource( |
| 1389 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer()))); | 1392 std::unique_ptr<cricket::VideoCapturer>( |
| 1393 new cricket::FakeVideoCapturer())))); |
| 1390 auto audio_sender = pc_->AddTrack(audio_track, stream_list); | 1394 auto audio_sender = pc_->AddTrack(audio_track, stream_list); |
| 1391 auto video_sender = pc_->AddTrack(video_track, stream_list); | 1395 auto video_sender = pc_->AddTrack(video_track, stream_list); |
| 1392 EXPECT_EQ(1UL, audio_sender->stream_ids().size()); | 1396 EXPECT_EQ(1UL, audio_sender->stream_ids().size()); |
| 1393 EXPECT_EQ(kStreamLabel1, audio_sender->stream_ids()[0]); | 1397 EXPECT_EQ(kStreamLabel1, audio_sender->stream_ids()[0]); |
| 1394 EXPECT_EQ("audio_track", audio_sender->id()); | 1398 EXPECT_EQ("audio_track", audio_sender->id()); |
| 1395 EXPECT_EQ(audio_track, audio_sender->track()); | 1399 EXPECT_EQ(audio_track, audio_sender->track()); |
| 1396 EXPECT_EQ(1UL, video_sender->stream_ids().size()); | 1400 EXPECT_EQ(1UL, video_sender->stream_ids().size()); |
| 1397 EXPECT_EQ(kStreamLabel1, video_sender->stream_ids()[0]); | 1401 EXPECT_EQ(kStreamLabel1, video_sender->stream_ids()[0]); |
| 1398 EXPECT_EQ("video_track", video_sender->id()); | 1402 EXPECT_EQ("video_track", video_sender->id()); |
| 1399 EXPECT_EQ(video_track, video_sender->track()); | 1403 EXPECT_EQ(video_track, video_sender->track()); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1449 | 1453 |
| 1450 // Test creating senders without a stream specified, | 1454 // Test creating senders without a stream specified, |
| 1451 // expecting a random stream ID to be generated. | 1455 // expecting a random stream ID to be generated. |
| 1452 TEST_F(PeerConnectionInterfaceTest, AddTrackWithoutStream) { | 1456 TEST_F(PeerConnectionInterfaceTest, AddTrackWithoutStream) { |
| 1453 CreatePeerConnectionWithoutDtls(); | 1457 CreatePeerConnectionWithoutDtls(); |
| 1454 // Create a dummy stream, so tracks share a stream label. | 1458 // Create a dummy stream, so tracks share a stream label. |
| 1455 rtc::scoped_refptr<AudioTrackInterface> audio_track( | 1459 rtc::scoped_refptr<AudioTrackInterface> audio_track( |
| 1456 pc_factory_->CreateAudioTrack("audio_track", nullptr)); | 1460 pc_factory_->CreateAudioTrack("audio_track", nullptr)); |
| 1457 rtc::scoped_refptr<VideoTrackInterface> video_track( | 1461 rtc::scoped_refptr<VideoTrackInterface> video_track( |
| 1458 pc_factory_->CreateVideoTrack( | 1462 pc_factory_->CreateVideoTrack( |
| 1459 "video_track", | 1463 "video_track", pc_factory_->CreateVideoSource( |
| 1460 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer()))); | 1464 std::unique_ptr<cricket::VideoCapturer>( |
| 1465 new cricket::FakeVideoCapturer())))); |
| 1461 auto audio_sender = | 1466 auto audio_sender = |
| 1462 pc_->AddTrack(audio_track, std::vector<MediaStreamInterface*>()); | 1467 pc_->AddTrack(audio_track, std::vector<MediaStreamInterface*>()); |
| 1463 auto video_sender = | 1468 auto video_sender = |
| 1464 pc_->AddTrack(video_track, std::vector<MediaStreamInterface*>()); | 1469 pc_->AddTrack(video_track, std::vector<MediaStreamInterface*>()); |
| 1465 EXPECT_EQ("audio_track", audio_sender->id()); | 1470 EXPECT_EQ("audio_track", audio_sender->id()); |
| 1466 EXPECT_EQ(audio_track, audio_sender->track()); | 1471 EXPECT_EQ(audio_track, audio_sender->track()); |
| 1467 EXPECT_EQ("video_track", video_sender->id()); | 1472 EXPECT_EQ("video_track", video_sender->id()); |
| 1468 EXPECT_EQ(video_track, video_sender->track()); | 1473 EXPECT_EQ(video_track, video_sender->track()); |
| 1469 // If the ID is truly a random GUID, it should be infinitely unlikely they | 1474 // If the ID is truly a random GUID, it should be infinitely unlikely they |
| 1470 // will be the same. | 1475 // will be the same. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 // TODO(deadbeef): Remove this test once this behavior is no longer supported. | 1616 // TODO(deadbeef): Remove this test once this behavior is no longer supported. |
| 1612 TEST_F(PeerConnectionInterfaceTest, AddTrackAfterAddStream) { | 1617 TEST_F(PeerConnectionInterfaceTest, AddTrackAfterAddStream) { |
| 1613 CreatePeerConnectionWithoutDtls(); | 1618 CreatePeerConnectionWithoutDtls(); |
| 1614 // Create audio stream and add to PeerConnection. | 1619 // Create audio stream and add to PeerConnection. |
| 1615 AddVoiceStream(kStreamLabel1); | 1620 AddVoiceStream(kStreamLabel1); |
| 1616 MediaStreamInterface* stream = pc_->local_streams()->at(0); | 1621 MediaStreamInterface* stream = pc_->local_streams()->at(0); |
| 1617 | 1622 |
| 1618 // Add video track to the audio-only stream. | 1623 // Add video track to the audio-only stream. |
| 1619 rtc::scoped_refptr<VideoTrackInterface> video_track( | 1624 rtc::scoped_refptr<VideoTrackInterface> video_track( |
| 1620 pc_factory_->CreateVideoTrack( | 1625 pc_factory_->CreateVideoTrack( |
| 1621 "video_label", | 1626 "video_label", pc_factory_->CreateVideoSource( |
| 1622 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer()))); | 1627 std::unique_ptr<cricket::VideoCapturer>( |
| 1628 new cricket::FakeVideoCapturer())))); |
| 1623 stream->AddTrack(video_track.get()); | 1629 stream->AddTrack(video_track.get()); |
| 1624 | 1630 |
| 1625 std::unique_ptr<SessionDescriptionInterface> offer; | 1631 std::unique_ptr<SessionDescriptionInterface> offer; |
| 1626 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); | 1632 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 1627 | 1633 |
| 1628 const cricket::MediaContentDescription* video_desc = | 1634 const cricket::MediaContentDescription* video_desc = |
| 1629 cricket::GetFirstVideoContentDescription(offer->description()); | 1635 cricket::GetFirstVideoContentDescription(offer->description()); |
| 1630 EXPECT_TRUE(video_desc != nullptr); | 1636 EXPECT_TRUE(video_desc != nullptr); |
| 1631 } | 1637 } |
| 1632 | 1638 |
| (...skipping 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3409 EXPECT_NE(a, f); | 3415 EXPECT_NE(a, f); |
| 3410 | 3416 |
| 3411 PeerConnectionInterface::RTCConfiguration g; | 3417 PeerConnectionInterface::RTCConfiguration g; |
| 3412 g.disable_ipv6 = true; | 3418 g.disable_ipv6 = true; |
| 3413 EXPECT_NE(a, g); | 3419 EXPECT_NE(a, g); |
| 3414 | 3420 |
| 3415 PeerConnectionInterface::RTCConfiguration h( | 3421 PeerConnectionInterface::RTCConfiguration h( |
| 3416 PeerConnectionInterface::RTCConfigurationType::kAggressive); | 3422 PeerConnectionInterface::RTCConfigurationType::kAggressive); |
| 3417 EXPECT_NE(a, h); | 3423 EXPECT_NE(a, h); |
| 3418 } | 3424 } |
| OLD | NEW |