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

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

Issue 2657863002: Move more calls to webrtc::field_trial::FindFullName into ctor (Closed)
Patch Set: Rebased Created 3 years, 10 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/modules/congestion_controller/transport_feedback_adapter.cc ('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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 #include "webrtc/video/video_send_stream.h" 10 #include "webrtc/video/video_send_stream.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } else if (pad_to_min_bitrate) { 282 } else if (pad_to_min_bitrate) {
283 pad_up_to_bitrate_bps = streams[0].min_bitrate_bps; 283 pad_up_to_bitrate_bps = streams[0].min_bitrate_bps;
284 } 284 }
285 285
286 pad_up_to_bitrate_bps = 286 pad_up_to_bitrate_bps =
287 std::max(pad_up_to_bitrate_bps, min_transmit_bitrate_bps); 287 std::max(pad_up_to_bitrate_bps, min_transmit_bitrate_bps);
288 288
289 return pad_up_to_bitrate_bps; 289 return pad_up_to_bitrate_bps;
290 } 290 }
291 291
292 uint32_t CalculateOverheadRateBps(int packets_per_second,
293 size_t overhead_bytes_per_packet,
294 uint32_t max_overhead_bps) {
295 if (webrtc::field_trial::FindFullName("WebRTC-SendSideBwe-WithOverhead") !=
296 "Enabled")
297 return 0;
298 uint32_t overhead_bps =
299 static_cast<uint32_t>(8 * overhead_bytes_per_packet * packets_per_second);
300 return std::min(overhead_bps, max_overhead_bps);
301 }
302
303 int CalculatePacketRate(uint32_t bitrate_bps, size_t packet_size_bytes) { 292 int CalculatePacketRate(uint32_t bitrate_bps, size_t packet_size_bytes) {
304 size_t packet_size_bits = 8 * packet_size_bytes; 293 size_t packet_size_bits = 8 * packet_size_bytes;
305 // Ceil for int value of bitrate_bps / packet_size_bits. 294 // Ceil for int value of bitrate_bps / packet_size_bits.
306 return static_cast<int>((bitrate_bps + packet_size_bits - 1) / 295 return static_cast<int>((bitrate_bps + packet_size_bits - 1) /
307 packet_size_bits); 296 packet_size_bits);
308 } 297 }
309 298
310 } // namespace 299 } // namespace
311 300
312 namespace internal { 301 namespace internal {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 const RTPFragmentationHeader* fragmentation) override; 380 const RTPFragmentationHeader* fragmentation) override;
392 381
393 // Implements VideoBitrateAllocationObserver. 382 // Implements VideoBitrateAllocationObserver.
394 void OnBitrateAllocationUpdated(const BitrateAllocation& allocation) override; 383 void OnBitrateAllocationUpdated(const BitrateAllocation& allocation) override;
395 384
396 void ConfigureProtection(); 385 void ConfigureProtection();
397 void ConfigureSsrcs(); 386 void ConfigureSsrcs();
398 void SignalEncoderTimedOut(); 387 void SignalEncoderTimedOut();
399 void SignalEncoderActive(); 388 void SignalEncoderActive();
400 389
390 uint32_t CalculateOverheadRateBps(int packets_per_second,
391 size_t overhead_bytes_per_packet,
minyue-webrtc 2017/01/31 11:48:06 Feels better if we keep it outside but add send_si
392 uint32_t max_overhead_bps);
393
394 const bool send_side_bwe_with_overhead_;
395
401 SendStatisticsProxy* const stats_proxy_; 396 SendStatisticsProxy* const stats_proxy_;
402 const VideoSendStream::Config* const config_; 397 const VideoSendStream::Config* const config_;
403 std::map<uint32_t, RtpState> suspended_ssrcs_; 398 std::map<uint32_t, RtpState> suspended_ssrcs_;
404 399
405 ProcessThread* module_process_thread_; 400 ProcessThread* module_process_thread_;
406 rtc::ThreadChecker module_process_thread_checker_; 401 rtc::ThreadChecker module_process_thread_checker_;
407 rtc::TaskQueue* const worker_queue_; 402 rtc::TaskQueue* const worker_queue_;
408 403
409 rtc::CriticalSection encoder_activity_crit_sect_; 404 rtc::CriticalSection encoder_activity_crit_sect_;
410 CheckEncoderActivityTask* check_encoder_activity_task_ 405 CheckEncoderActivityTask* check_encoder_activity_task_
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 CongestionController* congestion_controller, 746 CongestionController* congestion_controller,
752 PacketRouter* packet_router, 747 PacketRouter* packet_router,
753 BitrateAllocator* bitrate_allocator, 748 BitrateAllocator* bitrate_allocator,
754 SendDelayStats* send_delay_stats, 749 SendDelayStats* send_delay_stats,
755 VieRemb* remb, 750 VieRemb* remb,
756 ViEEncoder* vie_encoder, 751 ViEEncoder* vie_encoder,
757 RtcEventLog* event_log, 752 RtcEventLog* event_log,
758 const VideoSendStream::Config* config, 753 const VideoSendStream::Config* config,
759 int initial_encoder_max_bitrate, 754 int initial_encoder_max_bitrate,
760 std::map<uint32_t, RtpState> suspended_ssrcs) 755 std::map<uint32_t, RtpState> suspended_ssrcs)
761 : stats_proxy_(stats_proxy), 756 : send_side_bwe_with_overhead_(webrtc::field_trial::FindFullName(
757 "WebRTC-SendSideBwe-WithOverhead") == "Enabled"),
758 stats_proxy_(stats_proxy),
762 config_(config), 759 config_(config),
763 suspended_ssrcs_(std::move(suspended_ssrcs)), 760 suspended_ssrcs_(std::move(suspended_ssrcs)),
764 module_process_thread_(nullptr), 761 module_process_thread_(nullptr),
765 worker_queue_(worker_queue), 762 worker_queue_(worker_queue),
766 check_encoder_activity_task_(nullptr), 763 check_encoder_activity_task_(nullptr),
767 call_stats_(call_stats), 764 call_stats_(call_stats),
768 congestion_controller_(congestion_controller), 765 congestion_controller_(congestion_controller),
769 packet_router_(packet_router), 766 packet_router_(packet_router),
770 bitrate_allocator_(bitrate_allocator), 767 bitrate_allocator_(bitrate_allocator),
771 remb_(remb), 768 remb_(remb),
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 } 968 }
972 969
973 void VideoSendStreamImpl::SignalEncoderActive() { 970 void VideoSendStreamImpl::SignalEncoderActive() {
974 RTC_DCHECK_RUN_ON(worker_queue_); 971 RTC_DCHECK_RUN_ON(worker_queue_);
975 LOG(LS_INFO) << "SignalEncoderActive, Encoder is active."; 972 LOG(LS_INFO) << "SignalEncoderActive, Encoder is active.";
976 bitrate_allocator_->AddObserver( 973 bitrate_allocator_->AddObserver(
977 this, encoder_min_bitrate_bps_, encoder_max_bitrate_bps_, 974 this, encoder_min_bitrate_bps_, encoder_max_bitrate_bps_,
978 max_padding_bitrate_, !config_->suspend_below_min_bitrate); 975 max_padding_bitrate_, !config_->suspend_below_min_bitrate);
979 } 976 }
980 977
978 uint32_t VideoSendStreamImpl::CalculateOverheadRateBps(
979 int packets_per_second,
980 size_t overhead_bytes_per_packet,
981 uint32_t max_overhead_bps) {
982 if (!send_side_bwe_with_overhead_)
983 return 0;
984 uint32_t overhead_bps =
985 static_cast<uint32_t>(8 * overhead_bytes_per_packet * packets_per_second);
986 return std::min(overhead_bps, max_overhead_bps);
987 }
988
981 void VideoSendStreamImpl::OnEncoderConfigurationChanged( 989 void VideoSendStreamImpl::OnEncoderConfigurationChanged(
982 std::vector<VideoStream> streams, 990 std::vector<VideoStream> streams,
983 int min_transmit_bitrate_bps) { 991 int min_transmit_bitrate_bps) {
984 if (!worker_queue_->IsCurrent()) { 992 if (!worker_queue_->IsCurrent()) {
985 worker_queue_->PostTask( 993 worker_queue_->PostTask(
986 std::unique_ptr<rtc::QueuedTask>(new EncoderReconfiguredTask( 994 std::unique_ptr<rtc::QueuedTask>(new EncoderReconfiguredTask(
987 weak_ptr_, std::move(streams), min_transmit_bitrate_bps))); 995 weak_ptr_, std::move(streams), min_transmit_bitrate_bps)));
988 return; 996 return;
989 } 997 }
990 RTC_DCHECK_GE(config_->rtp.ssrcs.size(), streams.size()); 998 RTC_DCHECK_GE(config_->rtp.ssrcs.size(), streams.size());
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 std::min(config_->rtp.max_packet_size, 1336 std::min(config_->rtp.max_packet_size,
1329 kPathMTU - transport_overhead_bytes_per_packet_); 1337 kPathMTU - transport_overhead_bytes_per_packet_);
1330 1338
1331 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 1339 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
1332 rtp_rtcp->SetMaxRtpPacketSize(rtp_packet_size); 1340 rtp_rtcp->SetMaxRtpPacketSize(rtp_packet_size);
1333 } 1341 }
1334 } 1342 }
1335 1343
1336 } // namespace internal 1344 } // namespace internal
1337 } // namespace webrtc 1345 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/congestion_controller/transport_feedback_adapter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698