Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: webrtc/video/vie_encoder.h

Issue 2783183003: Revert of Add framerate to VideoSinkWants and ability to signal on overuse (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/video_send_stream_tests.cc ('k') | webrtc/video/vie_encoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
15 #include <memory> 14 #include <memory>
16 #include <string> 15 #include <string>
17 #include <vector> 16 #include <vector>
18 17
19 #include "webrtc/api/video/video_rotation.h" 18 #include "webrtc/api/video/video_rotation.h"
20 #include "webrtc/base/criticalsection.h" 19 #include "webrtc/base/criticalsection.h"
21 #include "webrtc/base/event.h" 20 #include "webrtc/base/event.h"
22 #include "webrtc/base/sequenced_task_checker.h" 21 #include "webrtc/base/sequenced_task_checker.h"
23 #include "webrtc/base/task_queue.h" 22 #include "webrtc/base/task_queue.h"
24 #include "webrtc/call/call.h" 23 #include "webrtc/call/call.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Interface for receiving encoded video frames and notifications about 55 // Interface for receiving encoded video frames and notifications about
57 // configuration changes. 56 // configuration changes.
58 class EncoderSink : public EncodedImageCallback { 57 class EncoderSink : public EncodedImageCallback {
59 public: 58 public:
60 virtual void OnEncoderConfigurationChanged( 59 virtual void OnEncoderConfigurationChanged(
61 std::vector<VideoStream> streams, 60 std::vector<VideoStream> streams,
62 int min_transmit_bitrate_bps) = 0; 61 int min_transmit_bitrate_bps) = 0;
63 }; 62 };
64 63
65 // Downscale resolution at most 2 times for CPU reasons. 64 // Downscale resolution at most 2 times for CPU reasons.
66 static const int kMaxCpuResolutionDowngrades = 2; 65 static const int kMaxCpuDowngrades = 2;
67 // Downscale framerate at most 4 times.
68 static const int kMaxCpuFramerateDowngrades = 4;
69 66
70 ViEEncoder(uint32_t number_of_cores, 67 ViEEncoder(uint32_t number_of_cores,
71 SendStatisticsProxy* stats_proxy, 68 SendStatisticsProxy* stats_proxy,
72 const VideoSendStream::Config::EncoderSettings& settings, 69 const VideoSendStream::Config::EncoderSettings& settings,
73 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, 70 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback,
74 EncodedFrameObserver* encoder_timing); 71 EncodedFrameObserver* encoder_timing);
75 ~ViEEncoder(); 72 ~ViEEncoder();
76 // RegisterProcessThread register |module_process_thread| with those objects 73 // RegisterProcessThread register |module_process_thread| with those objects
77 // that use it. Registration has to happen on the thread where 74 // that use it. Registration has to happen on the thread where
78 // |module_process_thread| was created (libjingle's worker thread). 75 // |module_process_thread| was created (libjingle's worker thread).
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 const EncodedImage& encoded_image, 165 const EncodedImage& encoded_image,
169 const CodecSpecificInfo* codec_specific_info, 166 const CodecSpecificInfo* codec_specific_info,
170 const RTPFragmentationHeader* fragmentation) override; 167 const RTPFragmentationHeader* fragmentation) override;
171 168
172 void OnDroppedFrame() override; 169 void OnDroppedFrame() override;
173 170
174 bool EncoderPaused() const; 171 bool EncoderPaused() const;
175 void TraceFrameDropStart(); 172 void TraceFrameDropStart();
176 void TraceFrameDropEnd(); 173 void TraceFrameDropEnd();
177 174
178 const std::vector<int>& GetScaleCounters()
179 EXCLUSIVE_LOCKS_REQUIRED(&encoder_queue_);
180 void IncrementScaleCounter(int reason, int delta)
181 EXCLUSIVE_LOCKS_REQUIRED(&encoder_queue_);
182
183 rtc::Event shutdown_event_; 175 rtc::Event shutdown_event_;
184 176
185 const uint32_t number_of_cores_; 177 const uint32_t number_of_cores_;
186 // Counts how many frames we've dropped in the initial rampup phase. 178 // Counts how many frames we've dropped in the initial rampup phase.
187 int initial_rampup_; 179 int initial_rampup_;
188 180
189 const std::unique_ptr<VideoSourceProxy> source_proxy_; 181 const std::unique_ptr<VideoSourceProxy> source_proxy_;
190 EncoderSink* sink_; 182 EncoderSink* sink_;
191 const VideoSendStream::Config::EncoderSettings settings_; 183 const VideoSendStream::Config::EncoderSettings settings_;
192 const VideoCodecType codec_type_; 184 const VideoCodecType codec_type_;
(...skipping 18 matching lines...) Expand all
211 // encoder on the next frame. 203 // encoder on the next frame.
212 bool pending_encoder_reconfiguration_ ACCESS_ON(&encoder_queue_); 204 bool pending_encoder_reconfiguration_ ACCESS_ON(&encoder_queue_);
213 rtc::Optional<VideoFrameInfo> last_frame_info_ ACCESS_ON(&encoder_queue_); 205 rtc::Optional<VideoFrameInfo> last_frame_info_ ACCESS_ON(&encoder_queue_);
214 uint32_t encoder_start_bitrate_bps_ ACCESS_ON(&encoder_queue_); 206 uint32_t encoder_start_bitrate_bps_ ACCESS_ON(&encoder_queue_);
215 size_t max_data_payload_length_ ACCESS_ON(&encoder_queue_); 207 size_t max_data_payload_length_ ACCESS_ON(&encoder_queue_);
216 bool nack_enabled_ ACCESS_ON(&encoder_queue_); 208 bool nack_enabled_ ACCESS_ON(&encoder_queue_);
217 uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_); 209 uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_);
218 bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_); 210 bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_);
219 Clock* const clock_; 211 Clock* const clock_;
220 // Counters used for deciding if the video resolution is currently 212 // Counters used for deciding if the video resolution is currently
221 // restricted, and if so, why, on a per degradation preference basis. 213 // restricted, and if so, why.
222 // TODO(sprang): Replace this with a state holding a relative overuse measure 214 std::vector<int> scale_counter_ ACCESS_ON(&encoder_queue_);
223 // instead, that can be translated into suitable down-scale or fps limit.
224 std::map<const VideoSendStream::DegradationPreference, std::vector<int>>
225 scale_counters_ ACCESS_ON(&encoder_queue_);
226 // Set depending on degradation preferences 215 // Set depending on degradation preferences
227 VideoSendStream::DegradationPreference degradation_preference_ 216 VideoSendStream::DegradationPreference degradation_preference_
228 ACCESS_ON(&encoder_queue_); 217 ACCESS_ON(&encoder_queue_);
229 218
230 struct AdaptationRequest { 219 struct AdaptationRequest {
231 // The pixel count produced by the source at the time of the adaptation. 220 // The pixel count produced by the source at the time of the adaptation.
232 int input_pixel_count_; 221 int input_pixel_count_;
233 // Framerate received from the source at the time of the adaptation.
234 int framerate_fps_;
235 // Indicates if request was to adapt up or down. 222 // Indicates if request was to adapt up or down.
236 enum class Mode { kAdaptUp, kAdaptDown } mode_; 223 enum class Mode { kAdaptUp, kAdaptDown } mode_;
237 }; 224 };
238 // Stores a snapshot of the last adaptation request triggered by an AdaptUp 225 // Stores a snapshot of the last adaptation request triggered by an AdaptUp
239 // or AdaptDown signal. 226 // or AdaptDown signal.
240 rtc::Optional<AdaptationRequest> last_adaptation_request_ 227 rtc::Optional<AdaptationRequest> last_adaptation_request_
241 ACCESS_ON(&encoder_queue_); 228 ACCESS_ON(&encoder_queue_);
242 229
243 rtc::RaceChecker incoming_frame_race_checker_ 230 rtc::RaceChecker incoming_frame_race_checker_
244 GUARDED_BY(incoming_frame_race_checker_); 231 GUARDED_BY(incoming_frame_race_checker_);
(...skipping 13 matching lines...) Expand all
258 // All public methods are proxied to |encoder_queue_|. It must must be 245 // All public methods are proxied to |encoder_queue_|. It must must be
259 // destroyed first to make sure no tasks are run that use other members. 246 // destroyed first to make sure no tasks are run that use other members.
260 rtc::TaskQueue encoder_queue_; 247 rtc::TaskQueue encoder_queue_;
261 248
262 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); 249 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder);
263 }; 250 };
264 251
265 } // namespace webrtc 252 } // namespace webrtc
266 253
267 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ 254 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_
OLDNEW
« no previous file with comments | « webrtc/video/video_send_stream_tests.cc ('k') | webrtc/video/vie_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698