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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
6 #define CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
13 #include "content/common/content_export.h"
16 class AudioInputDevice
;
17 class AudioOutputDevice
;
26 // 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 // provide specialized implementations.
29 class CONTENT_EXPORT AudioDeviceFactory
{
31 // Creates an AudioOutputDevice.
32 // |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
34 // 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|
36 // identify the output device to use.
37 // If |session_id| is zero and |device_id| and |security_origin| are empty,
38 // the default output device will be selected.
39 static scoped_refptr
<media::AudioOutputDevice
> NewOutputDevice(
42 const std::string
& device_id
,
43 const url::Origin
& security_origin
);
45 // Creates an AudioInputDevice using the currently registered factory.
46 // |render_frame_id| refers to the RenderFrame containing the entity
47 // consuming the audio.
48 static scoped_refptr
<media::AudioInputDevice
> NewInputDevice(
53 virtual ~AudioDeviceFactory();
55 // You can derive from this class and specify an implementation for these
56 // functions to provide alternate audio device implementations.
57 // If the return value of either of these function is NULL, we fall back
58 // on the default implementation.
59 virtual media::AudioOutputDevice
* CreateOutputDevice(
62 const std::string
& device_id
,
63 const url::Origin
& security_origin
) = 0;
64 virtual media::AudioInputDevice
* CreateInputDevice(int render_frame_id
) = 0;
67 // The current globally registered factory. This is NULL when we should
68 // create the default AudioRendererSinks.
69 static AudioDeviceFactory
* factory_
;
71 DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory
);
74 } // namespace content
76 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_