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

Side by Side Diff: talk/media/webrtc/webrtcvoiceengine.cc

Issue 1411083006: Revert of Implement AudioReceiveStream::GetStats(). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 2 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 | « talk/media/webrtc/webrtcvoe.h ('k') | talk/media/webrtc/webrtcvoiceengine_unittest.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 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 2676 matching lines...) Expand 10 before | Expand all | Expand 10 after
2687 2687
2688 int median, std; 2688 int median, std;
2689 float dummy; 2689 float dummy;
2690 if (engine()->voe()->processing()->GetEcDelayMetrics( 2690 if (engine()->voe()->processing()->GetEcDelayMetrics(
2691 median, std, dummy) != -1) { 2691 median, std, dummy) != -1) {
2692 echo_delay_median_ms = median; 2692 echo_delay_median_ms = median;
2693 echo_delay_std_ms = std; 2693 echo_delay_std_ms = std;
2694 } 2694 }
2695 } 2695 }
2696 2696
2697 webrtc::CallStatistics cs;
2698 unsigned int ssrc;
2699 webrtc::CodecInst codec;
2700 unsigned int level;
2701
2697 for (const auto& ch : send_channels_) { 2702 for (const auto& ch : send_channels_) {
2698 const int channel = ch.second->channel(); 2703 const int channel = ch.second->channel();
2699 2704
2700 // Fill in the sender info, based on what we know, and what the 2705 // Fill in the sender info, based on what we know, and what the
2701 // remote side told us it got from its RTCP report. 2706 // remote side told us it got from its RTCP report.
2702 VoiceSenderInfo sinfo; 2707 VoiceSenderInfo sinfo;
2703 2708
2704 webrtc::CallStatistics cs = {0};
2705 unsigned int ssrc = 0;
2706 if (engine()->voe()->rtp()->GetRTCPStatistics(channel, cs) == -1 || 2709 if (engine()->voe()->rtp()->GetRTCPStatistics(channel, cs) == -1 ||
2707 engine()->voe()->rtp()->GetLocalSSRC(channel, ssrc) == -1) { 2710 engine()->voe()->rtp()->GetLocalSSRC(channel, ssrc) == -1) {
2708 continue; 2711 continue;
2709 } 2712 }
2710 2713
2711 sinfo.add_ssrc(ssrc); 2714 sinfo.add_ssrc(ssrc);
2712 sinfo.codec_name = send_codec_.get() ? send_codec_->plname : ""; 2715 sinfo.codec_name = send_codec_.get() ? send_codec_->plname : "";
2713 sinfo.bytes_sent = cs.bytesSent; 2716 sinfo.bytes_sent = cs.bytesSent;
2714 sinfo.packets_sent = cs.packetsSent; 2717 sinfo.packets_sent = cs.packetsSent;
2715 // RTT isn't known until a RTCP report is received. Until then, VoiceEngine 2718 // RTT isn't known until a RTCP report is received. Until then, VoiceEngine
2716 // returns 0 to indicate an error value. 2719 // returns 0 to indicate an error value.
2717 sinfo.rtt_ms = (cs.rttMs > 0) ? cs.rttMs : -1; 2720 sinfo.rtt_ms = (cs.rttMs > 0) ? cs.rttMs : -1;
2718 2721
2719 // Get data from the last remote RTCP report. Use default values if no data 2722 // Get data from the last remote RTCP report. Use default values if no data
2720 // available. 2723 // available.
2721 sinfo.fraction_lost = -1.0; 2724 sinfo.fraction_lost = -1.0;
2722 sinfo.jitter_ms = -1; 2725 sinfo.jitter_ms = -1;
2723 sinfo.packets_lost = -1; 2726 sinfo.packets_lost = -1;
2724 sinfo.ext_seqnum = -1; 2727 sinfo.ext_seqnum = -1;
2725 std::vector<webrtc::ReportBlock> receive_blocks; 2728 std::vector<webrtc::ReportBlock> receive_blocks;
2726 webrtc::CodecInst codec = {0};
2727 if (engine()->voe()->rtp()->GetRemoteRTCPReportBlocks( 2729 if (engine()->voe()->rtp()->GetRemoteRTCPReportBlocks(
2728 channel, &receive_blocks) != -1 && 2730 channel, &receive_blocks) != -1 &&
2729 engine()->voe()->codec()->GetSendCodec(channel, codec) != -1) { 2731 engine()->voe()->codec()->GetSendCodec(channel, codec) != -1) {
2730 for (const webrtc::ReportBlock& block : receive_blocks) { 2732 for (const webrtc::ReportBlock& block : receive_blocks) {
2731 // Lookup report for send ssrc only. 2733 // Lookup report for send ssrc only.
2732 if (block.source_SSRC == sinfo.ssrc()) { 2734 if (block.source_SSRC == sinfo.ssrc()) {
2733 // Convert Q8 to floating point. 2735 // Convert Q8 to floating point.
2734 sinfo.fraction_lost = static_cast<float>(block.fraction_lost) / 256; 2736 sinfo.fraction_lost = static_cast<float>(block.fraction_lost) / 256;
2735 // Convert samples to milliseconds. 2737 // Convert samples to milliseconds.
2736 if (codec.plfreq / 1000 > 0) { 2738 if (codec.plfreq / 1000 > 0) {
2737 sinfo.jitter_ms = block.interarrival_jitter / (codec.plfreq / 1000); 2739 sinfo.jitter_ms = block.interarrival_jitter / (codec.plfreq / 1000);
2738 } 2740 }
2739 sinfo.packets_lost = block.cumulative_num_packets_lost; 2741 sinfo.packets_lost = block.cumulative_num_packets_lost;
2740 sinfo.ext_seqnum = block.extended_highest_sequence_number; 2742 sinfo.ext_seqnum = block.extended_highest_sequence_number;
2741 break; 2743 break;
2742 } 2744 }
2743 } 2745 }
2744 } 2746 }
2745 2747
2746 // Local speech level. 2748 // Local speech level.
2747 unsigned int level = 0;
2748 sinfo.audio_level = (engine()->voe()->volume()-> 2749 sinfo.audio_level = (engine()->voe()->volume()->
2749 GetSpeechInputLevelFullRange(level) != -1) ? level : -1; 2750 GetSpeechInputLevelFullRange(level) != -1) ? level : -1;
2750 2751
2751 // TODO(xians): We are injecting the same APM logging to all the send 2752 // TODO(xians): We are injecting the same APM logging to all the send
2752 // channels here because there is no good way to know which send channel 2753 // channels here because there is no good way to know which send channel
2753 // is using the APM. The correct fix is to allow the send channels to have 2754 // is using the APM. The correct fix is to allow the send channels to have
2754 // their own APM so that we can feed the correct APM logging to different 2755 // their own APM so that we can feed the correct APM logging to different
2755 // send channels. See issue crbug/264611 . 2756 // send channels. See issue crbug/264611 .
2756 sinfo.echo_return_loss = echo_return_loss; 2757 sinfo.echo_return_loss = echo_return_loss;
2757 sinfo.echo_return_loss_enhancement = echo_return_loss_enhancement; 2758 sinfo.echo_return_loss_enhancement = echo_return_loss_enhancement;
2758 sinfo.echo_delay_median_ms = echo_delay_median_ms; 2759 sinfo.echo_delay_median_ms = echo_delay_median_ms;
2759 sinfo.echo_delay_std_ms = echo_delay_std_ms; 2760 sinfo.echo_delay_std_ms = echo_delay_std_ms;
2760 // TODO(ajm): Re-enable this metric once we have a reliable implementation. 2761 // TODO(ajm): Re-enable this metric once we have a reliable implementation.
2761 sinfo.aec_quality_min = -1; 2762 sinfo.aec_quality_min = -1;
2762 sinfo.typing_noise_detected = typing_noise_detected_; 2763 sinfo.typing_noise_detected = typing_noise_detected_;
2763 2764
2764 info->senders.push_back(sinfo); 2765 info->senders.push_back(sinfo);
2765 } 2766 }
2766 2767
2767 // Get the SSRC and stats for each receiver. 2768 // Get the SSRC and stats for each receiver.
2768 info->receivers.clear(); 2769 for (const auto& ch : receive_channels_) {
2769 for (const auto& stream : receive_streams_) { 2770 int ch_id = ch.second->channel();
2770 webrtc::AudioReceiveStream::Stats stats = stream.second->GetStats(); 2771 memset(&cs, 0, sizeof(cs));
2771 VoiceReceiverInfo rinfo; 2772 if (engine()->voe()->rtp()->GetRemoteSSRC(ch_id, ssrc) != -1 &&
2772 rinfo.add_ssrc(stats.remote_ssrc); 2773 engine()->voe()->rtp()->GetRTCPStatistics(ch_id, cs) != -1 &&
2773 rinfo.bytes_rcvd = stats.bytes_rcvd; 2774 engine()->voe()->codec()->GetRecCodec(ch_id, codec) != -1) {
2774 rinfo.packets_rcvd = stats.packets_rcvd; 2775 VoiceReceiverInfo rinfo;
2775 rinfo.packets_lost = stats.packets_lost; 2776 rinfo.add_ssrc(ssrc);
2776 rinfo.fraction_lost = stats.fraction_lost; 2777 rinfo.bytes_rcvd = cs.bytesReceived;
2777 rinfo.codec_name = stats.codec_name; 2778 rinfo.packets_rcvd = cs.packetsReceived;
2778 rinfo.ext_seqnum = stats.ext_seqnum; 2779 // The next four fields are from the most recently sent RTCP report.
2779 rinfo.jitter_ms = stats.jitter_ms; 2780 // Convert Q8 to floating point.
2780 rinfo.jitter_buffer_ms = stats.jitter_buffer_ms; 2781 rinfo.fraction_lost = static_cast<float>(cs.fractionLost) / (1 << 8);
2781 rinfo.jitter_buffer_preferred_ms = stats.jitter_buffer_preferred_ms; 2782 rinfo.packets_lost = cs.cumulativeLost;
2782 rinfo.delay_estimate_ms = stats.delay_estimate_ms; 2783 rinfo.ext_seqnum = cs.extendedMax;
2783 rinfo.audio_level = stats.audio_level; 2784 rinfo.capture_start_ntp_time_ms = cs.capture_start_ntp_time_ms_;
2784 rinfo.expand_rate = stats.expand_rate; 2785 if (codec.pltype != -1) {
2785 rinfo.speech_expand_rate = stats.speech_expand_rate; 2786 rinfo.codec_name = codec.plname;
2786 rinfo.secondary_decoded_rate = stats.secondary_decoded_rate; 2787 }
2787 rinfo.accelerate_rate = stats.accelerate_rate; 2788 // Convert samples to milliseconds.
2788 rinfo.preemptive_expand_rate = stats.preemptive_expand_rate; 2789 if (codec.plfreq / 1000 > 0) {
2789 rinfo.decoding_calls_to_silence_generator = 2790 rinfo.jitter_ms = cs.jitterSamples / (codec.plfreq / 1000);
2790 stats.decoding_calls_to_silence_generator; 2791 }
2791 rinfo.decoding_calls_to_neteq = stats.decoding_calls_to_neteq; 2792
2792 rinfo.decoding_normal = stats.decoding_normal; 2793 // Get jitter buffer and total delay (alg + jitter + playout) stats.
2793 rinfo.decoding_plc = stats.decoding_plc; 2794 webrtc::NetworkStatistics ns;
2794 rinfo.decoding_cng = stats.decoding_cng; 2795 if (engine()->voe()->neteq() &&
2795 rinfo.decoding_plc_cng = stats.decoding_plc_cng; 2796 engine()->voe()->neteq()->GetNetworkStatistics(
2796 rinfo.capture_start_ntp_time_ms = stats.capture_start_ntp_time_ms; 2797 ch_id, ns) != -1) {
2797 info->receivers.push_back(rinfo); 2798 rinfo.jitter_buffer_ms = ns.currentBufferSize;
2799 rinfo.jitter_buffer_preferred_ms = ns.preferredBufferSize;
2800 rinfo.expand_rate =
2801 static_cast<float>(ns.currentExpandRate) / (1 << 14);
2802 rinfo.speech_expand_rate =
2803 static_cast<float>(ns.currentSpeechExpandRate) / (1 << 14);
2804 rinfo.secondary_decoded_rate =
2805 static_cast<float>(ns.currentSecondaryDecodedRate) / (1 << 14);
2806 rinfo.accelerate_rate =
2807 static_cast<float>(ns.currentAccelerateRate) / (1 << 14);
2808 rinfo.preemptive_expand_rate =
2809 static_cast<float>(ns.currentPreemptiveRate) / (1 << 14);
2810 }
2811
2812 webrtc::AudioDecodingCallStats ds;
2813 if (engine()->voe()->neteq() &&
2814 engine()->voe()->neteq()->GetDecodingCallStatistics(
2815 ch_id, &ds) != -1) {
2816 rinfo.decoding_calls_to_silence_generator =
2817 ds.calls_to_silence_generator;
2818 rinfo.decoding_calls_to_neteq = ds.calls_to_neteq;
2819 rinfo.decoding_normal = ds.decoded_normal;
2820 rinfo.decoding_plc = ds.decoded_plc;
2821 rinfo.decoding_cng = ds.decoded_cng;
2822 rinfo.decoding_plc_cng = ds.decoded_plc_cng;
2823 }
2824
2825 if (engine()->voe()->sync()) {
2826 int jitter_buffer_delay_ms = 0;
2827 int playout_buffer_delay_ms = 0;
2828 engine()->voe()->sync()->GetDelayEstimate(
2829 ch_id, &jitter_buffer_delay_ms, &playout_buffer_delay_ms);
2830 rinfo.delay_estimate_ms = jitter_buffer_delay_ms +
2831 playout_buffer_delay_ms;
2832 }
2833
2834 // Get speech level.
2835 rinfo.audio_level = (engine()->voe()->volume()->
2836 GetSpeechOutputLevelFullRange(ch_id, level) != -1) ? level : -1;
2837 info->receivers.push_back(rinfo);
2838 }
2798 } 2839 }
2799 2840
2800 return true; 2841 return true;
2801 } 2842 }
2802 2843
2803 void WebRtcVoiceMediaChannel::OnError(int error) { 2844 void WebRtcVoiceMediaChannel::OnError(int error) {
2804 if (send_ == SEND_NOTHING) { 2845 if (send_ == SEND_NOTHING) {
2805 return; 2846 return;
2806 } 2847 }
2807 if (error == VE_TYPING_NOISE_WARNING) { 2848 if (error == VE_TYPING_NOISE_WARNING) {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
3011 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); 3052 LOG(LS_WARNING) << "Unknown codec " << ToString(codec);
3012 return false; 3053 return false;
3013 } 3054 }
3014 } 3055 }
3015 return true; 3056 return true;
3016 } 3057 }
3017 3058
3018 } // namespace cricket 3059 } // namespace cricket
3019 3060
3020 #endif // HAVE_WEBRTC_VOICE 3061 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvoe.h ('k') | talk/media/webrtc/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698