blob: 5f4707f911551f449cb8cf42f46b64036180f7fc [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 Bonadei92ea95e2017-09-15 06:47:31 +020015#include "common_video/libyuv/include/webrtc_libyuv.h"
16#include "modules/video_capture/video_capture.h"
17#include "rtc_base/criticalsection.h"
18#include "rtc_base/scoped_ref_ptr.h"
Sebastian Janssonf1f363f2018-08-13 14:24:58 +020019#include "test/test_video_capturer.h"
pbos@webrtc.org29d58392013-05-16 12:08:03 +000020
21namespace webrtc {
22namespace test {
23
Sebastian Janssonf1f363f2018-08-13 14:24:58 +020024class VcmCapturer : public TestVideoCapturer,
Yves Gerey665174f2018-06-19 15:03:05 +020025 public rtc::VideoSinkInterface<VideoFrame> {
pbos@webrtc.org29d58392013-05-16 12:08:03 +000026 public:
Tarun Chawla8e857d12017-05-31 19:20:57 +053027 static VcmCapturer* Create(size_t width,
28 size_t height,
29 size_t target_fps,
30 size_t capture_device_index);
pbos@webrtc.org29d58392013-05-16 12:08:03 +000031 virtual ~VcmCapturer();
32
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000033 void Start() override;
34 void Stop() override;
perkja49cbd32016-09-16 07:53:41 -070035 void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
36 const rtc::VideoSinkWants& wants) override;
37 void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000038
nisseb29b9c82016-12-12 00:22:56 -080039 void OnFrame(const VideoFrame& frame) override;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000040
41 private:
perkja49cbd32016-09-16 07:53:41 -070042 VcmCapturer();
Tarun Chawla8e857d12017-05-31 19:20:57 +053043 bool Init(size_t width,
44 size_t height,
45 size_t target_fps,
46 size_t capture_device_index);
pbos@webrtc.org29d58392013-05-16 12:08:03 +000047 void Destroy();
48
Peter Boström1e737c62015-10-23 14:45:55 +020049 rtc::CriticalSection crit_;
danilchapa37de392017-09-09 04:17:22 -070050 bool started_ RTC_GUARDED_BY(crit_);
51 rtc::VideoSinkInterface<VideoFrame>* sink_ RTC_GUARDED_BY(crit_);
Peter Boström1d194412016-03-21 16:44:31 +010052 rtc::scoped_refptr<VideoCaptureModule> vcm_;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000053 VideoCaptureCapability capability_;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000054};
perkja49cbd32016-09-16 07:53:41 -070055
Yves Gerey665174f2018-06-19 15:03:05 +020056} // namespace test
57} // namespace webrtc
pbos@webrtc.org29d58392013-05-16 12:08:03 +000058
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020059#endif // TEST_VCM_CAPTURER_H_