2015-01-20 21:36:13 +00:00
|
|
|
/*
|
2016-02-07 20:46:45 -08:00
|
|
|
* Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
|
2015-01-20 21:36:13 +00:00
|
|
|
*
|
2016-02-07 20:46:45 -08:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2015-01-20 21:36:13 +00:00
|
|
|
*/
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MEDIA_ENGINE_FAKEWEBRTCVCMFACTORY_H_
|
|
|
|
|
#define MEDIA_ENGINE_FAKEWEBRTCVCMFACTORY_H_
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "media/engine/fakewebrtcdeviceinfo.h"
|
|
|
|
|
#include "media/engine/fakewebrtcvideocapturemodule.h"
|
|
|
|
|
#include "media/engine/webrtcvideocapturer.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Factory class to allow the fakes above to be injected into
|
|
|
|
|
// WebRtcVideoCapturer.
|
|
|
|
|
class FakeWebRtcVcmFactory : public cricket::WebRtcVcmFactoryInterface {
|
|
|
|
|
public:
|
2016-03-22 17:17:39 +01:00
|
|
|
virtual rtc::scoped_refptr<webrtc::VideoCaptureModule> Create(
|
|
|
|
|
const char* device_id) {
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!device_info.GetDeviceById(device_id)) return NULL;
|
2016-03-22 17:17:39 +01:00
|
|
|
rtc::scoped_refptr<FakeWebRtcVideoCaptureModule> module(
|
2016-12-12 00:22:56 -08:00
|
|
|
new rtc::RefCountedObject<FakeWebRtcVideoCaptureModule>(this));
|
2013-07-10 00:45:36 +00:00
|
|
|
modules.push_back(module);
|
|
|
|
|
return module;
|
|
|
|
|
}
|
2016-12-12 00:22:56 -08:00
|
|
|
virtual webrtc::VideoCaptureModule::DeviceInfo* CreateDeviceInfo() {
|
2013-07-10 00:45:36 +00:00
|
|
|
return &device_info;
|
|
|
|
|
}
|
|
|
|
|
virtual void DestroyDeviceInfo(webrtc::VideoCaptureModule::DeviceInfo* info) {
|
|
|
|
|
}
|
|
|
|
|
void OnDestroyed(webrtc::VideoCaptureModule* module) {
|
|
|
|
|
std::remove(modules.begin(), modules.end(), module);
|
|
|
|
|
}
|
|
|
|
|
FakeWebRtcDeviceInfo device_info;
|
2016-03-22 17:17:39 +01:00
|
|
|
std::vector<rtc::scoped_refptr<FakeWebRtcVideoCaptureModule>> modules;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FakeWebRtcVideoCaptureModule::~FakeWebRtcVideoCaptureModule() {
|
|
|
|
|
if (factory_)
|
|
|
|
|
factory_->OnDestroyed(this);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MEDIA_ENGINE_FAKEWEBRTCVCMFACTORY_H_
|