Index: webrtc/modules/rtp_rtcp/source/rtcp_packet/feedback_packet.h |
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_packet/feedback_packet.h b/webrtc/modules/rtp_rtcp/source/rtcp_packet/feedback_packet.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b3e55ea4e4f57081107f0c8ece2352c12fd8dfaa |
--- /dev/null |
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_packet/feedback_packet.h |
@@ -0,0 +1,103 @@ |
+/* |
+ * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FEEDBACK_PACKET_H_ |
+#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FEEDBACK_PACKET_H_ |
+ |
+#include <deque> |
+#include <vector> |
+ |
+#include "webrtc/base/constructormagic.h" |
+#include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" |
+ |
+namespace webrtc { |
+namespace rtcp { |
+ |
+class FeedbackPacket : public RtcpPacket { |
stefan-webrtc
2015/06/16 08:29:13
After reading most of the .cc file, I think it wou
sprang_webrtc
2015/06/22 12:20:10
Added comments in .cc
|
+ public: |
+ FeedbackPacket(); |
+ virtual ~FeedbackPacket(); |
+ |
+ void WithBase(uint16_t base_sequence, // Seq# of first packet in this msg. |
+ int64_t prev_timestamp_us, // Timestamp of last fb packet. |
+ int64_t ref_timestamp_us); // Reference timestamp for this msg. |
+ void WithFeedbackSequenceNumber(uint8_t feedback_sequence); |
+ // NOTE: These methods requires strictly increasing sequence numbers. |
stefan-webrtc
2015/06/16 08:29:13
Except for when they wrap, right?
sprang_webrtc
2015/06/22 12:20:11
Done.
|
+ bool WithReceivedPacket(uint16_t sequence_number, int64_t timestamp_us); |
+ bool WithUntimedPacket(uint16_t sequence_number); |
+ |
+ enum class StatusSymbol { |
+ kNotReceived, |
+ kReceivedSmallDelta, |
+ kReceivedLargeDelta, |
+ kReceivedUntimed, |
+ }; |
+ |
+ uint16_t GetBaseSequence() const; |
+ int16_t GetBaseDelta() const; |
+ std::vector<FeedbackPacket::StatusSymbol> GetStatusVector() const; |
+ std::vector<int16_t> GetReceiveDeltas() const; |
+ |
+ // Get the reference time in microseconds, including any precision loss. |
+ int64_t GetBaseDeltaUs() const; |
+ // Convenience method for getting all deltas as microseconds. For this method, |
+ // the first value will include the base delta. |
+ std::vector<int64_t> GetReceiveDeltasUs() const; |
+ |
+ static const int kDeltaScaleFactor = 250; // Convert to multiples of 0.25ms |
+ |
+ static rtc::scoped_ptr<FeedbackPacket> ParseFrom(const uint8_t* buffer, |
+ size_t length); |
+ |
+ class PacketStatusChunk; |
stefan-webrtc
2015/06/16 08:29:14
Does this have to be public?
sprang_webrtc
2015/06/22 12:20:11
Can't inherit from it otherwise. Moved it out of t
|
+ |
+ protected: |
+ bool Create(uint8_t* packet, |
+ size_t* position, |
+ size_t max_length, |
+ PacketReadyCallback* callback) const override; |
+ |
+ private: |
+ static const int kOneBitVectorCapacity = 14; |
+ static const int kTwoBitVectorCapacity = 7; |
+ static const int kRunLengthCapacity = 0x1FFF; |
+ // TODO(sprang): Add support for dynamic max size for easier fragmentation? |
stefan-webrtc
2015/06/16 08:29:13
I don't follow this. Could you explain?
sprang_webrtc
2015/06/22 12:20:11
Adding a public method for setting max size lower
stefan-webrtc
2015/07/14 12:14:54
Maybe, I guess it depends on bitrate?
sprang_webrtc
2015/07/16 11:12:10
Yes. High bitrate with long feedback interval may
|
+ static const int kMaxSizeBytes = 0xFF * 4 + 8; |
+ static const int kMinSizeBytes = 8 + 2; // Header plus one status chunk. |
+ static const int kBaseScaleFactor = kDeltaScaleFactor * (1 << 8); |
stefan-webrtc
2015/06/16 08:29:14
Could these be moved to the cc file?
sprang_webrtc
2015/06/22 12:20:10
Done.
|
+ |
+ static PacketStatusChunk* ParseChunk(const uint8_t* buffer, size_t max_size); |
+ |
+ int64_t Unwrap(uint16_t sequence_number); |
+ bool AddSymbol(StatusSymbol symbol, int64_t seq); |
+ bool Encode(StatusSymbol symbol); |
+ void EmitRemaining(); |
+ void EmitVectorChunk(); |
+ void EmitRunLengthChunk(); |
+ |
+ std::vector<PacketStatusChunk*> status_chunks_; |
+ std::vector<int16_t> receive_deltas_; |
+ int32_t base_seq_; |
+ int32_t base_delta_; |
+ uint8_t feedback_seq_; |
+ |
+ int64_t last_seq_; |
+ int64_t last_timestamp_; |
+ std::deque<StatusSymbol> symbol_vec_; |
+ uint16_t first_symbol_cardinality_; |
+ bool vec_needs_two_bit_symbols_; |
+ uint32_t size_bytes_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(FeedbackPacket); |
+}; |
+ |
+} // namespace rtcp |
+} // namespace webrtc |
+#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FEEDBACK_PACKET_H_ |