OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
11 * this list of conditions and the following disclaimer in the documentation | 11 * this list of conditions and the following disclaimer in the documentation |
12 * and/or other materials provided with the distribution. | 12 * and/or other materials provided with the distribution. |
13 * 3. The name of the author may not be used to endorse or promote products | 13 * 3. The name of the author may not be used to endorse or promote products |
14 * derived from this software without specific prior written permission. | 14 * derived from this software without specific prior written permission. |
15 * | 15 * |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include "talk/app/webrtc/mediastreamhandler.h" | |
29 | |
30 #include <string> | 28 #include <string> |
31 | 29 |
32 #include "talk/app/webrtc/audiotrack.h" | 30 #include "talk/app/webrtc/audiotrack.h" |
33 #include "talk/app/webrtc/mediastream.h" | 31 #include "talk/app/webrtc/mediastream.h" |
34 #include "talk/app/webrtc/remoteaudiosource.h" | 32 #include "talk/app/webrtc/remoteaudiosource.h" |
| 33 #include "talk/app/webrtc/rtpreceiver.h" |
| 34 #include "talk/app/webrtc/rtpsender.h" |
35 #include "talk/app/webrtc/streamcollection.h" | 35 #include "talk/app/webrtc/streamcollection.h" |
36 #include "talk/app/webrtc/videosource.h" | 36 #include "talk/app/webrtc/videosource.h" |
37 #include "talk/app/webrtc/videotrack.h" | 37 #include "talk/app/webrtc/videotrack.h" |
38 #include "talk/media/base/fakevideocapturer.h" | 38 #include "talk/media/base/fakevideocapturer.h" |
39 #include "talk/media/base/mediachannel.h" | 39 #include "talk/media/base/mediachannel.h" |
40 #include "testing/gmock/include/gmock/gmock.h" | 40 #include "testing/gmock/include/gmock/gmock.h" |
41 #include "testing/gtest/include/gtest/gtest.h" | 41 #include "testing/gtest/include/gtest/gtest.h" |
42 #include "webrtc/base/gunit.h" | 42 #include "webrtc/base/gunit.h" |
43 | 43 |
44 using ::testing::_; | 44 using ::testing::_; |
45 using ::testing::Exactly; | 45 using ::testing::Exactly; |
46 | 46 |
47 static const char kStreamLabel1[] = "local_stream_1"; | 47 static const char kStreamLabel1[] = "local_stream_1"; |
48 static const char kVideoTrackId[] = "video_1"; | 48 static const char kVideoTrackId[] = "video_1"; |
49 static const char kAudioTrackId[] = "audio_1"; | 49 static const char kAudioTrackId[] = "audio_1"; |
| 50 static const char kVideoMid[] = "video"; |
| 51 static const char kAudioMid[] = "audio"; |
50 static const uint32 kVideoSsrc = 98; | 52 static const uint32 kVideoSsrc = 98; |
51 static const uint32 kAudioSsrc = 99; | 53 static const uint32 kAudioSsrc = 99; |
52 | 54 |
53 namespace webrtc { | 55 namespace webrtc { |
54 | 56 |
55 // Helper class to test MediaStreamHandler. | 57 // Helper class to test RtpSender/RtpReceiver. |
56 class MockAudioProvider : public AudioProviderInterface { | 58 class MockAudioProvider : public AudioProviderInterface { |
57 public: | 59 public: |
58 virtual ~MockAudioProvider() {} | 60 virtual ~MockAudioProvider() {} |
59 MOCK_METHOD3(SetAudioPlayout, void(uint32 ssrc, bool enable, | 61 MOCK_METHOD3(SetAudioPlayout, |
60 cricket::AudioRenderer* renderer)); | 62 void(uint32 ssrc, |
61 MOCK_METHOD4(SetAudioSend, void(uint32 ssrc, bool enable, | 63 bool enable, |
62 const cricket::AudioOptions& options, | 64 cricket::AudioRenderer* renderer)); |
63 cricket::AudioRenderer* renderer)); | 65 MOCK_METHOD4(SetAudioSend, |
| 66 void(uint32 ssrc, |
| 67 bool enable, |
| 68 const cricket::AudioOptions& options, |
| 69 cricket::AudioRenderer* renderer)); |
64 MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32 ssrc, double volume)); | 70 MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32 ssrc, double volume)); |
65 }; | 71 }; |
66 | 72 |
67 // Helper class to test MediaStreamHandler. | 73 // Helper class to test RtpSender/RtpReceiver. |
68 class MockVideoProvider : public VideoProviderInterface { | 74 class MockVideoProvider : public VideoProviderInterface { |
69 public: | 75 public: |
70 virtual ~MockVideoProvider() {} | 76 virtual ~MockVideoProvider() {} |
71 MOCK_METHOD2(SetCaptureDevice, bool(uint32 ssrc, | 77 MOCK_METHOD2(SetCaptureDevice, |
72 cricket::VideoCapturer* camera)); | 78 bool(uint32 ssrc, cricket::VideoCapturer* camera)); |
73 MOCK_METHOD3(SetVideoPlayout, void(uint32 ssrc, | 79 MOCK_METHOD3(SetVideoPlayout, |
74 bool enable, | 80 void(uint32 ssrc, |
75 cricket::VideoRenderer* renderer)); | 81 bool enable, |
76 MOCK_METHOD3(SetVideoSend, void(uint32 ssrc, bool enable, | 82 cricket::VideoRenderer* renderer)); |
77 const cricket::VideoOptions* options)); | 83 MOCK_METHOD3(SetVideoSend, |
| 84 void(uint32 ssrc, |
| 85 bool enable, |
| 86 const cricket::VideoOptions* options)); |
78 }; | 87 }; |
79 | 88 |
80 class FakeVideoSource : public Notifier<VideoSourceInterface> { | 89 class FakeVideoSource : public Notifier<VideoSourceInterface> { |
81 public: | 90 public: |
82 static rtc::scoped_refptr<FakeVideoSource> Create() { | 91 static rtc::scoped_refptr<FakeVideoSource> Create() { |
83 return new rtc::RefCountedObject<FakeVideoSource>(); | 92 return new rtc::RefCountedObject<FakeVideoSource>(); |
84 } | 93 } |
85 virtual cricket::VideoCapturer* GetVideoCapturer() { | 94 virtual cricket::VideoCapturer* GetVideoCapturer() { return &fake_capturer_; } |
86 return &fake_capturer_; | |
87 } | |
88 virtual void Stop() {} | 95 virtual void Stop() {} |
89 virtual void Restart() {} | 96 virtual void Restart() {} |
90 virtual void AddSink(cricket::VideoRenderer* output) {} | 97 virtual void AddSink(cricket::VideoRenderer* output) {} |
91 virtual void RemoveSink(cricket::VideoRenderer* output) {} | 98 virtual void RemoveSink(cricket::VideoRenderer* output) {} |
92 virtual SourceState state() const { return state_; } | 99 virtual SourceState state() const { return state_; } |
93 virtual const cricket::VideoOptions* options() const { return &options_; } | 100 virtual const cricket::VideoOptions* options() const { return &options_; } |
94 virtual cricket::VideoRenderer* FrameInput() { return NULL; } | 101 virtual cricket::VideoRenderer* FrameInput() { return NULL; } |
95 | 102 |
96 protected: | 103 protected: |
97 FakeVideoSource() : state_(kLive) {} | 104 FakeVideoSource() : state_(kLive) {} |
98 ~FakeVideoSource() {} | 105 ~FakeVideoSource() {} |
99 | 106 |
100 private: | 107 private: |
101 cricket::FakeVideoCapturer fake_capturer_; | 108 cricket::FakeVideoCapturer fake_capturer_; |
102 SourceState state_; | 109 SourceState state_; |
103 cricket::VideoOptions options_; | 110 cricket::VideoOptions options_; |
104 }; | 111 }; |
105 | 112 |
106 class MediaStreamHandlerTest : public testing::Test { | 113 class RtpSenderReceiverTest : public testing::Test { |
107 public: | 114 public: |
108 MediaStreamHandlerTest() | |
109 : handlers_(&audio_provider_, &video_provider_) { | |
110 } | |
111 | |
112 virtual void SetUp() { | 115 virtual void SetUp() { |
113 stream_ = MediaStream::Create(kStreamLabel1); | 116 stream_ = MediaStream::Create(kStreamLabel1); |
114 rtc::scoped_refptr<VideoSourceInterface> source( | 117 rtc::scoped_refptr<VideoSourceInterface> source(FakeVideoSource::Create()); |
115 FakeVideoSource::Create()); | |
116 video_track_ = VideoTrack::Create(kVideoTrackId, source); | 118 video_track_ = VideoTrack::Create(kVideoTrackId, source); |
117 EXPECT_TRUE(stream_->AddTrack(video_track_)); | 119 EXPECT_TRUE(stream_->AddTrack(video_track_)); |
118 } | 120 } |
119 | 121 |
120 void AddLocalAudioTrack() { | 122 void CreateAudioRtpSender() { |
121 audio_track_ = AudioTrack::Create(kAudioTrackId, NULL); | 123 audio_track_ = AudioTrack::Create(kAudioTrackId, NULL); |
122 EXPECT_TRUE(stream_->AddTrack(audio_track_)); | 124 EXPECT_TRUE(stream_->AddTrack(audio_track_)); |
123 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _)); | 125 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _)); |
124 handlers_.AddLocalAudioTrack(stream_, stream_->GetAudioTracks()[0], | 126 audio_rtp_sender_ = new rtc::RefCountedObject<AudioRtpSender>( |
125 kAudioSsrc); | 127 stream_->GetAudioTracks()[0], kAudioSsrc, kAudioMid, &audio_provider_); |
126 } | 128 } |
127 | 129 |
128 void AddLocalVideoTrack() { | 130 void CreateVideoRtpSender() { |
129 EXPECT_CALL(video_provider_, SetCaptureDevice( | 131 EXPECT_CALL(video_provider_, |
130 kVideoSsrc, video_track_->GetSource()->GetVideoCapturer())); | 132 SetCaptureDevice( |
| 133 kVideoSsrc, video_track_->GetSource()->GetVideoCapturer())); |
131 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _)); | 134 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _)); |
132 handlers_.AddLocalVideoTrack(stream_, stream_->GetVideoTracks()[0], | 135 video_rtp_sender_ = new rtc::RefCountedObject<VideoRtpSender>( |
133 kVideoSsrc); | 136 stream_->GetVideoTracks()[0], kVideoSsrc, kVideoMid, &video_provider_); |
134 } | 137 } |
135 | 138 |
136 void RemoveLocalAudioTrack() { | 139 void DestroyAudioRtpSender() { |
137 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _)) | 140 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _)) |
138 .Times(1); | 141 .Times(1); |
139 handlers_.RemoveLocalTrack(stream_, audio_track_); | 142 audio_rtp_sender_ = nullptr; |
140 } | 143 } |
141 | 144 |
142 void RemoveLocalVideoTrack() { | 145 void DestroyVideoRtpSender() { |
143 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, NULL)) | 146 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, NULL)).Times(1); |
144 .Times(1); | 147 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1); |
145 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)) | 148 video_rtp_sender_ = nullptr; |
146 .Times(1); | |
147 handlers_.RemoveLocalTrack(stream_, video_track_); | |
148 } | 149 } |
149 | 150 |
150 void AddRemoteAudioTrack() { | 151 void CreateAudioRtpReceiver() { |
151 audio_track_ = AudioTrack::Create(kAudioTrackId, | 152 audio_track_ = |
152 RemoteAudioSource::Create().get()); | 153 AudioTrack::Create(kAudioTrackId, RemoteAudioSource::Create().get()); |
153 EXPECT_TRUE(stream_->AddTrack(audio_track_)); | 154 EXPECT_TRUE(stream_->AddTrack(audio_track_)); |
154 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); | 155 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); |
155 handlers_.AddRemoteAudioTrack(stream_, stream_->GetAudioTracks()[0], | 156 audio_rtp_receiver_ = new rtc::RefCountedObject<AudioRtpReceiver>( |
156 kAudioSsrc); | 157 stream_->GetAudioTracks()[0], kAudioSsrc, kAudioMid, &audio_provider_); |
157 } | 158 } |
158 | 159 |
159 void AddRemoteVideoTrack() { | 160 void CreateVideoRtpReceiver() { |
160 EXPECT_CALL(video_provider_, SetVideoPlayout( | 161 EXPECT_CALL(video_provider_, |
161 kVideoSsrc, true, video_track_->GetSource()->FrameInput())); | 162 SetVideoPlayout(kVideoSsrc, true, |
162 handlers_.AddRemoteVideoTrack(stream_, stream_->GetVideoTracks()[0], | 163 video_track_->GetSource()->FrameInput())); |
163 kVideoSsrc); | 164 video_rtp_receiver_ = new rtc::RefCountedObject<VideoRtpReceiver>( |
| 165 stream_->GetVideoTracks()[0], kVideoSsrc, kVideoMid, &video_provider_); |
164 } | 166 } |
165 | 167 |
166 void RemoveRemoteAudioTrack() { | 168 void DestroyAudioRtpReceiver() { |
167 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); | 169 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); |
168 handlers_.RemoveRemoteTrack(stream_, stream_->GetAudioTracks()[0]); | 170 audio_rtp_receiver_ = nullptr; |
169 } | 171 } |
170 | 172 |
171 void RemoveRemoteVideoTrack() { | 173 void DestroyVideoRtpReceiver() { |
172 EXPECT_CALL(video_provider_, SetVideoPlayout(kVideoSsrc, false, NULL)); | 174 EXPECT_CALL(video_provider_, SetVideoPlayout(kVideoSsrc, false, NULL)); |
173 handlers_.RemoveRemoteTrack(stream_, stream_->GetVideoTracks()[0]); | 175 video_rtp_receiver_ = nullptr; |
174 } | 176 } |
175 | 177 |
176 protected: | 178 protected: |
177 MockAudioProvider audio_provider_; | 179 MockAudioProvider audio_provider_; |
178 MockVideoProvider video_provider_; | 180 MockVideoProvider video_provider_; |
179 MediaStreamHandlerContainer handlers_; | 181 rtc::scoped_refptr<AudioRtpSender> audio_rtp_sender_; |
| 182 rtc::scoped_refptr<VideoRtpSender> video_rtp_sender_; |
| 183 rtc::scoped_refptr<AudioRtpReceiver> audio_rtp_receiver_; |
| 184 rtc::scoped_refptr<VideoRtpReceiver> video_rtp_receiver_; |
180 rtc::scoped_refptr<MediaStreamInterface> stream_; | 185 rtc::scoped_refptr<MediaStreamInterface> stream_; |
181 rtc::scoped_refptr<VideoTrackInterface> video_track_; | 186 rtc::scoped_refptr<VideoTrackInterface> video_track_; |
182 rtc::scoped_refptr<AudioTrackInterface> audio_track_; | 187 rtc::scoped_refptr<AudioTrackInterface> audio_track_; |
183 }; | 188 }; |
184 | 189 |
185 // Test that |audio_provider_| is notified when an audio track is associated | 190 // Test that |audio_provider_| is notified when an audio track is associated |
186 // and disassociated with a MediaStreamHandler. | 191 // and disassociated with an AudioRtpSender. |
187 TEST_F(MediaStreamHandlerTest, AddAndRemoveLocalAudioTrack) { | 192 TEST_F(RtpSenderReceiverTest, AddAndDestroyAudioRtpSender) { |
188 AddLocalAudioTrack(); | 193 CreateAudioRtpSender(); |
189 RemoveLocalAudioTrack(); | 194 DestroyAudioRtpSender(); |
190 | |
191 handlers_.RemoveLocalStream(stream_); | |
192 } | 195 } |
193 | 196 |
194 // Test that |video_provider_| is notified when a video track is associated and | 197 // Test that |video_provider_| is notified when a video track is associated and |
195 // disassociated with a MediaStreamHandler. | 198 // disassociated with a VideoRtpSender. |
196 TEST_F(MediaStreamHandlerTest, AddAndRemoveLocalVideoTrack) { | 199 TEST_F(RtpSenderReceiverTest, AddAndDestroyVideoRtpSender) { |
197 AddLocalVideoTrack(); | 200 CreateVideoRtpSender(); |
198 RemoveLocalVideoTrack(); | 201 DestroyVideoRtpSender(); |
199 | |
200 handlers_.RemoveLocalStream(stream_); | |
201 } | 202 } |
202 | 203 |
203 // Test that |video_provider_| and |audio_provider_| is notified when an audio | |
204 // and video track is disassociated with a MediaStreamHandler by calling | |
205 // RemoveLocalStream. | |
206 TEST_F(MediaStreamHandlerTest, RemoveLocalStream) { | |
207 AddLocalAudioTrack(); | |
208 AddLocalVideoTrack(); | |
209 | |
210 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, NULL)) | |
211 .Times(1); | |
212 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)) | |
213 .Times(1); | |
214 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _)) | |
215 .Times(1); | |
216 handlers_.RemoveLocalStream(stream_); | |
217 } | |
218 | |
219 | |
220 // Test that |audio_provider_| is notified when a remote audio and track is | 204 // Test that |audio_provider_| is notified when a remote audio and track is |
221 // associated and disassociated with a MediaStreamHandler. | 205 // associated and disassociated with an AudioRtpReceiver. |
222 TEST_F(MediaStreamHandlerTest, AddAndRemoveRemoteAudioTrack) { | 206 TEST_F(RtpSenderReceiverTest, AddAndDestroyAudioRtpReceiver) { |
223 AddRemoteAudioTrack(); | 207 CreateAudioRtpReceiver(); |
224 RemoveRemoteAudioTrack(); | 208 DestroyAudioRtpReceiver(); |
225 | |
226 handlers_.RemoveRemoteStream(stream_); | |
227 } | 209 } |
228 | 210 |
229 // Test that |video_provider_| is notified when a remote | 211 // Test that |video_provider_| is notified when a remote |
230 // video track is associated and disassociated with a MediaStreamHandler. | 212 // video track is associated and disassociated with a VideoRtpReceiver. |
231 TEST_F(MediaStreamHandlerTest, AddAndRemoveRemoteVideoTrack) { | 213 TEST_F(RtpSenderReceiverTest, AddAndDestroyVideoRtpReceiver) { |
232 AddRemoteVideoTrack(); | 214 CreateVideoRtpReceiver(); |
233 RemoveRemoteVideoTrack(); | 215 DestroyVideoRtpReceiver(); |
234 | |
235 handlers_.RemoveRemoteStream(stream_); | |
236 } | 216 } |
237 | 217 |
238 // Test that |audio_provider_| and |video_provider_| is notified when an audio | 218 TEST_F(RtpSenderReceiverTest, LocalAudioTrackDisable) { |
239 // and video track is disassociated with a MediaStreamHandler by calling | 219 CreateAudioRtpSender(); |
240 // RemoveRemoveStream. | |
241 TEST_F(MediaStreamHandlerTest, RemoveRemoteStream) { | |
242 AddRemoteAudioTrack(); | |
243 AddRemoteVideoTrack(); | |
244 | |
245 EXPECT_CALL(video_provider_, SetVideoPlayout(kVideoSsrc, false, NULL)) | |
246 .Times(1); | |
247 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)) | |
248 .Times(1); | |
249 handlers_.RemoveRemoteStream(stream_); | |
250 } | |
251 | |
252 TEST_F(MediaStreamHandlerTest, LocalAudioTrackDisable) { | |
253 AddLocalAudioTrack(); | |
254 | 220 |
255 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _)); | 221 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _)); |
256 audio_track_->set_enabled(false); | 222 audio_track_->set_enabled(false); |
257 | 223 |
258 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _)); | 224 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _)); |
259 audio_track_->set_enabled(true); | 225 audio_track_->set_enabled(true); |
260 | 226 |
261 RemoveLocalAudioTrack(); | 227 DestroyAudioRtpSender(); |
262 handlers_.TearDown(); | |
263 } | 228 } |
264 | 229 |
265 TEST_F(MediaStreamHandlerTest, RemoteAudioTrackDisable) { | 230 TEST_F(RtpSenderReceiverTest, RemoteAudioTrackDisable) { |
266 AddRemoteAudioTrack(); | 231 CreateAudioRtpReceiver(); |
267 | 232 |
268 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); | 233 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); |
269 audio_track_->set_enabled(false); | 234 audio_track_->set_enabled(false); |
270 | 235 |
271 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); | 236 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); |
272 audio_track_->set_enabled(true); | 237 audio_track_->set_enabled(true); |
273 | 238 |
274 RemoveRemoteAudioTrack(); | 239 DestroyAudioRtpReceiver(); |
275 handlers_.TearDown(); | |
276 } | 240 } |
277 | 241 |
278 TEST_F(MediaStreamHandlerTest, LocalVideoTrackDisable) { | 242 TEST_F(RtpSenderReceiverTest, LocalVideoTrackDisable) { |
279 AddLocalVideoTrack(); | 243 CreateVideoRtpSender(); |
280 | 244 |
281 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)); | 245 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)); |
282 video_track_->set_enabled(false); | 246 video_track_->set_enabled(false); |
283 | 247 |
284 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _)); | 248 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _)); |
285 video_track_->set_enabled(true); | 249 video_track_->set_enabled(true); |
286 | 250 |
287 RemoveLocalVideoTrack(); | 251 DestroyVideoRtpSender(); |
288 handlers_.TearDown(); | |
289 } | 252 } |
290 | 253 |
291 TEST_F(MediaStreamHandlerTest, RemoteVideoTrackDisable) { | 254 TEST_F(RtpSenderReceiverTest, RemoteVideoTrackDisable) { |
292 AddRemoteVideoTrack(); | 255 CreateVideoRtpReceiver(); |
293 | 256 |
294 video_track_->set_enabled(false); | 257 video_track_->set_enabled(false); |
295 | 258 |
296 video_track_->set_enabled(true); | 259 video_track_->set_enabled(true); |
297 | 260 |
298 RemoveRemoteVideoTrack(); | 261 DestroyVideoRtpReceiver(); |
299 handlers_.TearDown(); | |
300 } | 262 } |
301 | 263 |
302 TEST_F(MediaStreamHandlerTest, RemoteAudioTrackSetVolume) { | 264 TEST_F(RtpSenderReceiverTest, RemoteAudioTrackSetVolume) { |
303 AddRemoteAudioTrack(); | 265 CreateAudioRtpReceiver(); |
304 | 266 |
305 double volume = 0.5; | 267 double volume = 0.5; |
306 EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, volume)); | 268 EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, volume)); |
307 audio_track_->GetSource()->SetVolume(volume); | 269 audio_track_->GetSource()->SetVolume(volume); |
308 | 270 |
309 // Disable the audio track, this should prevent setting the volume. | 271 // Disable the audio track, this should prevent setting the volume. |
310 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); | 272 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); |
311 audio_track_->set_enabled(false); | 273 audio_track_->set_enabled(false); |
312 audio_track_->GetSource()->SetVolume(1.0); | 274 audio_track_->GetSource()->SetVolume(1.0); |
313 | 275 |
314 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); | 276 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); |
315 audio_track_->set_enabled(true); | 277 audio_track_->set_enabled(true); |
316 | 278 |
317 double new_volume = 0.8; | 279 double new_volume = 0.8; |
318 EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, new_volume)); | 280 EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, new_volume)); |
319 audio_track_->GetSource()->SetVolume(new_volume); | 281 audio_track_->GetSource()->SetVolume(new_volume); |
320 | 282 |
321 RemoveRemoteAudioTrack(); | 283 DestroyAudioRtpReceiver(); |
322 handlers_.TearDown(); | |
323 } | 284 } |
324 | 285 |
325 } // namespace webrtc | 286 } // namespace webrtc |
OLD | NEW |