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

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

Issue 1544983002: [rtp_rtcp] rtcp::SenderReport moved into own file and got Parse function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 11 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
« no previous file with comments | « webrtc/modules/rtp_rtcp/rtp_rtcp.gypi ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet.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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 11
12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ 12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_
13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ 13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_
14 14
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/scoped_ptr.h" 17 #include "webrtc/base/scoped_ptr.h"
18 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h"
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
21 #include "webrtc/typedefs.h" 19 #include "webrtc/typedefs.h"
22 20
23 namespace webrtc { 21 namespace webrtc {
24 namespace rtcp { 22 namespace rtcp {
25 23
26 static const int kCommonFbFmtLength = 12; 24 static const int kCommonFbFmtLength = 12;
27 static const int kReportBlockLength = 24;
28 25
29 class RawPacket; 26 class RawPacket;
30 27
31 // Class for building RTCP packets. 28 // Class for building RTCP packets.
32 // 29 //
33 // Example: 30 // Example:
34 // ReportBlock report_block; 31 // ReportBlock report_block;
35 // report_block.To(234) 32 // report_block.To(234)
36 // report_block.FractionLost(10); 33 // report_block.FractionLost(10);
37 // 34 //
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 static const size_t kHeaderLength = 4; 110 static const size_t kHeaderLength = 4;
114 std::vector<RtcpPacket*> appended_packets_; 111 std::vector<RtcpPacket*> appended_packets_;
115 112
116 private: 113 private:
117 bool CreateAndAddAppended(uint8_t* packet, 114 bool CreateAndAddAppended(uint8_t* packet,
118 size_t* index, 115 size_t* index,
119 size_t max_length, 116 size_t max_length,
120 PacketReadyCallback* callback) const; 117 PacketReadyCallback* callback) const;
121 }; 118 };
122 119
123 // TODO(sprang): Move RtcpPacket subclasses out to separate files.
124
125 // RTCP sender report (RFC 3550).
126 //
127 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
128 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
129 // |V=2|P| RC | PT=SR=200 | length |
130 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
131 // | SSRC of sender |
132 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
133 // | NTP timestamp, most significant word |
134 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
135 // | NTP timestamp, least significant word |
136 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
137 // | RTP timestamp |
138 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
139 // | sender's packet count |
140 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
141 // | sender's octet count |
142 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
143 // | report block(s) |
144 // | .... |
145
146 class SenderReport : public RtcpPacket {
147 public:
148 SenderReport() : RtcpPacket() {
149 memset(&sr_, 0, sizeof(sr_));
150 }
151
152 virtual ~SenderReport() {}
153
154 void From(uint32_t ssrc) {
155 sr_.SenderSSRC = ssrc;
156 }
157 void WithNtpSec(uint32_t sec) {
158 sr_.NTPMostSignificant = sec;
159 }
160 void WithNtpFrac(uint32_t frac) {
161 sr_.NTPLeastSignificant = frac;
162 }
163 void WithRtpTimestamp(uint32_t rtp_timestamp) {
164 sr_.RTPTimestamp = rtp_timestamp;
165 }
166 void WithPacketCount(uint32_t packet_count) {
167 sr_.SenderPacketCount = packet_count;
168 }
169 void WithOctetCount(uint32_t octet_count) {
170 sr_.SenderOctetCount = octet_count;
171 }
172 bool WithReportBlock(const ReportBlock& block);
173
174 protected:
175 bool Create(uint8_t* packet,
176 size_t* index,
177 size_t max_length,
178 RtcpPacket::PacketReadyCallback* callback) const override;
179
180 private:
181 static const int kMaxNumberOfReportBlocks = 0x1f;
182
183 size_t BlockLength() const {
184 const size_t kSrHeaderLength = 8;
185 const size_t kSenderInfoLength = 20;
186 return kSrHeaderLength + kSenderInfoLength +
187 report_blocks_.size() * kReportBlockLength;
188 }
189
190 RTCPUtility::RTCPPacketSR sr_;
191 std::vector<ReportBlock> report_blocks_;
192
193 RTC_DISALLOW_COPY_AND_ASSIGN(SenderReport);
194 };
195
196 // Class holding a RTCP packet. 120 // Class holding a RTCP packet.
197 // 121 //
198 // Takes a built rtcp packet. 122 // Takes a built rtcp packet.
199 // RawPacket raw_packet(buffer, length); 123 // RawPacket raw_packet(buffer, length);
200 // 124 //
201 // To access the raw packet: 125 // To access the raw packet:
202 // raw_packet.Buffer(); - pointer to the raw packet 126 // raw_packet.Buffer(); - pointer to the raw packet
203 // raw_packet.BufferLength(); - the length of the raw packet 127 // raw_packet.BufferLength(); - the length of the raw packet
204 128
205 class RawPacket { 129 class RawPacket {
206 public: 130 public:
207 explicit RawPacket(size_t buffer_length); 131 explicit RawPacket(size_t buffer_length);
208 RawPacket(const uint8_t* packet, size_t packet_length); 132 RawPacket(const uint8_t* packet, size_t packet_length);
209 133
210 const uint8_t* Buffer() const; 134 const uint8_t* Buffer() const;
211 uint8_t* MutableBuffer(); 135 uint8_t* MutableBuffer();
212 size_t BufferLength() const; 136 size_t BufferLength() const;
213 size_t Length() const; 137 size_t Length() const;
214 void SetLength(size_t length); 138 void SetLength(size_t length);
215 139
216 private: 140 private:
217 const size_t buffer_length_; 141 const size_t buffer_length_;
218 size_t length_; 142 size_t length_;
219 rtc::scoped_ptr<uint8_t[]> buffer_; 143 rtc::scoped_ptr<uint8_t[]> buffer_;
220 }; 144 };
221 145
222 } // namespace rtcp 146 } // namespace rtcp
223 } // namespace webrtc 147 } // namespace webrtc
224 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ 148 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/rtp_rtcp.gypi ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698