Change default timestamp to 64 bits in all webrtc directories.

BUG=
R=pbos@webrtc.org, pthatcher@webrtc.org, solenberg@webrtc.org

Review URL: https://codereview.webrtc.org/1835053002 .

Cr-Commit-Position: refs/heads/master@{#12646}
This commit is contained in:
Honghai Zhang 2016-05-06 11:29:15 -07:00
parent e76db89e0b
commit 82d7862fe7
55 changed files with 294 additions and 361 deletions

View File

@ -85,9 +85,9 @@ class FakeDtmfProvider : public DtmfProviderInterface {
// TODO(ronghuawu): Make the timer (basically the rtc::TimeNanos)
// mockable and use a fake timer in the unit tests.
if (last_insert_dtmf_call_ > 0) {
gap = static_cast<int>(rtc::Time() - last_insert_dtmf_call_);
gap = static_cast<int>(rtc::TimeMillis() - last_insert_dtmf_call_);
}
last_insert_dtmf_call_ = rtc::Time();
last_insert_dtmf_call_ = rtc::TimeMillis();
LOG(LS_VERBOSE) << "FakeDtmfProvider::InsertDtmf code=" << code
<< " duration=" << duration

View File

@ -38,7 +38,7 @@ using webrtc::PeerConnectionInterface;
namespace {
const size_t kMaxWait = 10000;
const int kMaxWait = 10000;
} // namespace

View File

@ -153,7 +153,7 @@ PeerConnectionFactory::~PeerConnectionFactory() {
bool PeerConnectionFactory::Initialize() {
RTC_DCHECK(signaling_thread_->IsCurrent());
rtc::InitRandom(rtc::Time());
rtc::InitRandom(rtc::Time32());
default_network_manager_.reset(new rtc::BasicNetworkManager());
if (!default_network_manager_) {

View File

@ -23,7 +23,7 @@ static const int kHighSampleValue = 10000;
// Same value as src/modules/audio_device/main/source/audio_device_config.h in
// https://code.google.com/p/webrtc/
static const uint32_t kAdmMaxIdleTimeProcess = 1000;
static const int kAdmMaxIdleTimeProcess = 1000;
// Constants here are derived by running VoE using a real ADM.
// The constants correspond to 10ms of mono audio at 44kHz.
@ -73,12 +73,12 @@ int FakeAudioCaptureModule::frames_received() const {
}
int64_t FakeAudioCaptureModule::TimeUntilNextProcess() {
const uint32_t current_time = rtc::Time();
const int64_t current_time = rtc::TimeMillis();
if (current_time < last_process_time_ms_) {
// TODO: wraparound could be handled more gracefully.
return 0;
}
const uint32_t elapsed_time = current_time - last_process_time_ms_;
const int64_t elapsed_time = current_time - last_process_time_ms_;
if (kAdmMaxIdleTimeProcess < elapsed_time) {
return 0;
}
@ -86,7 +86,7 @@ int64_t FakeAudioCaptureModule::TimeUntilNextProcess() {
}
void FakeAudioCaptureModule::Process() {
last_process_time_ms_ = rtc::Time();
last_process_time_ms_ = rtc::TimeMillis();
}
int32_t FakeAudioCaptureModule::ActiveAudioLayer(
@ -590,7 +590,7 @@ bool FakeAudioCaptureModule::Initialize() {
// sent to it. Note that the audio processing pipeline will likely distort the
// original signal.
SetSendBuffer(kHighSampleValue);
last_process_time_ms_ = rtc::Time();
last_process_time_ms_ = rtc::TimeMillis();
return true;
}
@ -649,7 +649,7 @@ void FakeAudioCaptureModule::StartProcessP() {
void FakeAudioCaptureModule::ProcessFrameP() {
ASSERT(process_thread_->IsCurrent());
if (!started_) {
next_frame_time_ = rtc::Time();
next_frame_time_ = rtc::TimeMillis();
started_ = true;
}
@ -665,8 +665,8 @@ void FakeAudioCaptureModule::ProcessFrameP() {
}
next_frame_time_ += kTimePerFrameMs;
const uint32_t current_time = rtc::Time();
const uint32_t wait_time =
const int64_t current_time = rtc::TimeMillis();
const int64_t wait_time =
(next_frame_time_ > current_time) ? next_frame_time_ - current_time : 0;
process_thread_->PostDelayed(wait_time, this, MSG_RUN_PROCESS);
}

View File

@ -227,7 +227,7 @@ class FakeAudioCaptureModule
// The time in milliseconds when Process() was last called or 0 if no call
// has been made.
uint32_t last_process_time_ms_;
int64_t last_process_time_ms_;
// Callback for playout and recording.
webrtc::AudioTransport* audio_callback_;
@ -247,7 +247,7 @@ class FakeAudioCaptureModule
// wall clock time the next frame should be generated and received. started_
// ensures that next_frame_time_ can be initialized properly on first call.
bool started_;
uint32_t next_frame_time_;
int64_t next_frame_time_;
std::unique_ptr<rtc::Thread> process_thread_;

View File

@ -296,7 +296,7 @@ int AsyncTCPSocket::Send(const void *pv, size_t cb,
return res;
}
rtc::SentPacket sent_packet(options.packet_id, rtc::Time());
rtc::SentPacket sent_packet(options.packet_id, rtc::TimeMillis());
SignalSentPacket(this, sent_packet);
// We claim to have sent the whole thing, even if we only sent partial

View File

@ -59,7 +59,7 @@ SocketAddress AsyncUDPSocket::GetRemoteAddress() const {
int AsyncUDPSocket::Send(const void *pv, size_t cb,
const rtc::PacketOptions& options) {
rtc::SentPacket sent_packet(options.packet_id, rtc::Time());
rtc::SentPacket sent_packet(options.packet_id, rtc::TimeMillis());
int ret = socket_->Send(pv, cb);
SignalSentPacket(this, sent_packet);
return ret;
@ -68,7 +68,7 @@ int AsyncUDPSocket::Send(const void *pv, size_t cb,
int AsyncUDPSocket::SendTo(const void *pv, size_t cb,
const SocketAddress& addr,
const rtc::PacketOptions& options) {
rtc::SentPacket sent_packet(options.packet_id, rtc::Time());
rtc::SentPacket sent_packet(options.packet_id, rtc::TimeMillis());
int ret = socket_->SendTo(pv, cb, addr);
SignalSentPacket(this, sent_packet);
return ret;

View File

@ -133,7 +133,7 @@ bool DirectoryIterator::OlderThan(int seconds) const {
#else
file_modify_time = stat_.st_mtime;
#endif
return TimeDiff(time(NULL), file_modify_time) >= seconds;
return time(NULL) - file_modify_time >= seconds;
}
FilesystemInterface* Filesystem::default_filesystem_ = NULL;

View File

@ -20,21 +20,22 @@
#endif
// Wait until "ex" is true, or "timeout" expires.
#define WAIT(ex, timeout) \
for (uint32_t start = rtc::Time(); !(ex) && rtc::Time() < start + timeout;) \
#define WAIT(ex, timeout) \
for (int64_t start = rtc::TimeMillis(); \
!(ex) && rtc::TimeMillis() < start + timeout;) \
rtc::Thread::Current()->ProcessMessages(1);
// This returns the result of the test in res, so that we don't re-evaluate
// the expression in the XXXX_WAIT macros below, since that causes problems
// when the expression is only true the first time you check it.
#define WAIT_(ex, timeout, res) \
do { \
uint32_t start = rtc::Time(); \
res = (ex); \
while (!res && rtc::Time() < start + timeout) { \
rtc::Thread::Current()->ProcessMessages(1); \
res = (ex); \
} \
#define WAIT_(ex, timeout, res) \
do { \
int64_t start = rtc::TimeMillis(); \
res = (ex); \
while (!res && rtc::TimeMillis() < start + timeout) { \
rtc::Thread::Current()->ProcessMessages(1); \
res = (ex); \
} \
} while (0)
// The typical EXPECT_XXXX and ASSERT_XXXXs, but done until true or a timeout.

View File

@ -124,7 +124,7 @@ LogMessage::LogMessage(const char* file,
const char* module)
: severity_(sev), tag_(kLibjingle) {
if (timestamp_) {
uint32_t time = TimeSince(LogStartTime());
int64_t time = TimeSince(LogStartTime());
// Also ensure WallClockStartTime is initialized, so that it matches
// LogStartTime.
WallClockStartTime();
@ -209,8 +209,8 @@ LogMessage::~LogMessage() {
}
}
uint32_t LogMessage::LogStartTime() {
static const uint32_t g_start = Time();
int64_t LogMessage::LogStartTime() {
static const int64_t g_start = TimeMillis();
return g_start;
}

View File

@ -156,7 +156,7 @@ class LogMessage {
// If this is not called externally, the LogMessage ctor also calls it, in
// which case the logging start time will be the time of the first LogMessage
// instance is created.
static uint32_t LogStartTime();
static int64_t LogStartTime();
// Returns the wall clock equivalent of |LogStartTime|, in seconds from the
// epoch.

View File

@ -138,18 +138,18 @@ TEST(LogTest, Perf) {
stream.DisableBuffering();
LogMessage::AddLogToStream(&stream, LS_SENSITIVE);
uint32_t start = Time(), finish;
int64_t start = TimeMillis(), finish;
std::string message('X', 80);
for (int i = 0; i < 1000; ++i) {
LOG(LS_SENSITIVE) << message;
}
finish = Time();
finish = TimeMillis();
LogMessage::RemoveLogToStream(&stream);
stream.Close();
Filesystem::DeleteFile(path);
LOG(LS_INFO) << "Average log time: " << TimeDiff(finish, start) << " us";
LOG(LS_INFO) << "Average log time: " << TimeDiff(finish, start) << " ms";
}
} // namespace rtc

View File

@ -17,7 +17,7 @@
namespace rtc {
const uint32_t kMaxMsgLatency = 150; // 150 ms
const int kMaxMsgLatency = 150; // 150 ms
//------------------------------------------------------------------
// MessageQueueManager
@ -215,16 +215,16 @@ bool MessageQueue::Get(Message *pmsg, int cmsWait, bool process_io) {
// Get w/wait + timer scan / dispatch + socket / event multiplexer dispatch
int cmsTotal = cmsWait;
int cmsElapsed = 0;
uint32_t msStart = Time();
uint32_t msCurrent = msStart;
int64_t cmsTotal = cmsWait;
int64_t cmsElapsed = 0;
int64_t msStart = TimeMillis();
int64_t msCurrent = msStart;
while (true) {
// Check for sent messages
ReceiveSends();
// Check for posted events
int cmsDelayNext = kForever;
int64_t cmsDelayNext = kForever;
bool first_pass = true;
while (true) {
// All queue operations need to be locked, but nothing else in this loop
@ -237,7 +237,7 @@ bool MessageQueue::Get(Message *pmsg, int cmsWait, bool process_io) {
if (first_pass) {
first_pass = false;
while (!dmsgq_.empty()) {
if (TimeIsLater(msCurrent, dmsgq_.top().msTrigger_)) {
if (msCurrent < dmsgq_.top().msTrigger_) {
cmsDelayNext = TimeDiff(dmsgq_.top().msTrigger_, msCurrent);
break;
}
@ -256,7 +256,7 @@ bool MessageQueue::Get(Message *pmsg, int cmsWait, bool process_io) {
// Log a warning for time-sensitive messages that we're late to deliver.
if (pmsg->ts_sensitive) {
int32_t delay = TimeDiff(msCurrent, pmsg->ts_sensitive);
int64_t delay = TimeDiff(msCurrent, pmsg->ts_sensitive);
if (delay > 0) {
LOG_F(LS_WARNING) << "id: " << pmsg->message_id << " delay: "
<< (delay + kMaxMsgLatency) << "ms";
@ -277,11 +277,11 @@ bool MessageQueue::Get(Message *pmsg, int cmsWait, bool process_io) {
// Which is shorter, the delay wait or the asked wait?
int cmsNext;
int64_t cmsNext;
if (cmsWait == kForever) {
cmsNext = cmsDelayNext;
} else {
cmsNext = std::max(0, cmsTotal - cmsElapsed);
cmsNext = std::max<int64_t>(0, cmsTotal - cmsElapsed);
if ((cmsDelayNext != kForever) && (cmsDelayNext < cmsNext))
cmsNext = cmsDelayNext;
}
@ -289,13 +289,13 @@ bool MessageQueue::Get(Message *pmsg, int cmsWait, bool process_io) {
{
// Wait and multiplex in the meantime
SharedScope ss(&ss_lock_);
if (!ss_->Wait(cmsNext, process_io))
if (!ss_->Wait(static_cast<int>(cmsNext), process_io))
return false;
}
// If the specified timeout expired, return
msCurrent = Time();
msCurrent = TimeMillis();
cmsElapsed = TimeDiff(msCurrent, msStart);
if (cmsWait != kForever) {
if (cmsElapsed >= cmsWait)
@ -326,7 +326,7 @@ void MessageQueue::Post(MessageHandler* phandler,
msg.message_id = id;
msg.pdata = pdata;
if (time_sensitive) {
msg.ts_sensitive = Time() + kMaxMsgLatency;
msg.ts_sensitive = TimeMillis() + kMaxMsgLatency;
}
msgq_.push_back(msg);
}
@ -344,11 +344,20 @@ void MessageQueue::PostAt(uint32_t tstamp,
MessageHandler* phandler,
uint32_t id,
MessageData* pdata) {
// This should work even if it is used (unexpectedly).
int delay = static_cast<uint32_t>(TimeMillis()) - tstamp;
return DoDelayPost(delay, tstamp, phandler, id, pdata);
}
void MessageQueue::PostAt(int64_t tstamp,
MessageHandler* phandler,
uint32_t id,
MessageData* pdata) {
return DoDelayPost(TimeUntil(tstamp), tstamp, phandler, id, pdata);
}
void MessageQueue::DoDelayPost(int cmsDelay,
uint32_t tstamp,
int64_t tstamp,
MessageHandler* phandler,
uint32_t id,
MessageData* pdata) {

View File

@ -142,7 +142,7 @@ struct Message {
MessageHandler *phandler;
uint32_t message_id;
MessageData *pdata;
uint32_t ts_sensitive;
int64_t ts_sensitive;
};
typedef std::list<Message> MessageList;
@ -152,7 +152,7 @@ typedef std::list<Message> MessageList;
class DelayedMessage {
public:
DelayedMessage(int delay, uint32_t trigger, uint32_t num, const Message& msg)
DelayedMessage(int delay, int64_t trigger, uint32_t num, const Message& msg)
: cmsDelay_(delay), msTrigger_(trigger), num_(num), msg_(msg) {}
bool operator< (const DelayedMessage& dmsg) const {
@ -161,7 +161,7 @@ class DelayedMessage {
}
int cmsDelay_; // for debugging
uint32_t msTrigger_;
int64_t msTrigger_;
uint32_t num_;
Message msg_;
};
@ -212,6 +212,11 @@ class MessageQueue {
MessageHandler* phandler,
uint32_t id = 0,
MessageData* pdata = NULL);
virtual void PostAt(int64_t tstamp,
MessageHandler* phandler,
uint32_t id = 0,
MessageData* pdata = NULL);
// TODO(honghaiz): Remove this when all the dependencies are removed.
virtual void PostAt(uint32_t tstamp,
MessageHandler* phandler,
uint32_t id = 0,
@ -250,7 +255,7 @@ class MessageQueue {
};
void DoDelayPost(int cmsDelay,
uint32_t tstamp,
int64_t tstamp,
MessageHandler* phandler,
uint32_t id,
MessageData* pdata);

View File

@ -54,7 +54,7 @@ struct DeletedLockChecker {
static void DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder(
MessageQueue* q) {
EXPECT_TRUE(q != NULL);
TimeStamp now = Time();
int64_t now = TimeMillis();
q->PostAt(now, NULL, 3);
q->PostAt(now - 2, NULL, 0);
q->PostAt(now - 1, NULL, 1);

View File

@ -37,7 +37,7 @@ TEST_F(NullSocketServerTest, WaitAndSet) {
}
TEST_F(NullSocketServerTest, TestWait) {
uint32_t start = Time();
int64_t start = TimeMillis();
ss_.Wait(200, true);
// The actual wait time is dependent on the resolution of the timer used by
// the Event class. Allow for the event to signal ~20ms early.

View File

@ -1470,9 +1470,9 @@ bool PhysicalSocketServer::InstallSignal(int signum, void (*handler)(int)) {
#if defined(WEBRTC_WIN)
bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) {
int cmsTotal = cmsWait;
int cmsElapsed = 0;
uint32_t msStart = Time();
int64_t cmsTotal = cmsWait;
int64_t cmsElapsed = 0;
int64_t msStart = Time();
fWait_ = true;
while (fWait_) {
@ -1509,18 +1509,18 @@ bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) {
// Which is shorter, the delay wait or the asked wait?
int cmsNext;
int64_t cmsNext;
if (cmsWait == kForever) {
cmsNext = cmsWait;
} else {
cmsNext = std::max(0, cmsTotal - cmsElapsed);
cmsNext = std::max<int64_t>(0, cmsTotal - cmsElapsed);
}
// Wait for one of the events to signal
DWORD dw = WSAWaitForMultipleEvents(static_cast<DWORD>(events.size()),
&events[0],
false,
cmsNext,
static_cast<DWORD>(cmsNext),
false);
if (dw == WSA_WAIT_FAILED) {

View File

@ -19,14 +19,16 @@
namespace rtc {
RateTracker::RateTracker(uint32_t bucket_milliseconds, size_t bucket_count)
static const int64_t kTimeUnset = -1;
RateTracker::RateTracker(int64_t bucket_milliseconds, size_t bucket_count)
: bucket_milliseconds_(bucket_milliseconds),
bucket_count_(bucket_count),
sample_buckets_(new size_t[bucket_count + 1]),
total_sample_count_(0u),
bucket_start_time_milliseconds_(~0u) {
RTC_CHECK(bucket_milliseconds > 0u);
RTC_CHECK(bucket_count > 0u);
bucket_start_time_milliseconds_(kTimeUnset) {
RTC_CHECK(bucket_milliseconds > 0);
RTC_CHECK(bucket_count > 0);
}
RateTracker::~RateTracker() {
@ -34,33 +36,33 @@ RateTracker::~RateTracker() {
}
double RateTracker::ComputeRateForInterval(
uint32_t interval_milliseconds) const {
if (bucket_start_time_milliseconds_ == ~0u) {
int64_t interval_milliseconds) const {
if (bucket_start_time_milliseconds_ == kTimeUnset) {
return 0.0;
}
uint32_t current_time = Time();
int64_t current_time = Time();
// Calculate which buckets to sum up given the current time. If the time
// has passed to a new bucket then we have to skip some of the oldest buckets.
uint32_t available_interval_milliseconds = std::min<uint32_t>(
interval_milliseconds,
bucket_milliseconds_ * static_cast<uint32_t>(bucket_count_));
int64_t available_interval_milliseconds =
std::min(interval_milliseconds,
bucket_milliseconds_ * static_cast<int64_t>(bucket_count_));
// number of old buckets (i.e. after the current bucket in the ring buffer)
// that are expired given our current time interval.
size_t buckets_to_skip;
// Number of milliseconds of the first bucket that are not a portion of the
// current interval.
uint32_t milliseconds_to_skip;
int64_t milliseconds_to_skip;
if (current_time >
initialization_time_milliseconds_ + available_interval_milliseconds) {
uint32_t time_to_skip =
int64_t time_to_skip =
current_time - bucket_start_time_milliseconds_ +
static_cast<uint32_t>(bucket_count_) * bucket_milliseconds_ -
static_cast<int64_t>(bucket_count_) * bucket_milliseconds_ -
available_interval_milliseconds;
buckets_to_skip = time_to_skip / bucket_milliseconds_;
milliseconds_to_skip = time_to_skip % bucket_milliseconds_;
} else {
buckets_to_skip = bucket_count_ - current_bucket_;
milliseconds_to_skip = 0u;
milliseconds_to_skip = 0;
available_interval_milliseconds =
TimeDiff(current_time, initialization_time_milliseconds_);
// Let one bucket interval pass after initialization before reporting.
@ -70,8 +72,7 @@ double RateTracker::ComputeRateForInterval(
}
// If we're skipping all buckets that means that there have been no samples
// within the sampling interval so report 0.
if (buckets_to_skip > bucket_count_ ||
available_interval_milliseconds == 0u) {
if (buckets_to_skip > bucket_count_ || available_interval_milliseconds == 0) {
return 0.0;
}
size_t start_bucket = NextBucketIndex(current_bucket_ + buckets_to_skip);
@ -88,21 +89,21 @@ double RateTracker::ComputeRateForInterval(
total_samples += sample_buckets_[i];
}
// Convert to samples per second.
return static_cast<double>(total_samples * 1000u) /
static_cast<double>(available_interval_milliseconds);
return static_cast<double>(total_samples * 1000) /
static_cast<double>(available_interval_milliseconds);
}
double RateTracker::ComputeTotalRate() const {
if (bucket_start_time_milliseconds_ == ~0u) {
if (bucket_start_time_milliseconds_ == kTimeUnset) {
return 0.0;
}
uint32_t current_time = Time();
if (TimeIsLaterOrEqual(current_time, initialization_time_milliseconds_)) {
int64_t current_time = Time();
if (current_time <= initialization_time_milliseconds_) {
return 0.0;
}
return static_cast<double>(total_sample_count_ * 1000u) /
static_cast<double>(
TimeDiff(current_time, initialization_time_milliseconds_));
return static_cast<double>(total_sample_count_ * 1000) /
static_cast<double>(
TimeDiff(current_time, initialization_time_milliseconds_));
}
size_t RateTracker::TotalSampleCount() const {
@ -111,15 +112,16 @@ size_t RateTracker::TotalSampleCount() const {
void RateTracker::AddSamples(size_t sample_count) {
EnsureInitialized();
uint32_t current_time = Time();
int64_t current_time = Time();
// Advance the current bucket as needed for the current time, and reset
// bucket counts as we advance.
for (size_t i = 0u; i <= bucket_count_ &&
current_time >= bucket_start_time_milliseconds_ + bucket_milliseconds_;
++i) {
for (size_t i = 0;
i <= bucket_count_ &&
current_time >= bucket_start_time_milliseconds_ + bucket_milliseconds_;
++i) {
bucket_start_time_milliseconds_ += bucket_milliseconds_;
current_bucket_ = NextBucketIndex(current_bucket_);
sample_buckets_[current_bucket_] = 0u;
sample_buckets_[current_bucket_] = 0;
}
// Ensure that bucket_start_time_milliseconds_ is updated appropriately if
// the entire buffer of samples has been expired.
@ -130,18 +132,18 @@ void RateTracker::AddSamples(size_t sample_count) {
total_sample_count_ += sample_count;
}
uint32_t RateTracker::Time() const {
return rtc::Time();
int64_t RateTracker::Time() const {
return rtc::TimeMillis();
}
void RateTracker::EnsureInitialized() {
if (bucket_start_time_milliseconds_ == ~0u) {
if (bucket_start_time_milliseconds_ == kTimeUnset) {
initialization_time_milliseconds_ = Time();
bucket_start_time_milliseconds_ = initialization_time_milliseconds_;
current_bucket_ = 0u;
current_bucket_ = 0;
// We only need to initialize the first bucket because we reset buckets when
// current_bucket_ increments.
sample_buckets_[current_bucket_] = 0u;
sample_buckets_[current_bucket_] = 0;
}
}

View File

@ -21,19 +21,19 @@ namespace rtc {
// that over each bucket the rate was constant.
class RateTracker {
public:
RateTracker(uint32_t bucket_milliseconds, size_t bucket_count);
RateTracker(int64_t bucket_milliseconds, size_t bucket_count);
virtual ~RateTracker();
// Computes the average rate over the most recent interval_milliseconds,
// or if the first sample was added within this period, computes the rate
// since the first sample was added.
double ComputeRateForInterval(uint32_t interval_milliseconds) const;
double ComputeRateForInterval(int64_t interval_milliseconds) const;
// Computes the average rate over the rate tracker's recording interval
// of bucket_milliseconds * bucket_count.
double ComputeRate() const {
return ComputeRateForInterval(bucket_milliseconds_ *
static_cast<uint32_t>(bucket_count_));
static_cast<int64_t>(bucket_count_));
}
// Computes the average rate since the first sample was added to the
@ -49,19 +49,19 @@ class RateTracker {
protected:
// overrideable for tests
virtual uint32_t Time() const;
virtual int64_t Time() const;
private:
void EnsureInitialized();
size_t NextBucketIndex(size_t bucket_index) const;
const uint32_t bucket_milliseconds_;
const int64_t bucket_milliseconds_;
const size_t bucket_count_;
size_t* sample_buckets_;
size_t total_sample_count_;
size_t current_bucket_;
uint32_t bucket_start_time_milliseconds_;
uint32_t initialization_time_milliseconds_;
int64_t bucket_start_time_milliseconds_;
int64_t initialization_time_milliseconds_;
};
} // namespace rtc

View File

@ -19,11 +19,11 @@ namespace {
class RateTrackerForTest : public RateTracker {
public:
RateTrackerForTest() : RateTracker(kBucketIntervalMs, 10u), time_(0) {}
virtual uint32_t Time() const { return time_; }
void AdvanceTime(uint32_t delta) { time_ += delta; }
virtual int64_t Time() const { return time_; }
void AdvanceTime(int delta) { time_ += delta; }
private:
uint32_t time_;
int64_t time_;
};
TEST(RateTrackerTest, Test30FPS) {
@ -36,7 +36,7 @@ TEST(RateTrackerTest, Test30FPS) {
tracker.AdvanceTime(1);
}
}
EXPECT_DOUBLE_EQ(30.0, tracker.ComputeRateForInterval(50000u));
EXPECT_DOUBLE_EQ(30.0, tracker.ComputeRateForInterval(50000));
}
TEST(RateTrackerTest, Test60FPS) {
@ -49,12 +49,12 @@ TEST(RateTrackerTest, Test60FPS) {
tracker.AdvanceTime(1);
}
}
EXPECT_DOUBLE_EQ(60.0, tracker.ComputeRateForInterval(1000u));
EXPECT_DOUBLE_EQ(60.0, tracker.ComputeRateForInterval(1000));
}
TEST(RateTrackerTest, TestRateTrackerBasics) {
RateTrackerForTest tracker;
EXPECT_DOUBLE_EQ(0.0, tracker.ComputeRateForInterval(1000u));
EXPECT_DOUBLE_EQ(0.0, tracker.ComputeRateForInterval(1000));
// Add a sample.
tracker.AddSamples(1234);
@ -63,7 +63,7 @@ TEST(RateTrackerTest, TestRateTrackerBasics) {
EXPECT_DOUBLE_EQ(0.0, tracker.ComputeRate());
// Advance the clock by 100 ms (one bucket interval).
tracker.AdvanceTime(1);
EXPECT_DOUBLE_EQ(12340.0, tracker.ComputeRateForInterval(1000u));
EXPECT_DOUBLE_EQ(12340.0, tracker.ComputeRateForInterval(1000));
EXPECT_DOUBLE_EQ(12340.0, tracker.ComputeRate());
EXPECT_EQ(1234U, tracker.TotalSampleCount());
EXPECT_DOUBLE_EQ(12340.0, tracker.ComputeTotalRate());
@ -71,7 +71,7 @@ TEST(RateTrackerTest, TestRateTrackerBasics) {
// Repeat.
tracker.AddSamples(1234);
tracker.AdvanceTime(100);
EXPECT_DOUBLE_EQ(12340.0, tracker.ComputeRateForInterval(1000u));
EXPECT_DOUBLE_EQ(12340.0, tracker.ComputeRateForInterval(1000));
EXPECT_DOUBLE_EQ(12340.0, tracker.ComputeRate());
EXPECT_EQ(1234U * 2, tracker.TotalSampleCount());
EXPECT_DOUBLE_EQ(12340.0, tracker.ComputeTotalRate());
@ -79,20 +79,20 @@ TEST(RateTrackerTest, TestRateTrackerBasics) {
// Advance the clock by 800 ms, so we've elapsed a full second.
// units_second should now be filled in properly.
tracker.AdvanceTime(800);
EXPECT_DOUBLE_EQ(1234.0 * 2.0, tracker.ComputeRateForInterval(1000u));
EXPECT_DOUBLE_EQ(1234.0 * 2.0, tracker.ComputeRateForInterval(1000));
EXPECT_DOUBLE_EQ(1234.0 * 2.0, tracker.ComputeRate());
EXPECT_EQ(1234U * 2, tracker.TotalSampleCount());
EXPECT_DOUBLE_EQ(1234.0 * 2.0, tracker.ComputeTotalRate());
// Poll the tracker again immediately. The reported rate should stay the same.
EXPECT_DOUBLE_EQ(1234.0 * 2.0, tracker.ComputeRateForInterval(1000u));
EXPECT_DOUBLE_EQ(1234.0 * 2.0, tracker.ComputeRateForInterval(1000));
EXPECT_DOUBLE_EQ(1234.0 * 2.0, tracker.ComputeRate());
EXPECT_EQ(1234U * 2, tracker.TotalSampleCount());
EXPECT_DOUBLE_EQ(1234.0 * 2.0, tracker.ComputeTotalRate());
// Do nothing and advance by a second. We should drop down to zero.
tracker.AdvanceTime(1000);
EXPECT_DOUBLE_EQ(0.0, tracker.ComputeRateForInterval(1000u));
EXPECT_DOUBLE_EQ(0.0, tracker.ComputeRateForInterval(1000));
EXPECT_DOUBLE_EQ(0.0, tracker.ComputeRate());
EXPECT_EQ(1234U * 2, tracker.TotalSampleCount());
EXPECT_DOUBLE_EQ(1234.0, tracker.ComputeTotalRate());
@ -103,7 +103,7 @@ TEST(RateTrackerTest, TestRateTrackerBasics) {
tracker.AddSamples(9876U);
tracker.AdvanceTime(100);
}
EXPECT_DOUBLE_EQ(9876.0 * 10.0, tracker.ComputeRateForInterval(1000u));
EXPECT_DOUBLE_EQ(9876.0 * 10.0, tracker.ComputeRateForInterval(1000));
EXPECT_DOUBLE_EQ(9876.0 * 10.0, tracker.ComputeRate());
EXPECT_EQ(1234U * 2 + 9876U * 55, tracker.TotalSampleCount());
EXPECT_DOUBLE_EQ((1234.0 * 2.0 + 9876.0 * 55.0) / 7.5,
@ -112,14 +112,14 @@ TEST(RateTrackerTest, TestRateTrackerBasics) {
// Advance the clock by 500 ms. Since we sent nothing over this half-second,
// the reported rate should be reduced by half.
tracker.AdvanceTime(500);
EXPECT_DOUBLE_EQ(9876.0 * 5.0, tracker.ComputeRateForInterval(1000u));
EXPECT_DOUBLE_EQ(9876.0 * 5.0, tracker.ComputeRateForInterval(1000));
EXPECT_DOUBLE_EQ(9876.0 * 5.0, tracker.ComputeRate());
EXPECT_EQ(1234U * 2 + 9876U * 55, tracker.TotalSampleCount());
EXPECT_DOUBLE_EQ((1234.0 * 2.0 + 9876.0 * 55.0) / 8.0,
tracker.ComputeTotalRate());
// Rate over the last half second should be zero.
EXPECT_DOUBLE_EQ(0.0, tracker.ComputeRateForInterval(500u));
EXPECT_DOUBLE_EQ(0.0, tracker.ComputeRateForInterval(500));
}
TEST(RateTrackerTest, TestLongPeriodBetweenSamples) {
@ -149,7 +149,7 @@ TEST(RateTrackerTest, TestRolloff) {
tracker.AdvanceTime(50);
}
EXPECT_DOUBLE_EQ(15.0, tracker.ComputeRate());
EXPECT_DOUBLE_EQ(20.0, tracker.ComputeRateForInterval(500u));
EXPECT_DOUBLE_EQ(20.0, tracker.ComputeRateForInterval(500));
for (int i = 0; i < 10; ++i) {
tracker.AddSamples(1U);
@ -162,7 +162,7 @@ TEST(RateTrackerTest, TestGetUnitSecondsAfterInitialValue) {
RateTrackerForTest tracker;
tracker.AddSamples(1234);
tracker.AdvanceTime(1000);
EXPECT_DOUBLE_EQ(1234.0, tracker.ComputeRateForInterval(1000u));
EXPECT_DOUBLE_EQ(1234.0, tracker.ComputeRateForInterval(1000));
}
} // namespace rtc

View File

@ -50,12 +50,12 @@ class SharedExclusiveTask : public MessageHandler {
worker_thread_->Start();
}
int waiting_time_in_ms() const { return waiting_time_in_ms_; }
int64_t waiting_time_in_ms() const { return waiting_time_in_ms_; }
protected:
std::unique_ptr<Thread> worker_thread_;
SharedExclusiveLock* shared_exclusive_lock_;
int waiting_time_in_ms_;
int64_t waiting_time_in_ms_;
int* value_;
bool* done_;
};
@ -79,10 +79,10 @@ class ReadTask : public SharedExclusiveTask {
TypedMessageData<int*>* message_data =
static_cast<TypedMessageData<int*>*>(message->pdata);
uint32_t start_time = Time();
int64_t start_time = TimeMillis();
{
SharedScope ss(shared_exclusive_lock_);
waiting_time_in_ms_ = TimeDiff(Time(), start_time);
waiting_time_in_ms_ = TimeDiff(TimeMillis(), start_time);
Thread::SleepMs(kProcessTimeInMs);
*message_data->data() = *value_;
@ -112,10 +112,10 @@ class WriteTask : public SharedExclusiveTask {
TypedMessageData<int>* message_data =
static_cast<TypedMessageData<int>*>(message->pdata);
uint32_t start_time = Time();
int64_t start_time = TimeMillis();
{
ExclusiveScope es(shared_exclusive_lock_);
waiting_time_in_ms_ = TimeDiff(Time(), start_time);
waiting_time_in_ms_ = TimeDiff(TimeMillis(), start_time);
Thread::SleepMs(kProcessTimeInMs);
*value_ = message_data->data();

View File

@ -33,7 +33,7 @@
namespace rtc {
static int64_t GetCurrentTime() {
return static_cast<int64_t>(Time()) * 10000;
return TimeMillis() * 10000;
}
// feel free to change these numbers. Note that '0' won't work, though

View File

@ -482,7 +482,7 @@ void Thread::Clear(MessageHandler* phandler,
}
bool Thread::ProcessMessages(int cmsLoop) {
uint32_t msEnd = (kForever == cmsLoop) ? 0 : TimeAfter(cmsLoop);
int64_t msEnd = (kForever == cmsLoop) ? 0 : TimeAfter(cmsLoop);
int cmsNext = cmsLoop;
while (true) {

View File

@ -30,8 +30,6 @@
namespace rtc {
const uint32_t HALF = 0x80000000;
uint64_t TimeNanos() {
int64_t ticks = 0;
#if defined(WEBRTC_MAC)
@ -90,27 +88,16 @@ uint64_t TimeMicros() {
return static_cast<uint64_t>(TimeNanos() / kNumNanosecsPerMicrosec);
}
uint32_t TimeAfter(int32_t elapsed) {
int64_t TimeAfter(int64_t elapsed) {
RTC_DCHECK_GE(elapsed, 0);
RTC_DCHECK_LT(static_cast<uint32_t>(elapsed), HALF);
return Time() + elapsed;
return TimeMillis() + elapsed;
}
bool TimeIsLaterOrEqual(uint32_t earlier, uint32_t later) {
int32_t diff = later - earlier;
return (diff >= 0 && static_cast<uint32_t>(diff) < HALF);
}
bool TimeIsLater(uint32_t earlier, uint32_t later) {
int32_t diff = later - earlier;
return (diff > 0 && static_cast<uint32_t>(diff) < HALF);
}
int32_t TimeDiff(uint32_t later, uint32_t earlier) {
int32_t TimeDiff32(uint32_t later, uint32_t earlier) {
return later - earlier;
}
int64_t TimeDiff64(int64_t later, int64_t earlier) {
int64_t TimeDiff(int64_t later, int64_t earlier) {
return later - earlier;
}

View File

@ -29,58 +29,40 @@ static const int64_t kNumNanosecsPerMillisec =
static const int64_t kNumNanosecsPerMicrosec =
kNumNanosecsPerSec / kNumMicrosecsPerSec;
typedef uint32_t TimeStamp;
// TODO(honghaiz): Define a type for the time value specifically.
// Returns the current time in milliseconds in 32 bits.
uint32_t Time32();
// Returns the current time in milliseconds in 64 bits.
int64_t TimeMillis();
// Returns the current time in milliseconds.
// TODO(honghaiz): Change to return TimeMillis() once majority of the webrtc
// code migrates to 64-bit timestamp.
inline uint32_t Time() {
return Time32();
// Deprecated. Do not use this in any new code.
inline int64_t Time() {
return TimeMillis();
}
// Returns the current time in microseconds.
uint64_t TimeMicros();
// Returns the current time in nanoseconds.
uint64_t TimeNanos();
// Returns a future timestamp, 'elapsed' milliseconds from now.
uint32_t TimeAfter(int32_t elapsed);
bool TimeIsLaterOrEqual(uint32_t earlier, uint32_t later); // Inclusive
bool TimeIsLater(uint32_t earlier, uint32_t later); // Exclusive
// Returns the later of two timestamps.
inline uint32_t TimeMax(uint32_t ts1, uint32_t ts2) {
return TimeIsLaterOrEqual(ts1, ts2) ? ts2 : ts1;
}
// Returns the earlier of two timestamps.
inline uint32_t TimeMin(uint32_t ts1, uint32_t ts2) {
return TimeIsLaterOrEqual(ts1, ts2) ? ts1 : ts2;
}
int64_t TimeAfter(int64_t elapsed);
// Number of milliseconds that would elapse between 'earlier' and 'later'
// timestamps. The value is negative if 'later' occurs before 'earlier'.
int32_t TimeDiff(uint32_t later, uint32_t earlier);
// Number of milliseconds that would elapse between 'earlier' and 'later'
// timestamps. The value is negative if 'later' occurs before 'earlier'.
int64_t TimeDiff64(int64_t later, int64_t earlier);
int64_t TimeDiff(int64_t later, int64_t earlier);
int32_t TimeDiff32(uint32_t later, uint32_t earlier);
// The number of milliseconds that have elapsed since 'earlier'.
inline int32_t TimeSince(uint32_t earlier) {
return TimeDiff(Time(), earlier);
inline int64_t TimeSince(int64_t earlier) {
return TimeMillis() - earlier;
}
// The number of milliseconds that will elapse between now and 'later'.
inline int32_t TimeUntil(uint32_t later) {
return TimeDiff(later, Time());
inline int64_t TimeUntil(uint64_t later) {
return later - TimeMillis();
}
class TimestampWrapAroundHandler {

View File

@ -17,59 +17,21 @@
namespace rtc {
TEST(TimeTest, TimeInMs) {
uint32_t ts_earlier = Time();
int64_t ts_earlier = TimeMillis();
Thread::SleepMs(100);
uint32_t ts_now = Time();
int64_t ts_now = TimeMillis();
// Allow for the thread to wakeup ~20ms early.
EXPECT_GE(ts_now, ts_earlier + 80);
// Make sure the Time is not returning in smaller unit like microseconds.
EXPECT_LT(ts_now, ts_earlier + 1000);
}
TEST(TimeTest, Comparison) {
// Obtain two different times, in known order
TimeStamp ts_earlier = Time();
Thread::SleepMs(100);
TimeStamp ts_now = Time();
EXPECT_NE(ts_earlier, ts_now);
// Common comparisons
EXPECT_TRUE( TimeIsLaterOrEqual(ts_earlier, ts_now));
EXPECT_TRUE( TimeIsLater( ts_earlier, ts_now));
EXPECT_FALSE(TimeIsLaterOrEqual(ts_now, ts_earlier));
EXPECT_FALSE(TimeIsLater( ts_now, ts_earlier));
// Edge cases
EXPECT_TRUE( TimeIsLaterOrEqual(ts_earlier, ts_earlier));
EXPECT_FALSE(TimeIsLater( ts_earlier, ts_earlier));
// Obtain a third time
TimeStamp ts_later = TimeAfter(100);
EXPECT_NE(ts_now, ts_later);
EXPECT_TRUE( TimeIsLater(ts_now, ts_later));
EXPECT_TRUE( TimeIsLater(ts_earlier, ts_later));
// Earlier of two times
EXPECT_EQ(ts_earlier, TimeMin(ts_earlier, ts_earlier));
EXPECT_EQ(ts_earlier, TimeMin(ts_earlier, ts_now));
EXPECT_EQ(ts_earlier, TimeMin(ts_earlier, ts_later));
EXPECT_EQ(ts_earlier, TimeMin(ts_now, ts_earlier));
EXPECT_EQ(ts_earlier, TimeMin(ts_later, ts_earlier));
// Later of two times
EXPECT_EQ(ts_earlier, TimeMax(ts_earlier, ts_earlier));
EXPECT_EQ(ts_now, TimeMax(ts_earlier, ts_now));
EXPECT_EQ(ts_later, TimeMax(ts_earlier, ts_later));
EXPECT_EQ(ts_now, TimeMax(ts_now, ts_earlier));
EXPECT_EQ(ts_later, TimeMax(ts_later, ts_earlier));
}
TEST(TimeTest, Intervals) {
TimeStamp ts_earlier = Time();
TimeStamp ts_later = TimeAfter(500);
int64_t ts_earlier = TimeMillis();
int64_t ts_later = TimeAfter(500);
// We can't depend on ts_later and ts_earlier to be exactly 500 apart
// since time elapses between the calls to Time() and TimeAfter(500)
// since time elapses between the calls to TimeMillis() and TimeAfter(500)
EXPECT_LE(500, TimeDiff(ts_later, ts_earlier));
EXPECT_GE(-500, TimeDiff(ts_earlier, ts_later));
@ -87,33 +49,6 @@ TEST(TimeTest, Intervals) {
EXPECT_LE(TimeUntil(ts_later), 500);
}
TEST(TimeTest, BoundaryComparison) {
// Obtain two different times, in known order
TimeStamp ts_earlier = static_cast<TimeStamp>(-50);
TimeStamp ts_later = ts_earlier + 100;
EXPECT_NE(ts_earlier, ts_later);
// Common comparisons
EXPECT_TRUE( TimeIsLaterOrEqual(ts_earlier, ts_later));
EXPECT_TRUE( TimeIsLater( ts_earlier, ts_later));
EXPECT_FALSE(TimeIsLaterOrEqual(ts_later, ts_earlier));
EXPECT_FALSE(TimeIsLater( ts_later, ts_earlier));
// Earlier of two times
EXPECT_EQ(ts_earlier, TimeMin(ts_earlier, ts_earlier));
EXPECT_EQ(ts_earlier, TimeMin(ts_earlier, ts_later));
EXPECT_EQ(ts_earlier, TimeMin(ts_later, ts_earlier));
// Later of two times
EXPECT_EQ(ts_earlier, TimeMax(ts_earlier, ts_earlier));
EXPECT_EQ(ts_later, TimeMax(ts_earlier, ts_later));
EXPECT_EQ(ts_later, TimeMax(ts_later, ts_earlier));
// Interval
EXPECT_EQ(100, TimeDiff(ts_later, ts_earlier));
EXPECT_EQ(-100, TimeDiff(ts_earlier, ts_later));
}
TEST(TimeTest, TestTimeDiff64) {
int64_t ts_diff = 100;
int64_t ts_earlier = rtc::TimeMillis();

View File

@ -35,7 +35,7 @@ struct Sender : public MessageHandler {
done(false),
rate(rt),
count(0) {
last_send = rtc::Time();
last_send = rtc::TimeMillis();
thread->PostDelayed(NextDelay(), this, 1);
}
@ -50,9 +50,9 @@ struct Sender : public MessageHandler {
if (done)
return;
uint32_t cur_time = rtc::Time();
uint32_t delay = cur_time - last_send;
uint32_t size = rate * delay / 1000;
int64_t cur_time = rtc::TimeMillis();
int64_t delay = cur_time - last_send;
uint32_t size = static_cast<uint32_t>(rate * delay / 1000);
size = std::min<uint32_t>(size, 4096);
size = std::max<uint32_t>(size, sizeof(uint32_t));
@ -70,7 +70,7 @@ struct Sender : public MessageHandler {
bool done;
uint32_t rate; // bytes per second
uint32_t count;
uint32_t last_send;
int64_t last_send;
char dummy[4096];
};
@ -103,7 +103,7 @@ struct Receiver : public MessageHandler, public sigslot::has_slots<> {
sec_count += size;
uint32_t send_time = *reinterpret_cast<const uint32_t*>(data);
uint32_t recv_time = rtc::Time();
uint32_t recv_time = rtc::TimeMillis();
uint32_t delay = recv_time - send_time;
sum += delay;
sum_sq += delay * delay;

View File

@ -501,15 +501,25 @@ int VirtualSocket::SendTcp(const void* pv, size_t cb) {
}
VirtualSocketServer::VirtualSocketServer(SocketServer* ss)
: server_(ss), server_owned_(false), msg_queue_(NULL), stop_on_idle_(false),
network_delay_(Time()), next_ipv4_(kInitialNextIPv4),
next_ipv6_(kInitialNextIPv6), next_port_(kFirstEphemeralPort),
bindings_(new AddressMap()), connections_(new ConnectionMap()),
bandwidth_(0), network_capacity_(kDefaultNetworkCapacity),
: server_(ss),
server_owned_(false),
msg_queue_(NULL),
stop_on_idle_(false),
network_delay_(TimeMillis()),
next_ipv4_(kInitialNextIPv4),
next_ipv6_(kInitialNextIPv6),
next_port_(kFirstEphemeralPort),
bindings_(new AddressMap()),
connections_(new ConnectionMap()),
bandwidth_(0),
network_capacity_(kDefaultNetworkCapacity),
send_buffer_capacity_(kDefaultTcpBufferSize),
recv_buffer_capacity_(kDefaultTcpBufferSize),
delay_mean_(0), delay_stddev_(0), delay_samples_(NUM_SAMPLES),
delay_dist_(NULL), drop_prob_(0.0) {
delay_mean_(0),
delay_stddev_(0),
delay_samples_(NUM_SAMPLES),
delay_dist_(NULL),
drop_prob_(0.0) {
if (!server_) {
server_ = new PhysicalSocketServer();
server_owned_ = true;
@ -792,7 +802,7 @@ int VirtualSocketServer::SendUdp(VirtualSocket* socket,
CritScope cs(&socket->crit_);
uint32_t cur_time = Time();
int64_t cur_time = TimeMillis();
PurgeNetworkPackets(socket, cur_time);
// Determine whether we have enough bandwidth to accept this packet. To do
@ -832,7 +842,7 @@ void VirtualSocketServer::SendTcp(VirtualSocket* socket) {
CritScope cs(&socket->crit_);
uint32_t cur_time = Time();
int64_t cur_time = TimeMillis();
PurgeNetworkPackets(socket, cur_time);
while (true) {
@ -867,7 +877,7 @@ void VirtualSocketServer::SendTcp(VirtualSocket* socket) {
void VirtualSocketServer::AddPacketToNetwork(VirtualSocket* sender,
VirtualSocket* recipient,
uint32_t cur_time,
int64_t cur_time,
const char* data,
size_t data_size,
size_t header_size,
@ -895,19 +905,19 @@ void VirtualSocketServer::AddPacketToNetwork(VirtualSocket* sender,
// Post the packet as a message to be delivered (on our own thread)
Packet* p = new Packet(data, data_size, sender_addr);
uint32_t ts = TimeAfter(send_delay + transit_delay);
int64_t ts = TimeAfter(send_delay + transit_delay);
if (ordered) {
// Ensure that new packets arrive after previous ones
// TODO: consider ordering on a per-socket basis, since this
// introduces artifical delay.
ts = TimeMax(ts, network_delay_);
// introduces artificial delay.
ts = std::max(ts, network_delay_);
}
msg_queue_->PostAt(ts, recipient, MSG_ID_PACKET, p);
network_delay_ = TimeMax(ts, network_delay_);
network_delay_ = std::max(ts, network_delay_);
}
void VirtualSocketServer::PurgeNetworkPackets(VirtualSocket* socket,
uint32_t cur_time) {
int64_t cur_time) {
while (!socket->network_.empty() &&
(socket->network_.front().done_time <= cur_time)) {
ASSERT(socket->network_size_ >= socket->network_.front().size);

View File

@ -169,14 +169,14 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> {
// Places a packet on the network.
void AddPacketToNetwork(VirtualSocket* socket,
VirtualSocket* recipient,
uint32_t cur_time,
int64_t cur_time,
const char* data,
size_t data_size,
size_t header_size,
bool ordered);
// Removes stale packets from the network
void PurgeNetworkPackets(VirtualSocket* socket, uint32_t cur_time);
void PurgeNetworkPackets(VirtualSocket* socket, int64_t cur_time);
// Computes the number of milliseconds required to send a packet of this size.
uint32_t SendDelay(uint32_t size);
@ -227,7 +227,7 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> {
bool server_owned_;
MessageQueue* msg_queue_;
bool stop_on_idle_;
uint32_t network_delay_;
int64_t network_delay_;
in_addr next_ipv4_;
in6_addr next_ipv6_;
uint16_t next_port_;
@ -293,7 +293,7 @@ class VirtualSocket : public AsyncSocket, public MessageHandler {
private:
struct NetworkEntry {
size_t size;
uint32_t done_time;
int64_t done_time;
};
typedef std::deque<SocketAddress> ListenQueue;

View File

@ -627,7 +627,7 @@ void Win32Socket::OnSocketNotify(SOCKET socket, int event, int error) {
if (error != ERROR_SUCCESS) {
ReportWSAError("WSAAsync:connect notify", error, addr_);
#if !defined(NDEBUG)
int32_t duration = TimeSince(connect_time_);
int64_t duration = TimeSince(connect_time_);
LOG(LS_INFO) << "WSAAsync:connect error (" << duration
<< " ms), faking close";
#endif
@ -640,7 +640,7 @@ void Win32Socket::OnSocketNotify(SOCKET socket, int event, int error) {
SignalCloseEvent(this, error);
} else {
#if !defined(NDEBUG)
int32_t duration = TimeSince(connect_time_);
int64_t duration = TimeSince(connect_time_);
LOG(LS_INFO) << "WSAAsync:connect (" << duration << " ms)";
#endif
state_ = CS_CONNECTED;

View File

@ -159,6 +159,6 @@ class Win32Thread : public Thread {
} // namespace rtc
#endif // WEBRTC_WIN
#endif // WEBRTC_WIN
#endif // WEBRTC_BASE_WIN32SOCKETSERVER_H_

View File

@ -57,7 +57,7 @@ int PingTask::ProcessStart() {
ping_response_deadline_ = 0;
}
uint32_t now = rtc::Time();
int64_t now = rtc::TimeMillis();
// If the ping timed out, signal.
if (ping_response_deadline_ != 0 && now >= ping_response_deadline_) {

View File

@ -46,8 +46,8 @@ class PingTask : public buzz::XmppTask, private rtc::MessageHandler {
rtc::MessageQueue* message_queue_;
uint32_t ping_period_millis_;
uint32_t ping_timeout_millis_;
uint32_t next_ping_time_;
uint32_t ping_response_deadline_; // 0 if the response has been received
int64_t next_ping_time_;
int64_t ping_response_deadline_; // 0 if the response has been received
};
} // namespace buzz

View File

@ -50,7 +50,7 @@ void XmppPump::WakeTasks() {
}
int64_t XmppPump::CurrentTime() {
return (int64_t)rtc::Time();
return (int64_t)rtc::TimeMillis();
}
void XmppPump::OnMessage(rtc::Message *pmsg) {

View File

@ -28,13 +28,12 @@ namespace cricket {
const char RtpDumpFileHeader::kFirstLine[] = "#!rtpplay1.0 0.0.0.0/0\n";
RtpDumpFileHeader::RtpDumpFileHeader(uint32_t start_ms, uint32_t s, uint16_t p)
: start_sec(start_ms / 1000),
start_usec(start_ms % 1000 * 1000),
RtpDumpFileHeader::RtpDumpFileHeader(int64_t start_ms, uint32_t s, uint16_t p)
: start_sec(static_cast<uint32_t>(start_ms / 1000)),
start_usec(static_cast<uint32_t>(start_ms % 1000 * 1000)),
source(s),
port(p),
padding(0) {
}
padding(0) {}
void RtpDumpFileHeader::WriteToByteBuffer(rtc::ByteBufferWriter* buf) {
buf->WriteUInt32(start_sec);
@ -44,7 +43,7 @@ void RtpDumpFileHeader::WriteToByteBuffer(rtc::ByteBufferWriter* buf) {
buf->WriteUInt16(padding);
}
static const uint32_t kDefaultTimeIncrease = 30;
static const int kDefaultTimeIncrease = 30;
bool RtpDumpPacket::IsValidRtpPacket() const {
return original_data_len >= data.size() &&
@ -162,7 +161,7 @@ rtc::StreamResult RtpDumpReader::ReadFileHeader() {
uint32_t start_usec;
buf.ReadUInt32(&start_sec);
buf.ReadUInt32(&start_usec);
start_time_ms_ = start_sec * 1000 + start_usec / 1000;
start_time_ms_ = static_cast<int64_t>(start_sec * 1000 + start_usec / 1000);
// Increase the length by 1 since first_line does not contain the ending \n.
first_line_and_file_header_len_ = first_line.size() + 1 + sizeof(header);
}
@ -305,9 +304,8 @@ RtpDumpWriter::RtpDumpWriter(rtc::StreamInterface* stream)
: stream_(stream),
packet_filter_(PF_ALL),
file_header_written_(false),
start_time_ms_(rtc::Time()),
warn_slow_writes_delay_(kWarnSlowWritesDelayMs) {
}
start_time_ms_(rtc::TimeMillis()),
warn_slow_writes_delay_(kWarnSlowWritesDelayMs) {}
void RtpDumpWriter::set_packet_filter(int filter) {
packet_filter_ = filter;
@ -315,7 +313,7 @@ void RtpDumpWriter::set_packet_filter(int filter) {
}
uint32_t RtpDumpWriter::GetElapsedTime() const {
return rtc::TimeSince(start_time_ms_);
return static_cast<uint32_t>(rtc::TimeSince(start_time_ms_));
}
rtc::StreamResult RtpDumpWriter::WriteFileHeader() {
@ -327,7 +325,7 @@ rtc::StreamResult RtpDumpWriter::WriteFileHeader() {
}
rtc::ByteBufferWriter buf;
RtpDumpFileHeader file_header(rtc::Time(), 0, 0);
RtpDumpFileHeader file_header(rtc::TimeMillis(), 0, 0);
file_header.WriteToByteBuffer(&buf);
return WriteToStream(buf.Data(), buf.Length());
}
@ -395,10 +393,10 @@ size_t RtpDumpWriter::FilterPacket(const void* data, size_t data_len,
rtc::StreamResult RtpDumpWriter::WriteToStream(
const void* data, size_t data_len) {
uint32_t before = rtc::Time();
int64_t before = rtc::TimeMillis();
rtc::StreamResult result =
stream_->WriteAll(data, data_len, NULL, NULL);
uint32_t delay = rtc::TimeSince(before);
int64_t delay = rtc::TimeSince(before);
if (delay >= warn_slow_writes_delay_) {
LOG(LS_WARNING) << "Slow RtpDump: took " << delay << "ms to write "
<< data_len << " bytes.";

View File

@ -40,7 +40,7 @@ enum RtpDumpPacketFilter {
};
struct RtpDumpFileHeader {
RtpDumpFileHeader(uint32_t start_ms, uint32_t s, uint16_t p);
RtpDumpFileHeader(int64_t start_ms, uint32_t s, uint16_t p);
void WriteToByteBuffer(rtc::ByteBufferWriter* buf);
static const char kFirstLine[];
@ -113,7 +113,7 @@ class RtpDumpReader {
rtc::StreamInterface* stream_;
bool file_header_read_;
size_t first_line_and_file_header_len_;
uint32_t start_time_ms_;
int64_t start_time_ms_;
uint32_t ssrc_override_;
RTC_DISALLOW_COPY_AND_ASSIGN(RtpDumpReader);
@ -159,10 +159,10 @@ class RtpDumpLoopReader : public RtpDumpReader {
// the previous dump packets in the input stream.
uint32_t first_elapsed_time_;
int first_rtp_seq_num_;
uint32_t first_rtp_timestamp_;
int64_t first_rtp_timestamp_;
uint32_t prev_elapsed_time_;
int prev_rtp_seq_num_;
uint32_t prev_rtp_timestamp_;
int64_t prev_rtp_timestamp_;
RTC_DISALLOW_COPY_AND_ASSIGN(RtpDumpLoopReader);
};
@ -207,9 +207,9 @@ class RtpDumpWriter {
rtc::StreamInterface* stream_;
int packet_filter_;
bool file_header_written_;
uint32_t start_time_ms_; // Time when the record starts.
int64_t start_time_ms_; // Time when the record starts.
// If writing to the stream takes longer than this many ms, log a warning.
uint32_t warn_slow_writes_delay_;
int64_t warn_slow_writes_delay_;
RTC_DISALLOW_COPY_AND_ASSIGN(RtpDumpWriter);
};

View File

@ -278,7 +278,7 @@ CaptureState WebRtcVideoCapturer::Start(const VideoFormat& capture_format) {
return CS_FAILED;
}
uint32_t start = rtc::Time();
int64_t start = rtc::TimeMillis();
module_->RegisterCaptureDataCallback(*this);
if (module_->StartCapture(cap) != 0) {
LOG(LS_ERROR) << "Camera '" << GetId() << "' failed to start";

View File

@ -1591,7 +1591,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame(
// frame->GetTimeStamp() is essentially a delta, align to webrtc time
if (!first_frame_timestamp_ms_) {
first_frame_timestamp_ms_ =
rtc::Optional<int64_t>(rtc::Time() - frame_delta_ms);
rtc::Optional<int64_t>(rtc::TimeMillis() - frame_delta_ms);
}
last_frame_timestamp_ms_ = *first_frame_timestamp_ms_ + frame_delta_ms;

View File

@ -789,8 +789,8 @@ Connection::Connection(Port* port,
last_ping_received_(0),
last_data_received_(0),
last_ping_response_received_(0),
recv_rate_tracker_(100u, 10u),
send_rate_tracker_(100u, 10u),
recv_rate_tracker_(100, 10u),
send_rate_tracker_(100, 10u),
sent_packets_discarded_(0),
sent_packets_total_(0),
reported_(false),

View File

@ -203,9 +203,9 @@ void ReportStats() {
uint32_t PseudoTcp::Now() {
#if 0 // Use this to synchronize timers with logging timestamps (easier debug)
return rtc::TimeSince(StartTime());
return static_cast<uint32_t>(rtc::TimeSince(StartTime()));
#else
return rtc::Time();
return rtc::Time32();
#endif
}
@ -289,7 +289,7 @@ void PseudoTcp::NotifyClock(uint32_t now) {
return;
// Check if it's time to retransmit a segment
if (m_rto_base && (rtc::TimeDiff(m_rto_base + m_rx_rto, now) <= 0)) {
if (m_rto_base && (rtc::TimeDiff32(m_rto_base + m_rx_rto, now) <= 0)) {
if (m_slist.empty()) {
ASSERT(false);
} else {
@ -320,9 +320,8 @@ void PseudoTcp::NotifyClock(uint32_t now) {
}
// Check if it's time to probe closed windows
if ((m_snd_wnd == 0)
&& (rtc::TimeDiff(m_lastsend + m_rx_rto, now) <= 0)) {
if (rtc::TimeDiff(now, m_lastrecv) >= 15000) {
if ((m_snd_wnd == 0) && (rtc::TimeDiff32(m_lastsend + m_rx_rto, now) <= 0)) {
if (rtc::TimeDiff32(now, m_lastrecv) >= 15000) {
closedown(ECONNABORTED);
return;
}
@ -336,19 +335,22 @@ void PseudoTcp::NotifyClock(uint32_t now) {
}
// Check if it's time to send delayed acks
if (m_t_ack && (rtc::TimeDiff(m_t_ack + m_ack_delay, now) <= 0)) {
if (m_t_ack && (rtc::TimeDiff32(m_t_ack + m_ack_delay, now) <= 0)) {
packet(m_snd_nxt, 0, 0, 0);
}
#if PSEUDO_KEEPALIVE
// Check for idle timeout
if ((m_state == TCP_ESTABLISHED) && (TimeDiff(m_lastrecv + IDLE_TIMEOUT, now) <= 0)) {
if ((m_state == TCP_ESTABLISHED) &&
(TimeDiff32(m_lastrecv + IDLE_TIMEOUT, now) <= 0)) {
closedown(ECONNABORTED);
return;
}
// Check for ping timeout (to keep udp mapping open)
if ((m_state == TCP_ESTABLISHED) && (TimeDiff(m_lasttraffic + (m_bOutgoing ? IDLE_PING * 3/2 : IDLE_PING), now) <= 0)) {
if ((m_state == TCP_ESTABLISHED) &&
(TimeDiff32(m_lasttraffic + (m_bOutgoing ? IDLE_PING * 3 / 2 : IDLE_PING),
now) <= 0)) {
packet(m_snd_nxt, 0, 0, 0);
}
#endif // PSEUDO_KEEPALIVE
@ -621,23 +623,24 @@ bool PseudoTcp::clock_check(uint32_t now, long& nTimeout) {
nTimeout = DEFAULT_TIMEOUT;
if (m_t_ack) {
nTimeout =
std::min<int32_t>(nTimeout, rtc::TimeDiff(m_t_ack + m_ack_delay, now));
nTimeout = std::min<int32_t>(nTimeout,
rtc::TimeDiff32(m_t_ack + m_ack_delay, now));
}
if (m_rto_base) {
nTimeout =
std::min<int32_t>(nTimeout, rtc::TimeDiff(m_rto_base + m_rx_rto, now));
nTimeout = std::min<int32_t>(nTimeout,
rtc::TimeDiff32(m_rto_base + m_rx_rto, now));
}
if (m_snd_wnd == 0) {
nTimeout =
std::min<int32_t>(nTimeout, rtc::TimeDiff(m_lastsend + m_rx_rto, now));
nTimeout = std::min<int32_t>(nTimeout,
rtc::TimeDiff32(m_lastsend + m_rx_rto, now));
}
#if PSEUDO_KEEPALIVE
if (m_state == TCP_ESTABLISHED) {
nTimeout = std::min<int32_t>(
nTimeout, rtc::TimeDiff(m_lasttraffic + (m_bOutgoing ? IDLE_PING * 3 / 2
: IDLE_PING),
now));
nTimeout,
rtc::TimeDiff32(
m_lasttraffic + (m_bOutgoing ? IDLE_PING * 3 / 2 : IDLE_PING),
now));
}
#endif // PSEUDO_KEEPALIVE
return true;
@ -710,7 +713,7 @@ bool PseudoTcp::process(Segment& seg) {
if ((seg.ack > m_snd_una) && (seg.ack <= m_snd_nxt)) {
// Calculate round-trip time
if (seg.tsecr) {
int32_t rtt = rtc::TimeDiff(now, seg.tsecr);
int32_t rtt = rtc::TimeDiff32(now, seg.tsecr);
if (rtt >= 0) {
if (m_rx_srtt == 0) {
m_rx_srtt = rtt;
@ -1033,7 +1036,7 @@ bool PseudoTcp::transmit(const SList::iterator& seg, uint32_t now) {
void PseudoTcp::attemptSend(SendFlags sflags) {
uint32_t now = Now();
if (rtc::TimeDiff(now, m_lastsend) > static_cast<long>(m_rx_rto)) {
if (rtc::TimeDiff32(now, m_lastsend) > static_cast<long>(m_rx_rto)) {
m_cwnd = m_mss;
}

View File

@ -208,7 +208,8 @@ class PseudoTcpTestBase : public testing::Test,
class PseudoTcpTest : public PseudoTcpTestBase {
public:
void TestTransfer(int size) {
uint32_t start, elapsed;
uint32_t start;
int32_t elapsed;
size_t received;
// Create some dummy data to send.
send_stream_.ReserveSize(size);
@ -220,13 +221,13 @@ class PseudoTcpTest : public PseudoTcpTestBase {
// Prepare the receive stream.
recv_stream_.ReserveSize(size);
// Connect and wait until connected.
start = rtc::Time();
start = rtc::Time32();
EXPECT_EQ(0, Connect());
EXPECT_TRUE_WAIT(have_connected_, kConnectTimeoutMs);
// Sending will start from OnTcpWriteable and complete when all data has
// been received.
EXPECT_TRUE_WAIT(have_disconnected_, kTransferTimeoutMs);
elapsed = rtc::TimeSince(start);
elapsed = rtc::Time32() - start;
recv_stream_.GetSize(&received);
// Ensure we closed down OK and we got the right data.
// TODO: Ensure the errors are cleared properly.
@ -339,7 +340,7 @@ class PseudoTcpTestPingPong : public PseudoTcpTestBase {
// Prepare the receive stream.
recv_stream_.ReserveSize(size);
// Connect and wait until connected.
start = rtc::Time();
start = rtc::Time32();
EXPECT_EQ(0, Connect());
EXPECT_TRUE_WAIT(have_connected_, kConnectTimeoutMs);
// Sending will start from OnTcpWriteable and stop when the required

View File

@ -87,7 +87,7 @@ class StunBindingRequest : public StunRequest {
int64_t now = rtc::TimeMillis();
if (WithinLifetime(now) &&
rtc::TimeDiff64(now, start_time_) < RETRY_TIMEOUT) {
rtc::TimeDiff(now, start_time_) < RETRY_TIMEOUT) {
port_->requests_.SendDelayed(
new StunBindingRequest(port_, server_addr_, start_time_, lifetime_),
port_->stun_keepalive_delay());
@ -105,7 +105,7 @@ class StunBindingRequest : public StunRequest {
// Returns true if |now| is within the lifetime of the request (a negative
// lifetime means infinite).
bool WithinLifetime(int64_t now) const {
return lifetime_ < 0 || rtc::TimeDiff64(now, start_time_) <= lifetime_;
return lifetime_ < 0 || rtc::TimeDiff(now, start_time_) <= lifetime_;
}
UDPPort* port_;
const rtc::SocketAddress server_addr_;

View File

@ -63,7 +63,7 @@ void CurrentSpeakerMonitor::Stop() {
}
void CurrentSpeakerMonitor::set_min_time_between_switches(
uint32_t min_time_between_switches) {
int min_time_between_switches) {
min_time_between_switches_ = min_time_between_switches;
}
@ -165,7 +165,7 @@ void CurrentSpeakerMonitor::OnAudioMonitor(
// We avoid over-switching by disabling switching for a period of time after
// a switch is done.
uint32_t now = rtc::Time();
int64_t now = rtc::TimeMillis();
if (earliest_permitted_switch_time_ <= now &&
current_speaker_ssrc_ != loudest_speaker_ssrc) {
current_speaker_ssrc_ = loudest_speaker_ssrc;

View File

@ -54,7 +54,7 @@ class CurrentSpeakerMonitor : public sigslot::has_slots<> {
// Used by tests. Note that the actual minimum time between switches
// enforced by the monitor will be the given value plus or minus the
// resolution of the system clock.
void set_min_time_between_switches(uint32_t min_time_between_switches);
void set_min_time_between_switches(int min_time_between_switches);
// This is fired when the current speaker changes, and provides his audio
// SSRC. This only fires after the audio monitor on the underlying
@ -86,8 +86,8 @@ class CurrentSpeakerMonitor : public sigslot::has_slots<> {
uint32_t current_speaker_ssrc_;
// To prevent overswitching, switching is disabled for some time after a
// switch is made. This gives us the earliest time a switch is permitted.
uint32_t earliest_permitted_switch_time_;
uint32_t min_time_between_switches_;
int64_t earliest_permitted_switch_time_;
int min_time_between_switches_;
};
} // namespace cricket

View File

@ -259,7 +259,7 @@ bool SrtpFilter::GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len) {
return send_session_->GetRtpAuthParams(key, key_len, tag_len);
}
void SrtpFilter::set_signal_silent_time(uint32_t signal_silent_time_in_ms) {
void SrtpFilter::set_signal_silent_time(int signal_silent_time_in_ms) {
signal_silent_time_in_ms_ = signal_silent_time_in_ms;
if (IsActive()) {
ASSERT(send_session_ != NULL);
@ -641,7 +641,7 @@ bool SrtpSession::GetSendStreamPacketIndex(void* p,
return true;
}
void SrtpSession::set_signal_silent_time(uint32_t signal_silent_time_in_ms) {
void SrtpSession::set_signal_silent_time(int signal_silent_time_in_ms) {
srtp_stat_->set_signal_silent_time(signal_silent_time_in_ms);
}
@ -891,10 +891,10 @@ void SrtpStat::HandleSrtpResult(const SrtpStat::FailureKey& key) {
if (key.error != SrtpFilter::ERROR_NONE) {
// For errors, signal first time and wait for 1 sec.
FailureStat* stat = &(failures_[key]);
uint32_t current_time = rtc::Time();
int64_t current_time = rtc::TimeMillis();
if (stat->last_signal_time == 0 ||
rtc::TimeDiff(current_time, stat->last_signal_time) >
static_cast<int>(signal_silent_time_)) {
signal_silent_time_) {
SignalSrtpError(key.ssrc, key.mode, key.error);
stat->last_signal_time = current_time;
}

View File

@ -120,7 +120,7 @@ class SrtpFilter {
bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len);
// Update the silent threshold (in ms) for signaling errors.
void set_signal_silent_time(uint32_t signal_silent_time_in_ms);
void set_signal_silent_time(int signal_silent_time_in_ms);
bool ResetParams();
@ -166,7 +166,7 @@ class SrtpFilter {
ST_RECEIVEDPRANSWER
};
State state_;
uint32_t signal_silent_time_in_ms_;
int signal_silent_time_in_ms_;
std::vector<CryptoParams> offer_params_;
std::unique_ptr<SrtpSession> send_session_;
std::unique_ptr<SrtpSession> recv_session_;
@ -208,7 +208,7 @@ class SrtpSession {
bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len);
// Update the silent threshold (in ms) for signaling errors.
void set_signal_silent_time(uint32_t signal_silent_time_in_ms);
void set_signal_silent_time(int signal_silent_time_in_ms);
// Calls srtp_shutdown if it's initialized.
static void Terminate();
@ -252,9 +252,9 @@ class SrtpStat {
void AddUnprotectRtcpResult(int result);
// Get silent time (in ms) for SRTP statistics handler.
uint32_t signal_silent_time() const { return signal_silent_time_; }
int signal_silent_time() const { return signal_silent_time_; }
// Set silent time (in ms) for SRTP statistics handler.
void set_signal_silent_time(uint32_t signal_silent_time) {
void set_signal_silent_time(int signal_silent_time) {
signal_silent_time_ = signal_silent_time;
}
@ -296,7 +296,7 @@ class SrtpStat {
void Reset() {
last_signal_time = 0;
}
uint32_t last_signal_time;
int64_t last_signal_time;
};
// Inspect SRTP result and signal error if needed.
@ -304,7 +304,7 @@ class SrtpStat {
std::map<FailureKey, FailureStat> failures_;
// Threshold in ms to silent the signaling errors.
uint32_t signal_silent_time_;
int signal_silent_time_;
RTC_DISALLOW_COPY_AND_ASSIGN(SrtpStat);
};

View File

@ -19,7 +19,6 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/event.h"
#include "webrtc/base/timeutils.h"
#include "webrtc/call.h"
#include "webrtc/call/transport_adapter.h"
#include "webrtc/common_video/include/frame_callback.h"
@ -2934,7 +2933,9 @@ void EndToEndTest::TestRtpStatePreservation(bool use_rtx) {
} else {
// Verify timestamps are reasonably close.
uint32_t latest_observed = timestamp_it->second;
int32_t timestamp_gap = rtc::TimeDiff(timestamp, latest_observed);
// Wraparound handling is unnecessary here as long as an int variable
// is used to store the result.
int32_t timestamp_gap = timestamp - latest_observed;
EXPECT_LE(std::abs(timestamp_gap), kMaxTimestampGap)
<< "Gap in timestamps (" << latest_observed << " -> "
<< timestamp << ") too large for SSRC: " << ssrc << ".";

View File

@ -27,8 +27,8 @@ ReceiveStatisticsProxy::ReceiveStatisticsProxy(
// 1000ms window, scale 1000 for ms to s.
decode_fps_estimator_(1000, 1000),
renders_fps_estimator_(1000, 1000),
render_fps_tracker_(100u, 10u),
render_pixel_tracker_(100u, 10u) {
render_fps_tracker_(100, 10u),
render_pixel_tracker_(100, 10u) {
stats_.ssrc = config.rtp.remote_ssrc;
for (auto it : config.rtp.rtx)
rtx_stats_[it.second.ssrc] = StreamDataCounters();

View File

@ -97,8 +97,8 @@ SendStatisticsProxy::UmaSamplesContainer::UmaSamplesContainer(
clock_(clock),
max_sent_width_per_timestamp_(0),
max_sent_height_per_timestamp_(0),
input_frame_rate_tracker_(100u, 10u),
sent_frame_rate_tracker_(100u, 10u),
input_frame_rate_tracker_(100, 10u),
sent_frame_rate_tracker_(100, 10u),
first_rtcp_stats_time_ms_(-1),
first_rtp_stats_time_ms_(-1),
start_stats_(stats) {}

View File

@ -131,7 +131,7 @@ void ConferenceTransport::StorePacket(Packet::Type type,
size_t len) {
{
rtc::CritScope lock(&pq_crit_);
packet_queue_.push_back(Packet(type, data, len, rtc::Time()));
packet_queue_.push_back(Packet(type, data, len, rtc::TimeMillis()));
}
packet_event_->Set();
}

View File

@ -108,7 +108,7 @@ class ConferenceTransport: public webrtc::Transport {
enum Type { Rtp, Rtcp, } type_;
Packet() : len_(0) {}
Packet(Type type, const void* data, size_t len, uint32_t time_ms)
Packet(Type type, const void* data, size_t len, int64_t time_ms)
: type_(type), len_(len), send_time_ms_(time_ms) {
EXPECT_LE(len_, kMaxPacketSizeByte);
memcpy(data_, data, len_);
@ -116,7 +116,7 @@ class ConferenceTransport: public webrtc::Transport {
uint8_t data_[kMaxPacketSizeByte];
size_t len_;
uint32_t send_time_ms_;
int64_t send_time_ms_;
};
static bool Run(void* transport) {

View File

@ -14,11 +14,10 @@
namespace voetest {
void LoudestFilter::RemoveTimeoutStreams(uint32_t time_ms) {
void LoudestFilter::RemoveTimeoutStreams(int64_t time_ms) {
auto it = stream_levels_.begin();
while (it != stream_levels_.end()) {
if (rtc::TimeDiff(time_ms, it->second.last_time_ms) >
kStreamTimeOutMs) {
if (rtc::TimeDiff(time_ms, it->second.last_time_ms) > kStreamTimeOutMs) {
stream_levels_.erase(it++);
} else {
++it;
@ -41,7 +40,7 @@ unsigned int LoudestFilter::FindQuietestStream() {
}
bool LoudestFilter::ForwardThisPacket(const webrtc::RTPHeader& rtp_header) {
uint32_t time_now_ms = rtc::Time();
int64_t time_now_ms = rtc::TimeMillis();
RemoveTimeoutStreams(time_now_ms);
int source_ssrc = rtp_header.ssrc;

View File

@ -29,15 +29,15 @@ class LoudestFilter {
private:
struct Status {
void Set(int audio_level, uint32_t last_time_ms) {
void Set(int audio_level, int64_t last_time_ms) {
this->audio_level = audio_level;
this->last_time_ms = last_time_ms;
}
int audio_level;
uint32_t last_time_ms;
int64_t last_time_ms;
};
void RemoveTimeoutStreams(uint32_t time_ms);
void RemoveTimeoutStreams(int64_t time_ms);
unsigned int FindQuietestStream();
// Keeps the streams being forwarded in pair<SSRC, Status>.

View File

@ -72,15 +72,15 @@ TEST(VoeConferenceTest, RttAndStartNtpTime) {
const int kStatsRequestIntervalMs = 1000;
const int kStatsBufferSize = 3;
uint32_t deadline = rtc::TimeAfter(kMaxRunTimeMs);
int64_t deadline = rtc::TimeAfter(kMaxRunTimeMs);
// Run the following up to |kMaxRunTimeMs| milliseconds.
int successive_pass = 0;
webrtc::CallStatistics stats_1;
webrtc::CallStatistics stats_2;
std::queue<Stats> stats_buffer;
while (rtc::TimeIsLater(rtc::Time(), deadline) &&
successive_pass < kNeedSuccessivePass) {
while (rtc::TimeMillis() < deadline &&
successive_pass < kNeedSuccessivePass) {
webrtc::SleepMs(kStatsRequestIntervalMs);
EXPECT_TRUE(trans.GetReceiverStatistics(id_1, &stats_1));

View File

@ -183,7 +183,7 @@ TEST(OutputTest, DISABLED_OpusDtxHasNoNoisePump) {
OutputTest test(-kDtxBoundForSilence, kDtxBoundForSilence);
Random random(1234ull);
uint32_t start_time = rtc::Time();
int64_t start_time = rtc::TimeMillis();
test.Start();
while (rtc::TimeSince(start_time) < kRuntimeMs) {
webrtc::SleepMs(random.Rand(kUnmuteTimeMs - kUnmuteTimeMs / 10,