tor-browser

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

rtp_format_vp9.h (2473B)


      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 //
     12 // This file contains the declaration of the VP9 packetizer class.
     13 // A packetizer object is created for each encoded video frame. The
     14 // constructor is called with the payload data and size.
     15 //
     16 // After creating the packetizer, the method NextPacket is called
     17 // repeatedly to get all packets for the frame. The method returns
     18 // false as long as there are more packets left to fetch.
     19 //
     20 
     21 #ifndef MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_
     22 #define MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_
     23 
     24 #include <stddef.h>
     25 #include <stdint.h>
     26 
     27 #include <vector>
     28 
     29 #include "api/array_view.h"
     30 #include "modules/rtp_rtcp/source/rtp_format.h"
     31 #include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
     32 #include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
     33 
     34 namespace webrtc {
     35 
     36 class RtpPacketizerVp9 : public RtpPacketizer {
     37 public:
     38  // The `payload` must be one encoded VP9 layer frame.
     39  RtpPacketizerVp9(ArrayView<const uint8_t> payload,
     40                   PayloadSizeLimits limits,
     41                   const RTPVideoHeaderVP9& hdr);
     42 
     43  ~RtpPacketizerVp9() override;
     44 
     45  RtpPacketizerVp9(const RtpPacketizerVp9&) = delete;
     46  RtpPacketizerVp9& operator=(const RtpPacketizerVp9&) = delete;
     47 
     48  size_t NumPackets() const override;
     49 
     50  // Gets the next payload with VP9 payload header.
     51  // Write payload and set marker bit of the `packet`.
     52  // Returns true on success, false otherwise.
     53  bool NextPacket(RtpPacketToSend* packet) override;
     54 
     55 private:
     56  // Writes the payload descriptor header.
     57  // `layer_begin` and `layer_end` indicates the postision of the packet in
     58  // the layer frame. Returns false on failure.
     59  bool WriteHeader(bool layer_begin,
     60                   bool layer_end,
     61                   ArrayView<uint8_t> rtp_payload) const;
     62 
     63  const RTPVideoHeaderVP9 hdr_;
     64  const int header_size_;
     65  const int first_packet_extra_header_size_;
     66  ArrayView<const uint8_t> remaining_payload_;
     67  std::vector<int> payload_sizes_;
     68  std::vector<int>::const_iterator current_packet_;
     69 };
     70 
     71 }  // namespace webrtc
     72 #endif  // MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_