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

Side by Side Diff: webrtc/modules/video_coding/media_optimization.h

Issue 1972083002: Move logic for calculating needed bitrate overhead used by NACK and FEC to VideoSender. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed Åsas comments. Created 4 years, 6 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
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
(...skipping 20 matching lines...) Expand all
31 class MediaOptimization { 31 class MediaOptimization {
32 public: 32 public:
33 explicit MediaOptimization(Clock* clock); 33 explicit MediaOptimization(Clock* clock);
34 ~MediaOptimization(); 34 ~MediaOptimization();
35 35
36 // TODO(andresp): Can Reset and SetEncodingData be done at construction time 36 // TODO(andresp): Can Reset and SetEncodingData be done at construction time
37 // only? 37 // only?
38 void Reset(); 38 void Reset();
39 39
40 // Informs media optimization of initial encoding state. 40 // Informs media optimization of initial encoding state.
41 void SetEncodingData(VideoCodecType send_codec_type, 41 // TODO(perkj): Deprecate SetEncodingData once its not used for stats in
42 int32_t max_bit_rate, 42 // VieEncoder.
43 void SetEncodingData(int32_t max_bit_rate,
43 uint32_t bit_rate, 44 uint32_t bit_rate,
44 uint16_t width, 45 uint16_t width,
45 uint16_t height, 46 uint16_t height,
46 uint32_t frame_rate, 47 uint32_t frame_rate,
47 int num_temporal_layers, 48 int num_temporal_layers,
48 int32_t mtu); 49 int32_t mtu);
49 50
50 // Sets target rates for the encoder given the channel parameters. 51 // Sets target rates for the encoder given the channel parameters.
51 // Inputs: target bitrate - the encoder target bitrate in bits/s. 52 // Inputs: target bitrate - the encoder target bitrate in bits/s.
52 // fraction_lost - packet loss rate in % in the network. 53 // fraction_lost - packet loss rate in % in the network.
53 // round_trip_time_ms - round trip time in milliseconds. 54 // round_trip_time_ms - round trip time in milliseconds.
54 // min_bit_rate - the bit rate of the end-point with lowest rate. 55 // min_bit_rate - the bit rate of the end-point with lowest rate.
55 // max_bit_rate - the bit rate of the end-point with highest rate. 56 // max_bit_rate - the bit rate of the end-point with highest rate.
56 // TODO(andresp): Find if the callbacks can be triggered only after releasing
57 // an internal critical section.
58 uint32_t SetTargetRates(uint32_t target_bitrate, 57 uint32_t SetTargetRates(uint32_t target_bitrate,
59 uint8_t fraction_lost, 58 uint8_t fraction_lost,
60 int64_t round_trip_time_ms, 59 int64_t round_trip_time_ms);
61 VCMProtectionCallback* protection_callback);
62 60
63 void SetProtectionMethod(VCMProtectionMethodEnum method);
64 void EnableFrameDropper(bool enable); 61 void EnableFrameDropper(bool enable);
65 62
66 // Lets the sender suspend video when the rate drops below 63 // Lets the sender suspend video when the rate drops below
67 // |threshold_bps|, and turns back on when the rate goes back up above 64 // |threshold_bps|, and turns back on when the rate goes back up above
68 // |threshold_bps| + |window_bps|. 65 // |threshold_bps| + |window_bps|.
69 void SuspendBelowMinBitrate(int threshold_bps, int window_bps); 66 void SuspendBelowMinBitrate(int threshold_bps, int window_bps);
70 bool IsVideoSuspended() const; 67 bool IsVideoSuspended() const;
71 68
72 bool DropFrame(); 69 bool DropFrame();
73 70
74 // Informs Media Optimization of encoded output. 71 // Informs Media Optimization of encoded output.
72 // TODO(perkj): Deprecate SetEncodingData once its not used for stats in
73 // VieEncoder.
75 int32_t UpdateWithEncodedData(const EncodedImage& encoded_image); 74 int32_t UpdateWithEncodedData(const EncodedImage& encoded_image);
76 75
77 // InputFrameRate 0 = no frame rate estimate available. 76 // InputFrameRate 0 = no frame rate estimate available.
78 uint32_t InputFrameRate(); 77 uint32_t InputFrameRate();
79 uint32_t SentFrameRate(); 78 uint32_t SentFrameRate();
80 uint32_t SentBitRate(); 79 uint32_t SentBitRate();
81 80
82 private: 81 private:
83 enum { kFrameCountHistorySize = 90 }; 82 enum { kFrameCountHistorySize = 90 };
84 enum { kFrameHistoryWinMs = 2000 }; 83 enum { kFrameHistoryWinMs = 2000 };
85 enum { kBitrateAverageWinMs = 1000 }; 84 enum { kBitrateAverageWinMs = 1000 };
86 85
87 struct EncodedFrameSample; 86 struct EncodedFrameSample;
88 typedef std::list<EncodedFrameSample> FrameSampleList; 87 typedef std::list<EncodedFrameSample> FrameSampleList;
89 88
90 void UpdateIncomingFrameRate() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); 89 void UpdateIncomingFrameRate() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
91 void PurgeOldFrameSamples(int64_t now_ms) 90 void PurgeOldFrameSamples(int64_t now_ms)
92 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); 91 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
93 void UpdateSentBitrate(int64_t now_ms) EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); 92 void UpdateSentBitrate(int64_t now_ms) EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
94 void UpdateSentFramerate() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); 93 void UpdateSentFramerate() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
95 94
96 void ProcessIncomingFrameRate(int64_t now) 95 void ProcessIncomingFrameRate(int64_t now)
97 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); 96 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
98 97
99 // Checks conditions for suspending the video. The method compares 98 // Checks conditions for suspending the video. The method compares
100 // |video_target_bitrate_| with the threshold values for suspension, and 99 // |video_target_bitrate_| with the threshold values for suspension, and
101 // changes the state of |video_suspended_| accordingly. 100 // changes the state of |video_suspended_| accordingly.
102 void CheckSuspendConditions() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); 101 void CheckSuspendConditions() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
103 102
104 void SetEncodingDataInternal(VideoCodecType send_codec_type, 103 void SetEncodingDataInternal(int32_t max_bit_rate,
105 int32_t max_bit_rate,
106 uint32_t frame_rate, 104 uint32_t frame_rate,
107 uint32_t bit_rate, 105 uint32_t bit_rate,
108 uint16_t width, 106 uint16_t width,
109 uint16_t height, 107 uint16_t height,
110 int num_temporal_layers, 108 int num_temporal_layers,
111 int32_t mtu) 109 int32_t mtu)
112 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); 110 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
113 111
114 uint32_t InputFrameRateInternal() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); 112 uint32_t InputFrameRateInternal() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
115 113
116 uint32_t SentFrameRateInternal() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); 114 uint32_t SentFrameRateInternal() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
117 115
118 // Protect all members. 116 // Protect all members.
119 std::unique_ptr<CriticalSectionWrapper> crit_sect_; 117 std::unique_ptr<CriticalSectionWrapper> crit_sect_;
120 118
121 Clock* clock_ GUARDED_BY(crit_sect_); 119 Clock* clock_ GUARDED_BY(crit_sect_);
122 int32_t max_bit_rate_ GUARDED_BY(crit_sect_); 120 int32_t max_bit_rate_ GUARDED_BY(crit_sect_);
123 VideoCodecType send_codec_type_ GUARDED_BY(crit_sect_);
124 uint16_t codec_width_ GUARDED_BY(crit_sect_); 121 uint16_t codec_width_ GUARDED_BY(crit_sect_);
125 uint16_t codec_height_ GUARDED_BY(crit_sect_); 122 uint16_t codec_height_ GUARDED_BY(crit_sect_);
126 float user_frame_rate_ GUARDED_BY(crit_sect_); 123 float user_frame_rate_ GUARDED_BY(crit_sect_);
127 std::unique_ptr<FrameDropper> frame_dropper_ GUARDED_BY(crit_sect_); 124 std::unique_ptr<FrameDropper> frame_dropper_ GUARDED_BY(crit_sect_);
128 std::unique_ptr<VCMLossProtectionLogic> loss_prot_logic_
129 GUARDED_BY(crit_sect_);
130 uint8_t fraction_lost_ GUARDED_BY(crit_sect_); 125 uint8_t fraction_lost_ GUARDED_BY(crit_sect_);
131 uint32_t send_statistics_[4] GUARDED_BY(crit_sect_); 126 uint32_t send_statistics_[4] GUARDED_BY(crit_sect_);
132 uint32_t send_statistics_zero_encode_ GUARDED_BY(crit_sect_); 127 uint32_t send_statistics_zero_encode_ GUARDED_BY(crit_sect_);
133 int32_t max_payload_size_ GUARDED_BY(crit_sect_); 128 int32_t max_payload_size_ GUARDED_BY(crit_sect_);
134 int video_target_bitrate_ GUARDED_BY(crit_sect_); 129 int video_target_bitrate_ GUARDED_BY(crit_sect_);
135 float incoming_frame_rate_ GUARDED_BY(crit_sect_); 130 float incoming_frame_rate_ GUARDED_BY(crit_sect_);
136 int64_t incoming_frame_times_[kFrameCountHistorySize] GUARDED_BY(crit_sect_); 131 int64_t incoming_frame_times_[kFrameCountHistorySize] GUARDED_BY(crit_sect_);
137 std::list<EncodedFrameSample> encoded_frame_samples_ GUARDED_BY(crit_sect_); 132 std::list<EncodedFrameSample> encoded_frame_samples_ GUARDED_BY(crit_sect_);
138 uint32_t avg_sent_bit_rate_bps_ GUARDED_BY(crit_sect_); 133 uint32_t avg_sent_bit_rate_bps_ GUARDED_BY(crit_sect_);
139 uint32_t avg_sent_framerate_ GUARDED_BY(crit_sect_); 134 uint32_t avg_sent_framerate_ GUARDED_BY(crit_sect_);
140 uint32_t key_frame_cnt_ GUARDED_BY(crit_sect_);
141 uint32_t delta_frame_cnt_ GUARDED_BY(crit_sect_);
142 int num_layers_ GUARDED_BY(crit_sect_); 135 int num_layers_ GUARDED_BY(crit_sect_);
143 bool suspension_enabled_ GUARDED_BY(crit_sect_); 136 bool suspension_enabled_ GUARDED_BY(crit_sect_);
144 bool video_suspended_ GUARDED_BY(crit_sect_); 137 bool video_suspended_ GUARDED_BY(crit_sect_);
145 int suspension_threshold_bps_ GUARDED_BY(crit_sect_); 138 int suspension_threshold_bps_ GUARDED_BY(crit_sect_);
146 int suspension_window_bps_ GUARDED_BY(crit_sect_); 139 int suspension_window_bps_ GUARDED_BY(crit_sect_);
147 }; 140 };
148 } // namespace media_optimization 141 } // namespace media_optimization
149 } // namespace webrtc 142 } // namespace webrtc
150 143
151 #endif // WEBRTC_MODULES_VIDEO_CODING_MEDIA_OPTIMIZATION_H_ 144 #endif // WEBRTC_MODULES_VIDEO_CODING_MEDIA_OPTIMIZATION_H_
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/include/video_coding.h ('k') | webrtc/modules/video_coding/media_optimization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698