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
11#ifndef SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_FILE_CAPTURE_DEVICE_H_
12#define SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_FILE_CAPTURE_DEVICE_H_
13
14#include <stdio.h>
15
16#include <string>
17
18#include "webrtc/typedefs.h"
19
20namespace webrtc {
21class CriticalSectionWrapper;
22class EventWrapper;
23class ViEExternalCapture;
24}
25
26// This class opens a i420 file and feeds it into a ExternalCapture instance,
27// thereby acting as a faked capture device with deterministic input.
28class ViEFileCaptureDevice {
29 public:
30  // The input sink is where to send the I420 video frames.
31  explicit ViEFileCaptureDevice(webrtc::ViEExternalCapture* input_sink);
32  virtual ~ViEFileCaptureDevice();
33
34  // Opens the provided I420 file and interprets it according to the provided
35  // width and height. Returns false if the file doesn't exist.
36  bool OpenI420File(const std::string& path, int width, int height);
37
38  // Reads the previously opened file for at most time_slice_ms milliseconds,
39  // after which it will return. It will make sure to sleep accordingly so we
40  // do not send more than max_fps cap (we may send less, though).
41  void ReadFileFor(uint64_t time_slice_ms, uint32_t max_fps);
42
43  // Closes the opened input file.
44  void CloseFile();
45
46 private:
47  webrtc::ViEExternalCapture* input_sink_;
48
49  FILE* input_file_;
50  webrtc::CriticalSectionWrapper* mutex_;
51
52  uint32_t frame_length_;
53  uint32_t width_;
54  uint32_t height_;
55};
56
57#endif  // SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_FILE_CAPTURE_DEVICE_H_
58