Move video_coding to new Clock interface and remove fake clock implementations from RTP module tests.
TEST=video_coding_unittests, video_coding_integrationtests, rtp_rtcp_unittests, trybots Review URL: https://webrtc-codereview.appspot.com/1044004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3393 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
a3c82bf667
commit
a678a3baee
@ -15,7 +15,7 @@
|
||||
namespace webrtc {
|
||||
|
||||
Bitrate::Bitrate(Clock* clock)
|
||||
: clock_(*clock),
|
||||
: clock_(clock),
|
||||
packet_rate_(0),
|
||||
bitrate_(0),
|
||||
bitrate_next_idx_(0),
|
||||
@ -41,7 +41,7 @@ WebRtc_UWord32 Bitrate::BitrateLast() const {
|
||||
}
|
||||
|
||||
WebRtc_UWord32 Bitrate::BitrateNow() const {
|
||||
WebRtc_Word64 now = clock_.TimeInMilliseconds();
|
||||
WebRtc_Word64 now = clock_->TimeInMilliseconds();
|
||||
WebRtc_Word64 diff_ms = now - time_last_rate_update_;
|
||||
|
||||
if (diff_ms > 10000) { // 10 seconds.
|
||||
@ -59,7 +59,7 @@ WebRtc_UWord32 Bitrate::BitrateNow() const {
|
||||
|
||||
void Bitrate::Process() {
|
||||
// Triggered by timer.
|
||||
WebRtc_Word64 now = clock_.TimeInMilliseconds();
|
||||
WebRtc_Word64 now = clock_->TimeInMilliseconds();
|
||||
WebRtc_Word64 diff_ms = now - time_last_rate_update_;
|
||||
|
||||
if (diff_ms < 100) {
|
||||
|
@ -42,7 +42,7 @@ class Bitrate {
|
||||
WebRtc_UWord32 BitrateNow() const;
|
||||
|
||||
protected:
|
||||
Clock& clock_;
|
||||
Clock* clock_;
|
||||
|
||||
private:
|
||||
WebRtc_UWord32 packet_rate_;
|
||||
|
@ -99,7 +99,6 @@ void RtcpFormatRembTest::TearDown() {
|
||||
delete rtcp_receiver_;
|
||||
delete dummy_rtp_rtcp_impl_;
|
||||
delete test_transport_;
|
||||
delete system_clock_;
|
||||
}
|
||||
|
||||
TEST_F(RtcpFormatRembTest, TestBasicAPI) {
|
||||
|
@ -34,7 +34,7 @@ RTCPReceiver::RTCPReceiver(const WebRtc_Word32 id, Clock* clock,
|
||||
ModuleRtpRtcpImpl* owner)
|
||||
: TMMBRHelp(),
|
||||
_id(id),
|
||||
_clock(*clock),
|
||||
_clock(clock),
|
||||
_method(kRtcpOff),
|
||||
_lastReceived(0),
|
||||
_rtpRtcp(*owner),
|
||||
@ -285,7 +285,7 @@ RTCPReceiver::IncomingRTCPPacket(RTCPPacketInformation& rtcpPacketInformation,
|
||||
{
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
|
||||
_lastReceived = _clock.TimeInMilliseconds();
|
||||
_lastReceived = _clock->TimeInMilliseconds();
|
||||
|
||||
RTCPUtility::RTCPPacketTypes pktType = rtcpParser->Begin();
|
||||
while (pktType != RTCPUtility::kRtcpNotValidCode)
|
||||
@ -406,7 +406,7 @@ RTCPReceiver::HandleSenderReceiverReport(RTCPUtility::RTCPParserV2& rtcpParser,
|
||||
_remoteSenderInfo.sendPacketCount = rtcpPacket.SR.SenderPacketCount;
|
||||
_remoteSenderInfo.sendOctetCount = rtcpPacket.SR.SenderOctetCount;
|
||||
|
||||
_clock.CurrentNtp(_lastReceivedSRNTPsecs, _lastReceivedSRNTPfrac);
|
||||
_clock->CurrentNtp(_lastReceivedSRNTPsecs, _lastReceivedSRNTPfrac);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -466,7 +466,7 @@ RTCPReceiver::HandleReportBlock(const RTCPUtility::RTCPPacket& rtcpPacket,
|
||||
return;
|
||||
}
|
||||
|
||||
_lastReceivedRrMs = _clock.TimeInMilliseconds();
|
||||
_lastReceivedRrMs = _clock->TimeInMilliseconds();
|
||||
const RTCPPacketReportBlockItem& rb = rtcpPacket.ReportBlockItem;
|
||||
reportBlock->remoteReceiveBlock.remoteSSRC = remoteSSRC;
|
||||
reportBlock->remoteReceiveBlock.sourceSSRC = rb.SSRC;
|
||||
@ -496,7 +496,7 @@ RTCPReceiver::HandleReportBlock(const RTCPUtility::RTCPPacket& rtcpPacket,
|
||||
WebRtc_UWord32 lastReceivedRRNTPsecs = 0;
|
||||
WebRtc_UWord32 lastReceivedRRNTPfrac = 0;
|
||||
|
||||
_clock.CurrentNtp(lastReceivedRRNTPsecs, lastReceivedRRNTPfrac);
|
||||
_clock->CurrentNtp(lastReceivedRRNTPsecs, lastReceivedRRNTPfrac);
|
||||
|
||||
// time when we received this in MS
|
||||
WebRtc_UWord32 receiveTimeMS = ModuleRTPUtility::ConvertNTPTimeToMS(
|
||||
@ -641,7 +641,7 @@ RTCPReceiver::GetReceiveInformation(WebRtc_UWord32 remoteSSRC) {
|
||||
void RTCPReceiver::UpdateReceiveInformation(
|
||||
RTCPReceiveInformation& receiveInformation) {
|
||||
// Update that this remote is alive
|
||||
receiveInformation.lastTimeReceived = _clock.TimeInMilliseconds();
|
||||
receiveInformation.lastTimeReceived = _clock->TimeInMilliseconds();
|
||||
}
|
||||
|
||||
bool RTCPReceiver::RtcpRrTimeout(int64_t rtcp_interval_ms) {
|
||||
@ -650,7 +650,7 @@ bool RTCPReceiver::RtcpRrTimeout(int64_t rtcp_interval_ms) {
|
||||
return false;
|
||||
|
||||
int64_t time_out_ms = kRrTimeoutIntervals * rtcp_interval_ms;
|
||||
if (_clock.TimeInMilliseconds() > _lastReceivedRrMs + time_out_ms) {
|
||||
if (_clock->TimeInMilliseconds() > _lastReceivedRrMs + time_out_ms) {
|
||||
// Reset the timer to only trigger one log.
|
||||
_lastReceivedRrMs = 0;
|
||||
return true;
|
||||
@ -664,7 +664,7 @@ bool RTCPReceiver::RtcpRrSequenceNumberTimeout(int64_t rtcp_interval_ms) {
|
||||
return false;
|
||||
|
||||
int64_t time_out_ms = kRrTimeoutIntervals * rtcp_interval_ms;
|
||||
if (_clock.TimeInMilliseconds() > _lastIncreasedSequenceNumberMs +
|
||||
if (_clock->TimeInMilliseconds() > _lastIncreasedSequenceNumberMs +
|
||||
time_out_ms) {
|
||||
// Reset the timer to only trigger one log.
|
||||
_lastIncreasedSequenceNumberMs = 0;
|
||||
@ -677,7 +677,7 @@ bool RTCPReceiver::UpdateRTCPReceiveInformationTimers() {
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
|
||||
bool updateBoundingSet = false;
|
||||
WebRtc_Word64 timeNow = _clock.TimeInMilliseconds();
|
||||
WebRtc_Word64 timeNow = _clock->TimeInMilliseconds();
|
||||
|
||||
std::map<WebRtc_UWord32, RTCPReceiveInformation*>::iterator receiveInfoIt =
|
||||
_receivedInfoMap.begin();
|
||||
@ -962,7 +962,7 @@ RTCPReceiver::HandleTMMBRItem(RTCPReceiveInformation& receiveInfo,
|
||||
rtcpPacket.TMMBRItem.MaxTotalMediaBitRate > 0)
|
||||
{
|
||||
receiveInfo.InsertTMMBRItem(senderSSRC, rtcpPacket.TMMBRItem,
|
||||
_clock.TimeInMilliseconds());
|
||||
_clock->TimeInMilliseconds());
|
||||
rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbr;
|
||||
}
|
||||
}
|
||||
@ -1150,7 +1150,7 @@ void RTCPReceiver::HandleFIRItem(RTCPReceiveInformation* receiveInfo,
|
||||
// check if we have reported this FIRSequenceNumber before
|
||||
if (rtcpPacket.FIRItem.CommandSequenceNumber !=
|
||||
receiveInfo->lastFIRSequenceNumber) {
|
||||
WebRtc_Word64 now = _clock.TimeInMilliseconds();
|
||||
WebRtc_Word64 now = _clock->TimeInMilliseconds();
|
||||
// sanity; don't go crazy with the callbacks
|
||||
if ((now - receiveInfo->lastFIRRequest) > RTCP_MIN_FRAME_LENGTH_MS) {
|
||||
receiveInfo->lastFIRRequest = now;
|
||||
@ -1308,7 +1308,7 @@ void RTCPReceiver::TriggerCallbacksFromRTCPPacket(
|
||||
if ((rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpSr ||
|
||||
rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpRr) &&
|
||||
rtcpPacketInformation.reportBlock) {
|
||||
WebRtc_Word64 now = _clock.TimeInMilliseconds();
|
||||
WebRtc_Word64 now = _clock->TimeInMilliseconds();
|
||||
_cbRtcpBandwidthObserver->OnReceivedRtcpReceiverReport(
|
||||
rtcpPacketInformation.remoteSSRC,
|
||||
rtcpPacketInformation.fractionLost,
|
||||
@ -1378,7 +1378,7 @@ WebRtc_Word32 RTCPReceiver::TMMBRReceived(const WebRtc_UWord32 size,
|
||||
for (WebRtc_UWord32 i = 0;
|
||||
(num < size) && (i < receiveInfo->TmmbrSet.lengthOfSet()); i++) {
|
||||
if (receiveInfo->GetTMMBRSet(i, num, candidateSet,
|
||||
_clock.TimeInMilliseconds()) == 0) {
|
||||
_clock->TimeInMilliseconds()) == 0) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
@ -1425,7 +1425,7 @@ void RTCPReceiver::PacketTimeout()
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word64 now = _clock.TimeInMilliseconds();
|
||||
WebRtc_Word64 now = _clock->TimeInMilliseconds();
|
||||
if(now - _lastReceived > _packetTimeOutMS)
|
||||
{
|
||||
packetTimeOut = true;
|
||||
|
@ -198,7 +198,7 @@ protected:
|
||||
|
||||
private:
|
||||
WebRtc_Word32 _id;
|
||||
Clock& _clock;
|
||||
Clock* _clock;
|
||||
RTCPMethod _method;
|
||||
WebRtc_Word64 _lastReceived;
|
||||
ModuleRtpRtcpImpl& _rtpRtcp;
|
||||
|
@ -168,30 +168,29 @@ class RtcpReceiverTest : public ::testing::Test {
|
||||
protected:
|
||||
RtcpReceiverTest()
|
||||
: over_use_detector_options_(),
|
||||
system_clock_(1335900000),
|
||||
remote_bitrate_observer_(),
|
||||
remote_bitrate_estimator_(
|
||||
RemoteBitrateEstimator::Create(
|
||||
&remote_bitrate_observer_,
|
||||
over_use_detector_options_,
|
||||
RemoteBitrateEstimator::kMultiStreamEstimation)) {
|
||||
system_clock_ = new SimulatedClock(1335900000);
|
||||
test_transport_ = new TestTransport();
|
||||
|
||||
RtpRtcp::Configuration configuration;
|
||||
configuration.id = 0;
|
||||
configuration.audio = false;
|
||||
configuration.clock = system_clock_;
|
||||
configuration.clock = &system_clock_;
|
||||
configuration.outgoing_transport = test_transport_;
|
||||
configuration.remote_bitrate_estimator = remote_bitrate_estimator_.get();
|
||||
rtp_rtcp_impl_ = new ModuleRtpRtcpImpl(configuration);
|
||||
rtcp_receiver_ = new RTCPReceiver(0, system_clock_, rtp_rtcp_impl_);
|
||||
rtcp_receiver_ = new RTCPReceiver(0, &system_clock_, rtp_rtcp_impl_);
|
||||
test_transport_->SetRTCPReceiver(rtcp_receiver_);
|
||||
}
|
||||
~RtcpReceiverTest() {
|
||||
delete rtcp_receiver_;
|
||||
delete rtp_rtcp_impl_;
|
||||
delete test_transport_;
|
||||
delete system_clock_;
|
||||
}
|
||||
|
||||
// Injects an RTCP packet into the receiver.
|
||||
@ -210,7 +209,7 @@ class RtcpReceiverTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
OverUseDetectorOptions over_use_detector_options_;
|
||||
SimulatedClock* system_clock_;
|
||||
SimulatedClock system_clock_;
|
||||
ModuleRtpRtcpImpl* rtp_rtcp_impl_;
|
||||
RTCPReceiver* rtcp_receiver_;
|
||||
TestTransport* test_transport_;
|
||||
@ -246,7 +245,7 @@ TEST_F(RtcpReceiverTest, ReceiveReportTimeout) {
|
||||
rtcp_receiver_->SetSSRC(kSourceSsrc);
|
||||
|
||||
uint32_t sequence_number = 1234;
|
||||
system_clock_->AdvanceTimeMs(3 * kRtcpIntervalMs);
|
||||
system_clock_.AdvanceTimeMilliseconds(3 * kRtcpIntervalMs);
|
||||
|
||||
// No RR received, shouldn't trigger a timeout.
|
||||
EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs));
|
||||
@ -256,7 +255,7 @@ TEST_F(RtcpReceiverTest, ReceiveReportTimeout) {
|
||||
PacketBuilder p1;
|
||||
p1.AddRrPacket(kSenderSsrc, kSourceSsrc, sequence_number);
|
||||
EXPECT_EQ(0, InjectRtcpPacket(p1.packet(), p1.length()));
|
||||
system_clock_->AdvanceTimeMs(3 * kRtcpIntervalMs - 1);
|
||||
system_clock_.AdvanceTimeMilliseconds(3 * kRtcpIntervalMs - 1);
|
||||
EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs));
|
||||
EXPECT_FALSE(rtcp_receiver_->RtcpRrSequenceNumberTimeout(kRtcpIntervalMs));
|
||||
|
||||
@ -265,12 +264,12 @@ TEST_F(RtcpReceiverTest, ReceiveReportTimeout) {
|
||||
PacketBuilder p2;
|
||||
p2.AddRrPacket(kSenderSsrc, kSourceSsrc, sequence_number);
|
||||
EXPECT_EQ(0, InjectRtcpPacket(p2.packet(), p2.length()));
|
||||
system_clock_->AdvanceTimeMs(2);
|
||||
system_clock_.AdvanceTimeMilliseconds(2);
|
||||
EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs));
|
||||
EXPECT_TRUE(rtcp_receiver_->RtcpRrSequenceNumberTimeout(kRtcpIntervalMs));
|
||||
|
||||
// Advance clock enough to trigger an RR timeout too.
|
||||
system_clock_->AdvanceTimeMs(3 * kRtcpIntervalMs);
|
||||
system_clock_.AdvanceTimeMilliseconds(3 * kRtcpIntervalMs);
|
||||
EXPECT_TRUE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs));
|
||||
|
||||
// We should only get one timeout even though we still haven't received a new
|
||||
@ -287,14 +286,14 @@ TEST_F(RtcpReceiverTest, ReceiveReportTimeout) {
|
||||
EXPECT_FALSE(rtcp_receiver_->RtcpRrSequenceNumberTimeout(kRtcpIntervalMs));
|
||||
|
||||
// Verify we can get a timeout again once we've received new RR.
|
||||
system_clock_->AdvanceTimeMs(2 * kRtcpIntervalMs);
|
||||
system_clock_.AdvanceTimeMilliseconds(2 * kRtcpIntervalMs);
|
||||
PacketBuilder p4;
|
||||
p4.AddRrPacket(kSenderSsrc, kSourceSsrc, sequence_number);
|
||||
EXPECT_EQ(0, InjectRtcpPacket(p4.packet(), p4.length()));
|
||||
system_clock_->AdvanceTimeMs(kRtcpIntervalMs + 1);
|
||||
system_clock_.AdvanceTimeMilliseconds(kRtcpIntervalMs + 1);
|
||||
EXPECT_FALSE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs));
|
||||
EXPECT_TRUE(rtcp_receiver_->RtcpRrSequenceNumberTimeout(kRtcpIntervalMs));
|
||||
system_clock_->AdvanceTimeMs(2 * kRtcpIntervalMs);
|
||||
system_clock_.AdvanceTimeMilliseconds(2 * kRtcpIntervalMs);
|
||||
EXPECT_TRUE(rtcp_receiver_->RtcpRrTimeout(kRtcpIntervalMs));
|
||||
}
|
||||
|
||||
@ -386,7 +385,8 @@ TEST_F(RtcpReceiverTest, TmmbrThreeConstraintsTimeOut) {
|
||||
p.AddTmmbrBandwidth(30000, 0, 0); // 30 Kbits/sec bandwidth, no overhead.
|
||||
|
||||
EXPECT_EQ(0, InjectRtcpPacket(p.packet(), p.length()));
|
||||
system_clock_->AdvanceTimeMs(5000); // 5 seconds between each packet.
|
||||
// 5 seconds between each packet.
|
||||
system_clock_.AdvanceTimeMilliseconds(5000);
|
||||
}
|
||||
// It is now starttime+15.
|
||||
EXPECT_EQ(3, rtcp_receiver_->TMMBRReceived(0, 0, NULL));
|
||||
@ -396,7 +396,7 @@ TEST_F(RtcpReceiverTest, TmmbrThreeConstraintsTimeOut) {
|
||||
EXPECT_LT(0U, candidate_set.Tmmbr(0));
|
||||
// We expect the timeout to be 25 seconds. Advance the clock by 12
|
||||
// seconds, timing out the first packet.
|
||||
system_clock_->AdvanceTimeMs(12000);
|
||||
system_clock_.AdvanceTimeMilliseconds(12000);
|
||||
// Odd behaviour: Just counting them does not trigger the timeout.
|
||||
EXPECT_EQ(3, rtcp_receiver_->TMMBRReceived(0, 0, NULL));
|
||||
// Odd behaviour: There's only one left after timeout, not 2.
|
||||
|
@ -29,7 +29,7 @@ RTCPSender::RTCPSender(const WebRtc_Word32 id,
|
||||
ModuleRtpRtcpImpl* owner) :
|
||||
_id(id),
|
||||
_audio(audio),
|
||||
_clock(*clock),
|
||||
_clock(clock),
|
||||
_method(kRtcpOff),
|
||||
_rtpRtcp(*owner),
|
||||
_criticalSectionTransport(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
@ -183,11 +183,11 @@ RTCPSender::SetRTCPStatus(const RTCPMethod method)
|
||||
{
|
||||
if(_audio)
|
||||
{
|
||||
_nextTimeToSendRTCP = _clock.TimeInMilliseconds() +
|
||||
_nextTimeToSendRTCP = _clock->TimeInMilliseconds() +
|
||||
(RTCP_INTERVAL_AUDIO_MS/2);
|
||||
} else
|
||||
{
|
||||
_nextTimeToSendRTCP = _clock.TimeInMilliseconds() +
|
||||
_nextTimeToSendRTCP = _clock->TimeInMilliseconds() +
|
||||
(RTCP_INTERVAL_VIDEO_MS/2);
|
||||
}
|
||||
}
|
||||
@ -304,7 +304,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.TimeInMilliseconds();
|
||||
last_frame_capture_time_ms_ = _clock->TimeInMilliseconds();
|
||||
} else {
|
||||
last_frame_capture_time_ms_ = capture_time_ms;
|
||||
}
|
||||
@ -320,7 +320,7 @@ RTCPSender::SetSSRC( const WebRtc_UWord32 ssrc)
|
||||
// not first SetSSRC, probably due to a collision
|
||||
// schedule a new RTCP report
|
||||
// make sure that we send a RTP packet
|
||||
_nextTimeToSendRTCP = _clock.TimeInMilliseconds() + 100;
|
||||
_nextTimeToSendRTCP = _clock->TimeInMilliseconds() + 100;
|
||||
}
|
||||
_SSRC = ssrc;
|
||||
}
|
||||
@ -451,7 +451,7 @@ From RFC 3550
|
||||
a value of the RTCP bandwidth below the intended average
|
||||
*/
|
||||
|
||||
WebRtc_Word64 now = _clock.TimeInMilliseconds();
|
||||
WebRtc_Word64 now = _clock->TimeInMilliseconds();
|
||||
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPSender);
|
||||
|
||||
@ -590,7 +590,7 @@ RTCPSender::BuildSR(WebRtc_UWord8* rtcpbuffer,
|
||||
// timestamp as the last frame's timestamp + the time since the last frame
|
||||
// was captured.
|
||||
RTPtime = start_timestamp_ + last_rtp_timestamp_ + (
|
||||
_clock.TimeInMilliseconds() - last_frame_capture_time_ms_) *
|
||||
_clock->TimeInMilliseconds() - last_frame_capture_time_ms_) *
|
||||
(freqHz / 1000);
|
||||
|
||||
// Add sender data
|
||||
@ -1580,7 +1580,7 @@ RTCPSender::SendRTCP(const WebRtc_UWord32 packetTypeFlags,
|
||||
remoteSR);
|
||||
|
||||
// get our NTP as late as possible to avoid a race
|
||||
_clock.CurrentNtp(NTPsec, NTPfrac);
|
||||
_clock->CurrentNtp(NTPsec, NTPfrac);
|
||||
|
||||
// Delay since last received report
|
||||
WebRtc_UWord32 delaySinceLastReceivedSR = 0;
|
||||
@ -1602,7 +1602,7 @@ RTCPSender::SendRTCP(const WebRtc_UWord32 packetTypeFlags,
|
||||
} else
|
||||
{
|
||||
// we need to send our NTP even if we dont have received any reports
|
||||
_clock.CurrentNtp(NTPsec, NTPfrac);
|
||||
_clock->CurrentNtp(NTPsec, NTPfrac);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1697,7 +1697,7 @@ RTCPSender::SendRTCP(const WebRtc_UWord32 packetTypeFlags,
|
||||
}
|
||||
timeToNext = (minIntervalMs/2) + (minIntervalMs*random/1000);
|
||||
}
|
||||
_nextTimeToSendRTCP = _clock.TimeInMilliseconds() + timeToNext;
|
||||
_nextTimeToSendRTCP = _clock->TimeInMilliseconds() + timeToNext;
|
||||
}
|
||||
|
||||
// if the data does not fitt in the packet we fill it as much as possible
|
||||
|
@ -186,7 +186,7 @@ private:
|
||||
private:
|
||||
WebRtc_Word32 _id;
|
||||
const bool _audio;
|
||||
Clock& _clock;
|
||||
Clock* _clock;
|
||||
RTCPMethod _method;
|
||||
|
||||
ModuleRtpRtcpImpl& _rtpRtcp;
|
||||
|
@ -129,7 +129,6 @@ class RtcpSenderTest : public ::testing::Test {
|
||||
delete rtcp_receiver_;
|
||||
delete rtp_rtcp_impl_;
|
||||
delete test_transport_;
|
||||
delete system_clock_;
|
||||
}
|
||||
|
||||
// Helper function: Incoming RTCP has a specific packet type.
|
||||
|
@ -20,7 +20,7 @@
|
||||
namespace webrtc {
|
||||
|
||||
RTPPacketHistory::RTPPacketHistory(Clock* clock)
|
||||
: clock_(*clock),
|
||||
: clock_(clock),
|
||||
critsect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
store_(false),
|
||||
prev_index_(0),
|
||||
@ -140,7 +140,7 @@ int32_t RTPPacketHistory::PutRTPPacket(const uint8_t* packet,
|
||||
stored_seq_nums_[prev_index_] = seq_num;
|
||||
stored_lengths_[prev_index_] = packet_length;
|
||||
stored_times_[prev_index_] =
|
||||
(capture_time_ms > 0) ? capture_time_ms : clock_.TimeInMilliseconds();
|
||||
(capture_time_ms > 0) ? capture_time_ms : clock_->TimeInMilliseconds();
|
||||
stored_resend_times_[prev_index_] = 0; // packet not resent
|
||||
stored_types_[prev_index_] = type;
|
||||
|
||||
@ -244,7 +244,7 @@ bool RTPPacketHistory::GetRTPPacket(uint16_t sequence_number,
|
||||
}
|
||||
|
||||
// Verify elapsed time since last retrieve.
|
||||
int64_t now = clock_.TimeInMilliseconds();
|
||||
int64_t now = clock_->TimeInMilliseconds();
|
||||
if (min_elapsed_time_ms > 0 &&
|
||||
((now - stored_resend_times_.at(index)) < min_elapsed_time_ms)) {
|
||||
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, -1,
|
||||
@ -276,7 +276,7 @@ void RTPPacketHistory::UpdateResendTime(uint16_t sequence_number) {
|
||||
"Failed to update resend time, seq num: %u.", sequence_number);
|
||||
return;
|
||||
}
|
||||
stored_resend_times_[index] = clock_.TimeInMilliseconds();
|
||||
stored_resend_times_[index] = clock_->TimeInMilliseconds();
|
||||
}
|
||||
|
||||
// private, lock should already be taken
|
||||
|
@ -77,7 +77,7 @@ class RTPPacketHistory {
|
||||
bool FindSeqNum(uint16_t sequence_number, int32_t* index) const;
|
||||
|
||||
private:
|
||||
Clock& clock_;
|
||||
Clock* clock_;
|
||||
CriticalSectionWrapper* critsect_;
|
||||
bool store_;
|
||||
uint32_t prev_index_;
|
||||
|
@ -12,49 +12,24 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "clock.h"
|
||||
#include "rtp_packet_history.h"
|
||||
#include "rtp_rtcp_defines.h"
|
||||
#include "typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class FakeClock : public Clock {
|
||||
public:
|
||||
FakeClock() {
|
||||
time_in_ms_ = 123456;
|
||||
}
|
||||
// Return a timestamp in milliseconds relative to some arbitrary
|
||||
// source; the source is fixed for this clock.
|
||||
virtual WebRtc_Word64 TimeInMilliseconds() {
|
||||
return time_in_ms_;
|
||||
}
|
||||
|
||||
virtual WebRtc_Word64 TimeInMicroseconds() {
|
||||
return time_in_ms_ * 1000;
|
||||
}
|
||||
|
||||
// Retrieve an NTP absolute timestamp.
|
||||
virtual void CurrentNtp(WebRtc_UWord32& secs, WebRtc_UWord32& frac) {
|
||||
secs = time_in_ms_ / 1000;
|
||||
frac = (time_in_ms_ % 1000) * 4294967;
|
||||
}
|
||||
void IncrementTime(WebRtc_UWord32 time_increment_ms) {
|
||||
time_in_ms_ += time_increment_ms;
|
||||
}
|
||||
private:
|
||||
WebRtc_Word64 time_in_ms_;
|
||||
};
|
||||
|
||||
class RtpPacketHistoryTest : public ::testing::Test {
|
||||
protected:
|
||||
RtpPacketHistoryTest()
|
||||
: hist_(new RTPPacketHistory(&fake_clock_)) {
|
||||
: fake_clock_(123456),
|
||||
hist_(new RTPPacketHistory(&fake_clock_)) {
|
||||
}
|
||||
~RtpPacketHistoryTest() {
|
||||
delete hist_;
|
||||
}
|
||||
|
||||
FakeClock fake_clock_;
|
||||
SimulatedClock fake_clock_;
|
||||
RTPPacketHistory* hist_;
|
||||
enum {kPayload = 127};
|
||||
enum {kSsrc = 12345678};
|
||||
@ -224,7 +199,7 @@ TEST_F(RtpPacketHistoryTest, ReplaceRtpHeader) {
|
||||
TEST_F(RtpPacketHistoryTest, NoCaptureTime) {
|
||||
hist_->SetStorePacketsStatus(true, 10);
|
||||
uint16_t len = 0;
|
||||
fake_clock_.IncrementTime(1);
|
||||
fake_clock_.AdvanceTimeMilliseconds(1);
|
||||
int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
|
||||
CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len);
|
||||
EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength,
|
||||
@ -270,7 +245,7 @@ TEST_F(RtpPacketHistoryTest, MinResendTime) {
|
||||
capture_time_ms, kAllowRetransmission));
|
||||
|
||||
hist_->UpdateResendTime(kSeqNum);
|
||||
fake_clock_.IncrementTime(100);
|
||||
fake_clock_.AdvanceTimeMilliseconds(100);
|
||||
|
||||
// Time has elapsed.
|
||||
len = kMaxPacketLength;
|
||||
|
@ -171,7 +171,7 @@ void RTPReceiver::PacketTimeout() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word64 now = clock_.TimeInMilliseconds();
|
||||
WebRtc_Word64 now = clock_->TimeInMilliseconds();
|
||||
|
||||
if (now - last_receive_time_ > packet_timeout_ms_) {
|
||||
packet_time_out = true;
|
||||
@ -416,7 +416,7 @@ WebRtc_Word32 RTPReceiver::IncomingRTPPacket(
|
||||
|
||||
WebRtc_Word32 ret_val = rtp_media_receiver_->ParseRtpPacket(
|
||||
rtp_header, specific_payload, is_red, packet, packet_length,
|
||||
clock_.TimeInMilliseconds(), is_first_packet);
|
||||
clock_->TimeInMilliseconds(), is_first_packet);
|
||||
|
||||
if (ret_val < 0) {
|
||||
return ret_val;
|
||||
@ -434,13 +434,13 @@ WebRtc_Word32 RTPReceiver::IncomingRTPPacket(
|
||||
|
||||
// Need to be updated after RetransmitOfOldPacket and
|
||||
// RetransmitOfOldPacketUpdateStatistics.
|
||||
last_receive_time_ = clock_.TimeInMilliseconds();
|
||||
last_receive_time_ = clock_->TimeInMilliseconds();
|
||||
last_received_payload_length_ = payload_data_length;
|
||||
|
||||
if (!old_packet) {
|
||||
if (last_received_timestamp_ != rtp_header->header.timestamp) {
|
||||
last_received_timestamp_ = rtp_header->header.timestamp;
|
||||
last_received_frame_time_ms_ = clock_.TimeInMilliseconds();
|
||||
last_received_frame_time_ms_ = clock_->TimeInMilliseconds();
|
||||
}
|
||||
last_received_sequence_number_ = rtp_header->header.sequenceNumber;
|
||||
last_received_transmission_time_offset_ =
|
||||
@ -466,14 +466,14 @@ void RTPReceiver::UpdateStatistics(const WebRtcRTPHeader* rtp_header,
|
||||
received_seq_max_ = rtp_header->header.sequenceNumber;
|
||||
received_inorder_packet_count_ = 1;
|
||||
local_time_last_received_timestamp_ =
|
||||
GetCurrentRTP(&clock_, frequency_hz); // Time in samples.
|
||||
GetCurrentRTP(clock_, frequency_hz); // Time in samples.
|
||||
return;
|
||||
}
|
||||
|
||||
// Count only the new packets received.
|
||||
if (InOrderPacket(rtp_header->header.sequenceNumber)) {
|
||||
const WebRtc_UWord32 RTPtime =
|
||||
GetCurrentRTP(&clock_, frequency_hz); // Time in samples.
|
||||
GetCurrentRTP(clock_, frequency_hz); // Time in samples.
|
||||
received_inorder_packet_count_++;
|
||||
|
||||
// Wrong if we use RetransmitOfOldPacket.
|
||||
@ -548,7 +548,8 @@ bool RTPReceiver::RetransmitOfOldPacket(
|
||||
}
|
||||
|
||||
WebRtc_UWord32 frequency_khz = rtp_media_receiver_->GetFrequencyHz() / 1000;
|
||||
WebRtc_Word64 time_diff_ms = clock_.TimeInMilliseconds() - last_receive_time_;
|
||||
WebRtc_Word64 time_diff_ms = clock_->TimeInMilliseconds() -
|
||||
last_receive_time_;
|
||||
|
||||
// Diff in time stamp since last received in order.
|
||||
WebRtc_Word32 rtp_time_stamp_diff_ms =
|
||||
@ -642,7 +643,7 @@ WebRtc_Word32 RTPReceiver::EstimatedRemoteTimeStamp(
|
||||
return -1;
|
||||
}
|
||||
// Time in samples.
|
||||
WebRtc_UWord32 diff = GetCurrentRTP(&clock_, frequency_hz) -
|
||||
WebRtc_UWord32 diff = GetCurrentRTP(clock_, frequency_hz) -
|
||||
local_time_last_received_timestamp_;
|
||||
|
||||
timestamp = last_received_timestamp_ + diff;
|
||||
|
@ -83,7 +83,6 @@ RtpRtcp* RtpRtcp::CreateRtpRtcp(const RtpRtcp::Configuration& configuration) {
|
||||
configuration_copy.clock = Clock::GetRealTimeClock();
|
||||
ModuleRtpRtcpImpl* rtp_rtcp_instance =
|
||||
new ModuleRtpRtcpImpl(configuration_copy);
|
||||
rtp_rtcp_instance->OwnsClock();
|
||||
return rtp_rtcp_instance;
|
||||
}
|
||||
}
|
||||
@ -102,8 +101,7 @@ ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration)
|
||||
rtcp_sender_(configuration.id, configuration.audio, configuration.clock,
|
||||
this),
|
||||
rtcp_receiver_(configuration.id, configuration.clock, this),
|
||||
owns_clock_(false),
|
||||
clock_(*configuration.clock),
|
||||
clock_(configuration.clock),
|
||||
id_(configuration.id),
|
||||
audio_(configuration.audio),
|
||||
collision_detected_(false),
|
||||
@ -168,9 +166,6 @@ ModuleRtpRtcpImpl::~ModuleRtpRtcpImpl() {
|
||||
plot1_ = NULL;
|
||||
}
|
||||
#endif
|
||||
if (owns_clock_) {
|
||||
delete &clock_;
|
||||
}
|
||||
}
|
||||
|
||||
void ModuleRtpRtcpImpl::RegisterChildModule(RtpRtcp* module) {
|
||||
@ -217,13 +212,13 @@ void ModuleRtpRtcpImpl::DeRegisterChildModule(RtpRtcp* remove_module) {
|
||||
// Returns the number of milliseconds until the module want a worker thread
|
||||
// to call Process.
|
||||
WebRtc_Word32 ModuleRtpRtcpImpl::TimeUntilNextProcess() {
|
||||
const WebRtc_Word64 now = clock_.TimeInMilliseconds();
|
||||
const WebRtc_Word64 now = clock_->TimeInMilliseconds();
|
||||
return kRtpRtcpMaxIdleTimeProcess - (now - last_process_time_);
|
||||
}
|
||||
|
||||
// Process any pending tasks such as timeouts (non time critical events).
|
||||
WebRtc_Word32 ModuleRtpRtcpImpl::Process() {
|
||||
const WebRtc_Word64 now = clock_.TimeInMilliseconds();
|
||||
const WebRtc_Word64 now = clock_->TimeInMilliseconds();
|
||||
last_process_time_ = now;
|
||||
|
||||
if (now >=
|
||||
@ -305,7 +300,7 @@ WebRtc_Word32 ModuleRtpRtcpImpl::Process() {
|
||||
|
||||
void ModuleRtpRtcpImpl::ProcessDeadOrAliveTimer() {
|
||||
if (dead_or_alive_active_) {
|
||||
const WebRtc_Word64 now = clock_.TimeInMilliseconds();
|
||||
const WebRtc_Word64 now = clock_->TimeInMilliseconds();
|
||||
if (now > dead_or_alive_timeout_ms_ + dead_or_alive_last_timer_) {
|
||||
// RTCP is alive if we have received a report the last 12 seconds.
|
||||
dead_or_alive_last_timer_ += dead_or_alive_timeout_ms_;
|
||||
@ -340,7 +335,7 @@ WebRtc_Word32 ModuleRtpRtcpImpl::SetPeriodicDeadOrAliveStatus(
|
||||
dead_or_alive_active_ = enable;
|
||||
dead_or_alive_timeout_ms_ = sample_time_seconds * 1000;
|
||||
// Trigger the first after one period.
|
||||
dead_or_alive_last_timer_ = clock_.TimeInMilliseconds();
|
||||
dead_or_alive_last_timer_ = clock_->TimeInMilliseconds();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1304,7 +1299,7 @@ WebRtc_Word32 ModuleRtpRtcpImpl::ReportBlockStatistics(
|
||||
#ifdef MATLAB
|
||||
if (plot1_ == NULL) {
|
||||
plot1_ = eng.NewPlot(new MatlabPlot());
|
||||
plot1_->AddTimeLine(30, "b", "lost", clock_.GetTimeInMS());
|
||||
plot1_->AddTimeLine(30, "b", "lost", clock_->TimeInMilliseconds());
|
||||
}
|
||||
plot1_->Append("lost", missing);
|
||||
plot1_->Plot();
|
||||
@ -1520,7 +1515,7 @@ WebRtc_Word32 ModuleRtpRtcpImpl::SendNACK(const WebRtc_UWord16* nack_list,
|
||||
if (wait_time == 5) {
|
||||
wait_time = 100; // During startup we don't have an RTT.
|
||||
}
|
||||
const WebRtc_Word64 now = clock_.TimeInMilliseconds();
|
||||
const WebRtc_Word64 now = clock_->TimeInMilliseconds();
|
||||
const WebRtc_Word64 time_limit = now - wait_time;
|
||||
WebRtc_UWord16 nackLength = size;
|
||||
WebRtc_UWord16 start_id = 0;
|
||||
|
@ -454,12 +454,6 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
|
||||
|
||||
void OnRequestSendReport();
|
||||
|
||||
// Following function is only called when constructing the object so no
|
||||
// need to worry about data race.
|
||||
void OwnsClock() {
|
||||
owns_clock_ = true;
|
||||
}
|
||||
|
||||
protected:
|
||||
void RegisterChildModule(RtpRtcp* module);
|
||||
|
||||
@ -483,8 +477,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
|
||||
RTCPSender rtcp_sender_;
|
||||
RTCPReceiver rtcp_receiver_;
|
||||
|
||||
bool owns_clock_;
|
||||
Clock& clock_;
|
||||
Clock* clock_;
|
||||
|
||||
private:
|
||||
int64_t RtcpReportInterval();
|
||||
|
@ -75,14 +75,14 @@ RTPSender::RTPSender(const WebRtc_Word32 id,
|
||||
memset(_nackByteCount, 0, sizeof(_nackByteCount));
|
||||
memset(_CSRC, 0, sizeof(_CSRC));
|
||||
// We need to seed the random generator.
|
||||
srand( (WebRtc_UWord32)clock_.TimeInMilliseconds() );
|
||||
srand(static_cast<WebRtc_UWord32>(clock_->TimeInMilliseconds()));
|
||||
_ssrc = _ssrcDB.CreateSSRC(); // Can't be 0.
|
||||
|
||||
if (audio) {
|
||||
_audio = new RTPSenderAudio(id, &clock_, this);
|
||||
_audio = new RTPSenderAudio(id, clock_, this);
|
||||
_audio->RegisterAudioCallback(audio_feedback);
|
||||
} else {
|
||||
_video = new RTPSenderVideo(id, &clock_, this);
|
||||
_video = new RTPSenderVideo(id, clock_, this);
|
||||
}
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, id, "%s created", __FUNCTION__);
|
||||
}
|
||||
@ -576,7 +576,7 @@ int RTPSender::SetSelectiveRetransmissions(uint8_t settings) {
|
||||
void RTPSender::OnReceivedNACK(const WebRtc_UWord16 nackSequenceNumbersLength,
|
||||
const WebRtc_UWord16* nackSequenceNumbers,
|
||||
const WebRtc_UWord16 avgRTT) {
|
||||
const WebRtc_Word64 now = clock_.TimeInMilliseconds();
|
||||
const WebRtc_Word64 now = clock_->TimeInMilliseconds();
|
||||
WebRtc_UWord32 bytesReSent = 0;
|
||||
|
||||
// Enough bandwidth to send NACK?
|
||||
@ -700,7 +700,7 @@ void RTPSender::TimeToSendPacket(uint16_t sequence_number,
|
||||
WebRtcRTPHeader rtp_header;
|
||||
rtpParser.Parse(rtp_header);
|
||||
|
||||
int64_t diff_ms = clock_.TimeInMilliseconds() - 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.
|
||||
_packetHistory->ReplaceRTPHeader(data_buffer,
|
||||
@ -738,7 +738,7 @@ WebRtc_Word32 RTPSender::SendToNetwork(uint8_t* buffer,
|
||||
// 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 time_now = clock_.TimeInMilliseconds();
|
||||
int64_t time_now = clock_->TimeInMilliseconds();
|
||||
UpdateTransmissionTimeOffset(buffer, payload_length + rtp_header_length,
|
||||
rtp_header, time_now - capture_time_ms);
|
||||
}
|
||||
@ -1027,7 +1027,7 @@ void RTPSender::SetSendingStatus(const bool enabled) {
|
||||
} else {
|
||||
frequency_hz = kDefaultVideoFrequency;
|
||||
}
|
||||
WebRtc_UWord32 RTPtime = ModuleRTPUtility::GetCurrentRTP(&clock_,
|
||||
WebRtc_UWord32 RTPtime = ModuleRTPUtility::GetCurrentRTP(clock_,
|
||||
frequency_hz);
|
||||
|
||||
// will be ignored if it's already configured via API
|
||||
|
@ -17,7 +17,7 @@ namespace webrtc {
|
||||
RTPSenderAudio::RTPSenderAudio(const WebRtc_Word32 id, Clock* clock,
|
||||
RTPSenderInterface* rtpSender) :
|
||||
_id(id),
|
||||
_clock(*clock),
|
||||
_clock(clock),
|
||||
_rtpSender(rtpSender),
|
||||
_audioFeedbackCritsect(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_audioFeedback(NULL),
|
||||
@ -217,7 +217,7 @@ RTPSenderAudio::SendTelephoneEventActive(WebRtc_Word8& telephoneEvent) const
|
||||
telephoneEvent = _dtmfKey;
|
||||
return true;
|
||||
}
|
||||
WebRtc_Word64 delaySinceLastDTMF = _clock.TimeInMilliseconds() -
|
||||
WebRtc_Word64 delaySinceLastDTMF = _clock->TimeInMilliseconds() -
|
||||
_dtmfTimeLastSent;
|
||||
if(delaySinceLastDTMF < 100)
|
||||
{
|
||||
@ -246,7 +246,7 @@ WebRtc_Word32 RTPSenderAudio::SendAudio(
|
||||
if (!_dtmfEventIsOn && PendingDTMF()) {
|
||||
CriticalSectionScoped cs(_sendAudioCritsect);
|
||||
|
||||
WebRtc_Word64 delaySinceLastDTMF = _clock.TimeInMilliseconds() -
|
||||
WebRtc_Word64 delaySinceLastDTMF = _clock->TimeInMilliseconds() -
|
||||
_dtmfTimeLastSent;
|
||||
|
||||
if (delaySinceLastDTMF > 100) {
|
||||
@ -297,7 +297,7 @@ WebRtc_Word32 RTPSenderAudio::SendAudio(
|
||||
} else {
|
||||
ended = true;
|
||||
_dtmfEventIsOn = false;
|
||||
_dtmfTimeLastSent = _clock.TimeInMilliseconds();
|
||||
_dtmfTimeLastSent = _clock->TimeInMilliseconds();
|
||||
}
|
||||
// don't hold the critsect while calling SendTelephoneEventPacket
|
||||
_sendAudioCritsect->Leave();
|
||||
|
@ -89,7 +89,7 @@ protected:
|
||||
|
||||
private:
|
||||
WebRtc_Word32 _id;
|
||||
Clock& _clock;
|
||||
Clock* _clock;
|
||||
RTPSenderInterface* _rtpSender;
|
||||
CriticalSectionWrapper* _audioFeedbackCritsect;
|
||||
RtpAudioFeedback* _audioFeedback;
|
||||
|
@ -33,33 +33,6 @@ const int kTimeOffset = 22222;
|
||||
const int kMaxPacketLength = 1500;
|
||||
} // namespace
|
||||
|
||||
class FakeClockTest : public Clock {
|
||||
public:
|
||||
FakeClockTest() {
|
||||
time_in_ms_ = 123456;
|
||||
}
|
||||
// Return a timestamp in milliseconds relative to some arbitrary
|
||||
// source; the source is fixed for this clock.
|
||||
virtual WebRtc_Word64 TimeInMilliseconds() {
|
||||
return time_in_ms_;
|
||||
}
|
||||
|
||||
virtual WebRtc_Word64 TimeInMicroseconds() {
|
||||
return time_in_ms_ * 1000;
|
||||
}
|
||||
|
||||
// Retrieve an NTP absolute timestamp.
|
||||
virtual void CurrentNtp(WebRtc_UWord32& secs, WebRtc_UWord32& frac) {
|
||||
secs = time_in_ms_ / 1000;
|
||||
frac = (time_in_ms_ % 1000) * 4294967;
|
||||
}
|
||||
void IncrementTime(WebRtc_UWord32 time_increment_ms) {
|
||||
time_in_ms_ += time_increment_ms;
|
||||
}
|
||||
private:
|
||||
WebRtc_Word64 time_in_ms_;
|
||||
};
|
||||
|
||||
class LoopbackTransportTest : public webrtc::Transport {
|
||||
public:
|
||||
LoopbackTransportTest()
|
||||
@ -83,14 +56,14 @@ class LoopbackTransportTest : public webrtc::Transport {
|
||||
class RtpSenderTest : public ::testing::Test {
|
||||
protected:
|
||||
RtpSenderTest()
|
||||
: fake_clock_(),
|
||||
: fake_clock_(123456),
|
||||
rtp_sender_(new RTPSender(0, false, &fake_clock_, &transport_, NULL,
|
||||
NULL)),
|
||||
kMarkerBit(true),
|
||||
kType(kRtpExtensionTransmissionTimeOffset) {
|
||||
rtp_sender_->SetSequenceNumber(kSeqNum);
|
||||
}
|
||||
FakeClockTest fake_clock_;
|
||||
SimulatedClock fake_clock_;
|
||||
scoped_ptr<RTPSender> rtp_sender_;
|
||||
LoopbackTransportTest transport_;
|
||||
const bool kMarkerBit;
|
||||
@ -232,7 +205,7 @@ TEST_F(RtpSenderTest, DISABLED_TrafficSmoothing) {
|
||||
kAllowRetransmission));
|
||||
EXPECT_EQ(0, transport_.packets_sent_);
|
||||
const int kStoredTimeInMs = 100;
|
||||
fake_clock_.IncrementTime(kStoredTimeInMs);
|
||||
fake_clock_.AdvanceTimeMilliseconds(kStoredTimeInMs);
|
||||
// Process send bucket. Packet should now be sent.
|
||||
EXPECT_EQ(1, transport_.packets_sent_);
|
||||
EXPECT_EQ(rtp_length, transport_.last_sent_packet_len_);
|
||||
|
@ -22,7 +22,7 @@ using namespace webrtc;
|
||||
|
||||
class RtpRtcpAPITest : public ::testing::Test {
|
||||
protected:
|
||||
RtpRtcpAPITest() {
|
||||
RtpRtcpAPITest() : module(NULL), fake_clock(123456) {
|
||||
test_CSRC[0] = 1234;
|
||||
test_CSRC[1] = 2345;
|
||||
test_id = 123;
|
||||
@ -50,7 +50,7 @@ class RtpRtcpAPITest : public ::testing::Test {
|
||||
WebRtc_UWord32 test_timestamp;
|
||||
WebRtc_UWord16 test_sequence_number;
|
||||
WebRtc_UWord32 test_CSRC[webrtc::kRtpCsrcSize];
|
||||
FakeRtpRtcpClock fake_clock;
|
||||
SimulatedClock fake_clock;
|
||||
};
|
||||
|
||||
TEST_F(RtpRtcpAPITest, Basic) {
|
||||
|
@ -14,31 +14,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class FakeRtpRtcpClock : public Clock {
|
||||
public:
|
||||
FakeRtpRtcpClock() {
|
||||
time_in_ms_ = 123456;
|
||||
}
|
||||
// Return a timestamp in milliseconds relative to some arbitrary
|
||||
// source; the source is fixed for this clock.
|
||||
virtual WebRtc_Word64 TimeInMilliseconds() {
|
||||
return time_in_ms_;
|
||||
}
|
||||
virtual int64_t TimeInMicroseconds() {
|
||||
return time_in_ms_ * 1000;
|
||||
}
|
||||
// Retrieve an NTP absolute timestamp.
|
||||
virtual void CurrentNtp(WebRtc_UWord32& secs, WebRtc_UWord32& frac) {
|
||||
secs = time_in_ms_ / 1000;
|
||||
frac = (time_in_ms_ % 1000) * 4294967;
|
||||
}
|
||||
void IncrementTime(WebRtc_UWord32 time_increment_ms) {
|
||||
time_in_ms_ += time_increment_ms;
|
||||
}
|
||||
private:
|
||||
WebRtc_Word64 time_in_ms_;
|
||||
};
|
||||
|
||||
// This class sends all its packet straight to the provided RtpRtcp module.
|
||||
// with optional packet loss.
|
||||
class LoopBackTransport : public webrtc::Transport {
|
||||
|
@ -119,7 +119,7 @@ class AudioFeedback : public RtpAudioFeedback {
|
||||
|
||||
class RtpRtcpAudioTest : public ::testing::Test {
|
||||
protected:
|
||||
RtpRtcpAudioTest() {
|
||||
RtpRtcpAudioTest() : fake_clock(123456) {
|
||||
test_CSRC[0] = 1234;
|
||||
test_CSRC[2] = 2345;
|
||||
test_id = 123;
|
||||
@ -183,7 +183,7 @@ class RtpRtcpAudioTest : public ::testing::Test {
|
||||
WebRtc_UWord32 test_timestamp;
|
||||
WebRtc_UWord16 test_sequence_number;
|
||||
WebRtc_UWord32 test_CSRC[webrtc::kRtpCsrcSize];
|
||||
FakeRtpRtcpClock fake_clock;
|
||||
SimulatedClock fake_clock;
|
||||
};
|
||||
|
||||
TEST_F(RtpRtcpAudioTest, Basic) {
|
||||
@ -317,7 +317,7 @@ TEST_F(RtpRtcpAudioTest, DTMF) {
|
||||
for (;timeStamp <= 250 * 160; timeStamp += 160) {
|
||||
EXPECT_EQ(0, module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96,
|
||||
timeStamp, -1, test, 4));
|
||||
fake_clock.IncrementTime(20);
|
||||
fake_clock.AdvanceTimeMilliseconds(20);
|
||||
module1->Process();
|
||||
}
|
||||
EXPECT_EQ(0, module1->SendTelephoneEventOutband(32, 9000, 10));
|
||||
@ -325,7 +325,7 @@ TEST_F(RtpRtcpAudioTest, DTMF) {
|
||||
for (;timeStamp <= 740 * 160; timeStamp += 160) {
|
||||
EXPECT_EQ(0, module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96,
|
||||
timeStamp, -1, test, 4));
|
||||
fake_clock.IncrementTime(20);
|
||||
fake_clock.AdvanceTimeMilliseconds(20);
|
||||
module1->Process();
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,12 @@ class NackLoopBackTransport : public webrtc::Transport {
|
||||
|
||||
class RtpRtcpNackTest : public ::testing::Test {
|
||||
protected:
|
||||
RtpRtcpNackTest() {}
|
||||
RtpRtcpNackTest()
|
||||
: video_module_(NULL),
|
||||
transport_(NULL),
|
||||
nack_receiver_(NULL),
|
||||
payload_data_length(sizeof(payload_data)),
|
||||
fake_clock(123456) {}
|
||||
~RtpRtcpNackTest() {}
|
||||
|
||||
virtual void SetUp() {
|
||||
@ -127,8 +132,6 @@ class RtpRtcpNackTest : public ::testing::Test {
|
||||
EXPECT_EQ(0, video_module_->RegisterSendPayload(video_codec));
|
||||
EXPECT_EQ(0, video_module_->RegisterReceivePayload(video_codec));
|
||||
|
||||
payload_data_length = sizeof(payload_data);
|
||||
|
||||
for (int n = 0; n < payload_data_length; n++) {
|
||||
payload_data[n] = n % 10;
|
||||
}
|
||||
@ -145,7 +148,7 @@ class RtpRtcpNackTest : public ::testing::Test {
|
||||
VerifyingNackReceiver* nack_receiver_;
|
||||
WebRtc_UWord8 payload_data[65000];
|
||||
int payload_data_length;
|
||||
FakeRtpRtcpClock fake_clock;
|
||||
SimulatedClock fake_clock;
|
||||
};
|
||||
|
||||
TEST_F(RtpRtcpNackTest, RTCP) {
|
||||
@ -185,7 +188,7 @@ TEST_F(RtpRtcpNackTest, RTCP) {
|
||||
nack_list[n++] = (*it);
|
||||
}
|
||||
video_module_->SendNACK(nack_list, n);
|
||||
fake_clock.IncrementTime(33);
|
||||
fake_clock.AdvanceTimeMilliseconds(33);
|
||||
video_module_->Process();
|
||||
|
||||
// Prepare next frame.
|
||||
@ -242,7 +245,7 @@ TEST_F(RtpRtcpNackTest, RTX) {
|
||||
nack_list[n++] = (*it);
|
||||
}
|
||||
video_module_->SendNACK(nack_list, n);
|
||||
fake_clock.IncrementTime(33);
|
||||
fake_clock.AdvanceTimeMilliseconds(33);
|
||||
video_module_->Process();
|
||||
|
||||
// Prepare next frame.
|
||||
|
@ -78,7 +78,7 @@ class RtcpCallback : public RtcpFeedback, public RtcpIntraFrameObserver {
|
||||
|
||||
class RtpRtcpRtcpTest : public ::testing::Test {
|
||||
protected:
|
||||
RtpRtcpRtcpTest() {
|
||||
RtpRtcpRtcpTest() : fake_clock(123456) {
|
||||
test_CSRC[0] = 1234;
|
||||
test_CSRC[1] = 2345;
|
||||
test_id = 123;
|
||||
@ -171,7 +171,7 @@ class RtpRtcpRtcpTest : public ::testing::Test {
|
||||
WebRtc_UWord32 test_timestamp;
|
||||
WebRtc_UWord16 test_sequence_number;
|
||||
WebRtc_UWord32 test_CSRC[webrtc::kRtpCsrcSize];
|
||||
FakeRtpRtcpClock fake_clock;
|
||||
SimulatedClock fake_clock;
|
||||
};
|
||||
|
||||
TEST_F(RtpRtcpRtcpTest, RTCP_PLI_RPSI) {
|
||||
@ -194,9 +194,9 @@ TEST_F(RtpRtcpRtcpTest, RTCP_CNAME) {
|
||||
EXPECT_EQ(0, module1->AddMixedCNAME(test_CSRC[1], "jane@192.168.0.2"));
|
||||
|
||||
// send RTCP packet, triggered by timer
|
||||
fake_clock.IncrementTime(7500);
|
||||
fake_clock.AdvanceTimeMilliseconds(7500);
|
||||
module1->Process();
|
||||
fake_clock.IncrementTime(100);
|
||||
fake_clock.AdvanceTimeMilliseconds(100);
|
||||
module2->Process();
|
||||
|
||||
char cName[RTCP_CNAME_SIZE];
|
||||
@ -251,9 +251,9 @@ TEST_F(RtpRtcpRtcpTest, RTCP) {
|
||||
300));
|
||||
|
||||
// send RTCP packet, triggered by timer
|
||||
fake_clock.IncrementTime(7500);
|
||||
fake_clock.AdvanceTimeMilliseconds(7500);
|
||||
module1->Process();
|
||||
fake_clock.IncrementTime(100);
|
||||
fake_clock.AdvanceTimeMilliseconds(100);
|
||||
module2->Process();
|
||||
|
||||
WebRtc_UWord32 receivedNTPsecs = 0;
|
||||
@ -318,7 +318,7 @@ TEST_F(RtpRtcpRtcpTest, RTCP) {
|
||||
EXPECT_EQ(0, module1->SetSendingStatus(false));
|
||||
|
||||
// Send RTCP packet, triggered by timer.
|
||||
fake_clock.IncrementTime(5000);
|
||||
fake_clock.AdvanceTimeMilliseconds(5000);
|
||||
module1->Process();
|
||||
module2->Process();
|
||||
}
|
||||
@ -330,9 +330,9 @@ TEST_F(RtpRtcpRtcpTest, RemoteRTCPStatRemote) {
|
||||
EXPECT_EQ(0u, report_blocks.size());
|
||||
|
||||
// send RTCP packet, triggered by timer
|
||||
fake_clock.IncrementTime(7500);
|
||||
fake_clock.AdvanceTimeMilliseconds(7500);
|
||||
module1->Process();
|
||||
fake_clock.IncrementTime(100);
|
||||
fake_clock.AdvanceTimeMilliseconds(100);
|
||||
module2->Process();
|
||||
|
||||
EXPECT_EQ(0, module1->RemoteRTCPStat(&report_blocks));
|
||||
|
@ -28,7 +28,8 @@ class RtpRtcpVideoTest : public ::testing::Test {
|
||||
: test_id_(123),
|
||||
test_ssrc_(3456),
|
||||
test_timestamp_(4567),
|
||||
test_sequence_number_(2345) {
|
||||
test_sequence_number_(2345),
|
||||
fake_clock(123456) {
|
||||
}
|
||||
~RtpRtcpVideoTest() {}
|
||||
|
||||
@ -124,7 +125,7 @@ class RtpRtcpVideoTest : public ::testing::Test {
|
||||
WebRtc_UWord16 test_sequence_number_;
|
||||
WebRtc_UWord8 video_frame_[65000];
|
||||
int payload_data_length_;
|
||||
FakeRtpRtcpClock fake_clock;
|
||||
SimulatedClock fake_clock;
|
||||
enum { kPayloadType = 100 };
|
||||
};
|
||||
|
||||
@ -157,7 +158,7 @@ TEST_F(RtpRtcpVideoTest, PaddingOnlyFrames) {
|
||||
EXPECT_EQ(packet_size - 12, receiver_->rtp_header().header.paddingLength);
|
||||
}
|
||||
timestamp += 3000;
|
||||
fake_clock.IncrementTime(33);
|
||||
fake_clock.AdvanceTimeMilliseconds(33);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
class TickTimeBase;
|
||||
class Clock;
|
||||
class VideoEncoder;
|
||||
class VideoDecoder;
|
||||
struct CodecSpecificInfo;
|
||||
@ -49,7 +49,7 @@ public:
|
||||
static VideoCodingModule* Create(const WebRtc_Word32 id);
|
||||
|
||||
static VideoCodingModule* Create(const WebRtc_Word32 id,
|
||||
TickTimeBase* clock);
|
||||
Clock* clock);
|
||||
|
||||
static void Destroy(VideoCodingModule* module);
|
||||
|
||||
|
@ -12,12 +12,12 @@
|
||||
#include "trace.h"
|
||||
#include "generic_decoder.h"
|
||||
#include "internal_defines.h"
|
||||
#include "tick_time_base.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming& timing,
|
||||
TickTimeBase* clock)
|
||||
Clock* clock)
|
||||
:
|
||||
_critSect(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_clock(clock),
|
||||
@ -56,7 +56,7 @@ WebRtc_Word32 VCMDecodedFrameCallback::Decoded(I420VideoFrame& decodedImage)
|
||||
_timing.StopDecodeTimer(
|
||||
decodedImage.timestamp(),
|
||||
frameInfo->decodeStartTimeMs,
|
||||
_clock->MillisecondTimestamp());
|
||||
_clock->TimeInMilliseconds());
|
||||
|
||||
if (_receiveCallback != NULL)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ struct VCMFrameInformation
|
||||
class VCMDecodedFrameCallback : public DecodedImageCallback
|
||||
{
|
||||
public:
|
||||
VCMDecodedFrameCallback(VCMTiming& timing, TickTimeBase* clock);
|
||||
VCMDecodedFrameCallback(VCMTiming& timing, Clock* clock);
|
||||
virtual ~VCMDecodedFrameCallback();
|
||||
void SetUserReceiveCallback(VCMReceiveCallback* receiveCallback);
|
||||
|
||||
@ -49,7 +49,7 @@ public:
|
||||
|
||||
private:
|
||||
CriticalSectionWrapper* _critSect;
|
||||
TickTimeBase* _clock;
|
||||
Clock* _clock;
|
||||
I420VideoFrame _frame;
|
||||
VCMReceiveCallback* _receiveCallback;
|
||||
VCMTiming& _timing;
|
||||
|
@ -12,16 +12,16 @@
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "modules/video_coding/main/source/event.h"
|
||||
#include "modules/video_coding/main/source/frame_buffer.h"
|
||||
#include "modules/video_coding/main/source/inter_frame_delay.h"
|
||||
#include "modules/video_coding/main/source/internal_defines.h"
|
||||
#include "modules/video_coding/main/source/jitter_buffer_common.h"
|
||||
#include "modules/video_coding/main/source/jitter_estimator.h"
|
||||
#include "modules/video_coding/main/source/packet.h"
|
||||
#include "modules/video_coding/main/source/tick_time_base.h"
|
||||
#include "system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "system_wrappers/interface/trace.h"
|
||||
#include "webrtc/modules/video_coding/main/source/event.h"
|
||||
#include "webrtc/modules/video_coding/main/source/frame_buffer.h"
|
||||
#include "webrtc/modules/video_coding/main/source/inter_frame_delay.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/jitter_estimator.h"
|
||||
#include "webrtc/modules/video_coding/main/source/packet.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -61,7 +61,7 @@ class CompleteDecodableKeyFrameCriteria {
|
||||
}
|
||||
};
|
||||
|
||||
VCMJitterBuffer::VCMJitterBuffer(TickTimeBase* clock,
|
||||
VCMJitterBuffer::VCMJitterBuffer(Clock* clock,
|
||||
int vcm_id,
|
||||
int receiver_id,
|
||||
bool master)
|
||||
@ -90,7 +90,7 @@ VCMJitterBuffer::VCMJitterBuffer(TickTimeBase* clock,
|
||||
num_consecutive_old_packets_(0),
|
||||
num_discarded_packets_(0),
|
||||
jitter_estimate_(vcm_id, receiver_id),
|
||||
inter_frame_delay_(clock_->MillisecondTimestamp()),
|
||||
inter_frame_delay_(clock_->TimeInMilliseconds()),
|
||||
rtt_ms_(kDefaultRtt),
|
||||
nack_mode_(kNoNack),
|
||||
low_rtt_nack_threshold_ms_(-1),
|
||||
@ -177,7 +177,7 @@ void VCMJitterBuffer::Start() {
|
||||
incoming_frame_rate_ = 0;
|
||||
incoming_bit_count_ = 0;
|
||||
incoming_bit_rate_ = 0;
|
||||
time_last_incoming_frame_count_ = clock_->MillisecondTimestamp();
|
||||
time_last_incoming_frame_count_ = clock_->TimeInMilliseconds();
|
||||
memset(receive_statistics_, 0, sizeof(receive_statistics_));
|
||||
|
||||
num_consecutive_old_frames_ = 0;
|
||||
@ -241,7 +241,7 @@ void VCMJitterBuffer::Flush() {
|
||||
num_consecutive_old_packets_ = 0;
|
||||
// Also reset the jitter and delay estimates
|
||||
jitter_estimate_.Reset();
|
||||
inter_frame_delay_.Reset(clock_->MillisecondTimestamp());
|
||||
inter_frame_delay_.Reset(clock_->TimeInMilliseconds());
|
||||
waiting_for_completion_.frame_size = 0;
|
||||
waiting_for_completion_.timestamp = 0;
|
||||
waiting_for_completion_.latest_packet_time = -1;
|
||||
@ -278,7 +278,7 @@ void VCMJitterBuffer::IncomingRateStatistics(unsigned int* framerate,
|
||||
assert(framerate);
|
||||
assert(bitrate);
|
||||
CriticalSectionScoped cs(crit_sect_);
|
||||
const int64_t now = clock_->MillisecondTimestamp();
|
||||
const int64_t now = clock_->TimeInMilliseconds();
|
||||
int64_t diff = now - time_last_incoming_frame_count_;
|
||||
if (diff < 1000 && incoming_frame_rate_ > 0 && incoming_bit_rate_ > 0) {
|
||||
// Make sure we report something even though less than
|
||||
@ -323,7 +323,7 @@ void VCMJitterBuffer::IncomingRateStatistics(unsigned int* framerate,
|
||||
|
||||
} else {
|
||||
// No frames since last call
|
||||
time_last_incoming_frame_count_ = clock_->MillisecondTimestamp();
|
||||
time_last_incoming_frame_count_ = clock_->TimeInMilliseconds();
|
||||
*framerate = 0;
|
||||
bitrate = 0;
|
||||
incoming_bit_rate_ = 0;
|
||||
@ -437,8 +437,8 @@ VCMEncodedFrame* VCMJitterBuffer::GetCompleteFrameForDecoding(
|
||||
crit_sect_->Leave();
|
||||
return NULL;
|
||||
}
|
||||
const int64_t end_wait_time_ms = clock_->MillisecondTimestamp()
|
||||
+ max_wait_time_ms;
|
||||
const int64_t end_wait_time_ms = clock_->TimeInMilliseconds() +
|
||||
max_wait_time_ms;
|
||||
int64_t wait_time_ms = max_wait_time_ms;
|
||||
while (wait_time_ms > 0) {
|
||||
crit_sect_->Leave();
|
||||
@ -457,8 +457,7 @@ VCMEncodedFrame* VCMJitterBuffer::GetCompleteFrameForDecoding(
|
||||
CleanUpOldFrames();
|
||||
it = FindOldestCompleteContinuousFrame(false);
|
||||
if (it == frame_list_.end()) {
|
||||
wait_time_ms = end_wait_time_ms -
|
||||
clock_->MillisecondTimestamp();
|
||||
wait_time_ms = end_wait_time_ms - clock_->TimeInMilliseconds();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@ -663,7 +662,7 @@ VCMFrameBufferEnum VCMJitterBuffer::InsertPacket(VCMEncodedFrame* encoded_frame,
|
||||
const VCMPacket& packet) {
|
||||
assert(encoded_frame);
|
||||
CriticalSectionScoped cs(crit_sect_);
|
||||
int64_t now_ms = clock_->MillisecondTimestamp();
|
||||
int64_t now_ms = clock_->TimeInMilliseconds();
|
||||
VCMFrameBufferEnum buffer_return = kSizeError;
|
||||
VCMFrameBufferEnum ret = kSizeError;
|
||||
VCMFrameBuffer* frame = static_cast<VCMFrameBuffer*>(encoded_frame);
|
||||
@ -673,7 +672,7 @@ VCMFrameBufferEnum VCMJitterBuffer::InsertPacket(VCMEncodedFrame* encoded_frame,
|
||||
if (first_packet_) {
|
||||
// Now it's time to start estimating jitter
|
||||
// reset the delay estimate.
|
||||
inter_frame_delay_.Reset(clock_->MillisecondTimestamp());
|
||||
inter_frame_delay_.Reset(clock_->TimeInMilliseconds());
|
||||
first_packet_ = false;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ enum VCMNackMode {
|
||||
typedef std::list<VCMFrameBuffer*> FrameList;
|
||||
|
||||
// forward declarations
|
||||
class TickTimeBase;
|
||||
class Clock;
|
||||
class VCMFrameBuffer;
|
||||
class VCMPacket;
|
||||
class VCMEncodedFrame;
|
||||
@ -49,7 +49,7 @@ struct VCMJitterSample {
|
||||
|
||||
class VCMJitterBuffer {
|
||||
public:
|
||||
VCMJitterBuffer(TickTimeBase* clock, int vcm_id = -1, int receiver_id = -1,
|
||||
VCMJitterBuffer(Clock* clock, int vcm_id = -1, int receiver_id = -1,
|
||||
bool master = true);
|
||||
virtual ~VCMJitterBuffer();
|
||||
|
||||
@ -206,7 +206,7 @@ class VCMJitterBuffer {
|
||||
|
||||
int vcm_id_;
|
||||
int receiver_id_;
|
||||
TickTimeBase* clock_;
|
||||
Clock* clock_;
|
||||
// If we are running (have started) or not.
|
||||
bool running_;
|
||||
CriticalSectionWrapper* crit_sect_;
|
||||
|
@ -15,8 +15,8 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "modules/video_coding/main/source/jitter_buffer.h"
|
||||
#include "modules/video_coding/main/source/media_opt_util.h"
|
||||
#include "modules/video_coding/main/source/mock/fake_tick_time.h"
|
||||
#include "modules/video_coding/main/source/packet.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -145,10 +145,10 @@ class TestRunningJitterBuffer : public ::testing::Test {
|
||||
enum { kDefaultFramePeriodMs = 1000 / kDefaultFrameRate };
|
||||
|
||||
virtual void SetUp() {
|
||||
clock_ = new FakeTickTime(0);
|
||||
jitter_buffer_ = new VCMJitterBuffer(clock_);
|
||||
clock_.reset(new SimulatedClock(0));
|
||||
jitter_buffer_ = new VCMJitterBuffer(clock_.get());
|
||||
stream_generator = new StreamGenerator(0, 0,
|
||||
clock_->MillisecondTimestamp());
|
||||
clock_->TimeInMilliseconds());
|
||||
jitter_buffer_->Start();
|
||||
memset(data_buffer_, 0, kDataBufferSize);
|
||||
}
|
||||
@ -157,7 +157,6 @@ class TestRunningJitterBuffer : public ::testing::Test {
|
||||
jitter_buffer_->Stop();
|
||||
delete stream_generator;
|
||||
delete jitter_buffer_;
|
||||
delete clock_;
|
||||
}
|
||||
|
||||
VCMFrameBufferEnum InsertPacketAndPop(int index) {
|
||||
@ -190,9 +189,9 @@ class TestRunningJitterBuffer : public ::testing::Test {
|
||||
stream_generator->GenerateFrame(frame_type,
|
||||
(frame_type != kFrameEmpty) ? 1 : 0,
|
||||
(frame_type == kFrameEmpty) ? 1 : 0,
|
||||
clock_->MillisecondTimestamp());
|
||||
clock_->TimeInMilliseconds());
|
||||
EXPECT_EQ(kFirstPacket, InsertPacketAndPop(0));
|
||||
clock_->IncrementDebugClock(kDefaultFramePeriodMs);
|
||||
clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs);
|
||||
}
|
||||
|
||||
void InsertFrames(int num_frames, FrameType frame_type) {
|
||||
@ -203,8 +202,8 @@ class TestRunningJitterBuffer : public ::testing::Test {
|
||||
|
||||
void DropFrame(int num_packets) {
|
||||
stream_generator->GenerateFrame(kVideoFrameDelta, num_packets, 0,
|
||||
clock_->MillisecondTimestamp());
|
||||
clock_->IncrementDebugClock(kDefaultFramePeriodMs);
|
||||
clock_->TimeInMilliseconds());
|
||||
clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs);
|
||||
}
|
||||
|
||||
bool DecodeCompleteFrame() {
|
||||
@ -223,7 +222,7 @@ class TestRunningJitterBuffer : public ::testing::Test {
|
||||
|
||||
VCMJitterBuffer* jitter_buffer_;
|
||||
StreamGenerator* stream_generator;
|
||||
FakeTickTime* clock_;
|
||||
scoped_ptr<SimulatedClock> clock_;
|
||||
uint8_t data_buffer_[kDataBufferSize];
|
||||
};
|
||||
|
||||
@ -258,7 +257,7 @@ TEST_F(TestRunningJitterBuffer, TestFull) {
|
||||
TEST_F(TestRunningJitterBuffer, TestEmptyPackets) {
|
||||
// Make sure a frame can get complete even though empty packets are missing.
|
||||
stream_generator->GenerateFrame(kVideoFrameKey, 3, 3,
|
||||
clock_->MillisecondTimestamp());
|
||||
clock_->TimeInMilliseconds());
|
||||
EXPECT_EQ(kFirstPacket, InsertPacketAndPop(4));
|
||||
EXPECT_EQ(kIncomplete, InsertPacketAndPop(4));
|
||||
EXPECT_EQ(kIncomplete, InsertPacketAndPop(0));
|
||||
@ -319,8 +318,8 @@ TEST_F(TestJitterBufferNack, TestNormalOperation) {
|
||||
// | 1 | 2 | .. | 8 | 9 | x | 11 | 12 | .. | 19 | x | 21 | .. | 100 |
|
||||
// ----------------------------------------------------------------
|
||||
stream_generator->GenerateFrame(kVideoFrameKey, 100, 0,
|
||||
clock_->MillisecondTimestamp());
|
||||
clock_->IncrementDebugClock(kDefaultFramePeriodMs);
|
||||
clock_->TimeInMilliseconds());
|
||||
clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs);
|
||||
EXPECT_EQ(kFirstPacket, InsertPacketAndPop(0));
|
||||
// Verify that the frame is incomplete.
|
||||
EXPECT_FALSE(DecodeCompleteFrame());
|
||||
@ -348,11 +347,11 @@ TEST_F(TestJitterBufferNack, TestNormalOperationWrap) {
|
||||
// ------- ------------------------------------------------------------
|
||||
// | 65532 | | 65533 | 65534 | 65535 | x | 1 | .. | 9 | x | 11 |.....| 96 |
|
||||
// ------- ------------------------------------------------------------
|
||||
stream_generator->Init(65532, 0, clock_->MillisecondTimestamp());
|
||||
stream_generator->Init(65532, 0, clock_->TimeInMilliseconds());
|
||||
InsertFrame(kVideoFrameKey);
|
||||
EXPECT_TRUE(DecodeCompleteFrame());
|
||||
stream_generator->GenerateFrame(kVideoFrameDelta, 100, 0,
|
||||
clock_->MillisecondTimestamp());
|
||||
clock_->TimeInMilliseconds());
|
||||
EXPECT_EQ(kFirstPacket, InsertPacketAndPop(0));
|
||||
while (stream_generator->PacketsRemaining() > 1) {
|
||||
if (stream_generator->NextSequenceNumber() % 10 != 0)
|
||||
|
@ -13,12 +13,12 @@
|
||||
#include "content_metrics_processing.h"
|
||||
#include "frame_dropper.h"
|
||||
#include "qm_select.h"
|
||||
#include "modules/video_coding/main/source/tick_time_base.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
VCMMediaOptimization::VCMMediaOptimization(WebRtc_Word32 id,
|
||||
TickTimeBase* clock):
|
||||
Clock* clock):
|
||||
_id(id),
|
||||
_clock(clock),
|
||||
_maxBitRate(0),
|
||||
@ -46,7 +46,7 @@ _numLayers(0)
|
||||
memset(_incomingFrameTimes, -1, sizeof(_incomingFrameTimes));
|
||||
|
||||
_frameDropper = new VCMFrameDropper(_id);
|
||||
_lossProtLogic = new VCMLossProtectionLogic(_clock->MillisecondTimestamp());
|
||||
_lossProtLogic = new VCMLossProtectionLogic(_clock->TimeInMilliseconds());
|
||||
_content = new VCMContentMetricsProcessing();
|
||||
_qmResolution = new VCMQmResolution();
|
||||
}
|
||||
@ -66,12 +66,12 @@ VCMMediaOptimization::Reset()
|
||||
memset(_incomingFrameTimes, -1, sizeof(_incomingFrameTimes));
|
||||
_incomingFrameRate = 0.0;
|
||||
_frameDropper->Reset();
|
||||
_lossProtLogic->Reset(_clock->MillisecondTimestamp());
|
||||
_lossProtLogic->Reset(_clock->TimeInMilliseconds());
|
||||
_frameDropper->SetRates(0, 0);
|
||||
_content->Reset();
|
||||
_qmResolution->Reset();
|
||||
_lossProtLogic->UpdateFrameRate(_incomingFrameRate);
|
||||
_lossProtLogic->Reset(_clock->MillisecondTimestamp());
|
||||
_lossProtLogic->Reset(_clock->TimeInMilliseconds());
|
||||
_sendStatisticsZeroEncode = 0;
|
||||
_targetBitRate = 0;
|
||||
_codecWidth = 0;
|
||||
@ -122,7 +122,7 @@ VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 bitRate,
|
||||
// Use max window filter for now.
|
||||
FilterPacketLossMode filter_mode = kMaxFilter;
|
||||
WebRtc_UWord8 packetLossEnc = _lossProtLogic->FilteredLoss(
|
||||
_clock->MillisecondTimestamp(), filter_mode, fractionLost);
|
||||
_clock->TimeInMilliseconds(), filter_mode, fractionLost);
|
||||
|
||||
// For now use the filtered loss for computing the robustness settings
|
||||
_lossProtLogic->UpdateFilteredLossPr(packetLossEnc);
|
||||
@ -274,7 +274,7 @@ VCMMediaOptimization::SetEncodingData(VideoCodecType sendCodecType,
|
||||
// has changed. If native dimension values have changed, then either user
|
||||
// initiated change, or QM initiated change. Will be able to determine only
|
||||
// after the processing of the first frame.
|
||||
_lastChangeTime = _clock->MillisecondTimestamp();
|
||||
_lastChangeTime = _clock->TimeInMilliseconds();
|
||||
_content->Reset();
|
||||
_content->UpdateFrameRate(frameRate);
|
||||
|
||||
@ -359,7 +359,7 @@ VCMMediaOptimization::SentFrameRate()
|
||||
float
|
||||
VCMMediaOptimization::SentBitRate()
|
||||
{
|
||||
UpdateBitRateEstimate(-1, _clock->MillisecondTimestamp());
|
||||
UpdateBitRateEstimate(-1, _clock->TimeInMilliseconds());
|
||||
return _avgSentBitRateBps / 1000.0f;
|
||||
}
|
||||
|
||||
@ -374,7 +374,7 @@ VCMMediaOptimization::UpdateWithEncodedData(WebRtc_Word32 encodedLength,
|
||||
FrameType encodedFrameType)
|
||||
{
|
||||
// look into the ViE version - debug mode - needs also number of layers.
|
||||
UpdateBitRateEstimate(encodedLength, _clock->MillisecondTimestamp());
|
||||
UpdateBitRateEstimate(encodedLength, _clock->TimeInMilliseconds());
|
||||
if(encodedLength > 0)
|
||||
{
|
||||
const bool deltaFrame = (encodedFrameType != kVideoFrameKey &&
|
||||
@ -388,12 +388,12 @@ VCMMediaOptimization::UpdateWithEncodedData(WebRtc_Word32 encodedLength,
|
||||
if (deltaFrame)
|
||||
{
|
||||
_lossProtLogic->UpdatePacketsPerFrame(
|
||||
minPacketsPerFrame, _clock->MillisecondTimestamp());
|
||||
minPacketsPerFrame, _clock->TimeInMilliseconds());
|
||||
}
|
||||
else
|
||||
{
|
||||
_lossProtLogic->UpdatePacketsPerFrameKey(
|
||||
minPacketsPerFrame, _clock->MillisecondTimestamp());
|
||||
minPacketsPerFrame, _clock->TimeInMilliseconds());
|
||||
}
|
||||
|
||||
if (_enableQm)
|
||||
@ -544,7 +544,7 @@ VCMMediaOptimization::SelectQuality()
|
||||
_qmResolution->ResetRates();
|
||||
|
||||
// Reset counters
|
||||
_lastQMUpdateTime = _clock->MillisecondTimestamp();
|
||||
_lastQMUpdateTime = _clock->TimeInMilliseconds();
|
||||
|
||||
// Reset content metrics
|
||||
_content->Reset();
|
||||
@ -567,7 +567,7 @@ VCMMediaOptimization::checkStatusForQMchange()
|
||||
// (to sample the metrics) from the event lastChangeTime
|
||||
// lastChangeTime is the time where user changed the size/rate/frame rate
|
||||
// (via SetEncodingData)
|
||||
WebRtc_Word64 now = _clock->MillisecondTimestamp();
|
||||
WebRtc_Word64 now = _clock->TimeInMilliseconds();
|
||||
if ((now - _lastQMUpdateTime) < kQmMinIntervalMs ||
|
||||
(now - _lastChangeTime) < kQmMinIntervalMs)
|
||||
{
|
||||
@ -619,7 +619,7 @@ bool VCMMediaOptimization::QMUpdate(VCMResolutionScale* qm) {
|
||||
void
|
||||
VCMMediaOptimization::UpdateIncomingFrameRate()
|
||||
{
|
||||
WebRtc_Word64 now = _clock->MillisecondTimestamp();
|
||||
WebRtc_Word64 now = _clock->TimeInMilliseconds();
|
||||
if (_incomingFrameTimes[0] == 0)
|
||||
{
|
||||
// first no shift
|
||||
@ -667,7 +667,7 @@ VCMMediaOptimization::ProcessIncomingFrameRate(WebRtc_Word64 now)
|
||||
WebRtc_UWord32
|
||||
VCMMediaOptimization::InputFrameRate()
|
||||
{
|
||||
ProcessIncomingFrameRate(_clock->MillisecondTimestamp());
|
||||
ProcessIncomingFrameRate(_clock->TimeInMilliseconds());
|
||||
return WebRtc_UWord32 (_incomingFrameRate + 0.5f);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace webrtc
|
||||
enum { kBitrateMaxFrameSamples = 60 };
|
||||
enum { kBitrateAverageWinMs = 1000 };
|
||||
|
||||
class TickTimeBase;
|
||||
class Clock;
|
||||
class VCMContentMetricsProcessing;
|
||||
class VCMFrameDropper;
|
||||
|
||||
@ -38,7 +38,7 @@ struct VCMEncodedFrameSample
|
||||
class VCMMediaOptimization
|
||||
{
|
||||
public:
|
||||
VCMMediaOptimization(WebRtc_Word32 id, TickTimeBase* clock);
|
||||
VCMMediaOptimization(WebRtc_Word32 id, Clock* clock);
|
||||
~VCMMediaOptimization(void);
|
||||
/*
|
||||
* Reset the Media Optimization module
|
||||
@ -163,7 +163,7 @@ private:
|
||||
enum { kFrameHistoryWinMs = 2000};
|
||||
|
||||
WebRtc_Word32 _id;
|
||||
TickTimeBase* _clock;
|
||||
Clock* _clock;
|
||||
WebRtc_Word32 _maxBitRate;
|
||||
VideoCodecType _sendCodecType;
|
||||
WebRtc_UWord16 _codecWidth;
|
||||
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2011 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.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_MOCK_FAKE_TICK_TIME_H_
|
||||
#define WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_MOCK_FAKE_TICK_TIME_H_
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "modules/video_coding/main/source/tick_time_base.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Provides a fake implementation of TickTimeBase, intended for offline
|
||||
// testing. This implementation does not query the system clock, but returns a
|
||||
// time value set by the user when creating the object, and incremented with
|
||||
// the method IncrementDebugClock.
|
||||
class FakeTickTime : public TickTimeBase {
|
||||
public:
|
||||
explicit FakeTickTime(int64_t start_time_ms) : fake_now_ms_(start_time_ms) {}
|
||||
virtual ~FakeTickTime() {}
|
||||
virtual int64_t MillisecondTimestamp() const {
|
||||
return fake_now_ms_;
|
||||
}
|
||||
virtual int64_t MicrosecondTimestamp() const {
|
||||
return 1000 * fake_now_ms_;
|
||||
}
|
||||
virtual void IncrementDebugClock(int64_t increase_ms) {
|
||||
assert(increase_ms <= std::numeric_limits<int64_t>::max() - fake_now_ms_);
|
||||
fake_now_ms_ += increase_ms;
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t fake_now_ms_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_MOCK_FAKE_TICK_TIME_H_
|
@ -16,13 +16,13 @@
|
||||
#include "webrtc/modules/video_coding/main/source/encoded_frame.h"
|
||||
#include "webrtc/modules/video_coding/main/source/internal_defines.h"
|
||||
#include "webrtc/modules/video_coding/main/source/media_opt_util.h"
|
||||
#include "webrtc/modules/video_coding/main/source/tick_time_base.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
VCMReceiver::VCMReceiver(VCMTiming* timing,
|
||||
TickTimeBase* clock,
|
||||
Clock* clock,
|
||||
int32_t vcm_id,
|
||||
int32_t receiver_id,
|
||||
bool master)
|
||||
@ -95,10 +95,10 @@ int32_t VCMReceiver::InsertPacket(const VCMPacket& packet, uint16_t frame_width,
|
||||
VCMId(vcm_id_, receiver_id_),
|
||||
"Packet seq_no %u of frame %u at %u",
|
||||
packet.seqNum, packet.timestamp,
|
||||
MaskWord64ToUWord32(clock_->MillisecondTimestamp()));
|
||||
MaskWord64ToUWord32(clock_->TimeInMilliseconds()));
|
||||
}
|
||||
|
||||
const int64_t now_ms = clock_->MillisecondTimestamp();
|
||||
const int64_t now_ms = clock_->TimeInMilliseconds();
|
||||
|
||||
int64_t render_time_ms = timing_->RenderTimeMs(packet.timestamp, now_ms);
|
||||
|
||||
@ -106,7 +106,7 @@ int32_t VCMReceiver::InsertPacket(const VCMPacket& packet, uint16_t frame_width,
|
||||
// Render time error. Assume that this is due to some change in the
|
||||
// incoming video stream and reset the JB and the timing.
|
||||
jitter_buffer_.Flush();
|
||||
timing_->Reset(clock_->MillisecondTimestamp());
|
||||
timing_->Reset(clock_->TimeInMilliseconds());
|
||||
return VCM_FLUSH_INDICATOR;
|
||||
} else if (render_time_ms < now_ms - kMaxVideoDelayMs) {
|
||||
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCoding,
|
||||
@ -115,7 +115,7 @@ int32_t VCMReceiver::InsertPacket(const VCMPacket& packet, uint16_t frame_width,
|
||||
"Flushing jitter buffer and resetting timing.",
|
||||
kMaxVideoDelayMs);
|
||||
jitter_buffer_.Flush();
|
||||
timing_->Reset(clock_->MillisecondTimestamp());
|
||||
timing_->Reset(clock_->TimeInMilliseconds());
|
||||
return VCM_FLUSH_INDICATOR;
|
||||
} else if (timing_->TargetVideoDelay() > kMaxVideoDelayMs) {
|
||||
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCoding,
|
||||
@ -123,13 +123,13 @@ int32_t VCMReceiver::InsertPacket(const VCMPacket& packet, uint16_t frame_width,
|
||||
"More than %u ms target delay. Flushing jitter buffer and"
|
||||
"resetting timing.", kMaxVideoDelayMs);
|
||||
jitter_buffer_.Flush();
|
||||
timing_->Reset(clock_->MillisecondTimestamp());
|
||||
timing_->Reset(clock_->TimeInMilliseconds());
|
||||
return VCM_FLUSH_INDICATOR;
|
||||
}
|
||||
|
||||
// First packet received belonging to this frame.
|
||||
if (buffer->Length() == 0) {
|
||||
const int64_t now_ms = clock_->MillisecondTimestamp();
|
||||
const int64_t now_ms = clock_->TimeInMilliseconds();
|
||||
if (master_) {
|
||||
// Only trace the primary receiver to make it possible to parse and plot
|
||||
// the trace file.
|
||||
@ -171,7 +171,7 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(
|
||||
// is thread-safe.
|
||||
FrameType incoming_frame_type = kVideoFrameDelta;
|
||||
next_render_time_ms = -1;
|
||||
const int64_t start_time_ms = clock_->MillisecondTimestamp();
|
||||
const int64_t start_time_ms = clock_->TimeInMilliseconds();
|
||||
int64_t ret = jitter_buffer_.NextTimestamp(max_wait_time_ms,
|
||||
&incoming_frame_type,
|
||||
&next_render_time_ms);
|
||||
@ -186,7 +186,7 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(
|
||||
timing_->UpdateCurrentDelay(time_stamp);
|
||||
|
||||
const int32_t temp_wait_time = max_wait_time_ms -
|
||||
static_cast<int32_t>(clock_->MillisecondTimestamp() - start_time_ms);
|
||||
static_cast<int32_t>(clock_->TimeInMilliseconds() - start_time_ms);
|
||||
uint16_t new_max_wait_time = static_cast<uint16_t>(VCM_MAX(temp_wait_time,
|
||||
0));
|
||||
|
||||
@ -223,7 +223,7 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(
|
||||
VCMReceiver* dual_receiver) {
|
||||
// How long can we wait until we must decode the next frame.
|
||||
uint32_t wait_time_ms = timing_->MaxWaitingTime(
|
||||
next_render_time_ms, clock_->MillisecondTimestamp());
|
||||
next_render_time_ms, clock_->TimeInMilliseconds());
|
||||
|
||||
// Try to get a complete frame from the jitter buffer.
|
||||
VCMEncodedFrame* frame = jitter_buffer_.GetCompleteFrameForDecoding(0);
|
||||
@ -257,7 +257,7 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(
|
||||
if (frame == NULL) {
|
||||
// Get an incomplete frame.
|
||||
if (timing_->MaxWaitingTime(next_render_time_ms,
|
||||
clock_->MillisecondTimestamp()) > 0) {
|
||||
clock_->TimeInMilliseconds()) > 0) {
|
||||
// Still time to wait for a complete frame.
|
||||
return NULL;
|
||||
}
|
||||
@ -286,7 +286,7 @@ VCMEncodedFrame* VCMReceiver::FrameForRendering(uint16_t max_wait_time_ms,
|
||||
// frame to the decoder, which will render the frame as soon as it has been
|
||||
// decoded.
|
||||
uint32_t wait_time_ms = timing_->MaxWaitingTime(
|
||||
next_render_time_ms, clock_->MillisecondTimestamp());
|
||||
next_render_time_ms, clock_->TimeInMilliseconds());
|
||||
if (max_wait_time_ms < wait_time_ms) {
|
||||
// If we're not allowed to wait until the frame is supposed to be rendered
|
||||
// we will have to return NULL for now.
|
||||
|
@ -14,11 +14,11 @@
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/modules/video_coding/main/source/jitter_buffer.h"
|
||||
#include "webrtc/modules/video_coding/main/source/packet.h"
|
||||
#include "webrtc/modules/video_coding/main/source/tick_time_base.h"
|
||||
#include "webrtc/modules/video_coding/main/source/timing.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class Clock;
|
||||
class VCMEncodedFrame;
|
||||
|
||||
enum VCMNackStatus {
|
||||
@ -36,7 +36,7 @@ enum VCMReceiverState {
|
||||
class VCMReceiver {
|
||||
public:
|
||||
VCMReceiver(VCMTiming* timing,
|
||||
TickTimeBase* clock,
|
||||
Clock* clock,
|
||||
int32_t vcm_id = -1,
|
||||
int32_t receiver_id = -1,
|
||||
bool master = true);
|
||||
@ -81,7 +81,7 @@ class VCMReceiver {
|
||||
|
||||
CriticalSectionWrapper* crit_sect_;
|
||||
int32_t vcm_id_;
|
||||
TickTimeBase* clock_;
|
||||
Clock* clock_;
|
||||
int32_t receiver_id_;
|
||||
bool master_;
|
||||
VCMJitterBuffer jitter_buffer_;
|
||||
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2011 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.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_TICK_TIME_BASE_H_
|
||||
#define WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_TICK_TIME_BASE_H_
|
||||
|
||||
#include "system_wrappers/interface/tick_util.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// This class provides a mockable wrapper to TickTime.
|
||||
class TickTimeBase {
|
||||
public:
|
||||
virtual ~TickTimeBase() {}
|
||||
|
||||
// "Now" in milliseconds.
|
||||
virtual int64_t MillisecondTimestamp() const {
|
||||
return TickTime::MillisecondTimestamp();
|
||||
}
|
||||
|
||||
// "Now" in microseconds.
|
||||
virtual int64_t MicrosecondTimestamp() const {
|
||||
return TickTime::MicrosecondTimestamp();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_TICK_TIME_BASE_H_
|
@ -9,13 +9,13 @@
|
||||
*/
|
||||
|
||||
#include "internal_defines.h"
|
||||
#include "modules/video_coding/main/source/tick_time_base.h"
|
||||
#include "timestamp_extrapolator.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
VCMTimestampExtrapolator::VCMTimestampExtrapolator(TickTimeBase* clock,
|
||||
VCMTimestampExtrapolator::VCMTimestampExtrapolator(Clock* clock,
|
||||
WebRtc_Word32 vcmId,
|
||||
WebRtc_Word32 id)
|
||||
:
|
||||
@ -38,7 +38,7 @@ _accDrift(6600), // in timestamp ticks, i.e. 15 ms
|
||||
_accMaxError(7000),
|
||||
_P11(1e10)
|
||||
{
|
||||
Reset(_clock->MillisecondTimestamp());
|
||||
Reset(_clock->TimeInMilliseconds());
|
||||
}
|
||||
|
||||
VCMTimestampExtrapolator::~VCMTimestampExtrapolator()
|
||||
@ -56,7 +56,7 @@ VCMTimestampExtrapolator::Reset(const WebRtc_Word64 nowMs /* = -1 */)
|
||||
}
|
||||
else
|
||||
{
|
||||
_startMs = _clock->MillisecondTimestamp();
|
||||
_startMs = _clock->TimeInMilliseconds();
|
||||
}
|
||||
_prevMs = _startMs;
|
||||
_firstTimestamp = 0;
|
||||
|
@ -17,12 +17,12 @@
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
class TickTimeBase;
|
||||
class Clock;
|
||||
|
||||
class VCMTimestampExtrapolator
|
||||
{
|
||||
public:
|
||||
VCMTimestampExtrapolator(TickTimeBase* clock,
|
||||
VCMTimestampExtrapolator(Clock* clock,
|
||||
WebRtc_Word32 vcmId = 0,
|
||||
WebRtc_Word32 receiverId = 0);
|
||||
~VCMTimestampExtrapolator();
|
||||
@ -37,16 +37,16 @@ private:
|
||||
RWLockWrapper* _rwLock;
|
||||
WebRtc_Word32 _vcmId;
|
||||
WebRtc_Word32 _id;
|
||||
TickTimeBase* _clock;
|
||||
double _w[2];
|
||||
double _P[2][2];
|
||||
Clock* _clock;
|
||||
double _w[2];
|
||||
double _P[2][2];
|
||||
WebRtc_Word64 _startMs;
|
||||
WebRtc_Word64 _prevMs;
|
||||
WebRtc_UWord32 _firstTimestamp;
|
||||
WebRtc_Word32 _wrapArounds;
|
||||
WebRtc_UWord32 _prevTs90khz;
|
||||
const double _lambda;
|
||||
bool _firstAfterReset;
|
||||
const double _lambda;
|
||||
bool _firstAfterReset;
|
||||
WebRtc_UWord32 _packetCount;
|
||||
const WebRtc_UWord32 _startUpFilterDelayInPackets;
|
||||
|
||||
|
@ -8,15 +8,17 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "trace.h"
|
||||
#include "internal_defines.h"
|
||||
#include "jitter_buffer_common.h"
|
||||
#include "timing.h"
|
||||
#include "timestamp_extrapolator.h"
|
||||
#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/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
VCMTiming::VCMTiming(TickTimeBase* clock,
|
||||
VCMTiming::VCMTiming(Clock* clock,
|
||||
WebRtc_Word32 vcmId,
|
||||
WebRtc_Word32 timingId,
|
||||
VCMTiming* masterTiming)
|
||||
|
@ -18,7 +18,7 @@
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
class TickTimeBase;
|
||||
class Clock;
|
||||
class VCMTimestampExtrapolator;
|
||||
|
||||
class VCMTiming
|
||||
@ -26,7 +26,7 @@ class VCMTiming
|
||||
public:
|
||||
// The primary timing component should be passed
|
||||
// if this is the dual timing component.
|
||||
VCMTiming(TickTimeBase* clock,
|
||||
VCMTiming(Clock* clock,
|
||||
WebRtc_Word32 vcmId = 0,
|
||||
WebRtc_Word32 timingId = 0,
|
||||
VCMTiming* masterTiming = NULL);
|
||||
@ -94,7 +94,7 @@ protected:
|
||||
private:
|
||||
CriticalSectionWrapper* _critSect;
|
||||
WebRtc_Word32 _vcmId;
|
||||
TickTimeBase* _clock;
|
||||
Clock* _clock;
|
||||
WebRtc_Word32 _timingId;
|
||||
bool _master;
|
||||
VCMTimestampExtrapolator* _tsExtrapolator;
|
||||
|
@ -62,7 +62,6 @@
|
||||
'receiver.h',
|
||||
'rtt_filter.h',
|
||||
'session_info.h',
|
||||
'tick_time_base.h',
|
||||
'timestamp_extrapolator.h',
|
||||
'timestamp_map.h',
|
||||
'timing.h',
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "packet.h"
|
||||
#include "trace.h"
|
||||
#include "video_codec_interface.h"
|
||||
#include "modules/video_coding/main/source/tick_time_base.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
@ -34,22 +34,20 @@ VCMProcessTimer::TimeUntilProcess() const
|
||||
{
|
||||
return static_cast<WebRtc_UWord32>(
|
||||
VCM_MAX(static_cast<WebRtc_Word64>(_periodMs) -
|
||||
(_clock->MillisecondTimestamp() - _latestMs), 0));
|
||||
(_clock->TimeInMilliseconds() - _latestMs), 0));
|
||||
}
|
||||
|
||||
void
|
||||
VCMProcessTimer::Processed()
|
||||
{
|
||||
_latestMs = _clock->MillisecondTimestamp();
|
||||
_latestMs = _clock->TimeInMilliseconds();
|
||||
}
|
||||
|
||||
VideoCodingModuleImpl::VideoCodingModuleImpl(const WebRtc_Word32 id,
|
||||
TickTimeBase* clock,
|
||||
bool delete_clock_on_destroy)
|
||||
Clock* clock)
|
||||
:
|
||||
_id(id),
|
||||
clock_(clock),
|
||||
delete_clock_on_destroy_(delete_clock_on_destroy),
|
||||
_receiveCritSect(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_receiverInited(false),
|
||||
_timing(clock_, id, 1),
|
||||
@ -99,7 +97,6 @@ VideoCodingModuleImpl::~VideoCodingModuleImpl()
|
||||
}
|
||||
delete _receiveCritSect;
|
||||
delete _sendCritSect;
|
||||
if (delete_clock_on_destroy_) delete clock_;
|
||||
#ifdef DEBUG_DECODER_BIT_STREAM
|
||||
fclose(_bitStreamBeforeDecoder);
|
||||
#endif
|
||||
@ -112,14 +109,14 @@ VideoCodingModuleImpl::~VideoCodingModuleImpl()
|
||||
VideoCodingModule*
|
||||
VideoCodingModule::Create(const WebRtc_Word32 id)
|
||||
{
|
||||
return new VideoCodingModuleImpl(id, new TickTimeBase(), true);
|
||||
return new VideoCodingModuleImpl(id, Clock::GetRealTimeClock());
|
||||
}
|
||||
|
||||
VideoCodingModule*
|
||||
VideoCodingModule::Create(const WebRtc_Word32 id, TickTimeBase* clock)
|
||||
VideoCodingModule::Create(const WebRtc_Word32 id, Clock* clock)
|
||||
{
|
||||
assert(clock);
|
||||
return new VideoCodingModuleImpl(id, clock, false);
|
||||
return new VideoCodingModuleImpl(id, clock);
|
||||
}
|
||||
|
||||
void
|
||||
@ -890,7 +887,7 @@ VideoCodingModuleImpl::Decode(WebRtc_UWord16 maxWaitTimeMs)
|
||||
|
||||
// If this frame was too late, we should adjust the delay accordingly
|
||||
_timing.UpdateCurrentDelay(frame->RenderTimeMs(),
|
||||
clock_->MillisecondTimestamp());
|
||||
clock_->TimeInMilliseconds());
|
||||
|
||||
#ifdef DEBUG_DECODER_BIT_STREAM
|
||||
if (_bitStreamBeforeDecoder != NULL)
|
||||
@ -1001,7 +998,7 @@ VideoCodingModuleImpl::DecodeDualFrame(WebRtc_UWord16 maxWaitTimeMs)
|
||||
dualFrame->TimeStamp());
|
||||
// Decode dualFrame and try to catch up
|
||||
WebRtc_Word32 ret = _dualDecoder->Decode(*dualFrame,
|
||||
clock_->MillisecondTimestamp());
|
||||
clock_->TimeInMilliseconds());
|
||||
if (ret != WEBRTC_VIDEO_CODEC_OK)
|
||||
{
|
||||
WEBRTC_TRACE(webrtc::kTraceWarning,
|
||||
@ -1049,7 +1046,7 @@ VideoCodingModuleImpl::Decode(const VCMEncodedFrame& frame)
|
||||
return VCM_NO_CODEC_REGISTERED;
|
||||
}
|
||||
// Decode a frame
|
||||
WebRtc_Word32 ret = _decoder->Decode(frame, clock_->MillisecondTimestamp());
|
||||
WebRtc_Word32 ret = _decoder->Decode(frame, clock_->TimeInMilliseconds());
|
||||
|
||||
// Check for failed decoding, run frame type request callback if needed.
|
||||
if (ret < 0)
|
||||
|
@ -15,16 +15,16 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "modules/video_coding/main/source/codec_database.h"
|
||||
#include "modules/video_coding/main/source/frame_buffer.h"
|
||||
#include "modules/video_coding/main/source/generic_decoder.h"
|
||||
#include "modules/video_coding/main/source/generic_encoder.h"
|
||||
#include "modules/video_coding/main/source/jitter_buffer.h"
|
||||
#include "modules/video_coding/main/source/media_optimization.h"
|
||||
#include "modules/video_coding/main/source/receiver.h"
|
||||
#include "modules/video_coding/main/source/tick_time_base.h"
|
||||
#include "modules/video_coding/main/source/timing.h"
|
||||
#include "system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/modules/video_coding/main/source/codec_database.h"
|
||||
#include "webrtc/modules/video_coding/main/source/frame_buffer.h"
|
||||
#include "webrtc/modules/video_coding/main/source/generic_decoder.h"
|
||||
#include "webrtc/modules/video_coding/main/source/generic_encoder.h"
|
||||
#include "webrtc/modules/video_coding/main/source/jitter_buffer.h"
|
||||
#include "webrtc/modules/video_coding/main/source/media_optimization.h"
|
||||
#include "webrtc/modules/video_coding/main/source/receiver.h"
|
||||
#include "webrtc/modules/video_coding/main/source/timing.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
@ -32,16 +32,16 @@ namespace webrtc
|
||||
class VCMProcessTimer
|
||||
{
|
||||
public:
|
||||
VCMProcessTimer(WebRtc_UWord32 periodMs, TickTimeBase* clock)
|
||||
VCMProcessTimer(WebRtc_UWord32 periodMs, Clock* clock)
|
||||
: _clock(clock),
|
||||
_periodMs(periodMs),
|
||||
_latestMs(_clock->MillisecondTimestamp()) {}
|
||||
_latestMs(_clock->TimeInMilliseconds()) {}
|
||||
WebRtc_UWord32 Period() const;
|
||||
WebRtc_UWord32 TimeUntilProcess() const;
|
||||
void Processed();
|
||||
|
||||
private:
|
||||
TickTimeBase* _clock;
|
||||
Clock* _clock;
|
||||
WebRtc_UWord32 _periodMs;
|
||||
WebRtc_Word64 _latestMs;
|
||||
};
|
||||
@ -59,8 +59,7 @@ class VideoCodingModuleImpl : public VideoCodingModule
|
||||
{
|
||||
public:
|
||||
VideoCodingModuleImpl(const WebRtc_Word32 id,
|
||||
TickTimeBase* clock,
|
||||
bool delete_clock_on_destroy);
|
||||
Clock* clock);
|
||||
|
||||
virtual ~VideoCodingModuleImpl();
|
||||
|
||||
@ -275,8 +274,7 @@ protected:
|
||||
|
||||
private:
|
||||
WebRtc_Word32 _id;
|
||||
TickTimeBase* clock_;
|
||||
bool delete_clock_on_destroy_;
|
||||
Clock* clock_;
|
||||
CriticalSectionWrapper* _receiveCritSect;
|
||||
bool _receiverInited;
|
||||
VCMTiming _timing;
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "modules/video_coding/codecs/interface/mock/mock_video_codec_interface.h"
|
||||
#include "modules/video_coding/main/interface/video_coding.h"
|
||||
#include "modules/video_coding/main/interface/mock/mock_vcm_callbacks.h"
|
||||
#include "modules/video_coding/main/source/mock/fake_tick_time.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -32,9 +32,9 @@ class VCMRobustnessTest : public ::testing::Test {
|
||||
static const size_t kPayloadLen = 10;
|
||||
|
||||
virtual void SetUp() {
|
||||
clock_ = new FakeTickTime(0);
|
||||
ASSERT_TRUE(clock_ != NULL);
|
||||
vcm_ = VideoCodingModule::Create(0, clock_);
|
||||
clock_.reset(new SimulatedClock(0));
|
||||
ASSERT_TRUE(clock_.get() != NULL);
|
||||
vcm_ = VideoCodingModule::Create(0, clock_.get());
|
||||
ASSERT_TRUE(vcm_ != NULL);
|
||||
ASSERT_EQ(0, vcm_->InitializeReceiver());
|
||||
ASSERT_EQ(0, vcm_->RegisterFrameTypeCallback(&frame_type_callback_));
|
||||
@ -48,7 +48,6 @@ class VCMRobustnessTest : public ::testing::Test {
|
||||
|
||||
virtual void TearDown() {
|
||||
VideoCodingModule::Destroy(vcm_);
|
||||
delete clock_;
|
||||
}
|
||||
|
||||
void InsertPacket(uint32_t timestamp,
|
||||
@ -77,7 +76,7 @@ class VCMRobustnessTest : public ::testing::Test {
|
||||
MockPacketRequestCallback request_callback_;
|
||||
NiceMock<MockVideoDecoder> decoder_;
|
||||
NiceMock<MockVideoDecoder> decoderCopy_;
|
||||
FakeTickTime* clock_;
|
||||
scoped_ptr<SimulatedClock> clock_;
|
||||
};
|
||||
|
||||
TEST_F(VCMRobustnessTest, TestHardNack) {
|
||||
@ -112,21 +111,21 @@ TEST_F(VCMRobustnessTest, TestHardNack) {
|
||||
ASSERT_EQ(VCM_OK, vcm_->Decode(0));
|
||||
ASSERT_EQ(VCM_FRAME_NOT_READY, vcm_->Decode(0));
|
||||
|
||||
clock_->IncrementDebugClock(10);
|
||||
clock_->AdvanceTimeMilliseconds(10);
|
||||
|
||||
ASSERT_EQ(VCM_OK, vcm_->Process());
|
||||
|
||||
ASSERT_EQ(VCM_FRAME_NOT_READY, vcm_->Decode(0));
|
||||
|
||||
InsertPacket(6000, 8, false, true, kVideoFrameDelta);
|
||||
clock_->IncrementDebugClock(10);
|
||||
clock_->AdvanceTimeMilliseconds(10);
|
||||
ASSERT_EQ(VCM_OK, vcm_->Process());
|
||||
|
||||
ASSERT_EQ(VCM_FRAME_NOT_READY, vcm_->Decode(0));
|
||||
|
||||
InsertPacket(6000, 6, true, false, kVideoFrameDelta);
|
||||
InsertPacket(6000, 7, false, false, kVideoFrameDelta);
|
||||
clock_->IncrementDebugClock(10);
|
||||
clock_->AdvanceTimeMilliseconds(10);
|
||||
ASSERT_EQ(VCM_OK, vcm_->Process());
|
||||
|
||||
ASSERT_EQ(VCM_OK, vcm_->Decode(0));
|
||||
@ -149,7 +148,7 @@ TEST_F(VCMRobustnessTest, TestHardNackNoneDecoded) {
|
||||
EXPECT_EQ(VCM_FRAME_NOT_READY, vcm_->Decode(0));
|
||||
ASSERT_EQ(VCM_OK, vcm_->Process());
|
||||
|
||||
clock_->IncrementDebugClock(10);
|
||||
clock_->AdvanceTimeMilliseconds(10);
|
||||
|
||||
EXPECT_EQ(VCM_FRAME_NOT_READY, vcm_->Decode(0));
|
||||
ASSERT_EQ(VCM_OK, vcm_->Process());
|
||||
@ -217,13 +216,13 @@ TEST_F(VCMRobustnessTest, TestDualDecoder) {
|
||||
InsertPacket(0, 2, false, true, kVideoFrameKey);
|
||||
EXPECT_EQ(VCM_OK, vcm_->Decode(0)); // Decode timestamp 0.
|
||||
|
||||
clock_->IncrementDebugClock(33);
|
||||
clock_->AdvanceTimeMilliseconds(33);
|
||||
InsertPacket(3000, 3, true, false, kVideoFrameDelta);
|
||||
// Packet 4 missing
|
||||
InsertPacket(3000, 5, false, true, kVideoFrameDelta);
|
||||
EXPECT_EQ(VCM_FRAME_NOT_READY, vcm_->Decode(0));
|
||||
|
||||
clock_->IncrementDebugClock(33);
|
||||
clock_->AdvanceTimeMilliseconds(33);
|
||||
InsertPacket(6000, 6, true, false, kVideoFrameDelta);
|
||||
InsertPacket(6000, 7, false, false, kVideoFrameDelta);
|
||||
InsertPacket(6000, 8, false, true, kVideoFrameDelta);
|
||||
@ -232,7 +231,7 @@ TEST_F(VCMRobustnessTest, TestDualDecoder) {
|
||||
// Spawn a decoder copy.
|
||||
EXPECT_EQ(0, vcm_->DecodeDualFrame(0)); // Expect no dual decoder action.
|
||||
|
||||
clock_->IncrementDebugClock(10);
|
||||
clock_->AdvanceTimeMilliseconds(10);
|
||||
EXPECT_EQ(VCM_OK, vcm_->Process()); // Generate NACK list.
|
||||
|
||||
EXPECT_EQ(VCM_OK, vcm_->Decode(0)); // Decode timestamp 6000 complete.
|
||||
@ -299,25 +298,25 @@ TEST_F(VCMRobustnessTest, TestModeNoneWithErrors) {
|
||||
EXPECT_EQ(VCM_OK, vcm_->Decode(0)); // Decode timestamp 0.
|
||||
EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list.
|
||||
|
||||
clock_->IncrementDebugClock(33);
|
||||
clock_->AdvanceTimeMilliseconds(33);
|
||||
InsertPacket(3000, 3, true, false, kVideoFrameDelta);
|
||||
// Packet 4 missing
|
||||
InsertPacket(3000, 5, false, true, kVideoFrameDelta);
|
||||
EXPECT_EQ(VCM_FRAME_NOT_READY, vcm_->Decode(0));
|
||||
EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list.
|
||||
|
||||
clock_->IncrementDebugClock(33);
|
||||
clock_->AdvanceTimeMilliseconds(33);
|
||||
InsertPacket(6000, 6, true, false, kVideoFrameDelta);
|
||||
InsertPacket(6000, 7, false, false, kVideoFrameDelta);
|
||||
InsertPacket(6000, 8, false, true, kVideoFrameDelta);
|
||||
EXPECT_EQ(VCM_OK, vcm_->Decode(0)); // Decode timestamp 3000 incomplete.
|
||||
EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list.
|
||||
|
||||
clock_->IncrementDebugClock(10);
|
||||
clock_->AdvanceTimeMilliseconds(10);
|
||||
EXPECT_EQ(VCM_OK, vcm_->Decode(0)); // Decode timestamp 6000 complete.
|
||||
EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list.
|
||||
|
||||
clock_->IncrementDebugClock(23);
|
||||
clock_->AdvanceTimeMilliseconds(23);
|
||||
InsertPacket(3000, 4, false, false, kVideoFrameDelta);
|
||||
|
||||
InsertPacket(9000, 9, true, false, kVideoFrameDelta);
|
||||
@ -371,14 +370,14 @@ TEST_F(VCMRobustnessTest, TestModeNoneWithoutErrors) {
|
||||
EXPECT_EQ(VCM_OK, vcm_->Decode(0)); // Decode timestamp 0.
|
||||
EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list.
|
||||
|
||||
clock_->IncrementDebugClock(33);
|
||||
clock_->AdvanceTimeMilliseconds(33);
|
||||
InsertPacket(3000, 3, true, false, kVideoFrameDelta);
|
||||
// Packet 4 missing
|
||||
InsertPacket(3000, 5, false, true, kVideoFrameDelta);
|
||||
EXPECT_EQ(VCM_FRAME_NOT_READY, vcm_->Decode(0));
|
||||
EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list.
|
||||
|
||||
clock_->IncrementDebugClock(33);
|
||||
clock_->AdvanceTimeMilliseconds(33);
|
||||
InsertPacket(6000, 6, true, false, kVideoFrameDelta);
|
||||
InsertPacket(6000, 7, false, false, kVideoFrameDelta);
|
||||
InsertPacket(6000, 8, false, true, kVideoFrameDelta);
|
||||
@ -386,11 +385,12 @@ TEST_F(VCMRobustnessTest, TestModeNoneWithoutErrors) {
|
||||
// Schedule key frame request.
|
||||
EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list.
|
||||
|
||||
clock_->IncrementDebugClock(10);
|
||||
clock_->AdvanceTimeMilliseconds(10);
|
||||
EXPECT_EQ(VCM_OK, vcm_->Decode(0)); // Decode timestamp 6000 complete.
|
||||
EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list.
|
||||
|
||||
clock_->IncrementDebugClock(500); // Wait for the key request timer to set.
|
||||
// Wait for the key request timer to set.
|
||||
clock_->AdvanceTimeMilliseconds(500);
|
||||
EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect key frame request.
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "trace.h"
|
||||
#include "../source/event.h"
|
||||
#include "rtp_player.h"
|
||||
#include "modules/video_coding/main/source/mock/fake_tick_time.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
@ -64,7 +64,7 @@ int DecodeFromStorageTest(CmdArgs& args)
|
||||
Trace::SetLevelFilter(webrtc::kTraceAll);
|
||||
|
||||
|
||||
FakeTickTime clock(0);
|
||||
SimulatedClock clock(0);
|
||||
// TODO(hlundin): This test was not verified after changing to FakeTickTime.
|
||||
VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock);
|
||||
VideoCodingModule* vcmPlayback = VideoCodingModule::Create(2, &clock);
|
||||
@ -125,9 +125,9 @@ int DecodeFromStorageTest(CmdArgs& args)
|
||||
ret = 0;
|
||||
|
||||
// RTP stream main loop
|
||||
while ((ret = rtpStream.NextPacket(clock.MillisecondTimestamp())) == 0)
|
||||
while ((ret = rtpStream.NextPacket(clock.TimeInMilliseconds())) == 0)
|
||||
{
|
||||
if (clock.MillisecondTimestamp() % 5 == 0)
|
||||
if (clock.TimeInMilliseconds() % 5 == 0)
|
||||
{
|
||||
ret = vcm->Decode();
|
||||
if (ret < 0)
|
||||
@ -139,11 +139,11 @@ int DecodeFromStorageTest(CmdArgs& args)
|
||||
{
|
||||
vcm->Process();
|
||||
}
|
||||
if (MAX_RUNTIME_MS > -1 && clock.MillisecondTimestamp() >= MAX_RUNTIME_MS)
|
||||
if (MAX_RUNTIME_MS > -1 && clock.TimeInMilliseconds() >= MAX_RUNTIME_MS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
clock.IncrementDebugClock(1);
|
||||
clock.AdvanceTimeMilliseconds(1);
|
||||
}
|
||||
|
||||
switch (ret)
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "rtp_rtcp.h"
|
||||
#include "common_video/interface/i420_video_frame.h"
|
||||
#include "test_macros.h"
|
||||
#include "modules/video_coding/main/source/mock/fake_tick_time.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
@ -27,7 +27,7 @@ int GenericCodecTest::RunTest(CmdArgs& args)
|
||||
printf("\n\nEnable debug events to run this test!\n\n");
|
||||
return -1;
|
||||
#endif
|
||||
FakeTickTime clock(0);
|
||||
SimulatedClock clock(0);
|
||||
VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock);
|
||||
GenericCodecTest* get = new GenericCodecTest(vcm, &clock);
|
||||
Trace::CreateTrace();
|
||||
@ -41,7 +41,8 @@ int GenericCodecTest::RunTest(CmdArgs& args)
|
||||
return 0;
|
||||
}
|
||||
|
||||
GenericCodecTest::GenericCodecTest(VideoCodingModule* vcm, FakeTickTime* clock):
|
||||
GenericCodecTest::GenericCodecTest(VideoCodingModule* vcm,
|
||||
SimulatedClock* clock):
|
||||
_clock(clock),
|
||||
_vcm(vcm),
|
||||
_width(0),
|
||||
@ -332,10 +333,6 @@ GenericCodecTest::Perform(CmdArgs& args)
|
||||
IncrementDebugClock(_frameRate);
|
||||
// The following should be uncommneted for timing tests. Release tests only include
|
||||
// compliance with full sequence bit rate.
|
||||
|
||||
|
||||
//totalBytes = WaitForEncodedFrame();
|
||||
//currentTime = VCMTickTime::MillisecondTimestamp();//clock()/(double)CLOCKS_PER_SEC;
|
||||
if (_frameCnt == _frameRate)// @ 1sec
|
||||
{
|
||||
totalBytesOneSec = _encodeCompleteCallback->EncodedBytes();//totalBytes;
|
||||
@ -482,8 +479,8 @@ GenericCodecTest::Print()
|
||||
float
|
||||
GenericCodecTest::WaitForEncodedFrame() const
|
||||
{
|
||||
WebRtc_Word64 startTime = _clock->MillisecondTimestamp();
|
||||
while (_clock->MillisecondTimestamp() - startTime < kMaxWaitEncTimeMs*10)
|
||||
WebRtc_Word64 startTime = _clock->TimeInMilliseconds();
|
||||
while (_clock->TimeInMilliseconds() - startTime < kMaxWaitEncTimeMs*10)
|
||||
{
|
||||
if (_encodeCompleteCallback->EncodeComplete())
|
||||
{
|
||||
@ -496,7 +493,7 @@ GenericCodecTest::WaitForEncodedFrame() const
|
||||
void
|
||||
GenericCodecTest::IncrementDebugClock(float frameRate)
|
||||
{
|
||||
_clock->IncrementDebugClock(1000/frameRate);
|
||||
_clock->AdvanceTimeMilliseconds(1000/frameRate);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -31,13 +31,13 @@ namespace webrtc {
|
||||
|
||||
int VCMGenericCodecTest(CmdArgs& args);
|
||||
|
||||
class FakeTickTime;
|
||||
class SimulatedClock;
|
||||
|
||||
class GenericCodecTest
|
||||
{
|
||||
public:
|
||||
GenericCodecTest(webrtc::VideoCodingModule* vcm,
|
||||
webrtc::FakeTickTime* clock);
|
||||
webrtc::SimulatedClock* clock);
|
||||
~GenericCodecTest();
|
||||
static int RunTest(CmdArgs& args);
|
||||
WebRtc_Word32 Perform(CmdArgs& args);
|
||||
@ -49,7 +49,7 @@ private:
|
||||
WebRtc_Word32 TearDown();
|
||||
void IncrementDebugClock(float frameRate);
|
||||
|
||||
webrtc::FakeTickTime* _clock;
|
||||
webrtc::SimulatedClock* _clock;
|
||||
webrtc::VideoCodingModule* _vcm;
|
||||
webrtc::VideoCodec _sendCodec;
|
||||
webrtc::VideoCodec _receiveCodec;
|
||||
|
@ -19,10 +19,10 @@
|
||||
#include "jitter_estimate_test.h"
|
||||
#include "jitter_estimator.h"
|
||||
#include "media_opt_util.h"
|
||||
#include "modules/video_coding/main/source/tick_time_base.h"
|
||||
#include "packet.h"
|
||||
#include "test_util.h"
|
||||
#include "test_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
// TODO(holmer): Get rid of this to conform with style guide.
|
||||
using namespace webrtc;
|
||||
@ -97,7 +97,7 @@ int JitterBufferTest(CmdArgs& args)
|
||||
#if defined(EVENT_DEBUG)
|
||||
return -1;
|
||||
#endif
|
||||
TickTimeBase clock;
|
||||
Clock* clock = Clock::GetRealTimeClock();
|
||||
|
||||
// Start test
|
||||
WebRtc_UWord16 seqNum = 1234;
|
||||
@ -106,7 +106,7 @@ int JitterBufferTest(CmdArgs& args)
|
||||
WebRtc_UWord8 data[1500];
|
||||
VCMPacket packet(data, size, seqNum, timeStamp, true);
|
||||
|
||||
VCMJitterBuffer jb(&clock);
|
||||
VCMJitterBuffer jb(clock);
|
||||
|
||||
seqNum = 1234;
|
||||
timeStamp = 123*90;
|
||||
|
@ -32,9 +32,9 @@ int MediaOptTest::RunTest(int testNum, CmdArgs& args)
|
||||
Trace::CreateTrace();
|
||||
Trace::SetTraceFile((test::OutputPath() + "mediaOptTestTrace.txt").c_str());
|
||||
Trace::SetLevelFilter(webrtc::kTraceAll);
|
||||
TickTimeBase clock;
|
||||
VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock);
|
||||
MediaOptTest* mot = new MediaOptTest(vcm, &clock);
|
||||
Clock* clock = Clock::GetRealTimeClock();
|
||||
VideoCodingModule* vcm = VideoCodingModule::Create(1, clock);
|
||||
MediaOptTest* mot = new MediaOptTest(vcm, clock);
|
||||
if (testNum == 0)
|
||||
{ // regular
|
||||
mot->Setup(0, args);
|
||||
@ -65,7 +65,7 @@ int MediaOptTest::RunTest(int testNum, CmdArgs& args)
|
||||
}
|
||||
|
||||
|
||||
MediaOptTest::MediaOptTest(VideoCodingModule* vcm, TickTimeBase* clock)
|
||||
MediaOptTest::MediaOptTest(VideoCodingModule* vcm, Clock* clock)
|
||||
: _vcm(vcm),
|
||||
_rtp(NULL),
|
||||
_outgoingTransport(NULL),
|
||||
|
@ -34,7 +34,7 @@ class MediaOptTest
|
||||
{
|
||||
public:
|
||||
MediaOptTest(webrtc::VideoCodingModule* vcm,
|
||||
webrtc::TickTimeBase* clock);
|
||||
webrtc::Clock* clock);
|
||||
~MediaOptTest();
|
||||
|
||||
static int RunTest(int testNum, CmdArgs& args);
|
||||
@ -57,7 +57,7 @@ private:
|
||||
webrtc::RTPSendCompleteCallback* _outgoingTransport;
|
||||
RtpDataCallback* _dataCallback;
|
||||
|
||||
webrtc::TickTimeBase* _clock;
|
||||
webrtc::Clock* _clock;
|
||||
std::string _inname;
|
||||
std::string _outname;
|
||||
std::string _actualSourcename;
|
||||
|
@ -143,12 +143,12 @@ int MTRxTxTest(CmdArgs& args)
|
||||
printf("Cannot read file %s.\n", outname.c_str());
|
||||
return -1;
|
||||
}
|
||||
TickTimeBase clock;
|
||||
VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock);
|
||||
Clock* clock = Clock::GetRealTimeClock();
|
||||
VideoCodingModule* vcm = VideoCodingModule::Create(1, clock);
|
||||
RtpDataCallback dataCallback(vcm);
|
||||
|
||||
RTPSendCompleteCallback* outgoingTransport =
|
||||
new RTPSendCompleteCallback(&clock, "dump.rtp");
|
||||
new RTPSendCompleteCallback(clock, "dump.rtp");
|
||||
|
||||
RtpRtcp::Configuration configuration;
|
||||
configuration.id = 1;
|
||||
|
@ -12,12 +12,12 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "modules/video_coding/main/source/tick_time_base.h"
|
||||
#include "rtp_dump.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
TransportCallback::TransportCallback(TickTimeBase* clock, const char* filename)
|
||||
TransportCallback::TransportCallback(Clock* clock, const char* filename)
|
||||
: RTPSendCompleteCallback(clock, filename) {
|
||||
}
|
||||
|
||||
@ -47,8 +47,8 @@ TransportCallback::SendPacket(int channel, const void *data, int len)
|
||||
transmitPacket = PacketLoss();
|
||||
}
|
||||
|
||||
TickTimeBase clock;
|
||||
int64_t now = clock.MillisecondTimestamp();
|
||||
Clock* clock = Clock::GetRealTimeClock();
|
||||
int64_t now = clock->TimeInMilliseconds();
|
||||
// Insert outgoing packet into list
|
||||
if (transmitPacket)
|
||||
{
|
||||
@ -72,8 +72,8 @@ TransportCallback::TransportPackets()
|
||||
{
|
||||
// Are we ready to send packets to the receiver?
|
||||
RtpPacket* packet = NULL;
|
||||
TickTimeBase clock;
|
||||
int64_t now = clock.MillisecondTimestamp();
|
||||
Clock* clock = Clock::GetRealTimeClock();
|
||||
int64_t now = clock->TimeInMilliseconds();
|
||||
|
||||
while (!_rtpPackets.empty())
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ class TransportCallback:public RTPSendCompleteCallback
|
||||
{
|
||||
public:
|
||||
// constructor input: (receive side) rtp module to send encoded data to
|
||||
TransportCallback(TickTimeBase* clock, const char* filename = NULL);
|
||||
TransportCallback(Clock* clock, const char* filename = NULL);
|
||||
virtual ~TransportCallback();
|
||||
// Add packets to list
|
||||
// Incorporate network conditions - delay and packet loss
|
||||
|
@ -18,12 +18,12 @@
|
||||
#include "../source/event.h"
|
||||
#include "common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "common_types.h"
|
||||
#include "modules/video_coding/main/source/mock/fake_tick_time.h"
|
||||
#include "test_callbacks.h"
|
||||
#include "test_macros.h"
|
||||
#include "test_util.h"
|
||||
#include "trace.h"
|
||||
#include "testsupport/metrics/video_metrics.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
@ -31,17 +31,18 @@ int NormalTest::RunTest(const CmdArgs& args)
|
||||
{
|
||||
#if defined(EVENT_DEBUG)
|
||||
printf("SIMULATION TIME\n");
|
||||
FakeTickTime clock(0);
|
||||
SimulatedClock sim_clock;
|
||||
SimulatedClock* clock = &sim_clock;
|
||||
#else
|
||||
printf("REAL-TIME\n");
|
||||
TickTimeBase clock;
|
||||
Clock* clock = Clock::GetRealTimeClock();
|
||||
#endif
|
||||
Trace::CreateTrace();
|
||||
Trace::SetTraceFile(
|
||||
(test::OutputPath() + "VCMNormalTestTrace.txt").c_str());
|
||||
Trace::SetLevelFilter(webrtc::kTraceAll);
|
||||
VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock);
|
||||
NormalTest VCMNTest(vcm, &clock);
|
||||
VideoCodingModule* vcm = VideoCodingModule::Create(1, clock);
|
||||
NormalTest VCMNTest(vcm, clock);
|
||||
VCMNTest.Perform(args);
|
||||
VideoCodingModule::Destroy(vcm);
|
||||
Trace::ReturnTrace();
|
||||
@ -183,7 +184,7 @@ VCMNTDecodeCompleCallback::DecodedBytes()
|
||||
|
||||
//VCM Normal Test Class implementation
|
||||
|
||||
NormalTest::NormalTest(VideoCodingModule* vcm, TickTimeBase* clock)
|
||||
NormalTest::NormalTest(VideoCodingModule* vcm, Clock* clock)
|
||||
:
|
||||
_clock(clock),
|
||||
_vcm(vcm),
|
||||
@ -289,7 +290,7 @@ NormalTest::Perform(const CmdArgs& args)
|
||||
|
||||
while (feof(_sourceFile) == 0) {
|
||||
#if !defined(EVENT_DEBUG)
|
||||
WebRtc_Word64 processStartTime = _clock->MillisecondTimestamp();
|
||||
WebRtc_Word64 processStartTime = _clock->TimeInMilliseconds();
|
||||
#endif
|
||||
TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0 ||
|
||||
feof(_sourceFile));
|
||||
@ -332,10 +333,10 @@ NormalTest::Perform(const CmdArgs& args)
|
||||
1000.0f / static_cast<float>(_sendCodec.maxFramerate) + 0.5f);
|
||||
|
||||
#if defined(EVENT_DEBUG)
|
||||
static_cast<FakeTickTime*>(_clock)->IncrementDebugClock(framePeriod);
|
||||
static_cast<SimulatedClock*>(_clock)->AdvanceTimeMilliseconds(framePeriod);
|
||||
#else
|
||||
WebRtc_Word64 timeSpent =
|
||||
_clock->MillisecondTimestamp() - processStartTime;
|
||||
_clock->TimeInMilliseconds() - processStartTime;
|
||||
if (timeSpent < framePeriod)
|
||||
{
|
||||
waitEvent->Wait(framePeriod - timeSpent);
|
||||
|
@ -86,7 +86,7 @@ class NormalTest
|
||||
{
|
||||
public:
|
||||
NormalTest(webrtc::VideoCodingModule* vcm,
|
||||
webrtc::TickTimeBase* clock);
|
||||
webrtc::Clock* clock);
|
||||
~NormalTest();
|
||||
static int RunTest(const CmdArgs& args);
|
||||
WebRtc_Word32 Perform(const CmdArgs& args);
|
||||
@ -108,7 +108,7 @@ protected:
|
||||
// calculating pipeline delay, and decoding time
|
||||
void FrameDecoded(WebRtc_UWord32 timeStamp);
|
||||
|
||||
webrtc::TickTimeBase* _clock;
|
||||
webrtc::Clock* _clock;
|
||||
webrtc::VideoCodingModule* _vcm;
|
||||
webrtc::VideoCodec _sendCodec;
|
||||
webrtc::VideoCodec _receiveCodec;
|
||||
|
@ -17,20 +17,19 @@
|
||||
|
||||
#include "common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "modules/video_coding/main/source/event.h"
|
||||
#include "modules/video_coding/main/source/mock/fake_tick_time.h"
|
||||
#include "modules/video_coding/main/source/tick_time_base.h"
|
||||
#include "modules/video_coding/main/test/test_callbacks.h"
|
||||
#include "modules/video_coding/main/test/test_macros.h"
|
||||
#include "modules/video_coding/main/test/test_util.h"
|
||||
#include "system_wrappers/interface/data_log.h"
|
||||
#include "system_wrappers/interface/data_log.h"
|
||||
#include "testsupport/metrics/video_metrics.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
int qualityModeTest(const CmdArgs& args)
|
||||
{
|
||||
FakeTickTime clock(0);
|
||||
SimulatedClock clock(0);
|
||||
VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock);
|
||||
QualityModesTest QMTest(vcm, &clock);
|
||||
QMTest.Perform(args);
|
||||
@ -39,7 +38,7 @@ int qualityModeTest(const CmdArgs& args)
|
||||
}
|
||||
|
||||
QualityModesTest::QualityModesTest(VideoCodingModule* vcm,
|
||||
TickTimeBase* clock):
|
||||
Clock* clock):
|
||||
NormalTest(vcm, clock),
|
||||
_vpm()
|
||||
{
|
||||
@ -367,8 +366,8 @@ QualityModesTest::Perform(const CmdArgs& args)
|
||||
DataLog::InsertCell(feature_table_name_, "frame rate", _nativeFrameRate);
|
||||
DataLog::NextRow(feature_table_name_);
|
||||
|
||||
static_cast<FakeTickTime*>(
|
||||
_clock)->IncrementDebugClock(1000 / _nativeFrameRate);
|
||||
static_cast<SimulatedClock*>(_clock)->AdvanceTimeMilliseconds(
|
||||
1000 / _nativeFrameRate);
|
||||
}
|
||||
|
||||
} while (feof(_sourceFile) == 0);
|
||||
|
@ -22,7 +22,7 @@ class QualityModesTest : public NormalTest
|
||||
{
|
||||
public:
|
||||
QualityModesTest(webrtc::VideoCodingModule* vcm,
|
||||
webrtc::TickTimeBase* clock);
|
||||
webrtc::Clock* clock);
|
||||
virtual ~QualityModesTest();
|
||||
WebRtc_Word32 Perform(const CmdArgs& args);
|
||||
|
||||
|
@ -61,8 +61,8 @@ int ReceiverTimingTests(CmdArgs& args)
|
||||
// A static random seed
|
||||
srand(0);
|
||||
|
||||
TickTimeBase clock;
|
||||
VCMTiming timing(&clock);
|
||||
Clock* clock = Clock::GetRealTimeClock();
|
||||
VCMTiming timing(clock);
|
||||
float clockInMs = 0.0;
|
||||
WebRtc_UWord32 waitTime = 0;
|
||||
WebRtc_UWord32 jitterDelayMs = 0;
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
#include "../source/internal_defines.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "modules/video_coding/main/source/tick_time_base.h"
|
||||
#include "rtp_rtcp.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
@ -137,7 +137,7 @@ void LostPackets::Print() const {
|
||||
|
||||
RTPPlayer::RTPPlayer(const char* filename,
|
||||
RtpData* callback,
|
||||
TickTimeBase* clock)
|
||||
Clock* clock)
|
||||
:
|
||||
_clock(clock),
|
||||
_rtpModule(NULL),
|
||||
@ -273,7 +273,8 @@ WebRtc_Word32 RTPPlayer::ReadHeader()
|
||||
|
||||
WebRtc_UWord32 RTPPlayer::TimeUntilNextPacket() const
|
||||
{
|
||||
WebRtc_Word64 timeLeft = (_nextRtpTime - _firstPacketRtpTime) - (_clock->MillisecondTimestamp() - _firstPacketTimeMs);
|
||||
WebRtc_Word64 timeLeft = (_nextRtpTime - _firstPacketRtpTime) -
|
||||
(_clock->TimeInMilliseconds() - _firstPacketTimeMs);
|
||||
if (timeLeft < 0)
|
||||
{
|
||||
return 0;
|
||||
@ -293,7 +294,7 @@ WebRtc_Word32 RTPPlayer::NextPacket(const WebRtc_Word64 timeNow)
|
||||
delete resend_packet;
|
||||
_resendPacketCount++;
|
||||
if (ret > 0) {
|
||||
_lostPackets.SetPacketResent(seqNo, _clock->MillisecondTimestamp());
|
||||
_lostPackets.SetPacketResent(seqNo, _clock->TimeInMilliseconds());
|
||||
} else if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
@ -307,7 +308,7 @@ WebRtc_Word32 RTPPlayer::NextPacket(const WebRtc_Word64 timeNow)
|
||||
if (_firstPacket)
|
||||
{
|
||||
_firstPacketRtpTime = static_cast<WebRtc_Word64>(_nextRtpTime);
|
||||
_firstPacketTimeMs = _clock->MillisecondTimestamp();
|
||||
_firstPacketTimeMs = _clock->TimeInMilliseconds();
|
||||
}
|
||||
if (_reordering && _reorderBuffer == NULL)
|
||||
{
|
||||
@ -428,8 +429,8 @@ WebRtc_Word32 RTPPlayer::ResendPackets(const WebRtc_UWord16* sequenceNumbers, We
|
||||
for (int i=0; i < length; i++)
|
||||
{
|
||||
_lostPackets.SetResendTime(sequenceNumbers[i],
|
||||
_clock->MillisecondTimestamp() + _rttMs,
|
||||
_clock->MillisecondTimestamp());
|
||||
_clock->TimeInMilliseconds() + _rttMs,
|
||||
_clock->TimeInMilliseconds());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "rtp_rtcp.h"
|
||||
#include "critical_section_wrapper.h"
|
||||
#include "video_coding_defines.h"
|
||||
#include "modules/video_coding/main/source/tick_time_base.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <list>
|
||||
@ -78,7 +78,7 @@ class RTPPlayer : public webrtc::VCMPacketRequestCallback
|
||||
public:
|
||||
RTPPlayer(const char* filename,
|
||||
webrtc::RtpData* callback,
|
||||
webrtc::TickTimeBase* clock);
|
||||
webrtc::Clock* clock);
|
||||
virtual ~RTPPlayer();
|
||||
|
||||
WebRtc_Word32 Initialize(const PayloadTypeList* payloadList);
|
||||
@ -93,7 +93,7 @@ private:
|
||||
WebRtc_Word32 SendPacket(WebRtc_UWord8* rtpData, WebRtc_UWord16 rtpLen);
|
||||
WebRtc_Word32 ReadPacket(WebRtc_Word16* rtpdata, WebRtc_UWord32* offset);
|
||||
WebRtc_Word32 ReadHeader();
|
||||
webrtc::TickTimeBase* _clock;
|
||||
webrtc::Clock* _clock;
|
||||
FILE* _rtpFile;
|
||||
webrtc::RtpRtcp* _rtpModule;
|
||||
WebRtc_UWord32 _nextRtpTime;
|
||||
|
@ -13,9 +13,9 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "modules/video_coding/main/source/tick_time_base.h"
|
||||
#include "rtp_dump.h"
|
||||
#include "test_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -204,7 +204,7 @@ VCMDecodeCompleteCallback::DecodedBytes()
|
||||
return _decodedBytes;
|
||||
}
|
||||
|
||||
RTPSendCompleteCallback::RTPSendCompleteCallback(TickTimeBase* clock,
|
||||
RTPSendCompleteCallback::RTPSendCompleteCallback(Clock* clock,
|
||||
const char* filename):
|
||||
_clock(clock),
|
||||
_sendCount(0),
|
||||
@ -258,7 +258,7 @@ RTPSendCompleteCallback::SendPacket(int channel, const void *data, int len)
|
||||
bool transmitPacket = true;
|
||||
transmitPacket = PacketLoss();
|
||||
|
||||
WebRtc_UWord64 now = _clock->MillisecondTimestamp();
|
||||
int64_t now = _clock->TimeInMilliseconds();
|
||||
// Insert outgoing packet into list
|
||||
if (transmitPacket)
|
||||
{
|
||||
|
@ -157,7 +157,7 @@ class RTPSendCompleteCallback: public Transport
|
||||
{
|
||||
public:
|
||||
// Constructor input: (receive side) rtp module to send encoded data to
|
||||
RTPSendCompleteCallback(TickTimeBase* clock,
|
||||
RTPSendCompleteCallback(Clock* clock,
|
||||
const char* filename = NULL);
|
||||
virtual ~RTPSendCompleteCallback();
|
||||
|
||||
@ -186,7 +186,7 @@ protected:
|
||||
// Random uniform loss model
|
||||
bool UnifomLoss(double lossPct);
|
||||
|
||||
TickTimeBase* _clock;
|
||||
Clock* _clock;
|
||||
WebRtc_UWord32 _sendCount;
|
||||
RtpRtcp* _rtp;
|
||||
double _lossPct;
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "../source/internal_defines.h"
|
||||
#include "test_macros.h"
|
||||
#include "rtp_player.h"
|
||||
#include "modules/video_coding/main/source/mock/fake_tick_time.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -130,7 +130,7 @@ int RtpPlay(CmdArgs& args)
|
||||
if (outFile == "")
|
||||
outFile = test::OutputPath() + "RtpPlay_decoded.yuv";
|
||||
FrameReceiveCallback receiveCallback(outFile);
|
||||
FakeTickTime clock(0);
|
||||
SimulatedClock clock(0);
|
||||
VideoCodingModule* vcm = VideoCodingModule::Create(1, &clock);
|
||||
RtpDataCallback dataCallback(vcm);
|
||||
RTPPlayer rtpStream(args.inputFile.c_str(), &dataCallback, &clock);
|
||||
@ -198,9 +198,9 @@ int RtpPlay(CmdArgs& args)
|
||||
ret = 0;
|
||||
|
||||
// RTP stream main loop
|
||||
while ((ret = rtpStream.NextPacket(clock.MillisecondTimestamp())) == 0)
|
||||
while ((ret = rtpStream.NextPacket(clock.TimeInMilliseconds())) == 0)
|
||||
{
|
||||
if (clock.MillisecondTimestamp() % 5 == 0)
|
||||
if (clock.TimeInMilliseconds() % 5 == 0)
|
||||
{
|
||||
ret = vcm->Decode();
|
||||
if (ret < 0)
|
||||
@ -214,12 +214,12 @@ int RtpPlay(CmdArgs& args)
|
||||
{
|
||||
vcm->Process();
|
||||
}
|
||||
if (MAX_RUNTIME_MS > -1 && clock.MillisecondTimestamp() >=
|
||||
if (MAX_RUNTIME_MS > -1 && clock.TimeInMilliseconds() >=
|
||||
MAX_RUNTIME_MS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
clock.IncrementDebugClock(1);
|
||||
clock.AdvanceTimeMilliseconds(1);
|
||||
}
|
||||
|
||||
// Tear down
|
||||
|
@ -8,17 +8,18 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "receiver_tests.h"
|
||||
#include "video_coding.h"
|
||||
#include "rtp_rtcp.h"
|
||||
#include "trace.h"
|
||||
#include "thread_wrapper.h"
|
||||
#include "../source/event.h"
|
||||
#include "test_macros.h"
|
||||
#include "rtp_player.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
|
||||
#include "webrtc/modules/video_coding/main/interface/video_coding.h"
|
||||
#include "webrtc/modules/video_coding/main/source/event.h"
|
||||
#include "webrtc/modules/video_coding/main/test/receiver_tests.h"
|
||||
#include "webrtc/modules/video_coding/main/test/rtp_player.h"
|
||||
#include "webrtc/modules/video_coding/main/test/test_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
bool ProcessingThread(void* obj)
|
||||
@ -39,8 +40,8 @@ bool RtpReaderThread(void* obj)
|
||||
SharedState* state = static_cast<SharedState*>(obj);
|
||||
EventWrapper& waitEvent = *EventWrapper::Create();
|
||||
// RTP stream main loop
|
||||
TickTimeBase clock;
|
||||
if (state->_rtpPlayer.NextPacket(clock.MillisecondTimestamp()) < 0)
|
||||
Clock* clock = Clock::GetRealTimeClock();
|
||||
if (state->_rtpPlayer.NextPacket(clock->TimeInMilliseconds()) < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -82,9 +83,9 @@ int RtpPlayMT(CmdArgs& args, int releaseTestNo, webrtc::VideoCodecType releaseTe
|
||||
(protection == kProtectionDualDecoder ||
|
||||
protection == kProtectionNack ||
|
||||
kProtectionNackFEC));
|
||||
TickTimeBase clock;
|
||||
Clock* clock = Clock::GetRealTimeClock();
|
||||
VideoCodingModule* vcm =
|
||||
VideoCodingModule::Create(1, &clock);
|
||||
VideoCodingModule::Create(1, clock);
|
||||
RtpDataCallback dataCallback(vcm);
|
||||
std::string rtpFilename;
|
||||
rtpFilename = args.inputFile;
|
||||
@ -137,7 +138,7 @@ int RtpPlayMT(CmdArgs& args, int releaseTestNo, webrtc::VideoCodecType releaseTe
|
||||
}
|
||||
printf("Watch %s to verify that the output is reasonable\n", outFilename.c_str());
|
||||
}
|
||||
RTPPlayer rtpStream(rtpFilename.c_str(), &dataCallback, &clock);
|
||||
RTPPlayer rtpStream(rtpFilename.c_str(), &dataCallback, clock);
|
||||
PayloadTypeList payloadTypes;
|
||||
payloadTypes.push_front(new PayloadCodecTuple(VCM_VP8_PAYLOAD_TYPE, "VP8",
|
||||
kVideoCodecVP8));
|
||||
@ -164,10 +165,10 @@ int RtpPlayMT(CmdArgs& args, int releaseTestNo, webrtc::VideoCodecType releaseTe
|
||||
}
|
||||
|
||||
// Create and start all threads
|
||||
ThreadWrapper* processingThread = ThreadWrapper::CreateThread(ProcessingThread,
|
||||
&mtState, kNormalPriority, "ProcessingThread");
|
||||
ThreadWrapper* rtpReaderThread = ThreadWrapper::CreateThread(RtpReaderThread,
|
||||
&mtState, kNormalPriority, "RtpReaderThread");
|
||||
ThreadWrapper* processingThread = ThreadWrapper::CreateThread(
|
||||
ProcessingThread, &mtState, kNormalPriority, "ProcessingThread");
|
||||
ThreadWrapper* rtpReaderThread = ThreadWrapper::CreateThread(
|
||||
RtpReaderThread, &mtState, kNormalPriority, "RtpReaderThread");
|
||||
ThreadWrapper* decodeThread = ThreadWrapper::CreateThread(DecodeThread,
|
||||
&mtState, kNormalPriority, "DecodeThread");
|
||||
|
||||
|
@ -43,7 +43,6 @@ class Clock {
|
||||
|
||||
class SimulatedClock : public Clock {
|
||||
public:
|
||||
SimulatedClock();
|
||||
explicit SimulatedClock(int64_t initial_time_us);
|
||||
|
||||
virtual ~SimulatedClock() {}
|
||||
@ -61,8 +60,8 @@ class SimulatedClock : public Clock {
|
||||
|
||||
// Advance the simulated clock with a given number of milliseconds or
|
||||
// microseconds.
|
||||
void AdvanceTimeMs(int64_t milliseconds);
|
||||
void AdvanceTimeUs(int64_t microseconds);
|
||||
void AdvanceTimeMilliseconds(int64_t milliseconds);
|
||||
void AdvanceTimeMicroseconds(int64_t microseconds);
|
||||
|
||||
private:
|
||||
int64_t time_us_;
|
||||
|
@ -220,16 +220,16 @@ static WindowsHelpTimer global_help_timer = {0, 0, {{ 0, 0}, 0}, 0};
|
||||
|
||||
Clock* Clock::GetRealTimeClock() {
|
||||
#if defined(_WIN32)
|
||||
return new WindowsRealTimeClock(&global_help_timer);
|
||||
static WindowsRealTimeClock clock(&global_help_timer);
|
||||
return &clock;
|
||||
#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
|
||||
return new UnixRealTimeClock();
|
||||
static UnixRealTimeClock clock;
|
||||
return &clock;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
SimulatedClock::SimulatedClock() : time_us_(0) {}
|
||||
|
||||
SimulatedClock::SimulatedClock(int64_t initial_time_us)
|
||||
: time_us_(initial_time_us) {}
|
||||
|
||||
@ -247,11 +247,11 @@ void SimulatedClock::CurrentNtp(uint32_t& seconds, uint32_t& fractions) {
|
||||
kMagicNtpFractionalUnit / 1000);
|
||||
}
|
||||
|
||||
void SimulatedClock::AdvanceTimeMs(int64_t milliseconds) {
|
||||
AdvanceTimeUs(1000 * milliseconds);
|
||||
void SimulatedClock::AdvanceTimeMilliseconds(int64_t milliseconds) {
|
||||
AdvanceTimeMicroseconds(1000 * milliseconds);
|
||||
}
|
||||
|
||||
void SimulatedClock::AdvanceTimeUs(int64_t microseconds) {
|
||||
void SimulatedClock::AdvanceTimeMicroseconds(int64_t microseconds) {
|
||||
time_us_ += microseconds;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user