| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 } | 667 } |
| 668 | 668 |
| 669 if (capture_start_rtp_time_stamp_ >= 0) { | 669 if (capture_start_rtp_time_stamp_ >= 0) { |
| 670 // audioFrame.timestamp_ should be valid from now on. | 670 // audioFrame.timestamp_ should be valid from now on. |
| 671 | 671 |
| 672 // Compute elapsed time. | 672 // Compute elapsed time. |
| 673 int64_t unwrap_timestamp = | 673 int64_t unwrap_timestamp = |
| 674 rtp_ts_wraparound_handler_->Unwrap(audioFrame->timestamp_); | 674 rtp_ts_wraparound_handler_->Unwrap(audioFrame->timestamp_); |
| 675 audioFrame->elapsed_time_ms_ = | 675 audioFrame->elapsed_time_ms_ = |
| 676 (unwrap_timestamp - capture_start_rtp_time_stamp_) / | 676 (unwrap_timestamp - capture_start_rtp_time_stamp_) / |
| 677 (GetPlayoutFrequency() / 1000); | 677 (GetRtpTimestampRateHz() / 1000); |
| 678 | 678 |
| 679 { | 679 { |
| 680 rtc::CritScope lock(&ts_stats_lock_); | 680 rtc::CritScope lock(&ts_stats_lock_); |
| 681 // Compute ntp time. | 681 // Compute ntp time. |
| 682 audioFrame->ntp_time_ms_ = | 682 audioFrame->ntp_time_ms_ = |
| 683 ntp_estimator_.Estimate(audioFrame->timestamp_); | 683 ntp_estimator_.Estimate(audioFrame->timestamp_); |
| 684 // |ntp_time_ms_| won't be valid until at least 2 RTCP SRs are received. | 684 // |ntp_time_ms_| won't be valid until at least 2 RTCP SRs are received. |
| 685 if (audioFrame->ntp_time_ms_ > 0) { | 685 if (audioFrame->ntp_time_ms_ > 0) { |
| 686 // Compute |capture_start_ntp_time_ms_| so that | 686 // Compute |capture_start_ntp_time_ms_| so that |
| 687 // |capture_start_ntp_time_ms_| + |elapsed_time_ms_| == |ntp_time_ms_| | 687 // |capture_start_ntp_time_ms_| + |elapsed_time_ms_| == |ntp_time_ms_| |
| (...skipping 2385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3073 _engineStatisticsPtr->SetLastError( | 3073 _engineStatisticsPtr->SetLastError( |
| 3074 VE_CANNOT_RETRIEVE_VALUE, kTraceError, | 3074 VE_CANNOT_RETRIEVE_VALUE, kTraceError, |
| 3075 "UpdatePlayoutTimestamp() failed to retrieve playout delay"); | 3075 "UpdatePlayoutTimestamp() failed to retrieve playout delay"); |
| 3076 return; | 3076 return; |
| 3077 } | 3077 } |
| 3078 | 3078 |
| 3079 RTC_DCHECK(jitter_buffer_playout_timestamp_); | 3079 RTC_DCHECK(jitter_buffer_playout_timestamp_); |
| 3080 uint32_t playout_timestamp = *jitter_buffer_playout_timestamp_; | 3080 uint32_t playout_timestamp = *jitter_buffer_playout_timestamp_; |
| 3081 | 3081 |
| 3082 // Remove the playout delay. | 3082 // Remove the playout delay. |
| 3083 playout_timestamp -= (delay_ms * (GetPlayoutFrequency() / 1000)); | 3083 playout_timestamp -= (delay_ms * (GetRtpTimestampRateHz() / 1000)); |
| 3084 | 3084 |
| 3085 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 3085 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
| 3086 "Channel::UpdatePlayoutTimestamp() => playoutTimestamp = %lu", | 3086 "Channel::UpdatePlayoutTimestamp() => playoutTimestamp = %lu", |
| 3087 playout_timestamp); | 3087 playout_timestamp); |
| 3088 | 3088 |
| 3089 { | 3089 { |
| 3090 rtc::CritScope lock(&video_sync_lock_); | 3090 rtc::CritScope lock(&video_sync_lock_); |
| 3091 if (rtcp) { | 3091 if (rtcp) { |
| 3092 playout_timestamp_rtcp_ = playout_timestamp; | 3092 playout_timestamp_rtcp_ = playout_timestamp; |
| 3093 } else { | 3093 } else { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3133 RTPExtensionType type, | 3133 RTPExtensionType type, |
| 3134 unsigned char id) { | 3134 unsigned char id) { |
| 3135 int error = 0; | 3135 int error = 0; |
| 3136 _rtpRtcpModule->DeregisterSendRtpHeaderExtension(type); | 3136 _rtpRtcpModule->DeregisterSendRtpHeaderExtension(type); |
| 3137 if (enable) { | 3137 if (enable) { |
| 3138 error = _rtpRtcpModule->RegisterSendRtpHeaderExtension(type, id); | 3138 error = _rtpRtcpModule->RegisterSendRtpHeaderExtension(type, id); |
| 3139 } | 3139 } |
| 3140 return error; | 3140 return error; |
| 3141 } | 3141 } |
| 3142 | 3142 |
| 3143 int32_t Channel::GetPlayoutFrequency() const { | 3143 int Channel::GetRtpTimestampRateHz() const { |
| 3144 int32_t playout_frequency = audio_coding_->PlayoutFrequency(); | 3144 const auto format = audio_coding_->ReceiveFormat(); |
| 3145 CodecInst current_recive_codec; | 3145 // Default to the playout frequency if we've not gotten any packets yet. |
| 3146 if (audio_coding_->ReceiveCodec(¤t_recive_codec) == 0) { | 3146 // TODO(ossu): Zero clockrate can only happen if we've added an external |
| 3147 if (STR_CASE_CMP("G722", current_recive_codec.plname) == 0) { | 3147 // decoder for a format we don't support internally. Remove once that way of |
| 3148 // Even though the actual sampling rate for G.722 audio is | 3148 // adding decoders is gone! |
| 3149 // 16,000 Hz, the RTP clock rate for the G722 payload format is | 3149 return (format && format->clockrate_hz != 0) |
| 3150 // 8,000 Hz because that value was erroneously assigned in | 3150 ? format->clockrate_hz |
| 3151 // RFC 1890 and must remain unchanged for backward compatibility. | 3151 : audio_coding_->PlayoutFrequency(); |
| 3152 playout_frequency = 8000; | |
| 3153 } else if (STR_CASE_CMP("opus", current_recive_codec.plname) == 0) { | |
| 3154 // We are resampling Opus internally to 32,000 Hz until all our | |
| 3155 // DSP routines can operate at 48,000 Hz, but the RTP clock | |
| 3156 // rate for the Opus payload format is standardized to 48,000 Hz, | |
| 3157 // because that is the maximum supported decoding sampling rate. | |
| 3158 playout_frequency = 48000; | |
| 3159 } | |
| 3160 } | |
| 3161 return playout_frequency; | |
| 3162 } | 3152 } |
| 3163 | 3153 |
| 3164 int64_t Channel::GetRTT(bool allow_associate_channel) const { | 3154 int64_t Channel::GetRTT(bool allow_associate_channel) const { |
| 3165 RtcpMode method = _rtpRtcpModule->RTCP(); | 3155 RtcpMode method = _rtpRtcpModule->RTCP(); |
| 3166 if (method == RtcpMode::kOff) { | 3156 if (method == RtcpMode::kOff) { |
| 3167 return 0; | 3157 return 0; |
| 3168 } | 3158 } |
| 3169 std::vector<RTCPReportBlock> report_blocks; | 3159 std::vector<RTCPReportBlock> report_blocks; |
| 3170 _rtpRtcpModule->RemoteRTCPStat(&report_blocks); | 3160 _rtpRtcpModule->RemoteRTCPStat(&report_blocks); |
| 3171 | 3161 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3205 int64_t min_rtt = 0; | 3195 int64_t min_rtt = 0; |
| 3206 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3196 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
| 3207 0) { | 3197 0) { |
| 3208 return 0; | 3198 return 0; |
| 3209 } | 3199 } |
| 3210 return rtt; | 3200 return rtt; |
| 3211 } | 3201 } |
| 3212 | 3202 |
| 3213 } // namespace voe | 3203 } // namespace voe |
| 3214 } // namespace webrtc | 3204 } // namespace webrtc |
| OLD | NEW |