| OLD | NEW |
| 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 <cmath> |
| 14 #include <sstream> | 14 #include <sstream> |
| 15 #include <string> | 15 #include <string> |
| 16 #include <utility> | 16 #include <utility> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "webrtc/common_types.h" | 19 #include "webrtc/common_types.h" |
| 20 #include "webrtc/common_video/include/video_bitrate_allocator.h" |
| 20 #include "webrtc/base/checks.h" | 21 #include "webrtc/base/checks.h" |
| 21 #include "webrtc/base/file.h" | 22 #include "webrtc/base/file.h" |
| 22 #include "webrtc/base/logging.h" | 23 #include "webrtc/base/logging.h" |
| 23 #include "webrtc/base/trace_event.h" | 24 #include "webrtc/base/trace_event.h" |
| 24 #include "webrtc/base/weak_ptr.h" | 25 #include "webrtc/base/weak_ptr.h" |
| 25 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 26 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
| 26 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 27 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
| 27 #include "webrtc/modules/pacing/packet_router.h" | 28 #include "webrtc/modules/pacing/packet_router.h" |
| 28 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 29 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
| 29 #include "webrtc/modules/utility/include/process_thread.h" | 30 #include "webrtc/modules/utility/include/process_thread.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // VideoSendStreamImpl implements internal::VideoSendStream. | 283 // VideoSendStreamImpl implements internal::VideoSendStream. |
| 283 // It is created and destroyed on |worker_queue|. The intent is to decrease the | 284 // It is created and destroyed on |worker_queue|. The intent is to decrease the |
| 284 // need for locking and to ensure methods are called in sequence. | 285 // need for locking and to ensure methods are called in sequence. |
| 285 // Public methods except |DeliverRtcp| must be called on |worker_queue|. | 286 // Public methods except |DeliverRtcp| must be called on |worker_queue|. |
| 286 // DeliverRtcp is called on the libjingle worker thread or a network thread. | 287 // DeliverRtcp is called on the libjingle worker thread or a network thread. |
| 287 // An encoder may deliver frames through the EncodedImageCallback on an | 288 // An encoder may deliver frames through the EncodedImageCallback on an |
| 288 // arbitrary thread. | 289 // arbitrary thread. |
| 289 class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver, | 290 class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver, |
| 290 public webrtc::OverheadObserver, | 291 public webrtc::OverheadObserver, |
| 291 public webrtc::VCMProtectionCallback, | 292 public webrtc::VCMProtectionCallback, |
| 292 public ViEEncoder::EncoderSink { | 293 public ViEEncoder::EncoderSink, |
| 294 public VideoBitrateAllocationObserver { |
| 293 public: | 295 public: |
| 294 VideoSendStreamImpl(SendStatisticsProxy* stats_proxy, | 296 VideoSendStreamImpl(SendStatisticsProxy* stats_proxy, |
| 295 rtc::TaskQueue* worker_queue, | 297 rtc::TaskQueue* worker_queue, |
| 296 CallStats* call_stats, | 298 CallStats* call_stats, |
| 297 CongestionController* congestion_controller, | 299 CongestionController* congestion_controller, |
| 298 PacketRouter* packet_router, | 300 PacketRouter* packet_router, |
| 299 BitrateAllocator* bitrate_allocator, | 301 BitrateAllocator* bitrate_allocator, |
| 300 SendDelayStats* send_delay_stats, | 302 SendDelayStats* send_delay_stats, |
| 301 VieRemb* remb, | 303 VieRemb* remb, |
| 302 ViEEncoder* vie_encoder, | 304 ViEEncoder* vie_encoder, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 int min_transmit_bitrate_bps) override; | 352 int min_transmit_bitrate_bps) override; |
| 351 | 353 |
| 352 // Implements EncodedImageCallback. The implementation routes encoded frames | 354 // Implements EncodedImageCallback. The implementation routes encoded frames |
| 353 // to the |payload_router_| and |config.pre_encode_callback| if set. | 355 // to the |payload_router_| and |config.pre_encode_callback| if set. |
| 354 // Called on an arbitrary encoder callback thread. | 356 // Called on an arbitrary encoder callback thread. |
| 355 EncodedImageCallback::Result OnEncodedImage( | 357 EncodedImageCallback::Result OnEncodedImage( |
| 356 const EncodedImage& encoded_image, | 358 const EncodedImage& encoded_image, |
| 357 const CodecSpecificInfo* codec_specific_info, | 359 const CodecSpecificInfo* codec_specific_info, |
| 358 const RTPFragmentationHeader* fragmentation) override; | 360 const RTPFragmentationHeader* fragmentation) override; |
| 359 | 361 |
| 362 // Implements VideoBitrateAllocationObserver. |
| 363 void OnBitrateAllocationUpdated(const BitrateAllocation& allocation) override; |
| 364 |
| 360 void ConfigureProtection(); | 365 void ConfigureProtection(); |
| 361 void ConfigureSsrcs(); | 366 void ConfigureSsrcs(); |
| 362 void SignalEncoderTimedOut(); | 367 void SignalEncoderTimedOut(); |
| 363 void SignalEncoderActive(); | 368 void SignalEncoderActive(); |
| 364 | 369 |
| 365 SendStatisticsProxy* const stats_proxy_; | 370 SendStatisticsProxy* const stats_proxy_; |
| 366 const VideoSendStream::Config* const config_; | 371 const VideoSendStream::Config* const config_; |
| 367 std::map<uint32_t, RtpState> suspended_ssrcs_; | 372 std::map<uint32_t, RtpState> suspended_ssrcs_; |
| 368 | 373 |
| 369 ProcessThread* module_process_thread_; | 374 ProcessThread* module_process_thread_; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 const std::map<uint32_t, RtpState>& suspended_ssrcs) | 596 const std::map<uint32_t, RtpState>& suspended_ssrcs) |
| 592 : worker_queue_(worker_queue), | 597 : worker_queue_(worker_queue), |
| 593 thread_sync_event_(false /* manual_reset */, false), | 598 thread_sync_event_(false /* manual_reset */, false), |
| 594 stats_proxy_(Clock::GetRealTimeClock(), | 599 stats_proxy_(Clock::GetRealTimeClock(), |
| 595 config, | 600 config, |
| 596 encoder_config.content_type), | 601 encoder_config.content_type), |
| 597 config_(std::move(config)) { | 602 config_(std::move(config)) { |
| 598 vie_encoder_.reset(new ViEEncoder( | 603 vie_encoder_.reset(new ViEEncoder( |
| 599 num_cpu_cores, &stats_proxy_, config_.encoder_settings, | 604 num_cpu_cores, &stats_proxy_, config_.encoder_settings, |
| 600 config_.pre_encode_callback, config_.post_encode_callback)); | 605 config_.pre_encode_callback, config_.post_encode_callback)); |
| 601 | |
| 602 worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask( | 606 worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask( |
| 603 &send_stream_, &thread_sync_event_, &stats_proxy_, vie_encoder_.get(), | 607 &send_stream_, &thread_sync_event_, &stats_proxy_, vie_encoder_.get(), |
| 604 module_process_thread, call_stats, congestion_controller, packet_router, | 608 module_process_thread, call_stats, congestion_controller, packet_router, |
| 605 bitrate_allocator, send_delay_stats, remb, event_log, &config_, | 609 bitrate_allocator, send_delay_stats, remb, event_log, &config_, |
| 606 encoder_config.max_bitrate_bps, suspended_ssrcs))); | 610 encoder_config.max_bitrate_bps, suspended_ssrcs))); |
| 607 | 611 |
| 608 // Wait for ConstructionTask to complete so that |send_stream_| can be used. | 612 // Wait for ConstructionTask to complete so that |send_stream_| can be used. |
| 609 // |module_process_thread| must be registered and deregistered on the thread | 613 // |module_process_thread| must be registered and deregistered on the thread |
| 610 // it was created on. | 614 // it was created on. |
| 611 thread_sync_event_.Wait(rtc::Event::kForever); | 615 thread_sync_event_.Wait(rtc::Event::kForever); |
| 612 send_stream_->RegisterProcessThread(module_process_thread); | 616 send_stream_->RegisterProcessThread(module_process_thread); |
| 613 | 617 vie_encoder_->SetBitrateObserver(send_stream_.get()); |
| 614 vie_encoder_->RegisterProcessThread(module_process_thread); | 618 vie_encoder_->RegisterProcessThread(module_process_thread); |
| 615 | 619 |
| 616 ReconfigureVideoEncoder(std::move(encoder_config)); | 620 ReconfigureVideoEncoder(std::move(encoder_config)); |
| 617 } | 621 } |
| 618 | 622 |
| 619 VideoSendStream::~VideoSendStream() { | 623 VideoSendStream::~VideoSendStream() { |
| 620 RTC_DCHECK_RUN_ON(&thread_checker_); | 624 RTC_DCHECK_RUN_ON(&thread_checker_); |
| 621 RTC_DCHECK(!send_stream_); | 625 RTC_DCHECK(!send_stream_); |
| 622 } | 626 } |
| 623 | 627 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 } | 846 } |
| 843 | 847 |
| 844 void VideoSendStreamImpl::DeRegisterProcessThread() { | 848 void VideoSendStreamImpl::DeRegisterProcessThread() { |
| 845 RTC_DCHECK_RUN_ON(&module_process_thread_checker_); | 849 RTC_DCHECK_RUN_ON(&module_process_thread_checker_); |
| 846 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 850 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
| 847 module_process_thread_->DeRegisterModule(rtp_rtcp); | 851 module_process_thread_->DeRegisterModule(rtp_rtcp); |
| 848 } | 852 } |
| 849 | 853 |
| 850 VideoSendStreamImpl::~VideoSendStreamImpl() { | 854 VideoSendStreamImpl::~VideoSendStreamImpl() { |
| 851 RTC_DCHECK_RUN_ON(worker_queue_); | 855 RTC_DCHECK_RUN_ON(worker_queue_); |
| 852 RTC_DCHECK(!payload_router_.active()) | 856 RTC_DCHECK(!payload_router_.IsActive()) |
| 853 << "VideoSendStreamImpl::Stop not called"; | 857 << "VideoSendStreamImpl::Stop not called"; |
| 854 LOG(LS_INFO) << "~VideoSendStreamInternal: " << config_->ToString(); | 858 LOG(LS_INFO) << "~VideoSendStreamInternal: " << config_->ToString(); |
| 855 | 859 |
| 856 rtp_rtcp_modules_[0]->SetREMBStatus(false); | 860 rtp_rtcp_modules_[0]->SetREMBStatus(false); |
| 857 remb_->RemoveRembSender(rtp_rtcp_modules_[0]); | 861 remb_->RemoveRembSender(rtp_rtcp_modules_[0]); |
| 858 | 862 |
| 859 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 863 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 860 packet_router_->RemoveRtpModule(rtp_rtcp); | 864 packet_router_->RemoveRtpModule(rtp_rtcp); |
| 861 delete rtp_rtcp; | 865 delete rtp_rtcp; |
| 862 } | 866 } |
| 863 } | 867 } |
| 864 | 868 |
| 865 bool VideoSendStreamImpl::DeliverRtcp(const uint8_t* packet, size_t length) { | 869 bool VideoSendStreamImpl::DeliverRtcp(const uint8_t* packet, size_t length) { |
| 866 // Runs on a network thread. | 870 // Runs on a network thread. |
| 867 RTC_DCHECK(!worker_queue_->IsCurrent()); | 871 RTC_DCHECK(!worker_queue_->IsCurrent()); |
| 868 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 872 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
| 869 rtp_rtcp->IncomingRtcpPacket(packet, length); | 873 rtp_rtcp->IncomingRtcpPacket(packet, length); |
| 870 return true; | 874 return true; |
| 871 } | 875 } |
| 872 | 876 |
| 873 void VideoSendStreamImpl::Start() { | 877 void VideoSendStreamImpl::Start() { |
| 874 RTC_DCHECK_RUN_ON(worker_queue_); | 878 RTC_DCHECK_RUN_ON(worker_queue_); |
| 875 LOG(LS_INFO) << "VideoSendStream::Start"; | 879 LOG(LS_INFO) << "VideoSendStream::Start"; |
| 876 if (payload_router_.active()) | 880 if (payload_router_.IsActive()) |
| 877 return; | 881 return; |
| 878 TRACE_EVENT_INSTANT0("webrtc", "VideoSendStream::Start"); | 882 TRACE_EVENT_INSTANT0("webrtc", "VideoSendStream::Start"); |
| 879 payload_router_.set_active(true); | 883 payload_router_.SetActive(true); |
| 880 | 884 |
| 881 bitrate_allocator_->AddObserver( | 885 bitrate_allocator_->AddObserver( |
| 882 this, encoder_min_bitrate_bps_, encoder_max_bitrate_bps_, | 886 this, encoder_min_bitrate_bps_, encoder_max_bitrate_bps_, |
| 883 max_padding_bitrate_, !config_->suspend_below_min_bitrate); | 887 max_padding_bitrate_, !config_->suspend_below_min_bitrate); |
| 884 | 888 |
| 885 // Start monitoring encoder activity. | 889 // Start monitoring encoder activity. |
| 886 { | 890 { |
| 887 rtc::CritScope lock(&encoder_activity_crit_sect_); | 891 rtc::CritScope lock(&encoder_activity_crit_sect_); |
| 888 RTC_DCHECK(!check_encoder_activity_task_); | 892 RTC_DCHECK(!check_encoder_activity_task_); |
| 889 check_encoder_activity_task_ = new CheckEncoderActivityTask(weak_ptr_); | 893 check_encoder_activity_task_ = new CheckEncoderActivityTask(weak_ptr_); |
| 890 worker_queue_->PostDelayedTask( | 894 worker_queue_->PostDelayedTask( |
| 891 std::unique_ptr<rtc::QueuedTask>(check_encoder_activity_task_), | 895 std::unique_ptr<rtc::QueuedTask>(check_encoder_activity_task_), |
| 892 CheckEncoderActivityTask::kEncoderTimeOutMs); | 896 CheckEncoderActivityTask::kEncoderTimeOutMs); |
| 893 } | 897 } |
| 894 | 898 |
| 895 vie_encoder_->SendKeyFrame(); | 899 vie_encoder_->SendKeyFrame(); |
| 896 } | 900 } |
| 897 | 901 |
| 898 void VideoSendStreamImpl::Stop() { | 902 void VideoSendStreamImpl::Stop() { |
| 899 RTC_DCHECK_RUN_ON(worker_queue_); | 903 RTC_DCHECK_RUN_ON(worker_queue_); |
| 900 LOG(LS_INFO) << "VideoSendStream::Stop"; | 904 LOG(LS_INFO) << "VideoSendStream::Stop"; |
| 901 if (!payload_router_.active()) | 905 if (!payload_router_.IsActive()) |
| 902 return; | 906 return; |
| 903 TRACE_EVENT_INSTANT0("webrtc", "VideoSendStream::Stop"); | 907 TRACE_EVENT_INSTANT0("webrtc", "VideoSendStream::Stop"); |
| 904 payload_router_.set_active(false); | 908 payload_router_.SetActive(false); |
| 905 bitrate_allocator_->RemoveObserver(this); | 909 bitrate_allocator_->RemoveObserver(this); |
| 906 { | 910 { |
| 907 rtc::CritScope lock(&encoder_activity_crit_sect_); | 911 rtc::CritScope lock(&encoder_activity_crit_sect_); |
| 908 check_encoder_activity_task_->Stop(); | 912 check_encoder_activity_task_->Stop(); |
| 909 check_encoder_activity_task_ = nullptr; | 913 check_encoder_activity_task_ = nullptr; |
| 910 } | 914 } |
| 911 vie_encoder_->OnBitrateUpdated(0, 0, 0); | 915 vie_encoder_->OnBitrateUpdated(0, 0, 0); |
| 912 stats_proxy_->OnSetEncoderTargetRate(0); | 916 stats_proxy_->OnSetEncoderTargetRate(0); |
| 913 } | 917 } |
| 914 | 918 |
| 915 void VideoSendStreamImpl::SignalEncoderTimedOut() { | 919 void VideoSendStreamImpl::SignalEncoderTimedOut() { |
| 916 RTC_DCHECK_RUN_ON(worker_queue_); | 920 RTC_DCHECK_RUN_ON(worker_queue_); |
| 917 // If the encoder has not produced anything the last kEncoderTimeOutMs and it | 921 // If the encoder has not produced anything the last kEncoderTimeOutMs and it |
| 918 // is supposed to, deregister as BitrateAllocatorObserver. This can happen | 922 // is supposed to, deregister as BitrateAllocatorObserver. This can happen |
| 919 // if a camera stops producing frames. | 923 // if a camera stops producing frames. |
| 920 if (encoder_target_rate_bps_ > 0) { | 924 if (encoder_target_rate_bps_ > 0) { |
| 921 LOG(LS_INFO) << "SignalEncoderTimedOut, Encoder timed out."; | 925 LOG(LS_INFO) << "SignalEncoderTimedOut, Encoder timed out."; |
| 922 bitrate_allocator_->RemoveObserver(this); | 926 bitrate_allocator_->RemoveObserver(this); |
| 923 } | 927 } |
| 924 } | 928 } |
| 925 | 929 |
| 930 void VideoSendStreamImpl::OnBitrateAllocationUpdated( |
| 931 const BitrateAllocation& allocation) { |
| 932 payload_router_.OnBitrateAllocationUpdated(allocation); |
| 933 } |
| 934 |
| 926 void VideoSendStreamImpl::SignalEncoderActive() { | 935 void VideoSendStreamImpl::SignalEncoderActive() { |
| 927 RTC_DCHECK_RUN_ON(worker_queue_); | 936 RTC_DCHECK_RUN_ON(worker_queue_); |
| 928 LOG(LS_INFO) << "SignalEncoderActive, Encoder is active."; | 937 LOG(LS_INFO) << "SignalEncoderActive, Encoder is active."; |
| 929 bitrate_allocator_->AddObserver( | 938 bitrate_allocator_->AddObserver( |
| 930 this, encoder_min_bitrate_bps_, encoder_max_bitrate_bps_, | 939 this, encoder_min_bitrate_bps_, encoder_max_bitrate_bps_, |
| 931 max_padding_bitrate_, !config_->suspend_below_min_bitrate); | 940 max_padding_bitrate_, !config_->suspend_below_min_bitrate); |
| 932 } | 941 } |
| 933 | 942 |
| 934 void VideoSendStreamImpl::OnEncoderConfigurationChanged( | 943 void VideoSendStreamImpl::OnEncoderConfigurationChanged( |
| 935 std::vector<VideoStream> streams, | 944 std::vector<VideoStream> streams, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 958 for (size_t i = streams.size(); i < config_->rtp.ssrcs.size(); ++i) { | 967 for (size_t i = streams.size(); i < config_->rtp.ssrcs.size(); ++i) { |
| 959 stats_proxy_->OnInactiveSsrc(config_->rtp.ssrcs[i]); | 968 stats_proxy_->OnInactiveSsrc(config_->rtp.ssrcs[i]); |
| 960 } | 969 } |
| 961 | 970 |
| 962 size_t number_of_temporal_layers = | 971 size_t number_of_temporal_layers = |
| 963 streams.back().temporal_layer_thresholds_bps.size() + 1; | 972 streams.back().temporal_layer_thresholds_bps.size() + 1; |
| 964 protection_bitrate_calculator_.SetEncodingData( | 973 protection_bitrate_calculator_.SetEncodingData( |
| 965 streams[0].width, streams[0].height, number_of_temporal_layers, | 974 streams[0].width, streams[0].height, number_of_temporal_layers, |
| 966 config_->rtp.max_packet_size); | 975 config_->rtp.max_packet_size); |
| 967 | 976 |
| 968 if (payload_router_.active()) { | 977 if (payload_router_.IsActive()) { |
| 969 // The send stream is started already. Update the allocator with new bitrate | 978 // The send stream is started already. Update the allocator with new bitrate |
| 970 // limits. | 979 // limits. |
| 971 bitrate_allocator_->AddObserver( | 980 bitrate_allocator_->AddObserver( |
| 972 this, encoder_min_bitrate_bps_, encoder_max_bitrate_bps_, | 981 this, encoder_min_bitrate_bps_, encoder_max_bitrate_bps_, |
| 973 max_padding_bitrate_, !config_->suspend_below_min_bitrate); | 982 max_padding_bitrate_, !config_->suspend_below_min_bitrate); |
| 974 } | 983 } |
| 975 } | 984 } |
| 976 | 985 |
| 977 EncodedImageCallback::Result VideoSendStreamImpl::OnEncodedImage( | 986 EncodedImageCallback::Result VideoSendStreamImpl::OnEncodedImage( |
| 978 const EncodedImage& encoded_image, | 987 const EncodedImage& encoded_image, |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 rtp_rtcp->SetRTCPStatus(state == kNetworkUp ? config_->rtp.rtcp_mode | 1176 rtp_rtcp->SetRTCPStatus(state == kNetworkUp ? config_->rtp.rtcp_mode |
| 1168 : RtcpMode::kOff); | 1177 : RtcpMode::kOff); |
| 1169 } | 1178 } |
| 1170 } | 1179 } |
| 1171 | 1180 |
| 1172 uint32_t VideoSendStreamImpl::OnBitrateUpdated(uint32_t bitrate_bps, | 1181 uint32_t VideoSendStreamImpl::OnBitrateUpdated(uint32_t bitrate_bps, |
| 1173 uint8_t fraction_loss, | 1182 uint8_t fraction_loss, |
| 1174 int64_t rtt, | 1183 int64_t rtt, |
| 1175 int64_t probing_interval_ms) { | 1184 int64_t probing_interval_ms) { |
| 1176 RTC_DCHECK_RUN_ON(worker_queue_); | 1185 RTC_DCHECK_RUN_ON(worker_queue_); |
| 1177 RTC_DCHECK(payload_router_.active()) | 1186 RTC_DCHECK(payload_router_.IsActive()) |
| 1178 << "VideoSendStream::Start has not been called."; | 1187 << "VideoSendStream::Start has not been called."; |
| 1179 | 1188 |
| 1180 if (webrtc::field_trial::FindFullName("WebRTC-SendSideBwe-WithOverhead") == | 1189 if (webrtc::field_trial::FindFullName("WebRTC-SendSideBwe-WithOverhead") == |
| 1181 "Enabled") { | 1190 "Enabled") { |
| 1182 // Substract overhead from bitrate. | 1191 // Substract overhead from bitrate. |
| 1183 rtc::CritScope lock(&overhead_bytes_per_packet_crit_); | 1192 rtc::CritScope lock(&overhead_bytes_per_packet_crit_); |
| 1184 int packets_per_second = | 1193 int packets_per_second = |
| 1185 std::ceil(bitrate_bps / (8 * (config_->rtp.max_packet_size + | 1194 std::ceil(bitrate_bps / (8 * (config_->rtp.max_packet_size + |
| 1186 transport_overhead_bytes_per_packet_))); | 1195 transport_overhead_bytes_per_packet_))); |
| 1187 uint32_t overhead_bps = static_cast<uint32_t>( | 1196 uint32_t overhead_bps = static_cast<uint32_t>( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 const uint16_t mtu = static_cast<uint16_t>( | 1270 const uint16_t mtu = static_cast<uint16_t>( |
| 1262 config_->rtp.max_packet_size + transport_overhead_bytes_per_packet); | 1271 config_->rtp.max_packet_size + transport_overhead_bytes_per_packet); |
| 1263 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 1272 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 1264 rtp_rtcp->SetTransportOverhead(transport_overhead_bytes_per_packet); | 1273 rtp_rtcp->SetTransportOverhead(transport_overhead_bytes_per_packet); |
| 1265 rtp_rtcp->SetMaxTransferUnit(mtu); | 1274 rtp_rtcp->SetMaxTransferUnit(mtu); |
| 1266 } | 1275 } |
| 1267 } | 1276 } |
| 1268 | 1277 |
| 1269 } // namespace internal | 1278 } // namespace internal |
| 1270 } // namespace webrtc | 1279 } // namespace webrtc |
| OLD | NEW |