summaryrefslogtreecommitdiffstats
path: root/content/renderer/media/audio_device_factory.h
blob: 46bf5f96099b2574bb75106d058f25b2d34a9774 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
#define CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_

#include "base/basictypes.h"
#include "base/memory/ref_counted.h"

namespace media {
class AudioInputDevice;
class AudioOutputDevice;
}

namespace content {

// A factory for creating AudioOutputDevices and AudioInputDevices.  There is a
// global factory function that can be installed for the purposes of testing to
// provide specialized implementations.
class AudioDeviceFactory {
 public:
  // Creates an AudioOutputDevice using the currently registered factory.
  // |render_view_id| refers to the render view containing the entity producing
  // the audio.
  static scoped_refptr<media::AudioOutputDevice> NewOutputDevice(
      int render_view_id);

  // Creates an AudioInputDevice using the currently registered factory.
  // |render_view_id| refers to the render view containing the entity consuming
  // the audio.
  static scoped_refptr<media::AudioInputDevice> NewInputDevice(
      int render_view_id);

 protected:
  AudioDeviceFactory();
  virtual ~AudioDeviceFactory();

  // You can derive from this class and specify an implementation for these
  // functions to provide alternate audio device implementations.
  // If the return value of either of these function is NULL, we fall back
  // on the default implementation.
  virtual media::AudioOutputDevice* CreateOutputDevice(int render_view_id) = 0;
  virtual media::AudioInputDevice* CreateInputDevice(int render_view_id) = 0;

 private:
  // The current globally registered factory. This is NULL when we should
  // create the default AudioRendererSinks.
  static AudioDeviceFactory* factory_;

  DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory);
};

}  // namespace content

#endif  // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_