Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/test/webrtc_audio_device_test.h" | 5 #include "content/test/webrtc_audio_device_test.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 virtual int GetEnabledBindings() const OVERRIDE { return 0; } | 70 virtual int GetEnabledBindings() const OVERRIDE { return 0; } |
| 71 virtual TransportDIB* CreateTransportDIB(size_t size) OVERRIDE { | 71 virtual TransportDIB* CreateTransportDIB(size_t size) OVERRIDE { |
| 72 return NULL; | 72 return NULL; |
| 73 } | 73 } |
| 74 virtual void FreeTransportDIB(TransportDIB*) OVERRIDE {} | 74 virtual void FreeTransportDIB(TransportDIB*) OVERRIDE {} |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 DISALLOW_COPY_AND_ASSIGN(WebRTCMockRenderProcess); | 77 DISALLOW_COPY_AND_ASSIGN(WebRTCMockRenderProcess); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 class TestAudioRendererHost : public AudioRendererHost { | |
| 81 public: | |
| 82 TestAudioRendererHost( | |
| 83 int render_process_id, | |
| 84 media::AudioManager* audio_manager, | |
| 85 AudioMirroringManager* mirroring_manager, | |
| 86 MediaInternals* media_internals, | |
| 87 MediaStreamManager* media_stream_manager, | |
| 88 IPC::Channel* channel) | |
| 89 : AudioRendererHost(render_process_id, audio_manager, mirroring_manager, | |
| 90 media_internals, media_stream_manager), | |
| 91 channel_(channel) {} | |
| 92 virtual bool Send(IPC::Message* message) OVERRIDE { | |
| 93 if (channel_) | |
| 94 return channel_->Send(message); | |
| 95 return false; | |
| 96 } | |
| 97 void ResetChannel() { | |
| 98 channel_ = NULL; | |
| 99 } | |
| 100 | |
| 101 private: | |
| 102 IPC::Channel* channel_; | |
| 103 }; | |
| 104 | |
| 105 class TestAudioInputRendererHost : public AudioInputRendererHost { | |
| 106 public: | |
| 107 TestAudioInputRendererHost( | |
| 108 media::AudioManager* audio_manager, | |
| 109 MediaStreamManager* media_stream_manager, | |
| 110 AudioMirroringManager* audio_mirroring_manager, | |
| 111 media::UserInputMonitor* user_input_monitor, | |
| 112 IPC::Channel* channel) | |
| 113 : AudioInputRendererHost(audio_manager, media_stream_manager, | |
| 114 audio_mirroring_manager, user_input_monitor), | |
|
scherkus (not reviewing)
2013/09/26 19:57:37
nit: fix indent?
looks off
jam
2013/09/26 20:22:39
Done.
| |
| 115 channel_(channel) {} | |
| 116 virtual bool Send(IPC::Message* message) OVERRIDE { | |
| 117 if (channel_) | |
| 118 return channel_->Send(message); | |
| 119 return false; | |
| 120 } | |
| 121 void ResetChannel() { | |
| 122 channel_ = NULL; | |
| 123 } | |
| 124 | |
| 125 private: | |
| 126 IPC::Channel* channel_; | |
| 127 }; | |
| 128 | |
| 80 // Utility scoped class to replace the global content client's renderer for the | 129 // Utility scoped class to replace the global content client's renderer for the |
| 81 // duration of the test. | 130 // duration of the test. |
| 82 class ReplaceContentClientRenderer { | 131 class ReplaceContentClientRenderer { |
| 83 public: | 132 public: |
| 84 explicit ReplaceContentClientRenderer(ContentRendererClient* new_renderer) { | 133 explicit ReplaceContentClientRenderer(ContentRendererClient* new_renderer) { |
| 85 saved_renderer_ = SetRendererClientForTesting(new_renderer); | 134 saved_renderer_ = SetRendererClientForTesting(new_renderer); |
| 86 } | 135 } |
| 87 ~ReplaceContentClientRenderer() { | 136 ~ReplaceContentClientRenderer() { |
| 88 // Restore the original renderer. | 137 // Restore the original renderer. |
| 89 SetRendererClientForTesting(saved_renderer_); | 138 SetRendererClientForTesting(saved_renderer_); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 #if defined(OS_WIN) | 300 #if defined(OS_WIN) |
| 252 initialize_com_.reset(); | 301 initialize_com_.reset(); |
| 253 #endif | 302 #endif |
| 254 | 303 |
| 255 audio_manager_.reset(); | 304 audio_manager_.reset(); |
| 256 } | 305 } |
| 257 | 306 |
| 258 void MAYBE_WebRTCAudioDeviceTest::CreateChannel(const char* name) { | 307 void MAYBE_WebRTCAudioDeviceTest::CreateChannel(const char* name) { |
| 259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 260 | 309 |
| 261 static const int kRenderProcessId = 1; | |
| 262 audio_render_host_ = new AudioRendererHost( | |
| 263 kRenderProcessId, audio_manager_.get(), mirroring_manager_.get(), | |
| 264 media_internals_.get(), media_stream_manager_.get()); | |
| 265 audio_render_host_->OnChannelConnected(base::GetCurrentProcId()); | |
| 266 | |
| 267 audio_input_renderer_host_ = | |
| 268 new AudioInputRendererHost(audio_manager_.get(), | |
| 269 media_stream_manager_.get(), | |
| 270 mirroring_manager_.get(), | |
| 271 NULL); | |
| 272 audio_input_renderer_host_->OnChannelConnected(base::GetCurrentProcId()); | |
| 273 | |
| 274 channel_.reset(new IPC::Channel(name, IPC::Channel::MODE_SERVER, this)); | 310 channel_.reset(new IPC::Channel(name, IPC::Channel::MODE_SERVER, this)); |
| 275 ASSERT_TRUE(channel_->Connect()); | 311 ASSERT_TRUE(channel_->Connect()); |
| 276 | 312 |
| 277 audio_render_host_->OnFilterAdded(channel_.get()); | 313 static const int kRenderProcessId = 1; |
| 278 audio_input_renderer_host_->OnFilterAdded(channel_.get()); | 314 audio_render_host_ = new TestAudioRendererHost( |
| 315 kRenderProcessId, audio_manager_.get(), mirroring_manager_.get(), | |
| 316 media_internals_.get(), media_stream_manager_.get(), channel_.get()); | |
| 317 audio_render_host_->set_peer_pid_for_testing(base::GetCurrentProcId()); | |
| 318 | |
| 319 audio_input_renderer_host_ = | |
| 320 new TestAudioInputRendererHost(audio_manager_.get(), | |
| 321 media_stream_manager_.get(), | |
| 322 mirroring_manager_.get(), | |
| 323 NULL, | |
| 324 channel_.get()); | |
| 325 audio_input_renderer_host_->set_peer_pid_for_testing( | |
| 326 base::GetCurrentProcId()); | |
| 279 } | 327 } |
| 280 | 328 |
| 281 void MAYBE_WebRTCAudioDeviceTest::DestroyChannel() { | 329 void MAYBE_WebRTCAudioDeviceTest::DestroyChannel() { |
| 282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 283 audio_render_host_->OnChannelClosing(); | 331 audio_render_host_->OnChannelClosing(); |
| 284 audio_render_host_->OnFilterRemoved(); | 332 audio_render_host_->OnFilterRemoved(); |
| 285 audio_input_renderer_host_->OnChannelClosing(); | 333 audio_input_renderer_host_->OnChannelClosing(); |
| 286 audio_input_renderer_host_->OnFilterRemoved(); | 334 audio_input_renderer_host_->OnFilterRemoved(); |
| 335 audio_render_host_->ResetChannel(); | |
| 336 audio_input_renderer_host_->ResetChannel(); | |
| 287 channel_.reset(); | 337 channel_.reset(); |
| 288 audio_render_host_ = NULL; | 338 audio_render_host_ = NULL; |
| 289 audio_input_renderer_host_ = NULL; | 339 audio_input_renderer_host_ = NULL; |
| 290 } | 340 } |
| 291 | 341 |
| 292 void MAYBE_WebRTCAudioDeviceTest::OnGetAudioHardwareConfig( | 342 void MAYBE_WebRTCAudioDeviceTest::OnGetAudioHardwareConfig( |
| 293 AudioParameters* input_params, AudioParameters* output_params) { | 343 AudioParameters* input_params, AudioParameters* output_params) { |
| 294 ASSERT_TRUE(audio_hardware_config_); | 344 ASSERT_TRUE(audio_hardware_config_); |
| 295 *input_params = audio_hardware_config_->GetInputConfig(); | 345 *input_params = audio_hardware_config_->GetInputConfig(); |
| 296 *output_params = audio_hardware_config_->GetOutputConfig(); | 346 *output_params = audio_hardware_config_->GetOutputConfig(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { | 432 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { |
| 383 return network_->ReceivedRTPPacket(channel, data, len); | 433 return network_->ReceivedRTPPacket(channel, data, len); |
| 384 } | 434 } |
| 385 | 435 |
| 386 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, | 436 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, |
| 387 int len) { | 437 int len) { |
| 388 return network_->ReceivedRTCPPacket(channel, data, len); | 438 return network_->ReceivedRTCPPacket(channel, data, len); |
| 389 } | 439 } |
| 390 | 440 |
| 391 } // namespace content | 441 } // namespace content |
| OLD | NEW |