Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

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

Issue 1175263002: Add packetization and coding/decoding of feedback message format. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Updated parsing to match new spec Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 {
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 methods requires increasing sequence numbers (excepting wraps).
stefan-webrtc 2015/07/14 12:14:54 s/requires/require
sprang_webrtc 2015/07/16 11:12:11 Done.
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
stefan-webrtc 2015/07/14 12:14:54 End with .
sprang_webrtc 2015/07/16 11:12:11 Done.
57 static const uint8_t kFeedbackMessageType = 15; // TODO(sprang): IANA reg?
58 static const uint8_t kPayloadType = 205; // RTPFB, see RFC4585
stefan-webrtc 2015/07/14 12:14:54 End with .
sprang_webrtc 2015/07/16 11:12:11 Done.
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 void EmitRemaining();
78 void EmitVectorChunk();
79 void EmitRunLengthChunk();
80
81 uint32_t packet_sender_ssrc_;
82 uint32_t media_source_ssrc_;
83 int32_t base_seq_;
84 int64_t base_time_;
85 uint8_t feedback_seq_;
86 std::vector<PacketStatusChunk*> status_chunks_;
87 std::vector<int16_t> receive_deltas_;
88
89 int64_t last_seq_;
90 int64_t last_timestamp_;
91 std::deque<StatusSymbol> symbol_vec_;
92 uint16_t first_symbol_cardinality_;
93 bool vec_needs_two_bit_symbols_;
94 uint32_t size_bytes_;
95
96 DISALLOW_COPY_AND_ASSIGN(FeedbackPacket);
97 };
98
99 } // namespace rtcp
100 } // namespace webrtc
101 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FEEDBACK_PACKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698