OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_RENDERER_MEDIA_RESTARTABLE_AUDIO_OUTPUT_DEVICE_FACTORY_H_ | |
6 #define CONTENT_RENDERER_MEDIA_RESTARTABLE_AUDIO_OUTPUT_DEVICE_FACTORY_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/macros.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "content/common/content_export.h" | |
14 #include "media/audio/audio_parameters.h" | |
15 #include "media/base/audio_renderer_sink.h" | |
16 | |
17 namespace media { | |
18 class RestartableAudioOutputDevice; | |
19 } | |
20 | |
21 namespace url { | |
22 class Origin; | |
23 } | |
24 | |
25 namespace content { | |
26 | |
27 // A factory for creating RestartableAudioOutputDevice. | |
28 // There is a global factory function that can be installed for the purposes of | |
29 // testing to provide specialized implementations. | |
30 class CONTENT_EXPORT RestartableAudioOutputDeviceFactory { | |
DaleCurtis
2016/02/08 19:10:25
Should we just make these new methods on the exist
o1ka
2016/02/09 14:15:38
Done.
| |
31 public: | |
32 enum SourceType { | |
33 kSourceHighLatency = 0, | |
34 kSourceWebRTC, | |
35 kSourceLocalUserMedia, | |
36 kSourceWebAudio, | |
37 kSourceLast = kSourceWebAudio // Only used for validation of format. | |
38 }; | |
39 | |
40 // Creates an RestartableAudioOutputDevice. | |
41 // |render_frame_id| refers to the RenderFrame containing the entity | |
42 // producing the audio. If |session_id| is nonzero, it is used by the browser | |
43 // to select the correct input device ID and its associated output device, if | |
44 // it exists. If |session_id| is zero, |device_id| and |security_origin| | |
45 // identify the output device to use. | |
46 // If |session_id| is zero and |device_id| and |security_origin| are empty, | |
47 // the default output device will be selected. | |
48 static scoped_refptr<media::RestartableAudioRendererSink> NewOutputDevice( | |
49 SourceType source_type, | |
50 int render_frame_id, | |
51 int session_id, | |
52 const std::string& device_id, | |
53 const url::Origin& security_origin); | |
54 | |
55 // TODO(olka): find a better home for this function. | |
56 // A helper to get output HW parameters in the absence of AudioOutputDevice. | |
57 static media::AudioParameters GetOutputHWParams( | |
58 int render_frame_id, | |
59 int session_id, | |
60 const std::string& device_id, | |
61 const url::Origin& security_origin); | |
62 | |
63 protected: | |
64 RestartableAudioOutputDeviceFactory(); | |
65 virtual ~RestartableAudioOutputDeviceFactory(); | |
66 | |
67 // You can derive from this class and specify an implementation for this | |
68 // function to provide alternate restartable audio output device | |
69 // implementations. If the return value of this function is NULL, we fall back | |
70 // on the default implementation. | |
71 virtual media::RestartableAudioRendererSink* CreateOutputDevice( | |
72 SourceType source_type, | |
73 int render_frame_id, | |
74 int sesssion_id, | |
75 const std::string& device_id, | |
76 const url::Origin& security_origin) = 0; | |
77 | |
78 private: | |
79 // The current globally registered factory. This is NULL when we should | |
80 // create the default AudioRendererSinks. | |
81 static RestartableAudioOutputDeviceFactory* factory_; | |
82 | |
83 DISALLOW_COPY_AND_ASSIGN(RestartableAudioOutputDeviceFactory); | |
84 }; | |
85 | |
86 } // namespace content | |
87 | |
88 #endif // CONTENT_RENDERER_MEDIA_RESTARTABLE_AUDIO_OUTPUT_DEVICE_FACTORY_H_ | |
OLD | NEW |