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 | 10 |
11 #include "webrtc/test/frame_generator_capturer.h" | 11 #include "webrtc/test/frame_generator_capturer.h" |
12 | 12 |
13 #include "webrtc/base/criticalsection.h" | 13 #include "webrtc/base/criticalsection.h" |
14 #include "webrtc/base/platform_thread.h" | 14 #include "webrtc/base/platform_thread.h" |
15 #include "webrtc/system_wrappers/include/clock.h" | 15 #include "webrtc/system_wrappers/include/clock.h" |
16 #include "webrtc/system_wrappers/include/event_wrapper.h" | 16 #include "webrtc/system_wrappers/include/event_wrapper.h" |
17 #include "webrtc/system_wrappers/include/sleep.h" | 17 #include "webrtc/system_wrappers/include/sleep.h" |
18 #include "webrtc/test/frame_generator.h" | 18 #include "webrtc/test/frame_generator.h" |
19 #include "webrtc/video_send_stream.h" | 19 #include "webrtc/video_send_stream.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 namespace test { | 22 namespace test { |
23 | 23 |
24 FrameGeneratorCapturer* FrameGeneratorCapturer::Create(size_t width, | 24 FrameGeneratorCapturer* FrameGeneratorCapturer::Create(int width, |
25 size_t height, | 25 int height, |
26 int target_fps, | 26 int target_fps, |
27 Clock* clock) { | 27 Clock* clock) { |
28 FrameGeneratorCapturer* capturer = new FrameGeneratorCapturer( | 28 FrameGeneratorCapturer* capturer = new FrameGeneratorCapturer( |
29 clock, FrameGenerator::CreateChromaGenerator(width, height), target_fps); | 29 clock, FrameGenerator::CreateSquareGenerator(width, height), target_fps); |
30 if (!capturer->Init()) { | 30 if (!capturer->Init()) { |
31 delete capturer; | 31 delete capturer; |
32 return NULL; | 32 return NULL; |
33 } | 33 } |
34 | 34 |
35 return capturer; | 35 return capturer; |
36 } | 36 } |
37 | 37 |
38 FrameGeneratorCapturer* FrameGeneratorCapturer::CreateFromYuvFile( | 38 FrameGeneratorCapturer* FrameGeneratorCapturer::CreateFromYuvFile( |
39 const std::string& file_name, | 39 const std::string& file_name, |
40 size_t width, | 40 size_t width, |
41 size_t height, | 41 size_t height, |
42 int target_fps, | 42 int target_fps, |
43 Clock* clock) { | 43 Clock* clock) { |
44 FrameGeneratorCapturer* capturer = new FrameGeneratorCapturer( | 44 FrameGeneratorCapturer* capturer = new FrameGeneratorCapturer( |
45 clock, FrameGenerator::CreateFromYuvFile( | 45 clock, FrameGenerator::CreateFromYuvFile( |
46 std::vector<std::string>(1, file_name), width, height, 1), | 46 std::vector<std::string>(1, file_name), width, height, 1), |
47 target_fps); | 47 target_fps); |
48 if (!capturer->Init()) { | 48 if (!capturer->Init()) { |
49 delete capturer; | 49 delete capturer; |
50 return NULL; | 50 return NULL; |
51 } | 51 } |
52 | 52 |
53 return capturer; | 53 return capturer; |
54 } | 54 } |
55 | 55 |
56 FrameGeneratorCapturer::FrameGeneratorCapturer(Clock* clock, | 56 FrameGeneratorCapturer::FrameGeneratorCapturer( |
57 FrameGenerator* frame_generator, | 57 Clock* clock, |
58 int target_fps) | 58 std::unique_ptr<FrameGenerator> frame_generator, |
| 59 int target_fps) |
59 : clock_(clock), | 60 : clock_(clock), |
60 sending_(false), | 61 sending_(false), |
61 sink_(nullptr), | 62 sink_(nullptr), |
62 sink_wants_observer_(nullptr), | 63 sink_wants_observer_(nullptr), |
63 tick_(EventTimerWrapper::Create()), | 64 tick_(EventTimerWrapper::Create()), |
64 thread_(FrameGeneratorCapturer::Run, this, "FrameGeneratorCapturer"), | 65 thread_(FrameGeneratorCapturer::Run, this, "FrameGeneratorCapturer"), |
65 frame_generator_(frame_generator), | 66 frame_generator_(std::move(frame_generator)), |
66 target_fps_(target_fps), | 67 target_fps_(target_fps), |
67 first_frame_capture_time_(-1) { | 68 first_frame_capture_time_(-1) { |
68 RTC_DCHECK(frame_generator); | 69 RTC_DCHECK(frame_generator_); |
69 RTC_DCHECK_GT(target_fps, 0); | 70 RTC_DCHECK_GT(target_fps, 0); |
70 } | 71 } |
71 | 72 |
72 FrameGeneratorCapturer::~FrameGeneratorCapturer() { | 73 FrameGeneratorCapturer::~FrameGeneratorCapturer() { |
73 Stop(); | 74 Stop(); |
74 | 75 |
75 thread_.Stop(); | 76 thread_.Stop(); |
76 } | 77 } |
77 | 78 |
78 void FrameGeneratorCapturer::SetFakeRotation(VideoRotation rotation) { | 79 void FrameGeneratorCapturer::SetFakeRotation(VideoRotation rotation) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 rtc::CritScope cs(&lock_); | 152 rtc::CritScope cs(&lock_); |
152 RTC_CHECK(sink_ == sink); | 153 RTC_CHECK(sink_ == sink); |
153 sink_ = nullptr; | 154 sink_ = nullptr; |
154 } | 155 } |
155 | 156 |
156 void FrameGeneratorCapturer::ForceFrame() { | 157 void FrameGeneratorCapturer::ForceFrame() { |
157 tick_->Set(); | 158 tick_->Set(); |
158 } | 159 } |
159 } // test | 160 } // test |
160 } // webrtc | 161 } // webrtc |
OLD | NEW |