1
/* $Id: h264_packetizer.h 3664 2011-07-19 03:42:28Z nanang $ */
3
* Copyright (C) 2011 Teluu Inc. (http://www.teluu.com)
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
#ifndef __PJMEDIA_H264_PACKETIZER_H__
20
#define __PJMEDIA_H264_PACKETIZER_H__
23
* @file h264_packetizer.h
24
* @brief Packetizes H.264 bitstream into RTP payload and vice versa.
32
* Opaque declaration for H.264 packetizer.
34
typedef struct pjmedia_h264_packetizer pjmedia_h264_packetizer;
38
* Enumeration of H.264 packetization modes.
43
* Single NAL unit packetization mode will only generate payloads
44
* containing a complete single NAL unit packet. As H.264 NAL unit
45
* size can be very large, this mode is usually not applicable for
46
* network environments with MTU size limitation.
48
PJMEDIA_H264_PACKETIZER_MODE_SINGLE_NAL,
51
* Non-interleaved packetization mode will generate payloads with the
52
* following possible formats:
53
* - single NAL unit packets,
54
* - NAL units aggregation STAP-A packets,
55
* - fragmented NAL unit FU-A packets.
57
PJMEDIA_H264_PACKETIZER_MODE_NON_INTERLEAVED,
60
* Interleaved packetization mode will generate payloads with the
61
* following possible formats:
62
* - single NAL unit packets,
63
* - NAL units aggregation STAP-A & STAP-B packets,
64
* - fragmented NAL unit FU-A & FU-B packets.
65
* This packetization mode is currently unsupported.
67
PJMEDIA_H264_PACKETIZER_MODE_INTERLEAVED,
68
} pjmedia_h264_packetizer_mode;
72
* H.264 packetizer setting.
74
typedef struct pjmedia_h264_packetizer_cfg
77
* Maximum payload length.
78
* Default: PJMEDIA_MAX_MTU
84
* Default: PJMEDIA_H264_PACKETIZER_MODE_NON_INTERLEAVED
86
pjmedia_h264_packetizer_mode mode;
88
pjmedia_h264_packetizer_cfg;
92
* Create H.264 packetizer.
94
* @param pool The memory pool.
95
* @param cfg Packetizer settings, if NULL, default setting
97
* @param p_pktz Pointer to receive the packetizer.
99
* @return PJ_SUCCESS on success.
101
PJ_DECL(pj_status_t) pjmedia_h264_packetizer_create(
103
const pjmedia_h264_packetizer_cfg *cfg,
104
pjmedia_h264_packetizer **p_pktz);
108
* Generate an RTP payload from a H.264 picture bitstream. Note that this
109
* function will apply in-place processing, so the bitstream may be modified
110
* during the packetization.
112
* @param pktz The packetizer.
113
* @param bits The picture bitstream to be packetized.
114
* @param bits_len The length of the bitstream.
115
* @param bits_pos The bitstream offset to be packetized.
116
* @param payload The output payload.
117
* @param payload_len The output payload length.
119
* @return PJ_SUCCESS on success.
121
PJ_DECL(pj_status_t) pjmedia_h264_packetize(pjmedia_h264_packetizer *pktz,
125
const pj_uint8_t **payload,
126
pj_size_t *payload_len);
130
* Append an RTP payload to an H.264 picture bitstream. Note that in case of
131
* noticing packet lost, application should keep calling this function with
132
* payload pointer set to NULL, as the packetizer need to update its internal
135
* @param pktz The packetizer.
136
* @param payload The payload to be unpacketized.
137
* @param payload_len The payload length.
138
* @param bits The bitstream buffer.
139
* @param bits_size The bitstream buffer size.
140
* @param bits_pos The bitstream offset to put the unpacketized payload
141
* in the bitstream, upon return, this will be updated
142
* to the latest offset as a result of the unpacketized
145
* @return PJ_SUCCESS on success.
147
PJ_DECL(pj_status_t) pjmedia_h264_unpacketize(pjmedia_h264_packetizer *pktz,
148
const pj_uint8_t *payload,
149
pj_size_t payload_len,
157
#endif /* __PJMEDIA_H264_PACKETIZER_H__ */