OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TRANSPORT_FEEDBACK_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TRANSPORT_FEEDBACK_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TRANSPORT_FEEDBACK_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TRANSPORT_FEEDBACK_H_ |
13 | 13 |
14 #include <deque> | |
15 #include <memory> | 14 #include <memory> |
16 #include <vector> | 15 #include <vector> |
17 | 16 |
18 #include "webrtc/base/constructormagic.h" | 17 #include "webrtc/base/constructormagic.h" |
19 #include "webrtc/base/deprecation.h" | |
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" | 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" |
21 | 19 |
22 namespace webrtc { | 20 namespace webrtc { |
23 namespace rtcp { | 21 namespace rtcp { |
24 class CommonHeader; | 22 class CommonHeader; |
25 | 23 |
26 class TransportFeedback : public Rtpfb { | 24 class TransportFeedback : public Rtpfb { |
27 public: | 25 public: |
28 class PacketStatusChunk; | |
29 // TODO(sprang): IANA reg? | 26 // TODO(sprang): IANA reg? |
30 static constexpr uint8_t kFeedbackMessageType = 15; | 27 static constexpr uint8_t kFeedbackMessageType = 15; |
31 // Convert to multiples of 0.25ms. | 28 // Convert to multiples of 0.25ms. |
32 static constexpr int kDeltaScaleFactor = 250; | 29 static constexpr int kDeltaScaleFactor = 250; |
30 // Maximum number of packets (including missing) TransportFeedback can report. | |
31 static constexpr size_t kMaxReportedPackets = 0xffff; | |
33 | 32 |
34 TransportFeedback(); | 33 TransportFeedback(); |
35 ~TransportFeedback() override; | 34 ~TransportFeedback() override; |
36 | 35 |
37 void SetBase(uint16_t base_sequence, // Seq# of first packet in this msg. | 36 void SetBase(uint16_t base_sequence, // Seq# of first packet in this msg. |
38 int64_t ref_timestamp_us); // Reference timestamp for this msg. | 37 int64_t ref_timestamp_us); // Reference timestamp for this msg. |
39 void SetFeedbackSequenceNumber(uint8_t feedback_sequence); | 38 void SetFeedbackSequenceNumber(uint8_t feedback_sequence); |
40 // NOTE: This method requires increasing sequence numbers (excepting wraps). | 39 // NOTE: This method requires increasing sequence numbers (excepting wraps). |
41 bool AddReceivedPacket(uint16_t sequence_number, int64_t timestamp_us); | 40 bool AddReceivedPacket(uint16_t sequence_number, int64_t timestamp_us); |
42 | 41 |
(...skipping 10 matching lines...) Expand all Loading... | |
53 // Get the reference time in microseconds, including any precision loss. | 52 // Get the reference time in microseconds, including any precision loss. |
54 int64_t GetBaseTimeUs() const; | 53 int64_t GetBaseTimeUs() const; |
55 // Convenience method for getting all deltas as microseconds. The first delta | 54 // Convenience method for getting all deltas as microseconds. The first delta |
56 // is relative the base time. | 55 // is relative the base time. |
57 std::vector<int64_t> GetReceiveDeltasUs() const; | 56 std::vector<int64_t> GetReceiveDeltasUs() const; |
58 | 57 |
59 bool Parse(const CommonHeader& packet); | 58 bool Parse(const CommonHeader& packet); |
60 static std::unique_ptr<TransportFeedback> ParseFrom(const uint8_t* buffer, | 59 static std::unique_ptr<TransportFeedback> ParseFrom(const uint8_t* buffer, |
61 size_t length); | 60 size_t length); |
62 | 61 |
63 RTC_DEPRECATED | |
64 void WithPacketSenderSsrc(uint32_t ssrc) { SetSenderSsrc(ssrc); } | |
65 RTC_DEPRECATED | |
66 void WithMediaSourceSsrc(uint32_t ssrc) { SetMediaSsrc(ssrc); } | |
67 RTC_DEPRECATED | |
68 void WithBase(uint16_t base_sequence, int64_t ref_timestamp_us) { | |
69 SetBase(base_sequence, ref_timestamp_us); | |
70 } | |
71 RTC_DEPRECATED | |
72 void WithFeedbackSequenceNumber(uint8_t feedback_sequence) { | |
73 SetFeedbackSequenceNumber(feedback_sequence); | |
74 } | |
75 RTC_DEPRECATED | |
76 bool WithReceivedPacket(uint16_t sequence_number, int64_t timestamp_us) { | |
77 return AddReceivedPacket(sequence_number, timestamp_us); | |
78 } | |
79 | |
80 protected: | 62 protected: |
81 bool Create(uint8_t* packet, | 63 bool Create(uint8_t* packet, |
82 size_t* position, | 64 size_t* position, |
83 size_t max_length, | 65 size_t max_length, |
84 PacketReadyCallback* callback) const override; | 66 PacketReadyCallback* callback) const override; |
85 | 67 |
86 size_t BlockLength() const override; | 68 size_t BlockLength() const override; |
87 | 69 |
88 private: | 70 private: |
89 static PacketStatusChunk* ParseChunk(const uint8_t* buffer, size_t max_size); | 71 using DeltaSize = uint8_t; |
sprang_webrtc
2017/01/12 13:18:46
Add comment static that this represents the byte s
danilchap
2017/01/16 09:45:15
Done.
| |
72 class LastChunk; | |
sprang_webrtc
2017/01/12 13:18:46
I'm not sure about this name. Could you update it
danilchap
2017/01/16 09:45:15
copied comment from definition of the class.
Not s
sprang_webrtc
2017/01/16 10:41:24
Let's keep the name, the comment is good.
| |
73 struct ReceivedPacket { | |
74 ReceivedPacket(uint16_t sequence_number, int16_t delta_ticks) | |
75 : sequence_number(sequence_number), delta_ticks(delta_ticks) {} | |
76 uint16_t sequence_number; | |
77 int16_t delta_ticks; | |
78 }; | |
79 // Pre and postcondition for all public methods. | |
80 bool IsConsistent() const; | |
90 | 81 |
91 int64_t Unwrap(uint16_t sequence_number); | 82 // Reset packet to consistent empty state. |
92 bool AddSymbol(StatusSymbol symbol, int64_t seq); | 83 void Clear(); |
93 bool Encode(StatusSymbol symbol); | |
94 bool HandleRleCandidate(StatusSymbol symbol, | |
95 int current_capacity, | |
96 int delta_size); | |
97 void EmitRemaining(); | |
98 void EmitVectorChunk(); | |
99 void EmitRunLengthChunk(); | |
100 | 84 |
101 int32_t base_seq_; | 85 bool AddDeltaSize(DeltaSize delta_size); |
102 int64_t base_time_; | 86 |
87 uint16_t base_seq_no_; | |
88 uint16_t num_seq_no_; | |
89 int32_t base_time_ticks_; | |
103 uint8_t feedback_seq_; | 90 uint8_t feedback_seq_; |
104 std::vector<PacketStatusChunk*> status_chunks_; | |
105 std::vector<int16_t> receive_deltas_; | |
106 | 91 |
107 int64_t last_seq_; | 92 int64_t last_timestamp_us_; |
108 int64_t last_timestamp_; | 93 std::vector<ReceivedPacket> packets_; |
109 std::deque<StatusSymbol> symbol_vec_; | 94 std::vector<uint16_t> chunks_; |
sprang_webrtc
2017/01/12 13:18:46
Can you comment or possibly typedef this so it's c
danilchap
2017/01/16 09:45:15
is rename enough?
Added also a comment, is helpful
sprang_webrtc
2017/01/16 10:41:25
This is fine with me, thanks!
| |
110 uint16_t first_symbol_cardinality_; | 95 const std::unique_ptr<LastChunk> last_chunk_; |
111 bool vec_needs_two_bit_symbols_; | 96 size_t size_bytes_; |
112 uint32_t size_bytes_; | |
113 | 97 |
114 RTC_DISALLOW_COPY_AND_ASSIGN(TransportFeedback); | 98 RTC_DISALLOW_COPY_AND_ASSIGN(TransportFeedback); |
115 }; | 99 }; |
116 | 100 |
117 } // namespace rtcp | 101 } // namespace rtcp |
118 } // namespace webrtc | 102 } // namespace webrtc |
119 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TRANSPORT_FEEDBACK_H_ | 103 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TRANSPORT_FEEDBACK_H_ |
OLD | NEW |