Fix ExpectedQueueTimeMs() to avoid truncation or overflow.
BUG=none TEST=none R=asapersson@webrtc.org Review URL: https://webrtc-codereview.appspot.com/30129004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7714 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
930e004a81
commit
2656bf813f
@ -58,7 +58,7 @@ class PacedSender : public Module {
|
||||
virtual ~Callback() {}
|
||||
};
|
||||
|
||||
static const int kDefaultMaxQueueLengthMs = 2000;
|
||||
static const int64_t kDefaultMaxQueueLengthMs = 2000;
|
||||
// Pace in kbits/s until we receive first estimate.
|
||||
static const int kDefaultInitialPaceKbps = 2000;
|
||||
// Pacing-rate relative to our target send rate.
|
||||
@ -112,7 +112,7 @@ class PacedSender : public Module {
|
||||
|
||||
// Returns the number of milliseconds it will take to send the current
|
||||
// packets in the queue, given the current size and bitrate, ignoring prio.
|
||||
virtual int ExpectedQueueTimeMs() const;
|
||||
virtual int64_t ExpectedQueueTimeMs() const;
|
||||
|
||||
// Returns the number of milliseconds until the module want a worker thread
|
||||
// to call Process.
|
||||
|
@ -122,7 +122,7 @@ class PacketQueue {
|
||||
|
||||
size_t SizeInPackets() const { return prio_queue_.size(); }
|
||||
|
||||
uint32_t SizeInBytes() const { return bytes_; }
|
||||
uint64_t SizeInBytes() const { return bytes_; }
|
||||
|
||||
int64_t OldestEnqueueTime() const {
|
||||
std::list<Packet>::const_reverse_iterator it = packet_list_.rbegin();
|
||||
@ -281,11 +281,11 @@ bool PacedSender::SendPacket(Priority priority, uint32_t ssrc,
|
||||
return false;
|
||||
}
|
||||
|
||||
int PacedSender::ExpectedQueueTimeMs() const {
|
||||
int64_t PacedSender::ExpectedQueueTimeMs() const {
|
||||
CriticalSectionScoped cs(critsect_.get());
|
||||
int target_rate = media_budget_->target_rate_kbps();
|
||||
assert(target_rate > 0);
|
||||
return packets_->SizeInBytes() * 8 / target_rate;
|
||||
return static_cast<int64_t>(packets_->SizeInBytes() * 8 / target_rate);
|
||||
}
|
||||
|
||||
size_t PacedSender::QueueSizePackets() const {
|
||||
|
@ -654,7 +654,7 @@ TEST_F(PacedSenderTest, ExpectedQueueTimeMs) {
|
||||
}
|
||||
|
||||
// Queue in ms = 1000 * (bytes in queue) / (kbit per second * 1000 / 8)
|
||||
int32_t queue_in_ms = kNumPackets * kPacketSize * 8 / kMaxBitrate;
|
||||
int64_t queue_in_ms = kNumPackets * kPacketSize * 8 / kMaxBitrate;
|
||||
EXPECT_EQ(queue_in_ms, send_bucket_->ExpectedQueueTimeMs());
|
||||
|
||||
int64_t time_start = clock_.TimeInMilliseconds();
|
||||
|
Loading…
Reference in New Issue
Block a user