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

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

Issue 2351633002: Let ViEEncoder handle resolution changes. (Closed)
Patch Set: rebased 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_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 <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/common_video/rotation.h"
24 #include "webrtc/media/base/videosinkinterface.h" 25 #include "webrtc/media/base/videosinkinterface.h"
25 #include "webrtc/modules/video_coding/include/video_coding_defines.h" 26 #include "webrtc/modules/video_coding/include/video_coding_defines.h"
26 #include "webrtc/modules/video_coding/utility/simulcast_rate_allocator.h" 27 #include "webrtc/modules/video_coding/utility/simulcast_rate_allocator.h"
27 #include "webrtc/modules/video_coding/video_coding_impl.h" 28 #include "webrtc/modules/video_coding/video_coding_impl.h"
28 #include "webrtc/modules/video_processing/include/video_processing.h" 29 #include "webrtc/modules/video_processing/include/video_processing.h"
29 #include "webrtc/system_wrappers/include/atomic32.h" 30 #include "webrtc/system_wrappers/include/atomic32.h"
30 #include "webrtc/video/overuse_frame_detector.h" 31 #include "webrtc/video/overuse_frame_detector.h"
31 #include "webrtc/video_encoder.h" 32 #include "webrtc/video_encoder.h"
32 #include "webrtc/video_send_stream.h" 33 #include "webrtc/video_send_stream.h"
33 #include "webrtc/typedefs.h" 34 #include "webrtc/typedefs.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 96
96 void OnBitrateUpdated(uint32_t bitrate_bps, 97 void OnBitrateUpdated(uint32_t bitrate_bps,
97 uint8_t fraction_lost, 98 uint8_t fraction_lost,
98 int64_t round_trip_time_ms); 99 int64_t round_trip_time_ms);
99 100
100 private: 101 private:
101 class ConfigureEncoderTask; 102 class ConfigureEncoderTask;
102 class EncodeTask; 103 class EncodeTask;
103 class VideoSourceProxy; 104 class VideoSourceProxy;
104 105
106 struct VideoFrameInfo {
107 VideoFrameInfo(int width,
108 int height,
109 VideoRotation rotation,
110 bool is_texture)
111 : width(width),
112 height(height),
113 rotation(rotation),
114 is_texture(is_texture) {}
115 int width;
116 int height;
117 webrtc::VideoRotation rotation;
118 bool is_texture;
119 };
120
105 void ConfigureEncoderOnTaskQueue(VideoEncoderConfig config, 121 void ConfigureEncoderOnTaskQueue(VideoEncoderConfig config,
106 size_t max_data_payload_length); 122 size_t max_data_payload_length);
123 void ReconfigureEncoder();
107 124
108 // Implements VideoSinkInterface. 125 // Implements VideoSinkInterface.
109 void OnFrame(const VideoFrame& video_frame) override; 126 void OnFrame(const VideoFrame& video_frame) override;
110 127
111 // Implements VideoSendStatisticsCallback. 128 // Implements VideoSendStatisticsCallback.
112 void SendStatistics(uint32_t bit_rate, 129 void SendStatistics(uint32_t bit_rate,
113 uint32_t frame_rate) override; 130 uint32_t frame_rate) override;
114 131
115 void EncodeVideoFrame(const VideoFrame& frame, 132 void EncodeVideoFrame(const VideoFrame& frame,
116 int64_t time_when_posted_in_ms); 133 int64_t time_when_posted_in_ms);
(...skipping 14 matching lines...) Expand all
131 148
132 rtc::Event shutdown_event_; 149 rtc::Event shutdown_event_;
133 150
134 const uint32_t number_of_cores_; 151 const uint32_t number_of_cores_;
135 152
136 const std::unique_ptr<VideoSourceProxy> source_proxy_; 153 const std::unique_ptr<VideoSourceProxy> source_proxy_;
137 EncoderSink* sink_; 154 EncoderSink* sink_;
138 const VideoSendStream::Config::EncoderSettings settings_; 155 const VideoSendStream::Config::EncoderSettings settings_;
139 const VideoCodecType codec_type_; 156 const VideoCodecType codec_type_;
140 157
141 const std::unique_ptr<VideoProcessing> vp_;
142 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_); 158 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_);
143 159
144 OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_); 160 OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_);
145 LoadObserver* const load_observer_ ACCESS_ON(&encoder_queue_); 161 LoadObserver* const load_observer_ ACCESS_ON(&encoder_queue_);
146 162
147 SendStatisticsProxy* const stats_proxy_; 163 SendStatisticsProxy* const stats_proxy_;
148 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; 164 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_;
149 ProcessThread* module_process_thread_; 165 ProcessThread* module_process_thread_;
150 rtc::ThreadChecker module_process_thread_checker_; 166 rtc::ThreadChecker module_process_thread_checker_;
151 // |thread_checker_| checks that public methods that are related to lifetime 167 // |thread_checker_| checks that public methods that are related to lifetime
152 // of ViEEncoder are called on the same thread. 168 // of ViEEncoder are called on the same thread.
153 rtc::ThreadChecker thread_checker_; 169 rtc::ThreadChecker thread_checker_;
154 170
155 VideoEncoderConfig encoder_config_ ACCESS_ON(&encoder_queue_); 171 VideoEncoderConfig encoder_config_ ACCESS_ON(&encoder_queue_);
156 // TODO(sprang): Change |rate_allocator_| to be a codec type 172 // TODO(sprang): Change |rate_allocator_| to be a codec type
157 // agnostic interface. It is currently VP8 simulcast specific if more than 173 // agnostic interface. It is currently VP8 simulcast specific if more than
158 // one layer is specified. 174 // one layer is specified.
159 std::unique_ptr<SimulcastRateAllocator> rate_allocator_ 175 std::unique_ptr<SimulcastRateAllocator> rate_allocator_
160 ACCESS_ON(&encoder_queue_); 176 ACCESS_ON(&encoder_queue_);
161 177
178 // Set when ConfigureEncoder has been called in order to lazy reconfigure the
179 // encoder on the next frame.
180 bool pending_encoder_reconfiguration_ ACCESS_ON(&encoder_queue_);
181 rtc::Optional<VideoFrameInfo> last_frame_info_ ACCESS_ON(&encoder_queue_);
162 uint32_t encoder_start_bitrate_bps_ ACCESS_ON(&encoder_queue_); 182 uint32_t encoder_start_bitrate_bps_ ACCESS_ON(&encoder_queue_);
163 size_t max_data_payload_length_ ACCESS_ON(&encoder_queue_); 183 size_t max_data_payload_length_ ACCESS_ON(&encoder_queue_);
164 uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_); 184 uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_);
165 bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_); 185 bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_);
166 bool has_received_sli_ ACCESS_ON(&encoder_queue_); 186 bool has_received_sli_ ACCESS_ON(&encoder_queue_);
167 uint8_t picture_id_sli_ ACCESS_ON(&encoder_queue_); 187 uint8_t picture_id_sli_ ACCESS_ON(&encoder_queue_);
168 bool has_received_rpsi_ ACCESS_ON(&encoder_queue_); 188 bool has_received_rpsi_ ACCESS_ON(&encoder_queue_);
169 uint64_t picture_id_rpsi_ ACCESS_ON(&encoder_queue_); 189 uint64_t picture_id_rpsi_ ACCESS_ON(&encoder_queue_);
170 Clock* const clock_; 190 Clock* const clock_;
171 191
(...skipping 11 matching lines...) Expand all
183 // All public methods are proxied to |encoder_queue_|. It must must be 203 // All public methods are proxied to |encoder_queue_|. It must must be
184 // destroyed first to make sure no tasks are run that use other members. 204 // destroyed first to make sure no tasks are run that use other members.
185 rtc::TaskQueue encoder_queue_; 205 rtc::TaskQueue encoder_queue_;
186 206
187 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); 207 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder);
188 }; 208 };
189 209
190 } // namespace webrtc 210 } // namespace webrtc
191 211
192 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ 212 #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