tor-browser

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

rtp_format.h (2034B)


      1 /*
      2 *  Copyright (c) 2014 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 #ifndef MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H_
     12 #define MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H_
     13 
     14 #include <stdint.h>
     15 
     16 #include <cstddef>
     17 #include <memory>
     18 #include <optional>
     19 #include <vector>
     20 
     21 #include "api/array_view.h"
     22 #include "api/video/video_codec_type.h"
     23 #include "modules/rtp_rtcp/source/rtp_video_header.h"
     24 
     25 namespace webrtc {
     26 
     27 class RtpPacketToSend;
     28 
     29 class RtpPacketizer {
     30 public:
     31  struct PayloadSizeLimits {
     32    int max_payload_len = 1200;
     33    int first_packet_reduction_len = 0;
     34    int last_packet_reduction_len = 0;
     35    // Reduction len for packet that is first & last at the same time.
     36    int single_packet_reduction_len = 0;
     37  };
     38 
     39  // If type is not set, returns a raw packetizer.
     40  static std::unique_ptr<RtpPacketizer> Create(
     41      std::optional<VideoCodecType> type,
     42      ArrayView<const uint8_t> payload,
     43      PayloadSizeLimits limits,
     44      // Codec-specific details.
     45      const RTPVideoHeader& rtp_video_header);
     46 
     47  virtual ~RtpPacketizer() = default;
     48 
     49  // Returns number of remaining packets to produce by the packetizer.
     50  virtual size_t NumPackets() const = 0;
     51 
     52  // Get the next payload with payload header.
     53  // Write payload and set marker bit of the `packet`.
     54  // Returns true on success, false otherwise.
     55  virtual bool NextPacket(RtpPacketToSend* packet) = 0;
     56 
     57  // Split payload_len into sum of integers with respect to `limits`.
     58  // Returns empty vector on failure.
     59  static std::vector<int> SplitAboutEqually(int payload_len,
     60                                            const PayloadSizeLimits& limits);
     61 };
     62 }  // namespace webrtc
     63 #endif  // MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H_