2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H264_H_
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H264_H_
17 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h"
21 class RtpPacketizerH264 : public RtpPacketizer {
23 // Initialize with payload from encoder.
24 // The payload_data must be exactly one encoded H264 frame.
25 RtpPacketizerH264(FrameType frame_type, size_t max_payload_len);
27 virtual ~RtpPacketizerH264();
29 virtual void SetPayloadData(
30 const uint8_t* payload_data,
32 const RTPFragmentationHeader* fragmentation) OVERRIDE;
34 // Get the next payload with H264 payload header.
35 // buffer is a pointer to where the output will be written.
36 // bytes_to_send is an output variable that will contain number of bytes
37 // written to buffer. The parameter last_packet is true for the last packet of
38 // the frame, false otherwise (i.e., call the function again to get the
40 // Returns true on success or false if there was no payload to packetize.
41 virtual bool NextPacket(uint8_t* buffer,
42 size_t* bytes_to_send,
43 bool* last_packet) OVERRIDE;
45 virtual ProtectionType GetProtectionType() OVERRIDE;
47 virtual StorageType GetStorageType(uint32_t retransmission_settings) OVERRIDE;
49 virtual std::string ToString() OVERRIDE;
61 first_fragment(first_fragment),
62 last_fragment(last_fragment),
63 aggregated(aggregated),
73 typedef std::queue<Packet> PacketQueue;
75 void GeneratePackets();
76 void PacketizeFuA(size_t fragment_offset, size_t fragment_length);
77 int PacketizeStapA(size_t fragment_index,
78 size_t fragment_offset,
79 size_t fragment_length);
80 void NextAggregatePacket(uint8_t* buffer, size_t* bytes_to_send);
81 void NextFragmentPacket(uint8_t* buffer, size_t* bytes_to_send);
83 const uint8_t* payload_data_;
85 const size_t max_payload_len_;
86 RTPFragmentationHeader fragmentation_;
88 FrameType frame_type_;
90 DISALLOW_COPY_AND_ASSIGN(RtpPacketizerH264);
93 // Depacketizer for H264.
94 class RtpDepacketizerH264 : public RtpDepacketizer {
96 virtual ~RtpDepacketizerH264() {}
98 virtual bool Parse(ParsedPayload* parsed_payload,
99 const uint8_t* payload_data,
100 size_t payload_data_length) OVERRIDE;
102 } // namespace webrtc
103 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H264_H_