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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace test { | 22 namespace test { |
23 | 23 |
24 FrameGeneratorCapturer* FrameGeneratorCapturer::Create(size_t width, | 24 FrameGeneratorCapturer* FrameGeneratorCapturer::Create(size_t width, |
25 size_t height, | 25 size_t 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::CreateChromaGenerator(width, height), target_fps); |
30 if (!capturer->Init()) { | 30 if (!capturer->Init()) { |
31 delete capturer; | 31 delete capturer; |
32 return NULL; | 32 return nullptr; |
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 nullptr; |
51 } | 51 } |
52 | 52 |
53 return capturer; | 53 return capturer; |
54 } | 54 } |
55 | 55 |
56 FrameGeneratorCapturer::FrameGeneratorCapturer(Clock* clock, | 56 FrameGeneratorCapturer::FrameGeneratorCapturer(Clock* clock, |
57 FrameGenerator* frame_generator, | 57 FrameGenerator* frame_generator, |
58 int target_fps) | 58 int target_fps) |
59 : clock_(clock), | 59 : clock_(clock), |
60 sending_(false), | 60 sending_(false), |
(...skipping 15 matching lines...) Expand all Loading... |
76 } | 76 } |
77 | 77 |
78 void FrameGeneratorCapturer::SetFakeRotation(VideoRotation rotation) { | 78 void FrameGeneratorCapturer::SetFakeRotation(VideoRotation rotation) { |
79 rtc::CritScope cs(&lock_); | 79 rtc::CritScope cs(&lock_); |
80 fake_rotation_ = rotation; | 80 fake_rotation_ = rotation; |
81 } | 81 } |
82 | 82 |
83 bool FrameGeneratorCapturer::Init() { | 83 bool FrameGeneratorCapturer::Init() { |
84 // This check is added because frame_generator_ might be file based and should | 84 // This check is added because frame_generator_ might be file based and should |
85 // not crash because a file moved. | 85 // not crash because a file moved. |
86 if (frame_generator_.get() == NULL) | 86 if (frame_generator_.get() == nullptr) |
87 return false; | 87 return false; |
88 | 88 |
89 if (!tick_->StartTimer(true, 1000 / target_fps_)) | 89 if (!tick_->StartTimer(true, 1000 / target_fps_)) |
90 return false; | 90 return false; |
91 thread_.Start(); | 91 thread_.Start(); |
92 thread_.SetPriority(rtc::kHighPriority); | 92 thread_.SetPriority(rtc::kHighPriority); |
93 return true; | 93 return true; |
94 } | 94 } |
95 | 95 |
96 bool FrameGeneratorCapturer::Run(void* obj) { | 96 bool FrameGeneratorCapturer::Run(void* obj) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 rtc::CritScope cs(&lock_); | 151 rtc::CritScope cs(&lock_); |
152 RTC_CHECK(sink_ == sink); | 152 RTC_CHECK(sink_ == sink); |
153 sink_ = nullptr; | 153 sink_ = nullptr; |
154 } | 154 } |
155 | 155 |
156 void FrameGeneratorCapturer::ForceFrame() { | 156 void FrameGeneratorCapturer::ForceFrame() { |
157 tick_->Set(); | 157 tick_->Set(); |
158 } | 158 } |
159 } // test | 159 } // test |
160 } // webrtc | 160 } // webrtc |
OLD | NEW |