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

Side by Side Diff: webrtc/audio/audio_receive_stream.cc

Issue 1414743004: Implement AudioSendStream::GetStats(). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: workaround for android build issue Created 5 years, 1 month 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 | « webrtc/audio/audio_receive_stream.h ('k') | webrtc/audio/audio_receive_stream_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 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 10 matching lines...) Expand all
21 #include "webrtc/voice_engine/include/voe_codec.h" 21 #include "webrtc/voice_engine/include/voe_codec.h"
22 #include "webrtc/voice_engine/include/voe_neteq_stats.h" 22 #include "webrtc/voice_engine/include/voe_neteq_stats.h"
23 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" 23 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
24 #include "webrtc/voice_engine/include/voe_video_sync.h" 24 #include "webrtc/voice_engine/include/voe_video_sync.h"
25 #include "webrtc/voice_engine/include/voe_volume_control.h" 25 #include "webrtc/voice_engine/include/voe_volume_control.h"
26 26
27 namespace webrtc { 27 namespace webrtc {
28 std::string AudioReceiveStream::Config::Rtp::ToString() const { 28 std::string AudioReceiveStream::Config::Rtp::ToString() const {
29 std::stringstream ss; 29 std::stringstream ss;
30 ss << "{remote_ssrc: " << remote_ssrc; 30 ss << "{remote_ssrc: " << remote_ssrc;
31 ss << ", local_ssrc: " << local_ssrc;
31 ss << ", extensions: ["; 32 ss << ", extensions: [";
32 for (size_t i = 0; i < extensions.size(); ++i) { 33 for (size_t i = 0; i < extensions.size(); ++i) {
33 ss << extensions[i].ToString(); 34 ss << extensions[i].ToString();
34 if (i != extensions.size() - 1) { 35 if (i != extensions.size() - 1) {
35 ss << ", "; 36 ss << ", ";
36 } 37 }
37 } 38 }
38 ss << ']'; 39 ss << ']';
39 ss << '}'; 40 ss << '}';
40 return ss.str(); 41 return ss.str();
41 } 42 }
42 43
43 std::string AudioReceiveStream::Config::ToString() const { 44 std::string AudioReceiveStream::Config::ToString() const {
44 std::stringstream ss; 45 std::stringstream ss;
45 ss << "{rtp: " << rtp.ToString(); 46 ss << "{rtp: " << rtp.ToString();
47 ss << ", receive_transport: "
48 << (receive_transport ? "(Transport)" : "nullptr");
49 ss << ", rtcp_send_transport: "
50 << (rtcp_send_transport ? "(Transport)" : "nullptr");
46 ss << ", voe_channel_id: " << voe_channel_id; 51 ss << ", voe_channel_id: " << voe_channel_id;
47 if (!sync_group.empty()) { 52 if (!sync_group.empty()) {
48 ss << ", sync_group: " << sync_group; 53 ss << ", sync_group: " << sync_group;
49 } 54 }
55 ss << ", combined_audio_video_bwe: "
56 << (combined_audio_video_bwe ? "true" : "false");
50 ss << '}'; 57 ss << '}';
51 return ss.str(); 58 return ss.str();
52 } 59 }
53 60
54 namespace internal { 61 namespace internal {
55 AudioReceiveStream::AudioReceiveStream( 62 AudioReceiveStream::AudioReceiveStream(
56 RemoteBitrateEstimator* remote_bitrate_estimator, 63 RemoteBitrateEstimator* remote_bitrate_estimator,
57 const webrtc::AudioReceiveStream::Config& config, 64 const webrtc::AudioReceiveStream::Config& config,
58 VoiceEngine* voice_engine) 65 VoiceEngine* voice_engine)
59 : remote_bitrate_estimator_(remote_bitrate_estimator), 66 : remote_bitrate_estimator_(remote_bitrate_estimator),
60 config_(config), 67 config_(config),
61 voice_engine_(voice_engine), 68 voice_engine_(voice_engine),
62 voe_base_(voice_engine), 69 voe_base_(voice_engine),
63 rtp_header_parser_(RtpHeaderParser::Create()) { 70 rtp_header_parser_(RtpHeaderParser::Create()) {
64 RTC_DCHECK(thread_checker_.CalledOnValidThread());
65 LOG(LS_INFO) << "AudioReceiveStream: " << config_.ToString(); 71 LOG(LS_INFO) << "AudioReceiveStream: " << config_.ToString();
66 RTC_DCHECK(config.voe_channel_id != -1); 72 RTC_DCHECK(config.voe_channel_id != -1);
67 RTC_DCHECK(remote_bitrate_estimator_ != nullptr); 73 RTC_DCHECK(remote_bitrate_estimator_ != nullptr);
68 RTC_DCHECK(voice_engine_ != nullptr); 74 RTC_DCHECK(voice_engine_ != nullptr);
69 RTC_DCHECK(rtp_header_parser_ != nullptr); 75 RTC_DCHECK(rtp_header_parser_ != nullptr);
70 for (const auto& ext : config.rtp.extensions) { 76 for (const auto& ext : config.rtp.extensions) {
71 // One-byte-extension local identifiers are in the range 1-14 inclusive. 77 // One-byte-extension local identifiers are in the range 1-14 inclusive.
72 RTC_DCHECK_GE(ext.id, 1); 78 RTC_DCHECK_GE(ext.id, 1);
73 RTC_DCHECK_LE(ext.id, 14); 79 RTC_DCHECK_LE(ext.id, 14);
74 if (ext.name == RtpExtension::kAudioLevel) { 80 if (ext.name == RtpExtension::kAudioLevel) {
(...skipping 19 matching lines...) Expand all
94 webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const { 100 webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const {
95 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 101 RTC_DCHECK(thread_checker_.CalledOnValidThread());
96 webrtc::AudioReceiveStream::Stats stats; 102 webrtc::AudioReceiveStream::Stats stats;
97 stats.remote_ssrc = config_.rtp.remote_ssrc; 103 stats.remote_ssrc = config_.rtp.remote_ssrc;
98 ScopedVoEInterface<VoECodec> codec(voice_engine_); 104 ScopedVoEInterface<VoECodec> codec(voice_engine_);
99 ScopedVoEInterface<VoENetEqStats> neteq(voice_engine_); 105 ScopedVoEInterface<VoENetEqStats> neteq(voice_engine_);
100 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine_); 106 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine_);
101 ScopedVoEInterface<VoEVideoSync> sync(voice_engine_); 107 ScopedVoEInterface<VoEVideoSync> sync(voice_engine_);
102 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine_); 108 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine_);
103 unsigned int ssrc = 0; 109 unsigned int ssrc = 0;
104 webrtc::CallStatistics cs = {0}; 110 webrtc::CallStatistics call_stats = {0};
105 webrtc::CodecInst ci = {0}; 111 webrtc::CodecInst codec_inst = {0};
106 // Only collect stats if we have seen some traffic with the SSRC. 112 // Only collect stats if we have seen some traffic with the SSRC.
107 if (rtp->GetRemoteSSRC(config_.voe_channel_id, ssrc) == -1 || 113 if (rtp->GetRemoteSSRC(config_.voe_channel_id, ssrc) == -1 ||
108 rtp->GetRTCPStatistics(config_.voe_channel_id, cs) == -1 || 114 rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats) == -1 ||
109 codec->GetRecCodec(config_.voe_channel_id, ci) == -1) { 115 codec->GetRecCodec(config_.voe_channel_id, codec_inst) == -1) {
110 return stats; 116 return stats;
111 } 117 }
112 118
113 stats.bytes_rcvd = cs.bytesReceived; 119 stats.bytes_rcvd = call_stats.bytesReceived;
114 stats.packets_rcvd = cs.packetsReceived; 120 stats.packets_rcvd = call_stats.packetsReceived;
115 stats.packets_lost = cs.cumulativeLost; 121 stats.packets_lost = call_stats.cumulativeLost;
116 stats.fraction_lost = static_cast<float>(cs.fractionLost) / (1 << 8); 122 stats.fraction_lost = Q8ToFloat(call_stats.fractionLost);
117 if (ci.pltype != -1) { 123 if (codec_inst.pltype != -1) {
118 stats.codec_name = ci.plname; 124 stats.codec_name = codec_inst.plname;
119 } 125 }
120 126 stats.ext_seqnum = call_stats.extendedMax;
121 stats.ext_seqnum = cs.extendedMax; 127 if (codec_inst.plfreq / 1000 > 0) {
122 if (ci.plfreq / 1000 > 0) { 128 stats.jitter_ms = call_stats.jitterSamples / (codec_inst.plfreq / 1000);
123 stats.jitter_ms = cs.jitterSamples / (ci.plfreq / 1000);
124 } 129 }
125 { 130 {
126 int jitter_buffer_delay_ms = 0; 131 int jitter_buffer_delay_ms = 0;
127 int playout_buffer_delay_ms = 0; 132 int playout_buffer_delay_ms = 0;
128 sync->GetDelayEstimate(config_.voe_channel_id, &jitter_buffer_delay_ms, 133 sync->GetDelayEstimate(config_.voe_channel_id, &jitter_buffer_delay_ms,
129 &playout_buffer_delay_ms); 134 &playout_buffer_delay_ms);
130 stats.delay_estimate_ms = 135 stats.delay_estimate_ms =
131 jitter_buffer_delay_ms + playout_buffer_delay_ms; 136 jitter_buffer_delay_ms + playout_buffer_delay_ms;
132 } 137 }
133 { 138 {
(...skipping 20 matching lines...) Expand all
154 if (neteq->GetDecodingCallStatistics(config_.voe_channel_id, &ds) != -1) { 159 if (neteq->GetDecodingCallStatistics(config_.voe_channel_id, &ds) != -1) {
155 stats.decoding_calls_to_silence_generator = 160 stats.decoding_calls_to_silence_generator =
156 ds.calls_to_silence_generator; 161 ds.calls_to_silence_generator;
157 stats.decoding_calls_to_neteq = ds.calls_to_neteq; 162 stats.decoding_calls_to_neteq = ds.calls_to_neteq;
158 stats.decoding_normal = ds.decoded_normal; 163 stats.decoding_normal = ds.decoded_normal;
159 stats.decoding_plc = ds.decoded_plc; 164 stats.decoding_plc = ds.decoded_plc;
160 stats.decoding_cng = ds.decoded_cng; 165 stats.decoding_cng = ds.decoded_cng;
161 stats.decoding_plc_cng = ds.decoded_plc_cng; 166 stats.decoding_plc_cng = ds.decoded_plc_cng;
162 } 167 }
163 168
164 stats.capture_start_ntp_time_ms = cs.capture_start_ntp_time_ms_; 169 stats.capture_start_ntp_time_ms = call_stats.capture_start_ntp_time_ms_;
165 170
166 return stats; 171 return stats;
167 } 172 }
168 173
169 const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { 174 const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const {
170 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 175 RTC_DCHECK(thread_checker_.CalledOnValidThread());
171 return config_; 176 return config_;
172 } 177 }
173 178
174 void AudioReceiveStream::Start() { 179 void AudioReceiveStream::Start() {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (packet_time.timestamp >= 0) 217 if (packet_time.timestamp >= 0)
213 arrival_time_ms = (packet_time.timestamp + 500) / 1000; 218 arrival_time_ms = (packet_time.timestamp + 500) / 1000;
214 size_t payload_size = length - header.headerLength; 219 size_t payload_size = length - header.headerLength;
215 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size, 220 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size,
216 header, false); 221 header, false);
217 } 222 }
218 return true; 223 return true;
219 } 224 }
220 } // namespace internal 225 } // namespace internal
221 } // namespace webrtc 226 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/audio/audio_receive_stream.h ('k') | webrtc/audio/audio_receive_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698