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, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 static const char kAudioTrackId[] = "audio_1"; | 49 static const char kAudioTrackId[] = "audio_1"; |
50 static const uint32_t kVideoSsrc = 98; | 50 static const uint32_t kVideoSsrc = 98; |
51 static const uint32_t kAudioSsrc = 99; | 51 static const uint32_t kAudioSsrc = 99; |
52 | 52 |
53 namespace webrtc { | 53 namespace webrtc { |
54 | 54 |
55 // Helper class to test RtpSender/RtpReceiver. | 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, | 59 MOCK_METHOD2(SetAudioPlayout, |
60 void(uint32_t ssrc, | 60 void(uint32_t ssrc, |
61 bool enable, | 61 bool enable)); |
62 cricket::AudioRenderer* renderer)); | |
63 MOCK_METHOD4(SetAudioSend, | 62 MOCK_METHOD4(SetAudioSend, |
64 void(uint32_t ssrc, | 63 void(uint32_t ssrc, |
65 bool enable, | 64 bool enable, |
66 const cricket::AudioOptions& options, | 65 const cricket::AudioOptions& options, |
67 cricket::AudioRenderer* renderer)); | 66 cricket::AudioRenderer* renderer)); |
68 MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32_t ssrc, double volume)); | 67 MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32_t ssrc, double volume)); |
69 }; | 68 }; |
70 | 69 |
71 // Helper class to test RtpSender/RtpReceiver. | 70 // Helper class to test RtpSender/RtpReceiver. |
72 class MockVideoProvider : public VideoProviderInterface { | 71 class MockVideoProvider : public VideoProviderInterface { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 void DestroyVideoRtpSender() { | 142 void DestroyVideoRtpSender() { |
144 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, NULL)).Times(1); | 143 EXPECT_CALL(video_provider_, SetCaptureDevice(kVideoSsrc, NULL)).Times(1); |
145 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1); | 144 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)).Times(1); |
146 video_rtp_sender_ = nullptr; | 145 video_rtp_sender_ = nullptr; |
147 } | 146 } |
148 | 147 |
149 void CreateAudioRtpReceiver() { | 148 void CreateAudioRtpReceiver() { |
150 audio_track_ = | 149 audio_track_ = |
151 AudioTrack::Create(kAudioTrackId, RemoteAudioSource::Create().get()); | 150 AudioTrack::Create(kAudioTrackId, RemoteAudioSource::Create().get()); |
152 EXPECT_TRUE(stream_->AddTrack(audio_track_)); | 151 EXPECT_TRUE(stream_->AddTrack(audio_track_)); |
153 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); | 152 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true)); |
154 audio_rtp_receiver_ = new AudioRtpReceiver(stream_->GetAudioTracks()[0], | 153 audio_rtp_receiver_ = new AudioRtpReceiver(stream_->GetAudioTracks()[0], |
155 kAudioSsrc, &audio_provider_); | 154 kAudioSsrc, &audio_provider_); |
156 } | 155 } |
157 | 156 |
158 void CreateVideoRtpReceiver() { | 157 void CreateVideoRtpReceiver() { |
159 EXPECT_CALL(video_provider_, | 158 EXPECT_CALL(video_provider_, |
160 SetVideoPlayout(kVideoSsrc, true, | 159 SetVideoPlayout(kVideoSsrc, true, |
161 video_track_->GetSource()->FrameInput())); | 160 video_track_->GetSource()->FrameInput())); |
162 video_rtp_receiver_ = new VideoRtpReceiver(stream_->GetVideoTracks()[0], | 161 video_rtp_receiver_ = new VideoRtpReceiver(stream_->GetVideoTracks()[0], |
163 kVideoSsrc, &video_provider_); | 162 kVideoSsrc, &video_provider_); |
164 } | 163 } |
165 | 164 |
166 void DestroyAudioRtpReceiver() { | 165 void DestroyAudioRtpReceiver() { |
167 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); | 166 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false)); |
168 audio_rtp_receiver_ = nullptr; | 167 audio_rtp_receiver_ = nullptr; |
169 } | 168 } |
170 | 169 |
171 void DestroyVideoRtpReceiver() { | 170 void DestroyVideoRtpReceiver() { |
172 EXPECT_CALL(video_provider_, SetVideoPlayout(kVideoSsrc, false, NULL)); | 171 EXPECT_CALL(video_provider_, SetVideoPlayout(kVideoSsrc, false, NULL)); |
173 video_rtp_receiver_ = nullptr; | 172 video_rtp_receiver_ = nullptr; |
174 } | 173 } |
175 | 174 |
176 protected: | 175 protected: |
177 MockAudioProvider audio_provider_; | 176 MockAudioProvider audio_provider_; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 220 |
222 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _)); | 221 EXPECT_CALL(audio_provider_, SetAudioSend(kAudioSsrc, true, _, _)); |
223 audio_track_->set_enabled(true); | 222 audio_track_->set_enabled(true); |
224 | 223 |
225 DestroyAudioRtpSender(); | 224 DestroyAudioRtpSender(); |
226 } | 225 } |
227 | 226 |
228 TEST_F(RtpSenderReceiverTest, RemoteAudioTrackDisable) { | 227 TEST_F(RtpSenderReceiverTest, RemoteAudioTrackDisable) { |
229 CreateAudioRtpReceiver(); | 228 CreateAudioRtpReceiver(); |
230 | 229 |
231 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); | 230 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false)); |
232 audio_track_->set_enabled(false); | 231 audio_track_->set_enabled(false); |
233 | 232 |
234 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); | 233 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true)); |
235 audio_track_->set_enabled(true); | 234 audio_track_->set_enabled(true); |
236 | 235 |
237 DestroyAudioRtpReceiver(); | 236 DestroyAudioRtpReceiver(); |
238 } | 237 } |
239 | 238 |
240 TEST_F(RtpSenderReceiverTest, LocalVideoTrackDisable) { | 239 TEST_F(RtpSenderReceiverTest, LocalVideoTrackDisable) { |
241 CreateVideoRtpSender(); | 240 CreateVideoRtpSender(); |
242 | 241 |
243 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)); | 242 EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc, false, _)); |
244 video_track_->set_enabled(false); | 243 video_track_->set_enabled(false); |
(...skipping 15 matching lines...) Expand all Loading... |
260 } | 259 } |
261 | 260 |
262 TEST_F(RtpSenderReceiverTest, RemoteAudioTrackSetVolume) { | 261 TEST_F(RtpSenderReceiverTest, RemoteAudioTrackSetVolume) { |
263 CreateAudioRtpReceiver(); | 262 CreateAudioRtpReceiver(); |
264 | 263 |
265 double volume = 0.5; | 264 double volume = 0.5; |
266 EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, volume)); | 265 EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, volume)); |
267 audio_track_->GetSource()->SetVolume(volume); | 266 audio_track_->GetSource()->SetVolume(volume); |
268 | 267 |
269 // Disable the audio track, this should prevent setting the volume. | 268 // Disable the audio track, this should prevent setting the volume. |
270 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false, _)); | 269 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, false)); |
271 audio_track_->set_enabled(false); | 270 audio_track_->set_enabled(false); |
272 audio_track_->GetSource()->SetVolume(1.0); | 271 audio_track_->GetSource()->SetVolume(1.0); |
273 | 272 |
274 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true, _)); | 273 EXPECT_CALL(audio_provider_, SetAudioPlayout(kAudioSsrc, true)); |
275 audio_track_->set_enabled(true); | 274 audio_track_->set_enabled(true); |
276 | 275 |
277 double new_volume = 0.8; | 276 double new_volume = 0.8; |
278 EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, new_volume)); | 277 EXPECT_CALL(audio_provider_, SetAudioPlayoutVolume(kAudioSsrc, new_volume)); |
279 audio_track_->GetSource()->SetVolume(new_volume); | 278 audio_track_->GetSource()->SetVolume(new_volume); |
280 | 279 |
281 DestroyAudioRtpReceiver(); | 280 DestroyAudioRtpReceiver(); |
282 } | 281 } |
283 | 282 |
284 } // namespace webrtc | 283 } // namespace webrtc |
OLD | NEW |