pbos@webrtc.org | 26d1210 | 2013-05-29 13:41:03 +0000 | [diff] [blame] | 1 | /* |
| 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.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 13 | #include <string> |
| 14 | |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame^] | 15 | #include "webrtc/base/criticalsection.h" |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 16 | #include "webrtc/base/scoped_ptr.h" |
pbos@webrtc.org | 16e03b7 | 2013-10-28 16:32:01 +0000 | [diff] [blame] | 17 | #include "webrtc/test/video_capturer.h" |
pbos@webrtc.org | 26d1210 | 2013-05-29 13:41:03 +0000 | [diff] [blame] | 18 | #include "webrtc/typedefs.h" |
| 19 | |
| 20 | namespace webrtc { |
| 21 | |
pbos@webrtc.org | 26d1210 | 2013-05-29 13:41:03 +0000 | [diff] [blame] | 22 | class CriticalSectionWrapper; |
Peter Boström | 64c0366 | 2015-04-08 11:24:19 +0200 | [diff] [blame] | 23 | class EventTimerWrapper; |
pbos@webrtc.org | 26d1210 | 2013-05-29 13:41:03 +0000 | [diff] [blame] | 24 | class ThreadWrapper; |
| 25 | |
| 26 | namespace test { |
| 27 | |
| 28 | class FrameGenerator; |
| 29 | |
| 30 | class FrameGeneratorCapturer : public VideoCapturer { |
| 31 | public: |
pbos@webrtc.org | 74fa489 | 2013-08-23 09:19:30 +0000 | [diff] [blame] | 32 | static FrameGeneratorCapturer* Create(VideoSendStreamInput* input, |
andresp@webrtc.org | ab65495 | 2013-09-19 12:14:03 +0000 | [diff] [blame] | 33 | size_t width, |
| 34 | size_t height, |
| 35 | int target_fps, |
| 36 | Clock* clock); |
| 37 | |
| 38 | static FrameGeneratorCapturer* CreateFromYuvFile(VideoSendStreamInput* input, |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 39 | const std::string& file_name, |
andresp@webrtc.org | ab65495 | 2013-09-19 12:14:03 +0000 | [diff] [blame] | 40 | size_t width, |
| 41 | size_t height, |
| 42 | int target_fps, |
| 43 | Clock* clock); |
pbos@webrtc.org | 26d1210 | 2013-05-29 13:41:03 +0000 | [diff] [blame] | 44 | virtual ~FrameGeneratorCapturer(); |
| 45 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 46 | void Start() override; |
| 47 | void Stop() override; |
pbos@webrtc.org | 26d1210 | 2013-05-29 13:41:03 +0000 | [diff] [blame] | 48 | |
wu@webrtc.org | cd70119 | 2014-04-24 22:10:24 +0000 | [diff] [blame] | 49 | int64_t first_frame_capture_time() const { return first_frame_capture_time_; } |
| 50 | |
andresp@webrtc.org | ab65495 | 2013-09-19 12:14:03 +0000 | [diff] [blame] | 51 | FrameGeneratorCapturer(Clock* clock, |
| 52 | VideoSendStreamInput* input, |
pbos@webrtc.org | 26d1210 | 2013-05-29 13:41:03 +0000 | [diff] [blame] | 53 | FrameGenerator* frame_generator, |
pbos@webrtc.org | af8d5af | 2013-07-09 08:02:33 +0000 | [diff] [blame] | 54 | int target_fps); |
pbos@webrtc.org | 26d1210 | 2013-05-29 13:41:03 +0000 | [diff] [blame] | 55 | bool Init(); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 56 | |
| 57 | private: |
pbos@webrtc.org | 26d1210 | 2013-05-29 13:41:03 +0000 | [diff] [blame] | 58 | void InsertFrame(); |
| 59 | static bool Run(void* obj); |
| 60 | |
pbos@webrtc.org | de1429e | 2014-04-28 13:00:21 +0000 | [diff] [blame] | 61 | Clock* const clock_; |
pbos@webrtc.org | 26d1210 | 2013-05-29 13:41:03 +0000 | [diff] [blame] | 62 | bool sending_; |
| 63 | |
Peter Boström | 64c0366 | 2015-04-08 11:24:19 +0200 | [diff] [blame] | 64 | rtc::scoped_ptr<EventTimerWrapper> tick_; |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame^] | 65 | rtc::CriticalSection lock_; |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 66 | rtc::scoped_ptr<ThreadWrapper> thread_; |
| 67 | rtc::scoped_ptr<FrameGenerator> frame_generator_; |
pbos@webrtc.org | 26d1210 | 2013-05-29 13:41:03 +0000 | [diff] [blame] | 68 | |
| 69 | int target_fps_; |
wu@webrtc.org | cd70119 | 2014-04-24 22:10:24 +0000 | [diff] [blame] | 70 | |
| 71 | int64_t first_frame_capture_time_; |
pbos@webrtc.org | 26d1210 | 2013-05-29 13:41:03 +0000 | [diff] [blame] | 72 | }; |
| 73 | } // test |
| 74 | } // webrtc |
| 75 | |
| 76 | #endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_FRAME_GENERATOR_CAPTURER_H_ |