jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 1 | /* |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 2 | * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 3 | * |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 9 | */ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 10 | |
kjellander@webrtc.org | 5ad1297 | 2016-02-12 06:39:40 +0100 | [diff] [blame] | 11 | #ifndef WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVCMFACTORY_H_ |
| 12 | #define WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVCMFACTORY_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 13 | |
| 14 | #include <vector> |
| 15 | |
solenberg | 8ad582d | 2016-03-16 09:34:56 -0700 | [diff] [blame] | 16 | #include "webrtc/media/engine/fakewebrtcdeviceinfo.h" |
kjellander@webrtc.org | 5ad1297 | 2016-02-12 06:39:40 +0100 | [diff] [blame] | 17 | #include "webrtc/media/engine/fakewebrtcvideocapturemodule.h" |
| 18 | #include "webrtc/media/engine/webrtcvideocapturer.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 19 | |
| 20 | // Factory class to allow the fakes above to be injected into |
| 21 | // WebRtcVideoCapturer. |
| 22 | class FakeWebRtcVcmFactory : public cricket::WebRtcVcmFactoryInterface { |
| 23 | public: |
Peter Boström | 09c3a1e | 2016-03-22 17:17:39 +0100 | [diff] [blame] | 24 | virtual rtc::scoped_refptr<webrtc::VideoCaptureModule> Create( |
Peter Boström | 09c3a1e | 2016-03-22 17:17:39 +0100 | [diff] [blame] | 25 | const char* device_id) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 26 | if (!device_info.GetDeviceById(device_id)) return NULL; |
Peter Boström | 09c3a1e | 2016-03-22 17:17:39 +0100 | [diff] [blame] | 27 | rtc::scoped_refptr<FakeWebRtcVideoCaptureModule> module( |
nisse | b29b9c8 | 2016-12-12 00:22:56 -0800 | [diff] [blame] | 28 | new rtc::RefCountedObject<FakeWebRtcVideoCaptureModule>(this)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 29 | modules.push_back(module); |
| 30 | return module; |
| 31 | } |
nisse | b29b9c8 | 2016-12-12 00:22:56 -0800 | [diff] [blame] | 32 | virtual webrtc::VideoCaptureModule::DeviceInfo* CreateDeviceInfo() { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 33 | return &device_info; |
| 34 | } |
| 35 | virtual void DestroyDeviceInfo(webrtc::VideoCaptureModule::DeviceInfo* info) { |
| 36 | } |
| 37 | void OnDestroyed(webrtc::VideoCaptureModule* module) { |
| 38 | std::remove(modules.begin(), modules.end(), module); |
| 39 | } |
| 40 | FakeWebRtcDeviceInfo device_info; |
Peter Boström | 09c3a1e | 2016-03-22 17:17:39 +0100 | [diff] [blame] | 41 | std::vector<rtc::scoped_refptr<FakeWebRtcVideoCaptureModule>> modules; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | FakeWebRtcVideoCaptureModule::~FakeWebRtcVideoCaptureModule() { |
| 45 | if (factory_) |
| 46 | factory_->OnDestroyed(this); |
| 47 | } |
| 48 | |
kjellander@webrtc.org | 5ad1297 | 2016-02-12 06:39:40 +0100 | [diff] [blame] | 49 | #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVCMFACTORY_H_ |