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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.cc

Issue 1579213005: [rtp_rtcp] rtcp::Xr moved into own file and renamed to ExtendedReports on the way (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 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 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h"
12
13 #include "webrtc/base/checks.h"
14 #include "webrtc/base/logging.h"
15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
16
17 using webrtc::RTCPUtility::PT_XR;
18 using webrtc::RTCPUtility::RTCPPacketXR;
19
20 namespace webrtc {
21 namespace rtcp {
22 namespace {
23 void AssignUWord32(uint8_t* buffer, size_t* offset, uint32_t value) {
24 ByteWriter<uint32_t>::WriteBigEndian(buffer + *offset, value);
25 *offset += 4;
26 }
27 // From RFC 3611: RTP Control Protocol Extended Reports (RTCP XR).
28 //
29 // Format for XR packets:
30 //
31 // 0 1 2 3
32 // 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
33 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
34 // |V=2|P|reserved | PT=XR=207 | length |
35 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 // | SSRC |
37 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 // : report blocks :
39 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 void CreateXrHeader(const RTCPPacketXR& header,
41 uint8_t* buffer,
42 size_t* pos) {
43 AssignUWord32(buffer, pos, header.OriginatorSSRC);
44 }
45 } // namespace
46
47 bool ExtendedReports::Create(uint8_t* packet,
48 size_t* index,
49 size_t max_length,
50 RtcpPacket::PacketReadyCallback* callback) const {
51 while (*index + BlockLength() > max_length) {
52 if (!OnBufferFull(packet, index, callback))
53 return false;
54 }
55 CreateHeader(0U, PT_XR, HeaderLength(), packet, index);
56 CreateXrHeader(xr_header_, packet, index);
57 for (const Rrtr& block : rrtr_blocks_) {
58 block.Create(packet + *index);
59 *index += Rrtr::kLength;
60 }
61 for (const Dlrr& block : dlrr_blocks_) {
62 block.Create(packet + *index);
63 *index += block.BlockLength();
64 }
65 for (const VoipMetric& block : voip_metric_blocks_) {
66 block.Create(packet + *index);
67 *index += VoipMetric::kLength;
68 }
69 return true;
70 }
71
72 bool ExtendedReports::WithRrtr(Rrtr* rrtr) {
73 RTC_DCHECK(rrtr);
74 if (rrtr_blocks_.size() >= kMaxNumberOfRrtrBlocks) {
75 LOG(LS_WARNING) << "Max RRTR blocks reached.";
76 return false;
77 }
78 rrtr_blocks_.push_back(*rrtr);
79 return true;
80 }
81
82 bool ExtendedReports::WithDlrr(Dlrr* dlrr) {
83 RTC_DCHECK(dlrr);
84 if (dlrr_blocks_.size() >= kMaxNumberOfDlrrBlocks) {
85 LOG(LS_WARNING) << "Max DLRR blocks reached.";
86 return false;
87 }
88 dlrr_blocks_.push_back(*dlrr);
89 return true;
90 }
91
92 bool ExtendedReports::WithVoipMetric(VoipMetric* voip_metric) {
93 assert(voip_metric);
94 if (voip_metric_blocks_.size() >= kMaxNumberOfVoipMetricBlocks) {
95 LOG(LS_WARNING) << "Max Voip Metric blocks reached.";
96 return false;
97 }
98 voip_metric_blocks_.push_back(*voip_metric);
99 return true;
100 }
101
102 size_t ExtendedReports::DlrrLength() const {
103 size_t length = 0;
104 for (const Dlrr& block : dlrr_blocks_) {
105 length += block.BlockLength();
106 }
107 return length;
108 }
109
110 } // namespace rtcp
111 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698