Home | History | Annotate | Download | only in media
      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.
      4 
      5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
      6 #define CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/memory/ref_counted.h"
     10 
     11 namespace media {
     12 class AudioInputDevice;
     13 class AudioOutputDevice;
     14 }
     15 
     16 namespace content {
     17 
     18 // A factory for creating AudioOutputDevices and AudioInputDevices.  There is a
     19 // global factory function that can be installed for the purposes of testing to
     20 // provide specialized implementations.
     21 class AudioDeviceFactory {
     22  public:
     23   // Creates an AudioOutputDevice using the currently registered factory.
     24   // |render_view_id| refers to the render view containing the entity producing
     25   // the audio.
     26   static scoped_refptr<media::AudioOutputDevice> NewOutputDevice(
     27       int render_view_id);
     28 
     29   // Creates an AudioInputDevice using the currently registered factory.
     30   // |render_view_id| refers to the render view containing the entity consuming
     31   // the audio.
     32   static scoped_refptr<media::AudioInputDevice> NewInputDevice(
     33       int render_view_id);
     34 
     35  protected:
     36   AudioDeviceFactory();
     37   virtual ~AudioDeviceFactory();
     38 
     39   // You can derive from this class and specify an implementation for these
     40   // functions to provide alternate audio device implementations.
     41   // If the return value of either of these function is NULL, we fall back
     42   // on the default implementation.
     43   virtual media::AudioOutputDevice* CreateOutputDevice(int render_view_id) = 0;
     44   virtual media::AudioInputDevice* CreateInputDevice(int render_view_id) = 0;
     45 
     46  private:
     47   // The current globally registered factory. This is NULL when we should
     48   // create the default AudioRendererSinks.
     49   static AudioDeviceFactory* factory_;
     50 
     51   DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory);
     52 };
     53 
     54 }  // namespace content
     55 
     56 #endif  // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
     57