diff options
author | stefan@webrtc.org <stefan@webrtc.org> | 2015-02-06 12:20:33 +0000 |
---|---|---|
committer | stefan@webrtc.org <stefan@webrtc.org> | 2015-02-06 12:21:21 +0000 |
commit | fb609a1f57ef5aec3382bf28d8309154344d191d (patch) | |
tree | 7dcffb1b7310c4a2b46693483d5cee468689ccd1 /webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc | |
parent | 353c8b8c08f4e1b5743cb08115120c9a33f99b3a (diff) | |
download | webrtc-fb609a1f57ef5aec3382bf28d8309154344d191d.tar.gz |
Wire up new feedback format by introducing a FeedbackPacket type.
The new format instantiates the RemoteBitrateEstimator at the send-side and feeds back all packet arrival timestamps and sequence numbers to the sender, where inter-arrival deltas are calculated.
Next step will be to make feedback packets part of regular packets and send them over the network. This also requires bi-directional simulations.
BUG=4173
R=mflodman@webrtc.org, sprang@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/37109004
Cr-Commit-Position: refs/heads/master@{#8264}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8264 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc')
-rw-r--r-- | webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc index c35757785b..e32ef72641 100644 --- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc +++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc @@ -111,6 +111,9 @@ class RemoteBitrateEstimatorAbsSendTimeImpl : public RemoteBitrateEstimator { uint32_t min_bitrate_bps); virtual ~RemoteBitrateEstimatorAbsSendTimeImpl() {} + virtual void IncomingPacketFeedbackVector( + const std::vector<PacketInfo>& packet_feedback_vector) OVERRIDE; + virtual void IncomingPacket(int64_t arrival_time_ms, size_t payload_size, const RTPHeader& header) OVERRIDE; @@ -129,7 +132,6 @@ class RemoteBitrateEstimatorAbsSendTimeImpl : public RemoteBitrateEstimator { private: typedef std::map<unsigned int, int64_t> Ssrcs; - static bool IsWithinClusterBounds(int send_delta_ms, const Cluster& cluster_aggregate) { if (cluster_aggregate.count == 0) @@ -150,6 +152,11 @@ class RemoteBitrateEstimatorAbsSendTimeImpl : public RemoteBitrateEstimator { return static_cast<int>(reinterpret_cast<uint64_t>(this)); } + void IncomingPacketInfo(int64_t arrival_time_ms, + uint32_t send_time_24bits, + size_t payload_size, + uint32_t ssrc); + bool IsProbe(int64_t send_time_ms, int payload_size) const EXCLUSIVE_LOCKS_REQUIRED(crit_sect_.get()); @@ -322,6 +329,19 @@ bool RemoteBitrateEstimatorAbsSendTimeImpl::IsBitrateImproving( return initial_probe || bitrate_above_estimate; } +void RemoteBitrateEstimatorAbsSendTimeImpl::IncomingPacketFeedbackVector( + const std::vector<PacketInfo>& packet_feedback_vector) { + for (const auto& packet_info : packet_feedback_vector) { + // TODO(holmer): We should get rid of this conversion if possible as we may + // lose precision. + uint32_t send_time_32bits = (packet_info.send_time_ms) / kTimestampToMs; + uint32_t send_time_24bits = + send_time_32bits >> kAbsSendTimeInterArrivalUpshift; + IncomingPacketInfo(packet_info.arrival_time_ms, send_time_24bits, + packet_info.payload_size, 0); + } +} + void RemoteBitrateEstimatorAbsSendTimeImpl::IncomingPacket( int64_t arrival_time_ms, size_t payload_size, @@ -330,27 +350,38 @@ void RemoteBitrateEstimatorAbsSendTimeImpl::IncomingPacket( LOG(LS_WARNING) << "RemoteBitrateEstimatorAbsSendTimeImpl: Incoming packet " "is missing absolute send time extension!"; } - uint32_t absolute_send_time = header.extension.absoluteSendTime; - assert(absolute_send_time < (1ul << 24)); - int64_t now_ms = clock_->TimeInMilliseconds(); + IncomingPacketInfo(arrival_time_ms, header.extension.absoluteSendTime, + payload_size, header.ssrc); +} + +void RemoteBitrateEstimatorAbsSendTimeImpl::IncomingPacketInfo( + int64_t arrival_time_ms, + uint32_t send_time_24bits, + size_t payload_size, + uint32_t ssrc) { + assert(send_time_24bits < (1ul << 24)); + // Shift up send time to use the full 32 bits that inter_arrival works with, + // so wrapping works properly. + uint32_t timestamp = send_time_24bits << kAbsSendTimeInterArrivalUpshift; + int64_t send_time_ms = static_cast<int64_t>(timestamp) * kTimestampToMs; + CriticalSectionScoped cs(crit_sect_.get()); - ssrcs_[header.ssrc] = now_ms; + int64_t now_ms = clock_->TimeInMilliseconds(); + // TODO(holmer): SSRCs are only needed for REMB, should be broken out from + // here. + ssrcs_[ssrc] = now_ms; incoming_bitrate_.Update(payload_size, now_ms); const BandwidthUsage prior_state = detector_.State(); if (first_packet_time_ms_ == -1) first_packet_time_ms_ = clock_->TimeInMilliseconds(); - // Shift up send time to use the full 32 bits that inter_arrival works with, - // so wrapping works properly. - uint32_t timestamp = absolute_send_time << kAbsSendTimeInterArrivalUpshift; uint32_t ts_delta = 0; int64_t t_delta = 0; int size_delta = 0; // For now only try to detect probes while we don't have a valid estimate. if (!remote_rate_->ValidEstimate() || now_ms - first_packet_time_ms_ < kInitialProbingIntervalMs) { - int64_t send_time_ms = static_cast<int64_t>(timestamp) * kTimestampToMs; // TODO(holmer): Use a map instead to get correct order? if (total_probes_received_ < kMaxProbePackets) { int send_delta_ms = -1; @@ -370,15 +401,11 @@ void RemoteBitrateEstimatorAbsSendTimeImpl::IncomingPacket( } if (!inter_arrival_.get()) { inter_arrival_.reset(new InterArrival( - (kTimestampGroupLengthMs << kInterArrivalShift) / 1000, - kTimestampToMs, remote_rate_->GetControlType() == kAimdControl)); + (kTimestampGroupLengthMs << kInterArrivalShift) / 1000, kTimestampToMs, + remote_rate_->GetControlType() == kAimdControl)); } - if (inter_arrival_->ComputeDeltas(timestamp, - arrival_time_ms, - payload_size, - &ts_delta, - &t_delta, - &size_delta)) { + if (inter_arrival_->ComputeDeltas(timestamp, arrival_time_ms, payload_size, + &ts_delta, &t_delta, &size_delta)) { double ts_delta_ms = (1000.0 * ts_delta) / (1 << kInterArrivalShift); estimator_.Update(t_delta, ts_delta_ms, size_delta, detector_.State()); detector_.Detect(estimator_.offset(), ts_delta_ms, |