OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FEEDBACK_PACKET_H_ | |
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FEEDBACK_PACKET_H_ | |
13 | |
14 #include <deque> | |
15 #include <vector> | |
16 | |
17 #include "webrtc/base/constructormagic.h" | |
18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" | |
19 | |
20 namespace webrtc { | |
21 namespace rtcp { | |
22 | |
23 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
| |
24 public: | |
25 FeedbackPacket(); | |
26 virtual ~FeedbackPacket(); | |
27 | |
28 void WithBase(uint16_t base_sequence, // Seq# of first packet in this msg. | |
29 int64_t prev_timestamp_us, // Timestamp of last fb packet. | |
30 int64_t ref_timestamp_us); // Reference timestamp for this msg. | |
31 void WithFeedbackSequenceNumber(uint8_t feedback_sequence); | |
32 // 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.
| |
33 bool WithReceivedPacket(uint16_t sequence_number, int64_t timestamp_us); | |
34 bool WithUntimedPacket(uint16_t sequence_number); | |
35 | |
36 enum class StatusSymbol { | |
37 kNotReceived, | |
38 kReceivedSmallDelta, | |
39 kReceivedLargeDelta, | |
40 kReceivedUntimed, | |
41 }; | |
42 | |
43 uint16_t GetBaseSequence() const; | |
44 int16_t GetBaseDelta() const; | |
45 std::vector<FeedbackPacket::StatusSymbol> GetStatusVector() const; | |
46 std::vector<int16_t> GetReceiveDeltas() const; | |
47 | |
48 // Get the reference time in microseconds, including any precision loss. | |
49 int64_t GetBaseDeltaUs() const; | |
50 // Convenience method for getting all deltas as microseconds. For this method, | |
51 // the first value will include the base delta. | |
52 std::vector<int64_t> GetReceiveDeltasUs() const; | |
53 | |
54 static const int kDeltaScaleFactor = 250; // Convert to multiples of 0.25ms | |
55 | |
56 static rtc::scoped_ptr<FeedbackPacket> ParseFrom(const uint8_t* buffer, | |
57 size_t length); | |
58 | |
59 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
| |
60 | |
61 protected: | |
62 bool Create(uint8_t* packet, | |
63 size_t* position, | |
64 size_t max_length, | |
65 PacketReadyCallback* callback) const override; | |
66 | |
67 private: | |
68 static const int kOneBitVectorCapacity = 14; | |
69 static const int kTwoBitVectorCapacity = 7; | |
70 static const int kRunLengthCapacity = 0x1FFF; | |
71 // 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
| |
72 static const int kMaxSizeBytes = 0xFF * 4 + 8; | |
73 static const int kMinSizeBytes = 8 + 2; // Header plus one status chunk. | |
74 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.
| |
75 | |
76 static PacketStatusChunk* ParseChunk(const uint8_t* buffer, size_t max_size); | |
77 | |
78 int64_t Unwrap(uint16_t sequence_number); | |
79 bool AddSymbol(StatusSymbol symbol, int64_t seq); | |
80 bool Encode(StatusSymbol symbol); | |
81 void EmitRemaining(); | |
82 void EmitVectorChunk(); | |
83 void EmitRunLengthChunk(); | |
84 | |
85 std::vector<PacketStatusChunk*> status_chunks_; | |
86 std::vector<int16_t> receive_deltas_; | |
87 int32_t base_seq_; | |
88 int32_t base_delta_; | |
89 uint8_t feedback_seq_; | |
90 | |
91 int64_t last_seq_; | |
92 int64_t last_timestamp_; | |
93 std::deque<StatusSymbol> symbol_vec_; | |
94 uint16_t first_symbol_cardinality_; | |
95 bool vec_needs_two_bit_symbols_; | |
96 uint32_t size_bytes_; | |
97 | |
98 DISALLOW_COPY_AND_ASSIGN(FeedbackPacket); | |
99 }; | |
100 | |
101 } // namespace rtcp | |
102 } // namespace webrtc | |
103 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FEEDBACK_PACKET_H_ | |
OLD | NEW |