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 /** Structure listing useful vars to parse RTP packet payload */
45
46 /** mpeg 4 AU headers */
61
64 };
65
71
72 /* All known fmtp parameters and the corresponding RTPAttrTypeEnum */
73 #define ATTR_NAME_TYPE_INT 0
74 #define ATTR_NAME_TYPE_STR 1
88 { NULL, -1, -1 },
89 };
90
92 {
94 }
95
97 {
101 }
102
104 {
105 /* decode the hexa encoded parameter */
113 return 0;
114 }
115
117 {
118 int au_headers_length, au_header_size, i;
120
121 if (len < 2)
123
124 /* decode the first 2 bytes where the AUHeader sections are stored
125 length in bits */
126 au_headers_length =
AV_RB16(buf);
127
129 return -1;
130
132
133 /* skip AU headers length section (2 bytes) */
134 buf += 2;
135 len -= 2;
136
137 if (len < data->au_headers_length_bytes)
139
141
142 /* XXX: Wrong if optional additional sections are present (cts, dts etc...) */
144 if (au_header_size <= 0 || (au_headers_length % au_header_size != 0))
145 return -1;
146
154 }
155
159 }
160
161 return 0;
162 }
163
164
165 /* Follows RFC 3640 */
170 {
172
173 if (!buf) {
185 }
186
188 return -1;
189
192
193 if (len < data->au_headers[0].
size)
201
207 return 1;
208 }
209
210 return 0;
211 }
212
214 char *attr,
char *
value)
215 {
218
219 if (!strcmp(attr, "config")) {
221
222 if (res < 0)
224 }
225
227 /* Looking for a known attribute */
228 for (i = 0; attr_names[i].
str; ++i) {
231 *(int *)((char *)data+
232 attr_names[i].
offset) = atoi(value);
234 *(char **)((char *)data+
236 }
237 }
238 }
239 return 0;
240 }
241
244 {
245 const char *p;
246
247 if (st_index < 0)
248 return 0;
249
252
253 return 0;
254 }
255
258 {
259 if (st_index < 0)
260 return 0;
262 return 0;
263 }
264
271 };
272
281 };