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/renderer/media/audio_device_factory.h" | 5 #include "content/renderer/media/audio_device_factory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/renderer/media/audio_input_message_filter.h" | 8 #include "content/renderer/media/audio_input_message_filter.h" |
| 9 #include "content/renderer/media/audio_message_filter.h" | 9 #include "content/renderer/media/audio_message_filter.h" |
| 10 #include "media/audio/audio_input_device.h" | 10 #include "media/audio/audio_input_device.h" |
| 11 #include "media/audio/audio_output_device.h" | 11 #include "media/audio/audio_output_device.h" |
| 12 #include "url/gurl.h" | |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 // static | 16 // static |
| 16 AudioDeviceFactory* AudioDeviceFactory::factory_ = NULL; | 17 AudioDeviceFactory* AudioDeviceFactory::factory_ = NULL; |
| 17 | 18 |
| 18 // static | 19 // static |
| 19 scoped_refptr<media::AudioOutputDevice> AudioDeviceFactory::NewOutputDevice( | 20 scoped_refptr<media::AudioOutputDevice> AudioDeviceFactory::NewOutputDevice( |
| 20 int render_frame_id) { | 21 int render_frame_id) { |
| 21 if (factory_) { | 22 if (factory_) { |
|
DaleCurtis
2015/09/09 01:31:57
This should just use some dummy params and call th
Guido Urdaneta
2015/09/09 16:22:23
Done.
| |
| 22 media::AudioOutputDevice* const device = | 23 media::AudioOutputDevice* const device = |
| 23 factory_->CreateOutputDevice(render_frame_id); | 24 factory_->CreateOutputDevice(render_frame_id); |
| 24 if (device) | 25 if (device) |
| 25 return device; | 26 return device; |
| 26 } | 27 } |
| 27 | 28 |
| 28 AudioMessageFilter* const filter = AudioMessageFilter::Get(); | 29 AudioMessageFilter* const filter = AudioMessageFilter::Get(); |
| 29 return new media::AudioOutputDevice( | 30 scoped_refptr<media::AudioOutputDevice> device = new media::AudioOutputDevice( |
| 30 filter->CreateAudioOutputIPC(render_frame_id), filter->io_task_runner()); | 31 filter->CreateAudioOutputIPC(render_frame_id), filter->io_task_runner()); |
| 32 device->RequestDeviceAuthorization(); | |
| 33 return device; | |
| 31 } | 34 } |
| 32 | 35 |
| 33 // static | 36 // static |
| 37 scoped_refptr<media::AudioOutputDevice> AudioDeviceFactory::NewOutputDevice( | |
| 38 int render_frame_id, | |
| 39 int session_id) { | |
| 40 if (factory_) { | |
|
DaleCurtis
2015/09/09 01:31:57
Ditto.
Guido Urdaneta
2015/09/09 16:22:23
This one is as deep as the one in l.56.
This one t
| |
| 41 media::AudioOutputDevice* const device = | |
| 42 factory_->CreateOutputDevice(render_frame_id, session_id); | |
| 43 if (device) | |
| 44 return device; | |
| 45 } | |
| 46 | |
| 47 AudioMessageFilter* const filter = AudioMessageFilter::Get(); | |
| 48 scoped_refptr<media::AudioOutputDevice> device = new media::AudioOutputDevice( | |
| 49 filter->CreateAudioOutputIPC(render_frame_id), filter->io_task_runner(), | |
| 50 session_id, std::string(), GURL::EmptyGURL()); | |
| 51 device->RequestDeviceAuthorization(); | |
| 52 return device; | |
| 53 } | |
| 54 | |
| 55 // static | |
| 56 scoped_refptr<media::AudioOutputDevice> AudioDeviceFactory::NewOutputDevice( | |
| 57 int render_frame_id, | |
| 58 const std::string& device_id, | |
| 59 const GURL& security_origin) { | |
| 60 if (factory_) { | |
| 61 media::AudioOutputDevice* const device = factory_->CreateOutputDevice( | |
| 62 render_frame_id, device_id, security_origin); | |
| 63 if (device) | |
| 64 return device; | |
| 65 } | |
| 66 | |
| 67 AudioMessageFilter* const filter = AudioMessageFilter::Get(); | |
| 68 scoped_refptr<media::AudioOutputDevice> device = new media::AudioOutputDevice( | |
| 69 filter->CreateAudioOutputIPC(render_frame_id), filter->io_task_runner(), | |
| 70 0, device_id, security_origin); | |
| 71 device->RequestDeviceAuthorization(); | |
| 72 return device; | |
| 73 } | |
| 74 | |
| 75 // static | |
| 34 scoped_refptr<media::AudioInputDevice> AudioDeviceFactory::NewInputDevice( | 76 scoped_refptr<media::AudioInputDevice> AudioDeviceFactory::NewInputDevice( |
| 35 int render_frame_id) { | 77 int render_frame_id) { |
| 36 if (factory_) { | 78 if (factory_) { |
| 37 media::AudioInputDevice* const device = | 79 media::AudioInputDevice* const device = |
| 38 factory_->CreateInputDevice(render_frame_id); | 80 factory_->CreateInputDevice(render_frame_id); |
| 39 if (device) | 81 if (device) |
| 40 return device; | 82 return device; |
| 41 } | 83 } |
| 42 | 84 |
| 43 AudioInputMessageFilter* const filter = AudioInputMessageFilter::Get(); | 85 AudioInputMessageFilter* const filter = AudioInputMessageFilter::Get(); |
| 44 return new media::AudioInputDevice( | 86 return new media::AudioInputDevice( |
| 45 filter->CreateAudioInputIPC(render_frame_id), filter->io_task_runner()); | 87 filter->CreateAudioInputIPC(render_frame_id), filter->io_task_runner()); |
| 46 } | 88 } |
| 47 | 89 |
| 48 AudioDeviceFactory::AudioDeviceFactory() { | 90 AudioDeviceFactory::AudioDeviceFactory() { |
| 49 DCHECK(!factory_) << "Can't register two factories at once."; | 91 DCHECK(!factory_) << "Can't register two factories at once."; |
| 50 factory_ = this; | 92 factory_ = this; |
| 51 } | 93 } |
| 52 | 94 |
| 53 AudioDeviceFactory::~AudioDeviceFactory() { | 95 AudioDeviceFactory::~AudioDeviceFactory() { |
| 54 factory_ = NULL; | 96 factory_ = NULL; |
| 55 } | 97 } |
| 56 | 98 |
| 57 } // namespace content | 99 } // namespace content |
| OLD | NEW |