OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * |
| 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. |
| 9 */ |
| 10 |
| 11 #ifndef WEBRTC_MEDIA_WEBRTC_FAKEWEBRTCVCMFACTORY_H_ |
| 12 #define WEBRTC_MEDIA_WEBRTC_FAKEWEBRTCVCMFACTORY_H_ |
| 13 |
| 14 #include <vector> |
| 15 |
| 16 #include "webrtc/media/webrtc/fakewebrtcvideocapturemodule.h" |
| 17 #include "webrtc/media/webrtc/webrtcvideocapturer.h" |
| 18 |
| 19 // Factory class to allow the fakes above to be injected into |
| 20 // WebRtcVideoCapturer. |
| 21 class FakeWebRtcVcmFactory : public cricket::WebRtcVcmFactoryInterface { |
| 22 public: |
| 23 virtual webrtc::VideoCaptureModule* Create(int module_id, |
| 24 const char* device_id) { |
| 25 if (!device_info.GetDeviceById(device_id)) return NULL; |
| 26 FakeWebRtcVideoCaptureModule* module = |
| 27 new FakeWebRtcVideoCaptureModule(this, module_id); |
| 28 modules.push_back(module); |
| 29 return module; |
| 30 } |
| 31 virtual webrtc::VideoCaptureModule::DeviceInfo* CreateDeviceInfo(int id) { |
| 32 return &device_info; |
| 33 } |
| 34 virtual void DestroyDeviceInfo(webrtc::VideoCaptureModule::DeviceInfo* info) { |
| 35 } |
| 36 void OnDestroyed(webrtc::VideoCaptureModule* module) { |
| 37 std::remove(modules.begin(), modules.end(), module); |
| 38 } |
| 39 FakeWebRtcDeviceInfo device_info; |
| 40 std::vector<FakeWebRtcVideoCaptureModule*> modules; |
| 41 }; |
| 42 |
| 43 FakeWebRtcVideoCaptureModule::~FakeWebRtcVideoCaptureModule() { |
| 44 if (factory_) |
| 45 factory_->OnDestroyed(this); |
| 46 } |
| 47 |
| 48 #endif // WEBRTC_MEDIA_WEBRTC_FAKEWEBRTCVCMFACTORY_H_ |
OLD | NEW |