From 82c4b8531c2c4c2aaf82ff57ee1805037a43ed50 Mon Sep 17 00:00:00 2001 From: "wu@webrtc.org" Date: Tue, 20 May 2014 22:55:01 +0000 Subject: [PATCH] Calculate capture ntp timestamp in local timebase for decoded audio frame. BUG=3111 R=stefan@webrtc.org, xians@webrtc.org Review URL: https://webrtc-codereview.appspot.com/19449005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6205 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/voice_engine/channel.cc | 8 ++++++-- webrtc/voice_engine/channel.h | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc index 365d4cadeb..700f5d668b 100644 --- a/webrtc/voice_engine/channel.cc +++ b/webrtc/voice_engine/channel.cc @@ -15,6 +15,7 @@ #include "webrtc/modules/audio_processing/include/audio_processing.h" #include "webrtc/modules/interface/module_common_types.h" #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" +#include "webrtc/modules/rtp_rtcp/interface/remote_ntp_time_estimator.h" #include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h" #include "webrtc/modules/rtp_rtcp/interface/rtp_receiver.h" #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" @@ -664,8 +665,7 @@ int32_t Channel::GetAudioFrame(int32_t id, AudioFrame& audioFrame) // Measure audio level (0-9) _outputAudioLevel.ComputeLevel(audioFrame); - // TODO(wu): Calculate capture NTP time based on RTP timestamp and RTCP SR. - audioFrame.ntp_time_ms_ = 0; + audioFrame.ntp_time_ms_ = ntp_estimator_->Estimate(audioFrame.timestamp_); if (!first_frame_arrived_) { first_frame_arrived_ = true; @@ -849,6 +849,7 @@ Channel::Channel(int32_t channelId, _outputExternalMediaCallbackPtr(NULL), _timeStamp(0), // This is just an offset, RTP module will add it's own random offset _sendTelephoneEventPayloadType(106), + ntp_estimator_(new RemoteNtpTimeEstimator(Clock::GetRealTimeClock())), jitter_buffer_playout_timestamp_(0), playout_timestamp_rtp_(0), playout_timestamp_rtcp_(0), @@ -1875,6 +1876,9 @@ int32_t Channel::ReceivedRTCPPacket(const int8_t* data, int32_t length) { VE_SOCKET_TRANSPORT_MODULE_ERROR, kTraceWarning, "Channel::IncomingRTPPacket() RTCP packet is invalid"); } + + ntp_estimator_->UpdateRtcpTimestamp(rtp_receiver_->SSRC(), + _rtpRtcpModule.get()); return 0; } diff --git a/webrtc/voice_engine/channel.h b/webrtc/voice_engine/channel.h index 7b40ed282c..2eba91e2ba 100644 --- a/webrtc/voice_engine/channel.h +++ b/webrtc/voice_engine/channel.h @@ -42,6 +42,7 @@ class CriticalSectionWrapper; class FileWrapper; class ProcessThread; class ReceiveStatistics; +class RemoteNtpTimeEstimator; class RtpDump; class RTPPayloadRegistry; class RtpReceiver; @@ -531,6 +532,8 @@ private: uint32_t _timeStamp; uint8_t _sendTelephoneEventPayloadType; + scoped_ptr ntp_estimator_; + // Timestamp of the audio pulled from NetEq. uint32_t jitter_buffer_playout_timestamp_; uint32_t playout_timestamp_rtp_;