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 |
11 #ifndef WEBRTC_VIDEO_VIE_ENCODER_H_ | 11 #ifndef WEBRTC_VIDEO_VIE_ENCODER_H_ |
12 #define WEBRTC_VIDEO_VIE_ENCODER_H_ | 12 #define WEBRTC_VIDEO_VIE_ENCODER_H_ |
13 | 13 |
| 14 #include <map> |
14 #include <memory> | 15 #include <memory> |
15 #include <string> | 16 #include <string> |
16 #include <vector> | 17 #include <vector> |
17 | 18 |
18 #include "webrtc/api/video/video_rotation.h" | 19 #include "webrtc/api/video/video_rotation.h" |
19 #include "webrtc/base/criticalsection.h" | 20 #include "webrtc/base/criticalsection.h" |
20 #include "webrtc/base/event.h" | 21 #include "webrtc/base/event.h" |
21 #include "webrtc/base/sequenced_task_checker.h" | 22 #include "webrtc/base/sequenced_task_checker.h" |
22 #include "webrtc/base/task_queue.h" | 23 #include "webrtc/base/task_queue.h" |
23 #include "webrtc/call/call.h" | 24 #include "webrtc/call/call.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 const EncodedImage& encoded_image, | 168 const EncodedImage& encoded_image, |
168 const CodecSpecificInfo* codec_specific_info, | 169 const CodecSpecificInfo* codec_specific_info, |
169 const RTPFragmentationHeader* fragmentation) override; | 170 const RTPFragmentationHeader* fragmentation) override; |
170 | 171 |
171 void OnDroppedFrame() override; | 172 void OnDroppedFrame() override; |
172 | 173 |
173 bool EncoderPaused() const; | 174 bool EncoderPaused() const; |
174 void TraceFrameDropStart(); | 175 void TraceFrameDropStart(); |
175 void TraceFrameDropEnd(); | 176 void TraceFrameDropEnd(); |
176 | 177 |
| 178 std::vector<int>* GetScaleCounters() |
| 179 EXCLUSIVE_LOCKS_REQUIRED(&encoder_queue_); |
| 180 |
177 rtc::Event shutdown_event_; | 181 rtc::Event shutdown_event_; |
178 | 182 |
179 const uint32_t number_of_cores_; | 183 const uint32_t number_of_cores_; |
180 // Counts how many frames we've dropped in the initial rampup phase. | 184 // Counts how many frames we've dropped in the initial rampup phase. |
181 int initial_rampup_; | 185 int initial_rampup_; |
182 | 186 |
183 const std::unique_ptr<VideoSourceProxy> source_proxy_; | 187 const std::unique_ptr<VideoSourceProxy> source_proxy_; |
184 EncoderSink* sink_; | 188 EncoderSink* sink_; |
185 const VideoSendStream::Config::EncoderSettings settings_; | 189 const VideoSendStream::Config::EncoderSettings settings_; |
186 const VideoCodecType codec_type_; | 190 const VideoCodecType codec_type_; |
(...skipping 22 matching lines...) Expand all Loading... |
209 size_t max_data_payload_length_ ACCESS_ON(&encoder_queue_); | 213 size_t max_data_payload_length_ ACCESS_ON(&encoder_queue_); |
210 bool nack_enabled_ ACCESS_ON(&encoder_queue_); | 214 bool nack_enabled_ ACCESS_ON(&encoder_queue_); |
211 uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_); | 215 uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_); |
212 bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_); | 216 bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_); |
213 bool has_received_sli_ ACCESS_ON(&encoder_queue_); | 217 bool has_received_sli_ ACCESS_ON(&encoder_queue_); |
214 uint8_t picture_id_sli_ ACCESS_ON(&encoder_queue_); | 218 uint8_t picture_id_sli_ ACCESS_ON(&encoder_queue_); |
215 bool has_received_rpsi_ ACCESS_ON(&encoder_queue_); | 219 bool has_received_rpsi_ ACCESS_ON(&encoder_queue_); |
216 uint64_t picture_id_rpsi_ ACCESS_ON(&encoder_queue_); | 220 uint64_t picture_id_rpsi_ ACCESS_ON(&encoder_queue_); |
217 Clock* const clock_; | 221 Clock* const clock_; |
218 // Counters used for deciding if the video resolution is currently | 222 // Counters used for deciding if the video resolution is currently |
219 // restricted, and if so, why. | 223 // restricted, and if so, why, on a per degradation preference basis. |
220 std::vector<int> scale_counter_ ACCESS_ON(&encoder_queue_); | 224 // TODO(sprang): Replace this with a state holding a relative overuse measure |
| 225 // instead, that can be translated into suitable down-scale or fps limit. |
| 226 std::map<const VideoSendStream::DegradationPreference, std::vector<int>> |
| 227 scale_counters_ ACCESS_ON(&encoder_queue_); |
221 // Set depending on degradation preferences | 228 // Set depending on degradation preferences |
222 VideoSendStream::DegradationPreference degradation_preference_ | 229 VideoSendStream::DegradationPreference degradation_preference_ |
223 ACCESS_ON(&encoder_queue_); | 230 ACCESS_ON(&encoder_queue_); |
224 | 231 |
225 struct AdaptationRequest { | 232 struct AdaptationRequest { |
226 // The pixel count produced by the source at the time of the adaptation. | 233 // The pixel count produced by the source at the time of the adaptation. |
227 int input_pixel_count_; | 234 int input_pixel_count_; |
| 235 // Framerate received from the source at the time of the adaptation. |
| 236 int framerate_fps_; |
228 // Indicates if request was to adapt up or down. | 237 // Indicates if request was to adapt up or down. |
229 enum class Mode { kAdaptUp, kAdaptDown } mode_; | 238 enum class Mode { kAdaptUp, kAdaptDown } mode_; |
230 }; | 239 }; |
231 // Stores a snapshot of the last adaptation request triggered by an AdaptUp | 240 // Stores a snapshot of the last adaptation request triggered by an AdaptUp |
232 // or AdaptDown signal. | 241 // or AdaptDown signal. |
233 rtc::Optional<AdaptationRequest> last_adaptation_request_ | 242 rtc::Optional<AdaptationRequest> last_adaptation_request_ |
234 ACCESS_ON(&encoder_queue_); | 243 ACCESS_ON(&encoder_queue_); |
235 | 244 |
236 rtc::RaceChecker incoming_frame_race_checker_ | 245 rtc::RaceChecker incoming_frame_race_checker_ |
237 GUARDED_BY(incoming_frame_race_checker_); | 246 GUARDED_BY(incoming_frame_race_checker_); |
(...skipping 13 matching lines...) Expand all Loading... |
251 // All public methods are proxied to |encoder_queue_|. It must must be | 260 // All public methods are proxied to |encoder_queue_|. It must must be |
252 // destroyed first to make sure no tasks are run that use other members. | 261 // destroyed first to make sure no tasks are run that use other members. |
253 rtc::TaskQueue encoder_queue_; | 262 rtc::TaskQueue encoder_queue_; |
254 | 263 |
255 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); | 264 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); |
256 }; | 265 }; |
257 | 266 |
258 } // namespace webrtc | 267 } // namespace webrtc |
259 | 268 |
260 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 269 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ |
OLD | NEW |