Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Unified Diff: webrtc/voice_engine/transport_feedback_packet_loss_tracker.h

Issue 2629883003: First-order-FEC recoverability calculation (Closed)
Patch Set: Undo unintended changes (from rebasing the diff) Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/voice_engine/transport_feedback_packet_loss_tracker.h
diff --git a/webrtc/voice_engine/transport_feedback_packet_loss_tracker.h b/webrtc/voice_engine/transport_feedback_packet_loss_tracker.h
index e5626eb9b22a44d7961809f7f9a32f2f74938602..63230795e15f39460007e197d1b50e07ac7f6f28 100644
--- a/webrtc/voice_engine/transport_feedback_packet_loss_tracker.h
+++ b/webrtc/voice_engine/transport_feedback_packet_loss_tracker.h
@@ -26,31 +26,35 @@ class TransportFeedbackPacketLossTracker final {
public:
// Up to |max_window_size| latest packet statuses wil be used for calculating
// the packet loss metrics. When less than |min_window_size| samples are
- // available for making a reliable estimation, GetPacketLossRates() will
- // return false to indicate packet loss metrics are not ready.
+ // available for making a reliable estimation, neither PLR nor RPLR would
+ // be considered validly computable.
+ // When |min_pairs_num_for_rplr| pairs or more are available, RPLR is reliably
+ // computable. This is independent of PLR being computable.
TransportFeedbackPacketLossTracker(size_t min_window_size,
minyue-webrtc 2017/01/25 09:38:45 rename min_window_size to make it specific to plr,
elad.alon_webrtc.org 2017/01/25 12:47:55 Please see subsequent CL, which renames to min/max
minyue-webrtc 2017/01/25 20:00:59 You see I did not ask you to rename max_window_siz
- size_t max_window_size);
+ size_t max_window_size,
minyue-webrtc 2017/01/25 09:38:45 change the order of min_window_size (and rename it
elad.alon_webrtc.org 2017/01/25 12:47:55 Min-then-max looks fine to me. That's how I'm used
+ size_t min_pairs_num_for_rplr);
minyue-webrtc 2017/01/25 09:38:45 rename to rplr_min_num_pairs_
elad.alon_webrtc.org 2017/01/25 12:47:55 Done.
void OnReceivedTransportFeedback(const rtcp::TransportFeedback& feedback);
- // Returns true if packet loss rate and packet loss episode duration are ready
- // and assigns respective values to |*packet_loss_rate| and
- // |*consecutive_packet_loss_rate|. Continuous packet loss rate is defined as
- // the probability of losing two adjacent packets.
- bool GetPacketLossRates(float* packet_loss_rate,
- float* consecutive_packet_loss_rate) const;
+ // Returns the packet loss rate, if the window has enough data to
+ // reliably compute it.
+ rtc::Optional<float> GetPacketLossRate() const;
+
+ // Returns the first-order-FEC recoverable packet loss rate, if the window
+ // has enough data to reliably compute it.
+ rtc::Optional<float> GetRecoverablePacketLossRate() const;
// Verifies that the internal states are correct. Only used for tests.
void Validate() const;
private:
- // PacketStatus is a map from sequence number to its reception status. The
- // status is true if the corresponding packet is received, and false if it is
- // lost. Unknown statuses are not present in the map.
+ // PacketStatus is a map from sequence number to a boolean. The boolean is
minyue-webrtc 2017/01/25 09:38:45 use the old comment.
elad.alon_webrtc.org 2017/01/25 12:47:55 Done. (Edited needlessly when doing some rebasing
minyue-webrtc 2017/01/25 20:00:59 Acknowledged.
+ // true if it is received.
typedef std::map<uint16_t, bool> PacketStatus;
typedef PacketStatus::const_iterator PacketStatusIterator;
void Reset();
+
// ReferenceSequenceNumber() provides a sequence number that defines the
// order of packet reception info stored in |packet_status_window_|. In
// particular, given any sequence number |x|,
@@ -60,22 +64,51 @@ class TransportFeedbackPacketLossTracker final {
bool IsOldSequenceNumber(uint16_t seq_num) const;
void InsertPacketStatus(uint16_t seq_num, bool received);
void RemoveOldestPacketStatus();
- void ApplyPacketStatus(PacketStatusIterator it);
- void UndoPacketStatus(PacketStatusIterator it);
+
+ void UpdateMetrics(PacketStatusIterator it, bool apply /* false = undo */);
minyue-webrtc 2017/01/25 09:38:45 I find it would be easier for me to understand vo
elad.alon_webrtc.org 2017/01/25 12:47:55 1. I think it would be confusing for a reader to s
minyue-webrtc 2017/01/25 20:00:59 Sure, anyway, either way should not be a problem f
+ void UpdatePlr(PacketStatusIterator it, bool apply /* false = undo */);
+ void UpdateRplr(PacketStatusIterator it, bool apply /* false = undo */);
+
PacketStatusIterator PreviousPacketStatus(PacketStatusIterator it);
PacketStatusIterator NextPacketStatus(PacketStatusIterator it);
- const size_t min_window_size_;
const size_t max_window_size_;
PacketStatus packet_status_window_;
// |ref_packet_status_| points to the oldest item in |packet_status_window_|.
PacketStatusIterator ref_packet_status_;
- size_t num_received_packets_;
- size_t num_lost_packets_;
- size_t num_consecutive_losses_;
- size_t num_consecutive_old_reports_;
+ struct PlrState {
+ PlrState(size_t min_window_size)
+ : min_window_size_(min_window_size) {
+ Reset();
+ }
+ void Reset() {
+ num_received_packets_ = 0;
+ num_lost_packets_ = 0;
+ }
+ rtc::Optional<float> GetMetric() const;
+ const size_t min_window_size_;
minyue-webrtc 2017/01/25 09:38:45 rename min_window_size -> min_num_packets_
elad.alon_webrtc.org 2017/01/25 12:47:55 In this CL, it is still the window. In the subsequ
minyue-webrtc 2017/01/25 20:00:59 True, but doing it now will make it clearer, parti
+ size_t num_received_packets_;
+ size_t num_lost_packets_;
+ } plr_state_;
+
+ struct RplrState {
+ RplrState(size_t min_pairs)
+ : min_pairs_(min_pairs) {
+ Reset();
+ }
+ void Reset() {
+ num_known_status_pairs_ = 0;
+ num_loss_followed_by_reception_pairs_ = 0;
+ }
+ rtc::Optional<float> GetMetric() const;
+ const size_t min_pairs_;
+ size_t num_known_status_pairs_;
+ size_t num_loss_followed_by_reception_pairs_;
minyue-webrtc 2017/01/25 09:38:45 let's consider making the var names more precise a
elad.alon_webrtc.org 2017/01/25 12:47:55 min_num_pair - OK num_pairs - I prefer num_known_p
minyue-webrtc 2017/01/25 20:00:59 known is not a clearly defined word. In the next s
+ } rplr_state_;
+
+ size_t num_consecutive_old_reports_; // TODO(eladalon): Upcoming CL removes.
minyue-webrtc 2017/01/25 09:38:46 elad.alon
elad.alon_webrtc.org 2017/01/25 12:47:55 Done.
};
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698