blob: a1ca3366b4f4fcefce90d1754b35e0aaa9167611 [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"
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000016#include "webrtc/base/scoped_ptr.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000017#include "webrtc/test/video_capturer.h"
pbos@webrtc.org26d12102013-05-29 13:41:03 +000018#include "webrtc/typedefs.h"
19
20namespace webrtc {
21
pbos@webrtc.org26d12102013-05-29 13:41:03 +000022class CriticalSectionWrapper;
Peter Boström64c03662015-04-08 11:24:19 +020023class EventTimerWrapper;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000024class ThreadWrapper;
25
26namespace test {
27
28class FrameGenerator;
29
30class FrameGeneratorCapturer : public VideoCapturer {
31 public:
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000032 static FrameGeneratorCapturer* Create(VideoSendStreamInput* 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
38 static FrameGeneratorCapturer* CreateFromYuvFile(VideoSendStreamInput* 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;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000048
wu@webrtc.orgcd701192014-04-24 22:10:24 +000049 int64_t first_frame_capture_time() const { return first_frame_capture_time_; }
50
andresp@webrtc.orgab654952013-09-19 12:14:03 +000051 FrameGeneratorCapturer(Clock* clock,
52 VideoSendStreamInput* input,
pbos@webrtc.org26d12102013-05-29 13:41:03 +000053 FrameGenerator* frame_generator,
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000054 int target_fps);
pbos@webrtc.org26d12102013-05-29 13:41:03 +000055 bool Init();
sprang@webrtc.org131bea82015-02-18 12:46:06 +000056
57 private:
pbos@webrtc.org26d12102013-05-29 13:41:03 +000058 void InsertFrame();
59 static bool Run(void* obj);
60
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000061 Clock* const clock_;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000062 bool sending_;
63
Peter Boström64c03662015-04-08 11:24:19 +020064 rtc::scoped_ptr<EventTimerWrapper> tick_;
Peter Boströmf2f82832015-05-01 13:00:41 +020065 rtc::CriticalSection lock_;
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000066 rtc::scoped_ptr<ThreadWrapper> thread_;
67 rtc::scoped_ptr<FrameGenerator> frame_generator_;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000068
69 int target_fps_;
wu@webrtc.orgcd701192014-04-24 22:10:24 +000070
71 int64_t first_frame_capture_time_;
pbos@webrtc.org26d12102013-05-29 13:41:03 +000072};
73} // test
74} // webrtc
75
76#endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_FRAME_GENERATOR_CAPTURER_H_