| 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 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "webrtc/api/audiotrack.h" | 16 #include "webrtc/api/audiotrack.h" |
| 17 #include "webrtc/api/mediastream.h" | 17 #include "webrtc/api/mediastream.h" |
| 18 #include "webrtc/api/remoteaudiosource.h" | 18 #include "webrtc/api/remoteaudiosource.h" |
| 19 #include "webrtc/api/rtpreceiver.h" | 19 #include "webrtc/api/rtpreceiver.h" |
| 20 #include "webrtc/api/rtpsender.h" | 20 #include "webrtc/api/rtpsender.h" |
| 21 #include "webrtc/api/streamcollection.h" | 21 #include "webrtc/api/streamcollection.h" |
| 22 #include "webrtc/api/videosource.h" | 22 #include "webrtc/api/videocapturertracksource.h" |
| 23 #include "webrtc/api/videotrack.h" | 23 #include "webrtc/api/videotrack.h" |
| 24 #include "webrtc/base/gunit.h" | 24 #include "webrtc/base/gunit.h" |
| 25 #include "webrtc/media/base/fakevideocapturer.h" | 25 #include "webrtc/media/base/fakevideocapturer.h" |
| 26 #include "webrtc/media/base/mediachannel.h" | 26 #include "webrtc/media/base/mediachannel.h" |
| 27 | 27 |
| 28 using ::testing::_; | 28 using ::testing::_; |
| 29 using ::testing::Exactly; | 29 using ::testing::Exactly; |
| 30 | 30 |
| 31 static const char kStreamLabel1[] = "local_stream_1"; | 31 static const char kStreamLabel1[] = "local_stream_1"; |
| 32 static const char kVideoTrackId[] = "video_1"; | 32 static const char kVideoTrackId[] = "video_1"; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 MOCK_METHOD3(SetVideoPlayout, | 71 MOCK_METHOD3(SetVideoPlayout, |
| 72 void(uint32_t ssrc, | 72 void(uint32_t ssrc, |
| 73 bool enable, | 73 bool enable, |
| 74 rtc::VideoSinkInterface<cricket::VideoFrame>* sink)); | 74 rtc::VideoSinkInterface<cricket::VideoFrame>* sink)); |
| 75 MOCK_METHOD3(SetVideoSend, | 75 MOCK_METHOD3(SetVideoSend, |
| 76 void(uint32_t ssrc, | 76 void(uint32_t ssrc, |
| 77 bool enable, | 77 bool enable, |
| 78 const cricket::VideoOptions* options)); | 78 const cricket::VideoOptions* options)); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 class FakeVideoSource : public Notifier<VideoSourceInterface> { | 81 class FakeVideoSource : public Notifier<VideoTrackSourceInterface> { |
| 82 public: | 82 public: |
| 83 static rtc::scoped_refptr<FakeVideoSource> Create(bool remote) { | 83 static rtc::scoped_refptr<FakeVideoSource> Create(bool remote) { |
| 84 return new rtc::RefCountedObject<FakeVideoSource>(remote); | 84 return new rtc::RefCountedObject<FakeVideoSource>(remote); |
| 85 } | 85 } |
| 86 cricket::VideoCapturer* GetVideoCapturer() { return &fake_capturer_; } | 86 cricket::VideoCapturer* GetVideoCapturer() { return &fake_capturer_; } |
| 87 void Stop() override {} | 87 void Stop() override {} |
| 88 void Restart() override {} | 88 void Restart() override {} |
| 89 void AddOrUpdateSink( | 89 void AddOrUpdateSink( |
| 90 rtc::VideoSinkInterface<cricket::VideoFrame>* sink, | 90 rtc::VideoSinkInterface<cricket::VideoFrame>* sink, |
| 91 const rtc::VideoSinkWants& wants) override {} | 91 const rtc::VideoSinkWants& wants) override {} |
| (...skipping 14 matching lines...) Expand all Loading... |
| 106 cricket::VideoOptions options_; | 106 cricket::VideoOptions options_; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 class RtpSenderReceiverTest : public testing::Test { | 109 class RtpSenderReceiverTest : public testing::Test { |
| 110 public: | 110 public: |
| 111 virtual void SetUp() { | 111 virtual void SetUp() { |
| 112 stream_ = MediaStream::Create(kStreamLabel1); | 112 stream_ = MediaStream::Create(kStreamLabel1); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void AddVideoTrack(bool remote) { | 115 void AddVideoTrack(bool remote) { |
| 116 rtc::scoped_refptr<VideoSourceInterface> source( | 116 rtc::scoped_refptr<VideoTrackSourceInterface> source( |
| 117 FakeVideoSource::Create(remote)); | 117 FakeVideoSource::Create(remote)); |
| 118 video_track_ = VideoTrack::Create(kVideoTrackId, source); | 118 video_track_ = VideoTrack::Create(kVideoTrackId, source); |
| 119 EXPECT_TRUE(stream_->AddTrack(video_track_)); | 119 EXPECT_TRUE(stream_->AddTrack(video_track_)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void CreateAudioRtpSender() { | 122 void CreateAudioRtpSender() { |
| 123 audio_track_ = AudioTrack::Create(kAudioTrackId, NULL); | 123 audio_track_ = AudioTrack::Create(kAudioTrackId, NULL); |
| 124 EXPECT_TRUE(stream_->AddTrack(audio_track_)); | 124 EXPECT_TRUE(stream_->AddTrack(audio_track_)); |
| 125 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _)); | 125 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _)); |
| 126 audio_rtp_sender_ = | 126 audio_rtp_sender_ = |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 video_track_->GetSource()->GetVideoCapturer())); | 490 video_track_->GetSource()->GetVideoCapturer())); |
| 491 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, true, _)); | 491 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, true, _)); |
| 492 sender->SetSsrc(kVideoSsrc2); | 492 sender->SetSsrc(kVideoSsrc2); |
| 493 | 493 |
| 494 // Calls expected from destructor. | 494 // Calls expected from destructor. |
| 495 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc2, nullptr)).Times(1); | 495 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc2, nullptr)).Times(1); |
| 496 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, false, _)).Times(1); | 496 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, false, _)).Times(1); |
| 497 } | 497 } |
| 498 | 498 |
| 499 } // namespace webrtc | 499 } // namespace webrtc |
| OLD | NEW |