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" |
21 | 22 |
22 namespace webrtc { | 23 namespace webrtc { |
23 | 24 |
24 class CriticalSectionWrapper; | 25 class CriticalSectionWrapper; |
25 class EventTimerWrapper; | 26 class EventTimerWrapper; |
26 | 27 |
27 namespace test { | 28 namespace test { |
28 | 29 |
29 class FrameGenerator; | 30 class FrameGenerator; |
30 | 31 |
31 class FrameGeneratorCapturer : public VideoCapturer { | 32 class FrameGeneratorCapturer : public VideoCapturer { |
32 public: | 33 public: |
33 static FrameGeneratorCapturer* Create(VideoCaptureInput* input, | 34 static FrameGeneratorCapturer* Create(size_t width, |
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(VideoCaptureInput* input, | 39 static FrameGeneratorCapturer* CreateFromYuvFile(const std::string& file_name, |
40 const std::string& file_name, | |
41 size_t width, | 40 size_t width, |
42 size_t height, | 41 size_t height, |
43 int target_fps, | 42 int target_fps, |
44 Clock* clock); | 43 Clock* clock); |
45 virtual ~FrameGeneratorCapturer(); | 44 virtual ~FrameGeneratorCapturer(); |
46 | 45 |
47 void Start() override; | 46 void Start() override; |
48 void Stop() override; | 47 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 |
49 void ForceFrame(); | 53 void ForceFrame(); |
50 void SetFakeRotation(VideoRotation rotation); | 54 void SetFakeRotation(VideoRotation rotation); |
51 | 55 |
52 int64_t first_frame_capture_time() const { return first_frame_capture_time_; } | 56 int64_t first_frame_capture_time() const { return first_frame_capture_time_; } |
53 | 57 |
54 FrameGeneratorCapturer(Clock* clock, | 58 FrameGeneratorCapturer(Clock* clock, |
55 VideoCaptureInput* input, | |
56 FrameGenerator* frame_generator, | 59 FrameGenerator* frame_generator, |
57 int target_fps); | 60 int target_fps); |
58 bool Init(); | 61 bool Init(); |
59 | 62 |
60 private: | 63 private: |
61 void InsertFrame(); | 64 void InsertFrame(); |
62 static bool Run(void* obj); | 65 static bool Run(void* obj); |
63 | 66 |
64 Clock* const clock_; | 67 Clock* const clock_; |
65 bool sending_; | 68 bool sending_; |
| 69 rtc::VideoSinkInterface<VideoFrame>* sink_ GUARDED_BY(&lock_); |
66 | 70 |
67 std::unique_ptr<EventTimerWrapper> tick_; | 71 std::unique_ptr<EventTimerWrapper> tick_; |
68 rtc::CriticalSection lock_; | 72 rtc::CriticalSection lock_; |
69 rtc::PlatformThread thread_; | 73 rtc::PlatformThread thread_; |
70 std::unique_ptr<FrameGenerator> frame_generator_; | 74 std::unique_ptr<FrameGenerator> frame_generator_; |
71 | 75 |
72 int target_fps_; | 76 int target_fps_; |
73 VideoRotation fake_rotation_ = kVideoRotation_0; | 77 VideoRotation fake_rotation_ = kVideoRotation_0; |
74 | 78 |
75 int64_t first_frame_capture_time_; | 79 int64_t first_frame_capture_time_; |
76 }; | 80 }; |
77 } // test | 81 } // test |
78 } // webrtc | 82 } // webrtc |
79 | 83 |
80 #endif // WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_ | 84 #endif // WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_ |
OLD | NEW |