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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 // Downscale resolution at most 2 times for CPU reasons. | 71 // Downscale resolution at most 2 times for CPU reasons. |
72 static const int kMaxCpuResolutionDowngrades = 2; | 72 static const int kMaxCpuResolutionDowngrades = 2; |
73 // Downscale framerate at most 4 times. | 73 // Downscale framerate at most 4 times. |
74 static const int kMaxCpuFramerateDowngrades = 4; | 74 static const int kMaxCpuFramerateDowngrades = 4; |
75 | 75 |
76 ViEEncoder(uint32_t number_of_cores, | 76 ViEEncoder(uint32_t number_of_cores, |
77 SendStatisticsProxy* stats_proxy, | 77 SendStatisticsProxy* stats_proxy, |
78 const VideoSendStream::Config::EncoderSettings& settings, | 78 const VideoSendStream::Config::EncoderSettings& settings, |
79 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, | 79 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, |
80 EncodedFrameObserver* encoder_timing); | 80 EncodedFrameObserver* encoder_timing, |
| 81 std::unique_ptr<OveruseFrameDetector> overuse_detector); |
81 ~ViEEncoder(); | 82 ~ViEEncoder(); |
82 // RegisterProcessThread register |module_process_thread| with those objects | 83 // RegisterProcessThread register |module_process_thread| with those objects |
83 // that use it. Registration has to happen on the thread where | 84 // that use it. Registration has to happen on the thread where |
84 // |module_process_thread| was created (libjingle's worker thread). | 85 // |module_process_thread| was created (libjingle's worker thread). |
85 // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue. | 86 // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue. |
86 void RegisterProcessThread(ProcessThread* module_process_thread); | 87 void RegisterProcessThread(ProcessThread* module_process_thread); |
87 void DeRegisterProcessThread(); | 88 void DeRegisterProcessThread(); |
88 | 89 |
89 // Sets the source that will provide I420 video frames. | 90 // Sets the source that will provide I420 video frames. |
90 // |degradation_preference| control whether or not resolution or frame rate | 91 // |degradation_preference| control whether or not resolution or frame rate |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 123 |
123 protected: | 124 protected: |
124 // Used for testing. For example the |ScalingObserverInterface| methods must | 125 // Used for testing. For example the |ScalingObserverInterface| methods must |
125 // be called on |encoder_queue_|. | 126 // be called on |encoder_queue_|. |
126 rtc::TaskQueue* encoder_queue() { return &encoder_queue_; } | 127 rtc::TaskQueue* encoder_queue() { return &encoder_queue_; } |
127 | 128 |
128 // webrtc::ScalingObserverInterface implementation. | 129 // webrtc::ScalingObserverInterface implementation. |
129 // These methods are protected for easier testing. | 130 // These methods are protected for easier testing. |
130 void AdaptUp(AdaptReason reason) override; | 131 void AdaptUp(AdaptReason reason) override; |
131 void AdaptDown(AdaptReason reason) override; | 132 void AdaptDown(AdaptReason reason) override; |
| 133 static CpuOveruseOptions GetCpuOveruseOptions(bool full_overuse_time); |
132 | 134 |
133 private: | 135 private: |
134 class ConfigureEncoderTask; | 136 class ConfigureEncoderTask; |
135 class EncodeTask; | 137 class EncodeTask; |
136 class VideoSourceProxy; | 138 class VideoSourceProxy; |
137 | 139 |
138 class VideoFrameInfo { | 140 class VideoFrameInfo { |
139 public: | 141 public: |
140 VideoFrameInfo(int width, | 142 VideoFrameInfo(int width, |
141 int height, | 143 int height, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 const uint32_t number_of_cores_; | 227 const uint32_t number_of_cores_; |
226 // Counts how many frames we've dropped in the initial rampup phase. | 228 // Counts how many frames we've dropped in the initial rampup phase. |
227 int initial_rampup_; | 229 int initial_rampup_; |
228 | 230 |
229 const std::unique_ptr<VideoSourceProxy> source_proxy_; | 231 const std::unique_ptr<VideoSourceProxy> source_proxy_; |
230 EncoderSink* sink_; | 232 EncoderSink* sink_; |
231 const VideoSendStream::Config::EncoderSettings settings_; | 233 const VideoSendStream::Config::EncoderSettings settings_; |
232 const VideoCodecType codec_type_; | 234 const VideoCodecType codec_type_; |
233 | 235 |
234 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_); | 236 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_); |
235 OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_); | 237 std::unique_ptr<OveruseFrameDetector> overuse_detector_ |
| 238 ACCESS_ON(&encoder_queue_); |
236 std::unique_ptr<QualityScaler> quality_scaler_ ACCESS_ON(&encoder_queue_); | 239 std::unique_ptr<QualityScaler> quality_scaler_ ACCESS_ON(&encoder_queue_); |
237 | 240 |
238 SendStatisticsProxy* const stats_proxy_; | 241 SendStatisticsProxy* const stats_proxy_; |
239 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; | 242 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; |
240 ProcessThread* module_process_thread_; | 243 ProcessThread* module_process_thread_; |
241 rtc::ThreadChecker module_process_thread_checker_; | 244 rtc::ThreadChecker module_process_thread_checker_; |
242 // |thread_checker_| checks that public methods that are related to lifetime | 245 // |thread_checker_| checks that public methods that are related to lifetime |
243 // of ViEEncoder are called on the same thread. | 246 // of ViEEncoder are called on the same thread. |
244 rtc::ThreadChecker thread_checker_; | 247 rtc::ThreadChecker thread_checker_; |
245 | 248 |
246 VideoEncoderConfig encoder_config_ ACCESS_ON(&encoder_queue_); | 249 VideoEncoderConfig encoder_config_ ACCESS_ON(&encoder_queue_); |
247 std::unique_ptr<VideoBitrateAllocator> rate_allocator_ | 250 std::unique_ptr<VideoBitrateAllocator> rate_allocator_ |
248 ACCESS_ON(&encoder_queue_); | 251 ACCESS_ON(&encoder_queue_); |
| 252 // The maximum frame rate of the current codec configuration, as determined |
| 253 // at the last ReconfigureEncoder() call. |
| 254 int max_framerate_ ACCESS_ON(&encoder_queue_); |
249 | 255 |
250 // Set when ConfigureEncoder has been called in order to lazy reconfigure the | 256 // Set when ConfigureEncoder has been called in order to lazy reconfigure the |
251 // encoder on the next frame. | 257 // encoder on the next frame. |
252 bool pending_encoder_reconfiguration_ ACCESS_ON(&encoder_queue_); | 258 bool pending_encoder_reconfiguration_ ACCESS_ON(&encoder_queue_); |
253 rtc::Optional<VideoFrameInfo> last_frame_info_ ACCESS_ON(&encoder_queue_); | 259 rtc::Optional<VideoFrameInfo> last_frame_info_ ACCESS_ON(&encoder_queue_); |
254 uint32_t encoder_start_bitrate_bps_ ACCESS_ON(&encoder_queue_); | 260 uint32_t encoder_start_bitrate_bps_ ACCESS_ON(&encoder_queue_); |
255 size_t max_data_payload_length_ ACCESS_ON(&encoder_queue_); | 261 size_t max_data_payload_length_ ACCESS_ON(&encoder_queue_); |
256 bool nack_enabled_ ACCESS_ON(&encoder_queue_); | 262 bool nack_enabled_ ACCESS_ON(&encoder_queue_); |
257 uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_); | 263 uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_); |
258 bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_); | 264 bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 // All public methods are proxied to |encoder_queue_|. It must must be | 305 // All public methods are proxied to |encoder_queue_|. It must must be |
300 // destroyed first to make sure no tasks are run that use other members. | 306 // destroyed first to make sure no tasks are run that use other members. |
301 rtc::TaskQueue encoder_queue_; | 307 rtc::TaskQueue encoder_queue_; |
302 | 308 |
303 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); | 309 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); |
304 }; | 310 }; |
305 | 311 |
306 } // namespace webrtc | 312 } // namespace webrtc |
307 | 313 |
308 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 314 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ |
OLD | NEW |