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 | 10 |
(...skipping 25 matching lines...) Expand all Loading... | |
36 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 36 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
37 #include "webrtc/modules/utility/include/process_thread.h" | 37 #include "webrtc/modules/utility/include/process_thread.h" |
38 #include "webrtc/system_wrappers/include/clock.h" | 38 #include "webrtc/system_wrappers/include/clock.h" |
39 #include "webrtc/system_wrappers/include/cpu_info.h" | 39 #include "webrtc/system_wrappers/include/cpu_info.h" |
40 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 40 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
41 #include "webrtc/system_wrappers/include/metrics.h" | 41 #include "webrtc/system_wrappers/include/metrics.h" |
42 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" | 42 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" |
43 #include "webrtc/system_wrappers/include/trace.h" | 43 #include "webrtc/system_wrappers/include/trace.h" |
44 #include "webrtc/video/call_stats.h" | 44 #include "webrtc/video/call_stats.h" |
45 #include "webrtc/video/send_delay_stats.h" | 45 #include "webrtc/video/send_delay_stats.h" |
46 #include "webrtc/video/stats_counter.h" | |
46 #include "webrtc/video/video_receive_stream.h" | 47 #include "webrtc/video/video_receive_stream.h" |
47 #include "webrtc/video/video_send_stream.h" | 48 #include "webrtc/video/video_send_stream.h" |
48 #include "webrtc/video/vie_remb.h" | 49 #include "webrtc/video/vie_remb.h" |
49 #include "webrtc/voice_engine/include/voe_codec.h" | 50 #include "webrtc/voice_engine/include/voe_codec.h" |
50 | 51 |
51 namespace webrtc { | 52 namespace webrtc { |
52 | 53 |
53 const int Call::Config::kDefaultStartBitrateBps = 300000; | 54 const int Call::Config::kDefaultStartBitrateBps = 300000; |
54 | 55 |
55 namespace internal { | 56 namespace internal { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 | 172 |
172 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; | 173 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; |
173 | 174 |
174 std::unique_ptr<webrtc::RtcEventLog> event_log_; | 175 std::unique_ptr<webrtc::RtcEventLog> event_log_; |
175 | 176 |
176 // The following members are only accessed (exclusively) from one thread and | 177 // The following members are only accessed (exclusively) from one thread and |
177 // from the destructor, and therefore doesn't need any explicit | 178 // from the destructor, and therefore doesn't need any explicit |
178 // synchronization. | 179 // synchronization. |
179 int64_t received_video_bytes_; | 180 int64_t received_video_bytes_; |
180 int64_t received_audio_bytes_; | 181 int64_t received_audio_bytes_; |
181 int64_t received_rtcp_bytes_; | 182 int64_t received_rtcp_bytes_; |
stefan-webrtc
2016/09/06 11:55:58
Should we do the same thing for these three? In th
åsapersson
2016/09/06 15:13:23
Also updated video, audio and rctp stats to use Ra
| |
182 int64_t first_rtp_packet_received_ms_; | 183 int64_t first_rtp_packet_received_ms_; |
183 int64_t last_rtp_packet_received_ms_; | 184 int64_t last_rtp_packet_received_ms_; |
184 int64_t first_packet_sent_ms_; | 185 int64_t first_packet_sent_ms_; |
186 RateCounter received_bytes_per_second_counter_; | |
185 | 187 |
186 // TODO(holmer): Remove this lock once BitrateController no longer calls | 188 // TODO(holmer): Remove this lock once BitrateController no longer calls |
187 // OnNetworkChanged from multiple threads. | 189 // OnNetworkChanged from multiple threads. |
188 rtc::CriticalSection bitrate_crit_; | 190 rtc::CriticalSection bitrate_crit_; |
189 int64_t estimated_send_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); | 191 int64_t estimated_send_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); |
190 int64_t pacer_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); | 192 int64_t pacer_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); |
191 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); | 193 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); |
192 int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_); | 194 int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_); |
193 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); | 195 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); |
194 | 196 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 video_network_state_(kNetworkUp), | 235 video_network_state_(kNetworkUp), |
234 receive_crit_(RWLockWrapper::CreateRWLock()), | 236 receive_crit_(RWLockWrapper::CreateRWLock()), |
235 send_crit_(RWLockWrapper::CreateRWLock()), | 237 send_crit_(RWLockWrapper::CreateRWLock()), |
236 event_log_(RtcEventLog::Create(webrtc::Clock::GetRealTimeClock())), | 238 event_log_(RtcEventLog::Create(webrtc::Clock::GetRealTimeClock())), |
237 received_video_bytes_(0), | 239 received_video_bytes_(0), |
238 received_audio_bytes_(0), | 240 received_audio_bytes_(0), |
239 received_rtcp_bytes_(0), | 241 received_rtcp_bytes_(0), |
240 first_rtp_packet_received_ms_(-1), | 242 first_rtp_packet_received_ms_(-1), |
241 last_rtp_packet_received_ms_(-1), | 243 last_rtp_packet_received_ms_(-1), |
242 first_packet_sent_ms_(-1), | 244 first_packet_sent_ms_(-1), |
245 received_bytes_per_second_counter_(clock_, nullptr, false), | |
243 estimated_send_bitrate_sum_kbits_(0), | 246 estimated_send_bitrate_sum_kbits_(0), |
244 pacer_bitrate_sum_kbits_(0), | 247 pacer_bitrate_sum_kbits_(0), |
245 min_allocated_send_bitrate_bps_(0), | 248 min_allocated_send_bitrate_bps_(0), |
246 num_bitrate_updates_(0), | 249 num_bitrate_updates_(0), |
247 configured_max_padding_bitrate_bps_(0), | 250 configured_max_padding_bitrate_bps_(0), |
248 remb_(clock_), | 251 remb_(clock_), |
249 congestion_controller_( | 252 congestion_controller_( |
250 new CongestionController(clock_, this, &remb_, event_log_.get())), | 253 new CongestionController(clock_, this, &remb_, event_log_.get())), |
251 video_send_delay_stats_(new SendDelayStats(clock_)), | 254 video_send_delay_stats_(new SendDelayStats(clock_)), |
252 start_ms_(clock_->TimeInMilliseconds()) { | 255 start_ms_(clock_->TimeInMilliseconds()) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 video_bitrate_kbps); | 348 video_bitrate_kbps); |
346 } | 349 } |
347 if (audio_bitrate_kbps > 0) { | 350 if (audio_bitrate_kbps > 0) { |
348 RTC_LOGGED_HISTOGRAM_COUNTS_100000("WebRTC.Call.AudioBitrateReceivedInKbps", | 351 RTC_LOGGED_HISTOGRAM_COUNTS_100000("WebRTC.Call.AudioBitrateReceivedInKbps", |
349 audio_bitrate_kbps); | 352 audio_bitrate_kbps); |
350 } | 353 } |
351 if (rtcp_bitrate_bps > 0) { | 354 if (rtcp_bitrate_bps > 0) { |
352 RTC_LOGGED_HISTOGRAM_COUNTS_100000("WebRTC.Call.RtcpBitrateReceivedInBps", | 355 RTC_LOGGED_HISTOGRAM_COUNTS_100000("WebRTC.Call.RtcpBitrateReceivedInBps", |
353 rtcp_bitrate_bps); | 356 rtcp_bitrate_bps); |
354 } | 357 } |
355 RTC_LOGGED_HISTOGRAM_COUNTS_100000( | 358 const int kMinRequiredPeriodicSamples = 5; |
356 "WebRTC.Call.BitrateReceivedInKbps", | 359 AggregatedStats recv_bytes_per_sec = |
357 audio_bitrate_kbps + video_bitrate_kbps + rtcp_bitrate_bps / 1000); | 360 received_bytes_per_second_counter_.GetStats(); |
361 if (recv_bytes_per_sec.num_samples >= kMinRequiredPeriodicSamples) { | |
362 RTC_LOGGED_HISTOGRAM_COUNTS_100000("WebRTC.Call.BitrateReceivedInKbps", | |
363 recv_bytes_per_sec.average * 8 / 1000); | |
364 } | |
358 } | 365 } |
359 | 366 |
360 PacketReceiver* Call::Receiver() { | 367 PacketReceiver* Call::Receiver() { |
361 // TODO(solenberg): Some test cases in EndToEndTest use this from a different | 368 // TODO(solenberg): Some test cases in EndToEndTest use this from a different |
362 // thread. Re-enable once that is fixed. | 369 // thread. Re-enable once that is fixed. |
363 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 370 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
364 return this; | 371 return this; |
365 } | 372 } |
366 | 373 |
367 webrtc::AudioSendStream* Call::CreateAudioSendStream( | 374 webrtc::AudioSendStream* Call::CreateAudioSendStream( |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
812 } | 819 } |
813 | 820 |
814 PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type, | 821 PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type, |
815 const uint8_t* packet, | 822 const uint8_t* packet, |
816 size_t length) { | 823 size_t length) { |
817 TRACE_EVENT0("webrtc", "Call::DeliverRtcp"); | 824 TRACE_EVENT0("webrtc", "Call::DeliverRtcp"); |
818 // TODO(pbos): Make sure it's a valid packet. | 825 // TODO(pbos): Make sure it's a valid packet. |
819 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that | 826 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that |
820 // there's no receiver of the packet. | 827 // there's no receiver of the packet. |
821 received_rtcp_bytes_ += length; | 828 received_rtcp_bytes_ += length; |
829 received_bytes_per_second_counter_.Add(length); | |
822 bool rtcp_delivered = false; | 830 bool rtcp_delivered = false; |
823 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 831 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
824 ReadLockScoped read_lock(*receive_crit_); | 832 ReadLockScoped read_lock(*receive_crit_); |
825 for (VideoReceiveStream* stream : video_receive_streams_) { | 833 for (VideoReceiveStream* stream : video_receive_streams_) { |
826 if (stream->DeliverRtcp(packet, length)) | 834 if (stream->DeliverRtcp(packet, length)) |
827 rtcp_delivered = true; | 835 rtcp_delivered = true; |
828 } | 836 } |
829 } | 837 } |
830 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { | 838 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { |
831 ReadLockScoped read_lock(*receive_crit_); | 839 ReadLockScoped read_lock(*receive_crit_); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
867 last_rtp_packet_received_ms_ = clock_->TimeInMilliseconds(); | 875 last_rtp_packet_received_ms_ = clock_->TimeInMilliseconds(); |
868 if (first_rtp_packet_received_ms_ == -1) | 876 if (first_rtp_packet_received_ms_ == -1) |
869 first_rtp_packet_received_ms_ = last_rtp_packet_received_ms_; | 877 first_rtp_packet_received_ms_ = last_rtp_packet_received_ms_; |
870 | 878 |
871 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 879 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
872 ReadLockScoped read_lock(*receive_crit_); | 880 ReadLockScoped read_lock(*receive_crit_); |
873 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { | 881 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { |
874 auto it = audio_receive_ssrcs_.find(ssrc); | 882 auto it = audio_receive_ssrcs_.find(ssrc); |
875 if (it != audio_receive_ssrcs_.end()) { | 883 if (it != audio_receive_ssrcs_.end()) { |
876 received_audio_bytes_ += length; | 884 received_audio_bytes_ += length; |
885 received_bytes_per_second_counter_.Add(length); | |
877 auto status = it->second->DeliverRtp(packet, length, packet_time) | 886 auto status = it->second->DeliverRtp(packet, length, packet_time) |
878 ? DELIVERY_OK | 887 ? DELIVERY_OK |
879 : DELIVERY_PACKET_ERROR; | 888 : DELIVERY_PACKET_ERROR; |
880 if (status == DELIVERY_OK) | 889 if (status == DELIVERY_OK) |
881 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 890 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
882 return status; | 891 return status; |
883 } | 892 } |
884 } | 893 } |
885 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 894 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
886 auto it = video_receive_ssrcs_.find(ssrc); | 895 auto it = video_receive_ssrcs_.find(ssrc); |
887 if (it != video_receive_ssrcs_.end()) { | 896 if (it != video_receive_ssrcs_.end()) { |
888 received_video_bytes_ += length; | 897 received_video_bytes_ += length; |
898 received_bytes_per_second_counter_.Add(length); | |
889 auto status = it->second->DeliverRtp(packet, length, packet_time) | 899 auto status = it->second->DeliverRtp(packet, length, packet_time) |
890 ? DELIVERY_OK | 900 ? DELIVERY_OK |
891 : DELIVERY_PACKET_ERROR; | 901 : DELIVERY_PACKET_ERROR; |
892 if (status == DELIVERY_OK) | 902 if (status == DELIVERY_OK) |
893 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 903 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
894 return status; | 904 return status; |
895 } | 905 } |
896 } | 906 } |
897 return DELIVERY_UNKNOWN_SSRC; | 907 return DELIVERY_UNKNOWN_SSRC; |
898 } | 908 } |
899 | 909 |
900 PacketReceiver::DeliveryStatus Call::DeliverPacket( | 910 PacketReceiver::DeliveryStatus Call::DeliverPacket( |
901 MediaType media_type, | 911 MediaType media_type, |
902 const uint8_t* packet, | 912 const uint8_t* packet, |
903 size_t length, | 913 size_t length, |
904 const PacketTime& packet_time) { | 914 const PacketTime& packet_time) { |
905 // TODO(solenberg): Tests call this function on a network thread, libjingle | 915 // TODO(solenberg): Tests call this function on a network thread, libjingle |
906 // calls on the worker thread. We should move towards always using a network | 916 // calls on the worker thread. We should move towards always using a network |
907 // thread. Then this check can be enabled. | 917 // thread. Then this check can be enabled. |
908 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); | 918 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); |
909 if (RtpHeaderParser::IsRtcp(packet, length)) | 919 if (RtpHeaderParser::IsRtcp(packet, length)) |
910 return DeliverRtcp(media_type, packet, length); | 920 return DeliverRtcp(media_type, packet, length); |
911 | 921 |
912 return DeliverRtp(media_type, packet, length, packet_time); | 922 return DeliverRtp(media_type, packet, length, packet_time); |
913 } | 923 } |
914 | 924 |
915 } // namespace internal | 925 } // namespace internal |
916 } // namespace webrtc | 926 } // namespace webrtc |
OLD | NEW |