Class H264Packetiser
Contains functions to packetise an H264 Network Abstraction Layer Units (NAL or NALU) into an RTP payload. See "RTP Payload Format for H.264 Video" https://tools.ietf.org/html/rfc6184
Inherited Members
Namespace: SipLib.Video
Assembly: SipLib.dll
Syntax
public class H264Packetiser
Remarks
Packetisation Modes (see https://tools.ietf.org/html/rfc6184#section-6.2):
Mode 0: Single NAL Unit Mode. This is the default mode used when no packetization-mode parameter is present or when it is set to 0. Only single NAL unit packets may be used in this mode. STAPs, MTAPs and FUs must not be used.
Mode 1: Non-interleaved mode. This is the mode used when the packetization-mode=1. Only single NAL unit packets, STAP-As and FU-As may be used in this mode.
Mode 2: Interleaved mode. This is the mode used when the packetization-mode=2. This mode is not currently supported.
Methods
| Edit this page View SourceGetH264RtpHeader(byte, bool, bool)
Constructs the RTP header for an H264 NAL. This method does NOT support aggregation packets where multiple NALs are sent as a single RTP payload. The supported H264 header type is Single-Time Aggregation Packet type A (STAP-A) and Fragmentation Unit A (FU-A). The headers produced correspond to H264 packetization-mode=1.
Declaration
public static byte[] GetH264RtpHeader(byte nal0, bool isFirstPacket, bool isFinalPacket)
Parameters
Type | Name | Description |
---|---|---|
byte | nal0 | Input H264 NAL |
bool | isFirstPacket | Input. Set to true if this is the first packet |
bool | isFinalPacket | Input. Set to true if this is the final packet |
Returns
Type | Description |
---|---|
byte[] |
Remarks
RTP Payload Format for H.264 Video: https://tools.ietf.org/html/rfc6184
FFmpeg H264 RTP packetisation code: https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/rtpenc_h264_hevc.c
When the payload size is less than or equal to max RTP payload, send as Single-Time Aggregation Packet (STAP): https://tools.ietf.org/html/rfc6184#section-5.7.1
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| RTP Header |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|STAP-A NAL HDR | NALU 1 Size | NALU 1 HDR |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|F|NRI| Type | |
+-+-+-+-+-+-+-+-+
Type = 24 for STAP-A (NOTE: this is the type of the H264 RTP header and NOT the NAL type).
When the payload size is greater than max RTP payload, send as Fragmentation Unit A (FU-A): https://tools.ietf.org/html/rfc6184#section-5.8
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FU indicator | FU header | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Fragmentation Unit (FU) Payload
|
...
The FU indicator octet has the following format:
+---------------+
|0|1|2|3|4|5|6|7|
+-+-+-+-+-+-+-+-+
|F|NRI| Type |
+---------------+
F and NRI bits come from the NAL being transmitted. Type = 28 for FU-A (NOTE: this is the type of the H264 RTP header and NOT the NAL type).
The FU header has the following format:
+---------------+
|0|1|2|3|4|5|6|7|
+-+-+-+-+-+-+-+-+
|S|E|R| Type |
+---------------+
S: Set to 1 for the start of the NAL FU (i.e. first packet in frame). E: Set to 1 for the end of the NAL FU (i.e. the last packet in the frame). R: Reserved bit must be 0. Type: The NAL unit payload type, comes from NAL packet (NOTE: this IS the type of the NAL message).
ParseNals(byte[])
Parses an H264 encoded frame (access unit) into a list of H264Nal structures
Declaration
public static IEnumerable<H264Packetiser.H264Nal> ParseNals(byte[] accessUnit)
Parameters
Type | Name | Description |
---|---|---|
byte[] | accessUnit | Input H264 access unit |
Returns
Type | Description |
---|---|
IEnumerable<H264Packetiser.H264Nal> |