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 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_ | 6 #define CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "media/base/audio_renderer_mixer_sink.h" | |
| 14 #include "media/base/audio_renderer_sink.h" | 15 #include "media/base/audio_renderer_sink.h" |
| 15 | 16 |
| 16 namespace media { | 17 namespace media { |
| 17 class AudioInputDevice; | 18 class AudioInputDevice; |
| 18 class AudioOutputDevice; | |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace url { | 21 namespace url { |
| 22 class Origin; | 22 class Origin; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 | 26 |
| 27 // A factory for creating AudioOutputDevices and AudioInputDevices. There is a | 27 // A factory for creating AudioOutputDevices and AudioInputDevices. There is a |
| 28 // global factory function that can be installed for the purposes of testing to | 28 // global factory function that can be installed for the purposes of testing to |
| 29 // provide specialized implementations. | 29 // provide specialized implementations. |
| 30 class CONTENT_EXPORT AudioDeviceFactory { | 30 class CONTENT_EXPORT AudioDeviceFactory { |
| 31 public: | 31 public: |
| 32 // Types of audio sources. | 32 // Types of audio sources. |
| 33 enum SourceType { | 33 enum SourceType { |
| 34 kSourceNone = 0, | 34 kSourceNone = 0, |
| 35 kSourceMediaElement, | 35 kSourceMediaElement, |
| 36 kSourceWebRtc, | 36 kSourceWebRtc, |
| 37 kSourceNonRtcAudioTrack, | 37 kSourceNonRtcAudioTrack, |
| 38 kSourceWebAudio, | 38 kSourceWebAudio, |
| 39 kSourceLast = kSourceWebAudio // Only used for validation of format. | 39 kSourceLast = kSourceWebAudio // Only used for validation of format. |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 // Creates an AudioOutputDevice. | 42 // Creates a sink for AudioRemdererMixer. |
|
Guido Urdaneta
2016/03/08 14:53:09
typo: s/Remderer/Renderer
o1ka
2016/04/05 15:13:37
Done.
| |
| 43 // |render_frame_id| refers to the RenderFrame containing the entity | 43 // |render_frame_id| refers to the RenderFrame containing the entity |
| 44 // producing the audio. If |session_id| is nonzero, it is used by the browser | 44 // producing the audio. If |session_id| is nonzero, it is used by the browser |
| 45 // to select the correct input device ID and its associated output device, if | 45 // to select the correct input device ID and its associated output device, if |
| 46 // it exists. If |session_id| is zero, |device_id| and |security_origin| | 46 // it exists. If |session_id| is zero, |device_id| and |security_origin| |
| 47 // identify the output device to use. | 47 // identify the output device to use. |
| 48 // If |session_id| is zero and |device_id| and |security_origin| are empty, | 48 // If |session_id| is zero and |device_id| and |security_origin| are empty, |
| 49 // the default output device will be selected. | 49 // the default output device will be selected. |
| 50 static scoped_refptr<media::AudioOutputDevice> NewOutputDevice( | 50 static scoped_refptr<media::AudioRendererMixerSink> NewAudioRendererMixerSink( |
| 51 int render_frame_id, | 51 int render_frame_id, |
| 52 int session_id, | 52 int session_id, |
| 53 const std::string& device_id, | 53 const std::string& device_id, |
| 54 const url::Origin& security_origin); | 54 const url::Origin& security_origin); |
| 55 | 55 |
| 56 // Creates an AudioRendererSink bound to an AudioOutputDevice. | 56 // Creates an AudioRendererSink bound to an AudioOutputDevice. |
| 57 // Basing on |source_type| and build configuration, audio played out through | 57 // Basing on |source_type| and build configuration, audio played out through |
| 58 // the sink goes to AOD directly or can be mixed with other audio before that. | 58 // the sink goes to AOD directly or can be mixed with other audio before that. |
| 59 // TODO(olka): merge it with NewRestartableOutputDevice() as soon as | 59 // TODO(olka): merge it with NewRestartableOutputDevice() as soon as |
| 60 // AudioOutputDevice is fixed to be restartable. | 60 // AudioOutputDevice is fixed to be restartable. |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 89 int render_frame_id); | 89 int render_frame_id); |
| 90 | 90 |
| 91 protected: | 91 protected: |
| 92 AudioDeviceFactory(); | 92 AudioDeviceFactory(); |
| 93 virtual ~AudioDeviceFactory(); | 93 virtual ~AudioDeviceFactory(); |
| 94 | 94 |
| 95 // You can derive from this class and specify an implementation for these | 95 // You can derive from this class and specify an implementation for these |
| 96 // functions to provide alternate audio device implementations. | 96 // functions to provide alternate audio device implementations. |
| 97 // If the return value of either of these function is NULL, we fall back | 97 // If the return value of either of these function is NULL, we fall back |
| 98 // on the default implementation. | 98 // on the default implementation. |
| 99 virtual media::AudioOutputDevice* CreateOutputDevice( | 99 virtual media::AudioRendererMixerSink* CreateAudioRendererMixerSink( |
| 100 int render_frame_id, | 100 int render_frame_id, |
| 101 int sesssion_id, | 101 int sesssion_id, |
| 102 const std::string& device_id, | 102 const std::string& device_id, |
| 103 const url::Origin& security_origin) = 0; | 103 const url::Origin& security_origin) = 0; |
| 104 | 104 |
| 105 virtual media::AudioRendererSink* CreateAudioRendererSink( | 105 virtual media::AudioRendererSink* CreateAudioRendererSink( |
| 106 SourceType source_type, | 106 SourceType source_type, |
| 107 int render_frame_id, | 107 int render_frame_id, |
| 108 int sesssion_id, | 108 int sesssion_id, |
| 109 const std::string& device_id, | 109 const std::string& device_id, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 122 // The current globally registered factory. This is NULL when we should | 122 // The current globally registered factory. This is NULL when we should |
| 123 // create the default AudioRendererSinks. | 123 // create the default AudioRendererSinks. |
| 124 static AudioDeviceFactory* factory_; | 124 static AudioDeviceFactory* factory_; |
| 125 | 125 |
| 126 DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory); | 126 DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory); |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 } // namespace content | 129 } // namespace content |
| 130 | 130 |
| 131 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_ | 131 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_ |
| OLD | NEW |