tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

compound_packet.cc (1503B)


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