summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/remote_bitrate_estimator/rtp_to_ntp.cc18
-rw-r--r--modules/rtp_rtcp/interface/rtp_rtcp.h7
-rw-r--r--modules/rtp_rtcp/mocks/mock_rtp_rtcp.h2
-rw-r--r--modules/rtp_rtcp/source/rtcp_receiver.cc4
-rw-r--r--modules/rtp_rtcp/source/rtcp_sender.cc56
-rw-r--r--modules/rtp_rtcp/source/rtcp_sender.h7
-rw-r--r--modules/rtp_rtcp/source/rtp_rtcp_impl.cc24
-rw-r--r--modules/rtp_rtcp/source/rtp_rtcp_impl.h2
-rw-r--r--modules/rtp_rtcp/source/rtp_sender.cc6
-rw-r--r--modules/rtp_rtcp/source/rtp_utility.cc8
-rw-r--r--modules/rtp_rtcp/source/rtp_utility.h5
-rw-r--r--modules/video_capture/video_capture_impl.cc4
-rw-r--r--system_wrappers/interface/clock.h13
-rw-r--r--system_wrappers/source/clock.cc93
-rw-r--r--system_wrappers/source/clock_unittest.cc26
-rw-r--r--system_wrappers/source/system_wrappers_tests.gyp1
-rw-r--r--video_engine/vie_encoder.cc1
17 files changed, 141 insertions, 136 deletions
diff --git a/modules/remote_bitrate_estimator/rtp_to_ntp.cc b/modules/remote_bitrate_estimator/rtp_to_ntp.cc
index 5ed38c9f..642c02d9 100644
--- a/modules/remote_bitrate_estimator/rtp_to_ntp.cc
+++ b/modules/remote_bitrate_estimator/rtp_to_ntp.cc
@@ -8,9 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/modules/remote_bitrate_estimator/include/rtp_to_ntp.h"
-
-#include "webrtc/system_wrappers/interface/clock.h"
+#include "modules/remote_bitrate_estimator/include/rtp_to_ntp.h"
#include <assert.h>
@@ -59,6 +57,12 @@ bool CompensateForWrapAround(uint32_t new_timestamp,
return true;
}
+// Converts an NTP timestamp to a millisecond timestamp.
+int64_t NtpToMs(uint32_t ntp_secs, uint32_t ntp_frac) {
+ const double ntp_frac_ms = static_cast<double>(ntp_frac) / kNtpFracPerMs;
+ return ntp_secs * 1000 + ntp_frac_ms + 0.5;
+}
+
// Converts |rtp_timestamp| to the NTP time base using the NTP and RTP timestamp
// pairs in |rtcp|. The converted timestamp is returned in
// |rtp_timestamp_in_ms|. This function compensates for wrap arounds in RTP
@@ -67,10 +71,10 @@ bool RtpToNtpMs(int64_t rtp_timestamp,
const synchronization::RtcpList& rtcp,
int64_t* rtp_timestamp_in_ms) {
assert(rtcp.size() == 2);
- int64_t rtcp_ntp_ms_new = Clock::NtpToMs(rtcp.front().ntp_secs,
- rtcp.front().ntp_frac);
- int64_t rtcp_ntp_ms_old = Clock::NtpToMs(rtcp.back().ntp_secs,
- rtcp.back().ntp_frac);
+ int64_t rtcp_ntp_ms_new = synchronization::NtpToMs(rtcp.front().ntp_secs,
+ rtcp.front().ntp_frac);
+ int64_t rtcp_ntp_ms_old = synchronization::NtpToMs(rtcp.back().ntp_secs,
+ rtcp.back().ntp_frac);
int64_t rtcp_timestamp_new = rtcp.front().rtp_timestamp;
int64_t rtcp_timestamp_old = rtcp.back().rtp_timestamp;
if (!CompensateForWrapAround(rtcp_timestamp_new,
diff --git a/modules/rtp_rtcp/interface/rtp_rtcp.h b/modules/rtp_rtcp/interface/rtp_rtcp.h
index 779f0d53..38552048 100644
--- a/modules/rtp_rtcp/interface/rtp_rtcp.h
+++ b/modules/rtp_rtcp/interface/rtp_rtcp.h
@@ -880,6 +880,13 @@ class RtpRtcp : public Module {
***************************************************************************/
/*
+ * Set the estimated camera delay in MS
+ *
+ * return -1 on failure else 0
+ */
+ virtual int32_t SetCameraDelay(const int32_t delayMS) = 0;
+
+ /*
* Set the target send bitrate
*/
virtual void SetTargetSendBitrate(const uint32_t bitrate) = 0;
diff --git a/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h b/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h
index 8ee4c560..76cc3168 100644
--- a/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h
+++ b/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h
@@ -265,6 +265,8 @@ class MockRtpRtcp : public RtpRtcp {
int32_t(bool& enable, uint8_t& ID));
MOCK_METHOD1(SetAudioLevel,
int32_t(const uint8_t level_dBov));
+ MOCK_METHOD1(SetCameraDelay,
+ int32_t(const int32_t delayMS));
MOCK_METHOD1(SetTargetSendBitrate,
void(const uint32_t bitrate));
MOCK_METHOD3(SetGenericFECStatus,
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index ddd8e337..d6bf0927 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -512,8 +512,8 @@ RTCPReceiver::HandleReportBlock(const RTCPUtility::RTCPPacket& rtcpPacket,
_clock->CurrentNtp(lastReceivedRRNTPsecs, lastReceivedRRNTPfrac);
// time when we received this in MS
- uint32_t receiveTimeMS = Clock::NtpToMs(lastReceivedRRNTPsecs,
- lastReceivedRRNTPfrac);
+ uint32_t receiveTimeMS = ModuleRTPUtility::ConvertNTPTimeToMS(
+ lastReceivedRRNTPsecs, lastReceivedRRNTPfrac);
// Estimate RTT
uint32_t d = (delaySinceLastSendReport & 0x0000ffff) * 1000;
diff --git a/modules/rtp_rtcp/source/rtcp_sender.cc b/modules/rtp_rtcp/source/rtcp_sender.cc
index c333186b..ef97f85a 100644
--- a/modules/rtp_rtcp/source/rtcp_sender.cc
+++ b/modules/rtp_rtcp/source/rtcp_sender.cc
@@ -91,6 +91,8 @@ RTCPSender::RTCPSender(const int32_t id,
_reportBlocks(),
_csrcCNAMEs(),
+ _cameraDelayMS(0),
+
_lastSendReport(),
_lastRTCPTime(),
@@ -168,6 +170,7 @@ RTCPSender::Init()
start_timestamp_ = -1;
_SSRC = 0;
_remoteSSRC = 0;
+ _cameraDelayMS = 0;
_sequenceNumberFIR = 0;
_tmmbr_Send = 0;
_packetOH_Send = 0;
@@ -348,7 +351,7 @@ void RTCPSender::SetLastRtpTime(uint32_t rtp_timestamp,
last_rtp_timestamp_ = rtp_timestamp;
if (capture_time_ms < 0) {
// We don't currently get a capture time from VoiceEngine.
- last_frame_capture_time_ms_ = _clock->CurrentNtpInMilliseconds();
+ last_frame_capture_time_ms_ = _clock->TimeInMilliseconds();
} else {
last_frame_capture_time_ms_ = capture_time_ms;
}
@@ -377,6 +380,19 @@ RTCPSender::SetRemoteSSRC( const uint32_t ssrc)
return 0;
}
+int32_t
+RTCPSender::SetCameraDelay(const int32_t delayMS)
+{
+ CriticalSectionScoped lock(_criticalSectionRTCPSender);
+ if(delayMS > 1000 || delayMS < -1000)
+ {
+ WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument, delay can't be larger than 1 sec", __FUNCTION__);
+ return -1;
+ }
+ _cameraDelayMS = delayMS;
+ return 0;
+}
+
int32_t RTCPSender::CNAME(char cName[RTCP_CNAME_SIZE]) {
assert(cName);
CriticalSectionScoped lock(_criticalSectionRTCPSender);
@@ -609,13 +625,25 @@ RTCPSender::BuildSR(uint8_t* rtcpbuffer,
_lastRTCPTime[i+1] =_lastRTCPTime[i];
}
- _lastRTCPTime[0] = Clock::NtpToMs(NTPsec, NTPfrac);
+ _lastRTCPTime[0] = ModuleRTPUtility::ConvertNTPTimeToMS(NTPsec, NTPfrac);
_lastSendReport[0] = (NTPsec << 16) + (NTPfrac >> 16);
- if (!RtpTimestampNow(NTPsec, NTPfrac, &RTPtime)) {
- RTPtime = 0;
+ uint32_t freqHz = 90000; // For video
+ if(_audio) {
+ freqHz = _rtpRtcp.CurrentSendFrequencyHz();
}
+ // The timestamp of this RTCP packet should be estimated as the timestamp of
+ // the frame being captured at this moment. We are calculating that
+ // timestamp as the last frame's timestamp + the time since the last frame
+ // was captured.
+ {
+ // Needs protection since this method is called on the process thread.
+ CriticalSectionScoped lock(_criticalSectionRTCPSender);
+ RTPtime = start_timestamp_ + last_rtp_timestamp_ + (
+ _clock->TimeInMilliseconds() - last_frame_capture_time_ms_) *
+ (freqHz / 1000);
+ }
// Add sender data
// Save for our length field
@@ -655,24 +683,6 @@ RTCPSender::BuildSR(uint8_t* rtcpbuffer,
return 0;
}
-bool RTCPSender::RtpTimestampNow(uint32_t ntp_secs_now, uint32_t ntp_fracs_now,
- uint32_t* timestamp_now) const {
- if (last_frame_capture_time_ms_ < 0) {
- return false;
- }
- uint32_t freq_khz = 90; // Default for video.
- if(_audio) {
- freq_khz = _rtpRtcp.CurrentSendFrequencyHz() / 1000;
- }
- // The timestamp of this RTCP packet should be estimated as the timestamp of
- // the frame being captured at this moment. We are calculating that
- // timestamp as the last frame's timestamp + the time since the last frame
- // was captured.
- *timestamp_now = start_timestamp_ + last_rtp_timestamp_ +
- (Clock::NtpToMs(ntp_secs_now, ntp_fracs_now) -
- last_frame_capture_time_ms_) * freq_khz;
- return true;
-}
int32_t RTCPSender::BuildSDEC(uint8_t* rtcpbuffer,
uint32_t& pos) {
@@ -2081,7 +2091,7 @@ int32_t RTCPSender::AddReportBlocks(uint8_t* rtcpbuffer,
}
if (received) {
// answer to the one that sends to me
- _lastRTCPTime[0] = Clock::NtpToMs(NTPsec, NTPfrac);
+ _lastRTCPTime[0] = ModuleRTPUtility::ConvertNTPTimeToMS(NTPsec, NTPfrac);
// Remote SSRC
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, _remoteSSRC);
diff --git a/modules/rtp_rtcp/source/rtcp_sender.h b/modules/rtp_rtcp/source/rtcp_sender.h
index 5a0c58fd..014b975d 100644
--- a/modules/rtp_rtcp/source/rtcp_sender.h
+++ b/modules/rtp_rtcp/source/rtcp_sender.h
@@ -72,6 +72,8 @@ public:
int32_t SetRemoteSSRC( const uint32_t ssrc);
+ int32_t SetCameraDelay(const int32_t delayMS);
+
int32_t CNAME(char cName[RTCP_CNAME_SIZE]);
int32_t SetCNAME(const char cName[RTCP_CNAME_SIZE]);
@@ -195,9 +197,6 @@ private:
const uint16_t* nackList,
std::string* nackString);
- bool RtpTimestampNow(uint32_t ntp_secs_now, uint32_t ntp_fracs_now,
- uint32_t* timestamp_now) const;
-
private:
int32_t _id;
const bool _audio;
@@ -230,6 +229,8 @@ private:
std::map<uint32_t, RTCPReportBlock*> _reportBlocks;
std::map<uint32_t, RTCPUtility::RTCPCnameInformation*> _csrcCNAMEs;
+ int32_t _cameraDelayMS;
+
// Sent
uint32_t _lastSendReport[RTCP_NUMBER_OF_SR]; // allow packet loss and RTT above 1 sec
uint32_t _lastRTCPTime[RTCP_NUMBER_OF_SR];
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index bc08bc99..1597ab2c 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -1811,6 +1811,30 @@ int32_t ModuleRtpRtcpImpl::SendRTCPSliceLossIndication(
return rtcp_sender_.SendRTCP(kRtcpSli, 0, 0, false, picture_id);
}
+int32_t ModuleRtpRtcpImpl::SetCameraDelay(const int32_t delay_ms) {
+ WEBRTC_TRACE(kTraceModuleCall,
+ kTraceRtpRtcp,
+ id_,
+ "SetCameraDelay(%d)",
+ delay_ms);
+ const bool default_instance(child_modules_.empty() ? false : true);
+
+ if (default_instance) {
+ CriticalSectionScoped lock(critical_section_module_ptrs_.get());
+
+ std::list<ModuleRtpRtcpImpl*>::iterator it = child_modules_.begin();
+ while (it != child_modules_.end()) {
+ RtpRtcp* module = *it;
+ if (module) {
+ module->SetCameraDelay(delay_ms);
+ }
+ it++;
+ }
+ return 0;
+ }
+ return rtcp_sender_.SetCameraDelay(delay_ms);
+}
+
int32_t ModuleRtpRtcpImpl::SetGenericFECStatus(
const bool enable,
const uint8_t payload_type_red,
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
index ef6ac839..3d0be8be 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
@@ -390,6 +390,8 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
// Send a request for a keyframe.
virtual int32_t RequestKeyFrame();
+ virtual int32_t SetCameraDelay(const int32_t delay_ms);
+
virtual void SetTargetSendBitrate(const uint32_t bitrate);
virtual int32_t SetGenericFECStatus(
diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc
index be358ba7..9c5cfe02 100644
--- a/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/modules/rtp_rtcp/source/rtp_sender.cc
@@ -609,7 +609,7 @@ void RTPSender::TimeToSendPacket(uint16_t sequence_number,
WebRtcRTPHeader rtp_header;
rtp_parser.Parse(rtp_header);
- int64_t diff_ms = clock_->CurrentNtpInMilliseconds() - capture_time_ms;
+ int64_t diff_ms = clock_->TimeInMilliseconds() - capture_time_ms;
if (UpdateTransmissionTimeOffset(data_buffer, length, rtp_header, diff_ms)) {
// Update stored packet in case of receiving a re-transmission request.
packet_history_->ReplaceRTPHeader(data_buffer,
@@ -645,9 +645,9 @@ int32_t RTPSender::SendToNetwork(
// TODO(holmer): This should be changed all over Video Engine so that negative
// time is consider invalid, while 0 is considered a valid time.
if (capture_time_ms > 0) {
- int64_t diff_ms = clock_->CurrentNtpInMilliseconds() - capture_time_ms;
+ int64_t time_now = clock_->TimeInMilliseconds();
UpdateTransmissionTimeOffset(buffer, payload_length + rtp_header_length,
- rtp_header, diff_ms);
+ rtp_header, time_now - capture_time_ms);
}
// Used for NACK and to spread out the transmission of packets.
if (packet_history_->PutRTPPacket(buffer, rtp_header_length + payload_length,
diff --git a/modules/rtp_rtcp/source/rtp_utility.cc b/modules/rtp_rtcp/source/rtp_utility.cc
index 3d31f681..c9af76ca 100644
--- a/modules/rtp_rtcp/source/rtp_utility.cc
+++ b/modules/rtp_rtcp/source/rtp_utility.cc
@@ -74,6 +74,14 @@ uint32_t ConvertNTPTimeToRTP(uint32_t NTPsec, uint32_t NTPfrac, uint32_t freq) {
return NTPsec * freq + tmp;
}
+uint32_t ConvertNTPTimeToMS(uint32_t NTPsec, uint32_t NTPfrac) {
+ int freq = 1000;
+ float ftemp = (float)NTPfrac / (float)NTP_FRAC;
+ uint32_t tmp = (uint32_t)(ftemp * freq);
+ uint32_t MStime = NTPsec * freq + tmp;
+ return MStime;
+}
+
bool OldTimestamp(uint32_t newTimestamp,
uint32_t existingTimestamp,
bool* wrapped) {
diff --git a/modules/rtp_rtcp/source/rtp_utility.h b/modules/rtp_rtcp/source/rtp_utility.h
index 6c6e9b85..7614ca66 100644
--- a/modules/rtp_rtcp/source/rtp_utility.h
+++ b/modules/rtp_rtcp/source/rtp_utility.h
@@ -70,6 +70,11 @@ namespace ModuleRTPUtility
uint32_t NTPfrac,
uint32_t freq);
+ // Return the time in milliseconds corresponding to the specified
+ // NTP timestamp.
+ uint32_t ConvertNTPTimeToMS(uint32_t NTPsec,
+ uint32_t NTPfrac);
+
uint32_t pow2(uint8_t exp);
// Returns a pointer to the payload data given a packet.
diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc
index 3dd57cf5..49762376 100644
--- a/modules/video_capture/video_capture_impl.cc
+++ b/modules/video_capture/video_capture_impl.cc
@@ -10,7 +10,6 @@
#include "video_capture_impl.h"
-#include "clock.h"
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "critical_section_wrapper.h"
#include "module_common_types.h"
@@ -197,8 +196,7 @@ WebRtc_Word32 VideoCaptureImpl::DeliverCapturedFrame(I420VideoFrame&
captureFrame.set_render_time_ms(capture_time);
}
else {
- captureFrame.set_render_time_ms(
- Clock::GetRealTimeClock()->CurrentNtpInMilliseconds());
+ captureFrame.set_render_time_ms(TickTime::MillisecondTimestamp());
}
if (captureFrame.render_time_ms() == last_capture_time_) {
diff --git a/system_wrappers/interface/clock.h b/system_wrappers/interface/clock.h
index 177e18fe..7a946d90 100644
--- a/system_wrappers/interface/clock.h
+++ b/system_wrappers/interface/clock.h
@@ -34,15 +34,9 @@ class Clock {
// source is fixed for this clock.
virtual int64_t TimeInMicroseconds() = 0;
- // Retrieve an NTP absolute timestamp in seconds and fractions of a second.
+ // Retrieve an NTP absolute timestamp.
virtual void CurrentNtp(uint32_t& seconds, uint32_t& fractions) = 0;
- // Retrieve an NTP absolute timestamp in milliseconds.
- virtual int64_t CurrentNtpInMilliseconds() = 0;
-
- // Converts an NTP timestamp to a millisecond timestamp.
- static int64_t NtpToMs(uint32_t seconds, uint32_t fractions);
-
// Returns an instance of the real-time system clock implementation.
static Clock* GetRealTimeClock();
};
@@ -61,12 +55,9 @@ class SimulatedClock : public Clock {
// source is fixed for this clock.
virtual int64_t TimeInMicroseconds();
- // Retrieve an NTP absolute timestamp in milliseconds.
+ // Retrieve an NTP absolute timestamp.
virtual void CurrentNtp(uint32_t& seconds, uint32_t& fractions);
- // Converts an NTP timestamp to a millisecond timestamp.
- virtual int64_t CurrentNtpInMilliseconds();
-
// Advance the simulated clock with a given number of milliseconds or
// microseconds.
void AdvanceTimeMilliseconds(int64_t milliseconds);
diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc
index 9b017b82..8085e56d 100644
--- a/system_wrappers/source/clock.cc
+++ b/system_wrappers/source/clock.cc
@@ -23,14 +23,6 @@
namespace webrtc {
-const double kNtpFracPerMs = 4.294967296E6;
-
-int64_t Clock::NtpToMs(uint32_t ntp_secs, uint32_t ntp_frac) {
- const double ntp_frac_ms = static_cast<double>(ntp_frac) / kNtpFracPerMs;
- return 1000 * static_cast<int64_t>(ntp_secs) +
- static_cast<int64_t>(ntp_frac_ms + 0.5);
-}
-
#if defined(_WIN32)
struct reference_point {
@@ -136,42 +128,6 @@ class RealTimeClock : public Clock {
virtual int64_t TimeInMicroseconds() {
return TickTime::MicrosecondTimestamp();
}
-
- // Retrieve an NTP absolute timestamp in seconds and fractions of a second.
- virtual void CurrentNtp(uint32_t& seconds, uint32_t& fractions) {
- timeval tv = CurrentTimeVal();
- double microseconds_in_seconds;
- Adjust(tv, &seconds, &microseconds_in_seconds);
- fractions = static_cast<uint32_t>(
- microseconds_in_seconds * kMagicNtpFractionalUnit + 0.5);
- }
-
- // Retrieve an NTP absolute timestamp in milliseconds.
- virtual int64_t CurrentNtpInMilliseconds() {
- timeval tv = CurrentTimeVal();
- uint32_t seconds;
- double microseconds_in_seconds;
- Adjust(tv, &seconds, &microseconds_in_seconds);
- return 1000 * static_cast<int64_t>(seconds) +
- static_cast<int64_t>(1000.0 * microseconds_in_seconds + 0.5);
- }
-
- protected:
- virtual timeval CurrentTimeVal() const = 0;
-
- static void Adjust(const timeval& tv, uint32_t* adjusted_s,
- double* adjusted_us_in_s) {
- *adjusted_s = tv.tv_sec + kNtpJan1970;
- *adjusted_us_in_s = tv.tv_usec / 1e6;
-
- if (*adjusted_us_in_s >= 1) {
- *adjusted_us_in_s -= 1;
- ++*adjusted_s;
- } else if (*adjusted_us_in_s < -1) {
- *adjusted_us_in_s += 1;
- --*adjusted_s;
- }
- }
};
#if defined(_WIN32)
@@ -182,8 +138,8 @@ class WindowsRealTimeClock : public RealTimeClock {
virtual ~WindowsRealTimeClock() {}
- protected:
- timeval CurrentTimeVal() const {
+ // Retrieve an NTP absolute timestamp.
+ virtual void CurrentNtp(uint32_t& seconds, uint32_t& fractions) {
const uint64_t FILETIME_1970 = 0x019db1ded53e8000;
FILETIME StartTime;
@@ -191,20 +147,35 @@ class WindowsRealTimeClock : public RealTimeClock {
struct timeval tv;
// We can't use query performance counter since they can change depending on
- // speed stepping.
+ // speed steping
get_time(_helpTimer, StartTime);
Time = (((uint64_t) StartTime.dwHighDateTime) << 32) +
(uint64_t) StartTime.dwLowDateTime;
- // Convert the hecto-nano second time to tv format.
+ // Convert the hecto-nano second time to tv format
Time -= FILETIME_1970;
tv.tv_sec = (uint32_t)(Time / (uint64_t)10000000);
tv.tv_usec = (uint32_t)((Time % (uint64_t)10000000) / 10);
- return tv;
+
+ double dtemp;
+
+ seconds = tv.tv_sec + kNtpJan1970;
+ dtemp = tv.tv_usec / 1e6;
+
+ if (dtemp >= 1) {
+ dtemp -= 1;
+ seconds++;
+ } else if (dtemp < -1) {
+ dtemp += 1;
+ seconds--;
+ }
+ dtemp *= kMagicNtpFractionalUnit;
+ fractions = (uint32_t)dtemp;
}
+ private:
WindowsHelpTimer* _helpTimer;
};
@@ -215,14 +186,26 @@ class UnixRealTimeClock : public RealTimeClock {
virtual ~UnixRealTimeClock() {}
- protected:
- timeval CurrentTimeVal() const {
+ // Retrieve an NTP absolute timestamp.
+ virtual void CurrentNtp(uint32_t& seconds, uint32_t& fractions) {
+ double dtemp;
struct timeval tv;
struct timezone tz;
- tz.tz_minuteswest = 0;
+ tz.tz_minuteswest = 0;
tz.tz_dsttime = 0;
gettimeofday(&tv, &tz);
- return tv;
+
+ seconds = tv.tv_sec + kNtpJan1970;
+ dtemp = tv.tv_usec / 1e6;
+ if (dtemp >= 1) {
+ dtemp -= 1;
+ seconds++;
+ } else if (dtemp < -1) {
+ dtemp += 1;
+ seconds--;
+ }
+ dtemp *= kMagicNtpFractionalUnit;
+ fractions = (uint32_t)dtemp;
}
};
#endif
@@ -264,10 +247,6 @@ void SimulatedClock::CurrentNtp(uint32_t& seconds, uint32_t& fractions) {
kMagicNtpFractionalUnit / 1000);
}
-int64_t SimulatedClock::CurrentNtpInMilliseconds() {
- return TimeInMilliseconds() + 1000 * static_cast<int64_t>(kNtpJan1970);
-}
-
void SimulatedClock::AdvanceTimeMilliseconds(int64_t milliseconds) {
AdvanceTimeMicroseconds(1000 * milliseconds);
}
diff --git a/system_wrappers/source/clock_unittest.cc b/system_wrappers/source/clock_unittest.cc
deleted file mode 100644
index 67d699e5..00000000
--- a/system_wrappers/source/clock_unittest.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "webrtc/system_wrappers/interface/clock.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace webrtc {
-
-TEST(ClockTest, NtpTime) {
- Clock* clock = Clock::GetRealTimeClock();
- uint32_t seconds;
- uint32_t fractions;
- clock->CurrentNtp(seconds, fractions);
- int64_t milliseconds = clock->CurrentNtpInMilliseconds();
- EXPECT_GE(milliseconds, Clock::NtpToMs(seconds, fractions));
- EXPECT_NEAR(milliseconds, Clock::NtpToMs(seconds, fractions), 5);
-}
-} // namespace webrtc
diff --git a/system_wrappers/source/system_wrappers_tests.gyp b/system_wrappers/source/system_wrappers_tests.gyp
index f036731a..fd1db254 100644
--- a/system_wrappers/source/system_wrappers_tests.gyp
+++ b/system_wrappers/source/system_wrappers_tests.gyp
@@ -19,7 +19,6 @@
],
'sources': [
'aligned_malloc_unittest.cc',
- 'clock_unittest.cc',
'condition_variable_unittest.cc',
'critical_section_unittest.cc',
'event_tracer_unittest.cc',
diff --git a/video_engine/vie_encoder.cc b/video_engine/vie_encoder.cc
index 3f672bae..c647d7a8 100644
--- a/video_engine/vie_encoder.cc
+++ b/video_engine/vie_encoder.cc
@@ -608,6 +608,7 @@ void ViEEncoder::DelayChanged(int id, int frame_delay) {
ViEId(engine_id_, channel_id_), "%s: %u", __FUNCTION__,
frame_delay);
+ default_rtp_rtcp_->SetCameraDelay(frame_delay);
file_recorder_.SetFrameDelay(frame_delay);
}