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

Side by Side Diff: webrtc/voice_engine/channel.cc

Issue 1857183002: VoE: Handle empty playout timestamp differently (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@neteq-playout-timestamp-optional
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | no next file » | 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) 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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 _inputFilePlayerId(VoEModuleId(instanceId, channelId) + 1024), 736 _inputFilePlayerId(VoEModuleId(instanceId, channelId) + 1024),
737 _outputFilePlayerId(VoEModuleId(instanceId, channelId) + 1025), 737 _outputFilePlayerId(VoEModuleId(instanceId, channelId) + 1025),
738 _outputFileRecorderId(VoEModuleId(instanceId, channelId) + 1026), 738 _outputFileRecorderId(VoEModuleId(instanceId, channelId) + 1026),
739 _outputFileRecording(false), 739 _outputFileRecording(false),
740 _outputExternalMedia(false), 740 _outputExternalMedia(false),
741 _inputExternalMediaCallbackPtr(NULL), 741 _inputExternalMediaCallbackPtr(NULL),
742 _outputExternalMediaCallbackPtr(NULL), 742 _outputExternalMediaCallbackPtr(NULL),
743 _timeStamp(0), // This is just an offset, RTP module will add it's own 743 _timeStamp(0), // This is just an offset, RTP module will add it's own
744 // random offset 744 // random offset
745 ntp_estimator_(Clock::GetRealTimeClock()), 745 ntp_estimator_(Clock::GetRealTimeClock()),
746 jitter_buffer_playout_timestamp_(0),
747 playout_timestamp_rtp_(0), 746 playout_timestamp_rtp_(0),
748 playout_timestamp_rtcp_(0), 747 playout_timestamp_rtcp_(0),
749 playout_delay_ms_(0), 748 playout_delay_ms_(0),
750 _numberOfDiscardedPackets(0), 749 _numberOfDiscardedPackets(0),
751 send_sequence_number_(0), 750 send_sequence_number_(0),
752 rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()), 751 rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()),
753 capture_start_rtp_time_stamp_(-1), 752 capture_start_rtp_time_stamp_(-1),
754 capture_start_ntp_time_ms_(-1), 753 capture_start_ntp_time_ms_(-1),
755 _engineStatisticsPtr(NULL), 754 _engineStatisticsPtr(NULL),
756 _outputMixerPtr(NULL), 755 _outputMixerPtr(NULL),
(...skipping 2524 matching lines...) Expand 10 before | Expand all | Expand 10 after
3281 ") != " 3280 ") != "
3282 "fileSamples(%" PRIuS ")", 3281 "fileSamples(%" PRIuS ")",
3283 audioFrame.samples_per_channel_, fileSamples); 3282 audioFrame.samples_per_channel_, fileSamples);
3284 return -1; 3283 return -1;
3285 } 3284 }
3286 3285
3287 return 0; 3286 return 0;
3288 } 3287 }
3289 3288
3290 void Channel::UpdatePlayoutTimestamp(bool rtcp) { 3289 void Channel::UpdatePlayoutTimestamp(bool rtcp) {
3291 rtc::Optional<uint32_t> playout_timestamp = audio_coding_->PlayoutTimestamp(); 3290 jitter_buffer_playout_timestamp_ = audio_coding_->PlayoutTimestamp();
3292 3291
3293 if (!playout_timestamp) { 3292 if (!jitter_buffer_playout_timestamp_) {
3294 // This can happen if this channel has not been received any RTP packet. In 3293 // This can happen if this channel has not received any RTP packets. In
3295 // this case, NetEq is not capable of computing playout timestamp. 3294 // this case, NetEq is not capable of computing a playout timestamp.
3296 return; 3295 return;
3297 } 3296 }
3298 3297
3299 uint16_t delay_ms = 0; 3298 uint16_t delay_ms = 0;
3300 if (_audioDeviceModulePtr->PlayoutDelay(&delay_ms) == -1) { 3299 if (_audioDeviceModulePtr->PlayoutDelay(&delay_ms) == -1) {
3301 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), 3300 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
3302 "Channel::UpdatePlayoutTimestamp() failed to read playout" 3301 "Channel::UpdatePlayoutTimestamp() failed to read playout"
3303 " delay from the ADM"); 3302 " delay from the ADM");
3304 _engineStatisticsPtr->SetLastError( 3303 _engineStatisticsPtr->SetLastError(
3305 VE_CANNOT_RETRIEVE_VALUE, kTraceError, 3304 VE_CANNOT_RETRIEVE_VALUE, kTraceError,
3306 "UpdatePlayoutTimestamp() failed to retrieve playout delay"); 3305 "UpdatePlayoutTimestamp() failed to retrieve playout delay");
3307 return; 3306 return;
3308 } 3307 }
3309 3308
3310 jitter_buffer_playout_timestamp_ = *playout_timestamp; 3309 RTC_DCHECK(jitter_buffer_playout_timestamp_);
3310 uint32_t playout_timestamp = *jitter_buffer_playout_timestamp_;
3311 3311
3312 // Remove the playout delay. 3312 // Remove the playout delay.
3313 *playout_timestamp -= (delay_ms * (GetPlayoutFrequency() / 1000)); 3313 playout_timestamp -= (delay_ms * (GetPlayoutFrequency() / 1000));
3314 3314
3315 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), 3315 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId),
3316 "Channel::UpdatePlayoutTimestamp() => playoutTimestamp = %lu", 3316 "Channel::UpdatePlayoutTimestamp() => playoutTimestamp = %lu",
3317 *playout_timestamp); 3317 playout_timestamp);
3318 3318
3319 { 3319 {
3320 rtc::CritScope lock(&video_sync_lock_); 3320 rtc::CritScope lock(&video_sync_lock_);
3321 if (rtcp) { 3321 if (rtcp) {
3322 playout_timestamp_rtcp_ = *playout_timestamp; 3322 playout_timestamp_rtcp_ = playout_timestamp;
3323 } else { 3323 } else {
3324 playout_timestamp_rtp_ = *playout_timestamp; 3324 playout_timestamp_rtp_ = playout_timestamp;
3325 } 3325 }
3326 playout_delay_ms_ = delay_ms; 3326 playout_delay_ms_ = delay_ms;
3327 } 3327 }
3328 } 3328 }
3329 3329
3330 // Called for incoming RTP packets after successful RTP header parsing. 3330 // Called for incoming RTP packets after successful RTP header parsing.
3331 void Channel::UpdatePacketDelay(uint32_t rtp_timestamp, 3331 void Channel::UpdatePacketDelay(uint32_t rtp_timestamp,
3332 uint16_t sequence_number) { 3332 uint16_t sequence_number) {
3333 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), 3333 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId),
3334 "Channel::UpdatePacketDelay(timestamp=%lu, sequenceNumber=%u)", 3334 "Channel::UpdatePacketDelay(timestamp=%lu, sequenceNumber=%u)",
3335 rtp_timestamp, sequence_number); 3335 rtp_timestamp, sequence_number);
3336 3336
3337 // Get frequency of last received payload 3337 // Get frequency of last received payload
3338 int rtp_receive_frequency = GetPlayoutFrequency(); 3338 int rtp_receive_frequency = GetPlayoutFrequency();
3339 3339
3340 // |jitter_buffer_playout_timestamp_| updated in UpdatePlayoutTimestamp for 3340 // |jitter_buffer_playout_timestamp_| updated in UpdatePlayoutTimestamp for
3341 // every incoming packet. 3341 // every incoming packet. May be empty if no valid playout timestamp is
3342 uint32_t timestamp_diff_ms = 3342 // available.
3343 (rtp_timestamp - jitter_buffer_playout_timestamp_) / 3343 uint32_t timestamp_diff_ms = 0;
3344 (rtp_receive_frequency / 1000); 3344 if (jitter_buffer_playout_timestamp_ &&
3345 if (!IsNewerTimestamp(rtp_timestamp, jitter_buffer_playout_timestamp_) || 3345 IsNewerTimestamp(rtp_timestamp, *jitter_buffer_playout_timestamp_)) {
3346 timestamp_diff_ms > (2 * kVoiceEngineMaxMinPlayoutDelayMs)) {
3347 // If |jitter_buffer_playout_timestamp_| is newer than the incoming RTP 3346 // If |jitter_buffer_playout_timestamp_| is newer than the incoming RTP
3348 // timestamp, the resulting difference is negative, but is set to zero. 3347 // timestamp, the resulting difference is negative, but is set to zero.
the sun 2016/04/05 14:06:29 AFAICT this comment is wrong now - you're not sett
hlundin-webrtc 2016/04/05 14:35:15 Implicitly I still do. I changed the negation befo
3349 // This can happen when a network glitch causes a packet to arrive late, 3348 // This can happen when a network glitch causes a packet to arrive late,
3350 // and during long comfort noise periods with clock drift. 3349 // and during long comfort noise periods with clock drift.
3351 timestamp_diff_ms = 0; 3350 timestamp_diff_ms = (rtp_timestamp - *jitter_buffer_playout_timestamp_) /
3351 (rtp_receive_frequency / 1000);
3352 if (timestamp_diff_ms > (2 * kVoiceEngineMaxMinPlayoutDelayMs)) {
3353 // Diff is too large; set it to zero instead.
3354 timestamp_diff_ms = 0;
3355 }
3352 } 3356 }
3353 3357
3354 uint16_t packet_delay_ms = 3358 uint16_t packet_delay_ms =
3355 (rtp_timestamp - _previousTimestamp) / (rtp_receive_frequency / 1000); 3359 (rtp_timestamp - _previousTimestamp) / (rtp_receive_frequency / 1000);
3356 3360
3357 _previousTimestamp = rtp_timestamp; 3361 _previousTimestamp = rtp_timestamp;
3358 3362
3359 if (timestamp_diff_ms == 0) 3363 if (timestamp_diff_ms == 0)
3360 return; 3364 return;
3361 3365
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
3528 int64_t min_rtt = 0; 3532 int64_t min_rtt = 0;
3529 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3533 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3530 0) { 3534 0) {
3531 return 0; 3535 return 0;
3532 } 3536 }
3533 return rtt; 3537 return rtt;
3534 } 3538 }
3535 3539
3536 } // namespace voe 3540 } // namespace voe
3537 } // namespace webrtc 3541 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698