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

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

Issue 1666363005: Switching audio clients to using RestartableAudioRendererSink interface as a sink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: export fix Created 4 years, 10 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 15
15 namespace media { 16 namespace media {
16 class AudioInputDevice; 17 class AudioInputDevice;
17 class AudioOutputDevice; 18 class AudioOutputDevice;
18 } 19 }
19 20
20 namespace url { 21 namespace url {
21 class Origin; 22 class Origin;
22 } 23 }
23 24
24 namespace content { 25 namespace content {
25 26
26 // A factory for creating AudioOutputDevices and AudioInputDevices. There is a 27 // A factory for creating AudioOutputDevices and AudioInputDevices. There is a
27 // 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
28 // provide specialized implementations. 29 // provide specialized implementations.
29 class CONTENT_EXPORT AudioDeviceFactory { 30 class CONTENT_EXPORT AudioDeviceFactory {
30 public: 31 public:
32 // Types of audio sources.
33 enum SourceType {
34 kSourceNone = 0,
35 kSourceHighLatency,
36 kSourceWebRTC,
37 kSourceLocalUserMedia,
38 kSourceWebAudio,
Henrik Grunell 2016/02/11 12:01:26 When the categories or explicit latencies for WebA
o1ka 2016/02/11 17:18:23 renamed
39 kSourceLast = kSourceWebAudio // Only used for validation of format.
40 };
41
31 // Creates an AudioOutputDevice. 42 // Creates an AudioOutputDevice.
32 // |render_frame_id| refers to the RenderFrame containing the entity 43 // |render_frame_id| refers to the RenderFrame containing the entity
33 // 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
34 // 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
35 // 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|
36 // identify the output device to use. 47 // identify the output device to use.
37 // 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,
38 // the default output device will be selected. 49 // the default output device will be selected.
39 static scoped_refptr<media::AudioOutputDevice> NewOutputDevice( 50 static scoped_refptr<media::AudioOutputDevice> NewOutputDevice(
40 int render_frame_id, 51 int render_frame_id,
41 int session_id, 52 int session_id,
42 const std::string& device_id, 53 const std::string& device_id,
43 const url::Origin& security_origin); 54 const url::Origin& security_origin);
44 55
56 // Creates an AudioRendererSink bound to an AudioOutputDevice.
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.
59 // TODO(olka): merge it with NewRestartableOutputDevice() as soon as
60 // AudioOutputDevice is fixed to be restartable.
61 static scoped_refptr<media::AudioRendererSink> NewOutputDevice(
DaleCurtis 2016/02/10 23:25:33 Can you give this a different name? We should avoi
Henrik Grunell 2016/02/11 12:01:26 Maybe simply call it NewAudioRendererSink? (That's
o1ka 2016/02/11 17:18:23 Done.
62 SourceType source_type,
63 int render_frame_id,
64 int session_id,
65 const std::string& device_id,
66 const url::Origin& security_origin);
67
68 // Creates a RestartableAudioRendererSink bound to an AudioOutputDevice
69 // 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.
71 static scoped_refptr<media::RestartableAudioRendererSink>
72 NewRestartableOutputDevice(SourceType source_type,
Henrik Grunell 2016/02/11 12:01:26 Name it NewRestartableAudioRendererSink, assuming
o1ka 2016/02/11 17:18:23 Done.
73 int render_frame_id,
74 int session_id,
75 const std::string& device_id,
76 const url::Origin& security_origin);
77
78 // A helper to get HW device status in the absence of AudioOutputDevice.
Henrik Grunell 2016/02/11 12:01:26 Nit: HW -> hardware
o1ka 2016/02/11 17:18:23 Done.
79 static media::OutputDeviceStatus GetOutputDeviceStatus(
80 int render_frame_id,
81 int session_id,
82 const std::string& device_id,
83 const url::Origin& security_origin);
84
45 // Creates an AudioInputDevice using the currently registered factory. 85 // Creates an AudioInputDevice using the currently registered factory.
46 // |render_frame_id| refers to the RenderFrame containing the entity 86 // |render_frame_id| refers to the RenderFrame containing the entity
47 // consuming the audio. 87 // consuming the audio.
48 static scoped_refptr<media::AudioInputDevice> NewInputDevice( 88 static scoped_refptr<media::AudioInputDevice> NewInputDevice(
49 int render_frame_id); 89 int render_frame_id);
50 90
51 protected: 91 protected:
52 AudioDeviceFactory(); 92 AudioDeviceFactory();
53 virtual ~AudioDeviceFactory(); 93 virtual ~AudioDeviceFactory();
54 94
55 // 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
56 // functions to provide alternate audio device implementations. 96 // functions to provide alternate audio device implementations.
57 // 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
58 // on the default implementation. 98 // on the default implementation.
59 virtual media::AudioOutputDevice* CreateOutputDevice( 99 virtual media::AudioOutputDevice* CreateOutputDevice(
60 int render_frame_id, 100 int render_frame_id,
61 int sesssion_id, 101 int sesssion_id,
62 const std::string& device_id, 102 const std::string& device_id,
63 const url::Origin& security_origin) = 0; 103 const url::Origin& security_origin) = 0;
104
105 virtual media::AudioRendererSink* CreateOutputDevice(
Henrik Grunell 2016/02/11 12:01:26 Change name according to the public versions if th
o1ka 2016/02/11 17:18:23 Done.
106 SourceType source_type,
107 int render_frame_id,
108 int sesssion_id,
109 const std::string& device_id,
110 const url::Origin& security_origin) = 0;
111
112 virtual media::RestartableAudioRendererSink* CreateRestartableOutputDevice(
113 SourceType source_type,
114 int render_frame_id,
115 int sesssion_id,
116 const std::string& device_id,
117 const url::Origin& security_origin) = 0;
118
64 virtual media::AudioInputDevice* CreateInputDevice(int render_frame_id) = 0; 119 virtual media::AudioInputDevice* CreateInputDevice(int render_frame_id) = 0;
65 120
66 private: 121 private:
67 // The current globally registered factory. This is NULL when we should 122 // The current globally registered factory. This is NULL when we should
68 // create the default AudioRendererSinks. 123 // create the default AudioRendererSinks.
69 static AudioDeviceFactory* factory_; 124 static AudioDeviceFactory* factory_;
70 125
71 DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory); 126 DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory);
72 }; 127 };
73 128
74 } // namespace content 129 } // namespace content
75 130
76 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_ 131 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/audio_device_factory.cc » ('j') | content/renderer/media/audio_device_factory.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698