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

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

Issue 2351633002: Let ViEEncoder handle resolution changes. (Closed)
Patch Set: Fix perf test 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
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 18 matching lines...) Expand all
29 #include "webrtc/video/overuse_frame_detector.h" 29 #include "webrtc/video/overuse_frame_detector.h"
30 #include "webrtc/video_encoder.h" 30 #include "webrtc/video_encoder.h"
31 #include "webrtc/video_send_stream.h" 31 #include "webrtc/video_send_stream.h"
32 #include "webrtc/typedefs.h" 32 #include "webrtc/typedefs.h"
33 33
34 namespace webrtc { 34 namespace webrtc {
35 35
36 class ProcessThread; 36 class ProcessThread;
37 class SendStatisticsProxy; 37 class SendStatisticsProxy;
38 38
39 class ViEEncoderSink : public EncodedImageCallback {
40 public:
41 virtual void EncoderConfigurationChanged(
42 const std::vector<VideoStream>& stream) = 0;
43 };
44
39 // VieEncoder represent a video encoder that accepts raw video frames as input 45 // VieEncoder represent a video encoder that accepts raw video frames as input
40 // and produces an encoded bit stream. 46 // and produces an encoded bit stream.
41 // Usage: 47 // Usage:
42 // Instantiate. 48 // Instantiate.
43 // Call SetSink. 49 // Call SetSink.
44 // Call SetSource. 50 // Call SetSource.
45 // Call ConfigureEncoder with the codec settings. 51 // Call ConfigureEncoder with the codec settings.
46 // Call Stop() when done. 52 // Call Stop() when done.
47 class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>, 53 class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>,
48 public EncodedImageCallback, 54 public EncodedImageCallback,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 virtual void OnReceivedIntraFrameRequest(size_t stream_index); 97 virtual void OnReceivedIntraFrameRequest(size_t stream_index);
92 virtual void OnReceivedSLI(uint8_t picture_id); 98 virtual void OnReceivedSLI(uint8_t picture_id);
93 virtual void OnReceivedRPSI(uint64_t picture_id); 99 virtual void OnReceivedRPSI(uint64_t picture_id);
94 100
95 void OnBitrateUpdated(uint32_t bitrate_bps, 101 void OnBitrateUpdated(uint32_t bitrate_bps,
96 uint8_t fraction_lost, 102 uint8_t fraction_lost,
97 int64_t round_trip_time_ms); 103 int64_t round_trip_time_ms);
98 104
99 private: 105 private:
100 class EncodeTask; 106 class EncodeTask;
107 class ConfigureEncoderTask;
101 class VideoSourceProxy; 108 class VideoSourceProxy;
102 109
103 void ConfigureEncoderInternal(const VideoCodec& video_codec, 110 struct VideoFrameInfo {
104 size_t max_data_payload_length, 111 VideoFrameInfo(int width,
105 std::vector<VideoStream> stream, 112 int height,
106 int min_transmit_bitrate); 113 VideoRotation rotation,
114 bool is_texture)
115 : width(width),
116 height(height),
117 rotation(rotation),
118 is_texture(is_texture) {}
119 int width;
120 int height;
121 webrtc::VideoRotation rotation;
122 bool is_texture;
123 };
124
125 void ConfigureEncoderOnTaskQueue(VideoEncoderConfig config,
126 size_t max_data_payload_length);
127 void ReconfigureEncoder();
107 128
108 // Implements VideoSinkInterface. 129 // Implements VideoSinkInterface.
109 void OnFrame(const VideoFrame& video_frame) override; 130 void OnFrame(const VideoFrame& video_frame) override;
110 131
111 // Implements VideoSendStatisticsCallback. 132 // Implements VideoSendStatisticsCallback.
112 void SendStatistics(uint32_t bit_rate, 133 void SendStatistics(uint32_t bit_rate,
113 uint32_t frame_rate) override; 134 uint32_t frame_rate) override;
114 135
115 void EncodeVideoFrame(const VideoFrame& frame, 136 void EncodeVideoFrame(const VideoFrame& frame,
116 int64_t time_when_posted_in_ms); 137 int64_t time_when_posted_in_ms);
(...skipping 12 matching lines...) Expand all
129 void TraceFrameDropStart(); 150 void TraceFrameDropStart();
130 void TraceFrameDropEnd(); 151 void TraceFrameDropEnd();
131 152
132 rtc::Event shutdown_event_; 153 rtc::Event shutdown_event_;
133 154
134 const uint32_t number_of_cores_; 155 const uint32_t number_of_cores_;
135 156
136 const std::unique_ptr<VideoSourceProxy> source_proxy_; 157 const std::unique_ptr<VideoSourceProxy> source_proxy_;
137 EncoderSink* sink_; 158 EncoderSink* sink_;
138 const VideoSendStream::Config::EncoderSettings settings_; 159 const VideoSendStream::Config::EncoderSettings settings_;
160 const VideoCodecType codec_type_;
139 161
140 const std::unique_ptr<VideoProcessing> vp_;
141 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_); 162 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_);
142 163
143 OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_); 164 OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_);
144 LoadObserver* const load_observer_ ACCESS_ON(&encoder_queue_); 165 LoadObserver* const load_observer_ ACCESS_ON(&encoder_queue_);
145 166
146 SendStatisticsProxy* const stats_proxy_; 167 SendStatisticsProxy* const stats_proxy_;
147 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; 168 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_;
148 ProcessThread* module_process_thread_; 169 ProcessThread* module_process_thread_;
149 rtc::ThreadChecker module_process_thread_checker_; 170 rtc::ThreadChecker module_process_thread_checker_;
150 // |thread_checker_| checks that public methods that are related to lifetime 171 // |thread_checker_| checks that public methods that are related to lifetime
151 // of ViEEncoder are called on the same thread. 172 // of ViEEncoder are called on the same thread.
152 rtc::ThreadChecker thread_checker_; 173 rtc::ThreadChecker thread_checker_;
153 174
154 VideoCodec encoder_config_ ACCESS_ON(&encoder_queue_); 175 VideoEncoderConfig encoder_config_ ACCESS_ON(&encoder_queue_);
155 176
156 int encoder_start_bitrate_bps_ ACCESS_ON(&encoder_queue_); 177 bool pending_encoder_reconfiguration_ ACCESS_ON(&encoder_queue_);
sprang_webrtc 2016/09/22 13:06:16 Is encoder_config_ only is in ReconfigureEncoder()
perkj_webrtc 2016/09/26 12:09:42 no- also when the input size change. The the encod
sprang_webrtc 2016/09/26 13:47:37 Acknowledged.
178 rtc::Optional<VideoFrameInfo> last_frame_info_ ACCESS_ON(&encoder_queue_);
179
180 unsigned int encoder_start_bitrate_bps_ ACCESS_ON(&encoder_queue_);
sprang_webrtc 2016/09/22 13:06:16 nit: uint32_t
perkj_webrtc 2016/09/26 12:09:42 Done.
181 size_t max_data_payload_length_ ACCESS_ON(&encoder_queue_);
157 uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_); 182 uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_);
158 bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_); 183 bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_);
159 bool has_received_sli_ ACCESS_ON(&encoder_queue_); 184 bool has_received_sli_ ACCESS_ON(&encoder_queue_);
160 uint8_t picture_id_sli_ ACCESS_ON(&encoder_queue_); 185 uint8_t picture_id_sli_ ACCESS_ON(&encoder_queue_);
161 bool has_received_rpsi_ ACCESS_ON(&encoder_queue_); 186 bool has_received_rpsi_ ACCESS_ON(&encoder_queue_);
162 uint64_t picture_id_rpsi_ ACCESS_ON(&encoder_queue_); 187 uint64_t picture_id_rpsi_ ACCESS_ON(&encoder_queue_);
163 Clock* const clock_; 188 Clock* const clock_;
164 189
165 rtc::RaceChecker incoming_frame_race_checker_; 190 rtc::RaceChecker incoming_frame_race_checker_;
166 Atomic32 posted_frames_waiting_for_encode_; 191 Atomic32 posted_frames_waiting_for_encode_;
167 // Used to make sure incoming time stamp is increasing for every frame. 192 // Used to make sure incoming time stamp is increasing for every frame.
168 int64_t last_captured_timestamp_ GUARDED_BY(incoming_frame_race_checker_); 193 int64_t last_captured_timestamp_ GUARDED_BY(incoming_frame_race_checker_);
169 // Delta used for translating between NTP and internal timestamps. 194 // Delta used for translating between NTP and internal timestamps.
170 const int64_t delta_ntp_internal_ms_; 195 const int64_t delta_ntp_internal_ms_;
171 196
172 int64_t last_frame_log_ms_ GUARDED_BY(incoming_frame_race_checker_); 197 int64_t last_frame_log_ms_ GUARDED_BY(incoming_frame_race_checker_);
173 int captured_frame_count_ ACCESS_ON(&encoder_queue_); 198 int captured_frame_count_ ACCESS_ON(&encoder_queue_);
174 int dropped_frame_count_ ACCESS_ON(&encoder_queue_); 199 int dropped_frame_count_ ACCESS_ON(&encoder_queue_);
175 200
176 // All public methods are proxied to |encoder_queue_|. It must must be 201 // 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. 202 // destroyed first to make sure no tasks are run that use other members.
178 rtc::TaskQueue encoder_queue_; 203 rtc::TaskQueue encoder_queue_;
179 204
180 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); 205 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder);
181 }; 206 };
182 207
183 } // namespace webrtc 208 } // namespace webrtc
184 209
185 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ 210 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698