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 protected: |
| 102 virtual ~TestAudioRendererHost() {} |
| 103 |
| 104 private: |
| 105 IPC::Channel* channel_; |
| 106 }; |
| 107 |
| 108 class TestAudioInputRendererHost : public AudioInputRendererHost { |
| 109 public: |
| 110 TestAudioInputRendererHost( |
| 111 media::AudioManager* audio_manager, |
| 112 MediaStreamManager* media_stream_manager, |
| 113 AudioMirroringManager* audio_mirroring_manager, |
| 114 media::UserInputMonitor* user_input_monitor, |
| 115 IPC::Channel* channel) |
| 116 : AudioInputRendererHost(audio_manager, media_stream_manager, |
| 117 audio_mirroring_manager, user_input_monitor), |
| 118 channel_(channel) {} |
| 119 virtual bool Send(IPC::Message* message) OVERRIDE { |
| 120 if (channel_) |
| 121 return channel_->Send(message); |
| 122 return false; |
| 123 } |
| 124 void ResetChannel() { |
| 125 channel_ = NULL; |
| 126 } |
| 127 |
| 128 protected: |
| 129 virtual ~TestAudioInputRendererHost() {} |
| 130 |
| 131 private: |
| 132 IPC::Channel* channel_; |
| 133 }; |
| 134 |
80 // Utility scoped class to replace the global content client's renderer for the | 135 // Utility scoped class to replace the global content client's renderer for the |
81 // duration of the test. | 136 // duration of the test. |
82 class ReplaceContentClientRenderer { | 137 class ReplaceContentClientRenderer { |
83 public: | 138 public: |
84 explicit ReplaceContentClientRenderer(ContentRendererClient* new_renderer) { | 139 explicit ReplaceContentClientRenderer(ContentRendererClient* new_renderer) { |
85 saved_renderer_ = SetRendererClientForTesting(new_renderer); | 140 saved_renderer_ = SetRendererClientForTesting(new_renderer); |
86 } | 141 } |
87 ~ReplaceContentClientRenderer() { | 142 ~ReplaceContentClientRenderer() { |
88 // Restore the original renderer. | 143 // Restore the original renderer. |
89 SetRendererClientForTesting(saved_renderer_); | 144 SetRendererClientForTesting(saved_renderer_); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 #if defined(OS_WIN) | 306 #if defined(OS_WIN) |
252 initialize_com_.reset(); | 307 initialize_com_.reset(); |
253 #endif | 308 #endif |
254 | 309 |
255 audio_manager_.reset(); | 310 audio_manager_.reset(); |
256 } | 311 } |
257 | 312 |
258 void MAYBE_WebRTCAudioDeviceTest::CreateChannel(const char* name) { | 313 void MAYBE_WebRTCAudioDeviceTest::CreateChannel(const char* name) { |
259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 314 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
260 | 315 |
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)); | 316 channel_.reset(new IPC::Channel(name, IPC::Channel::MODE_SERVER, this)); |
275 ASSERT_TRUE(channel_->Connect()); | 317 ASSERT_TRUE(channel_->Connect()); |
276 | 318 |
277 audio_render_host_->OnFilterAdded(channel_.get()); | 319 static const int kRenderProcessId = 1; |
278 audio_input_renderer_host_->OnFilterAdded(channel_.get()); | 320 audio_render_host_ = new TestAudioRendererHost( |
| 321 kRenderProcessId, audio_manager_.get(), mirroring_manager_.get(), |
| 322 media_internals_.get(), media_stream_manager_.get(), channel_.get()); |
| 323 audio_render_host_->set_peer_pid_for_testing(base::GetCurrentProcId()); |
| 324 |
| 325 audio_input_renderer_host_ = |
| 326 new TestAudioInputRendererHost(audio_manager_.get(), |
| 327 media_stream_manager_.get(), |
| 328 mirroring_manager_.get(), |
| 329 NULL, |
| 330 channel_.get()); |
| 331 audio_input_renderer_host_->set_peer_pid_for_testing( |
| 332 base::GetCurrentProcId()); |
279 } | 333 } |
280 | 334 |
281 void MAYBE_WebRTCAudioDeviceTest::DestroyChannel() { | 335 void MAYBE_WebRTCAudioDeviceTest::DestroyChannel() { |
282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 336 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
283 audio_render_host_->OnChannelClosing(); | 337 audio_render_host_->OnChannelClosing(); |
284 audio_render_host_->OnFilterRemoved(); | 338 audio_render_host_->OnFilterRemoved(); |
285 audio_input_renderer_host_->OnChannelClosing(); | 339 audio_input_renderer_host_->OnChannelClosing(); |
286 audio_input_renderer_host_->OnFilterRemoved(); | 340 audio_input_renderer_host_->OnFilterRemoved(); |
| 341 audio_render_host_->ResetChannel(); |
| 342 audio_input_renderer_host_->ResetChannel(); |
287 channel_.reset(); | 343 channel_.reset(); |
288 audio_render_host_ = NULL; | 344 audio_render_host_ = NULL; |
289 audio_input_renderer_host_ = NULL; | 345 audio_input_renderer_host_ = NULL; |
290 } | 346 } |
291 | 347 |
292 void MAYBE_WebRTCAudioDeviceTest::OnGetAudioHardwareConfig( | 348 void MAYBE_WebRTCAudioDeviceTest::OnGetAudioHardwareConfig( |
293 AudioParameters* input_params, AudioParameters* output_params) { | 349 AudioParameters* input_params, AudioParameters* output_params) { |
294 ASSERT_TRUE(audio_hardware_config_); | 350 ASSERT_TRUE(audio_hardware_config_); |
295 *input_params = audio_hardware_config_->GetInputConfig(); | 351 *input_params = audio_hardware_config_->GetInputConfig(); |
296 *output_params = audio_hardware_config_->GetOutputConfig(); | 352 *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) { | 438 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { |
383 return network_->ReceivedRTPPacket(channel, data, len); | 439 return network_->ReceivedRTPPacket(channel, data, len); |
384 } | 440 } |
385 | 441 |
386 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, | 442 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, |
387 int len) { | 443 int len) { |
388 return network_->ReceivedRTCPPacket(channel, data, len); | 444 return network_->ReceivedRTCPPacket(channel, data, len); |
389 } | 445 } |
390 | 446 |
391 } // namespace content | 447 } // namespace content |
OLD | NEW |