Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information. This CL was reviewed and approved in pieces in the following CLs: https://webrtc-codereview.appspot.com/24209004/ https://webrtc-codereview.appspot.com/24229004/ https://webrtc-codereview.appspot.com/24259004/ https://webrtc-codereview.appspot.com/25109004/ https://webrtc-codereview.appspot.com/26099004/ https://webrtc-codereview.appspot.com/27069004/ https://webrtc-codereview.appspot.com/27969004/ https://webrtc-codereview.appspot.com/27989004/ https://webrtc-codereview.appspot.com/29009004/ https://webrtc-codereview.appspot.com/30929004/ https://webrtc-codereview.appspot.com/30939004/ https://webrtc-codereview.appspot.com/31999004/ Committing as TBR to the original reviewers. BUG=chromium:81439 TEST=none TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom Review URL: https://webrtc-codereview.appspot.com/23129004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -73,7 +73,7 @@ class RemoteBitrateEstimator : public CallStatsObserver, public Module {
|
||||
// packet size excluding headers.
|
||||
// Note that |arrival_time_ms| can be of an arbitrary time base.
|
||||
virtual void IncomingPacket(int64_t arrival_time_ms,
|
||||
int payload_size,
|
||||
size_t payload_size,
|
||||
const RTPHeader& header) = 0;
|
||||
|
||||
// Removes all data for |ssrc|.
|
||||
|
||||
@@ -46,7 +46,7 @@ OveruseDetector::~OveruseDetector() {
|
||||
ts_delta_hist_.clear();
|
||||
}
|
||||
|
||||
void OveruseDetector::Update(uint16_t packet_size,
|
||||
void OveruseDetector::Update(size_t packet_size,
|
||||
int64_t timestamp_ms,
|
||||
uint32_t timestamp,
|
||||
const int64_t arrival_time_ms) {
|
||||
@@ -157,8 +157,8 @@ double OveruseDetector::CurrentDrift() {
|
||||
|
||||
void OveruseDetector::UpdateKalman(int64_t t_delta,
|
||||
double ts_delta,
|
||||
uint32_t frame_size,
|
||||
uint32_t prev_frame_size) {
|
||||
size_t frame_size,
|
||||
size_t prev_frame_size) {
|
||||
const double min_frame_period = UpdateMinFramePeriod(ts_delta);
|
||||
const double drift = CurrentDrift();
|
||||
// Compensate for drift
|
||||
|
||||
@@ -25,7 +25,7 @@ class OveruseDetector {
|
||||
public:
|
||||
explicit OveruseDetector(const OverUseDetectorOptions& options);
|
||||
~OveruseDetector();
|
||||
void Update(uint16_t packet_size,
|
||||
void Update(size_t packet_size,
|
||||
int64_t timestamp_ms,
|
||||
uint32_t rtp_timestamp,
|
||||
int64_t arrival_time_ms);
|
||||
@@ -41,7 +41,7 @@ class OveruseDetector {
|
||||
timestamp(-1),
|
||||
timestamp_ms(-1) {}
|
||||
|
||||
uint32_t size;
|
||||
size_t size;
|
||||
int64_t complete_time_ms;
|
||||
int64_t timestamp;
|
||||
int64_t timestamp_ms;
|
||||
@@ -63,8 +63,8 @@ class OveruseDetector {
|
||||
double* ts_delta);
|
||||
void UpdateKalman(int64_t t_delta,
|
||||
double ts_elta,
|
||||
uint32_t frame_size,
|
||||
uint32_t prev_frame_size);
|
||||
size_t frame_size,
|
||||
size_t prev_frame_size);
|
||||
double UpdateMinFramePeriod(double ts_delta);
|
||||
void UpdateNoiseEstimate(double residual, double ts_delta, bool stable_state);
|
||||
BandwidthUsage Detect(double ts_delta);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace webrtc {
|
||||
|
||||
RateStatistics::RateStatistics(uint32_t window_size_ms, float scale)
|
||||
: num_buckets_(window_size_ms + 1), // N ms in (N+1) buckets.
|
||||
buckets_(new uint32_t[num_buckets_]()),
|
||||
buckets_(new size_t[num_buckets_]()),
|
||||
accumulated_count_(0),
|
||||
oldest_time_(0),
|
||||
oldest_index_(0),
|
||||
@@ -35,7 +35,7 @@ void RateStatistics::Reset() {
|
||||
}
|
||||
}
|
||||
|
||||
void RateStatistics::Update(uint32_t count, int64_t now_ms) {
|
||||
void RateStatistics::Update(size_t count, int64_t now_ms) {
|
||||
if (now_ms < oldest_time_) {
|
||||
// Too old data is ignored.
|
||||
return;
|
||||
@@ -65,7 +65,7 @@ void RateStatistics::EraseOld(int64_t now_ms) {
|
||||
}
|
||||
|
||||
while (oldest_time_ < new_oldest_time) {
|
||||
uint32_t count_in_oldest_bucket = buckets_[oldest_index_];
|
||||
size_t count_in_oldest_bucket = buckets_[oldest_index_];
|
||||
assert(accumulated_count_ >= count_in_oldest_bucket);
|
||||
accumulated_count_ -= count_in_oldest_bucket;
|
||||
buckets_[oldest_index_] = 0;
|
||||
|
||||
@@ -25,7 +25,7 @@ class RateStatistics {
|
||||
~RateStatistics();
|
||||
|
||||
void Reset();
|
||||
void Update(uint32_t count, int64_t now_ms);
|
||||
void Update(size_t count, int64_t now_ms);
|
||||
uint32_t Rate(int64_t now_ms);
|
||||
|
||||
private:
|
||||
@@ -34,10 +34,10 @@ class RateStatistics {
|
||||
// Counters are kept in buckets (circular buffer), with one bucket
|
||||
// per millisecond.
|
||||
const int num_buckets_;
|
||||
scoped_ptr<uint32_t[]> buckets_;
|
||||
scoped_ptr<size_t[]> buckets_;
|
||||
|
||||
// Total count recorded in buckets.
|
||||
uint32_t accumulated_count_;
|
||||
size_t accumulated_count_;
|
||||
|
||||
// Oldest time recorded in buckets.
|
||||
int64_t oldest_time_;
|
||||
|
||||
@@ -35,7 +35,7 @@ class RemoteBitrateEstimatorSingleStream : public RemoteBitrateEstimator {
|
||||
// remote bitrate estimate will be updated. Note that |payload_size| is the
|
||||
// packet size excluding headers.
|
||||
virtual void IncomingPacket(int64_t arrival_time_ms,
|
||||
int payload_size,
|
||||
size_t payload_size,
|
||||
const RTPHeader& header) OVERRIDE;
|
||||
|
||||
// Triggers a new estimate calculation.
|
||||
@@ -107,7 +107,7 @@ RemoteBitrateEstimatorSingleStream::RemoteBitrateEstimatorSingleStream(
|
||||
|
||||
void RemoteBitrateEstimatorSingleStream::IncomingPacket(
|
||||
int64_t arrival_time_ms,
|
||||
int payload_size,
|
||||
size_t payload_size,
|
||||
const RTPHeader& header) {
|
||||
uint32_t ssrc = header.ssrc;
|
||||
uint32_t rtp_timestamp = header.timestamp +
|
||||
@@ -133,7 +133,7 @@ void RemoteBitrateEstimatorSingleStream::IncomingPacket(
|
||||
const BandwidthUsage prior_state = overuse_detector->State();
|
||||
overuse_detector->Update(payload_size, -1, rtp_timestamp, arrival_time_ms);
|
||||
if (overuse_detector->State() == kBwOverusing) {
|
||||
unsigned int incoming_bitrate = incoming_bitrate_.Rate(now_ms);
|
||||
uint32_t incoming_bitrate = incoming_bitrate_.Rate(now_ms);
|
||||
if (prior_state != kBwOverusing ||
|
||||
remote_rate_.TimeToReduceFurther(now_ms, incoming_bitrate)) {
|
||||
// The first overuse should immediately trigger a new estimate.
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
enum { kMtu = 1200, kAcceptedBitrateErrorBps = 50000u };
|
||||
const size_t kMtu = 1200;
|
||||
const unsigned int kAcceptedBitrateErrorBps = 50000;
|
||||
|
||||
namespace testing {
|
||||
|
||||
@@ -54,11 +55,11 @@ int64_t RtpStream::GenerateFrame(int64_t time_now_us, PacketList* packets) {
|
||||
return next_rtp_time_;
|
||||
}
|
||||
assert(packets != NULL);
|
||||
int bits_per_frame = (bitrate_bps_ + fps_ / 2) / fps_;
|
||||
int n_packets = std::max((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1);
|
||||
int packet_size = (bits_per_frame + 4 * n_packets) / (8 * n_packets);
|
||||
assert(n_packets >= 0);
|
||||
for (int i = 0; i < n_packets; ++i) {
|
||||
size_t bits_per_frame = (bitrate_bps_ + fps_ / 2) / fps_;
|
||||
size_t n_packets =
|
||||
std::max<size_t>((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1u);
|
||||
size_t packet_size = (bits_per_frame + 4 * n_packets) / (8 * n_packets);
|
||||
for (size_t i = 0; i < n_packets; ++i) {
|
||||
RtpPacket* packet = new RtpPacket;
|
||||
packet->send_time = time_now_us + kSendSideOffsetUs;
|
||||
packet->size = packet_size;
|
||||
@@ -217,7 +218,7 @@ uint32_t RemoteBitrateEstimatorTest::AddAbsSendTime(uint32_t t1, uint32_t t2) {
|
||||
const unsigned int RemoteBitrateEstimatorTest::kDefaultSsrc = 1;
|
||||
|
||||
void RemoteBitrateEstimatorTest::IncomingPacket(uint32_t ssrc,
|
||||
uint32_t payload_size,
|
||||
size_t payload_size,
|
||||
int64_t arrival_time,
|
||||
uint32_t rtp_timestamp,
|
||||
uint32_t absolute_send_time) {
|
||||
|
||||
@@ -49,7 +49,7 @@ class RtpStream {
|
||||
int64_t send_time;
|
||||
int64_t arrival_time;
|
||||
uint32_t rtp_timestamp;
|
||||
unsigned int size;
|
||||
size_t size;
|
||||
unsigned int ssrc;
|
||||
};
|
||||
|
||||
@@ -165,7 +165,7 @@ class RemoteBitrateEstimatorTest : public ::testing::Test {
|
||||
// estimator (all other fields are cleared) and call IncomingPacket on the
|
||||
// estimator.
|
||||
void IncomingPacket(uint32_t ssrc,
|
||||
uint32_t payload_size,
|
||||
size_t payload_size,
|
||||
int64_t arrival_time,
|
||||
uint32_t rtp_timestamp,
|
||||
uint32_t absolute_send_time);
|
||||
|
||||
@@ -127,7 +127,7 @@ Packet::Packet()
|
||||
memset(&header_, 0, sizeof(header_));
|
||||
}
|
||||
|
||||
Packet::Packet(int flow_id, int64_t send_time_us, uint32_t payload_size,
|
||||
Packet::Packet(int flow_id, int64_t send_time_us, size_t payload_size,
|
||||
const RTPHeader& header)
|
||||
: flow_id_(flow_id),
|
||||
creation_time_us_(send_time_us),
|
||||
@@ -785,7 +785,7 @@ bool PacedVideoSender::TimeToSendPacket(uint32_t ssrc,
|
||||
return false;
|
||||
}
|
||||
|
||||
int PacedVideoSender::TimeToSendPadding(int bytes) {
|
||||
size_t PacedVideoSender::TimeToSendPadding(size_t bytes) {
|
||||
return 0;
|
||||
}
|
||||
} // namespace bwe
|
||||
|
||||
@@ -153,7 +153,7 @@ class Random {
|
||||
class Packet {
|
||||
public:
|
||||
Packet();
|
||||
Packet(int flow_id, int64_t send_time_us, uint32_t payload_size,
|
||||
Packet(int flow_id, int64_t send_time_us, size_t payload_size,
|
||||
const RTPHeader& header);
|
||||
Packet(int64_t send_time_us, uint32_t sequence_number);
|
||||
|
||||
@@ -164,14 +164,14 @@ class Packet {
|
||||
void set_send_time_us(int64_t send_time_us);
|
||||
int64_t send_time_us() const { return send_time_us_; }
|
||||
void SetAbsSendTimeMs(int64_t abs_send_time_ms);
|
||||
uint32_t payload_size() const { return payload_size_; }
|
||||
size_t payload_size() const { return payload_size_; }
|
||||
const RTPHeader& header() const { return header_; }
|
||||
|
||||
private:
|
||||
int flow_id_;
|
||||
int64_t creation_time_us_; // Time when the packet was created.
|
||||
int64_t send_time_us_; // Time the packet left last processor touching it.
|
||||
uint32_t payload_size_; // Size of the (non-existent, simulated) payload.
|
||||
size_t payload_size_; // Size of the (non-existent, simulated) payload.
|
||||
RTPHeader header_; // Actual contents.
|
||||
};
|
||||
|
||||
@@ -474,7 +474,7 @@ class PacedVideoSender : public PacketSender, public PacedSender::Callback {
|
||||
uint16_t sequence_number,
|
||||
int64_t capture_time_ms,
|
||||
bool retransmission) OVERRIDE;
|
||||
virtual int TimeToSendPadding(int bytes) OVERRIDE;
|
||||
virtual size_t TimeToSendPadding(size_t bytes) OVERRIDE;
|
||||
|
||||
private:
|
||||
class ProbingPacedSender : public PacedSender {
|
||||
|
||||
@@ -83,7 +83,7 @@ int main(int argc, char** argv) {
|
||||
if (header.extension.transmissionTimeOffset != 0)
|
||||
++non_zero_ts_offsets;
|
||||
rbe->IncomingPacket(clock.TimeInMilliseconds(),
|
||||
static_cast<int>(packet.length - header.headerLength),
|
||||
packet.length - header.headerLength,
|
||||
header);
|
||||
++packet_counter;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user