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 <memory> 14 #include <utility> 15 16 #include "rtc_base/checks.h" 17 18 namespace webrtc { 19 namespace rtcp { 20 21 CompoundPacket::CompoundPacket() = default; 22 23 CompoundPacket::~CompoundPacket() = default; 24 Append(std::unique_ptr<RtcpPacket> packet)25void CompoundPacket::Append(std::unique_ptr<RtcpPacket> packet) { 26 RTC_CHECK(packet); 27 appended_packets_.push_back(std::move(packet)); 28 } 29 Create(uint8_t * packet,size_t * index,size_t max_length,PacketReadyCallback callback) const30bool CompoundPacket::Create(uint8_t* packet, 31 size_t* index, 32 size_t max_length, 33 PacketReadyCallback callback) const { 34 for (const auto& appended : appended_packets_) { 35 if (!appended->Create(packet, index, max_length, callback)) 36 return false; 37 } 38 return true; 39 } 40 BlockLength() const41size_t CompoundPacket::BlockLength() const { 42 size_t block_length = 0; 43 for (const auto& appended : appended_packets_) { 44 block_length += appended->BlockLength(); 45 } 46 return block_length; 47 } 48 49 } // namespace rtcp 50 } // namespace webrtc 51