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
This commit is contained in:
pkasting@chromium.org
2015-01-12 21:51:21 +00:00
parent a7add19cf4
commit 16825b1a82
124 changed files with 422 additions and 417 deletions

View File

@ -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 @@ void AcmReceiver::DisableNack() {
}
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());

View File

@ -305,7 +305,7 @@ class AcmReceiver {
// -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().

View File

@ -2017,7 +2017,7 @@ void AudioCodingModuleImpl::DisableNack() {
}
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);
}

View File

@ -246,7 +246,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
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;

View File

@ -207,13 +207,13 @@ void Nack::LimitNackListSize() {
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) {

View File

@ -87,7 +87,7 @@ class Nack {
// 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 @@ class Nack {
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 @@ class Nack {
// 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 @@ class Nack {
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.

View File

@ -29,7 +29,7 @@ const int kNackThreshold = 3;
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,

View File

@ -991,7 +991,8 @@ class AudioCodingModule: public Module {
// 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;