| 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 uint32 kVideoSsrc = 98; | 50 static const uint32 kVideoSsrc = 98; |
| 51 static const uint32 kAudioSsrc = 99; | 51 static const uint32 kAudioSsrc = 99; |
| 52 | 52 |
| 53 namespace webrtc { | 53 namespace webrtc { |
| 54 | 54 |
| 55 // Helper class to test MediaStreamHandler. | 55 // Helper class to test RtpSender/RtpReceiver. |
| 56 class MockAudioProvider : public AudioProviderInterface { | 56 class MockAudioProvider : public AudioProviderInterface { |
| 57 public: | 57 public: |
| 58 virtual ~MockAudioProvider() {} | 58 virtual ~MockAudioProvider() {} |
| 59 MOCK_METHOD3(SetAudioPlayout, void(uint32 ssrc, bool enable, | 59 MOCK_METHOD3(SetAudioPlayout, |
| 60 cricket::AudioRenderer* renderer)); | 60 void(uint32 ssrc, |
| 61 MOCK_METHOD4(SetAudioSend, void(uint32 ssrc, bool enable, | 61 bool enable, |
| 62 const cricket::AudioOptions& options, | 62 cricket::AudioRenderer* renderer)); |
| 63 cricket::AudioRenderer* renderer)); | 63 MOCK_METHOD4(SetAudioSend, |
| 64 void(uint32 ssrc, |
| 65 bool enable, |
| 66 const cricket::AudioOptions& options, |
| 67 cricket::AudioRenderer* renderer)); |
| 64 MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32 ssrc, double volume)); | 68 MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32 ssrc, double volume)); |
| 65 }; | 69 }; |
| 66 | 70 |
| 67 // Helper class to test MediaStreamHandler. | 71 // Helper class to test RtpSender/RtpReceiver. |
| 68 class MockVideoProvider : public VideoProviderInterface { | 72 class MockVideoProvider : public VideoProviderInterface { |
| 69 public: | 73 public: |
| 70 virtual ~MockVideoProvider() {} | 74 virtual ~MockVideoProvider() {} |
| 71 MOCK_METHOD2(SetCaptureDevice, bool(uint32 ssrc, | 75 MOCK_METHOD2(SetCaptureDevice, |
| 72 cricket::VideoCapturer* camera)); | 76 bool(uint32 ssrc, cricket::VideoCapturer* camera)); |
| 73 MOCK_METHOD3(SetVideoPlayout, void(uint32 ssrc, | 77 MOCK_METHOD3(SetVideoPlayout, |
| 74 bool enable, | 78 void(uint32 ssrc, |
| 75 cricket::VideoRenderer* renderer)); | 79 bool enable, |
| 76 MOCK_METHOD3(SetVideoSend, void(uint32 ssrc, bool enable, | 80 cricket::VideoRenderer* renderer)); |
| 77 const cricket::VideoOptions* options)); | 81 MOCK_METHOD3(SetVideoSend, |
| 82 void(uint32 ssrc, |
| 83 bool enable, |
| 84 const cricket::VideoOptions* options)); |
| 78 }; | 85 }; |
| 79 | 86 |
| 80 class FakeVideoSource : public Notifier<VideoSourceInterface> { | 87 class FakeVideoSource : public Notifier<VideoSourceInterface> { |
| 81 public: | 88 public: |
| 82 static rtc::scoped_refptr<FakeVideoSource> Create() { | 89 static rtc::scoped_refptr<FakeVideoSource> Create() { |
| 83 return new rtc::RefCountedObject<FakeVideoSource>(); | 90 return new rtc::RefCountedObject<FakeVideoSource>(); |
| 84 } | 91 } |
| 85 virtual cricket::VideoCapturer* GetVideoCapturer() { | 92 virtual cricket::VideoCapturer* GetVideoCapturer() { return &fake_capturer_; } |
| 86 return &fake_capturer_; | |
| 87 } | |
| 88 virtual void Stop() {} | 93 virtual void Stop() {} |
| 89 virtual void Restart() {} | 94 virtual void Restart() {} |
| 90 virtual void AddSink(cricket::VideoRenderer* output) {} | 95 virtual void AddSink(cricket::VideoRenderer* output) {} |
| 91 virtual void RemoveSink(cricket::VideoRenderer* output) {} | 96 virtual void RemoveSink(cricket::VideoRenderer* output) {} |
| 92 virtual SourceState state() const { return state_; } | 97 virtual SourceState state() const { return state_; } |
| 93 virtual const cricket::VideoOptions* options() const { return &options_; } | 98 virtual const cricket::VideoOptions* options() const { return &options_; } |
| 94 virtual cricket::VideoRenderer* FrameInput() { return NULL; } | 99 virtual cricket::VideoRenderer* FrameInput() { return NULL; } |
| 95 | 100 |
| 96 protected: | 101 protected: |
| 97 FakeVideoSource() : state_(kLive) {} | 102 FakeVideoSource() : state_(kLive) {} |
| 98 ~FakeVideoSource() {} | 103 ~FakeVideoSource() {} |
| 99 | 104 |
| 100 private: | 105 private: |
| 101 cricket::FakeVideoCapturer fake_capturer_; | 106 cricket::FakeVideoCapturer fake_capturer_; |
| 102 SourceState state_; | 107 SourceState state_; |
| 103 cricket::VideoOptions options_; | 108 cricket::VideoOptions options_; |
| 104 }; | 109 }; |
| 105 | 110 |
| 106 class MediaStreamHandlerTest : public testing::Test { | 111 class RtpSenderReceiverTest : public testing::Test { |
| 107 public: | 112 public: |
| 108 MediaStreamHandlerTest() | |
| 109 : handlers_(&audio_provider_, &video_provider_) { | |
| 110 } | |
| 111 | |
| 112 virtual void SetUp() { | 113 virtual void SetUp() { |
| 113 stream_ = MediaStream::Create(kStreamLabel1); | 114 stream_ = MediaStream::Create(kStreamLabel1); |
| 114 rtc::scoped_refptr<VideoSourceInterface> source( | 115 rtc::scoped_refptr<VideoSourceInterface> source(FakeVideoSource::Create()); |
| 115 FakeVideoSource::Create()); | |
| 116 video_track_ = VideoTrack::Create(kVideoTrackId, source); | 116 video_track_ = VideoTrack::Create(kVideoTrackId, source); |
| 117 EXPECT_TRUE(stream_->AddTrack(video_track_)); | 117 EXPECT_TRUE(stream_->AddTrack(video_track_)); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void AddLocalAudioTrack() { | 120 void CreateAudioRtpSender() { |
| 121 audio_track_ = AudioTrack::Create(kAudioTrackId, NULL); | 121 audio_track_ = AudioTrack::Create(kAudioTrackId, NULL); |
| 122 EXPECT_TRUE(stream_->AddTrack(audio_track_)); | 122 EXPECT_TRUE(stream_->AddTrack(audio_track_)); |
| 123 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _)); | 123 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _)); |
| 124 handlers_.AddLocalAudioTrack(stream_, stream_->GetAudioTracks()[0], | 124 audio_rtp_sender_ = new AudioRtpSender(stream_->GetAudioTracks()[0], |
| 125 kAudioSsrc); | 125 kAudioSsrc, &audio_provider_); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void AddLocalVideoTrack() { | 128 void CreateVideoRtpSender() { |
| 129 EXPECT_CALL(video_provider_, SetCaptureDevice( | 129 EXPECT_CALL(video_provider_, |
| 130 kVideoSsrc, video_track_->GetSource()->GetVideoCapturer())); | 130 SetCaptureDevice( |
| 131 kVideoSsrc, video_track_->GetSource()->GetVideoCapturer())); |
| 131 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _)); | 132 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _)); |
| 132 handlers_.AddLocalVideoTrack(stream_, stream_->GetVideoTracks()[0], | 133 video_rtp_sender_ = new VideoRtpSender(stream_->GetVideoTracks()[0], |
| 133 kVideoSsrc); | 134 kVideoSsrc, &video_provider_); |
| 134 } | 135 } |
| 135 | 136 |
| 136 void RemoveLocalAudioTrack() { | 137 void DestroyAudioRtpSender() { |
| 137 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _)) | 138 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _)) |
| 138 .Times(1); | 139 .Times(1); |
| 139 handlers_.RemoveLocalTrack(stream_, audio_track_); | 140 audio_rtp_sender_ = nullptr; |
| 140 } | 141 } |
| 141 | 142 |
| 142 void RemoveLocalVideoTrack() { | 143 void DestroyVideoRtpSender() { |
| 143 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, NULL)) | 144 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, NULL)).Times(1); |
| 144 .Times(1); | 145 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1); |
| 145 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)) | 146 video_rtp_sender_ = nullptr; |
| 146 .Times(1); | |
| 147 handlers_.RemoveLocalTrack(stream_, video_track_); | |
| 148 } | 147 } |
| 149 | 148 |
| 150 void AddRemoteAudioTrack() { | 149 void CreateAudioRtpReceiver() { |
| 151 audio_track_ = AudioTrack::Create(kAudioTrackId, | 150 audio_track_ = |
| 152 RemoteAudioSource::Create().get()); | 151 AudioTrack::Create(kAudioTrackId, RemoteAudioSource::Create().get()); |
| 153 EXPECT_TRUE(stream_->AddTrack(audio_track_)); | 152 EXPECT_TRUE(stream_->AddTrack(audio_track_)); |
| 154 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); | 153 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); |
| 155 handlers_.AddRemoteAudioTrack(stream_, stream_->GetAudioTracks()[0], | 154 audio_rtp_receiver_ = new AudioRtpReceiver(stream_->GetAudioTracks()[0], |
| 156 kAudioSsrc); | 155 kAudioSsrc, &audio_provider_); |
| 157 } | 156 } |
| 158 | 157 |
| 159 void AddRemoteVideoTrack() { | 158 void CreateVideoRtpReceiver() { |
| 160 EXPECT_CALL(video_provider_, SetVideoPlayout( | 159 EXPECT_CALL(video_provider_, |
| 161 kVideoSsrc, true, video_track_->GetSource()->FrameInput())); | 160 SetVideoPlayout(kVideoSsrc, true, |
| 162 handlers_.AddRemoteVideoTrack(stream_, stream_->GetVideoTracks()[0], | 161 video_track_->GetSource()->FrameInput())); |
| 163 kVideoSsrc); | 162 video_rtp_receiver_ = new VideoRtpReceiver(stream_->GetVideoTracks()[0], |
| 163 kVideoSsrc, &video_provider_); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void RemoveRemoteAudioTrack() { | 166 void DestroyAudioRtpReceiver() { |
| 167 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); | 167 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); |
| 168 handlers_.RemoveRemoteTrack(stream_, stream_->GetAudioTracks()[0]); | 168 audio_rtp_receiver_ = nullptr; |
| 169 } | 169 } |
| 170 | 170 |
| 171 void RemoveRemoteVideoTrack() { | 171 void DestroyVideoRtpReceiver() { |
| 172 EXPECT_CALL(video_provider_, SetVideoPlayout(kVideoSsrc, false, NULL)); | 172 EXPECT_CALL(video_provider_, SetVideoPlayout(kVideoSsrc, false, NULL)); |
| 173 handlers_.RemoveRemoteTrack(stream_, stream_->GetVideoTracks()[0]); | 173 video_rtp_receiver_ = nullptr; |
| 174 } | 174 } |
| 175 | 175 |
| 176 protected: | 176 protected: |
| 177 MockAudioProvider audio_provider_; | 177 MockAudioProvider audio_provider_; |
| 178 MockVideoProvider video_provider_; | 178 MockVideoProvider video_provider_; |
| 179 MediaStreamHandlerContainer handlers_; | 179 rtc::scoped_refptr<AudioRtpSender> audio_rtp_sender_; |
| 180 rtc::scoped_refptr<VideoRtpSender> video_rtp_sender_; |
| 181 rtc::scoped_refptr<AudioRtpReceiver> audio_rtp_receiver_; |
| 182 rtc::scoped_refptr<VideoRtpReceiver> video_rtp_receiver_; |
| 180 rtc::scoped_refptr<MediaStreamInterface> stream_; | 183 rtc::scoped_refptr<MediaStreamInterface> stream_; |
| 181 rtc::scoped_refptr<VideoTrackInterface> video_track_; | 184 rtc::scoped_refptr<VideoTrackInterface> video_track_; |
| 182 rtc::scoped_refptr<AudioTrackInterface> audio_track_; | 185 rtc::scoped_refptr<AudioTrackInterface> audio_track_; |
| 183 }; | 186 }; |
| 184 | 187 |
| 185 // Test that |audio_provider_| is notified when an audio track is associated | 188 // Test that |audio_provider_| is notified when an audio track is associated |
| 186 // and disassociated with a MediaStreamHandler. | 189 // and disassociated with an AudioRtpSender. |
| 187 TEST_F(MediaStreamHandlerTest, AddAndRemoveLocalAudioTrack) { | 190 TEST_F(RtpSenderReceiverTest, AddAndDestroyAudioRtpSender) { |
| 188 AddLocalAudioTrack(); | 191 CreateAudioRtpSender(); |
| 189 RemoveLocalAudioTrack(); | 192 DestroyAudioRtpSender(); |
| 190 | |
| 191 handlers_.RemoveLocalStream(stream_); | |
| 192 } | 193 } |
| 193 | 194 |
| 194 // Test that |video_provider_| is notified when a video track is associated and | 195 // Test that |video_provider_| is notified when a video track is associated and |
| 195 // disassociated with a MediaStreamHandler. | 196 // disassociated with a VideoRtpSender. |
| 196 TEST_F(MediaStreamHandlerTest, AddAndRemoveLocalVideoTrack) { | 197 TEST_F(RtpSenderReceiverTest, AddAndDestroyVideoRtpSender) { |
| 197 AddLocalVideoTrack(); | 198 CreateVideoRtpSender(); |
| 198 RemoveLocalVideoTrack(); | 199 DestroyVideoRtpSender(); |
| 199 | |
| 200 handlers_.RemoveLocalStream(stream_); | |
| 201 } | 200 } |
| 202 | 201 |
| 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 | 202 // Test that |audio_provider_| is notified when a remote audio and track is |
| 221 // associated and disassociated with a MediaStreamHandler. | 203 // associated and disassociated with an AudioRtpReceiver. |
| 222 TEST_F(MediaStreamHandlerTest, AddAndRemoveRemoteAudioTrack) { | 204 TEST_F(RtpSenderReceiverTest, AddAndDestroyAudioRtpReceiver) { |
| 223 AddRemoteAudioTrack(); | 205 CreateAudioRtpReceiver(); |
| 224 RemoveRemoteAudioTrack(); | 206 DestroyAudioRtpReceiver(); |
| 225 | |
| 226 handlers_.RemoveRemoteStream(stream_); | |
| 227 } | 207 } |
| 228 | 208 |
| 229 // Test that |video_provider_| is notified when a remote | 209 // Test that |video_provider_| is notified when a remote |
| 230 // video track is associated and disassociated with a MediaStreamHandler. | 210 // video track is associated and disassociated with a VideoRtpReceiver. |
| 231 TEST_F(MediaStreamHandlerTest, AddAndRemoveRemoteVideoTrack) { | 211 TEST_F(RtpSenderReceiverTest, AddAndDestroyVideoRtpReceiver) { |
| 232 AddRemoteVideoTrack(); | 212 CreateVideoRtpReceiver(); |
| 233 RemoveRemoteVideoTrack(); | 213 DestroyVideoRtpReceiver(); |
| 234 | |
| 235 handlers_.RemoveRemoteStream(stream_); | |
| 236 } | 214 } |
| 237 | 215 |
| 238 // Test that |audio_provider_| and |video_provider_| is notified when an audio | 216 TEST_F(RtpSenderReceiverTest, LocalAudioTrackDisable) { |
| 239 // and video track is disassociated with a MediaStreamHandler by calling | 217 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 | 218 |
| 255 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _)); | 219 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, false, _, _)); |
| 256 audio_track_->set_enabled(false); | 220 audio_track_->set_enabled(false); |
| 257 | 221 |
| 258 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _)); | 222 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _)); |
| 259 audio_track_->set_enabled(true); | 223 audio_track_->set_enabled(true); |
| 260 | 224 |
| 261 RemoveLocalAudioTrack(); | 225 DestroyAudioRtpSender(); |
| 262 handlers_.TearDown(); | |
| 263 } | 226 } |
| 264 | 227 |
| 265 TEST_F(MediaStreamHandlerTest, RemoteAudioTrackDisable) { | 228 TEST_F(RtpSenderReceiverTest, RemoteAudioTrackDisable) { |
| 266 AddRemoteAudioTrack(); | 229 CreateAudioRtpReceiver(); |
| 267 | 230 |
| 268 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); | 231 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); |
| 269 audio_track_->set_enabled(false); | 232 audio_track_->set_enabled(false); |
| 270 | 233 |
| 271 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); | 234 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); |
| 272 audio_track_->set_enabled(true); | 235 audio_track_->set_enabled(true); |
| 273 | 236 |
| 274 RemoveRemoteAudioTrack(); | 237 DestroyAudioRtpReceiver(); |
| 275 handlers_.TearDown(); | |
| 276 } | 238 } |
| 277 | 239 |
| 278 TEST_F(MediaStreamHandlerTest, LocalVideoTrackDisable) { | 240 TEST_F(RtpSenderReceiverTest, LocalVideoTrackDisable) { |
| 279 AddLocalVideoTrack(); | 241 CreateVideoRtpSender(); |
| 280 | 242 |
| 281 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)); | 243 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)); |
| 282 video_track_->set_enabled(false); | 244 video_track_->set_enabled(false); |
| 283 | 245 |
| 284 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _)); | 246 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, true, _)); |
| 285 video_track_->set_enabled(true); | 247 video_track_->set_enabled(true); |
| 286 | 248 |
| 287 RemoveLocalVideoTrack(); | 249 DestroyVideoRtpSender(); |
| 288 handlers_.TearDown(); | |
| 289 } | 250 } |
| 290 | 251 |
| 291 TEST_F(MediaStreamHandlerTest, RemoteVideoTrackDisable) { | 252 TEST_F(RtpSenderReceiverTest, RemoteVideoTrackDisable) { |
| 292 AddRemoteVideoTrack(); | 253 CreateVideoRtpReceiver(); |
| 293 | 254 |
| 294 video_track_->set_enabled(false); | 255 video_track_->set_enabled(false); |
| 295 | 256 |
| 296 video_track_->set_enabled(true); | 257 video_track_->set_enabled(true); |
| 297 | 258 |
| 298 RemoveRemoteVideoTrack(); | 259 DestroyVideoRtpReceiver(); |
| 299 handlers_.TearDown(); | |
| 300 } | 260 } |
| 301 | 261 |
| 302 TEST_F(MediaStreamHandlerTest, RemoteAudioTrackSetVolume) { | 262 TEST_F(RtpSenderReceiverTest, RemoteAudioTrackSetVolume) { |
| 303 AddRemoteAudioTrack(); | 263 CreateAudioRtpReceiver(); |
| 304 | 264 |
| 305 double volume = 0.5; | 265 double volume = 0.5; |
| 306 EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, volume)); | 266 EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, volume)); |
| 307 audio_track_->GetSource()->SetVolume(volume); | 267 audio_track_->GetSource()->SetVolume(volume); |
| 308 | 268 |
| 309 // Disable the audio track, this should prevent setting the volume. | 269 // Disable the audio track, this should prevent setting the volume. |
| 310 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); | 270 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); |
| 311 audio_track_->set_enabled(false); | 271 audio_track_->set_enabled(false); |
| 312 audio_track_->GetSource()->SetVolume(1.0); | 272 audio_track_->GetSource()->SetVolume(1.0); |
| 313 | 273 |
| 314 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); | 274 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); |
| 315 audio_track_->set_enabled(true); | 275 audio_track_->set_enabled(true); |
| 316 | 276 |
| 317 double new_volume = 0.8; | 277 double new_volume = 0.8; |
| 318 EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, new_volume)); | 278 EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, new_volume)); |
| 319 audio_track_->GetSource()->SetVolume(new_volume); | 279 audio_track_->GetSource()->SetVolume(new_volume); |
| 320 | 280 |
| 321 RemoveRemoteAudioTrack(); | 281 DestroyAudioRtpReceiver(); |
| 322 handlers_.TearDown(); | |
| 323 } | 282 } |
| 324 | 283 |
| 325 } // namespace webrtc | 284 } // namespace webrtc |
| OLD | NEW |