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/videocapturertracksource.h" | 22 #include "webrtc/api/videotracksource.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<VideoTrackSourceInterface> { | 81 class FakeVideoTrackSource : public VideoTrackSource { |
82 public: | 82 public: |
83 static rtc::scoped_refptr<FakeVideoSource> Create(bool remote) { | 83 static rtc::scoped_refptr<FakeVideoTrackSource> Create(bool remote) { |
84 return new rtc::RefCountedObject<FakeVideoSource>(remote); | 84 return new rtc::RefCountedObject<FakeVideoTrackSource>(remote); |
85 } | 85 } |
86 cricket::VideoCapturer* GetVideoCapturer() { return &fake_capturer_; } | 86 cricket::VideoCapturer* GetVideoCapturer() { return &fake_capturer_; } |
87 void Stop() override {} | |
88 void Restart() override {} | |
89 void AddOrUpdateSink( | |
90 rtc::VideoSinkInterface<cricket::VideoFrame>* sink, | |
91 const rtc::VideoSinkWants& wants) override {} | |
92 void RemoveSink( | |
93 rtc::VideoSinkInterface<cricket::VideoFrame>* output) override {} | |
94 SourceState state() const override { return state_; } | |
95 bool remote() const override { return remote_; } | |
96 const cricket::VideoOptions* options() const override { return &options_; } | |
97 | 87 |
98 protected: | 88 protected: |
99 explicit FakeVideoSource(bool remote) : state_(kLive), remote_(remote) {} | 89 explicit FakeVideoTrackSource(bool remote) |
100 ~FakeVideoSource() {} | 90 : VideoTrackSource(&fake_capturer_, rtc::Thread::Current(), remote) {} |
| 91 ~FakeVideoTrackSource() {} |
101 | 92 |
102 private: | 93 private: |
103 cricket::FakeVideoCapturer fake_capturer_; | 94 cricket::FakeVideoCapturer fake_capturer_; |
104 SourceState state_; | |
105 bool remote_; | |
106 cricket::VideoOptions options_; | |
107 }; | 95 }; |
108 | 96 |
109 class RtpSenderReceiverTest : public testing::Test { | 97 class RtpSenderReceiverTest : public testing::Test { |
110 public: | 98 public: |
111 virtual void SetUp() { | 99 virtual void SetUp() { |
112 stream_ = MediaStream::Create(kStreamLabel1); | 100 stream_ = MediaStream::Create(kStreamLabel1); |
113 } | 101 } |
114 | 102 |
115 void AddVideoTrack(bool remote) { | 103 void AddVideoTrack(bool remote) { |
116 rtc::scoped_refptr<VideoTrackSourceInterface> source( | 104 rtc::scoped_refptr<VideoTrackSourceInterface> source( |
117 FakeVideoSource::Create(remote)); | 105 FakeVideoTrackSource::Create(remote)); |
118 video_track_ = VideoTrack::Create(kVideoTrackId, source); | 106 video_track_ = VideoTrack::Create(kVideoTrackId, source); |
119 EXPECT_TRUE(stream_->AddTrack(video_track_)); | 107 EXPECT_TRUE(stream_->AddTrack(video_track_)); |
120 } | 108 } |
121 | 109 |
122 void CreateAudioRtpSender() { | 110 void CreateAudioRtpSender() { |
123 audio_track_ = AudioTrack::Create(kAudioTrackId, NULL); | 111 audio_track_ = AudioTrack::Create(kAudioTrackId, NULL); |
124 EXPECT_TRUE(stream_->AddTrack(audio_track_)); | 112 EXPECT_TRUE(stream_->AddTrack(audio_track_)); |
125 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _)); | 113 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _)); |
126 audio_rtp_sender_ = | 114 audio_rtp_sender_ = |
127 new AudioRtpSender(stream_->GetAudioTracks()[0], stream_->label(), | 115 new AudioRtpSender(stream_->GetAudioTracks()[0], stream_->label(), |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 video_track_->GetSource()->GetVideoCapturer())); | 478 video_track_->GetSource()->GetVideoCapturer())); |
491 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, true, _)); | 479 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, true, _)); |
492 sender->SetSsrc(kVideoSsrc2); | 480 sender->SetSsrc(kVideoSsrc2); |
493 | 481 |
494 // Calls expected from destructor. | 482 // Calls expected from destructor. |
495 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc2, nullptr)).Times(1); | 483 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc2, nullptr)).Times(1); |
496 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, false, _)).Times(1); | 484 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, false, _)).Times(1); |
497 } | 485 } |
498 | 486 |
499 } // namespace webrtc | 487 } // namespace webrtc |
OLD | NEW |