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

Unified Diff: talk/media/webrtc/webrtcvoiceengine.cc

Issue 1390753002: Implement AudioReceiveStream::GetStats(). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: merge master 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/media/webrtc/webrtcvoiceengine.cc
diff --git a/talk/media/webrtc/webrtcvoiceengine.cc b/talk/media/webrtc/webrtcvoiceengine.cc
index eed1195975704aea781d564eefca5a9953b164d4..fd93535bea0672c35b64e13e80d1d794475a0dd2 100644
--- a/talk/media/webrtc/webrtcvoiceengine.cc
+++ b/talk/media/webrtc/webrtcvoiceengine.cc
@@ -2649,11 +2649,6 @@ bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info) {
}
}
- webrtc::CallStatistics cs;
- unsigned int ssrc;
- webrtc::CodecInst codec;
- unsigned int level;
-
for (const auto& ch : send_streams_) {
const int channel = ch.second->channel();
@@ -2661,6 +2656,8 @@ bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info) {
// remote side told us it got from its RTCP report.
VoiceSenderInfo sinfo;
+ webrtc::CallStatistics cs = {0};
+ unsigned int ssrc = 0;
if (engine()->voe()->rtp()->GetRTCPStatistics(channel, cs) == -1 ||
engine()->voe()->rtp()->GetLocalSSRC(channel, ssrc) == -1) {
continue;
@@ -2681,6 +2678,7 @@ bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info) {
sinfo.packets_lost = -1;
sinfo.ext_seqnum = -1;
std::vector<webrtc::ReportBlock> receive_blocks;
+ webrtc::CodecInst codec = {0};
if (engine()->voe()->rtp()->GetRemoteRTCPReportBlocks(
channel, &receive_blocks) != -1 &&
engine()->voe()->codec()->GetSendCodec(channel, codec) != -1) {
@@ -2701,6 +2699,7 @@ bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info) {
}
// Local speech level.
+ unsigned int level = 0;
sinfo.audio_level = (engine()->voe()->volume()->
GetSpeechInputLevelFullRange(level) != -1) ? level : -1;
@@ -2721,76 +2720,36 @@ bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info) {
}
// Get the SSRC and stats for each receiver.
- for (const auto& ch : receive_channels_) {
- int ch_id = ch.second->channel();
- memset(&cs, 0, sizeof(cs));
- if (engine()->voe()->rtp()->GetRemoteSSRC(ch_id, ssrc) != -1 &&
- engine()->voe()->rtp()->GetRTCPStatistics(ch_id, cs) != -1 &&
- engine()->voe()->codec()->GetRecCodec(ch_id, codec) != -1) {
- VoiceReceiverInfo rinfo;
- rinfo.add_ssrc(ssrc);
- rinfo.bytes_rcvd = cs.bytesReceived;
- rinfo.packets_rcvd = cs.packetsReceived;
- // The next four fields are from the most recently sent RTCP report.
- // Convert Q8 to floating point.
- rinfo.fraction_lost = static_cast<float>(cs.fractionLost) / (1 << 8);
- rinfo.packets_lost = cs.cumulativeLost;
- rinfo.ext_seqnum = cs.extendedMax;
- rinfo.capture_start_ntp_time_ms = cs.capture_start_ntp_time_ms_;
- if (codec.pltype != -1) {
- rinfo.codec_name = codec.plname;
- }
- // Convert samples to milliseconds.
- if (codec.plfreq / 1000 > 0) {
- rinfo.jitter_ms = cs.jitterSamples / (codec.plfreq / 1000);
- }
-
- // Get jitter buffer and total delay (alg + jitter + playout) stats.
- webrtc::NetworkStatistics ns;
- if (engine()->voe()->neteq() &&
- engine()->voe()->neteq()->GetNetworkStatistics(
- ch_id, ns) != -1) {
- rinfo.jitter_buffer_ms = ns.currentBufferSize;
- rinfo.jitter_buffer_preferred_ms = ns.preferredBufferSize;
- rinfo.expand_rate =
- static_cast<float>(ns.currentExpandRate) / (1 << 14);
- rinfo.speech_expand_rate =
- static_cast<float>(ns.currentSpeechExpandRate) / (1 << 14);
- rinfo.secondary_decoded_rate =
- static_cast<float>(ns.currentSecondaryDecodedRate) / (1 << 14);
- rinfo.accelerate_rate =
- static_cast<float>(ns.currentAccelerateRate) / (1 << 14);
- rinfo.preemptive_expand_rate =
- static_cast<float>(ns.currentPreemptiveRate) / (1 << 14);
- }
-
- webrtc::AudioDecodingCallStats ds;
- if (engine()->voe()->neteq() &&
- engine()->voe()->neteq()->GetDecodingCallStatistics(
- ch_id, &ds) != -1) {
- rinfo.decoding_calls_to_silence_generator =
- ds.calls_to_silence_generator;
- rinfo.decoding_calls_to_neteq = ds.calls_to_neteq;
- rinfo.decoding_normal = ds.decoded_normal;
- rinfo.decoding_plc = ds.decoded_plc;
- rinfo.decoding_cng = ds.decoded_cng;
- rinfo.decoding_plc_cng = ds.decoded_plc_cng;
- }
-
- if (engine()->voe()->sync()) {
- int jitter_buffer_delay_ms = 0;
- int playout_buffer_delay_ms = 0;
- engine()->voe()->sync()->GetDelayEstimate(
- ch_id, &jitter_buffer_delay_ms, &playout_buffer_delay_ms);
- rinfo.delay_estimate_ms = jitter_buffer_delay_ms +
- playout_buffer_delay_ms;
- }
-
- // Get speech level.
- rinfo.audio_level = (engine()->voe()->volume()->
- GetSpeechOutputLevelFullRange(ch_id, level) != -1) ? level : -1;
- info->receivers.push_back(rinfo);
- }
+ info->receivers.clear();
+ for (const auto& stream : receive_streams_) {
+ webrtc::AudioReceiveStream::Stats stats = stream.second->GetStats();
+ VoiceReceiverInfo rinfo;
+ rinfo.add_ssrc(stats.remote_ssrc);
+ rinfo.bytes_rcvd = stats.bytes_rcvd;
+ rinfo.packets_rcvd = stats.packets_rcvd;
+ rinfo.packets_lost = stats.packets_lost;
+ rinfo.fraction_lost = stats.fraction_lost;
+ rinfo.codec_name = stats.codec_name;
+ rinfo.ext_seqnum = stats.ext_seqnum;
+ rinfo.jitter_ms = stats.jitter_ms;
+ rinfo.jitter_buffer_ms = stats.jitter_buffer_ms;
+ rinfo.jitter_buffer_preferred_ms = stats.jitter_buffer_preferred_ms;
+ rinfo.delay_estimate_ms = stats.delay_estimate_ms;
+ rinfo.audio_level = stats.audio_level;
+ rinfo.expand_rate = stats.expand_rate;
+ rinfo.speech_expand_rate = stats.speech_expand_rate;
+ rinfo.secondary_decoded_rate = stats.secondary_decoded_rate;
+ rinfo.accelerate_rate = stats.accelerate_rate;
+ rinfo.preemptive_expand_rate = stats.preemptive_expand_rate;
+ rinfo.decoding_calls_to_silence_generator =
+ stats.decoding_calls_to_silence_generator;
+ rinfo.decoding_calls_to_neteq = stats.decoding_calls_to_neteq;
+ rinfo.decoding_normal = stats.decoding_normal;
+ rinfo.decoding_plc = stats.decoding_plc;
+ rinfo.decoding_cng = stats.decoding_cng;
+ rinfo.decoding_plc_cng = stats.decoding_plc_cng;
+ rinfo.capture_start_ntp_time_ms = stats.capture_start_ntp_time_ms;
+ info->receivers.push_back(rinfo);
}
return true;
« 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