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

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: Replace RestartableAudioRendererSink with SwitchableAudioRendererSink in webmediaplayer_impl unit t… Created 4 years, 9 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/audio_renderer_sink.h"
15 15
16 namespace media { 16 namespace media {
17 class AudioInputDevice; 17 class AudioInputDevice;
18 class AudioOutputDevice;
19 } 18 }
20 19
21 namespace url { 20 namespace url {
22 class Origin; 21 class Origin;
23 } 22 }
24 23
25 namespace content { 24 namespace content {
26 25
27 // A factory for creating AudioOutputDevices and AudioInputDevices. There is a 26 // A factory for creating AudioOutputDevices and AudioInputDevices. There is a
28 // global factory function that can be installed for the purposes of testing to 27 // global factory function that can be installed for the purposes of testing to
29 // provide specialized implementations. 28 // provide specialized implementations.
30 class CONTENT_EXPORT AudioDeviceFactory { 29 class CONTENT_EXPORT AudioDeviceFactory {
31 public: 30 public:
32 // Types of audio sources. 31 // Types of audio sources.
33 enum SourceType { 32 enum SourceType {
34 kSourceNone = 0, 33 kSourceNone = 0,
35 kSourceMediaElement, 34 kSourceMediaElement,
36 kSourceWebRtc, 35 kSourceWebRtc,
37 kSourceNonRtcAudioTrack, 36 kSourceNonRtcAudioTrack,
38 kSourceWebAudio, 37 kSourceWebAudio,
39 kSourceLast = kSourceWebAudio // Only used for validation of format. 38 kSourceLast = kSourceWebAudio // Only used for validation of format.
40 }; 39 };
41 40
42 // Creates an AudioOutputDevice. 41 // Creates a sink for AudioRendererMixer.
43 // |render_frame_id| refers to the RenderFrame containing the entity 42 // |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 43 // 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 44 // 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| 45 // it exists. If |session_id| is zero, |device_id| and |security_origin|
47 // identify the output device to use. 46 // identify the output device to use.
48 // If |session_id| is zero and |device_id| and |security_origin| are empty, 47 // If |session_id| is zero and |device_id| and |security_origin| are empty,
49 // the default output device will be selected. 48 // the default output device will be selected.
50 static scoped_refptr<media::AudioOutputDevice> NewOutputDevice( 49 static scoped_refptr<media::AudioRendererSink> NewAudioRendererMixerSink(
51 int render_frame_id, 50 int render_frame_id,
52 int session_id, 51 int session_id,
53 const std::string& device_id, 52 const std::string& device_id,
54 const url::Origin& security_origin); 53 const url::Origin& security_origin);
55 54
56 // Creates an AudioRendererSink bound to an AudioOutputDevice. 55 // Creates an AudioRendererSink bound to an AudioOutputDevice.
57 // Basing on |source_type| and build configuration, audio played out through 56 // 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. 57 // 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 58 // TODO(olka): merge it with NewRestartableOutputDevice() as soon as
60 // AudioOutputDevice is fixed to be restartable. 59 // AudioOutputDevice is fixed to be restartable.
61 static scoped_refptr<media::AudioRendererSink> NewAudioRendererSink( 60 static scoped_refptr<media::AudioRendererSink> NewAudioRendererSink(
62 SourceType source_type, 61 SourceType source_type,
63 int render_frame_id, 62 int render_frame_id,
64 int session_id, 63 int session_id,
65 const std::string& device_id, 64 const std::string& device_id,
66 const url::Origin& security_origin); 65 const url::Origin& security_origin);
67 66
68 // Creates a RestartableAudioRendererSink bound to an AudioOutputDevice 67 // Creates a RestartableAudioRendererSink bound to an AudioOutputDevice
Guido Urdaneta 2016/03/17 17:38:24 s/Restartable/Switchable
o1ka 2016/03/18 10:45:40 Done.
69 // Basing on |source_type| and build configuration, audio played out through 68 // 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. 69 // the sink goes to AOD directly or can be mixed with other audio before that.
71 static scoped_refptr<media::RestartableAudioRendererSink> 70 static scoped_refptr<media::SwitchableAudioRendererSink>
72 NewRestartableAudioRendererSink(SourceType source_type, 71 NewSwitchableAudioRendererSink(SourceType source_type,
73 int render_frame_id, 72 int render_frame_id,
74 int session_id, 73 int session_id,
75 const std::string& device_id, 74 const std::string& device_id,
76 const url::Origin& security_origin); 75 const url::Origin& security_origin);
77 76
78 // A helper to get HW device status in the absence of AudioOutputDevice. 77 // A helper to get HW device status in the absence of AudioOutputDevice.
79 static media::OutputDeviceStatus GetOutputDeviceStatus( 78 static media::OutputDeviceStatus GetOutputDeviceStatus(
80 int render_frame_id, 79 int render_frame_id,
81 int session_id, 80 int session_id,
82 const std::string& device_id, 81 const std::string& device_id,
83 const url::Origin& security_origin); 82 const url::Origin& security_origin);
84 83
85 // Creates an AudioInputDevice using the currently registered factory. 84 // Creates an AudioInputDevice using the currently registered factory.
86 // |render_frame_id| refers to the RenderFrame containing the entity 85 // |render_frame_id| refers to the RenderFrame containing the entity
87 // consuming the audio. 86 // consuming the audio.
88 static scoped_refptr<media::AudioInputDevice> NewInputDevice( 87 static scoped_refptr<media::AudioInputDevice> NewInputDevice(
89 int render_frame_id); 88 int render_frame_id);
90 89
91 protected: 90 protected:
92 AudioDeviceFactory(); 91 AudioDeviceFactory();
93 virtual ~AudioDeviceFactory(); 92 virtual ~AudioDeviceFactory();
94 93
95 // You can derive from this class and specify an implementation for these 94 // You can derive from this class and specify an implementation for these
96 // functions to provide alternate audio device implementations. 95 // functions to provide alternate audio device implementations.
97 // If the return value of either of these function is NULL, we fall back 96 // If the return value of either of these function is NULL, we fall back
98 // on the default implementation. 97 // on the default implementation.
99 virtual media::AudioOutputDevice* CreateOutputDevice( 98 virtual media::AudioRendererSink* CreateAudioRendererMixerSink(
100 int render_frame_id, 99 int render_frame_id,
101 int sesssion_id, 100 int sesssion_id,
102 const std::string& device_id, 101 const std::string& device_id,
103 const url::Origin& security_origin) = 0; 102 const url::Origin& security_origin) = 0;
104 103
105 virtual media::AudioRendererSink* CreateAudioRendererSink( 104 virtual media::AudioRendererSink* CreateAudioRendererSink(
106 SourceType source_type, 105 SourceType source_type,
107 int render_frame_id, 106 int render_frame_id,
108 int sesssion_id, 107 int sesssion_id,
109 const std::string& device_id, 108 const std::string& device_id,
110 const url::Origin& security_origin) = 0; 109 const url::Origin& security_origin) = 0;
111 110
112 virtual media::RestartableAudioRendererSink* 111 virtual media::SwitchableAudioRendererSink* CreateSwitchableAudioRendererSink(
113 CreateRestartableAudioRendererSink(SourceType source_type, 112 SourceType source_type,
114 int render_frame_id, 113 int render_frame_id,
115 int sesssion_id, 114 int sesssion_id,
116 const std::string& device_id, 115 const std::string& device_id,
117 const url::Origin& security_origin) = 0; 116 const url::Origin& security_origin) = 0;
118 117
119 virtual media::AudioInputDevice* CreateInputDevice(int render_frame_id) = 0; 118 virtual media::AudioInputDevice* CreateInputDevice(int render_frame_id) = 0;
120 119
121 private: 120 private:
122 // The current globally registered factory. This is NULL when we should 121 // The current globally registered factory. This is NULL when we should
123 // create the default AudioRendererSinks. 122 // create the default AudioRendererSinks.
124 static AudioDeviceFactory* factory_; 123 static AudioDeviceFactory* factory_;
125 124
126 DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory); 125 DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory);
127 }; 126 };
128 127
129 } // namespace content 128 } // namespace content
130 129
131 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_ 130 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698