Use int64_t more consistently for times, in particular for RTT values.
Existing code was inconsistent about whether to use uint16_t, int, unsigned int,
or uint32_t, and sometimes silently truncated one to another, or truncated
int64_t. Because most core time-handling functions use int64_t, being
consistent about using int64_t unless otherwise necessary minimizes the number
of explicit or implicit casts.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, holmer@google.com, tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/31349004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8045 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
index f0531ed..07c2784 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
@@ -15,6 +15,7 @@
#include <algorithm> // sort
#include <vector>
+#include "webrtc/base/format_macros.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/codecs/audio_decoder.h"
@@ -727,12 +728,12 @@
}
std::vector<uint16_t> AcmReceiver::GetNackList(
- int round_trip_time_ms) const {
+ int64_t round_trip_time_ms) const {
CriticalSectionScoped lock(crit_sect_.get());
if (round_trip_time_ms < 0) {
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, id_,
"GetNackList: round trip time cannot be negative."
- " round_trip_time_ms=%d", round_trip_time_ms);
+ " round_trip_time_ms=%" PRId64, round_trip_time_ms);
}
if (nack_enabled_ && round_trip_time_ms >= 0) {
assert(nack_.get());
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.h b/webrtc/modules/audio_coding/main/acm2/acm_receiver.h
index 057cb5a..f6ce463 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.h
+++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.h
@@ -305,7 +305,7 @@
// -round_trip_time_ms : estimate of the round-trip-time (in milliseconds).
// Return value : list of packets to be retransmitted.
//
- std::vector<uint16_t> GetNackList(int round_trip_time_ms) const;
+ std::vector<uint16_t> GetNackList(int64_t round_trip_time_ms) const;
//
// Get statistics of calls to GetAudio().
diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
index cbea050..4aa372f 100644
--- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
+++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
@@ -2017,7 +2017,7 @@
}
std::vector<uint16_t> AudioCodingModuleImpl::GetNackList(
- int round_trip_time_ms) const {
+ int64_t round_trip_time_ms) const {
return receiver_.GetNackList(round_trip_time_ms);
}
diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h
index 2d0f767..a06d877 100644
--- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h
+++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h
@@ -246,7 +246,7 @@
virtual void DisableNack() OVERRIDE;
virtual std::vector<uint16_t> GetNackList(
- int round_trip_time_ms) const OVERRIDE;
+ int64_t round_trip_time_ms) const OVERRIDE;
virtual void GetDecodingCallStatistics(
AudioDecodingCallStats* stats) const OVERRIDE;
diff --git a/webrtc/modules/audio_coding/main/acm2/nack.cc b/webrtc/modules/audio_coding/main/acm2/nack.cc
index 7265fe6..4324cd2 100644
--- a/webrtc/modules/audio_coding/main/acm2/nack.cc
+++ b/webrtc/modules/audio_coding/main/acm2/nack.cc
@@ -207,13 +207,13 @@
nack_list_.erase(nack_list_.begin(), nack_list_.upper_bound(limit));
}
-int Nack::TimeToPlay(uint32_t timestamp) const {
+int64_t Nack::TimeToPlay(uint32_t timestamp) const {
uint32_t timestamp_increase = timestamp - timestamp_last_decoded_rtp_;
return timestamp_increase / sample_rate_khz_;
}
// We don't erase elements with time-to-play shorter than round-trip-time.
-std::vector<uint16_t> Nack::GetNackList(int round_trip_time_ms) const {
+std::vector<uint16_t> Nack::GetNackList(int64_t round_trip_time_ms) const {
std::vector<uint16_t> sequence_numbers;
for (NackList::const_iterator it = nack_list_.begin(); it != nack_list_.end();
++it) {
diff --git a/webrtc/modules/audio_coding/main/acm2/nack.h b/webrtc/modules/audio_coding/main/acm2/nack.h
index 3809327..d74bb1f 100644
--- a/webrtc/modules/audio_coding/main/acm2/nack.h
+++ b/webrtc/modules/audio_coding/main/acm2/nack.h
@@ -87,7 +87,7 @@
// Get a list of "missing" packets which have expected time-to-play larger
// than the given round-trip-time (in milliseconds).
// Note: Late packets are not included.
- std::vector<uint16_t> GetNackList(int round_trip_time_ms) const;
+ std::vector<uint16_t> GetNackList(int64_t round_trip_time_ms) const;
// Reset to default values. The NACK list is cleared.
// |nack_threshold_packets_| & |max_nack_list_size_| preserve their values.
@@ -98,7 +98,7 @@
FRIEND_TEST_ALL_PREFIXES(NackTest, EstimateTimestampAndTimeToPlay);
struct NackElement {
- NackElement(int initial_time_to_play_ms,
+ NackElement(int64_t initial_time_to_play_ms,
uint32_t initial_timestamp,
bool missing)
: time_to_play_ms(initial_time_to_play_ms),
@@ -107,7 +107,7 @@
// Estimated time (ms) left for this packet to be decoded. This estimate is
// updated every time jitter buffer decodes a packet.
- int time_to_play_ms;
+ int64_t time_to_play_ms;
// A guess about the timestamp of the missing packet, it is used for
// estimation of |time_to_play_ms|. The estimate might be slightly wrong if
@@ -171,7 +171,7 @@
uint32_t EstimateTimestamp(uint16_t sequence_number);
// Compute time-to-play given a timestamp.
- int TimeToPlay(uint32_t timestamp) const;
+ int64_t TimeToPlay(uint32_t timestamp) const;
// If packet N is arrived, any packet prior to N - |nack_threshold_packets_|
// which is not arrived is considered missing, and should be in NACK list.
diff --git a/webrtc/modules/audio_coding/main/acm2/nack_unittest.cc b/webrtc/modules/audio_coding/main/acm2/nack_unittest.cc
index 7863c75..c175908 100644
--- a/webrtc/modules/audio_coding/main/acm2/nack_unittest.cc
+++ b/webrtc/modules/audio_coding/main/acm2/nack_unittest.cc
@@ -29,7 +29,7 @@
const int kSampleRateHz = 16000;
const int kPacketSizeMs = 30;
const uint32_t kTimestampIncrement = 480; // 30 ms.
-const int kShortRoundTripTimeMs = 1;
+const int64_t kShortRoundTripTimeMs = 1;
bool IsNackListCorrect(const std::vector<uint16_t>& nack_list,
const uint16_t* lost_sequence_numbers,
diff --git a/webrtc/modules/audio_coding/main/interface/audio_coding_module.h b/webrtc/modules/audio_coding/main/interface/audio_coding_module.h
index 83e6dce..8826194 100644
--- a/webrtc/modules/audio_coding/main/interface/audio_coding_module.h
+++ b/webrtc/modules/audio_coding/main/interface/audio_coding_module.h
@@ -991,7 +991,8 @@
// Negative |round_trip_time_ms| results is an error message and empty list
// is returned.
//
- virtual std::vector<uint16_t> GetNackList(int round_trip_time_ms) const = 0;
+ virtual std::vector<uint16_t> GetNackList(
+ int64_t round_trip_time_ms) const = 0;
virtual void GetDecodingCallStatistics(
AudioDecodingCallStats* call_stats) const = 0;