2
// Copyright 2004--2011 Google Inc.
4
// Redistribution and use in source and binary forms, with or without
5
// modification, are permitted provided that the following conditions are met:
7
// 1. Redistributions of source code must retain the above copyright notice,
8
// this list of conditions and the following disclaimer.
9
// 2. Redistributions in binary form must reproduce the above copyright notice,
10
// this list of conditions and the following disclaimer in the documentation
11
// and/or other materials provided with the distribution.
12
// 3. The name of the author may not be used to endorse or promote products
13
// derived from this software without specific prior written permission.
15
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
#ifndef TALK_SESSION_PHONE_FAKEWEBRTCDEVICEINFO_H_
27
#define TALK_SESSION_PHONE_FAKEWEBRTCDEVICEINFO_H_
31
#include "talk/base/stringutils.h"
32
#include "talk/session/phone/webrtcvideocapturer.h"
34
// Fake class for mocking out webrtc::VideoCaptureModule::DeviceInfo.
35
class FakeWebRtcDeviceInfo : public webrtc::VideoCaptureModule::DeviceInfo {
38
Device(const std::string& n, const std::string& i) : name(n), id(i) {}
42
std::vector<webrtc::VideoCaptureCapability> caps;
44
FakeWebRtcDeviceInfo() {}
45
void AddDevice(const std::string& device_name, const std::string& device_id) {
46
devices_.push_back(Device(device_name, device_id));
48
void AddCapability(const std::string& device_id,
49
const webrtc::VideoCaptureCapability& cap) {
50
Device* dev = GetDeviceById(
51
reinterpret_cast<const char*>(device_id.c_str()));
53
dev->caps.push_back(cap);
55
virtual WebRtc_UWord32 NumberOfDevices() {
56
return devices_.size();
58
virtual WebRtc_Word32 GetDeviceName(WebRtc_UWord32 device_num,
60
WebRtc_UWord32 device_name_len,
62
WebRtc_UWord32 device_id_len,
64
WebRtc_UWord32 product_id_len) {
65
Device* dev = GetDeviceByIndex(device_num);
67
talk_base::strcpyn(reinterpret_cast<char*>(device_name), device_name_len,
69
talk_base::strcpyn(reinterpret_cast<char*>(device_id), device_id_len,
72
talk_base::strcpyn(reinterpret_cast<char*>(product_id), product_id_len,
73
dev->product.c_str());
77
virtual WebRtc_Word32 NumberOfCapabilities(const char* device_id) {
78
Device* dev = GetDeviceById(device_id);
80
return dev->caps.size();
82
virtual WebRtc_Word32 GetCapability(const char* device_id,
83
const WebRtc_UWord32 device_cap_num,
84
webrtc::VideoCaptureCapability& cap) {
85
Device* dev = GetDeviceById(device_id);
87
if (device_cap_num >= dev->caps.size()) return -1;
88
cap = dev->caps[device_cap_num];
91
virtual WebRtc_Word32 GetOrientation(const char* device_id,
92
webrtc::VideoCaptureRotation& rotation) {
93
return -1; // not implemented
95
virtual WebRtc_Word32 GetBestMatchedCapability(
96
const char* device_id,
97
const webrtc::VideoCaptureCapability& requested,
98
webrtc::VideoCaptureCapability& resulting) {
99
return -1; // not implemented
101
virtual WebRtc_Word32 DisplayCaptureSettingsDialogBox(
102
const char* device_id, const char* dialog_title,
103
void* parent, WebRtc_UWord32 x, WebRtc_UWord32 y) {
104
return -1; // not implemented
107
Device* GetDeviceByIndex(size_t num) {
108
return (num < devices_.size()) ? &devices_[num] : NULL;
110
Device* GetDeviceById(const char* device_id) {
111
for (size_t i = 0; i < devices_.size(); ++i) {
112
if (devices_[i].id == reinterpret_cast<const char*>(device_id)) {
120
std::vector<Device> devices_;
123
#endif // TALK_SESSION_PHONE_FAKEWEBRTCDEVICEINFO_H_