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

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

Issue 1434213004: rtcp::Ij renamed to rtcp::ExtendedJitterReport and moved into own file (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month 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 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h"
12
13 #include "webrtc/base/checks.h"
14 #include "webrtc/base/logging.h"
15 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
16 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
17
18 using webrtc::RTCPUtility::RtcpCommonHeader;
19
20 namespace webrtc {
21 namespace rtcp {
22
23 // Transmission Time Offsets in RTP Streams (RFC 5450).
24 //
25 // 0 1 2 3
26 // 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
27 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
28 // hdr |V=2|P| RC | PT=IJ=195 | length |
29 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
30 // | inter-arrival jitter |
31 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
32 // . .
33 // . .
34 // . .
35 // | inter-arrival jitter |
36 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 //
38 // If present, this RTCP packet must be placed after a receiver report
39 // (inside a compound RTCP packet), and MUST have the same value for RC
40 // (reception report count) as the receiver report.
41
42 bool ExtendedJitterReport::Parse(const RtcpCommonHeader& header,
43 const uint8_t* payload) {
44 RTC_DCHECK(header.packet_type == kPacketType);
45
46 const uint8_t jitters_count = header.count_or_format;
47 const size_t kJitterSizeBytes = 4u;
48
49 if (header.payload_size_bytes < jitters_count * kJitterSizeBytes) {
50 LOG(LS_WARNING) << "Packet is too small to contain all the jitter.";
51 return false;
52 }
53
54 inter_arrival_jitters_.resize(jitters_count);
55 for (size_t index = 0; index < jitters_count; ++index) {
56 inter_arrival_jitters_[index] =
57 ByteReader<uint32_t>::ReadBigEndian(&payload[index * kJitterSizeBytes]);
58 }
59
60 return true;
61 }
62
63 bool ExtendedJitterReport::WithJitter(uint32_t jitter) {
64 if (inter_arrival_jitters_.size() >= kMaxNumberOfJitters) {
65 LOG(LS_WARNING) << "Max inter-arrival jitter items reached.";
66 return false;
67 }
68 inter_arrival_jitters_.push_back(jitter);
69 return true;
70 }
71
72 bool ExtendedJitterReport::Create(
73 uint8_t* packet,
74 size_t* index,
75 size_t max_length,
76 RtcpPacket::PacketReadyCallback* callback) const {
77 while (*index + BlockLength() > max_length) {
78 if (!OnBufferFull(packet, index, callback))
79 return false;
80 }
81 const size_t index_end = *index + BlockLength();
82 size_t length = inter_arrival_jitters_.size();
83 CreateHeader(length, kPacketType, length, packet, index);
84
85 for (uint32_t jitter : inter_arrival_jitters_) {
86 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, jitter);
87 *index += sizeof(uint32_t);
88 }
89 // Sanity check.
90 RTC_DCHECK_EQ(index_end, *index);
91 return true;
92 }
93
94 } // namespace rtcp
95 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698