OLD | NEW |
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 webrtc::AudioReceiveStream::Stats stats; | 102 webrtc::AudioReceiveStream::Stats stats; |
103 stats.remote_ssrc = config_.rtp.remote_ssrc; | 103 stats.remote_ssrc = config_.rtp.remote_ssrc; |
104 internal::AudioState* audio_state = | 104 internal::AudioState* audio_state = |
105 static_cast<internal::AudioState*>(audio_state_.get()); | 105 static_cast<internal::AudioState*>(audio_state_.get()); |
106 VoiceEngine* voice_engine = audio_state->voice_engine(); | 106 VoiceEngine* voice_engine = audio_state->voice_engine(); |
107 ScopedVoEInterface<VoECodec> codec(voice_engine); | 107 ScopedVoEInterface<VoECodec> codec(voice_engine); |
108 ScopedVoEInterface<VoENetEqStats> neteq(voice_engine); | 108 ScopedVoEInterface<VoENetEqStats> neteq(voice_engine); |
109 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine); | 109 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine); |
110 ScopedVoEInterface<VoEVideoSync> sync(voice_engine); | 110 ScopedVoEInterface<VoEVideoSync> sync(voice_engine); |
111 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine); | 111 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine); |
112 unsigned int ssrc = 0; | 112 |
113 webrtc::CallStatistics call_stats = {0}; | 113 webrtc::CallStatistics call_stats = {0}; |
| 114 int error = rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats); |
| 115 RTC_DCHECK_EQ(0, error); |
114 webrtc::CodecInst codec_inst = {0}; | 116 webrtc::CodecInst codec_inst = {0}; |
115 // Only collect stats if we have seen some traffic with the SSRC. | 117 if (codec->GetRecCodec(config_.voe_channel_id, codec_inst) == -1) { |
116 if (rtp->GetRemoteSSRC(config_.voe_channel_id, ssrc) == -1 || | |
117 rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats) == -1 || | |
118 codec->GetRecCodec(config_.voe_channel_id, codec_inst) == -1) { | |
119 return stats; | 118 return stats; |
120 } | 119 } |
121 | 120 |
122 stats.bytes_rcvd = call_stats.bytesReceived; | 121 stats.bytes_rcvd = call_stats.bytesReceived; |
123 stats.packets_rcvd = call_stats.packetsReceived; | 122 stats.packets_rcvd = call_stats.packetsReceived; |
124 stats.packets_lost = call_stats.cumulativeLost; | 123 stats.packets_lost = call_stats.cumulativeLost; |
125 stats.fraction_lost = Q8ToFloat(call_stats.fractionLost); | 124 stats.fraction_lost = Q8ToFloat(call_stats.fractionLost); |
| 125 stats.capture_start_ntp_time_ms = call_stats.capture_start_ntp_time_ms_; |
126 if (codec_inst.pltype != -1) { | 126 if (codec_inst.pltype != -1) { |
127 stats.codec_name = codec_inst.plname; | 127 stats.codec_name = codec_inst.plname; |
128 } | 128 } |
129 stats.ext_seqnum = call_stats.extendedMax; | 129 stats.ext_seqnum = call_stats.extendedMax; |
130 if (codec_inst.plfreq / 1000 > 0) { | 130 if (codec_inst.plfreq / 1000 > 0) { |
131 stats.jitter_ms = call_stats.jitterSamples / (codec_inst.plfreq / 1000); | 131 stats.jitter_ms = call_stats.jitterSamples / (codec_inst.plfreq / 1000); |
132 } | 132 } |
133 { | 133 { |
134 int jitter_buffer_delay_ms = 0; | 134 int jitter_buffer_delay_ms = 0; |
135 int playout_buffer_delay_ms = 0; | 135 int playout_buffer_delay_ms = 0; |
136 sync->GetDelayEstimate(config_.voe_channel_id, &jitter_buffer_delay_ms, | 136 sync->GetDelayEstimate(config_.voe_channel_id, &jitter_buffer_delay_ms, |
137 &playout_buffer_delay_ms); | 137 &playout_buffer_delay_ms); |
138 stats.delay_estimate_ms = jitter_buffer_delay_ms + playout_buffer_delay_ms; | 138 stats.delay_estimate_ms = jitter_buffer_delay_ms + playout_buffer_delay_ms; |
139 } | 139 } |
140 { | 140 { |
141 unsigned int level = 0; | 141 unsigned int level = 0; |
142 if (volume->GetSpeechOutputLevelFullRange(config_.voe_channel_id, level) != | 142 error = volume->GetSpeechOutputLevelFullRange(config_.voe_channel_id, |
143 -1) { | 143 level); |
144 stats.audio_level = static_cast<int32_t>(level); | 144 RTC_DCHECK_EQ(0, error); |
145 } | 145 stats.audio_level = static_cast<int32_t>(level); |
146 } | 146 } |
147 | 147 |
| 148 // Get jitter buffer and total delay (alg + jitter + playout) stats. |
148 webrtc::NetworkStatistics ns = {0}; | 149 webrtc::NetworkStatistics ns = {0}; |
149 if (neteq->GetNetworkStatistics(config_.voe_channel_id, ns) != -1) { | 150 error = neteq->GetNetworkStatistics(config_.voe_channel_id, ns); |
150 // Get jitter buffer and total delay (alg + jitter + playout) stats. | 151 RTC_DCHECK_EQ(0, error); |
151 stats.jitter_buffer_ms = ns.currentBufferSize; | 152 stats.jitter_buffer_ms = ns.currentBufferSize; |
152 stats.jitter_buffer_preferred_ms = ns.preferredBufferSize; | 153 stats.jitter_buffer_preferred_ms = ns.preferredBufferSize; |
153 stats.expand_rate = Q14ToFloat(ns.currentExpandRate); | 154 stats.expand_rate = Q14ToFloat(ns.currentExpandRate); |
154 stats.speech_expand_rate = Q14ToFloat(ns.currentSpeechExpandRate); | 155 stats.speech_expand_rate = Q14ToFloat(ns.currentSpeechExpandRate); |
155 stats.secondary_decoded_rate = Q14ToFloat(ns.currentSecondaryDecodedRate); | 156 stats.secondary_decoded_rate = Q14ToFloat(ns.currentSecondaryDecodedRate); |
156 stats.accelerate_rate = Q14ToFloat(ns.currentAccelerateRate); | 157 stats.accelerate_rate = Q14ToFloat(ns.currentAccelerateRate); |
157 stats.preemptive_expand_rate = Q14ToFloat(ns.currentPreemptiveRate); | 158 stats.preemptive_expand_rate = Q14ToFloat(ns.currentPreemptiveRate); |
158 } | |
159 | 159 |
160 webrtc::AudioDecodingCallStats ds; | 160 webrtc::AudioDecodingCallStats ds; |
161 if (neteq->GetDecodingCallStatistics(config_.voe_channel_id, &ds) != -1) { | 161 error = neteq->GetDecodingCallStatistics(config_.voe_channel_id, &ds); |
162 stats.decoding_calls_to_silence_generator = ds.calls_to_silence_generator; | 162 RTC_DCHECK_EQ(0, error); |
163 stats.decoding_calls_to_neteq = ds.calls_to_neteq; | 163 stats.decoding_calls_to_silence_generator = ds.calls_to_silence_generator; |
164 stats.decoding_normal = ds.decoded_normal; | 164 stats.decoding_calls_to_neteq = ds.calls_to_neteq; |
165 stats.decoding_plc = ds.decoded_plc; | 165 stats.decoding_normal = ds.decoded_normal; |
166 stats.decoding_cng = ds.decoded_cng; | 166 stats.decoding_plc = ds.decoded_plc; |
167 stats.decoding_plc_cng = ds.decoded_plc_cng; | 167 stats.decoding_cng = ds.decoded_cng; |
168 } | 168 stats.decoding_plc_cng = ds.decoded_plc_cng; |
169 | |
170 stats.capture_start_ntp_time_ms = call_stats.capture_start_ntp_time_ms_; | |
171 | 169 |
172 return stats; | 170 return stats; |
173 } | 171 } |
174 | 172 |
175 const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { | 173 const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { |
176 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 174 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
177 return config_; | 175 return config_; |
178 } | 176 } |
179 | 177 |
180 void AudioReceiveStream::Start() { | 178 void AudioReceiveStream::Start() { |
(...skipping 17 matching lines...) Expand all Loading... |
198 } | 196 } |
199 | 197 |
200 bool AudioReceiveStream::DeliverRtp(const uint8_t* packet, | 198 bool AudioReceiveStream::DeliverRtp(const uint8_t* packet, |
201 size_t length, | 199 size_t length, |
202 const PacketTime& packet_time) { | 200 const PacketTime& packet_time) { |
203 // TODO(solenberg): Tests call this function on a network thread, libjingle | 201 // TODO(solenberg): Tests call this function on a network thread, libjingle |
204 // calls on the worker thread. We should move towards always using a network | 202 // calls on the worker thread. We should move towards always using a network |
205 // thread. Then this check can be enabled. | 203 // thread. Then this check can be enabled. |
206 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); | 204 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); |
207 RTPHeader header; | 205 RTPHeader header; |
208 | |
209 if (!rtp_header_parser_->Parse(packet, length, &header)) { | 206 if (!rtp_header_parser_->Parse(packet, length, &header)) { |
210 return false; | 207 return false; |
211 } | 208 } |
212 | 209 |
213 // Only forward if the parsed header has absolute sender time. RTP timestamps | 210 // Only forward if the parsed header has absolute sender time. RTP timestamps |
214 // may have different rates for audio and video and shouldn't be mixed. | 211 // may have different rates for audio and video and shouldn't be mixed. |
215 if (config_.combined_audio_video_bwe && | 212 if (config_.combined_audio_video_bwe && |
216 header.extension.hasAbsoluteSendTime) { | 213 header.extension.hasAbsoluteSendTime) { |
217 int64_t arrival_time_ms = TickTime::MillisecondTimestamp(); | 214 int64_t arrival_time_ms = TickTime::MillisecondTimestamp(); |
218 if (packet_time.timestamp >= 0) | 215 if (packet_time.timestamp >= 0) |
219 arrival_time_ms = (packet_time.timestamp + 500) / 1000; | 216 arrival_time_ms = (packet_time.timestamp + 500) / 1000; |
220 size_t payload_size = length - header.headerLength; | 217 size_t payload_size = length - header.headerLength; |
221 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size, | 218 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size, |
222 header, false); | 219 header, false); |
223 } | 220 } |
224 return true; | 221 return true; |
225 } | 222 } |
226 } // namespace internal | 223 } // namespace internal |
227 } // namespace webrtc | 224 } // namespace webrtc |
OLD | NEW |