OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #ifndef WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_ | 10 #ifndef WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_ |
11 #define WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_ | 11 #define WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_ |
12 | 12 |
13 #include <memory> | 13 #include <memory> |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "webrtc/base/criticalsection.h" | 16 #include "webrtc/base/criticalsection.h" |
17 #include "webrtc/base/platform_thread.h" | 17 #include "webrtc/base/platform_thread.h" |
18 #include "webrtc/common_video/rotation.h" | 18 #include "webrtc/common_video/rotation.h" |
19 #include "webrtc/test/video_capturer.h" | 19 #include "webrtc/test/video_capturer.h" |
20 #include "webrtc/typedefs.h" | 20 #include "webrtc/typedefs.h" |
21 #include "webrtc/video_frame.h" | |
22 | 21 |
23 namespace webrtc { | 22 namespace webrtc { |
24 | 23 |
25 class CriticalSectionWrapper; | 24 class CriticalSectionWrapper; |
26 class EventTimerWrapper; | 25 class EventTimerWrapper; |
27 | 26 |
28 namespace test { | 27 namespace test { |
29 | 28 |
30 class FrameGenerator; | 29 class FrameGenerator; |
31 | 30 |
32 class FrameGeneratorCapturer : public VideoCapturer { | 31 class FrameGeneratorCapturer : public VideoCapturer { |
33 public: | 32 public: |
34 static FrameGeneratorCapturer* Create(size_t width, | 33 static FrameGeneratorCapturer* Create(VideoCaptureInput* input, |
| 34 size_t width, |
35 size_t height, | 35 size_t height, |
36 int target_fps, | 36 int target_fps, |
37 Clock* clock); | 37 Clock* clock); |
38 | 38 |
39 static FrameGeneratorCapturer* CreateFromYuvFile(const std::string& file_name, | 39 static FrameGeneratorCapturer* CreateFromYuvFile(VideoCaptureInput* input, |
| 40 const std::string& file_name, |
40 size_t width, | 41 size_t width, |
41 size_t height, | 42 size_t height, |
42 int target_fps, | 43 int target_fps, |
43 Clock* clock); | 44 Clock* clock); |
44 virtual ~FrameGeneratorCapturer(); | 45 virtual ~FrameGeneratorCapturer(); |
45 | 46 |
46 void Start() override; | 47 void Start() override; |
47 void Stop() override; | 48 void Stop() override; |
48 | |
49 void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, | |
50 const rtc::VideoSinkWants& wants) override; | |
51 void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override; | |
52 | |
53 void ForceFrame(); | 49 void ForceFrame(); |
54 void SetFakeRotation(VideoRotation rotation); | 50 void SetFakeRotation(VideoRotation rotation); |
55 | 51 |
56 int64_t first_frame_capture_time() const { return first_frame_capture_time_; } | 52 int64_t first_frame_capture_time() const { return first_frame_capture_time_; } |
57 | 53 |
58 FrameGeneratorCapturer(Clock* clock, | 54 FrameGeneratorCapturer(Clock* clock, |
| 55 VideoCaptureInput* input, |
59 FrameGenerator* frame_generator, | 56 FrameGenerator* frame_generator, |
60 int target_fps); | 57 int target_fps); |
61 bool Init(); | 58 bool Init(); |
62 | 59 |
63 private: | 60 private: |
64 void InsertFrame(); | 61 void InsertFrame(); |
65 static bool Run(void* obj); | 62 static bool Run(void* obj); |
66 | 63 |
67 Clock* const clock_; | 64 Clock* const clock_; |
68 bool sending_; | 65 bool sending_; |
69 rtc::VideoSinkInterface<VideoFrame>* sink_ GUARDED_BY(&lock_); | |
70 | 66 |
71 std::unique_ptr<EventTimerWrapper> tick_; | 67 std::unique_ptr<EventTimerWrapper> tick_; |
72 rtc::CriticalSection lock_; | 68 rtc::CriticalSection lock_; |
73 rtc::PlatformThread thread_; | 69 rtc::PlatformThread thread_; |
74 std::unique_ptr<FrameGenerator> frame_generator_; | 70 std::unique_ptr<FrameGenerator> frame_generator_; |
75 | 71 |
76 int target_fps_; | 72 int target_fps_; |
77 VideoRotation fake_rotation_ = kVideoRotation_0; | 73 VideoRotation fake_rotation_ = kVideoRotation_0; |
78 | 74 |
79 int64_t first_frame_capture_time_; | 75 int64_t first_frame_capture_time_; |
80 }; | 76 }; |
81 } // test | 77 } // test |
82 } // webrtc | 78 } // webrtc |
83 | 79 |
84 #endif // WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_ | 80 #endif // WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_ |
OLD | NEW |