| 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 "content/renderer/media/audio_renderer_mixer_manager.h" | 10 #include "content/renderer/media/audio_renderer_mixer_manager.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 if (source_type == AudioDeviceFactory::kSourceMediaElement) | 40 if (source_type == AudioDeviceFactory::kSourceMediaElement) |
| 41 return true; // Must ALWAYS go through mixer. | 41 return true; // Must ALWAYS go through mixer. |
| 42 | 42 |
| 43 // TODO(olka): make a decision for the rest of the sources basing on OS | 43 // TODO(olka): make a decision for the rest of the sources basing on OS |
| 44 // type and configuration parameters. | 44 // type and configuration parameters. |
| 45 return false; | 45 return false; |
| 46 } | 46 } |
| 47 | 47 |
| 48 scoped_refptr<media::SwitchableAudioRendererSink> NewMixableSink( | 48 scoped_refptr<media::SwitchableAudioRendererSink> NewMixableSink( |
| 49 int render_frame_id, | 49 int render_frame_id, |
| 50 int session_id, |
| 50 const std::string& device_id, | 51 const std::string& device_id, |
| 51 const url::Origin& security_origin) { | 52 const url::Origin& security_origin) { |
| 52 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 53 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 53 return scoped_refptr<media::AudioRendererMixerInput>( | 54 return scoped_refptr<media::AudioRendererMixerInput>( |
| 54 render_thread->GetAudioRendererMixerManager()->CreateInput( | 55 render_thread->GetAudioRendererMixerManager()->CreateInput( |
| 55 render_frame_id, device_id, security_origin)); | 56 render_frame_id, session_id, device_id, security_origin)); |
| 56 } | 57 } |
| 57 | 58 |
| 58 scoped_refptr<media::AudioRendererSink> NewUnmixableSink( | 59 scoped_refptr<media::AudioRendererSink> NewUnmixableSink( |
| 59 int render_frame_id, | 60 int render_frame_id, |
| 60 int session_id, | 61 int session_id, |
| 61 const std::string& device_id, | 62 const std::string& device_id, |
| 62 const url::Origin& security_origin) { | 63 const url::Origin& security_origin) { |
| 63 return NewOutputDevice(render_frame_id, session_id, device_id, | 64 return NewOutputDevice(render_frame_id, session_id, device_id, |
| 64 security_origin); | 65 security_origin); |
| 65 } | 66 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 93 if (factory_) { | 94 if (factory_) { |
| 94 scoped_refptr<media::AudioRendererSink> device = | 95 scoped_refptr<media::AudioRendererSink> device = |
| 95 factory_->CreateAudioRendererSink(source_type, render_frame_id, | 96 factory_->CreateAudioRendererSink(source_type, render_frame_id, |
| 96 session_id, device_id, | 97 session_id, device_id, |
| 97 security_origin); | 98 security_origin); |
| 98 if (device) | 99 if (device) |
| 99 return device; | 100 return device; |
| 100 } | 101 } |
| 101 | 102 |
| 102 if (IsMixable(source_type)) | 103 if (IsMixable(source_type)) |
| 103 return NewMixableSink(render_frame_id, device_id, security_origin); | 104 return NewMixableSink(render_frame_id, session_id, device_id, |
| 105 security_origin); |
| 104 | 106 |
| 105 return NewUnmixableSink(render_frame_id, session_id, device_id, | 107 return NewUnmixableSink(render_frame_id, session_id, device_id, |
| 106 security_origin); | 108 security_origin); |
| 107 } | 109 } |
| 108 | 110 |
| 109 // static | 111 // static |
| 110 scoped_refptr<media::SwitchableAudioRendererSink> | 112 scoped_refptr<media::SwitchableAudioRendererSink> |
| 111 AudioDeviceFactory::NewSwitchableAudioRendererSink( | 113 AudioDeviceFactory::NewSwitchableAudioRendererSink( |
| 112 SourceType source_type, | 114 SourceType source_type, |
| 113 int render_frame_id, | 115 int render_frame_id, |
| 114 int session_id, | 116 int session_id, |
| 115 const std::string& device_id, | 117 const std::string& device_id, |
| 116 const url::Origin& security_origin) { | 118 const url::Origin& security_origin) { |
| 117 if (factory_) { | 119 if (factory_) { |
| 118 scoped_refptr<media::SwitchableAudioRendererSink> sink = | 120 scoped_refptr<media::SwitchableAudioRendererSink> sink = |
| 119 factory_->CreateSwitchableAudioRendererSink(source_type, | 121 factory_->CreateSwitchableAudioRendererSink(source_type, |
| 120 render_frame_id, session_id, | 122 render_frame_id, session_id, |
| 121 device_id, security_origin); | 123 device_id, security_origin); |
| 122 if (sink) | 124 if (sink) |
| 123 return sink; | 125 return sink; |
| 124 } | 126 } |
| 125 | 127 |
| 126 if (IsMixable(source_type)) | 128 if (IsMixable(source_type)) |
| 127 return NewMixableSink(render_frame_id, device_id, security_origin); | 129 return NewMixableSink(render_frame_id, session_id, device_id, |
| 130 security_origin); |
| 128 | 131 |
| 129 // AudioOutputDevice is not RestartableAudioRendererSink, so we can't return | 132 // AudioOutputDevice is not RestartableAudioRendererSink, so we can't return |
| 130 // anything for those who wants to create an unmixable sink. | 133 // anything for those who wants to create an unmixable sink. |
| 131 NOTIMPLEMENTED(); | 134 NOTIMPLEMENTED(); |
| 132 return nullptr; | 135 return nullptr; |
| 133 } | 136 } |
| 134 | 137 |
| 135 // static | 138 // static |
| 136 scoped_refptr<media::AudioCapturerSource> | 139 scoped_refptr<media::AudioCapturerSource> |
| 137 AudioDeviceFactory::NewAudioCapturerSource(int render_frame_id) { | 140 AudioDeviceFactory::NewAudioCapturerSource(int render_frame_id) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 166 AudioDeviceFactory::AudioDeviceFactory() { | 169 AudioDeviceFactory::AudioDeviceFactory() { |
| 167 DCHECK(!factory_) << "Can't register two factories at once."; | 170 DCHECK(!factory_) << "Can't register two factories at once."; |
| 168 factory_ = this; | 171 factory_ = this; |
| 169 } | 172 } |
| 170 | 173 |
| 171 AudioDeviceFactory::~AudioDeviceFactory() { | 174 AudioDeviceFactory::~AudioDeviceFactory() { |
| 172 factory_ = NULL; | 175 factory_ = NULL; |
| 173 } | 176 } |
| 174 | 177 |
| 175 } // namespace content | 178 } // namespace content |
| OLD | NEW |