1 /*
2 * Common code for the RTP depacketization of MPEG-4 formats.
3 * Copyright (c) 2010 Fabrice Bellard
4 * Romain Degez
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 /**
24 * @file
25 * @brief MPEG4 / RTP Code
26 * @author Fabrice Bellard
27 * @author Romain Degez
28 */
29
35
36 #define MAX_AAC_HBR_FRAME_SIZE 8191
37
38 /** Structure listing useful vars to parse RTP packet payload */
47
48 /** mpeg 4 AU headers */
63
67 };
68
74
75 /* All known fmtp parameters and the corresponding RTPAttrTypeEnum */
76 #define ATTR_NAME_TYPE_INT 0
77 #define ATTR_NAME_TYPE_STR 1
92 };
93
95 {
98 }
99
101 {
102 /* decode the hexa encoded parameter */
108 return 0;
109 }
110
112 {
113 int au_headers_length, au_header_size, i;
115
116 if (len < 2)
118
119 /* decode the first 2 bytes where the AUHeader sections are stored
120 length in bits */
121 au_headers_length =
AV_RB16(buf);
122
124 return -1;
125
127
128 /* skip AU headers length section (2 bytes) */
129 buf += 2;
130 len -= 2;
131
132 if (len < data->au_headers_length_bytes)
134
136
137 /* XXX: Wrong if optional additional sections are present (cts, dts etc...) */
139 if (au_header_size <= 0 || (au_headers_length % au_header_size != 0))
140 return -1;
141
149 }
150
154 }
155
156 return 0;
157 }
158
159
160 /* Follows RFC 3640 */
165 {
167
168
169 if (!buf) {
173 }
177 }
181 }
186
189 return 0;
190 }
191
192 return 1;
193 }
194
197 return -1;
198 }
199
202 if (data->
nb_au_headers == 1 && len < data->au_headers[0].size) {
203 /* Packet is fragmented */
204
209 }
210
213 }
214
222 }
223
226
229
234 }
235
238 if (ret < 0) {
241 }
243
245
246 return 0;
247 }
248
249 if (len < data->au_headers[0].
size) {
252 }
256 }
261
267 return 1;
268 }
269
270 return 0;
271 }
272
275 const char *attr,
const char *
value)
276 {
278 int res, i;
279
280 if (!strcmp(attr, "config")) {
282
283 if (res < 0)
284 return res;
285 }
286
288 /* Looking for a known attribute */
289 for (i = 0; attr_names[i].
str; ++i) {
292 *(int *)((char *)data+
293 attr_names[i].
offset) = atoi(value);
295 *(char **)((char *)data+
297 }
298 }
299 }
300 return 0;
301 }
302
305 {
306 const char *p;
307
308 if (st_index < 0)
309 return 0;
310
313
314 return 0;
315 }
316
324 };
325
334 };