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

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

Issue 2060403002: Add task queue to Call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@move_getpadding
Patch Set: Revert changes to gypi. 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 11 matching lines...) Expand all
22 #include "webrtc/modules/video_coding/include/video_coding.h" 22 #include "webrtc/modules/video_coding/include/video_coding.h"
23 #include "webrtc/modules/video_coding/include/video_coding_defines.h" 23 #include "webrtc/modules/video_coding/include/video_coding_defines.h"
24 #include "webrtc/system_wrappers/include/metrics.h" 24 #include "webrtc/system_wrappers/include/metrics.h"
25 #include "webrtc/video/overuse_frame_detector.h" 25 #include "webrtc/video/overuse_frame_detector.h"
26 #include "webrtc/video/send_statistics_proxy.h" 26 #include "webrtc/video/send_statistics_proxy.h"
27 #include "webrtc/video_frame.h" 27 #include "webrtc/video_frame.h"
28 28
29 namespace webrtc { 29 namespace webrtc {
30 30
31 ViEEncoder::ViEEncoder(uint32_t number_of_cores, 31 ViEEncoder::ViEEncoder(uint32_t number_of_cores,
32 ProcessThread* module_process_thread,
33 SendStatisticsProxy* stats_proxy, 32 SendStatisticsProxy* stats_proxy,
34 OveruseFrameDetector* overuse_detector, 33 OveruseFrameDetector* overuse_detector,
35 EncodedImageCallback* sink) 34 EncodedImageCallback* sink)
36 : number_of_cores_(number_of_cores), 35 : number_of_cores_(number_of_cores),
37 sink_(sink), 36 sink_(sink),
38 vp_(VideoProcessing::Create()), 37 vp_(VideoProcessing::Create()),
39 video_sender_(Clock::GetRealTimeClock(), this, this, this), 38 video_sender_(Clock::GetRealTimeClock(), this, this, this),
40 stats_proxy_(stats_proxy), 39 stats_proxy_(stats_proxy),
41 overuse_detector_(overuse_detector), 40 overuse_detector_(overuse_detector),
42 time_of_last_frame_activity_ms_(0),
43 encoder_config_(), 41 encoder_config_(),
44 last_observed_bitrate_bps_(0), 42 last_observed_bitrate_bps_(0),
45 encoder_paused_(true), 43 encoder_paused_(true),
46 encoder_paused_and_dropped_frame_(false), 44 encoder_paused_and_dropped_frame_(false),
47 module_process_thread_(module_process_thread), 45 module_process_thread_(nullptr),
48 has_received_sli_(false), 46 has_received_sli_(false),
49 picture_id_sli_(0), 47 picture_id_sli_(0),
50 has_received_rpsi_(false), 48 has_received_rpsi_(false),
51 picture_id_rpsi_(0), 49 picture_id_rpsi_(0),
52 video_suspended_(false) { 50 video_suspended_(false) {
53 module_process_thread_->RegisterModule(&video_sender_);
54 vp_->EnableTemporalDecimation(true); 51 vp_->EnableTemporalDecimation(true);
55 } 52 }
56 53
57 vcm::VideoSender* ViEEncoder::video_sender() { 54 vcm::VideoSender* ViEEncoder::video_sender() {
58 return &video_sender_; 55 return &video_sender_;
59 } 56 }
60 57
61 ViEEncoder::~ViEEncoder() { 58 ViEEncoder::~ViEEncoder() {}
59
60 void ViEEncoder::RegisterProcessThread(ProcessThread* module_process_thread) {
61 RTC_DCHECK(!module_process_thread_);
62 module_process_thread_ = module_process_thread;
63 module_process_thread_->RegisterModule(&video_sender_);
64 }
65 void ViEEncoder::DeRegisterProcessThread() {
62 module_process_thread_->DeRegisterModule(&video_sender_); 66 module_process_thread_->DeRegisterModule(&video_sender_);
63 } 67 }
64 68
65 void ViEEncoder::Pause() { 69 void ViEEncoder::Pause() {
66 rtc::CritScope lock(&data_cs_); 70 rtc::CritScope lock(&data_cs_);
67 encoder_paused_ = true; 71 encoder_paused_ = true;
68 } 72 }
69 73
70 void ViEEncoder::Start() { 74 void ViEEncoder::Start() {
71 rtc::CritScope lock(&data_cs_); 75 rtc::CritScope lock(&data_cs_);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (encoder_paused_and_dropped_frame_) { 150 if (encoder_paused_and_dropped_frame_) {
147 TRACE_EVENT_ASYNC_END0("webrtc", "EncoderPaused", this); 151 TRACE_EVENT_ASYNC_END0("webrtc", "EncoderPaused", this);
148 } 152 }
149 encoder_paused_and_dropped_frame_ = false; 153 encoder_paused_and_dropped_frame_ = false;
150 } 154 }
151 155
152 void ViEEncoder::EncodeVideoFrame(const VideoFrame& video_frame) { 156 void ViEEncoder::EncodeVideoFrame(const VideoFrame& video_frame) {
153 VideoCodecType codec_type; 157 VideoCodecType codec_type;
154 { 158 {
155 rtc::CritScope lock(&data_cs_); 159 rtc::CritScope lock(&data_cs_);
156 time_of_last_frame_activity_ms_ = rtc::TimeMillis();
157 if (EncoderPaused()) { 160 if (EncoderPaused()) {
158 TraceFrameDropStart(); 161 TraceFrameDropStart();
159 return; 162 return;
160 } 163 }
161 TraceFrameDropEnd(); 164 TraceFrameDropEnd();
162 codec_type = encoder_config_.codecType; 165 codec_type = encoder_config_.codecType;
163 } 166 }
164 167
165 TRACE_EVENT_ASYNC_STEP0("webrtc", "Video", video_frame.render_time_ms(), 168 TRACE_EVENT_ASYNC_STEP0("webrtc", "Video", video_frame.render_time_ms(),
166 "Encode"); 169 "Encode");
(...skipping 28 matching lines...) Expand all
195 video_sender_.AddVideoFrame(*frame_to_send, &codec_specific_info); 198 video_sender_.AddVideoFrame(*frame_to_send, &codec_specific_info);
196 return; 199 return;
197 } 200 }
198 video_sender_.AddVideoFrame(*frame_to_send, nullptr); 201 video_sender_.AddVideoFrame(*frame_to_send, nullptr);
199 } 202 }
200 203
201 void ViEEncoder::SendKeyFrame() { 204 void ViEEncoder::SendKeyFrame() {
202 video_sender_.IntraFrameRequest(0); 205 video_sender_.IntraFrameRequest(0);
203 } 206 }
204 207
205 int64_t ViEEncoder::time_of_last_frame_activity_ms() {
206 rtc::CritScope lock(&data_cs_);
207 return time_of_last_frame_activity_ms_;
208 }
209
210 void ViEEncoder::OnSetRates(uint32_t bitrate_bps, int framerate) { 208 void ViEEncoder::OnSetRates(uint32_t bitrate_bps, int framerate) {
211 if (stats_proxy_) 209 if (stats_proxy_)
212 stats_proxy_->OnSetRates(bitrate_bps, framerate); 210 stats_proxy_->OnSetRates(bitrate_bps, framerate);
213 } 211 }
214 212
215 int32_t ViEEncoder::Encoded(const EncodedImage& encoded_image, 213 int32_t ViEEncoder::Encoded(const EncodedImage& encoded_image,
216 const CodecSpecificInfo* codec_specific_info, 214 const CodecSpecificInfo* codec_specific_info,
217 const RTPFragmentationHeader* fragmentation) { 215 const RTPFragmentationHeader* fragmentation) {
218 {
219 rtc::CritScope lock(&data_cs_);
220 time_of_last_frame_activity_ms_ = rtc::TimeMillis();
221 }
222 if (stats_proxy_) { 216 if (stats_proxy_) {
223 stats_proxy_->OnSendEncodedImage(encoded_image, codec_specific_info); 217 stats_proxy_->OnSendEncodedImage(encoded_image, codec_specific_info);
224 } 218 }
225 219
226 int success = 220 int success =
227 sink_->Encoded(encoded_image, codec_specific_info, fragmentation); 221 sink_->Encoded(encoded_image, codec_specific_info, fragmentation);
228 222
229 overuse_detector_->FrameSent(encoded_image._timeStamp); 223 overuse_detector_->FrameSent(encoded_image._timeStamp);
230 return success; 224 return success;
231 } 225 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 video_suspended_ = video_is_suspended; 266 video_suspended_ = video_is_suspended;
273 } 267 }
274 268
275 if (stats_proxy_ && video_suspension_changed) { 269 if (stats_proxy_ && video_suspension_changed) {
276 LOG(LS_INFO) << "Video suspend state changed " << video_is_suspended; 270 LOG(LS_INFO) << "Video suspend state changed " << video_is_suspended;
277 stats_proxy_->OnSuspendChange(video_is_suspended); 271 stats_proxy_->OnSuspendChange(video_is_suspended);
278 } 272 }
279 } 273 }
280 274
281 } // namespace webrtc 275 } // namespace webrtc
OLDNEW
« webrtc/video/video_send_stream.cc ('K') | « webrtc/video/vie_encoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698