blob: 2b34dd2c5996d36e3a218d1002a4b5f53a64c03e [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
kwibergbfefb032016-05-01 14:53:46 -070013#include <memory>
sprang@webrtc.org131bea82015-02-18 12:46:06 +000014#include <string>
15
Peter Boströmf2f82832015-05-01 13:00:41 +020016#include "webrtc/base/criticalsection.h"
Peter Boström8c38e8b2015-11-26 17:45:47 +010017#include "webrtc/base/platform_thread.h"
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000018#include "webrtc/base/scoped_ptr.h"
Perba7dc722016-04-19 15:01:23 +020019#include "webrtc/common_video/rotation.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000020#include "webrtc/test/video_capturer.h"
pbos@webrtc.org26d12102013-05-29 13:41:03 +000021#include "webrtc/typedefs.h"
22
23namespace webrtc {
24
pbos@webrtc.org26d12102013-05-29 13:41:03 +000025class CriticalSectionWrapper;
Peter Boström64c03662015-04-08 11:24:19 +020026class EventTimerWrapper;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000027
28namespace test {
29
30class FrameGenerator;
31
32class FrameGeneratorCapturer : public VideoCapturer {
33 public:
Peter Boström4b91bd02015-06-26 06:58:16 +020034 static FrameGeneratorCapturer* Create(VideoCaptureInput* input,
andresp@webrtc.orgab654952013-09-19 12:14:03 +000035 size_t width,
36 size_t height,
37 int target_fps,
38 Clock* clock);
39
Peter Boström4b91bd02015-06-26 06:58:16 +020040 static FrameGeneratorCapturer* CreateFromYuvFile(VideoCaptureInput* input,
sprang@webrtc.org131bea82015-02-18 12:46:06 +000041 const std::string& file_name,
andresp@webrtc.orgab654952013-09-19 12:14:03 +000042 size_t width,
43 size_t height,
44 int target_fps,
45 Clock* clock);
pbos@webrtc.org26d12102013-05-29 13:41:03 +000046 virtual ~FrameGeneratorCapturer();
47
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000048 void Start() override;
49 void Stop() override;
sprang867fb522015-08-03 04:38:41 -070050 void ForceFrame();
Perba7dc722016-04-19 15:01:23 +020051 void SetFakeRotation(VideoRotation rotation);
pbos@webrtc.org26d12102013-05-29 13:41:03 +000052
wu@webrtc.orgcd701192014-04-24 22:10:24 +000053 int64_t first_frame_capture_time() const { return first_frame_capture_time_; }
54
andresp@webrtc.orgab654952013-09-19 12:14:03 +000055 FrameGeneratorCapturer(Clock* clock,
Peter Boström4b91bd02015-06-26 06:58:16 +020056 VideoCaptureInput* input,
pbos@webrtc.org26d12102013-05-29 13:41:03 +000057 FrameGenerator* frame_generator,
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000058 int target_fps);
pbos@webrtc.org26d12102013-05-29 13:41:03 +000059 bool Init();
sprang@webrtc.org131bea82015-02-18 12:46:06 +000060
61 private:
pbos@webrtc.org26d12102013-05-29 13:41:03 +000062 void InsertFrame();
63 static bool Run(void* obj);
64
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000065 Clock* const clock_;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000066 bool sending_;
67
kwibergbfefb032016-05-01 14:53:46 -070068 std::unique_ptr<EventTimerWrapper> tick_;
Peter Boströmf2f82832015-05-01 13:00:41 +020069 rtc::CriticalSection lock_;
Peter Boström8c38e8b2015-11-26 17:45:47 +010070 rtc::PlatformThread thread_;
kwibergbfefb032016-05-01 14:53:46 -070071 std::unique_ptr<FrameGenerator> frame_generator_;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000072
73 int target_fps_;
Perba7dc722016-04-19 15:01:23 +020074 VideoRotation fake_rotation_ = kVideoRotation_0;
wu@webrtc.orgcd701192014-04-24 22:10:24 +000075
76 int64_t first_frame_capture_time_;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000077};
78} // test
79} // webrtc
80
Peter Boström7623ce42015-12-09 12:13:30 +010081#endif // WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_