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

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

Issue 2368223002: Add VideoSendStream::Stats::prefered_media_bitrate_bps (Closed)
Patch Set: Addressed nits Created 4 years, 2 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.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 <memory> 14 #include <memory>
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/base/criticalsection.h" 18 #include "webrtc/base/criticalsection.h"
19 #include "webrtc/base/event.h" 19 #include "webrtc/base/event.h"
20 #include "webrtc/base/sequenced_task_checker.h" 20 #include "webrtc/base/sequenced_task_checker.h"
21 #include "webrtc/base/task_queue.h" 21 #include "webrtc/base/task_queue.h"
22 #include "webrtc/call.h" 22 #include "webrtc/call.h"
23 #include "webrtc/common_types.h" 23 #include "webrtc/common_types.h"
24 #include "webrtc/media/base/videosinkinterface.h" 24 #include "webrtc/media/base/videosinkinterface.h"
25 #include "webrtc/modules/video_coding/include/video_coding_defines.h" 25 #include "webrtc/modules/video_coding/include/video_coding_defines.h"
26 #include "webrtc/modules/video_coding/utility/simulcast_rate_allocator.h"
26 #include "webrtc/modules/video_coding/video_coding_impl.h" 27 #include "webrtc/modules/video_coding/video_coding_impl.h"
27 #include "webrtc/modules/video_processing/include/video_processing.h" 28 #include "webrtc/modules/video_processing/include/video_processing.h"
28 #include "webrtc/system_wrappers/include/atomic32.h" 29 #include "webrtc/system_wrappers/include/atomic32.h"
29 #include "webrtc/video/overuse_frame_detector.h" 30 #include "webrtc/video/overuse_frame_detector.h"
30 #include "webrtc/video_encoder.h" 31 #include "webrtc/video_encoder.h"
31 #include "webrtc/video_send_stream.h" 32 #include "webrtc/video_send_stream.h"
32 #include "webrtc/typedefs.h" 33 #include "webrtc/typedefs.h"
33 34
34 namespace webrtc { 35 namespace webrtc {
35 36
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // virtual to test EncoderStateFeedback with mocks. 91 // virtual to test EncoderStateFeedback with mocks.
91 virtual void OnReceivedIntraFrameRequest(size_t stream_index); 92 virtual void OnReceivedIntraFrameRequest(size_t stream_index);
92 virtual void OnReceivedSLI(uint8_t picture_id); 93 virtual void OnReceivedSLI(uint8_t picture_id);
93 virtual void OnReceivedRPSI(uint64_t picture_id); 94 virtual void OnReceivedRPSI(uint64_t picture_id);
94 95
95 void OnBitrateUpdated(uint32_t bitrate_bps, 96 void OnBitrateUpdated(uint32_t bitrate_bps,
96 uint8_t fraction_lost, 97 uint8_t fraction_lost,
97 int64_t round_trip_time_ms); 98 int64_t round_trip_time_ms);
98 99
99 private: 100 private:
101 class ConfigureEncoderTask;
100 class EncodeTask; 102 class EncodeTask;
101 class VideoSourceProxy; 103 class VideoSourceProxy;
102 104
103 void ConfigureEncoderInternal(const VideoCodec& video_codec, 105 void ConfigureEncoderOnTaskQueue(VideoEncoderConfig config,
104 size_t max_data_payload_length, 106 size_t max_data_payload_length);
105 std::vector<VideoStream> stream,
106 int min_transmit_bitrate);
107 107
108 // Implements VideoSinkInterface. 108 // Implements VideoSinkInterface.
109 void OnFrame(const VideoFrame& video_frame) override; 109 void OnFrame(const VideoFrame& video_frame) override;
110 110
111 // Implements VideoSendStatisticsCallback. 111 // Implements VideoSendStatisticsCallback.
112 void SendStatistics(uint32_t bit_rate, 112 void SendStatistics(uint32_t bit_rate,
113 uint32_t frame_rate) override; 113 uint32_t frame_rate) override;
114 114
115 void EncodeVideoFrame(const VideoFrame& frame, 115 void EncodeVideoFrame(const VideoFrame& frame,
116 int64_t time_when_posted_in_ms); 116 int64_t time_when_posted_in_ms);
(...skipping 12 matching lines...) Expand all
129 void TraceFrameDropStart(); 129 void TraceFrameDropStart();
130 void TraceFrameDropEnd(); 130 void TraceFrameDropEnd();
131 131
132 rtc::Event shutdown_event_; 132 rtc::Event shutdown_event_;
133 133
134 const uint32_t number_of_cores_; 134 const uint32_t number_of_cores_;
135 135
136 const std::unique_ptr<VideoSourceProxy> source_proxy_; 136 const std::unique_ptr<VideoSourceProxy> source_proxy_;
137 EncoderSink* sink_; 137 EncoderSink* sink_;
138 const VideoSendStream::Config::EncoderSettings settings_; 138 const VideoSendStream::Config::EncoderSettings settings_;
139 const VideoCodecType codec_type_;
139 140
140 const std::unique_ptr<VideoProcessing> vp_; 141 const std::unique_ptr<VideoProcessing> vp_;
141 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_); 142 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_);
142 143
143 OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_); 144 OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_);
144 LoadObserver* const load_observer_ ACCESS_ON(&encoder_queue_); 145 LoadObserver* const load_observer_ ACCESS_ON(&encoder_queue_);
145 146
146 SendStatisticsProxy* const stats_proxy_; 147 SendStatisticsProxy* const stats_proxy_;
147 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; 148 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_;
148 ProcessThread* module_process_thread_; 149 ProcessThread* module_process_thread_;
149 rtc::ThreadChecker module_process_thread_checker_; 150 rtc::ThreadChecker module_process_thread_checker_;
150 // |thread_checker_| checks that public methods that are related to lifetime 151 // |thread_checker_| checks that public methods that are related to lifetime
151 // of ViEEncoder are called on the same thread. 152 // of ViEEncoder are called on the same thread.
152 rtc::ThreadChecker thread_checker_; 153 rtc::ThreadChecker thread_checker_;
153 154
154 VideoCodec encoder_config_ ACCESS_ON(&encoder_queue_); 155 VideoEncoderConfig encoder_config_ ACCESS_ON(&encoder_queue_);
156 // TODO(sprang): Change |rate_allocator_| to be a codec type
157 // agnostic interface. It is currently VP8 simulcast specific if more than
158 // one layer is specified.
159 std::unique_ptr<SimulcastRateAllocator> rate_allocator_
160 ACCESS_ON(&encoder_queue_);
155 161
156 int encoder_start_bitrate_bps_ ACCESS_ON(&encoder_queue_); 162 uint32_t encoder_start_bitrate_bps_ ACCESS_ON(&encoder_queue_);
163 size_t max_data_payload_length_ ACCESS_ON(&encoder_queue_);
157 uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_); 164 uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_);
158 bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_); 165 bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_);
159 bool has_received_sli_ ACCESS_ON(&encoder_queue_); 166 bool has_received_sli_ ACCESS_ON(&encoder_queue_);
160 uint8_t picture_id_sli_ ACCESS_ON(&encoder_queue_); 167 uint8_t picture_id_sli_ ACCESS_ON(&encoder_queue_);
161 bool has_received_rpsi_ ACCESS_ON(&encoder_queue_); 168 bool has_received_rpsi_ ACCESS_ON(&encoder_queue_);
162 uint64_t picture_id_rpsi_ ACCESS_ON(&encoder_queue_); 169 uint64_t picture_id_rpsi_ ACCESS_ON(&encoder_queue_);
163 Clock* const clock_; 170 Clock* const clock_;
164 171
165 rtc::RaceChecker incoming_frame_race_checker_; 172 rtc::RaceChecker incoming_frame_race_checker_;
166 Atomic32 posted_frames_waiting_for_encode_; 173 Atomic32 posted_frames_waiting_for_encode_;
167 // Used to make sure incoming time stamp is increasing for every frame. 174 // Used to make sure incoming time stamp is increasing for every frame.
168 int64_t last_captured_timestamp_ GUARDED_BY(incoming_frame_race_checker_); 175 int64_t last_captured_timestamp_ GUARDED_BY(incoming_frame_race_checker_);
169 // Delta used for translating between NTP and internal timestamps. 176 // Delta used for translating between NTP and internal timestamps.
170 const int64_t delta_ntp_internal_ms_; 177 const int64_t delta_ntp_internal_ms_;
171 178
172 int64_t last_frame_log_ms_ GUARDED_BY(incoming_frame_race_checker_); 179 int64_t last_frame_log_ms_ GUARDED_BY(incoming_frame_race_checker_);
173 int captured_frame_count_ ACCESS_ON(&encoder_queue_); 180 int captured_frame_count_ ACCESS_ON(&encoder_queue_);
174 int dropped_frame_count_ ACCESS_ON(&encoder_queue_); 181 int dropped_frame_count_ ACCESS_ON(&encoder_queue_);
175 182
176 // All public methods are proxied to |encoder_queue_|. It must must be 183 // All public methods are proxied to |encoder_queue_|. It must must be
177 // destroyed first to make sure no tasks are run that use other members. 184 // destroyed first to make sure no tasks are run that use other members.
178 rtc::TaskQueue encoder_queue_; 185 rtc::TaskQueue encoder_queue_;
179 186
180 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); 187 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder);
181 }; 188 };
182 189
183 } // namespace webrtc 190 } // namespace webrtc
184 191
185 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ 192 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_
OLDNEW
« no previous file with comments | « webrtc/video/video_send_stream.cc ('k') | webrtc/video/vie_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698