15976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// libjingle 25976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// Copyright 2004 Google Inc. 35976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// 45976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// Redistribution and use in source and binary forms, with or without 55976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// modification, are permitted provided that the following conditions are met: 65976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// 75976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// 1. Redistributions of source code must retain the above copyright notice, 85976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// this list of conditions and the following disclaimer. 95976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// 2. Redistributions in binary form must reproduce the above copyright notice, 105976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// this list of conditions and the following disclaimer in the documentation 115976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// and/or other materials provided with the distribution. 125976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// 3. The name of the author may not be used to endorse or promote products 135976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// derived from this software without specific prior written permission. 145976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// 155976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 165976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 175976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 185976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 195976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 205976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 215976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 225976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 235976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 245976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 255976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 265976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#ifndef TALK_SESSION_PHONE_FAKEWEBRTCVCMFACTORY_H_ 275976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#define TALK_SESSION_PHONE_FAKEWEBRTCVCMFACTORY_H_ 285976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 295976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include <vector> 305976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 315976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include "talk/media/webrtc/fakewebrtcvideocapturemodule.h" 325976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include "talk/media/webrtc/webrtcvideocapturer.h" 335976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 345976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// Factory class to allow the fakes above to be injected into 355976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// WebRtcVideoCapturer. 365976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgclass FakeWebRtcVcmFactory : public cricket::WebRtcVcmFactoryInterface { 375976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org public: 385976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual webrtc::VideoCaptureModule* Create(int module_id, 395976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org const char* device_id) { 405976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org if (!device_info.GetDeviceById(device_id)) return NULL; 415976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org FakeWebRtcVideoCaptureModule* module = 425976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org new FakeWebRtcVideoCaptureModule(this, module_id); 435976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org modules.push_back(module); 445976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org return module; 455976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org } 465976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual webrtc::VideoCaptureModule::DeviceInfo* CreateDeviceInfo(int id) { 475976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org return &device_info; 485976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org } 495976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org virtual void DestroyDeviceInfo(webrtc::VideoCaptureModule::DeviceInfo* info) { 505976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org } 515976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org void OnDestroyed(webrtc::VideoCaptureModule* module) { 525976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org std::remove(modules.begin(), modules.end(), module); 535976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org } 545976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org FakeWebRtcDeviceInfo device_info; 555976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org std::vector<FakeWebRtcVideoCaptureModule*> modules; 565976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org}; 575976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 585976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgFakeWebRtcVideoCaptureModule::~FakeWebRtcVideoCaptureModule() { 595976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org if (factory_) 605976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org factory_->OnDestroyed(this); 615976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org} 625976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org 635976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#endif // TALK_SESSION_PHONE_FAKEWEBRTCVCMFACTORY_H_ 64