| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 rtp_header_parser_(RtpHeaderParser::Create()) { | 72 rtp_header_parser_(RtpHeaderParser::Create()) { |
| 73 LOG(LS_INFO) << "AudioReceiveStream: " << config_.ToString(); | 73 LOG(LS_INFO) << "AudioReceiveStream: " << config_.ToString(); |
| 74 RTC_DCHECK_NE(config_.voe_channel_id, -1); | 74 RTC_DCHECK_NE(config_.voe_channel_id, -1); |
| 75 RTC_DCHECK(remote_bitrate_estimator_); | 75 RTC_DCHECK(remote_bitrate_estimator_); |
| 76 RTC_DCHECK(audio_state_.get()); | 76 RTC_DCHECK(audio_state_.get()); |
| 77 RTC_DCHECK(rtp_header_parser_); | 77 RTC_DCHECK(rtp_header_parser_); |
| 78 | 78 |
| 79 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); | 79 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); |
| 80 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); | 80 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); |
| 81 channel_proxy_->SetLocalSSRC(config.rtp.local_ssrc); | 81 channel_proxy_->SetLocalSSRC(config.rtp.local_ssrc); |
| 82 | |
| 83 const int channel_id = config.voe_channel_id; | |
| 84 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine()); | |
| 85 for (const auto& extension : config.rtp.extensions) { | 82 for (const auto& extension : config.rtp.extensions) { |
| 86 // One-byte-extension local identifiers are in the range 1-14 inclusive. | |
| 87 RTC_DCHECK_GE(extension.id, 1); | |
| 88 RTC_DCHECK_LE(extension.id, 14); | |
| 89 if (extension.name == RtpExtension::kAudioLevel) { | 83 if (extension.name == RtpExtension::kAudioLevel) { |
| 90 int error = rtp->SetReceiveAudioLevelIndicationStatus(channel_id, true, | 84 channel_proxy_->SetReceiveAudioLevelIndicationStatus(true, extension.id); |
| 91 extension.id); | |
| 92 RTC_DCHECK_EQ(0, error); | |
| 93 bool registered = rtp_header_parser_->RegisterRtpHeaderExtension( | 85 bool registered = rtp_header_parser_->RegisterRtpHeaderExtension( |
| 94 kRtpExtensionAudioLevel, extension.id); | 86 kRtpExtensionAudioLevel, extension.id); |
| 95 RTC_DCHECK(registered); | 87 RTC_DCHECK(registered); |
| 96 } else if (extension.name == RtpExtension::kAbsSendTime) { | 88 } else if (extension.name == RtpExtension::kAbsSendTime) { |
| 97 int error = rtp->SetReceiveAbsoluteSenderTimeStatus(channel_id, true, | 89 channel_proxy_->SetReceiveAbsoluteSenderTimeStatus(true, extension.id); |
| 98 extension.id); | |
| 99 RTC_DCHECK_EQ(0, error); | |
| 100 bool registered = rtp_header_parser_->RegisterRtpHeaderExtension( | 90 bool registered = rtp_header_parser_->RegisterRtpHeaderExtension( |
| 101 kRtpExtensionAbsoluteSendTime, extension.id); | 91 kRtpExtensionAbsoluteSendTime, extension.id); |
| 102 RTC_DCHECK(registered); | 92 RTC_DCHECK(registered); |
| 103 } else if (extension.name == RtpExtension::kTransportSequenceNumber) { | 93 } else if (extension.name == RtpExtension::kTransportSequenceNumber) { |
| 104 // TODO(holmer): Need to do something here or in DeliverRtp() to actually | 94 // TODO(holmer): Need to do something here or in DeliverRtp() to actually |
| 105 // handle audio packets with this header extension. | 95 // handle audio packets with this header extension. |
| 106 bool registered = rtp_header_parser_->RegisterRtpHeaderExtension( | 96 bool registered = rtp_header_parser_->RegisterRtpHeaderExtension( |
| 107 kRtpExtensionTransportSequenceNumber, extension.id); | 97 kRtpExtensionTransportSequenceNumber, extension.id); |
| 108 RTC_DCHECK(registered); | 98 RTC_DCHECK(registered); |
| 109 } else { | 99 } else { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 header, false); | 151 header, false); |
| 162 } | 152 } |
| 163 return true; | 153 return true; |
| 164 } | 154 } |
| 165 | 155 |
| 166 webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const { | 156 webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const { |
| 167 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 157 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 168 webrtc::AudioReceiveStream::Stats stats; | 158 webrtc::AudioReceiveStream::Stats stats; |
| 169 stats.remote_ssrc = config_.rtp.remote_ssrc; | 159 stats.remote_ssrc = config_.rtp.remote_ssrc; |
| 170 ScopedVoEInterface<VoECodec> codec(voice_engine()); | 160 ScopedVoEInterface<VoECodec> codec(voice_engine()); |
| 171 ScopedVoEInterface<VoENetEqStats> neteq(voice_engine()); | |
| 172 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine()); | |
| 173 ScopedVoEInterface<VoEVideoSync> sync(voice_engine()); | |
| 174 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine()); | |
| 175 | 161 |
| 176 webrtc::CallStatistics call_stats = {0}; | 162 webrtc::CallStatistics call_stats = channel_proxy_->GetRTCPStatistics(); |
| 177 int error = rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats); | |
| 178 RTC_DCHECK_EQ(0, error); | |
| 179 webrtc::CodecInst codec_inst = {0}; | 163 webrtc::CodecInst codec_inst = {0}; |
| 180 if (codec->GetRecCodec(config_.voe_channel_id, codec_inst) == -1) { | 164 if (codec->GetRecCodec(config_.voe_channel_id, codec_inst) == -1) { |
| 181 return stats; | 165 return stats; |
| 182 } | 166 } |
| 183 | 167 |
| 184 stats.bytes_rcvd = call_stats.bytesReceived; | 168 stats.bytes_rcvd = call_stats.bytesReceived; |
| 185 stats.packets_rcvd = call_stats.packetsReceived; | 169 stats.packets_rcvd = call_stats.packetsReceived; |
| 186 stats.packets_lost = call_stats.cumulativeLost; | 170 stats.packets_lost = call_stats.cumulativeLost; |
| 187 stats.fraction_lost = Q8ToFloat(call_stats.fractionLost); | 171 stats.fraction_lost = Q8ToFloat(call_stats.fractionLost); |
| 188 stats.capture_start_ntp_time_ms = call_stats.capture_start_ntp_time_ms_; | 172 stats.capture_start_ntp_time_ms = call_stats.capture_start_ntp_time_ms_; |
| 189 if (codec_inst.pltype != -1) { | 173 if (codec_inst.pltype != -1) { |
| 190 stats.codec_name = codec_inst.plname; | 174 stats.codec_name = codec_inst.plname; |
| 191 } | 175 } |
| 192 stats.ext_seqnum = call_stats.extendedMax; | 176 stats.ext_seqnum = call_stats.extendedMax; |
| 193 if (codec_inst.plfreq / 1000 > 0) { | 177 if (codec_inst.plfreq / 1000 > 0) { |
| 194 stats.jitter_ms = call_stats.jitterSamples / (codec_inst.plfreq / 1000); | 178 stats.jitter_ms = call_stats.jitterSamples / (codec_inst.plfreq / 1000); |
| 195 } | 179 } |
| 196 { | 180 stats.delay_estimate_ms = channel_proxy_->GetDelayEstimate(); |
| 197 int jitter_buffer_delay_ms = 0; | 181 stats.audio_level = channel_proxy_->GetSpeechOutputLevelFullRange(); |
| 198 int playout_buffer_delay_ms = 0; | |
| 199 sync->GetDelayEstimate(config_.voe_channel_id, &jitter_buffer_delay_ms, | |
| 200 &playout_buffer_delay_ms); | |
| 201 stats.delay_estimate_ms = jitter_buffer_delay_ms + playout_buffer_delay_ms; | |
| 202 } | |
| 203 { | |
| 204 unsigned int level = 0; | |
| 205 error = volume->GetSpeechOutputLevelFullRange(config_.voe_channel_id, | |
| 206 level); | |
| 207 RTC_DCHECK_EQ(0, error); | |
| 208 stats.audio_level = static_cast<int32_t>(level); | |
| 209 } | |
| 210 | 182 |
| 211 // Get jitter buffer and total delay (alg + jitter + playout) stats. | 183 // Get jitter buffer and total delay (alg + jitter + playout) stats. |
| 212 webrtc::NetworkStatistics ns = {0}; | 184 auto ns = channel_proxy_->GetNetworkStatistics(); |
| 213 error = neteq->GetNetworkStatistics(config_.voe_channel_id, ns); | |
| 214 RTC_DCHECK_EQ(0, error); | |
| 215 stats.jitter_buffer_ms = ns.currentBufferSize; | 185 stats.jitter_buffer_ms = ns.currentBufferSize; |
| 216 stats.jitter_buffer_preferred_ms = ns.preferredBufferSize; | 186 stats.jitter_buffer_preferred_ms = ns.preferredBufferSize; |
| 217 stats.expand_rate = Q14ToFloat(ns.currentExpandRate); | 187 stats.expand_rate = Q14ToFloat(ns.currentExpandRate); |
| 218 stats.speech_expand_rate = Q14ToFloat(ns.currentSpeechExpandRate); | 188 stats.speech_expand_rate = Q14ToFloat(ns.currentSpeechExpandRate); |
| 219 stats.secondary_decoded_rate = Q14ToFloat(ns.currentSecondaryDecodedRate); | 189 stats.secondary_decoded_rate = Q14ToFloat(ns.currentSecondaryDecodedRate); |
| 220 stats.accelerate_rate = Q14ToFloat(ns.currentAccelerateRate); | 190 stats.accelerate_rate = Q14ToFloat(ns.currentAccelerateRate); |
| 221 stats.preemptive_expand_rate = Q14ToFloat(ns.currentPreemptiveRate); | 191 stats.preemptive_expand_rate = Q14ToFloat(ns.currentPreemptiveRate); |
| 222 | 192 |
| 223 webrtc::AudioDecodingCallStats ds; | 193 auto ds = channel_proxy_->GetDecodingCallStatistics(); |
| 224 error = neteq->GetDecodingCallStatistics(config_.voe_channel_id, &ds); | |
| 225 RTC_DCHECK_EQ(0, error); | |
| 226 stats.decoding_calls_to_silence_generator = ds.calls_to_silence_generator; | 194 stats.decoding_calls_to_silence_generator = ds.calls_to_silence_generator; |
| 227 stats.decoding_calls_to_neteq = ds.calls_to_neteq; | 195 stats.decoding_calls_to_neteq = ds.calls_to_neteq; |
| 228 stats.decoding_normal = ds.decoded_normal; | 196 stats.decoding_normal = ds.decoded_normal; |
| 229 stats.decoding_plc = ds.decoded_plc; | 197 stats.decoding_plc = ds.decoded_plc; |
| 230 stats.decoding_cng = ds.decoded_cng; | 198 stats.decoding_cng = ds.decoded_cng; |
| 231 stats.decoding_plc_cng = ds.decoded_plc_cng; | 199 stats.decoding_plc_cng = ds.decoded_plc_cng; |
| 232 | 200 |
| 233 return stats; | 201 return stats; |
| 234 } | 202 } |
| 235 | 203 |
| 236 const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { | 204 const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { |
| 237 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 205 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 238 return config_; | 206 return config_; |
| 239 } | 207 } |
| 240 | 208 |
| 241 VoiceEngine* AudioReceiveStream::voice_engine() const { | 209 VoiceEngine* AudioReceiveStream::voice_engine() const { |
| 242 internal::AudioState* audio_state = | 210 internal::AudioState* audio_state = |
| 243 static_cast<internal::AudioState*>(audio_state_.get()); | 211 static_cast<internal::AudioState*>(audio_state_.get()); |
| 244 VoiceEngine* voice_engine = audio_state->voice_engine(); | 212 VoiceEngine* voice_engine = audio_state->voice_engine(); |
| 245 RTC_DCHECK(voice_engine); | 213 RTC_DCHECK(voice_engine); |
| 246 return voice_engine; | 214 return voice_engine; |
| 247 } | 215 } |
| 248 } // namespace internal | 216 } // namespace internal |
| 249 } // namespace webrtc | 217 } // namespace webrtc |
| OLD | NEW |