blob: 208a77158aa7afcb7a52adbaa6a6f29bdd0ddc52 [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
perkja49cbd32016-09-16 07:53:41 -070033 void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
34 const rtc::VideoSinkWants& wants) override;
35 void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000036
nisseb29b9c82016-12-12 00:22:56 -080037 void OnFrame(const VideoFrame& frame) override;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000038
39 private:
perkja49cbd32016-09-16 07:53:41 -070040 VcmCapturer();
Tarun Chawla8e857d12017-05-31 19:20:57 +053041 bool Init(size_t width,
42 size_t height,
43 size_t target_fps,
44 size_t capture_device_index);
pbos@webrtc.org29d58392013-05-16 12:08:03 +000045 void Destroy();
46
Peter Boström1e737c62015-10-23 14:45:55 +020047 rtc::CriticalSection crit_;
danilchapa37de392017-09-09 04:17:22 -070048 rtc::VideoSinkInterface<VideoFrame>* sink_ RTC_GUARDED_BY(crit_);
Peter Boström1d194412016-03-21 16:44:31 +010049 rtc::scoped_refptr<VideoCaptureModule> vcm_;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000050 VideoCaptureCapability capability_;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000051};
perkja49cbd32016-09-16 07:53:41 -070052
Yves Gerey665174f2018-06-19 15:03:05 +020053} // namespace test
54} // namespace webrtc
pbos@webrtc.org29d58392013-05-16 12:08:03 +000055
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020056#endif // TEST_VCM_CAPTURER_H_