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 #include "rtc_base/constructor_magic.h" 34 35 namespace webrtc { 36 37 class RtpPacketizerVp9 : public RtpPacketizer { 38 public: 39 // The |payload| must be one encoded VP9 layer frame. 40 RtpPacketizerVp9(rtc::ArrayView<const uint8_t> payload, 41 PayloadSizeLimits limits, 42 const RTPVideoHeaderVP9& hdr); 43 44 ~RtpPacketizerVp9() override; 45 46 size_t NumPackets() const override; 47 48 // Gets the next payload with VP9 payload header. 49 // Write payload and set marker bit of the |packet|. 50 // Returns true on success, false otherwise. 51 bool NextPacket(RtpPacketToSend* packet) override; 52 53 private: 54 // Writes the payload descriptor header. 55 // |layer_begin| and |layer_end| indicates the postision of the packet in 56 // the layer frame. Returns false on failure. 57 bool WriteHeader(bool layer_begin, 58 bool layer_end, 59 rtc::ArrayView<uint8_t> rtp_payload) const; 60 61 const RTPVideoHeaderVP9 hdr_; 62 const int header_size_; 63 const int first_packet_extra_header_size_; 64 rtc::ArrayView<const uint8_t> remaining_payload_; 65 std::vector<int> payload_sizes_; 66 std::vector<int>::const_iterator current_packet_; 67 68 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerVp9); 69 }; 70 71 } // namespace webrtc 72 #endif // MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_ 73