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

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

Issue 2517243005: Remove overhead from video bitrate. (Closed)
Patch Set: Add cmath include. Created 4 years 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 | « no previous file | webrtc/video/video_send_stream_tests.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) 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"
11 11
12 #include <algorithm> 12 #include <algorithm>
13 #include <cmath>
13 #include <sstream> 14 #include <sstream>
14 #include <string> 15 #include <string>
15 #include <utility> 16 #include <utility>
16 #include <vector> 17 #include <vector>
17 18
18 #include "webrtc/common_types.h" 19 #include "webrtc/common_types.h"
19 #include "webrtc/base/checks.h" 20 #include "webrtc/base/checks.h"
20 #include "webrtc/base/file.h" 21 #include "webrtc/base/file.h"
21 #include "webrtc/base/logging.h" 22 #include "webrtc/base/logging.h"
22 #include "webrtc/base/trace_event.h" 23 #include "webrtc/base/trace_event.h"
23 #include "webrtc/base/weak_ptr.h" 24 #include "webrtc/base/weak_ptr.h"
24 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 25 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
25 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" 26 #include "webrtc/modules/congestion_controller/include/congestion_controller.h"
26 #include "webrtc/modules/pacing/packet_router.h" 27 #include "webrtc/modules/pacing/packet_router.h"
27 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 28 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
28 #include "webrtc/modules/utility/include/process_thread.h" 29 #include "webrtc/modules/utility/include/process_thread.h"
29 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" 30 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h"
31 #include "webrtc/system_wrappers/include/field_trial.h"
30 #include "webrtc/video/call_stats.h" 32 #include "webrtc/video/call_stats.h"
31 #include "webrtc/video/vie_remb.h" 33 #include "webrtc/video/vie_remb.h"
32 #include "webrtc/video_send_stream.h" 34 #include "webrtc/video_send_stream.h"
33 35
34 namespace webrtc { 36 namespace webrtc {
35 37
36 static const int kMinSendSidePacketHistorySize = 600; 38 static const int kMinSendSidePacketHistorySize = 600;
37 namespace { 39 namespace {
38 40
39 std::vector<RtpRtcp*> CreateRtpRtcpModules( 41 std::vector<RtpRtcp*> CreateRtpRtcpModules(
40 Transport* outgoing_transport, 42 Transport* outgoing_transport,
41 RtcpIntraFrameObserver* intra_frame_callback, 43 RtcpIntraFrameObserver* intra_frame_callback,
42 RtcpBandwidthObserver* bandwidth_callback, 44 RtcpBandwidthObserver* bandwidth_callback,
43 TransportFeedbackObserver* transport_feedback_callback, 45 TransportFeedbackObserver* transport_feedback_callback,
44 RtcpRttStats* rtt_stats, 46 RtcpRttStats* rtt_stats,
45 RtpPacketSender* paced_sender, 47 RtpPacketSender* paced_sender,
46 TransportSequenceNumberAllocator* transport_sequence_number_allocator, 48 TransportSequenceNumberAllocator* transport_sequence_number_allocator,
47 FlexfecSender* flexfec_sender, 49 FlexfecSender* flexfec_sender,
48 SendStatisticsProxy* stats_proxy, 50 SendStatisticsProxy* stats_proxy,
49 SendDelayStats* send_delay_stats, 51 SendDelayStats* send_delay_stats,
50 RtcEventLog* event_log, 52 RtcEventLog* event_log,
51 RateLimiter* retransmission_rate_limiter, 53 RateLimiter* retransmission_rate_limiter,
54 OverheadObserver* overhead_observer,
52 size_t num_modules) { 55 size_t num_modules) {
53 RTC_DCHECK_GT(num_modules, 0); 56 RTC_DCHECK_GT(num_modules, 0);
54 RtpRtcp::Configuration configuration; 57 RtpRtcp::Configuration configuration;
55 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics; 58 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics;
56 configuration.audio = false; 59 configuration.audio = false;
57 configuration.receiver_only = false; 60 configuration.receiver_only = false;
58 configuration.flexfec_sender = flexfec_sender; 61 configuration.flexfec_sender = flexfec_sender;
59 configuration.receive_statistics = null_receive_statistics; 62 configuration.receive_statistics = null_receive_statistics;
60 configuration.outgoing_transport = outgoing_transport; 63 configuration.outgoing_transport = outgoing_transport;
61 configuration.intra_frame_callback = intra_frame_callback; 64 configuration.intra_frame_callback = intra_frame_callback;
62 configuration.bandwidth_callback = bandwidth_callback; 65 configuration.bandwidth_callback = bandwidth_callback;
63 configuration.transport_feedback_callback = transport_feedback_callback; 66 configuration.transport_feedback_callback = transport_feedback_callback;
64 configuration.rtt_stats = rtt_stats; 67 configuration.rtt_stats = rtt_stats;
65 configuration.rtcp_packet_type_counter_observer = stats_proxy; 68 configuration.rtcp_packet_type_counter_observer = stats_proxy;
66 configuration.paced_sender = paced_sender; 69 configuration.paced_sender = paced_sender;
67 configuration.transport_sequence_number_allocator = 70 configuration.transport_sequence_number_allocator =
68 transport_sequence_number_allocator; 71 transport_sequence_number_allocator;
69 configuration.send_bitrate_observer = stats_proxy; 72 configuration.send_bitrate_observer = stats_proxy;
70 configuration.send_frame_count_observer = stats_proxy; 73 configuration.send_frame_count_observer = stats_proxy;
71 configuration.send_side_delay_observer = stats_proxy; 74 configuration.send_side_delay_observer = stats_proxy;
72 configuration.send_packet_observer = send_delay_stats; 75 configuration.send_packet_observer = send_delay_stats;
73 configuration.event_log = event_log; 76 configuration.event_log = event_log;
74 configuration.retransmission_rate_limiter = retransmission_rate_limiter; 77 configuration.retransmission_rate_limiter = retransmission_rate_limiter;
75 78 configuration.overhead_observer = overhead_observer;
76 std::vector<RtpRtcp*> modules; 79 std::vector<RtpRtcp*> modules;
77 for (size_t i = 0; i < num_modules; ++i) { 80 for (size_t i = 0; i < num_modules; ++i) {
78 RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration); 81 RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration);
79 rtp_rtcp->SetSendingStatus(false); 82 rtp_rtcp->SetSendingStatus(false);
80 rtp_rtcp->SetSendingMediaStatus(false); 83 rtp_rtcp->SetSendingMediaStatus(false);
81 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); 84 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound);
82 modules.push_back(rtp_rtcp); 85 modules.push_back(rtp_rtcp);
83 } 86 }
84 return modules; 87 return modules;
85 } 88 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 namespace internal { 280 namespace internal {
278 281
279 // VideoSendStreamImpl implements internal::VideoSendStream. 282 // VideoSendStreamImpl implements internal::VideoSendStream.
280 // It is created and destroyed on |worker_queue|. The intent is to decrease the 283 // It is created and destroyed on |worker_queue|. The intent is to decrease the
281 // need for locking and to ensure methods are called in sequence. 284 // need for locking and to ensure methods are called in sequence.
282 // Public methods except |DeliverRtcp| must be called on |worker_queue|. 285 // Public methods except |DeliverRtcp| must be called on |worker_queue|.
283 // DeliverRtcp is called on the libjingle worker thread or a network thread. 286 // DeliverRtcp is called on the libjingle worker thread or a network thread.
284 // An encoder may deliver frames through the EncodedImageCallback on an 287 // An encoder may deliver frames through the EncodedImageCallback on an
285 // arbitrary thread. 288 // arbitrary thread.
286 class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver, 289 class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver,
290 public webrtc::OverheadObserver,
287 public webrtc::VCMProtectionCallback, 291 public webrtc::VCMProtectionCallback,
288 public ViEEncoder::EncoderSink { 292 public ViEEncoder::EncoderSink {
289 public: 293 public:
290 VideoSendStreamImpl(SendStatisticsProxy* stats_proxy, 294 VideoSendStreamImpl(SendStatisticsProxy* stats_proxy,
291 rtc::TaskQueue* worker_queue, 295 rtc::TaskQueue* worker_queue,
292 CallStats* call_stats, 296 CallStats* call_stats,
293 CongestionController* congestion_controller, 297 CongestionController* congestion_controller,
294 BitrateAllocator* bitrate_allocator, 298 BitrateAllocator* bitrate_allocator,
295 SendDelayStats* send_delay_stats, 299 SendDelayStats* send_delay_stats,
296 VieRemb* remb, 300 VieRemb* remb,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 uint8_t fraction_loss, 334 uint8_t fraction_loss,
331 int64_t rtt) override; 335 int64_t rtt) override;
332 336
333 // Implements webrtc::VCMProtectionCallback. 337 // Implements webrtc::VCMProtectionCallback.
334 int ProtectionRequest(const FecProtectionParams* delta_params, 338 int ProtectionRequest(const FecProtectionParams* delta_params,
335 const FecProtectionParams* key_params, 339 const FecProtectionParams* key_params,
336 uint32_t* sent_video_rate_bps, 340 uint32_t* sent_video_rate_bps,
337 uint32_t* sent_nack_rate_bps, 341 uint32_t* sent_nack_rate_bps,
338 uint32_t* sent_fec_rate_bps) override; 342 uint32_t* sent_fec_rate_bps) override;
339 343
344 // Implements OverheadObserver.
345 void OnOverheadChanged(size_t overhead_bytes_per_packet) override;
346
340 void OnEncoderConfigurationChanged(std::vector<VideoStream> streams, 347 void OnEncoderConfigurationChanged(std::vector<VideoStream> streams,
341 int min_transmit_bitrate_bps) override; 348 int min_transmit_bitrate_bps) override;
342 349
343 // Implements EncodedImageCallback. The implementation routes encoded frames 350 // Implements EncodedImageCallback. The implementation routes encoded frames
344 // to the |payload_router_| and |config.pre_encode_callback| if set. 351 // to the |payload_router_| and |config.pre_encode_callback| if set.
345 // Called on an arbitrary encoder callback thread. 352 // Called on an arbitrary encoder callback thread.
346 EncodedImageCallback::Result OnEncodedImage( 353 EncodedImageCallback::Result OnEncodedImage(
347 const EncodedImage& encoded_image, 354 const EncodedImage& encoded_image,
348 const CodecSpecificInfo* codec_specific_info, 355 const CodecSpecificInfo* codec_specific_info,
349 const RTPFragmentationHeader* fragmentation) override; 356 const RTPFragmentationHeader* fragmentation) override;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 const std::vector<RtpRtcp*> rtp_rtcp_modules_; 398 const std::vector<RtpRtcp*> rtp_rtcp_modules_;
392 PayloadRouter payload_router_; 399 PayloadRouter payload_router_;
393 400
394 // |weak_ptr_| to our self. This is used since we can not call 401 // |weak_ptr_| to our self. This is used since we can not call
395 // |weak_ptr_factory_.GetWeakPtr| from multiple sequences but it is ok to copy 402 // |weak_ptr_factory_.GetWeakPtr| from multiple sequences but it is ok to copy
396 // an existing WeakPtr. 403 // an existing WeakPtr.
397 rtc::WeakPtr<VideoSendStreamImpl> weak_ptr_; 404 rtc::WeakPtr<VideoSendStreamImpl> weak_ptr_;
398 // |weak_ptr_factory_| must be declared last to make sure all WeakPtr's are 405 // |weak_ptr_factory_| must be declared last to make sure all WeakPtr's are
399 // invalidated before any other members are destroyed. 406 // invalidated before any other members are destroyed.
400 rtc::WeakPtrFactory<VideoSendStreamImpl> weak_ptr_factory_; 407 rtc::WeakPtrFactory<VideoSendStreamImpl> weak_ptr_factory_;
408
409 rtc::CriticalSection overhead_bytes_per_packet_crit_;
410 size_t overhead_bytes_per_packet_ GUARDED_BY(overhead_bytes_per_packet_crit_);
411 size_t transport_overhead_bytes_per_packet_;
401 }; 412 };
402 413
403 // TODO(tommi): See if there's a more elegant way to create a task that creates 414 // TODO(tommi): See if there's a more elegant way to create a task that creates
404 // an object on the correct task queue. 415 // an object on the correct task queue.
405 class VideoSendStream::ConstructionTask : public rtc::QueuedTask { 416 class VideoSendStream::ConstructionTask : public rtc::QueuedTask {
406 public: 417 public:
407 ConstructionTask(std::unique_ptr<VideoSendStreamImpl>* send_stream, 418 ConstructionTask(std::unique_ptr<VideoSendStreamImpl>* send_stream,
408 rtc::Event* done_event, 419 rtc::Event* done_event,
409 SendStatisticsProxy* stats_proxy, 420 SendStatisticsProxy* stats_proxy,
410 ViEEncoder* vie_encoder, 421 ViEEncoder* vie_encoder,
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 bandwidth_observer_.get(), 738 bandwidth_observer_.get(),
728 congestion_controller_->GetTransportFeedbackObserver(), 739 congestion_controller_->GetTransportFeedbackObserver(),
729 call_stats_->rtcp_rtt_stats(), 740 call_stats_->rtcp_rtt_stats(),
730 congestion_controller_->pacer(), 741 congestion_controller_->pacer(),
731 congestion_controller_->packet_router(), 742 congestion_controller_->packet_router(),
732 flexfec_sender_.get(), 743 flexfec_sender_.get(),
733 stats_proxy_, 744 stats_proxy_,
734 send_delay_stats, 745 send_delay_stats,
735 event_log, 746 event_log,
736 congestion_controller_->GetRetransmissionRateLimiter(), 747 congestion_controller_->GetRetransmissionRateLimiter(),
748 this,
737 config_->rtp.ssrcs.size())), 749 config_->rtp.ssrcs.size())),
738 payload_router_(rtp_rtcp_modules_, 750 payload_router_(rtp_rtcp_modules_,
739 config_->encoder_settings.payload_type), 751 config_->encoder_settings.payload_type),
740 weak_ptr_factory_(this) { 752 weak_ptr_factory_(this),
753 overhead_bytes_per_packet_(0),
754 transport_overhead_bytes_per_packet_(0) {
741 RTC_DCHECK_RUN_ON(worker_queue_); 755 RTC_DCHECK_RUN_ON(worker_queue_);
742 LOG(LS_INFO) << "VideoSendStreamInternal: " << config_->ToString(); 756 LOG(LS_INFO) << "VideoSendStreamInternal: " << config_->ToString();
743 weak_ptr_ = weak_ptr_factory_.GetWeakPtr(); 757 weak_ptr_ = weak_ptr_factory_.GetWeakPtr();
744 module_process_thread_checker_.DetachFromThread(); 758 module_process_thread_checker_.DetachFromThread();
745 759
746 RTC_DCHECK(!config_->rtp.ssrcs.empty()); 760 RTC_DCHECK(!config_->rtp.ssrcs.empty());
747 RTC_DCHECK(call_stats_); 761 RTC_DCHECK(call_stats_);
748 RTC_DCHECK(congestion_controller_); 762 RTC_DCHECK(congestion_controller_);
749 RTC_DCHECK(remb_); 763 RTC_DCHECK(remb_);
750 764
(...skipping 19 matching lines...) Expand all
770 } 784 }
771 785
772 remb_->AddRembSender(rtp_rtcp_modules_[0]); 786 remb_->AddRembSender(rtp_rtcp_modules_[0]);
773 rtp_rtcp_modules_[0]->SetREMBStatus(true); 787 rtp_rtcp_modules_[0]->SetREMBStatus(true);
774 788
775 ConfigureProtection(); 789 ConfigureProtection();
776 ConfigureSsrcs(); 790 ConfigureSsrcs();
777 791
778 // TODO(pbos): Should we set CNAME on all RTP modules? 792 // TODO(pbos): Should we set CNAME on all RTP modules?
779 rtp_rtcp_modules_.front()->SetCNAME(config_->rtp.c_name.c_str()); 793 rtp_rtcp_modules_.front()->SetCNAME(config_->rtp.c_name.c_str());
780 // 28 to match packet overhead in ModuleRtpRtcpImpl. 794
781 static const size_t kRtpPacketSizeOverhead = 28;
782 RTC_DCHECK_LE(config_->rtp.max_packet_size, 0xFFFFu + kRtpPacketSizeOverhead);
783 const uint16_t mtu = static_cast<uint16_t>(config_->rtp.max_packet_size +
784 kRtpPacketSizeOverhead);
785 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 795 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
786 rtp_rtcp->RegisterRtcpStatisticsCallback(stats_proxy_); 796 rtp_rtcp->RegisterRtcpStatisticsCallback(stats_proxy_);
787 rtp_rtcp->RegisterSendChannelRtpStatisticsCallback(stats_proxy_); 797 rtp_rtcp->RegisterSendChannelRtpStatisticsCallback(stats_proxy_);
788 rtp_rtcp->SetMaxTransferUnit(mtu); 798 rtp_rtcp->SetMaxTransferUnit(
799 static_cast<uint16_t>(config_->rtp.max_packet_size));
789 rtp_rtcp->RegisterVideoSendPayload( 800 rtp_rtcp->RegisterVideoSendPayload(
790 config_->encoder_settings.payload_type, 801 config_->encoder_settings.payload_type,
791 config_->encoder_settings.payload_name.c_str()); 802 config_->encoder_settings.payload_name.c_str());
792 } 803 }
793 804
794 RTC_DCHECK(config_->encoder_settings.encoder); 805 RTC_DCHECK(config_->encoder_settings.encoder);
795 RTC_DCHECK_GE(config_->encoder_settings.payload_type, 0); 806 RTC_DCHECK_GE(config_->encoder_settings.payload_type, 0);
796 RTC_DCHECK_LE(config_->encoder_settings.payload_type, 127); 807 RTC_DCHECK_LE(config_->encoder_settings.payload_type, 127);
797 808
798 vie_encoder_->SetStartBitrate(bitrate_allocator_->GetStartBitrate(this)); 809 vie_encoder_->SetStartBitrate(bitrate_allocator_->GetStartBitrate(this));
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 : RtcpMode::kOff); 1159 : RtcpMode::kOff);
1149 } 1160 }
1150 } 1161 }
1151 1162
1152 uint32_t VideoSendStreamImpl::OnBitrateUpdated(uint32_t bitrate_bps, 1163 uint32_t VideoSendStreamImpl::OnBitrateUpdated(uint32_t bitrate_bps,
1153 uint8_t fraction_loss, 1164 uint8_t fraction_loss,
1154 int64_t rtt) { 1165 int64_t rtt) {
1155 RTC_DCHECK_RUN_ON(worker_queue_); 1166 RTC_DCHECK_RUN_ON(worker_queue_);
1156 RTC_DCHECK(payload_router_.active()) 1167 RTC_DCHECK(payload_router_.active())
1157 << "VideoSendStream::Start has not been called."; 1168 << "VideoSendStream::Start has not been called.";
1169
1170 if (webrtc::field_trial::FindFullName("WebRTC-SendSideBwe-WithOverhead") ==
1171 "Enabled") {
1172 // Substract overhead from bitrate.
1173 rtc::CritScope lock(&overhead_bytes_per_packet_crit_);
1174 int packets_per_second =
1175 std::ceil(bitrate_bps / (8 * (config_->rtp.max_packet_size +
1176 transport_overhead_bytes_per_packet_)));
1177 uint32_t overhead_bps = static_cast<uint32_t>(
1178 8 * overhead_bytes_per_packet_ * packets_per_second);
1179 bitrate_bps = overhead_bps > bitrate_bps ? 0u : bitrate_bps - overhead_bps;
1180 }
1181
1158 // Get the encoder target rate. It is the estimated network rate - 1182 // Get the encoder target rate. It is the estimated network rate -
1159 // protection overhead. 1183 // protection overhead.
1160 encoder_target_rate_bps_ = protection_bitrate_calculator_.SetTargetRates( 1184 encoder_target_rate_bps_ = protection_bitrate_calculator_.SetTargetRates(
1161 bitrate_bps, stats_proxy_->GetSendFrameRate(), fraction_loss, rtt); 1185 bitrate_bps, stats_proxy_->GetSendFrameRate(), fraction_loss, rtt);
1162 uint32_t protection_bitrate = bitrate_bps - encoder_target_rate_bps_; 1186 uint32_t protection_bitrate = bitrate_bps - encoder_target_rate_bps_;
1163 1187
1164 encoder_target_rate_bps_ = 1188 encoder_target_rate_bps_ =
1165 std::min(encoder_max_bitrate_bps_, encoder_target_rate_bps_); 1189 std::min(encoder_max_bitrate_bps_, encoder_target_rate_bps_);
1166 vie_encoder_->OnBitrateUpdated(encoder_target_rate_bps_, fraction_loss, rtt); 1190 vie_encoder_->OnBitrateUpdated(encoder_target_rate_bps_, fraction_loss, rtt);
1167 stats_proxy_->OnSetEncoderTargetRate(encoder_target_rate_bps_); 1191 stats_proxy_->OnSetEncoderTargetRate(encoder_target_rate_bps_);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 rtp_rtcp->SetFecParameters(*delta_params, *key_params); 1231 rtp_rtcp->SetFecParameters(*delta_params, *key_params);
1208 rtp_rtcp->BitrateSent(&not_used, &module_video_rate, &module_fec_rate, 1232 rtp_rtcp->BitrateSent(&not_used, &module_video_rate, &module_fec_rate,
1209 &module_nack_rate); 1233 &module_nack_rate);
1210 *sent_video_rate_bps += module_video_rate; 1234 *sent_video_rate_bps += module_video_rate;
1211 *sent_nack_rate_bps += module_nack_rate; 1235 *sent_nack_rate_bps += module_nack_rate;
1212 *sent_fec_rate_bps += module_fec_rate; 1236 *sent_fec_rate_bps += module_fec_rate;
1213 } 1237 }
1214 return 0; 1238 return 0;
1215 } 1239 }
1216 1240
1241 void VideoSendStreamImpl::OnOverheadChanged(size_t overhead_bytes_per_packet) {
1242 rtc::CritScope lock(&overhead_bytes_per_packet_crit_);
1243 overhead_bytes_per_packet_ = overhead_bytes_per_packet;
1244 }
1245
1217 void VideoSendStreamImpl::SetTransportOverhead( 1246 void VideoSendStreamImpl::SetTransportOverhead(
1218 int transport_overhead_per_packet) { 1247 int transport_overhead_bytes_per_packet) {
1219 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) 1248 transport_overhead_bytes_per_packet_ = transport_overhead_bytes_per_packet;
1220 rtp_rtcp->SetTransportOverhead(transport_overhead_per_packet); 1249 RTC_DCHECK_LE(config_->rtp.max_packet_size,
1250 0xFFFFu + transport_overhead_bytes_per_packet);
1251 const uint16_t mtu = static_cast<uint16_t>(
1252 config_->rtp.max_packet_size + transport_overhead_bytes_per_packet);
1253 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
1254 rtp_rtcp->SetTransportOverhead(transport_overhead_bytes_per_packet);
1255 rtp_rtcp->SetMaxTransferUnit(mtu);
1256 }
1221 } 1257 }
1222 1258
1223 } // namespace internal 1259 } // namespace internal
1224 } // namespace webrtc 1260 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/video/video_send_stream_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698