blob: 88b2e001bc721393cb6c8a024c71639a2249cab3 [file] [log] [blame]
pbos@webrtc.org26d12102013-05-29 13:41: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 */
10#ifndef WEBRTC_VIDEO_ENGINE_TEST_COMMON_FRAME_GENERATOR_CAPTURER_H_
11#define WEBRTC_VIDEO_ENGINE_TEST_COMMON_FRAME_GENERATOR_CAPTURER_H_
12
sprang@webrtc.org131bea82015-02-18 12:46:06 +000013#include <string>
14
Peter Boströmf2f82832015-05-01 13:00:41 +020015#include "webrtc/base/criticalsection.h"
Peter Boström8c38e8b2015-11-26 17:45:47 +010016#include "webrtc/base/platform_thread.h"
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000017#include "webrtc/base/scoped_ptr.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000018#include "webrtc/test/video_capturer.h"
pbos@webrtc.org26d12102013-05-29 13:41:03 +000019#include "webrtc/typedefs.h"
20
21namespace webrtc {
22
pbos@webrtc.org26d12102013-05-29 13:41:03 +000023class CriticalSectionWrapper;
Peter Boström64c03662015-04-08 11:24:19 +020024class EventTimerWrapper;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000025
26namespace test {
27
28class FrameGenerator;
29
30class FrameGeneratorCapturer : public VideoCapturer {
31 public:
Peter Boström4b91bd02015-06-26 06:58:16 +020032 static FrameGeneratorCapturer* Create(VideoCaptureInput* input,
andresp@webrtc.orgab654952013-09-19 12:14:03 +000033 size_t width,
34 size_t height,
35 int target_fps,
36 Clock* clock);
37
Peter Boström4b91bd02015-06-26 06:58:16 +020038 static FrameGeneratorCapturer* CreateFromYuvFile(VideoCaptureInput* input,
sprang@webrtc.org131bea82015-02-18 12:46:06 +000039 const std::string& file_name,
andresp@webrtc.orgab654952013-09-19 12:14:03 +000040 size_t width,
41 size_t height,
42 int target_fps,
43 Clock* clock);
pbos@webrtc.org26d12102013-05-29 13:41:03 +000044 virtual ~FrameGeneratorCapturer();
45
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000046 void Start() override;
47 void Stop() override;
sprang867fb522015-08-03 04:38:41 -070048 void ForceFrame();
pbos@webrtc.org26d12102013-05-29 13:41:03 +000049
wu@webrtc.orgcd701192014-04-24 22:10:24 +000050 int64_t first_frame_capture_time() const { return first_frame_capture_time_; }
51
andresp@webrtc.orgab654952013-09-19 12:14:03 +000052 FrameGeneratorCapturer(Clock* clock,
Peter Boström4b91bd02015-06-26 06:58:16 +020053 VideoCaptureInput* input,
pbos@webrtc.org26d12102013-05-29 13:41:03 +000054 FrameGenerator* frame_generator,
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000055 int target_fps);
pbos@webrtc.org26d12102013-05-29 13:41:03 +000056 bool Init();
sprang@webrtc.org131bea82015-02-18 12:46:06 +000057
58 private:
pbos@webrtc.org26d12102013-05-29 13:41:03 +000059 void InsertFrame();
60 static bool Run(void* obj);
61
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000062 Clock* const clock_;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000063 bool sending_;
64
Peter Boström64c03662015-04-08 11:24:19 +020065 rtc::scoped_ptr<EventTimerWrapper> tick_;
Peter Boströmf2f82832015-05-01 13:00:41 +020066 rtc::CriticalSection lock_;
Peter Boström8c38e8b2015-11-26 17:45:47 +010067 rtc::PlatformThread thread_;
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000068 rtc::scoped_ptr<FrameGenerator> frame_generator_;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000069
70 int target_fps_;
wu@webrtc.orgcd701192014-04-24 22:10:24 +000071
72 int64_t first_frame_capture_time_;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000073};
74} // test
75} // webrtc
76
77#endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_FRAME_GENERATOR_CAPTURER_H_