Chromium Code Reviews

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h

Issue 1847973003: [rtcp] TransportFeedback adjusted to match other rtcp packets (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove underused buffer check from Parse, added it to Create Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 14 #include <deque>
15 #include <memory> 15 #include <memory>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/base/constructormagic.h" 18 #include "webrtc/base/constructormagic.h"
19 #include "webrtc/modules/include/module_common_types.h" 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h"
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
21 20
22 namespace webrtc { 21 namespace webrtc {
23 namespace rtcp { 22 namespace rtcp {
23 class CommonHeader;
24 24
25 class PacketStatusChunk; 25 class TransportFeedback : public Rtpfb {
26 public:
27 class PacketStatusChunk;
28 // TODO(sprang): IANA reg?
29 static constexpr uint8_t kFeedbackMessageType = 15;
30 // Convert to multiples of 0.25ms.
31 static constexpr int kDeltaScaleFactor = 250;
26 32
27 class TransportFeedback : public RtcpPacket {
28 public:
29 TransportFeedback(); 33 TransportFeedback();
30 virtual ~TransportFeedback(); 34 ~TransportFeedback() override;
31 35
32 void WithPacketSenderSsrc(uint32_t ssrc); 36 void WithPacketSenderSsrc(uint32_t ssrc) { From(ssrc); }
33 void WithMediaSourceSsrc(uint32_t ssrc); 37 void WithMediaSourceSsrc(uint32_t ssrc) { To(ssrc); }
34 void WithBase(uint16_t base_sequence, // Seq# of first packet in this msg. 38 void WithBase(uint16_t base_sequence, // Seq# of first packet in this msg.
35 int64_t ref_timestamp_us); // Reference timestamp for this msg. 39 int64_t ref_timestamp_us); // Reference timestamp for this msg.
36 void WithFeedbackSequenceNumber(uint8_t feedback_sequence); 40 void WithFeedbackSequenceNumber(uint8_t feedback_sequence);
37 // NOTE: This method requires increasing sequence numbers (excepting wraps). 41 // NOTE: This method requires increasing sequence numbers (excepting wraps).
38 bool WithReceivedPacket(uint16_t sequence_number, int64_t timestamp_us); 42 bool WithReceivedPacket(uint16_t sequence_number, int64_t timestamp_us);
39 43
40 enum class StatusSymbol { 44 enum class StatusSymbol {
41 kNotReceived, 45 kNotReceived,
42 kReceivedSmallDelta, 46 kReceivedSmallDelta,
43 kReceivedLargeDelta, 47 kReceivedLargeDelta,
44 }; 48 };
45 49
46 uint16_t GetBaseSequence() const; 50 uint16_t GetBaseSequence() const;
47 std::vector<TransportFeedback::StatusSymbol> GetStatusVector() const; 51 std::vector<TransportFeedback::StatusSymbol> GetStatusVector() const;
48 std::vector<int16_t> GetReceiveDeltas() const; 52 std::vector<int16_t> GetReceiveDeltas() const;
49 53
50 // Get the reference time in microseconds, including any precision loss. 54 // Get the reference time in microseconds, including any precision loss.
51 int64_t GetBaseTimeUs() const; 55 int64_t GetBaseTimeUs() const;
52 // Convenience method for getting all deltas as microseconds. The first delta 56 // Convenience method for getting all deltas as microseconds. The first delta
53 // is relative the base time. 57 // is relative the base time.
54 std::vector<int64_t> GetReceiveDeltasUs() const; 58 std::vector<int64_t> GetReceiveDeltasUs() const;
55 59
56 uint32_t GetPacketSenderSsrc() const; 60 uint32_t GetPacketSenderSsrc() const { return sender_ssrc(); }
57 uint32_t GetMediaSourceSsrc() const; 61 uint32_t GetMediaSourceSsrc() const { return media_ssrc(); }
58 static const int kDeltaScaleFactor = 250; // Convert to multiples of 0.25ms.
59 static const uint8_t kFeedbackMessageType = 15; // TODO(sprang): IANA reg?
60 static const uint8_t kPayloadType = 205; // RTPFB, see RFC4585.
61 62
63 bool Parse(const CommonHeader& packet);
62 static std::unique_ptr<TransportFeedback> ParseFrom(const uint8_t* buffer, 64 static std::unique_ptr<TransportFeedback> ParseFrom(const uint8_t* buffer,
63 size_t length); 65 size_t length);
64 66
65 protected: 67 protected:
66 bool Create(uint8_t* packet, 68 bool Create(uint8_t* packet,
67 size_t* position, 69 size_t* position,
68 size_t max_length, 70 size_t max_length,
69 PacketReadyCallback* callback) const override; 71 PacketReadyCallback* callback) const override;
70 72
71 size_t BlockLength() const override; 73 size_t BlockLength() const override;
72 74
73 private: 75 private:
74 static PacketStatusChunk* ParseChunk(const uint8_t* buffer, size_t max_size); 76 static PacketStatusChunk* ParseChunk(const uint8_t* buffer, size_t max_size);
75 77
76 int64_t Unwrap(uint16_t sequence_number); 78 int64_t Unwrap(uint16_t sequence_number);
77 bool AddSymbol(StatusSymbol symbol, int64_t seq); 79 bool AddSymbol(StatusSymbol symbol, int64_t seq);
78 bool Encode(StatusSymbol symbol); 80 bool Encode(StatusSymbol symbol);
79 bool HandleRleCandidate(StatusSymbol symbol, 81 bool HandleRleCandidate(StatusSymbol symbol,
80 int current_capacity, 82 int current_capacity,
81 int delta_size); 83 int delta_size);
82 void EmitRemaining(); 84 void EmitRemaining();
83 void EmitVectorChunk(); 85 void EmitVectorChunk();
84 void EmitRunLengthChunk(); 86 void EmitRunLengthChunk();
85 87
86 uint32_t packet_sender_ssrc_;
87 uint32_t media_source_ssrc_;
88 int32_t base_seq_; 88 int32_t base_seq_;
89 int64_t base_time_; 89 int64_t base_time_;
90 uint8_t feedback_seq_; 90 uint8_t feedback_seq_;
91 std::vector<PacketStatusChunk*> status_chunks_; 91 std::vector<PacketStatusChunk*> status_chunks_;
92 std::vector<int16_t> receive_deltas_; 92 std::vector<int16_t> receive_deltas_;
93 93
94 int64_t last_seq_; 94 int64_t last_seq_;
95 int64_t last_timestamp_; 95 int64_t last_timestamp_;
96 std::deque<StatusSymbol> symbol_vec_; 96 std::deque<StatusSymbol> symbol_vec_;
97 uint16_t first_symbol_cardinality_; 97 uint16_t first_symbol_cardinality_;
98 bool vec_needs_two_bit_symbols_; 98 bool vec_needs_two_bit_symbols_;
99 uint32_t size_bytes_; 99 uint32_t size_bytes_;
100 100
101 RTC_DISALLOW_COPY_AND_ASSIGN(TransportFeedback); 101 RTC_DISALLOW_COPY_AND_ASSIGN(TransportFeedback);
102 }; 102 };
103 103
104 } // namespace rtcp 104 } // namespace rtcp
105 } // namespace webrtc 105 } // namespace webrtc
106 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TRANSPORT_FEEDBACK_H_ 106 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TRANSPORT_FEEDBACK_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.cc » ('j') | no next file with comments »

Powered by Google App Engine