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

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

Issue 1984243003: Set ViEEncoder sink_ on construction. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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/vie_encoder.h ('k') | no next file » | 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
(...skipping 15 matching lines...) Expand all
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 static const float kStopPaddingThresholdMs = 2000; 31 static const float kStopPaddingThresholdMs = 2000;
32 32
33 ViEEncoder::ViEEncoder(uint32_t number_of_cores, 33 ViEEncoder::ViEEncoder(uint32_t number_of_cores,
34 ProcessThread* module_process_thread, 34 ProcessThread* module_process_thread,
35 SendStatisticsProxy* stats_proxy, 35 SendStatisticsProxy* stats_proxy,
36 OveruseFrameDetector* overuse_detector) 36 OveruseFrameDetector* overuse_detector,
37 EncodedImageCallback* sink)
37 : number_of_cores_(number_of_cores), 38 : number_of_cores_(number_of_cores),
39 sink_(sink),
38 vp_(VideoProcessing::Create()), 40 vp_(VideoProcessing::Create()),
39 video_sender_(Clock::GetRealTimeClock(), this, this, this), 41 video_sender_(Clock::GetRealTimeClock(), this, this, this),
40 stats_proxy_(stats_proxy), 42 stats_proxy_(stats_proxy),
41 overuse_detector_(overuse_detector), 43 overuse_detector_(overuse_detector),
42 time_of_last_frame_activity_ms_(0), 44 time_of_last_frame_activity_ms_(0),
43 encoder_config_(), 45 encoder_config_(),
44 min_transmit_bitrate_bps_(0), 46 min_transmit_bitrate_bps_(0),
45 last_observed_bitrate_bps_(0), 47 last_observed_bitrate_bps_(0),
46 encoder_paused_(true), 48 encoder_paused_(true),
47 encoder_paused_and_dropped_frame_(false), 49 encoder_paused_and_dropped_frame_(false),
(...skipping 29 matching lines...) Expand all
77 uint8_t pl_type, 79 uint8_t pl_type,
78 bool internal_source) { 80 bool internal_source) {
79 video_sender_.RegisterExternalEncoder(encoder, pl_type, internal_source); 81 video_sender_.RegisterExternalEncoder(encoder, pl_type, internal_source);
80 return 0; 82 return 0;
81 } 83 }
82 84
83 int32_t ViEEncoder::DeRegisterExternalEncoder(uint8_t pl_type) { 85 int32_t ViEEncoder::DeRegisterExternalEncoder(uint8_t pl_type) {
84 video_sender_.RegisterExternalEncoder(nullptr, pl_type, false); 86 video_sender_.RegisterExternalEncoder(nullptr, pl_type, false);
85 return 0; 87 return 0;
86 } 88 }
89
87 void ViEEncoder::SetEncoder(const webrtc::VideoCodec& video_codec, 90 void ViEEncoder::SetEncoder(const webrtc::VideoCodec& video_codec,
88 int min_transmit_bitrate_bps, 91 int min_transmit_bitrate_bps,
89 size_t max_data_payload_length, 92 size_t max_data_payload_length) {
90 EncodedImageCallback* sink) {
91 // Setting target width and height for VPM. 93 // Setting target width and height for VPM.
92 RTC_CHECK_EQ(VPM_OK, 94 RTC_CHECK_EQ(VPM_OK,
93 vp_->SetTargetResolution(video_codec.width, video_codec.height, 95 vp_->SetTargetResolution(video_codec.width, video_codec.height,
94 video_codec.maxFramerate)); 96 video_codec.maxFramerate));
95 97
96 // Cache codec before calling AddBitrateObserver (which calls OnBitrateUpdated 98 // Cache codec before calling AddBitrateObserver (which calls OnBitrateUpdated
97 // that makes use of the number of simulcast streams configured). 99 // that makes use of the number of simulcast streams configured).
98 { 100 {
99 rtc::CritScope lock(&data_cs_); 101 rtc::CritScope lock(&data_cs_);
100 encoder_config_ = video_codec; 102 encoder_config_ = video_codec;
101 min_transmit_bitrate_bps_ = min_transmit_bitrate_bps; 103 min_transmit_bitrate_bps_ = min_transmit_bitrate_bps;
102 } 104 }
103 {
104 rtc::CritScope lock(&sink_cs_);
105 sink_ = sink;
106 }
107 105
108 bool success = video_sender_.RegisterSendCodec( 106 bool success = video_sender_.RegisterSendCodec(
109 &video_codec, number_of_cores_, 107 &video_codec, number_of_cores_,
110 static_cast<uint32_t>(max_data_payload_length)) == VCM_OK; 108 static_cast<uint32_t>(max_data_payload_length)) == VCM_OK;
111 if (!success) { 109 if (!success) {
112 LOG(LS_ERROR) << "Failed to configure encoder."; 110 LOG(LS_ERROR) << "Failed to configure encoder.";
113 RTC_DCHECK(success); 111 RTC_DCHECK(success);
114 } 112 }
115 113
116 if (stats_proxy_) { 114 if (stats_proxy_) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 const CodecSpecificInfo* codec_specific_info, 285 const CodecSpecificInfo* codec_specific_info,
288 const RTPFragmentationHeader* fragmentation) { 286 const RTPFragmentationHeader* fragmentation) {
289 { 287 {
290 rtc::CritScope lock(&data_cs_); 288 rtc::CritScope lock(&data_cs_);
291 time_of_last_frame_activity_ms_ = rtc::TimeMillis(); 289 time_of_last_frame_activity_ms_ = rtc::TimeMillis();
292 } 290 }
293 if (stats_proxy_) { 291 if (stats_proxy_) {
294 stats_proxy_->OnSendEncodedImage(encoded_image, codec_specific_info); 292 stats_proxy_->OnSendEncodedImage(encoded_image, codec_specific_info);
295 } 293 }
296 294
297 int success = 0; 295 int success =
298 { 296 sink_->Encoded(encoded_image, codec_specific_info, fragmentation);
299 rtc::CritScope lock(&sink_cs_);
300 success = sink_->Encoded(encoded_image, codec_specific_info, fragmentation);
301 }
302 297
303 overuse_detector_->FrameSent(encoded_image._timeStamp); 298 overuse_detector_->FrameSent(encoded_image._timeStamp);
304 return success; 299 return success;
305 } 300 }
306 301
307 void ViEEncoder::SendStatistics(uint32_t bit_rate, 302 void ViEEncoder::SendStatistics(uint32_t bit_rate,
308 uint32_t frame_rate, 303 uint32_t frame_rate,
309 const std::string& encoder_name) { 304 const std::string& encoder_name) {
310 if (stats_proxy_) 305 if (stats_proxy_)
311 stats_proxy_->OnEncoderStatsUpdate(frame_rate, bit_rate, encoder_name); 306 stats_proxy_->OnEncoderStatsUpdate(frame_rate, bit_rate, encoder_name);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if (!video_suspension_changed) 344 if (!video_suspension_changed)
350 return; 345 return;
351 // Video suspend-state changed, inform codec observer. 346 // Video suspend-state changed, inform codec observer.
352 LOG(LS_INFO) << "Video suspend state changed " << video_is_suspended; 347 LOG(LS_INFO) << "Video suspend state changed " << video_is_suspended;
353 348
354 if (stats_proxy_) 349 if (stats_proxy_)
355 stats_proxy_->OnSuspendChange(video_is_suspended); 350 stats_proxy_->OnSuspendChange(video_is_suspended);
356 } 351 }
357 352
358 } // namespace webrtc 353 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/vie_encoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698