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> | 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/base/deprecation.h" |
19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 namespace rtcp { | 23 namespace rtcp { |
23 class CommonHeader; | 24 class CommonHeader; |
24 | 25 |
25 class TransportFeedback : public Rtpfb { | 26 class TransportFeedback : public Rtpfb { |
26 public: | 27 public: |
27 class PacketStatusChunk; | 28 class PacketStatusChunk; |
28 // TODO(sprang): IANA reg? | 29 // TODO(sprang): IANA reg? |
29 static constexpr uint8_t kFeedbackMessageType = 15; | 30 static constexpr uint8_t kFeedbackMessageType = 15; |
30 // Convert to multiples of 0.25ms. | 31 // Convert to multiples of 0.25ms. |
31 static constexpr int kDeltaScaleFactor = 250; | 32 static constexpr int kDeltaScaleFactor = 250; |
32 | 33 |
33 TransportFeedback(); | 34 TransportFeedback(); |
34 ~TransportFeedback() override; | 35 ~TransportFeedback() override; |
35 | 36 |
36 void WithPacketSenderSsrc(uint32_t ssrc) { From(ssrc); } | 37 void SetBase(uint16_t base_sequence, // Seq# of first packet in this msg. |
37 void WithMediaSourceSsrc(uint32_t ssrc) { To(ssrc); } | 38 int64_t ref_timestamp_us); // Reference timestamp for this msg. |
38 void WithBase(uint16_t base_sequence, // Seq# of first packet in this msg. | 39 void SetFeedbackSequenceNumber(uint8_t feedback_sequence); |
39 int64_t ref_timestamp_us); // Reference timestamp for this msg. | |
40 void WithFeedbackSequenceNumber(uint8_t feedback_sequence); | |
41 // NOTE: This method requires increasing sequence numbers (excepting wraps). | 40 // NOTE: This method requires increasing sequence numbers (excepting wraps). |
42 bool WithReceivedPacket(uint16_t sequence_number, int64_t timestamp_us); | 41 bool AddReceivedPacket(uint16_t sequence_number, int64_t timestamp_us); |
43 | 42 |
44 enum class StatusSymbol { | 43 enum class StatusSymbol { |
45 kNotReceived, | 44 kNotReceived, |
46 kReceivedSmallDelta, | 45 kReceivedSmallDelta, |
47 kReceivedLargeDelta, | 46 kReceivedLargeDelta, |
48 }; | 47 }; |
49 | 48 |
50 uint16_t GetBaseSequence() const; | 49 uint16_t GetBaseSequence() const; |
51 std::vector<TransportFeedback::StatusSymbol> GetStatusVector() const; | 50 std::vector<TransportFeedback::StatusSymbol> GetStatusVector() const; |
52 std::vector<int16_t> GetReceiveDeltas() const; | 51 std::vector<int16_t> GetReceiveDeltas() const; |
53 | 52 |
54 // Get the reference time in microseconds, including any precision loss. | 53 // Get the reference time in microseconds, including any precision loss. |
55 int64_t GetBaseTimeUs() const; | 54 int64_t GetBaseTimeUs() const; |
56 // Convenience method for getting all deltas as microseconds. The first delta | 55 // Convenience method for getting all deltas as microseconds. The first delta |
57 // is relative the base time. | 56 // is relative the base time. |
58 std::vector<int64_t> GetReceiveDeltasUs() const; | 57 std::vector<int64_t> GetReceiveDeltasUs() const; |
59 | 58 |
60 uint32_t GetPacketSenderSsrc() const { return sender_ssrc(); } | |
61 uint32_t GetMediaSourceSsrc() const { return media_ssrc(); } | |
62 | |
63 bool Parse(const CommonHeader& packet); | 59 bool Parse(const CommonHeader& packet); |
64 static std::unique_ptr<TransportFeedback> ParseFrom(const uint8_t* buffer, | 60 static std::unique_ptr<TransportFeedback> ParseFrom(const uint8_t* buffer, |
65 size_t length); | 61 size_t length); |
66 | 62 |
| 63 RTC_DEPRECATED |
| 64 void WithPacketSenderSenderSsrc(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 |
67 protected: | 80 protected: |
68 bool Create(uint8_t* packet, | 81 bool Create(uint8_t* packet, |
69 size_t* position, | 82 size_t* position, |
70 size_t max_length, | 83 size_t max_length, |
71 PacketReadyCallback* callback) const override; | 84 PacketReadyCallback* callback) const override; |
72 | 85 |
73 size_t BlockLength() const override; | 86 size_t BlockLength() const override; |
74 | 87 |
75 private: | 88 private: |
76 static PacketStatusChunk* ParseChunk(const uint8_t* buffer, size_t max_size); | 89 static PacketStatusChunk* ParseChunk(const uint8_t* buffer, size_t max_size); |
(...skipping 20 matching lines...) Expand all Loading... |
97 uint16_t first_symbol_cardinality_; | 110 uint16_t first_symbol_cardinality_; |
98 bool vec_needs_two_bit_symbols_; | 111 bool vec_needs_two_bit_symbols_; |
99 uint32_t size_bytes_; | 112 uint32_t size_bytes_; |
100 | 113 |
101 RTC_DISALLOW_COPY_AND_ASSIGN(TransportFeedback); | 114 RTC_DISALLOW_COPY_AND_ASSIGN(TransportFeedback); |
102 }; | 115 }; |
103 | 116 |
104 } // namespace rtcp | 117 } // namespace rtcp |
105 } // namespace webrtc | 118 } // namespace webrtc |
106 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TRANSPORT_FEEDBACK_H_ | 119 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TRANSPORT_FEEDBACK_H_ |
OLD | NEW |