1/* 2 * Copyright (c) 2012 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#ifndef SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_FAKE_CAMERA_H_ 11#define SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_FAKE_CAMERA_H_ 12 13#include <string> 14 15namespace webrtc { 16class ViECapture; 17class ThreadWrapper; 18} 19 20class ViEFileCaptureDevice; 21 22// Registers an external capture device with the provided capture interface 23// and starts running a fake camera by reading frames from a file. The frame- 24// reading code runs in a separate thread which makes it possible to run tests 25// while the fake camera feeds data into the system. This class is not thread- 26// safe in itself (but handles its own thread in a safe manner). 27class ViEFakeCamera { 28 public: 29 // The argument is the capture interface to register with. 30 explicit ViEFakeCamera(webrtc::ViECapture* capture_interface); 31 virtual ~ViEFakeCamera(); 32 33 // Runs the scenario in the class comments. 34 bool StartCameraInNewThread(const std::string& i420_test_video_path, 35 int width, 36 int height); 37 // Stops the camera and cleans up everything allocated by the start method. 38 bool StopCamera(); 39 40 int capture_id() const { return capture_id_; } 41 42 private: 43 webrtc::ViECapture* capture_interface_; 44 45 int capture_id_; 46 webrtc::ThreadWrapper* camera_thread_; 47 ViEFileCaptureDevice* file_capture_device_; 48}; 49 50#endif // SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_FAKE_CAMERA_H_ 51