blob: 2b4323c0e55f01f8241b1c7ba413bb344df7d9bf [file] [log] [blame]
pbos@webrtc.org29d58392013-05-16 12:08:03 +00001/*
2 * Copyright (c) 2013 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 */
Peter Boström7623ce42015-12-09 12:13:30 +010010#ifndef WEBRTC_TEST_VCM_CAPTURER_H_
11#define WEBRTC_TEST_VCM_CAPTURER_H_
pbos@webrtc.org29d58392013-05-16 12:08:03 +000012
sprangc5d62e22017-04-02 23:53:04 -070013#include <memory>
14
pbos@webrtc.org29d58392013-05-16 12:08:03 +000015#include "webrtc/common_types.h"
16#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
Henrik Kjellander5dda80a2015-11-12 12:46:09 +010017#include "webrtc/modules/video_capture/video_capture.h"
Edward Lemurc20978e2017-07-06 19:44:34 +020018#include "webrtc/rtc_base/criticalsection.h"
19#include "webrtc/rtc_base/scoped_ref_ptr.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000020#include "webrtc/test/video_capturer.h"
pbos@webrtc.org29d58392013-05-16 12:08:03 +000021
22namespace webrtc {
23namespace test {
24
nisseb29b9c82016-12-12 00:22:56 -080025class VcmCapturer
26 : public VideoCapturer,
27 public rtc::VideoSinkInterface<VideoFrame> {
pbos@webrtc.org29d58392013-05-16 12:08:03 +000028 public:
Tarun Chawla8e857d12017-05-31 19:20:57 +053029 static VcmCapturer* Create(size_t width,
30 size_t height,
31 size_t target_fps,
32 size_t capture_device_index);
pbos@webrtc.org29d58392013-05-16 12:08:03 +000033 virtual ~VcmCapturer();
34
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000035 void Start() override;
36 void Stop() override;
perkja49cbd32016-09-16 07:53:41 -070037 void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
38 const rtc::VideoSinkWants& wants) override;
39 void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000040
nisseb29b9c82016-12-12 00:22:56 -080041 void OnFrame(const VideoFrame& frame) override;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000042
43 private:
perkja49cbd32016-09-16 07:53:41 -070044 VcmCapturer();
Tarun Chawla8e857d12017-05-31 19:20:57 +053045 bool Init(size_t width,
46 size_t height,
47 size_t target_fps,
48 size_t capture_device_index);
pbos@webrtc.org29d58392013-05-16 12:08:03 +000049 void Destroy();
50
Peter Boström1e737c62015-10-23 14:45:55 +020051 rtc::CriticalSection crit_;
danilchapa37de392017-09-09 04:17:22 -070052 bool started_ RTC_GUARDED_BY(crit_);
53 rtc::VideoSinkInterface<VideoFrame>* sink_ RTC_GUARDED_BY(crit_);
Peter Boström1d194412016-03-21 16:44:31 +010054 rtc::scoped_refptr<VideoCaptureModule> vcm_;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000055 VideoCaptureCapability capability_;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000056};
perkja49cbd32016-09-16 07:53:41 -070057
pbos@webrtc.org29d58392013-05-16 12:08:03 +000058} // test
59} // webrtc
60
Peter Boström7623ce42015-12-09 12:13:30 +010061#endif // WEBRTC_TEST_VCM_CAPTURER_H_