3
* Copyright 2004 Google Inc.
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
8
* 1. Redistributions of source code must retain the above copyright notice,
9
* this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright notice,
11
* this list of conditions and the following disclaimer in the documentation
12
* and/or other materials provided with the distribution.
13
* 3. The name of the author may not be used to endorse or promote products
14
* derived from this software without specific prior written permission.
16
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
#ifndef TALK_SESSION_PHONE_DEVICEMANAGER_H_
29
#define TALK_SESSION_PHONE_DEVICEMANAGER_H_
34
#include "talk/base/scoped_ptr.h"
35
#include "talk/base/sigslot.h"
36
#include "talk/base/stringencode.h"
40
// Used to represent an audio or video capture or render device.
43
Device(const std::string& first, int second)
45
id(talk_base::ToString(second)) {
47
Device(const std::string& first, const std::string& second)
48
: name(first), id(second) {}
54
// DeviceManagerInterface - interface to manage the audio and
55
// video devices on the system.
56
class DeviceManagerInterface {
58
virtual ~DeviceManagerInterface() { }
61
virtual bool Init() = 0;
62
virtual void Terminate() = 0;
65
virtual int GetCapabilities() = 0;
68
virtual bool GetAudioInputDevices(std::vector<Device>* devices) = 0;
69
virtual bool GetAudioOutputDevices(std::vector<Device>* devices) = 0;
71
virtual bool GetAudioInputDevice(const std::string& name, Device* out) = 0;
72
virtual bool GetAudioOutputDevice(const std::string& name, Device* out) = 0;
74
virtual bool GetVideoCaptureDevices(std::vector<Device>* devs) = 0;
75
virtual bool GetVideoCaptureDevice(const std::string& name, Device* out) = 0;
77
sigslot::signal0<> SignalDevicesChange;
79
static const char kDefaultDeviceName[];
84
explicit DeviceWatcher(DeviceManagerInterface* dm) {}
85
virtual ~DeviceWatcher() {}
86
virtual bool Start() { return true; }
87
virtual void Stop() {}
90
class DeviceManagerFactory {
92
static DeviceManagerInterface* Create();
94
DeviceManagerFactory();
97
class DeviceManager : public DeviceManagerInterface {
100
virtual ~DeviceManager();
104
virtual void Terminate();
107
virtual int GetCapabilities();
109
// Device enumeration
110
virtual bool GetAudioInputDevices(std::vector<Device>* devices);
111
virtual bool GetAudioOutputDevices(std::vector<Device>* devices);
113
virtual bool GetAudioInputDevice(const std::string& name, Device* out);
114
virtual bool GetAudioOutputDevice(const std::string& name, Device* out);
116
virtual bool GetVideoCaptureDevices(std::vector<Device>* devs);
117
virtual bool GetVideoCaptureDevice(const std::string& name, Device* out);
119
// The exclusion_list MUST be a NULL terminated list.
120
static bool FilterDevices(std::vector<Device>* devices,
121
const char* const exclusion_list[]);
122
bool initialized() const { return initialized_; }
125
virtual bool GetAudioDevices(bool input, std::vector<Device>* devs);
126
virtual bool GetAudioDevice(bool is_input, const std::string& name,
128
virtual bool GetDefaultVideoCaptureDevice(Device* device);
130
void set_initialized(bool initialized) { initialized_ = initialized; }
132
void set_watcher(DeviceWatcher* watcher) { watcher_.reset(watcher); }
133
DeviceWatcher* watcher() { return watcher_.get(); }
136
// The exclusion_list MUST be a NULL terminated list.
137
static bool ShouldDeviceBeIgnored(const std::string& device_name,
138
const char* const exclusion_list[]);
140
talk_base::scoped_ptr<DeviceWatcher> watcher_;
143
} // namespace cricket
145
#endif // TALK_SESSION_PHONE_DEVICEMANAGER_H_