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 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 State state() const { return state_; } | 287 State state() const { return state_; } |
288 | 288 |
289 protected: | 289 protected: |
290 ~WebRtcSessionCreateSDPObserverForTest() {} | 290 ~WebRtcSessionCreateSDPObserverForTest() {} |
291 | 291 |
292 private: | 292 private: |
293 rtc::scoped_ptr<SessionDescriptionInterface> description_; | 293 rtc::scoped_ptr<SessionDescriptionInterface> description_; |
294 State state_; | 294 State state_; |
295 }; | 295 }; |
296 | 296 |
297 class FakeAudioRenderer : public cricket::AudioRenderer { | 297 class FakeAudioSource : public cricket::AudioSource { |
298 public: | 298 public: |
299 FakeAudioRenderer() : sink_(NULL) {} | 299 FakeAudioSource() : sink_(NULL) {} |
300 virtual ~FakeAudioRenderer() { | 300 virtual ~FakeAudioSource() { |
301 if (sink_) | 301 if (sink_) |
302 sink_->OnClose(); | 302 sink_->OnClose(); |
303 } | 303 } |
304 | 304 |
305 void SetSink(Sink* sink) override { sink_ = sink; } | 305 void SetSink(Sink* sink) override { sink_ = sink; } |
306 | 306 |
307 cricket::AudioRenderer::Sink* sink() const { return sink_; } | 307 const cricket::AudioSource::Sink* sink() const { return sink_; } |
| 308 |
308 private: | 309 private: |
309 cricket::AudioRenderer::Sink* sink_; | 310 cricket::AudioSource::Sink* sink_; |
310 }; | 311 }; |
311 | 312 |
312 class WebRtcSessionTest | 313 class WebRtcSessionTest |
313 : public testing::TestWithParam<RTCCertificateGenerationMethod>, | 314 : public testing::TestWithParam<RTCCertificateGenerationMethod>, |
314 public sigslot::has_slots<> { | 315 public sigslot::has_slots<> { |
315 protected: | 316 protected: |
316 // TODO Investigate why ChannelManager crashes, if it's created | 317 // TODO Investigate why ChannelManager crashes, if it's created |
317 // after stun_server. | 318 // after stun_server. |
318 WebRtcSessionTest() | 319 WebRtcSessionTest() |
319 : media_engine_(new cricket::FakeMediaEngine()), | 320 : media_engine_(new cricket::FakeMediaEngine()), |
(...skipping 3010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3330 CreateAndSetRemoteOfferAndLocalAnswer(); | 3331 CreateAndSetRemoteOfferAndLocalAnswer(); |
3331 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); | 3332 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); |
3332 ASSERT_TRUE(channel != NULL); | 3333 ASSERT_TRUE(channel != NULL); |
3333 ASSERT_EQ(1u, channel->send_streams().size()); | 3334 ASSERT_EQ(1u, channel->send_streams().size()); |
3334 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); | 3335 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); |
3335 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); | 3336 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); |
3336 | 3337 |
3337 cricket::AudioOptions options; | 3338 cricket::AudioOptions options; |
3338 options.echo_cancellation = rtc::Optional<bool>(true); | 3339 options.echo_cancellation = rtc::Optional<bool>(true); |
3339 | 3340 |
3340 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); | 3341 rtc::scoped_ptr<FakeAudioSource> source(new FakeAudioSource()); |
3341 session_->SetAudioSend(send_ssrc, false, options, renderer.get()); | 3342 session_->SetAudioSend(send_ssrc, false, options, source.get()); |
3342 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); | 3343 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); |
3343 EXPECT_EQ(rtc::Optional<bool>(), channel->options().echo_cancellation); | 3344 EXPECT_EQ(rtc::Optional<bool>(), channel->options().echo_cancellation); |
3344 EXPECT_TRUE(renderer->sink() != NULL); | 3345 EXPECT_TRUE(source->sink() != nullptr); |
3345 | 3346 |
3346 // This will trigger SetSink(NULL) to the |renderer|. | 3347 // This will trigger SetSink(nullptr) to the |source|. |
3347 session_->SetAudioSend(send_ssrc, true, options, NULL); | 3348 session_->SetAudioSend(send_ssrc, true, options, nullptr); |
3348 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); | 3349 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); |
3349 EXPECT_EQ(rtc::Optional<bool>(true), channel->options().echo_cancellation); | 3350 EXPECT_EQ(rtc::Optional<bool>(true), channel->options().echo_cancellation); |
3350 EXPECT_TRUE(renderer->sink() == NULL); | 3351 EXPECT_TRUE(source->sink() == nullptr); |
3351 } | 3352 } |
3352 | 3353 |
3353 TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) { | 3354 TEST_F(WebRtcSessionTest, AudioSourceForLocalStream) { |
3354 Init(); | 3355 Init(); |
3355 SendAudioVideoStream1(); | 3356 SendAudioVideoStream1(); |
3356 CreateAndSetRemoteOfferAndLocalAnswer(); | 3357 CreateAndSetRemoteOfferAndLocalAnswer(); |
3357 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); | 3358 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); |
3358 ASSERT_TRUE(channel != NULL); | 3359 ASSERT_TRUE(channel != NULL); |
3359 ASSERT_EQ(1u, channel->send_streams().size()); | 3360 ASSERT_EQ(1u, channel->send_streams().size()); |
3360 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); | 3361 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); |
3361 | 3362 |
3362 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); | 3363 rtc::scoped_ptr<FakeAudioSource> source(new FakeAudioSource()); |
3363 cricket::AudioOptions options; | 3364 cricket::AudioOptions options; |
3364 session_->SetAudioSend(send_ssrc, true, options, renderer.get()); | 3365 session_->SetAudioSend(send_ssrc, true, options, source.get()); |
3365 EXPECT_TRUE(renderer->sink() != NULL); | 3366 EXPECT_TRUE(source->sink() != nullptr); |
3366 | 3367 |
3367 // Delete the |renderer| and it will trigger OnClose() to the sink, and this | 3368 // Delete the |source| and it will trigger OnClose() to the sink, and this |
3368 // will invalidate the |renderer_| pointer in the sink and prevent getting a | 3369 // will invalidate the |source_| pointer in the sink and prevent getting a |
3369 // SetSink(NULL) callback afterwards. | 3370 // SetSink(nullptr) callback afterwards. |
3370 renderer.reset(); | 3371 source.reset(); |
3371 | 3372 |
3372 // This will trigger SetSink(NULL) if no OnClose() callback. | 3373 // This will trigger SetSink(nullptr) if no OnClose() callback. |
3373 session_->SetAudioSend(send_ssrc, true, options, NULL); | 3374 session_->SetAudioSend(send_ssrc, true, options, nullptr); |
3374 } | 3375 } |
3375 | 3376 |
3376 TEST_F(WebRtcSessionTest, SetVideoPlayout) { | 3377 TEST_F(WebRtcSessionTest, SetVideoPlayout) { |
3377 Init(); | 3378 Init(); |
3378 SendAudioVideoStream1(); | 3379 SendAudioVideoStream1(); |
3379 CreateAndSetRemoteOfferAndLocalAnswer(); | 3380 CreateAndSetRemoteOfferAndLocalAnswer(); |
3380 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); | 3381 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); |
3381 ASSERT_TRUE(channel != NULL); | 3382 ASSERT_TRUE(channel != NULL); |
3382 ASSERT_LT(0u, channel->sinks().size()); | 3383 ASSERT_LT(0u, channel->sinks().size()); |
3383 EXPECT_TRUE(channel->sinks().begin()->second == NULL); | 3384 EXPECT_TRUE(channel->sinks().begin()->second == NULL); |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4286 } | 4287 } |
4287 | 4288 |
4288 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4289 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
4289 // currently fails because upon disconnection and reconnection OnIceComplete is | 4290 // currently fails because upon disconnection and reconnection OnIceComplete is |
4290 // called more than once without returning to IceGatheringGathering. | 4291 // called more than once without returning to IceGatheringGathering. |
4291 | 4292 |
4292 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4293 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
4293 WebRtcSessionTest, | 4294 WebRtcSessionTest, |
4294 testing::Values(ALREADY_GENERATED, | 4295 testing::Values(ALREADY_GENERATED, |
4295 DTLS_IDENTITY_STORE)); | 4296 DTLS_IDENTITY_STORE)); |
OLD | NEW |