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/interface/module_common_types.h" | |
19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" | |
20 | |
21 namespace webrtc { | |
22 namespace rtcp { | |
23 | |
24 class PacketStatusChunk; | |
25 | |
26 class FeedbackPacket : public RtcpPacket { | |
stefan-webrtc
2015/07/27 11:49:28
I wonder if maybe we should rename this class to b
sprang_webrtc
2015/07/28 08:28:54
Renamed to TransportFeedback
| |
27 public: | |
28 FeedbackPacket(); | |
29 virtual ~FeedbackPacket(); | |
30 | |
31 void WithPacketSenderSsrc(uint32_t ssrc); | |
32 void WithMediaSourceSsrc(uint32_t ssrc); | |
33 void WithBase(uint16_t base_sequence, // Seq# of first packet in this msg. | |
34 int64_t ref_timestamp_us); // Reference timestamp for this msg. | |
35 void WithFeedbackSequenceNumber(uint8_t feedback_sequence); | |
36 // NOTE: This method require increasing sequence numbers (excepting wraps). | |
stefan-webrtc
2015/07/27 11:49:28
method requires or methods require :)
sprang_webrtc
2015/07/28 08:28:54
Bah, went too fast..
| |
37 bool WithReceivedPacket(uint16_t sequence_number, int64_t timestamp_us); | |
38 | |
39 enum class StatusSymbol { | |
40 kNotReceived, | |
41 kReceivedSmallDelta, | |
42 kReceivedLargeDelta, | |
43 }; | |
44 | |
45 uint16_t GetBaseSequence() const; | |
46 int32_t GetBaseTime() const; | |
47 std::vector<FeedbackPacket::StatusSymbol> GetStatusVector() const; | |
48 std::vector<int16_t> GetReceiveDeltas() const; | |
49 | |
50 // Get the reference time in microseconds, including any precision loss. | |
51 int64_t GetBaseTimeUs() const; | |
52 // Convenience method for getting all deltas as microseconds. The first delta | |
53 // is relative the base time. | |
54 std::vector<int64_t> GetReceiveDeltasUs() const; | |
55 | |
56 static const int kDeltaScaleFactor = 250; // Convert to multiples of 0.25ms. | |
57 static const uint8_t kFeedbackMessageType = 15; // TODO(sprang): IANA reg? | |
58 static const uint8_t kPayloadType = 205; // RTPFB, see RFC4585. | |
59 | |
60 static rtc::scoped_ptr<FeedbackPacket> ParseFrom(const uint8_t* buffer, | |
61 size_t length); | |
62 | |
63 protected: | |
64 bool Create(uint8_t* packet, | |
65 size_t* position, | |
66 size_t max_length, | |
67 PacketReadyCallback* callback) const override; | |
68 | |
69 size_t BlockLength() const override; | |
70 | |
71 private: | |
72 static PacketStatusChunk* ParseChunk(const uint8_t* buffer, size_t max_size); | |
73 | |
74 int64_t Unwrap(uint16_t sequence_number); | |
75 bool AddSymbol(StatusSymbol symbol, int64_t seq); | |
76 bool Encode(StatusSymbol symbol); | |
77 bool HandleRleCandidate(StatusSymbol symbol, | |
78 int current_capacity, | |
79 int delta_size); | |
80 void EmitRemaining(); | |
81 void EmitVectorChunk(); | |
82 void EmitRunLengthChunk(); | |
83 | |
84 uint32_t packet_sender_ssrc_; | |
85 uint32_t media_source_ssrc_; | |
86 int32_t base_seq_; | |
87 int64_t base_time_; | |
88 uint8_t feedback_seq_; | |
89 std::vector<PacketStatusChunk*> status_chunks_; | |
90 std::vector<int16_t> receive_deltas_; | |
91 | |
92 int64_t last_seq_; | |
93 int64_t last_timestamp_; | |
94 std::deque<StatusSymbol> symbol_vec_; | |
95 uint16_t first_symbol_cardinality_; | |
96 bool vec_needs_two_bit_symbols_; | |
97 uint32_t size_bytes_; | |
98 | |
99 DISALLOW_COPY_AND_ASSIGN(FeedbackPacket); | |
100 }; | |
101 | |
102 } // namespace rtcp | |
103 } // namespace webrtc | |
104 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FEEDBACK_PACKET_H_ | |
OLD | NEW |