Move timestamp_extrapolator and rtp_to_ntp to system wrapper so that it can be shared by both audio and video engine.

BUG=3111
TEST=try bots
R=mflodman@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/13459004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6074 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
wu@webrtc.org 2014-05-07 17:09:44 +00:00
parent 25a344edc6
commit 66773a032a
21 changed files with 102 additions and 128 deletions

View File

@ -180,7 +180,6 @@
'remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc',
'remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h',
'remote_bitrate_estimator/remote_bitrate_estimators_test.cc',
'remote_bitrate_estimator/rtp_to_ntp_unittest.cc',
'remote_bitrate_estimator/test/bwe_test_baselinefile.cc',
'remote_bitrate_estimator/test/bwe_test_baselinefile.h',
'remote_bitrate_estimator/test/bwe_test_fileutils.cc',

View File

@ -21,10 +21,8 @@
'sources': [
'include/bwe_defines.h',
'include/remote_bitrate_estimator.h',
'include/rtp_to_ntp.h',
'rate_statistics.cc',
'rate_statistics.h',
'rtp_to_ntp.cc',
], # source
},
{

View File

@ -37,7 +37,6 @@ LOCAL_SRC_FILES := \
receiver.cc \
rtt_filter.cc \
session_info.cc \
timestamp_extrapolator.cc \
timestamp_map.cc \
timing.cc \
video_coding_impl.cc
@ -56,7 +55,7 @@ LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../../../../common_video/vplib/main/interface \
$(LOCAL_PATH)/../../../../common_video/interface \
$(LOCAL_PATH)/../../utility/include \
$(LOCAL_PATH)/../../../../system_wrappers/interface
$(LOCAL_PATH)/../../../../system_wrappers/interface
LOCAL_SHARED_LIBRARIES := \
libcutils \

View File

@ -10,12 +10,10 @@
#include "webrtc/modules/video_coding/main/source/timing.h"
#include "webrtc/modules/video_coding/main/source/internal_defines.h"
#include "webrtc/modules/video_coding/main/source/jitter_buffer_common.h"
#include "webrtc/modules/video_coding/main/source/timestamp_extrapolator.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/timestamp_extrapolator.h"
namespace webrtc {
@ -35,8 +33,7 @@ VCMTiming::VCMTiming(Clock* clock,
prev_frame_timestamp_(0) {
if (master_timing == NULL) {
master_ = true;
ts_extrapolator_ =
new VCMTimestampExtrapolator(clock_->TimeInMilliseconds());
ts_extrapolator_ = new TimestampExtrapolator(clock_->TimeInMilliseconds());
} else {
ts_extrapolator_ = master_timing->ts_extrapolator_;
}

View File

@ -18,7 +18,7 @@
namespace webrtc {
class Clock;
class VCMTimestampExtrapolator;
class TimestampExtrapolator;
class VCMTiming {
public:
@ -101,7 +101,7 @@ class VCMTiming {
CriticalSectionWrapper* crit_sect_;
Clock* clock_;
bool master_;
VCMTimestampExtrapolator* ts_extrapolator_;
TimestampExtrapolator* ts_extrapolator_;
VCMCodecTimer codec_timer_;
uint32_t render_delay_ms_;
uint32_t min_playout_delay_ms_;

View File

@ -48,7 +48,6 @@
'receiver.h',
'rtt_filter.h',
'session_info.h',
'timestamp_extrapolator.h',
'timestamp_map.h',
'timing.h',
'video_coding_impl.h',
@ -72,7 +71,6 @@
'receiver.cc',
'rtt_filter.cc',
'session_info.cc',
'timestamp_extrapolator.cc',
'timestamp_map.cc',
'timing.cc',
'video_coding_impl.cc',

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_RTP_TO_NTP_H_
#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_RTP_TO_NTP_H_
#ifndef SYSTEM_WRAPPERS_INTERFACE_RTP_TO_NTP_H_
#define SYSTEM_WRAPPERS_INTERFACE_RTP_TO_NTP_H_
#include <list>
@ -17,8 +17,6 @@
namespace webrtc {
namespace synchronization {
struct RtcpMeasurement {
RtcpMeasurement();
RtcpMeasurement(uint32_t ntp_secs, uint32_t ntp_frac, uint32_t timestamp);
@ -46,7 +44,7 @@ bool RtpToNtpMs(int64_t rtp_timestamp, const RtcpList& rtcp,
// Returns 1 there has been a forward wrap around, 0 if there has been no wrap
// around and -1 if there has been a backwards wrap around (i.e. reordering).
int CheckForWrapArounds(uint32_t rtp_timestamp, uint32_t rtcp_rtp_timestamp);
} // namespace synchronization
} // namespace webrtc
#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_RTP_TO_NTP_H_
#endif // SYSTEM_WRAPPERS_INTERFACE_RTP_TO_NTP_H_

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_EXTRAPOLATOR_H_
#define WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_EXTRAPOLATOR_H_
#ifndef SYSTEM_WRAPPERS_INTERFACE_TIMESTAMP_EXTRAPOLATOR_H_
#define SYSTEM_WRAPPERS_INTERFACE_TIMESTAMP_EXTRAPOLATOR_H_
#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
#include "webrtc/typedefs.h"
@ -17,11 +17,11 @@
namespace webrtc
{
class VCMTimestampExtrapolator
class TimestampExtrapolator
{
public:
explicit VCMTimestampExtrapolator(int64_t start_ms);
~VCMTimestampExtrapolator();
explicit TimestampExtrapolator(int64_t start_ms);
~TimestampExtrapolator();
void Update(int64_t tMs, uint32_t ts90khz);
int64_t ExtrapolateLocalTime(uint32_t timestamp90khz);
void Reset(int64_t start_ms);
@ -53,4 +53,4 @@ private:
} // namespace webrtc
#endif // WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_EXTRAPOLATOR_H_
#endif // SYSTEM_WRAPPERS_INTERFACE_TIMESTAMP_EXTRAPOLATOR_H_

View File

@ -35,11 +35,13 @@ LOCAL_SRC_FILES := \
condition_variable_posix.cc \
critical_section_posix.cc \
event_posix.cc \
rtp_to_ntp.cc \
sleep.cc \
thread_posix.cc \
tick_util.cc \
timestamp_extrapolator.cc \
trace_posix.cc \
rw_lock_posix.cc
rw_lock_posix.cc
LOCAL_CFLAGS := \
$(MY_WEBRTC_COMMON_DEFS)

View File

@ -8,7 +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/rtp_to_ntp.h"
#include "webrtc/system_wrappers/interface/clock.h"
@ -16,8 +16,6 @@
namespace webrtc {
namespace synchronization {
RtcpMeasurement::RtcpMeasurement()
: ntp_secs(0), ntp_frac(0), rtp_timestamp(0) {}
@ -47,8 +45,7 @@ bool CompensateForWrapAround(uint32_t new_timestamp,
uint32_t old_timestamp,
int64_t* compensated_timestamp) {
assert(compensated_timestamp);
int64_t wraps = synchronization::CheckForWrapArounds(new_timestamp,
old_timestamp);
int64_t wraps = CheckForWrapArounds(new_timestamp, old_timestamp);
if (wraps < 0) {
// Reordering, don't use this packet.
return false;
@ -96,7 +93,7 @@ bool UpdateRtcpList(uint32_t ntp_secs,
// |rtp_timestamp_in_ms|. This function compensates for wrap arounds in RTP
// timestamps and returns false if it can't do the conversion due to reordering.
bool RtpToNtpMs(int64_t rtp_timestamp,
const synchronization::RtcpList& rtcp,
const RtcpList& rtcp,
int64_t* rtp_timestamp_in_ms) {
assert(rtcp.size() == 2);
int64_t rtcp_ntp_ms_new = Clock::NtpToMs(rtcp.front().ntp_secs,
@ -149,5 +146,5 @@ int CheckForWrapArounds(uint32_t new_timestamp, uint32_t old_timestamp) {
}
return 0;
}
} // namespace synchronization
} // namespace webrtc

View File

@ -9,67 +9,62 @@
*/
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/modules/remote_bitrate_estimator/include/rtp_to_ntp.h"
#include "webrtc/system_wrappers/interface/rtp_to_ntp.h"
namespace webrtc {
TEST(WrapAroundTests, NoWrap) {
EXPECT_EQ(0, synchronization::CheckForWrapArounds(0xFFFFFFFF, 0xFFFFFFFE));
EXPECT_EQ(0, synchronization::CheckForWrapArounds(1, 0));
EXPECT_EQ(0, synchronization::CheckForWrapArounds(0x00010000, 0x0000FFFF));
EXPECT_EQ(0, CheckForWrapArounds(0xFFFFFFFF, 0xFFFFFFFE));
EXPECT_EQ(0, CheckForWrapArounds(1, 0));
EXPECT_EQ(0, CheckForWrapArounds(0x00010000, 0x0000FFFF));
}
TEST(WrapAroundTests, ForwardWrap) {
EXPECT_EQ(1, synchronization::CheckForWrapArounds(0, 0xFFFFFFFF));
EXPECT_EQ(1, synchronization::CheckForWrapArounds(0, 0xFFFF0000));
EXPECT_EQ(1, synchronization::CheckForWrapArounds(0x0000FFFF, 0xFFFFFFFF));
EXPECT_EQ(1, synchronization::CheckForWrapArounds(0x0000FFFF, 0xFFFF0000));
EXPECT_EQ(1, CheckForWrapArounds(0, 0xFFFFFFFF));
EXPECT_EQ(1, CheckForWrapArounds(0, 0xFFFF0000));
EXPECT_EQ(1, CheckForWrapArounds(0x0000FFFF, 0xFFFFFFFF));
EXPECT_EQ(1, CheckForWrapArounds(0x0000FFFF, 0xFFFF0000));
}
TEST(WrapAroundTests, BackwardWrap) {
EXPECT_EQ(-1, synchronization::CheckForWrapArounds(0xFFFFFFFF, 0));
EXPECT_EQ(-1, synchronization::CheckForWrapArounds(0xFFFF0000, 0));
EXPECT_EQ(-1, synchronization::CheckForWrapArounds(0xFFFFFFFF, 0x0000FFFF));
EXPECT_EQ(-1, synchronization::CheckForWrapArounds(0xFFFF0000, 0x0000FFFF));
EXPECT_EQ(-1, CheckForWrapArounds(0xFFFFFFFF, 0));
EXPECT_EQ(-1, CheckForWrapArounds(0xFFFF0000, 0));
EXPECT_EQ(-1, CheckForWrapArounds(0xFFFFFFFF, 0x0000FFFF));
EXPECT_EQ(-1, CheckForWrapArounds(0xFFFF0000, 0x0000FFFF));
}
TEST(WrapAroundTests, OldRtcpWrapped) {
synchronization::RtcpList rtcp;
RtcpList rtcp;
uint32_t ntp_sec = 0;
uint32_t ntp_frac = 0;
uint32_t timestamp = 0;
const uint32_t kOneMsInNtpFrac = 4294967;
const uint32_t kTimestampTicksPerMs = 90;
rtcp.push_front(synchronization::RtcpMeasurement(ntp_sec, ntp_frac,
timestamp));
rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp));
ntp_frac += kOneMsInNtpFrac;
timestamp -= kTimestampTicksPerMs;
rtcp.push_front(synchronization::RtcpMeasurement(ntp_sec, ntp_frac,
timestamp));
rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp));
ntp_frac += kOneMsInNtpFrac;
timestamp -= kTimestampTicksPerMs;
int64_t timestamp_in_ms = -1;
// This expected to fail since it's highly unlikely that the older RTCP
// has a much smaller RTP timestamp than the newer.
EXPECT_FALSE(synchronization::RtpToNtpMs(timestamp, rtcp, &timestamp_in_ms));
EXPECT_FALSE(RtpToNtpMs(timestamp, rtcp, &timestamp_in_ms));
}
TEST(WrapAroundTests, NewRtcpWrapped) {
synchronization::RtcpList rtcp;
RtcpList rtcp;
uint32_t ntp_sec = 0;
uint32_t ntp_frac = 0;
uint32_t timestamp = 0xFFFFFFFF;
const uint32_t kOneMsInNtpFrac = 4294967;
const uint32_t kTimestampTicksPerMs = 90;
rtcp.push_front(synchronization::RtcpMeasurement(ntp_sec, ntp_frac,
timestamp));
rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp));
ntp_frac += kOneMsInNtpFrac;
timestamp += kTimestampTicksPerMs;
rtcp.push_front(synchronization::RtcpMeasurement(ntp_sec, ntp_frac,
timestamp));
rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp));
int64_t timestamp_in_ms = -1;
EXPECT_TRUE(synchronization::RtpToNtpMs(rtcp.back().rtp_timestamp, rtcp,
&timestamp_in_ms));
EXPECT_TRUE(RtpToNtpMs(rtcp.back().rtp_timestamp, rtcp, &timestamp_in_ms));
// Since this RTP packet has the same timestamp as the RTCP packet constructed
// at time 0 it should be mapped to 0 as well.
EXPECT_EQ(0, timestamp_in_ms);
@ -78,21 +73,18 @@ TEST(WrapAroundTests, NewRtcpWrapped) {
TEST(WrapAroundTests, RtpWrapped) {
const uint32_t kOneMsInNtpFrac = 4294967;
const uint32_t kTimestampTicksPerMs = 90;
synchronization::RtcpList rtcp;
RtcpList rtcp;
uint32_t ntp_sec = 0;
uint32_t ntp_frac = 0;
uint32_t timestamp = 0xFFFFFFFF - 2 * kTimestampTicksPerMs;
rtcp.push_front(synchronization::RtcpMeasurement(ntp_sec, ntp_frac,
timestamp));
rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp));
ntp_frac += kOneMsInNtpFrac;
timestamp += kTimestampTicksPerMs;
rtcp.push_front(synchronization::RtcpMeasurement(ntp_sec, ntp_frac,
timestamp));
rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp));
ntp_frac += kOneMsInNtpFrac;
timestamp += kTimestampTicksPerMs;
int64_t timestamp_in_ms = -1;
EXPECT_TRUE(synchronization::RtpToNtpMs(timestamp, rtcp,
&timestamp_in_ms));
EXPECT_TRUE(RtpToNtpMs(timestamp, rtcp, &timestamp_in_ms));
// Since this RTP packet has the same timestamp as the RTCP packet constructed
// at time 0 it should be mapped to 0 as well.
EXPECT_EQ(2, timestamp_in_ms);
@ -101,41 +93,35 @@ TEST(WrapAroundTests, RtpWrapped) {
TEST(WrapAroundTests, OldRtp_RtcpsWrapped) {
const uint32_t kOneMsInNtpFrac = 4294967;
const uint32_t kTimestampTicksPerMs = 90;
synchronization::RtcpList rtcp;
RtcpList rtcp;
uint32_t ntp_sec = 0;
uint32_t ntp_frac = 0;
uint32_t timestamp = 0;
rtcp.push_front(synchronization::RtcpMeasurement(ntp_sec, ntp_frac,
timestamp));
rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp));
ntp_frac += kOneMsInNtpFrac;
timestamp += kTimestampTicksPerMs;
rtcp.push_front(synchronization::RtcpMeasurement(ntp_sec, ntp_frac,
timestamp));
rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp));
ntp_frac += kOneMsInNtpFrac;
timestamp -= 2*kTimestampTicksPerMs;
int64_t timestamp_in_ms = -1;
EXPECT_FALSE(synchronization::RtpToNtpMs(timestamp, rtcp,
&timestamp_in_ms));
EXPECT_FALSE(RtpToNtpMs(timestamp, rtcp, &timestamp_in_ms));
}
TEST(WrapAroundTests, OldRtp_NewRtcpWrapped) {
const uint32_t kOneMsInNtpFrac = 4294967;
const uint32_t kTimestampTicksPerMs = 90;
synchronization::RtcpList rtcp;
RtcpList rtcp;
uint32_t ntp_sec = 0;
uint32_t ntp_frac = 0;
uint32_t timestamp = 0xFFFFFFFF;
rtcp.push_front(synchronization::RtcpMeasurement(ntp_sec, ntp_frac,
timestamp));
rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp));
ntp_frac += kOneMsInNtpFrac;
timestamp += kTimestampTicksPerMs;
rtcp.push_front(synchronization::RtcpMeasurement(ntp_sec, ntp_frac,
timestamp));
rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp));
ntp_frac += kOneMsInNtpFrac;
timestamp -= kTimestampTicksPerMs;
int64_t timestamp_in_ms = -1;
EXPECT_TRUE(synchronization::RtpToNtpMs(timestamp, rtcp,
&timestamp_in_ms));
EXPECT_TRUE(RtpToNtpMs(timestamp, rtcp, &timestamp_in_ms));
// Constructed at the same time as the first RTCP and should therefore be
// mapped to zero.
EXPECT_EQ(0, timestamp_in_ms);
@ -144,20 +130,17 @@ TEST(WrapAroundTests, OldRtp_NewRtcpWrapped) {
TEST(WrapAroundTests, OldRtp_OldRtcpWrapped) {
const uint32_t kOneMsInNtpFrac = 4294967;
const uint32_t kTimestampTicksPerMs = 90;
synchronization::RtcpList rtcp;
RtcpList rtcp;
uint32_t ntp_sec = 0;
uint32_t ntp_frac = 0;
uint32_t timestamp = 0;
rtcp.push_front(synchronization::RtcpMeasurement(ntp_sec, ntp_frac,
timestamp));
rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp));
ntp_frac += kOneMsInNtpFrac;
timestamp -= kTimestampTicksPerMs;
rtcp.push_front(synchronization::RtcpMeasurement(ntp_sec, ntp_frac,
timestamp));
rtcp.push_front(RtcpMeasurement(ntp_sec, ntp_frac, timestamp));
ntp_frac += kOneMsInNtpFrac;
timestamp += 2*kTimestampTicksPerMs;
int64_t timestamp_in_ms = -1;
EXPECT_FALSE(synchronization::RtpToNtpMs(timestamp, rtcp,
&timestamp_in_ms));
EXPECT_FALSE(RtpToNtpMs(timestamp, rtcp, &timestamp_in_ms));
}
}; // namespace webrtc

View File

@ -40,6 +40,7 @@
'../interface/logcat_trace_context.h',
'../interface/logging.h',
'../interface/ref_count.h',
'../interface/rtp_to_ntp.h',
'../interface/rw_lock_wrapper.h',
'../interface/scoped_ptr.h',
'../interface/scoped_refptr.h',
@ -52,6 +53,7 @@
'../interface/thread_annotations.h',
'../interface/thread_wrapper.h',
'../interface/tick_util.h',
'../interface/timestamp_extrapolator.h',
'../interface/trace.h',
'../interface/trace_event.h',
'../interface/utf_util_win.h',
@ -87,6 +89,7 @@
'file_impl.h',
'logcat_trace_context.cc',
'logging.cc',
'rtp_to_ntp.cc',
'rw_lock.cc',
'rw_lock_generic.cc',
'rw_lock_generic.h',
@ -103,6 +106,7 @@
'thread_posix.h',
'thread_win.cc',
'thread_win.h',
'timestamp_extrapolator.cc',
'trace_impl.cc',
'trace_impl.h',
'trace_posix.cc',

View File

@ -29,6 +29,7 @@
'data_log_helpers_unittest.cc',
'data_log_c_helpers_unittest.c',
'data_log_c_helpers_unittest.h',
'rtp_to_ntp_unittest.cc',
'scoped_vector_unittest.cc',
'stringize_macros_unittest.cc',
'stl_util_unittest.cc',

View File

@ -8,13 +8,13 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/modules/video_coding/main/source/timestamp_extrapolator.h"
#include "webrtc/system_wrappers/interface/timestamp_extrapolator.h"
#include <algorithm>
namespace webrtc {
VCMTimestampExtrapolator::VCMTimestampExtrapolator(int64_t start_ms)
TimestampExtrapolator::TimestampExtrapolator(int64_t start_ms)
: _rwLock(RWLockWrapper::CreateRWLock()),
_startMs(0),
_firstTimestamp(0),
@ -34,13 +34,12 @@ VCMTimestampExtrapolator::VCMTimestampExtrapolator(int64_t start_ms)
Reset(start_ms);
}
VCMTimestampExtrapolator::~VCMTimestampExtrapolator()
TimestampExtrapolator::~TimestampExtrapolator()
{
delete _rwLock;
}
void
VCMTimestampExtrapolator::Reset(int64_t start_ms)
void TimestampExtrapolator::Reset(int64_t start_ms)
{
WriteLockScoped wl(*_rwLock);
_startMs = start_ms;
@ -61,7 +60,7 @@ VCMTimestampExtrapolator::Reset(int64_t start_ms)
}
void
VCMTimestampExtrapolator::Update(int64_t tMs, uint32_t ts90khz)
TimestampExtrapolator::Update(int64_t tMs, uint32_t ts90khz)
{
_rwLock->AcquireLockExclusive();
@ -143,7 +142,7 @@ VCMTimestampExtrapolator::Update(int64_t tMs, uint32_t ts90khz)
}
int64_t
VCMTimestampExtrapolator::ExtrapolateLocalTime(uint32_t timestamp90khz)
TimestampExtrapolator::ExtrapolateLocalTime(uint32_t timestamp90khz)
{
ReadLockScoped rl(*_rwLock);
int64_t localTimeMs = 0;
@ -181,7 +180,7 @@ VCMTimestampExtrapolator::ExtrapolateLocalTime(uint32_t timestamp90khz)
// Investigates if the timestamp clock has overflowed since the last timestamp and
// keeps track of the number of wrap arounds since reset.
void
VCMTimestampExtrapolator::CheckForWrapArounds(uint32_t ts90khz)
TimestampExtrapolator::CheckForWrapArounds(uint32_t ts90khz)
{
if (_prevWrapTimestamp == -1)
{
@ -210,7 +209,7 @@ VCMTimestampExtrapolator::CheckForWrapArounds(uint32_t ts90khz)
}
bool
VCMTimestampExtrapolator::DelayChangeDetection(double error)
TimestampExtrapolator::DelayChangeDetection(double error)
{
// CUSUM detection of sudden delay changes
error = (error > 0) ? std::min(error, _accMaxError) :

View File

@ -17,10 +17,10 @@
#include "webrtc/call.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
#include "webrtc/modules/remote_bitrate_estimator/include/rtp_to_ntp.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/rtp_to_ntp.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/system_wrappers/interface/thread_annotations.h"
#include "webrtc/test/direct_transport.h"
@ -105,7 +105,7 @@ class SyncRtcpObserver : public test::RtpRtcpObserver {
packet_type = parser.Iterate()) {
if (packet_type == RTCPUtility::kRtcpSrCode) {
const RTCPUtility::RTCPPacket& packet = parser.Packet();
synchronization::RtcpMeasurement ntp_rtp_pair(
RtcpMeasurement ntp_rtp_pair(
packet.SR.NTPMostSignificant,
packet.SR.NTPLeastSignificant,
packet.SR.RTPTimestamp);
@ -122,16 +122,16 @@ class SyncRtcpObserver : public test::RtpRtcpObserver {
// TODO(stefan): We can't EXPECT_TRUE on this call due to a bug in the
// RTCP sender where it sends RTCP SR before any RTP packets, which leads
// to a bogus NTP/RTP mapping.
synchronization::RtpToNtpMs(timestamp, ntp_rtp_pairs_, &timestamp_in_ms);
RtpToNtpMs(timestamp, ntp_rtp_pairs_, &timestamp_in_ms);
return timestamp_in_ms;
}
return -1;
}
private:
void StoreNtpRtpPair(synchronization::RtcpMeasurement ntp_rtp_pair) {
void StoreNtpRtpPair(RtcpMeasurement ntp_rtp_pair) {
CriticalSectionScoped lock(crit_.get());
for (synchronization::RtcpList::iterator it = ntp_rtp_pairs_.begin();
for (RtcpList::iterator it = ntp_rtp_pairs_.begin();
it != ntp_rtp_pairs_.end();
++it) {
if (ntp_rtp_pair.ntp_secs == it->ntp_secs &&
@ -149,7 +149,7 @@ class SyncRtcpObserver : public test::RtpRtcpObserver {
}
const scoped_ptr<CriticalSectionWrapper> crit_;
synchronization::RtcpList ntp_rtp_pairs_ GUARDED_BY(crit_);
RtcpList ntp_rtp_pairs_ GUARDED_BY(crit_);
};
class VideoRtcpAndSyncObserver : public SyncRtcpObserver, public VideoRenderer {

View File

@ -64,15 +64,15 @@ bool StreamSynchronization::ComputeRelativeDelay(
return false;
}
int64_t audio_last_capture_time_ms;
if (!synchronization::RtpToNtpMs(audio_measurement.latest_timestamp,
audio_measurement.rtcp,
&audio_last_capture_time_ms)) {
if (!RtpToNtpMs(audio_measurement.latest_timestamp,
audio_measurement.rtcp,
&audio_last_capture_time_ms)) {
return false;
}
int64_t video_last_capture_time_ms;
if (!synchronization::RtpToNtpMs(video_measurement.latest_timestamp,
video_measurement.rtcp,
&video_last_capture_time_ms)) {
if (!RtpToNtpMs(video_measurement.latest_timestamp,
video_measurement.rtcp,
&video_last_capture_time_ms)) {
return false;
}
if (video_last_capture_time_ms < 0) {

View File

@ -13,7 +13,7 @@
#include <list>
#include "webrtc/modules/remote_bitrate_estimator/include/rtp_to_ntp.h"
#include "webrtc/system_wrappers/interface/rtp_to_ntp.h"
#include "webrtc/typedefs.h"
namespace webrtc {
@ -24,7 +24,7 @@ class StreamSynchronization {
public:
struct Measurements {
Measurements() : rtcp(), latest_receive_time_ms(0), latest_timestamp(0) {}
synchronization::RtcpList rtcp;
RtcpList rtcp;
int64_t latest_receive_time_ms;
uint32_t latest_timestamp;
};

View File

@ -33,9 +33,8 @@ class Time {
: kNtpJan1970(2208988800UL),
time_now_ms_(offset) {}
synchronization::RtcpMeasurement GenerateRtcp(int frequency,
uint32_t offset) const {
synchronization::RtcpMeasurement rtcp;
RtcpMeasurement GenerateRtcp(int frequency, uint32_t offset) const {
RtcpMeasurement rtcp;
NowNtp(&rtcp.ntp_secs, &rtcp.ntp_frac);
rtcp.rtp_timestamp = NowRtp(frequency, offset);
return rtcp;

View File

@ -21,10 +21,10 @@
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
#include "webrtc/modules/utility/interface/rtp_dump.h"
#include "webrtc/modules/video_coding/main/interface/video_coding.h"
#include "webrtc/modules/video_coding/main/source/timestamp_extrapolator.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/system_wrappers/interface/tick_util.h"
#include "webrtc/system_wrappers/interface/timestamp_extrapolator.h"
#include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc {
@ -49,7 +49,7 @@ ViEReceiver::ViEReceiver(const int32_t channel_id,
remote_bitrate_estimator_(remote_bitrate_estimator),
clock_(Clock::GetRealTimeClock()),
ts_extrapolator_(
new VCMTimestampExtrapolator(clock_->TimeInMilliseconds())),
new TimestampExtrapolator(clock_->TimeInMilliseconds())),
rtp_dump_(NULL),
receiving_(false),
restored_packet_in_use_(false),
@ -194,9 +194,9 @@ void ViEReceiver::CalculateCaptureNtpTime(WebRtcRTPHeader* rtp_header) {
}
int64_t sender_capture_ntp_ms = 0;
if (!synchronization::RtpToNtpMs(rtp_header->header.timestamp,
rtcp_list_,
&sender_capture_ntp_ms)) {
if (!RtpToNtpMs(rtp_header->header.timestamp,
rtcp_list_,
&sender_capture_ntp_ms)) {
return;
}
uint32_t timestamp = sender_capture_ntp_ms * 90;
@ -390,8 +390,11 @@ bool ViEReceiver::GetRtcpTimestamp() {
}
bool new_rtcp_sr = false;
if (!synchronization::UpdateRtcpList(
ntp_secs, ntp_frac, rtp_timestamp, &rtcp_list_, &new_rtcp_sr)) {
if (!UpdateRtcpList(ntp_secs,
ntp_frac,
rtp_timestamp,
&rtcp_list_,
&new_rtcp_sr)) {
return false;
}

View File

@ -14,17 +14,14 @@
#include <list>
#include "webrtc/engine_configurations.h"
#include "webrtc/modules/remote_bitrate_estimator/include/rtp_to_ntp.h"
#include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
#include "webrtc/system_wrappers/interface/rtp_to_ntp.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/typedefs.h"
#include "webrtc/video_engine/include/vie_network.h"
#include "webrtc/video_engine/vie_defines.h"
// TODO(wu): Move rtp_to_ntp.h and timestamp_extrapolator.h to somewhere that
// can be shared between audio and video.
namespace webrtc {
class CriticalSectionWrapper;
@ -36,7 +33,7 @@ class RtpHeaderParser;
class RTPPayloadRegistry;
class RtpReceiver;
class RtpRtcp;
class VCMTimestampExtrapolator;
class TimestampExtrapolator;
class VideoCodingModule;
struct ReceiveBandwidthEstimatorStats;
@ -124,8 +121,8 @@ class ViEReceiver : public RtpData {
RemoteBitrateEstimator* remote_bitrate_estimator_;
Clock* clock_;
scoped_ptr<VCMTimestampExtrapolator> ts_extrapolator_;
synchronization::RtcpList rtcp_list_;
scoped_ptr<TimestampExtrapolator> ts_extrapolator_;
RtcpList rtcp_list_;
RtpDump* rtp_dump_;
bool receiving_;

View File

@ -43,7 +43,7 @@ int UpdateMeasurements(StreamSynchronization::Measurements* stream,
}
bool new_rtcp_sr = false;
if (!synchronization::UpdateRtcpList(
if (!UpdateRtcpList(
ntp_secs, ntp_frac, rtp_timestamp, &stream->rtcp, &new_rtcp_sr)) {
return -1;
}