blob: 91ed84339576a6a3489c598c9cccc35a491f118f [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 */
Peter Boström7623ce42015-12-09 12:13:30 +010010#ifndef WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_
11#define WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_
pbos@webrtc.org26d12102013-05-29 13:41:03 +000012
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"
Perba7dc722016-04-19 15:01:23 +020018#include "webrtc/common_video/rotation.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000019#include "webrtc/test/video_capturer.h"
pbos@webrtc.org26d12102013-05-29 13:41:03 +000020#include "webrtc/typedefs.h"
21
22namespace webrtc {
23
pbos@webrtc.org26d12102013-05-29 13:41:03 +000024class CriticalSectionWrapper;
Peter Boström64c03662015-04-08 11:24:19 +020025class EventTimerWrapper;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000026
27namespace test {
28
29class FrameGenerator;
30
31class FrameGeneratorCapturer : public VideoCapturer {
32 public:
Peter Boström4b91bd02015-06-26 06:58:16 +020033 static FrameGeneratorCapturer* Create(VideoCaptureInput* input,
andresp@webrtc.orgab654952013-09-19 12:14:03 +000034 size_t width,
35 size_t height,
36 int target_fps,
37 Clock* clock);
38
Peter Boström4b91bd02015-06-26 06:58:16 +020039 static FrameGeneratorCapturer* CreateFromYuvFile(VideoCaptureInput* input,
sprang@webrtc.org131bea82015-02-18 12:46:06 +000040 const std::string& file_name,
andresp@webrtc.orgab654952013-09-19 12:14:03 +000041 size_t width,
42 size_t height,
43 int target_fps,
44 Clock* clock);
pbos@webrtc.org26d12102013-05-29 13:41:03 +000045 virtual ~FrameGeneratorCapturer();
46
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000047 void Start() override;
48 void Stop() override;
sprang867fb522015-08-03 04:38:41 -070049 void ForceFrame();
Perba7dc722016-04-19 15:01:23 +020050 void SetFakeRotation(VideoRotation rotation);
pbos@webrtc.org26d12102013-05-29 13:41:03 +000051
wu@webrtc.orgcd701192014-04-24 22:10:24 +000052 int64_t first_frame_capture_time() const { return first_frame_capture_time_; }
53
andresp@webrtc.orgab654952013-09-19 12:14:03 +000054 FrameGeneratorCapturer(Clock* clock,
Peter Boström4b91bd02015-06-26 06:58:16 +020055 VideoCaptureInput* input,
pbos@webrtc.org26d12102013-05-29 13:41:03 +000056 FrameGenerator* frame_generator,
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000057 int target_fps);
pbos@webrtc.org26d12102013-05-29 13:41:03 +000058 bool Init();
sprang@webrtc.org131bea82015-02-18 12:46:06 +000059
60 private:
pbos@webrtc.org26d12102013-05-29 13:41:03 +000061 void InsertFrame();
62 static bool Run(void* obj);
63
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000064 Clock* const clock_;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000065 bool sending_;
66
Peter Boström64c03662015-04-08 11:24:19 +020067 rtc::scoped_ptr<EventTimerWrapper> tick_;
Peter Boströmf2f82832015-05-01 13:00:41 +020068 rtc::CriticalSection lock_;
Peter Boström8c38e8b2015-11-26 17:45:47 +010069 rtc::PlatformThread thread_;
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000070 rtc::scoped_ptr<FrameGenerator> frame_generator_;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000071
72 int target_fps_;
Perba7dc722016-04-19 15:01:23 +020073 VideoRotation fake_rotation_ = kVideoRotation_0;
wu@webrtc.orgcd701192014-04-24 22:10:24 +000074
75 int64_t first_frame_capture_time_;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000076};
77} // test
78} // webrtc
79
Peter Boström7623ce42015-12-09 12:13:30 +010080#endif // WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_