blob: 5e62c48d3e5dec5ec19e06d7a692490058a1e530 [file] [log] [blame]
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
#include <cstdio>
#include <string>
#include "typedefs.h"
namespace webrtc {
class CriticalSectionWrapper;
class EventWrapper;
class ViEExternalCapture;
// This class opens a i420 file and feeds it into a ExternalCapture instance,
// thereby acting as a faked capture device with deterministic input.
class ViEFileCaptureDevice {
// The input sink is where to send the I420 video frames.
explicit ViEFileCaptureDevice(webrtc::ViEExternalCapture* input_sink);
virtual ~ViEFileCaptureDevice();
// Opens the provided I420 file and interprets it according to the provided
// width and height. Returns false if the file doesn't exist.
bool OpenI420File(const std::string& path, int width, int height);
// Reads the previously opened file for at most time_slice_ms milliseconds,
// after which it will return. It will make sure to sleep accordingly so we
// do not send more than max_fps cap (we may send less, though).
void ReadFileFor(uint64_t time_slice_ms, uint32_t max_fps);
// Closes the opened input file.
void CloseFile();
webrtc::ViEExternalCapture* input_sink_;
std::FILE* input_file_;
webrtc::CriticalSectionWrapper* mutex_;
WebRtc_UWord32 frame_length_;
WebRtc_UWord8* frame_buffer_;
WebRtc_UWord32 width_;
WebRtc_UWord32 height_;