OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // webrtc::ScalingObserverInterface implementation. | 121 // webrtc::ScalingObserverInterface implementation. |
122 // These methods are protected for easier testing. | 122 // These methods are protected for easier testing. |
123 void ScaleUp(ScaleReason reason) override; | 123 void ScaleUp(ScaleReason reason) override; |
124 void ScaleDown(ScaleReason reason) override; | 124 void ScaleDown(ScaleReason reason) override; |
125 | 125 |
126 private: | 126 private: |
127 class ConfigureEncoderTask; | 127 class ConfigureEncoderTask; |
128 class EncodeTask; | 128 class EncodeTask; |
129 class VideoSourceProxy; | 129 class VideoSourceProxy; |
130 | 130 |
131 struct VideoFrameInfo { | 131 class VideoFrameInfo { |
| 132 public: |
132 VideoFrameInfo(int width, | 133 VideoFrameInfo(int width, |
133 int height, | 134 int height, |
134 VideoRotation rotation, | 135 VideoRotation rotation, |
135 bool is_texture) | 136 bool is_texture) |
136 : width(width), | 137 : width(width), |
137 height(height), | 138 height(height), |
138 rotation(rotation), | 139 rotation(rotation), |
139 is_texture(is_texture) {} | 140 is_texture(is_texture) {} |
140 int width; | 141 int width; |
141 int height; | 142 int height; |
142 VideoRotation rotation; | 143 VideoRotation rotation; |
143 bool is_texture; | 144 bool is_texture; |
| 145 int pixel_count() const { return width * height; } |
144 }; | 146 }; |
145 | 147 |
146 void ConfigureEncoderOnTaskQueue(VideoEncoderConfig config, | 148 void ConfigureEncoderOnTaskQueue(VideoEncoderConfig config, |
147 size_t max_data_payload_length, | 149 size_t max_data_payload_length, |
148 bool nack_enabled); | 150 bool nack_enabled); |
149 void ReconfigureEncoder(); | 151 void ReconfigureEncoder(); |
150 | 152 |
151 // Implements VideoSinkInterface. | 153 // Implements VideoSinkInterface. |
152 void OnFrame(const VideoFrame& video_frame) override; | 154 void OnFrame(const VideoFrame& video_frame) override; |
153 | 155 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 uint8_t picture_id_sli_ ACCESS_ON(&encoder_queue_); | 210 uint8_t picture_id_sli_ ACCESS_ON(&encoder_queue_); |
209 bool has_received_rpsi_ ACCESS_ON(&encoder_queue_); | 211 bool has_received_rpsi_ ACCESS_ON(&encoder_queue_); |
210 uint64_t picture_id_rpsi_ ACCESS_ON(&encoder_queue_); | 212 uint64_t picture_id_rpsi_ ACCESS_ON(&encoder_queue_); |
211 Clock* const clock_; | 213 Clock* const clock_; |
212 // Counters used for deciding if the video resolution is currently | 214 // Counters used for deciding if the video resolution is currently |
213 // restricted, and if so, why. | 215 // restricted, and if so, why. |
214 std::vector<int> scale_counter_ ACCESS_ON(&encoder_queue_); | 216 std::vector<int> scale_counter_ ACCESS_ON(&encoder_queue_); |
215 // Set depending on degradation preferences | 217 // Set depending on degradation preferences |
216 bool scaling_enabled_ ACCESS_ON(&encoder_queue_) = false; | 218 bool scaling_enabled_ ACCESS_ON(&encoder_queue_) = false; |
217 | 219 |
218 int last_frame_width_ ACCESS_ON(&encoder_queue_); | |
219 int last_frame_height_ ACCESS_ON(&encoder_queue_); | |
220 // Pixel count last time the resolution was requested to be changed down. | 220 // Pixel count last time the resolution was requested to be changed down. |
221 rtc::Optional<int> max_pixel_count_ ACCESS_ON(&encoder_queue_); | 221 rtc::Optional<int> max_pixel_count_ ACCESS_ON(&encoder_queue_); |
222 // Pixel count last time the resolution was requested to be changed up. | 222 // Pixel count last time the resolution was requested to be changed up. |
223 rtc::Optional<int> max_pixel_count_step_up_ ACCESS_ON(&encoder_queue_); | 223 rtc::Optional<int> max_pixel_count_step_up_ ACCESS_ON(&encoder_queue_); |
224 | 224 |
225 rtc::RaceChecker incoming_frame_race_checker_ | 225 rtc::RaceChecker incoming_frame_race_checker_ |
226 GUARDED_BY(incoming_frame_race_checker_); | 226 GUARDED_BY(incoming_frame_race_checker_); |
227 Atomic32 posted_frames_waiting_for_encode_; | 227 Atomic32 posted_frames_waiting_for_encode_; |
228 // Used to make sure incoming time stamp is increasing for every frame. | 228 // Used to make sure incoming time stamp is increasing for every frame. |
229 int64_t last_captured_timestamp_ GUARDED_BY(incoming_frame_race_checker_); | 229 int64_t last_captured_timestamp_ GUARDED_BY(incoming_frame_race_checker_); |
230 // Delta used for translating between NTP and internal timestamps. | 230 // Delta used for translating between NTP and internal timestamps. |
231 const int64_t delta_ntp_internal_ms_ GUARDED_BY(incoming_frame_race_checker_); | 231 const int64_t delta_ntp_internal_ms_ GUARDED_BY(incoming_frame_race_checker_); |
232 | 232 |
233 int64_t last_frame_log_ms_ GUARDED_BY(incoming_frame_race_checker_); | 233 int64_t last_frame_log_ms_ GUARDED_BY(incoming_frame_race_checker_); |
234 int captured_frame_count_ ACCESS_ON(&encoder_queue_); | 234 int captured_frame_count_ ACCESS_ON(&encoder_queue_); |
235 int dropped_frame_count_ ACCESS_ON(&encoder_queue_); | 235 int dropped_frame_count_ ACCESS_ON(&encoder_queue_); |
236 | 236 |
237 VideoBitrateAllocationObserver* bitrate_observer_ ACCESS_ON(&encoder_queue_); | 237 VideoBitrateAllocationObserver* bitrate_observer_ ACCESS_ON(&encoder_queue_); |
238 | 238 |
239 // All public methods are proxied to |encoder_queue_|. It must must be | 239 // All public methods are proxied to |encoder_queue_|. It must must be |
240 // destroyed first to make sure no tasks are run that use other members. | 240 // destroyed first to make sure no tasks are run that use other members. |
241 rtc::TaskQueue encoder_queue_; | 241 rtc::TaskQueue encoder_queue_; |
242 | 242 |
243 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); | 243 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); |
244 }; | 244 }; |
245 | 245 |
246 } // namespace webrtc | 246 } // namespace webrtc |
247 | 247 |
248 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 248 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ |
OLD | NEW |