Debian Codegraph @

Xpjproject/pjmedia/include/pjmedia-codec/h264_packetizer.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2011 Teluu Inc. (http://www.teluu.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 #ifndef __PJMEDIA_H264_PACKETIZER_H__
19 #define __PJMEDIA_H264_PACKETIZER_H__
20
21 /**
22 * @file h264_packetizer.h
23 * @brief Packetizes H.264 bitstream into RTP payload and vice versa.
24 */
25
26 #include <pj/types.h>
27
28 PJ_BEGIN_DECL
29
30 /**
31 * Opaque declaration for H.264 packetizer.
32 */
33 typedef struct pjmedia_h264_packetizer pjmedia_h264_packetizer;
34
35
36 /**
37 * Enumeration of H.264 packetization modes.
38 */
39 typedef enum
40 {
41 /**
42 * Single NAL unit packetization mode will only generate payloads
43 * containing a complete single NAL unit packet. As H.264 NAL unit
44 * size can be very large, this mode is usually not applicable for
45 * network environments with MTU size limitation.
46 */
47 PJMEDIA_H264_PACKETIZER_MODE_SINGLE_NAL,
48
49 /**
50 * Non-interleaved packetization mode will generate payloads with the
51 * following possible formats:
52 * - single NAL unit packets,
53 * - NAL units aggregation STAP-A packets,
54 * - fragmented NAL unit FU-A packets.
55 */
56 PJMEDIA_H264_PACKETIZER_MODE_NON_INTERLEAVED,
57
58 /**
59 * Interleaved packetization mode will generate payloads with the
60 * following possible formats:
61 * - single NAL unit packets,
62 * - NAL units aggregation STAP-A & STAP-B packets,
63 * - fragmented NAL unit FU-A & FU-B packets.
64 * This packetization mode is currently unsupported.
65 */
66 PJMEDIA_H264_PACKETIZER_MODE_INTERLEAVED,
67 } pjmedia_h264_packetizer_mode;
68
69
70 /**
71 * H.264 packetizer setting.
72 */
73 typedef struct pjmedia_h264_packetizer_cfg
74 {
75 /**
76 * Maximum payload length.
77 * Default: PJMEDIA_MAX_MTU
78 */
79 int mtu;
80
81 /**
82 * Packetization mode.
83 * Default: PJMEDIA_H264_PACKETIZER_MODE_NON_INTERLEAVED
84 */
85 pjmedia_h264_packetizer_mode mode;
86
87 /**
88 * NAL start code size used for unpacketizing.
89 * Valid options are 3 (0, 0, 1) or 4 (0, 0, 0, 1).
90 * Default: 3 (0, 0, 1)
91 */
92 unsigned unpack_nal_start;
93 }
94 pjmedia_h264_packetizer_cfg;
95
96
97 /**
98 * Create H.264 packetizer.
99 *
100 * @param pool The memory pool.
101 * @param cfg Packetizer settings, if NULL, default setting
102 * will be used.
103 * @param p_pktz Pointer to receive the packetizer.
104 *
105 * @return PJ_SUCCESS on success.
106 */
107 PJ_DECL(pj_status_t) pjmedia_h264_packetizer_create(
108 pj_pool_t *pool,
109 const pjmedia_h264_packetizer_cfg *cfg,
110 pjmedia_h264_packetizer **p_pktz);
111
112
113 /**
114 * Generate an RTP payload from a H.264 picture bitstream. Note that this
115 * function will apply in-place processing, so the bitstream may be modified
116 * during the packetization.
117 *
118 * @param pktz The packetizer.
119 * @param bits The picture bitstream to be packetized.
120 * @param bits_len The length of the bitstream.
121 * @param bits_pos The bitstream offset to be packetized.
122 * @param payload The output payload.
123 * @param payload_len The output payload length.
124 *
125 * @return PJ_SUCCESS on success.
126 */
127 PJ_DECL(pj_status_t) pjmedia_h264_packetize(pjmedia_h264_packetizer *pktz,
128 pj_uint8_t *bits,
129 pj_size_t bits_len,
130 unsigned *bits_pos,
131 const pj_uint8_t **payload,
132 pj_size_t *payload_len);
133
134
135 /**
136 * Append an RTP payload to an H.264 picture bitstream. Note that in case of
137 * noticing packet lost, application should keep calling this function with
138 * payload pointer set to NULL, as the packetizer need to update its internal
139 * state.
140 *
141 * @param pktz The packetizer.
142 * @param payload The payload to be unpacketized.
143 * @param payload_len The payload length.
144 * @param bits The bitstream buffer.
145 * @param bits_len The bitstream buffer size.
146 * @param bits_pos The bitstream offset to put the unpacketized payload
147 * in the bitstream, upon return, this will be updated
148 * to the latest offset as a result of the unpacketized
149 * payload.
150 *
151 * @return PJ_SUCCESS on success.
152 */
153 PJ_DECL(pj_status_t) pjmedia_h264_unpacketize(pjmedia_h264_packetizer *pktz,
154 const pj_uint8_t *payload,
155 pj_size_t payload_len,
156 pj_uint8_t *bits,
157 pj_size_t bits_len,
158 unsigned *bits_pos);
159
160
161 PJ_END_DECL
162
163 #endif /* __PJMEDIA_H264_PACKETIZER_H__ */