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

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

Issue 1393343003: Revert of Remove AudioTrackRenderer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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() : sink_(NULL) {} 333 FakeAudioRenderer() : channel_id_(-1), 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 }
339 void SetSink(Sink* sink) override { sink_ = sink; } 347 void SetSink(Sink* sink) override { sink_ = sink; }
340 348
349 int channel_id() const { return channel_id_; }
341 cricket::AudioRenderer::Sink* sink() const { return sink_; } 350 cricket::AudioRenderer::Sink* sink() const { return sink_; }
342 private: 351 private:
352 int channel_id_;
343 cricket::AudioRenderer::Sink* sink_; 353 cricket::AudioRenderer::Sink* sink_;
344 }; 354 };
345 355
346 class WebRtcSessionTest 356 class WebRtcSessionTest
347 : public testing::TestWithParam<RTCCertificateGenerationMethod> { 357 : public testing::TestWithParam<RTCCertificateGenerationMethod> {
348 protected: 358 protected:
349 // TODO Investigate why ChannelManager crashes, if it's created 359 // TODO Investigate why ChannelManager crashes, if it's created
350 // after stun_server. 360 // after stun_server.
351 WebRtcSessionTest() 361 WebRtcSessionTest()
352 : media_engine_(new cricket::FakeMediaEngine()), 362 : media_engine_(new cricket::FakeMediaEngine()),
(...skipping 2747 matching lines...) Expand 10 before | Expand all | Expand 10 after
3100 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc(); 3110 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc();
3101 double left_vol, right_vol; 3111 double left_vol, right_vol;
3102 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); 3112 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol));
3103 EXPECT_EQ(1, left_vol); 3113 EXPECT_EQ(1, left_vol);
3104 EXPECT_EQ(1, right_vol); 3114 EXPECT_EQ(1, right_vol);
3105 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); 3115 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer());
3106 session_->SetAudioPlayout(receive_ssrc, false, renderer.get()); 3116 session_->SetAudioPlayout(receive_ssrc, false, renderer.get());
3107 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); 3117 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol));
3108 EXPECT_EQ(0, left_vol); 3118 EXPECT_EQ(0, left_vol);
3109 EXPECT_EQ(0, right_vol); 3119 EXPECT_EQ(0, right_vol);
3120 EXPECT_EQ(0, renderer->channel_id());
3110 session_->SetAudioPlayout(receive_ssrc, true, NULL); 3121 session_->SetAudioPlayout(receive_ssrc, true, NULL);
3111 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); 3122 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol));
3112 EXPECT_EQ(1, left_vol); 3123 EXPECT_EQ(1, left_vol);
3113 EXPECT_EQ(1, right_vol); 3124 EXPECT_EQ(1, right_vol);
3125 EXPECT_EQ(-1, renderer->channel_id());
3114 } 3126 }
3115 3127
3116 TEST_F(WebRtcSessionTest, SetAudioSend) { 3128 TEST_F(WebRtcSessionTest, SetAudioSend) {
3117 Init(); 3129 Init();
3118 mediastream_signaling_.SendAudioVideoStream1(); 3130 mediastream_signaling_.SendAudioVideoStream1();
3119 CreateAndSetRemoteOfferAndLocalAnswer(); 3131 CreateAndSetRemoteOfferAndLocalAnswer();
3120 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); 3132 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3121 ASSERT_TRUE(channel != NULL); 3133 ASSERT_TRUE(channel != NULL);
3122 ASSERT_EQ(1u, channel->send_streams().size()); 3134 ASSERT_EQ(1u, channel->send_streams().size());
3123 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); 3135 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
3124 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); 3136 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3125 3137
3126 cricket::AudioOptions options; 3138 cricket::AudioOptions options;
3127 options.echo_cancellation.Set(true); 3139 options.echo_cancellation.Set(true);
3128 3140
3129 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); 3141 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer());
3130 session_->SetAudioSend(send_ssrc, false, options, renderer.get()); 3142 session_->SetAudioSend(send_ssrc, false, options, renderer.get());
3131 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); 3143 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc));
3132 EXPECT_FALSE(channel->options().echo_cancellation.IsSet()); 3144 EXPECT_FALSE(channel->options().echo_cancellation.IsSet());
3145 EXPECT_EQ(0, renderer->channel_id());
3133 EXPECT_TRUE(renderer->sink() != NULL); 3146 EXPECT_TRUE(renderer->sink() != NULL);
3134 3147
3135 // This will trigger SetSink(NULL) to the |renderer|. 3148 // This will trigger SetSink(NULL) to the |renderer|.
3136 session_->SetAudioSend(send_ssrc, true, options, NULL); 3149 session_->SetAudioSend(send_ssrc, true, options, NULL);
3137 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); 3150 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3138 bool value; 3151 bool value;
3139 EXPECT_TRUE(channel->options().echo_cancellation.Get(&value)); 3152 EXPECT_TRUE(channel->options().echo_cancellation.Get(&value));
3140 EXPECT_TRUE(value); 3153 EXPECT_TRUE(value);
3154 EXPECT_EQ(-1, renderer->channel_id());
3141 EXPECT_TRUE(renderer->sink() == NULL); 3155 EXPECT_TRUE(renderer->sink() == NULL);
3142 } 3156 }
3143 3157
3144 TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) { 3158 TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) {
3145 Init(); 3159 Init();
3146 mediastream_signaling_.SendAudioVideoStream1(); 3160 mediastream_signaling_.SendAudioVideoStream1();
3147 CreateAndSetRemoteOfferAndLocalAnswer(); 3161 CreateAndSetRemoteOfferAndLocalAnswer();
3148 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); 3162 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3149 ASSERT_TRUE(channel != NULL); 3163 ASSERT_TRUE(channel != NULL);
3150 ASSERT_EQ(1u, channel->send_streams().size()); 3164 ASSERT_EQ(1u, channel->send_streams().size());
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
4019 } 4033 }
4020 4034
4021 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4035 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4022 // currently fails because upon disconnection and reconnection OnIceComplete is 4036 // currently fails because upon disconnection and reconnection OnIceComplete is
4023 // called more than once without returning to IceGatheringGathering. 4037 // called more than once without returning to IceGatheringGathering.
4024 4038
4025 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4039 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4026 WebRtcSessionTest, 4040 WebRtcSessionTest,
4027 testing::Values(ALREADY_GENERATED, 4041 testing::Values(ALREADY_GENERATED,
4028 DTLS_IDENTITY_STORE)); 4042 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