Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: talk/app/webrtc/webrtcsession_unittest.cc

Issue 1399553003: Reland: Remove AudioTrackRenderer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/app/webrtc/audiotrackrenderer.cc ('k') | talk/libjingle.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 protected: 323 protected:
324 ~WebRtcSessionCreateSDPObserverForTest() {} 324 ~WebRtcSessionCreateSDPObserverForTest() {}
325 325
326 private: 326 private:
327 rtc::scoped_ptr<SessionDescriptionInterface> description_; 327 rtc::scoped_ptr<SessionDescriptionInterface> description_;
328 State state_; 328 State state_;
329 }; 329 };
330 330
331 class FakeAudioRenderer : public cricket::AudioRenderer { 331 class FakeAudioRenderer : public cricket::AudioRenderer {
332 public: 332 public:
333 FakeAudioRenderer() : channel_id_(-1), sink_(NULL) {} 333 FakeAudioRenderer() : sink_(NULL) {}
334 virtual ~FakeAudioRenderer() { 334 virtual ~FakeAudioRenderer() {
335 if (sink_) 335 if (sink_)
336 sink_->OnClose(); 336 sink_->OnClose();
337 } 337 }
338 338
339 void AddChannel(int channel_id) override {
340 ASSERT(channel_id_ == -1);
341 channel_id_ = channel_id;
342 }
343 void RemoveChannel(int channel_id) override {
344 ASSERT(channel_id == channel_id_);
345 channel_id_ = -1;
346 }
347 void SetSink(Sink* sink) override { sink_ = sink; } 339 void SetSink(Sink* sink) override { sink_ = sink; }
348 340
349 int channel_id() const { return channel_id_; }
350 cricket::AudioRenderer::Sink* sink() const { return sink_; } 341 cricket::AudioRenderer::Sink* sink() const { return sink_; }
351 private: 342 private:
352 int channel_id_;
353 cricket::AudioRenderer::Sink* sink_; 343 cricket::AudioRenderer::Sink* sink_;
354 }; 344 };
355 345
356 class WebRtcSessionTest 346 class WebRtcSessionTest
357 : public testing::TestWithParam<RTCCertificateGenerationMethod> { 347 : public testing::TestWithParam<RTCCertificateGenerationMethod> {
358 protected: 348 protected:
359 // TODO Investigate why ChannelManager crashes, if it's created 349 // TODO Investigate why ChannelManager crashes, if it's created
360 // after stun_server. 350 // after stun_server.
361 WebRtcSessionTest() 351 WebRtcSessionTest()
362 : media_engine_(new cricket::FakeMediaEngine()), 352 : media_engine_(new cricket::FakeMediaEngine()),
(...skipping 2745 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 ASSERT_TRUE(channel != NULL); 3098 ASSERT_TRUE(channel != NULL);
3109 ASSERT_EQ(1u, channel->recv_streams().size()); 3099 ASSERT_EQ(1u, channel->recv_streams().size());
3110 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc(); 3100 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc();
3111 double volume; 3101 double volume;
3112 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume)); 3102 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume));
3113 EXPECT_EQ(1, volume); 3103 EXPECT_EQ(1, volume);
3114 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); 3104 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer());
3115 session_->SetAudioPlayout(receive_ssrc, false, renderer.get()); 3105 session_->SetAudioPlayout(receive_ssrc, false, renderer.get());
3116 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume)); 3106 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume));
3117 EXPECT_EQ(0, volume); 3107 EXPECT_EQ(0, volume);
3118 EXPECT_EQ(0, renderer->channel_id());
3119 session_->SetAudioPlayout(receive_ssrc, true, NULL); 3108 session_->SetAudioPlayout(receive_ssrc, true, NULL);
3120 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume)); 3109 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume));
3121 EXPECT_EQ(1, volume); 3110 EXPECT_EQ(1, volume);
3122 EXPECT_EQ(-1, renderer->channel_id());
3123 } 3111 }
3124 3112
3125 TEST_F(WebRtcSessionTest, SetAudioSend) { 3113 TEST_F(WebRtcSessionTest, SetAudioSend) {
3126 Init(); 3114 Init();
3127 mediastream_signaling_.SendAudioVideoStream1(); 3115 mediastream_signaling_.SendAudioVideoStream1();
3128 CreateAndSetRemoteOfferAndLocalAnswer(); 3116 CreateAndSetRemoteOfferAndLocalAnswer();
3129 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); 3117 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3130 ASSERT_TRUE(channel != NULL); 3118 ASSERT_TRUE(channel != NULL);
3131 ASSERT_EQ(1u, channel->send_streams().size()); 3119 ASSERT_EQ(1u, channel->send_streams().size());
3132 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); 3120 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
3133 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); 3121 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3134 3122
3135 cricket::AudioOptions options; 3123 cricket::AudioOptions options;
3136 options.echo_cancellation.Set(true); 3124 options.echo_cancellation.Set(true);
3137 3125
3138 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); 3126 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer());
3139 session_->SetAudioSend(send_ssrc, false, options, renderer.get()); 3127 session_->SetAudioSend(send_ssrc, false, options, renderer.get());
3140 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); 3128 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc));
3141 EXPECT_FALSE(channel->options().echo_cancellation.IsSet()); 3129 EXPECT_FALSE(channel->options().echo_cancellation.IsSet());
3142 EXPECT_EQ(0, renderer->channel_id());
3143 EXPECT_TRUE(renderer->sink() != NULL); 3130 EXPECT_TRUE(renderer->sink() != NULL);
3144 3131
3145 // This will trigger SetSink(NULL) to the |renderer|. 3132 // This will trigger SetSink(NULL) to the |renderer|.
3146 session_->SetAudioSend(send_ssrc, true, options, NULL); 3133 session_->SetAudioSend(send_ssrc, true, options, NULL);
3147 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); 3134 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3148 bool value; 3135 bool value;
3149 EXPECT_TRUE(channel->options().echo_cancellation.Get(&value)); 3136 EXPECT_TRUE(channel->options().echo_cancellation.Get(&value));
3150 EXPECT_TRUE(value); 3137 EXPECT_TRUE(value);
3151 EXPECT_EQ(-1, renderer->channel_id());
3152 EXPECT_TRUE(renderer->sink() == NULL); 3138 EXPECT_TRUE(renderer->sink() == NULL);
3153 } 3139 }
3154 3140
3155 TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) { 3141 TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) {
3156 Init(); 3142 Init();
3157 mediastream_signaling_.SendAudioVideoStream1(); 3143 mediastream_signaling_.SendAudioVideoStream1();
3158 CreateAndSetRemoteOfferAndLocalAnswer(); 3144 CreateAndSetRemoteOfferAndLocalAnswer();
3159 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); 3145 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3160 ASSERT_TRUE(channel != NULL); 3146 ASSERT_TRUE(channel != NULL);
3161 ASSERT_EQ(1u, channel->send_streams().size()); 3147 ASSERT_EQ(1u, channel->send_streams().size());
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
4030 } 4016 }
4031 4017
4032 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4018 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4033 // currently fails because upon disconnection and reconnection OnIceComplete is 4019 // currently fails because upon disconnection and reconnection OnIceComplete is
4034 // called more than once without returning to IceGatheringGathering. 4020 // called more than once without returning to IceGatheringGathering.
4035 4021
4036 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4022 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4037 WebRtcSessionTest, 4023 WebRtcSessionTest,
4038 testing::Values(ALREADY_GENERATED, 4024 testing::Values(ALREADY_GENERATED,
4039 DTLS_IDENTITY_STORE)); 4025 DTLS_IDENTITY_STORE));
OLDNEW
« no previous file with comments | « talk/app/webrtc/audiotrackrenderer.cc ('k') | talk/libjingle.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698