OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVCMFACTORY_H_ | 11 #ifndef WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVCMFACTORY_H_ |
12 #define WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVCMFACTORY_H_ | 12 #define WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVCMFACTORY_H_ |
13 | 13 |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "webrtc/media/engine/fakewebrtcdeviceinfo.h" | 16 #include "webrtc/media/engine/fakewebrtcdeviceinfo.h" |
17 #include "webrtc/media/engine/fakewebrtcvideocapturemodule.h" | 17 #include "webrtc/media/engine/fakewebrtcvideocapturemodule.h" |
18 #include "webrtc/media/engine/webrtcvideocapturer.h" | 18 #include "webrtc/media/engine/webrtcvideocapturer.h" |
19 | 19 |
20 // Factory class to allow the fakes above to be injected into | 20 // Factory class to allow the fakes above to be injected into |
21 // WebRtcVideoCapturer. | 21 // WebRtcVideoCapturer. |
22 class FakeWebRtcVcmFactory : public cricket::WebRtcVcmFactoryInterface { | 22 class FakeWebRtcVcmFactory : public cricket::WebRtcVcmFactoryInterface { |
23 public: | 23 public: |
24 virtual rtc::scoped_refptr<webrtc::VideoCaptureModule> Create( | 24 virtual rtc::scoped_refptr<webrtc::VideoCaptureModule> Create( |
25 int module_id, | |
26 const char* device_id) { | 25 const char* device_id) { |
27 if (!device_info.GetDeviceById(device_id)) return NULL; | 26 if (!device_info.GetDeviceById(device_id)) return NULL; |
28 rtc::scoped_refptr<FakeWebRtcVideoCaptureModule> module( | 27 rtc::scoped_refptr<FakeWebRtcVideoCaptureModule> module( |
29 new rtc::RefCountedObject<FakeWebRtcVideoCaptureModule>(this, | 28 new rtc::RefCountedObject<FakeWebRtcVideoCaptureModule>(this)); |
30 module_id)); | |
31 modules.push_back(module); | 29 modules.push_back(module); |
32 return module; | 30 return module; |
33 } | 31 } |
34 virtual webrtc::VideoCaptureModule::DeviceInfo* CreateDeviceInfo(int id) { | 32 virtual webrtc::VideoCaptureModule::DeviceInfo* CreateDeviceInfo() { |
35 return &device_info; | 33 return &device_info; |
36 } | 34 } |
37 virtual void DestroyDeviceInfo(webrtc::VideoCaptureModule::DeviceInfo* info) { | 35 virtual void DestroyDeviceInfo(webrtc::VideoCaptureModule::DeviceInfo* info) { |
38 } | 36 } |
39 void OnDestroyed(webrtc::VideoCaptureModule* module) { | 37 void OnDestroyed(webrtc::VideoCaptureModule* module) { |
40 std::remove(modules.begin(), modules.end(), module); | 38 std::remove(modules.begin(), modules.end(), module); |
41 } | 39 } |
42 FakeWebRtcDeviceInfo device_info; | 40 FakeWebRtcDeviceInfo device_info; |
43 std::vector<rtc::scoped_refptr<FakeWebRtcVideoCaptureModule>> modules; | 41 std::vector<rtc::scoped_refptr<FakeWebRtcVideoCaptureModule>> modules; |
44 }; | 42 }; |
45 | 43 |
46 FakeWebRtcVideoCaptureModule::~FakeWebRtcVideoCaptureModule() { | 44 FakeWebRtcVideoCaptureModule::~FakeWebRtcVideoCaptureModule() { |
47 if (factory_) | 45 if (factory_) |
48 factory_->OnDestroyed(this); | 46 factory_->OnDestroyed(this); |
49 } | 47 } |
50 | 48 |
51 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVCMFACTORY_H_ | 49 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVCMFACTORY_H_ |
OLD | NEW |