blob: 9d158c3fcde94bbc7aa25d4e20bca3a7e83e8b90 [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 */
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020010#ifndef TEST_VCM_CAPTURER_H_
11#define TEST_VCM_CAPTURER_H_
pbos@webrtc.org29d58392013-05-16 12:08:03 +000012
sprangc5d62e22017-04-02 23:53:04 -070013#include <memory>
14
Mirko Bonadei71207422017-09-15 13:58:09 +020015#include "common_types.h" // NOLINT(build/include)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "common_video/libyuv/include/webrtc_libyuv.h"
17#include "modules/video_capture/video_capture.h"
18#include "rtc_base/criticalsection.h"
19#include "rtc_base/scoped_ref_ptr.h"
20#include "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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020061#endif // TEST_VCM_CAPTURER_H_