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

Side by Side Diff: webrtc/call/call.cc

Issue 2035383002: Implementing auto pausing of video streams. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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) 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 10
11 #include <string.h> 11 #include <string.h>
12 12
13 #include <algorithm>
13 #include <map> 14 #include <map>
14 #include <memory> 15 #include <memory>
15 #include <vector> 16 #include <vector>
16 17
17 #include "webrtc/audio/audio_receive_stream.h" 18 #include "webrtc/audio/audio_receive_stream.h"
18 #include "webrtc/audio/audio_send_stream.h" 19 #include "webrtc/audio/audio_send_stream.h"
19 #include "webrtc/audio/audio_state.h" 20 #include "webrtc/audio/audio_state.h"
20 #include "webrtc/audio/scoped_voe_interface.h" 21 #include "webrtc/audio/scoped_voe_interface.h"
21 #include "webrtc/base/checks.h" 22 #include "webrtc/base/checks.h"
22 #include "webrtc/base/constructormagic.h" 23 #include "webrtc/base/constructormagic.h"
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id, 671 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id,
671 clock_->TimeInMilliseconds()); 672 clock_->TimeInMilliseconds());
672 congestion_controller_->OnSentPacket(sent_packet); 673 congestion_controller_->OnSentPacket(sent_packet);
673 } 674 }
674 675
675 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss, 676 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss,
676 int64_t rtt_ms) { 677 int64_t rtt_ms) {
677 uint32_t allocated_bitrate_bps = bitrate_allocator_->OnNetworkChanged( 678 uint32_t allocated_bitrate_bps = bitrate_allocator_->OnNetworkChanged(
678 target_bitrate_bps, fraction_loss, rtt_ms); 679 target_bitrate_bps, fraction_loss, rtt_ms);
679 680
680 int pad_up_to_bitrate_bps = 0; 681 int pad_up_to_bitrate_bps = 0;
pbos-webrtc 2016/06/06 15:26:29 Should this be an uint32_t?
mflodman 2016/06/09 13:23:13 I can take care of this in a follow up to not make
681 { 682 {
682 ReadLockScoped read_lock(*send_crit_); 683 ReadLockScoped read_lock(*send_crit_);
683 // No need to update as long as we're not sending. 684 // No need to update as long as we're not sending.
684 if (video_send_streams_.empty()) 685 if (video_send_streams_.empty())
685 return; 686 return;
686 687
687 for (VideoSendStream* stream : video_send_streams_) 688 for (VideoSendStream* stream : video_send_streams_)
688 pad_up_to_bitrate_bps += stream->GetPaddingNeededBps(); 689 pad_up_to_bitrate_bps += stream->GetPaddingNeededBps();
689 } 690 }
690 // Allocated bitrate might be higher than bitrate estimate if enforcing min 691 // Allocated bitrate might be higher than bitrate estimate if enforcing min
691 // bitrate, or lower if estimate is higher than the sum of max bitrates, so 692 // bitrate, or lower if estimate is higher than the sum of max bitrates, so
692 // set the pacer bitrate to the maximum of the two. 693 // set the pacer bitrate to the maximum of the two.
693 uint32_t pacer_bitrate_bps = 694 uint32_t pacer_bitrate_bps =
694 std::max(target_bitrate_bps, allocated_bitrate_bps); 695 std::max(target_bitrate_bps, allocated_bitrate_bps);
695 { 696 {
696 rtc::CritScope lock(&bitrate_crit_); 697 rtc::CritScope lock(&bitrate_crit_);
697 // We only update these stats if we have send streams, and assume that 698 // We only update these stats if we have send streams, and assume that
698 // OnNetworkChanged is called roughly with a fixed frequency. 699 // OnNetworkChanged is called roughly with a fixed frequency.
699 estimated_send_bitrate_sum_kbits_ += target_bitrate_bps / 1000; 700 estimated_send_bitrate_sum_kbits_ += target_bitrate_bps / 1000;
700 pacer_bitrate_sum_kbits_ += pacer_bitrate_bps / 1000; 701 pacer_bitrate_sum_kbits_ += pacer_bitrate_bps / 1000;
701 ++num_bitrate_updates_; 702 ++num_bitrate_updates_;
702 } 703 }
704
705 // Make sure to not ask for more padding than the current BWE allows for.
pbos-webrtc 2016/06/06 15:26:29 Should this be controlled in here or capped inside
mflodman 2016/06/09 13:23:13 That is a good question, but Per is reworking this
706 pad_up_to_bitrate_bps = std::min(static_cast<uint32_t>(pad_up_to_bitrate_bps),
707 target_bitrate_bps);
703 congestion_controller_->SetAllocatedSendBitrate(allocated_bitrate_bps, 708 congestion_controller_->SetAllocatedSendBitrate(allocated_bitrate_bps,
704 pad_up_to_bitrate_bps); 709 pad_up_to_bitrate_bps);
705 } 710 }
706 711
707 void Call::ConfigureSync(const std::string& sync_group) { 712 void Call::ConfigureSync(const std::string& sync_group) {
708 // Set sync only if there was no previous one. 713 // Set sync only if there was no previous one.
709 if (voice_engine() == nullptr || sync_group.empty()) 714 if (voice_engine() == nullptr || sync_group.empty())
710 return; 715 return;
711 716
712 AudioReceiveStream* sync_audio_stream = nullptr; 717 AudioReceiveStream* sync_audio_stream = nullptr;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 // thread. Then this check can be enabled. 853 // thread. Then this check can be enabled.
849 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); 854 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread());
850 if (RtpHeaderParser::IsRtcp(packet, length)) 855 if (RtpHeaderParser::IsRtcp(packet, length))
851 return DeliverRtcp(media_type, packet, length); 856 return DeliverRtcp(media_type, packet, length);
852 857
853 return DeliverRtp(media_type, packet, length, packet_time); 858 return DeliverRtp(media_type, packet, length, packet_time);
854 } 859 }
855 860
856 } // namespace internal 861 } // namespace internal
857 } // namespace webrtc 862 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698