Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2219)

Side by Side Diff: content/renderer/media/audio_device_factory.h

Issue 1809093003: Moving SwitchOutputDevice out of OutputDevice interface, eliminating OutputDevice (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_sink.h" 14 #include "media/base/output_device_info.h"
15 15
16 namespace media { 16 namespace media {
17 class AudioInputDevice; 17 class AudioRendererSink;
18 class AudioOutputDevice; 18 class SwitchableAudioRendererSink;
19 class AudioCapturerSource;
19 } 20 }
20 21
21 namespace url { 22 namespace url {
22 class Origin; 23 class Origin;
23 } 24 }
24 25
25 namespace content { 26 namespace content {
26 27
27 // A factory for creating AudioOutputDevices and AudioInputDevices. There is a 28 // A factory for creating AudioRendererSinks and AudioCapturerSources. There is
28 // global factory function that can be installed for the purposes of testing to 29 // a global factory function that can be installed for the purposes of testing
29 // provide specialized implementations. 30 // to provide specialized implementations.
31 // TODO(olka): rename it, probably split it into AudioRendererSinkFactory and
32 // AudioCapturerSourceFactory.
30 class CONTENT_EXPORT AudioDeviceFactory { 33 class CONTENT_EXPORT AudioDeviceFactory {
31 public: 34 public:
32 // Types of audio sources. 35 // Types of audio sources.
33 enum SourceType { 36 enum SourceType {
34 kSourceNone = 0, 37 kSourceNone = 0,
35 kSourceMediaElement, 38 kSourceMediaElement,
36 kSourceWebRtc, 39 kSourceWebRtc,
37 kSourceNonRtcAudioTrack, 40 kSourceNonRtcAudioTrack,
38 kSourceWebAudio, 41 kSourceWebAudio,
39 kSourceLast = kSourceWebAudio // Only used for validation of format. 42 kSourceLast = kSourceWebAudio // Only used for validation of format.
40 }; 43 };
41 44
42 // Creates an AudioOutputDevice. 45 // Creates a sink for AudioRendererMixer.
43 // |render_frame_id| refers to the RenderFrame containing the entity 46 // |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 47 // 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 48 // 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| 49 // it exists. If |session_id| is zero, |device_id| and |security_origin|
47 // identify the output device to use. 50 // identify the output device to use.
48 // If |session_id| is zero and |device_id| and |security_origin| are empty, 51 // If |session_id| is zero and |device_id| and |security_origin| are empty,
49 // the default output device will be selected. 52 // the default output device will be selected.
50 static scoped_refptr<media::AudioOutputDevice> NewOutputDevice( 53 static scoped_refptr<media::AudioRendererSink> NewAudioRendererMixerSink(
51 int render_frame_id, 54 int render_frame_id,
52 int session_id, 55 int session_id,
53 const std::string& device_id, 56 const std::string& device_id,
54 const url::Origin& security_origin); 57 const url::Origin& security_origin);
55 58
56 // Creates an AudioRendererSink bound to an AudioOutputDevice. 59 // Creates an AudioRendererSink bound to an AudioOutputDevice.
57 // Basing on |source_type| and build configuration, audio played out through 60 // 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. 61 // 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 62 // TODO(olka): merge it with NewRestartableOutputDevice() as soon as
60 // AudioOutputDevice is fixed to be restartable. 63 // AudioOutputDevice is fixed to be restartable.
61 static scoped_refptr<media::AudioRendererSink> NewAudioRendererSink( 64 static scoped_refptr<media::AudioRendererSink> NewAudioRendererSink(
62 SourceType source_type, 65 SourceType source_type,
63 int render_frame_id, 66 int render_frame_id,
64 int session_id, 67 int session_id,
65 const std::string& device_id, 68 const std::string& device_id,
66 const url::Origin& security_origin); 69 const url::Origin& security_origin);
67 70
68 // Creates a RestartableAudioRendererSink bound to an AudioOutputDevice 71 // Creates a SwitchableAudioRendererSink bound to an AudioOutputDevice
69 // Basing on |source_type| and build configuration, audio played out through 72 // Basing on |source_type| and build configuration, audio played out through
70 // the sink goes to AOD directly or can be mixed with other audio before that. 73 // the sink goes to AOD directly or can be mixed with other audio before that.
71 static scoped_refptr<media::RestartableAudioRendererSink> 74 static scoped_refptr<media::SwitchableAudioRendererSink>
72 NewRestartableAudioRendererSink(SourceType source_type, 75 NewSwitchableAudioRendererSink(SourceType source_type,
73 int render_frame_id, 76 int render_frame_id,
74 int session_id, 77 int session_id,
75 const std::string& device_id, 78 const std::string& device_id,
76 const url::Origin& security_origin); 79 const url::Origin& security_origin);
77 80
78 // A helper to get HW device status in the absence of AudioOutputDevice. 81 // A helper to get device info in the absence of AudioOutputDevice.
79 static media::OutputDeviceStatus GetOutputDeviceStatus( 82 static media::OutputDeviceInfo GetOutputDeviceInfo(
80 int render_frame_id, 83 int render_frame_id,
81 int session_id, 84 int session_id,
82 const std::string& device_id, 85 const std::string& device_id,
83 const url::Origin& security_origin); 86 const url::Origin& security_origin);
84 87
85 // Creates an AudioInputDevice using the currently registered factory. 88 // Creates an AudioCapturerSource using the currently registered factory.
86 // |render_frame_id| refers to the RenderFrame containing the entity 89 // |render_frame_id| refers to the RenderFrame containing the entity
87 // consuming the audio. 90 // consuming the audio.
88 static scoped_refptr<media::AudioInputDevice> NewInputDevice( 91 static scoped_refptr<media::AudioCapturerSource> NewAudioCapturerSource(
89 int render_frame_id); 92 int render_frame_id);
90 93
91 protected: 94 protected:
92 AudioDeviceFactory(); 95 AudioDeviceFactory();
93 virtual ~AudioDeviceFactory(); 96 virtual ~AudioDeviceFactory();
94 97
95 // You can derive from this class and specify an implementation for these 98 // You can derive from this class and specify an implementation for these
96 // functions to provide alternate audio device implementations. 99 // functions to provide alternate audio device implementations.
97 // If the return value of either of these function is NULL, we fall back 100 // If the return value of either of these function is NULL, we fall back
98 // on the default implementation. 101 // on the default implementation.
99 virtual media::AudioOutputDevice* CreateOutputDevice( 102 virtual scoped_refptr<media::AudioRendererSink> CreateAudioRendererMixerSink(
100 int render_frame_id, 103 int render_frame_id,
101 int sesssion_id, 104 int sesssion_id,
102 const std::string& device_id, 105 const std::string& device_id,
103 const url::Origin& security_origin) = 0; 106 const url::Origin& security_origin) = 0;
104 107
105 virtual media::AudioRendererSink* CreateAudioRendererSink( 108 virtual scoped_refptr<media::AudioRendererSink> CreateAudioRendererSink(
106 SourceType source_type, 109 SourceType source_type,
107 int render_frame_id, 110 int render_frame_id,
108 int sesssion_id, 111 int sesssion_id,
109 const std::string& device_id, 112 const std::string& device_id,
110 const url::Origin& security_origin) = 0; 113 const url::Origin& security_origin) = 0;
111 114
112 virtual media::RestartableAudioRendererSink* 115 virtual scoped_refptr<media::SwitchableAudioRendererSink>
113 CreateRestartableAudioRendererSink(SourceType source_type, 116 CreateSwitchableAudioRendererSink(SourceType source_type,
114 int render_frame_id, 117 int render_frame_id,
115 int sesssion_id, 118 int sesssion_id,
116 const std::string& device_id, 119 const std::string& device_id,
117 const url::Origin& security_origin) = 0; 120 const url::Origin& security_origin) = 0;
118 121
119 virtual media::AudioInputDevice* CreateInputDevice(int render_frame_id) = 0; 122 virtual scoped_refptr<media::AudioCapturerSource> CreateAudioCapturerSource(
123 int render_frame_id) = 0;
120 124
121 private: 125 private:
122 // The current globally registered factory. This is NULL when we should 126 // The current globally registered factory. This is NULL when we should
123 // create the default AudioRendererSinks. 127 // create the default AudioRendererSinks.
124 static AudioDeviceFactory* factory_; 128 static AudioDeviceFactory* factory_;
125 129
126 DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory); 130 DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory);
127 }; 131 };
128 132
129 } // namespace content 133 } // namespace content
130 134
131 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_ 135 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
OLDNEW
« no previous file with comments | « content/public/renderer/media_stream_audio_renderer.h ('k') | content/renderer/media/audio_device_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698