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 "modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" 12 13 #include "rtc_base/checks.h" 14 15 namespace webrtc { 16 namespace rtcp { 17 18 CompoundPacket::CompoundPacket() = default; 19 20 CompoundPacket::~CompoundPacket() = default; 21 Append(RtcpPacket * packet)22void CompoundPacket::Append(RtcpPacket* packet) { 23 RTC_CHECK(packet); 24 appended_packets_.push_back(packet); 25 } 26 Create(uint8_t * packet,size_t * index,size_t max_length,PacketReadyCallback callback) const27bool CompoundPacket::Create(uint8_t* packet, 28 size_t* index, 29 size_t max_length, 30 PacketReadyCallback callback) const { 31 for (RtcpPacket* appended : appended_packets_) { 32 if (!appended->Create(packet, index, max_length, callback)) 33 return false; 34 } 35 return true; 36 } 37 BlockLength() const38size_t CompoundPacket::BlockLength() const { 39 size_t block_length = 0; 40 for (RtcpPacket* appended : appended_packets_) { 41 block_length += appended->BlockLength(); 42 } 43 return block_length; 44 } 45 46 } // namespace rtcp 47 } // namespace webrtc 48