comparison libdlna-0.2.3/src/av_mpeg4_part2.c @ 129:4f6d9621ee00

add multi session streaming & add depending librarys. - libupnp-1.6.6 - libdlna-0.2.3
author Naoya OYAMA <naoya.oyama@gmail.com>
date Sun, 10 Oct 2010 15:33:18 +0900
parents
children
comparison
equal deleted inserted replaced
128:3a7d8d2f0585 129:4f6d9621ee00
1 /*
2 * libdlna: reference DLNA standards implementation.
3 * Copyright (C) 2007 Benjamin Zores <ben@geexbox.org>
4 *
5 * This file is part of libdlna.
6 *
7 * libdlna is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * libdlna is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with libdlna; if not, write to the Free Software
19 * Foundation, Inc, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <stdlib.h>
23 #include <string.h>
24 #include <unistd.h>
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <fcntl.h>
28
29 #include <ffmpeg/avcodec.h>
30
31 #include "dlna_internals.h"
32 #include "profiles.h"
33 #include "containers.h"
34
35 typedef enum {
36 MPEG4_VCODEC_INVALID,
37 MPEG4_VCODEC_H263,
38 MPEG4_VCODEC_P2,
39 } mpeg4_vcodec_type_t;
40
41 static const struct {
42 int codec_id;
43 mpeg4_vcodec_type_t type;
44 } avf_vcodec_mapping[] = {
45 { CODEC_ID_H263, MPEG4_VCODEC_H263 },
46 { CODEC_ID_H263I, MPEG4_VCODEC_H263 },
47 { CODEC_ID_H263P, MPEG4_VCODEC_H263 },
48 { CODEC_ID_MPEG4, MPEG4_VCODEC_P2 },
49 { CODEC_ID_MSMPEG4V1, MPEG4_VCODEC_P2 },
50 { CODEC_ID_MSMPEG4V2, MPEG4_VCODEC_P2 },
51 { CODEC_ID_MSMPEG4V3, MPEG4_VCODEC_P2 },
52 { -1, 0 }
53 };
54
55 typedef enum {
56 MPEG4_VIDEO_PROFILE_INVALID,
57 MPEG4_VIDEO_PROFILE_H263,
58 MPEG4_VIDEO_PROFILE_P2_SP_L0B,
59 MPEG4_VIDEO_PROFILE_P2_SP_L2,
60 MPEG4_VIDEO_PROFILE_P2_SP_L3,
61 MPEG4_VIDEO_PROFILE_P2_SP_L3_VGA,
62 MPEG4_VIDEO_PROFILE_P2_ASP_L4,
63 MPEG4_VIDEO_PROFILE_P2_ASP_L5
64 } mpeg4_video_profile_t;
65
66 typedef struct video_properties_s {
67 int width;
68 int height;
69 int fps_num;
70 int fps_den;
71 } video_properties_t;
72
73 /* H263 Resolutions (all <= 15 fps) */
74 static video_properties_t profile_h263_res[] = {
75 { 176, 144, 15, 1 }, /* QCIF */
76 { 128, 96, 15, 1 } /* SQCIF */
77 };
78
79 /* MPEG-4 SP L0B Resolutions (all <= 15 fps) */
80 static video_properties_t profile_p2_sp_l0b_res[] = {
81 { 176, 144, 15, 1 }, /* QCIF */
82 { 128, 96, 15, 1 } /* SQCIF */
83 };
84
85 /* MPEG-4 SP L2 Resolutions */
86 static video_properties_t profile_p2_sp_l2_res[] = {
87 { 352, 288, 15, 1 }, /* CIF */
88 { 320, 240, 15, 1 }, /* QVGA 4:3 */
89 { 320, 180, 15, 1 }, /* QVGA 16:9 */
90 { 176, 144, 30, 1 }, /* QCIF */
91 { 128, 96, 30, 1 } /* SQCIF */
92 };
93
94 /* MPEG-4 SP L3_VGA Resolutions */
95 static video_properties_t profile_p2_sp_l3_vga_res[] = {
96 { 640, 480, 30, 1 }, /* VGA */
97 { 640, 360, 30, 1 } /* VGA 16:9 */
98 };
99
100 /* MPEG-4 L3 / CO Resolutions (all <= 30 fps) */
101 static video_properties_t profile_p2_sp_l3_co_res[] = {
102 { 352, 288, 30, 1 }, /* CIF, 625SIF */
103 { 352, 240, 30, 1 }, /* 525SIF */
104 { 320, 240, 30, 1 }, /* QVGA 4:3 */
105 { 320, 180, 30, 1 }, /* QVGA 16:9 */
106 { 240, 180, 30, 1 }, /* 1/7 VGA 4:3 */
107 { 208, 160, 30, 1 }, /* 1/9 VGA 4:3 */
108 { 176, 144, 30, 1 }, /* QCIF,625QCIF */
109 { 176, 120, 30, 1 }, /* 525QCIF */
110 { 160, 120, 30, 1 }, /* SQVGA 4:3 */
111 { 160, 112, 30, 1 }, /* 1/16 VGA 4:3 */
112 { 160, 90, 30, 1 }, /* SQVGA 16:9 */
113 { 128, 96, 30, 1 } /* SQCIF */
114 };
115
116 /* MPEG-4 ASP L4 SO Resolutions (all <= 30 fps) */
117 static video_properties_t profile_p2_asp_l4_res[] = {
118 { 352, 576, 30, 1 }, /* 625 1/2 D1 */
119 { 352, 480, 30, 1 }, /* 525 1/2 D1 */
120 { 352, 288, 30, 1 }, /* CIF, 625SIF */
121 { 352, 240, 30, 1 }, /* 525SIF */
122 { 320, 240, 30, 1 }, /* QVGA 4:3 */
123 { 320, 180, 30, 1 }, /* QVGA 16:9 */
124 { 240, 180, 30, 1 }, /* 1/7 VGA 4:3 */
125 { 208, 160, 30, 1 }, /* 1/9 VGA 4:3 */
126 { 176, 144, 30, 1 }, /* QCIF,625QCIF */
127 { 176, 120, 30, 1 }, /* 525QCIF */
128 { 160, 120, 30, 1 }, /* SQVGA 4:3 */
129 { 160, 112, 30, 1 }, /* 1/16 VGA 4:3 */
130 { 160, 90, 30, 1 }, /* SQVGA 16:9 */
131 { 128, 96, 30, 1 } /* SQCIF */
132 };
133
134 /* MPEG-4 ASP L5 Resolutions (all <= 30 fps) */
135 static video_properties_t profile_p2_asp_l5_res[] = {
136 { 720, 576, 30, 1 }, /* 625 D1 */
137 { 720, 480, 30, 1 }, /* 525 D1 */
138 { 704, 576, 30, 1 }, /* 625 4SIF */
139 { 704, 480, 30, 1 }, /* 525 4SIF */
140 { 640, 480, 30, 1 }, /* VGA */
141 { 640, 360, 30, 1 }, /* VGA 16:9 */
142 { 544, 576, 30, 1 }, /* 625 3/4 D1 */
143 { 544, 480, 30, 1 }, /* 525 3/4 D1 */
144 { 480, 576, 30, 1 }, /* 625 2/3 D1 */
145 { 480, 480, 30, 1 }, /* 525 2/3 D1 */
146 { 480, 360, 30, 1 }, /* 9/16 VGA 4:3 */
147 { 480, 270, 30, 1 }, /* 9/16 VGA 16:9 */
148 { 352, 576, 30, 1 }, /* 625 1/2 D1 */
149 { 352, 480, 30, 1 }, /* 525 1/2 D1 */
150 { 352, 288, 30, 1 }, /* CIF, 625SIF */
151 { 352, 240, 30, 1 }, /* 525SIF */
152 { 320, 240, 30, 1 }, /* QVGA 4:3 */
153 { 320, 180, 30, 1 }, /* QVGA 16:9 */
154 { 240, 180, 30, 1 }, /* 1/7 VGA 4:3 */
155 { 208, 160, 30, 1 }, /* 1/9 VGA 4:3 */
156 { 176, 144, 30, 1 }, /* QCIF,625QCIF */
157 { 176, 120, 30, 1 }, /* 525QCIF */
158 { 160, 120, 30, 1 }, /* SQVGA 4:3 */
159 { 160, 112, 30, 1 }, /* 1/16 VGA 4:3 */
160 { 160, 90, 30, 1 }, /* SQVGA 16:9 */
161 { 128, 96, 30, 1 } /* SQCIF */
162 };
163
164 /********************/
165 /* MPEG-4 Container */
166 /********************/
167
168 /* Profile for MPEG-4 Part 2 Simple Profile with AAC LC audio,
169 encapsulated in MP4 */
170 static dlna_profile_t mpeg4_p2_mp4_sp_aac = {
171 .id = "MPEG4_P2_MP4_SP_AAC",
172 .mime = MIME_VIDEO_MPEG_4,
173 .label = LABEL_VIDEO_CIF30
174 };
175
176 /* Profile for MPEG-4 Part 2 Simple Profile with HE AAC audio,
177 encapsulated in MP4 */
178 static dlna_profile_t mpeg4_p2_mp4_sp_heaac = {
179 .id = "MPEG4_P2_MP4_SP_HEAAC",
180 .mime = MIME_VIDEO_MPEG_4,
181 .label = LABEL_VIDEO_CIF30
182 };
183
184 /* Profile for MPEG-4 Part 2 Simple Profile with ATRAC3plus audio,
185 encapsulated in MP4 */
186 static dlna_profile_t mpeg4_p2_mp4_sp_atrac3plus = {
187 .id = "MPEG4_P2_MP4_SP_ATRAC3plus",
188 .mime = MIME_VIDEO_MPEG_4,
189 .label = LABEL_VIDEO_CIF30
190 };
191
192 /* Profile for MPEG-4 Part 2 Simple Profile with AAC LTP audio,
193 encapsulated in MP4 */
194 static dlna_profile_t mpeg4_p2_mp4_sp_aac_ltp = {
195 .id = "MPEG4_P2_MP4_SP_AAC_LTP",
196 .mime = MIME_VIDEO_MPEG_4,
197 .label = LABEL_VIDEO_CIF30
198 };
199
200 /* Profile for MPEG-4 Part 2 Simple Profile Level 2 with AAC audio,
201 encapsulated in MP4 */
202 static dlna_profile_t mpeg4_p2_mp4_sp_l2_aac = {
203 .id = "MPEG4_P2_MP4_SP_L2_AAC",
204 .mime = MIME_VIDEO_MPEG_4,
205 .label = LABEL_VIDEO_CIF15
206 };
207
208 /* Profile for MPEG-4 Part 2 Simple Profile Level 2 with AMR audio,
209 encapsulated in MP4 */
210 static dlna_profile_t mpeg4_p2_mp4_sp_l2_amr = {
211 .id = "MPEG4_P2_MP4_SP_L2_AMR",
212 .mime = MIME_VIDEO_MPEG_4,
213 .label = LABEL_VIDEO_CIF15
214 };
215
216 /* Profile for MPEG-4 Part 2 Simple Profile Level 3+ with AAC audio,
217 encapsulated in MP4 */
218 static dlna_profile_t mpeg4_p2_mp4_sp_vga_aac = {
219 .id = "MPEG4_P2_MP4_SP_VGA_AAC",
220 .mime = MIME_VIDEO_MPEG_4,
221 .label = LABEL_VIDEO_SD
222 };
223
224 /* Profile for MPEG-4 Part 2 Simple Profile Level 3+ with HEAAC audio,
225 encapsulated in MP4 */
226 static dlna_profile_t mpeg4_p2_mp4_sp_vga_heaac = {
227 .id = "MPEG4_P2_MP4_SP_VGA_HEAAC",
228 .mime = MIME_VIDEO_MPEG_4,
229 .label = LABEL_VIDEO_SD
230 };
231
232 /* Profile for MPEG-4 Part 2 Advanced Simple Profile with AAC LC audio,
233 encapsulated in MP4 */
234 static dlna_profile_t mpeg4_p2_mp4_asp_aac = {
235 .id = "MPEG4_P2_MP4_ASP_AAC",
236 .mime = MIME_VIDEO_MPEG_4,
237 .label = LABEL_VIDEO_SD
238 };
239
240 /* Profile for MPEG-4 Part 2 Advanced Simple Profile with HEAAC audio,
241 encapsulated in MP4 */
242 static dlna_profile_t mpeg4_p2_mp4_asp_heaac = {
243 .id = "MPEG4_P2_MP4_ASP_HEAAC",
244 .mime = MIME_VIDEO_MPEG_4,
245 .label = LABEL_VIDEO_SD
246 };
247
248 /* Profile for MPEG-4 Part 2 Advanced Simple Profile with HEAAC
249 multi-channel audio, encapsulated in MP4 */
250 static dlna_profile_t mpeg4_p2_mp4_asp_heaac_mult5 = {
251 .id = "MPEG4_P2_MP4_ASP_HEAAC_MULT5",
252 .mime = MIME_VIDEO_MPEG_4,
253 .label = LABEL_VIDEO_SD
254 };
255
256 /* Profile for MPEG-4 Part 2 Advanced Simple Profile with ATRAC3plus audio,
257 encapsulated in MP4 */
258 static dlna_profile_t mpeg4_p2_mp4_asp_actrac3plus = {
259 .id = "MPEG4_P2_MP4_ASP_ATRAC3plus",
260 .mime = MIME_VIDEO_MPEG_4,
261 .label = LABEL_VIDEO_SD
262 };
263
264 /* Profile for MPEG-4 Part 2 Advanced Simple Profile up to Level 5
265 with only Simple Object with AAC LC audio, encapsulated in MP4 */
266 static dlna_profile_t mpeg4_p2_mp4_asp_l5_so_aac = {
267 .id = "MPEG4_P2_MP4_ASP_L5_SO_AAC",
268 .mime = MIME_VIDEO_MPEG_4,
269 .label = LABEL_VIDEO_SD
270 };
271
272 /* Profile for MPEG-4 Part 2 Advanced Simple Profile up to Level 5
273 with only Simple Object with HEAAC audio, encapsulated in MP4 */
274 static dlna_profile_t mpeg4_p2_mp4_asp_l5_so_heaac = {
275 .id = "MPEG4_P2_MP4_ASP_L5_SO_HEAAC",
276 .mime = MIME_VIDEO_MPEG_4,
277 .label = LABEL_VIDEO_SD
278 };
279
280 /* Profile for MPEG-4 Part 2 Advanced Simple Profile up to Level 5
281 with only Simple Object with HEAAC multichannel audio,
282 encapsulated in MP4 */
283 static dlna_profile_t mpeg4_p2_mp4_asp_l5_so_heaac_mult5 = {
284 .id = "MPEG4_P2_MP4_ASP_L5_SO_HEAAC_MULT5",
285 .mime = MIME_VIDEO_MPEG_4,
286 .label = LABEL_VIDEO_SD
287 };
288
289 /* Profile for MPEG-4 Part 2 Advanced Simple Profile up to Level 4
290 with only Simple Object with AAC LC audio, encapsulated in MP4 */
291 static dlna_profile_t mpeg4_p2_mp4_asp_l4_so_aac = {
292 .id = "MPEG4_P2_MP4_ASP_L4_SO_AAC",
293 .mime = MIME_VIDEO_MPEG_4,
294 .label = LABEL_VIDEO_CIF30
295 };
296
297 /* Profile for MPEG-4 Part 2 Advanced Simple Profile up to Level 4
298 with only Simple Object with HEAAC audio, encapsulated in MP4 */
299 static dlna_profile_t mpeg4_p2_mp4_asp_l4_so_heaac = {
300 .id = "MPEG4_P2_MP4_ASP_L4_SO_HEAAC",
301 .mime = MIME_VIDEO_MPEG_4,
302 .label = LABEL_VIDEO_CIF30
303 };
304
305 /* Profile for MPEG-4 Part 2 Advanced Simple Profile up to Level 4
306 with only Simple Object with HEAAC multichannel audio,
307 encapsulated in MP4 */
308 static dlna_profile_t mpeg4_p2_mp4_asp_l4_so_heaac_mult5 = {
309 .id = "MPEG4_P2_MP4_ASP_L4_SO_HEAAC_MULT5",
310 .mime = MIME_VIDEO_MPEG_4,
311 .label = LABEL_VIDEO_CIF30
312 };
313
314 /* Profile for H263 Profile 0 Level 10 with AAC LC audio,
315 encapsulated in MP4 */
316 static dlna_profile_t mpeg4_h263_mp4_p0_l10_aac = {
317 .id = "MPEG4_H263_MP4_P0_L10_AAC",
318 .mime = MIME_VIDEO_3GP,
319 .label = LABEL_VIDEO_QCIF15
320 };
321
322 /* Profile for H263 Profile 0 Level 10 with AAC LTP audio,
323 encapsulated in MP4 */
324 static dlna_profile_t mpeg4_h263_mp4_p0_l10_aac_ltp = {
325 .id = "MPEG4_H263_MP4_P0_L10_AAC_LTP",
326 .mime = MIME_VIDEO_3GP,
327 .label = LABEL_VIDEO_QCIF15
328 };
329
330 /*********************/
331 /* MPEG-TS Container */
332 /*********************/
333
334 /* Profile for MPEG-4 Part 2 Simple Profile with AAC LC audio,
335 encapsulated in MPEG2-TS with a zero timestamp field */
336 static dlna_profile_t mpeg4_p2_ts_sp_aac = {
337 .id = "MPEG4_P2_TS_SP_AAC",
338 .mime = MIME_VIDEO_MPEG_TS,
339 .label = LABEL_VIDEO_CIF30
340 };
341
342 /* Profile for MPEG-4 Part 2 Simple Profile with AAC LC audio,
343 encapsulated in MPEG2-TS with a valid timestamp field */
344 static dlna_profile_t mpeg4_p2_ts_sp_aac_t = {
345 .id = "MPEG4_P2_TS_SP_AAC_T",
346 .mime = MIME_VIDEO_MPEG_TS,
347 .label = LABEL_VIDEO_CIF30
348 };
349
350 /* Profile for MPEG-4 Part 2 Simple Profile with AAC LC audio,
351 encapsulated in MPEG2-TS without a timestamp field */
352 static dlna_profile_t mpeg4_p2_ts_sp_aac_iso = {
353 .id = "MPEG4_P2_TS_SP_AAC_ISO",
354 .mime = MIME_VIDEO_MPEG,
355 .label = LABEL_VIDEO_CIF30
356 };
357
358 /* Profile for MPEG-4 Part 2 Simple Profile with MPEG-1 Layer3 audio,
359 encapsulated in MPEG2-TS with a zero timestamp field */
360 static dlna_profile_t mpeg4_p2_ts_sp_mpeg1_l3 = {
361 .id = "MPEG4_P2_TS_SP_MPEG1_L3",
362 .mime = MIME_VIDEO_MPEG_TS,
363 .label = LABEL_VIDEO_CIF30
364 };
365
366 /* Profile for MPEG-4 Part 2 Simple Profile with MPEG-1 Layer3 audio,
367 encapsulated in MPEG2-TS with a valid timestamp field */
368 static dlna_profile_t mpeg4_p2_ts_sp_mpeg1_l3_t = {
369 .id = "MPEG4_P2_TS_SP_MPEG1_L3_T",
370 .mime = MIME_VIDEO_MPEG_TS,
371 .label = LABEL_VIDEO_CIF30
372 };
373
374 /* Profile for MPEG-4 Part 2 Simple Profile with MPEG-1 Layer3 audio,
375 encapsulated in MPEG2-TS without a timestamp field */
376 static dlna_profile_t mpeg4_p2_ts_sp_mpeg1_l3_iso = {
377 .id = "MPEG4_P2_TS_SP_MPEG1_L3_ISO",
378 .mime = MIME_VIDEO_MPEG,
379 .label = LABEL_VIDEO_CIF30
380 };
381
382 /* Profile for MPEG-4 Part 2 Simple Profile with AC3 multichannel audio,
383 encapsulated in MPEG2-TS with a zero timestamp field */
384 static dlna_profile_t mpeg4_p2_ts_sp_ac3 = {
385 .id = "MPEG4_P2_TS_SP_AC3_L3",
386 .mime = MIME_VIDEO_MPEG_TS,
387 .label = LABEL_VIDEO_CIF30
388 };
389
390 /* Profile for MPEG-4 Part 2 Simple Profile with AC3 multichannel audio,
391 encapsulated in MPEG2-TS with a valid timestamp field */
392 static dlna_profile_t mpeg4_p2_ts_sp_ac3_t = {
393 .id = "MPEG4_P2_TS_SP_AC3_T",
394 .mime = MIME_VIDEO_MPEG_TS,
395 .label = LABEL_VIDEO_CIF30
396 };
397
398 /* Profile for MPEG-4 Part 2 Simple Profile with AC3 multichannel audio,
399 encapsulated in MPEG2-TS without a timestamp field */
400 static dlna_profile_t mpeg4_p2_ts_sp_ac3_iso = {
401 .id = "MPEG4_P2_TS_SP_AC3_ISO",
402 .mime = MIME_VIDEO_MPEG,
403 .label = LABEL_VIDEO_CIF30
404 };
405
406 /* Profile for MPEG-4 Part 2 Simple Profile with MPEG-1/2 Layer 1/2
407 multichannel audio, encapsulated in MPEG2-TS with a zero timestamp field */
408 static dlna_profile_t mpeg4_p2_ts_sp_mpeg2_l2 = {
409 .id = "MPEG4_P2_TS_SP_MPEG2_L2",
410 .mime = MIME_VIDEO_MPEG_TS,
411 .label = LABEL_VIDEO_CIF30
412 };
413
414 /* Profile for MPEG-4 Part 2 Simple Profile with MPEG-1/2 Layer1/2
415 multichannel audio,
416 encapsulated in MPEG2-TS with a valid timestamp field */
417 static dlna_profile_t mpeg4_p2_ts_sp_mpeg2_l2_t = {
418 .id = "MPEG4_P2_TS_SP_MPEG2_L2_T",
419 .mime = MIME_VIDEO_MPEG_TS,
420 .label = LABEL_VIDEO_CIF30
421 };
422
423 /* Profile for MPEG-4 Part 2 Simple Profile with MPEG-1/2 Layer1/2
424 multichannel audio,
425 encapsulated in MPEG2-TS without a timestamp field */
426 static dlna_profile_t mpeg4_p2_ts_sp_mpeg2_l2_iso = {
427 .id = "MPEG4_P2_TS_SP_MPEG2_L2_ISO",
428 .mime = MIME_VIDEO_MPEG,
429 .label = LABEL_VIDEO_CIF30
430 };
431
432 /* Profile for MPEG-4 Part 2 Advanced Simple Profile with AAC LC audio,
433 encapsulated in MPEG2-TS with a zero timestamp field */
434 static dlna_profile_t mpeg4_p2_ts_asp_aac = {
435 .id = "MPEG4_P2_TS_ASP_AAC",
436 .mime = MIME_VIDEO_MPEG_TS,
437 .label = LABEL_VIDEO_SD
438 };
439
440 /* Profile for MPEG-4 Part 2 Advanced Simple Profile with AAC LC audio,
441 encapsulated in MPEG2-TS with a valid timestamp field */
442 static dlna_profile_t mpeg4_p2_ts_asp_aac_t = {
443 .id = "MPEG4_P2_TS_ASP_AAC_T",
444 .mime = MIME_VIDEO_MPEG_TS,
445 .label = LABEL_VIDEO_CIF30
446 };
447
448 /* Profile for MPEG-4 Part 2 Advanced Simple Profile with AAC LC audio,
449 encapsulated in MPEG2-TS without a timestamp field */
450 static dlna_profile_t mpeg4_p2_ts_asp_aac_iso = {
451 .id = "MPEG4_P2_TS_ASP_AAC_ISO",
452 .mime = MIME_VIDEO_MPEG,
453 .label = LABEL_VIDEO_SD
454 };
455
456 /* Profile for MPEG-4 Part 2 Advanced Simple Profile with MPEG-1 Layer3 audio,
457 encapsulated in MPEG2-TS with a zero timestamp field */
458 static dlna_profile_t mpeg4_p2_ts_asp_mpeg1_l3 = {
459 .id = "MPEG4_P2_TS_ASP_MPEG1_L3",
460 .mime = MIME_VIDEO_MPEG_TS,
461 .label = LABEL_VIDEO_SD
462 };
463
464 /* Profile for MPEG-4 Part 2 Advanced Simple Profile with MPEG-1 Layer3 audio,
465 encapsulated in MPEG2-TS with a valid timestamp field */
466 static dlna_profile_t mpeg4_p2_ts_asp_mpeg1_l3_t = {
467 .id = "MPEG4_P2_TS_ASP_MPEG1_L3_T",
468 .mime = MIME_VIDEO_MPEG_TS,
469 .label = LABEL_VIDEO_SD
470 };
471
472 /* Profile for MPEG-4 Part 2 Advanced Simple Profile with MPEG-1 Layer3 audio,
473 encapsulated in MPEG2-TS without a timestamp field */
474 static dlna_profile_t mpeg4_p2_ts_asp_mpeg1_l3_iso = {
475 .id = "MPEG4_P2_TS_ASP_MPEG1_L3_ISO",
476 .mime = MIME_VIDEO_MPEG,
477 .label = LABEL_VIDEO_SD
478 };
479
480 /* Profile for MPEG-4 Part 2 Advanced Simple Profile with AC3
481 multichannel audio,
482 encapsulated in MPEG2-TS with a zero timestamp field */
483 static dlna_profile_t mpeg4_p2_ts_asp_ac3 = {
484 .id = "MPEG4_P2_TS_ASP_AC3_L3",
485 .mime = MIME_VIDEO_MPEG_TS,
486 .label = LABEL_VIDEO_SD
487 };
488
489 /* Profile for MPEG-4 Part 2 Advanced Simple Profile with AC3
490 multichannel audio,
491 encapsulated in MPEG2-TS with a valid timestamp field */
492 static dlna_profile_t mpeg4_p2_ts_asp_ac3_t = {
493 .id = "MPEG4_P2_TS_ASP_AC3_T",
494 .mime = MIME_VIDEO_MPEG_TS,
495 .label = LABEL_VIDEO_SD
496 };
497
498 /* Profile for MPEG-4 Part 2 Advanced Simple Profile with AC3
499 multichannel audio,
500 encapsulated in MPEG2-TS without a timestamp field */
501 static dlna_profile_t mpeg4_p2_ts_asp_ac3_iso = {
502 .id = "MPEG4_P2_TS_ASP_AC3_ISO",
503 .mime = MIME_VIDEO_MPEG,
504 .label = LABEL_VIDEO_SD
505 };
506
507 /* Profile for MPEG-4 Part 2 Core Profile with AC3 multichannel audio,
508 encapsulated in MPEG2-TS with a zero timestamp field */
509 static dlna_profile_t mpeg4_p2_ts_co_ac3 = {
510 .id = "MPEG4_P2_TS_CO_AC3",
511 .mime = MIME_VIDEO_MPEG_TS,
512 .label = LABEL_VIDEO_CIF30
513 };
514
515 /* Profile for MPEG-4 Part 2 Core Profile with AC3 multichannel audio,
516 encapsulated in MPEG2-TS with a valid timestamp field */
517 static dlna_profile_t mpeg4_p2_ts_co_ac3_t = {
518 .id = "MPEG4_P2_TS_CO_AC3_T",
519 .mime = MIME_VIDEO_MPEG_TS,
520 .label = LABEL_VIDEO_CIF30
521 };
522
523 /* Profile for MPEG-4 Part 2 Core Profile with AC3 multichannel audio,
524 encapsulated in MPEG2-TS without a timestamp field */
525 static dlna_profile_t mpeg4_p2_ts_co_ac3_iso = {
526 .id = "MPEG4_P2_TS_CO_AC3_ISO",
527 .mime = MIME_VIDEO_MPEG,
528 .label = LABEL_VIDEO_CIF30
529 };
530
531 /* Profile for MPEG-4 Part 2 Core Profile with MPEG-1/2 Layer1/2 audio,
532 encapsulated in MPEG2-TS with a zero timestamp field */
533 static dlna_profile_t mpeg4_p2_ts_co_mpeg2_l2 = {
534 .id = "MPEG4_P2_TS_CO_MPEG2_L2",
535 .mime = MIME_VIDEO_MPEG_TS,
536 .label = LABEL_VIDEO_CIF30
537 };
538
539 /* Profile for MPEG-4 Part 2 Core Profile with MPEG-1/2 Layer1/2 audio,
540 encapsulated in MPEG2-TS with a valid timestamp field */
541 static dlna_profile_t mpeg4_p2_ts_co_mpeg2_l2_t = {
542 .id = "MPEG4_P2_TS_CO_MPEG2_L2_T",
543 .mime = MIME_VIDEO_MPEG_TS,
544 .label = LABEL_VIDEO_CIF30
545 };
546
547 /* Profile for MPEG-4 Part 2 Core Profile with MPEG-1/2 Layer1/2 audio,
548 encapsulated in MPEG2-TS without a timestamp field */
549 static dlna_profile_t mpeg4_p2_ts_co_mpeg2_l2_iso = {
550 .id = "MPEG4_P2_TS_CO_MPEG2_L2_ISO",
551 .mime = MIME_VIDEO_MPEG,
552 .label = LABEL_VIDEO_CIF30
553 };
554
555 /*****************/
556 /* ASF Container */
557 /*****************/
558
559 /* Profile for MPEG-4 Part 2 Simple Profile with G.726 audio,
560 encapsulated in ASF */
561 static dlna_profile_t mpeg4_p2_asf_sp_g726 = {
562 .id = "MPEG4_P2_ASF_SP_G726",
563 .mime = MIME_VIDEO_ASF,
564 .label = LABEL_VIDEO_CIF30
565 };
566
567 /* Profile for MPEG-4 Part 2 Advanced Simple Profile up to Level 5
568 with only Simple Object with G.726 audio, encapsulated in ASF */
569 static dlna_profile_t mpeg4_p2_asf_asp_l5_so_g726 = {
570 .id = "MPEG4_P2_ASF_ASP_L5_SO_G726",
571 .mime = MIME_VIDEO_ASF,
572 .label = LABEL_VIDEO_SD
573 };
574
575 /* Profile for MPEG-4 Part 2 Advanced Simple Profile up to Level 4
576 with only Simple Object with G.726 audio, encapsulated in ASF */
577 static dlna_profile_t mpeg4_p2_asf_asp_l4_so_g726 = {
578 .id = "MPEG4_P2_ASF_ASP_L4_SO_G726",
579 .mime = MIME_VIDEO_ASF,
580 .label = LABEL_VIDEO_CIF30
581 };
582
583 /******************/
584 /* 3GPP Container */
585 /******************/
586
587 /* Profile for H.263 Profile 0 Level 10 with AMR-WB+ audio,
588 encapsulated in 3GPP */
589 static dlna_profile_t mpeg4_h263_3gpp_p0_l10_amr_wbplus = {
590 .id = "MPEG4_H263_3GPP_P0_L10_AMR_WBplus",
591 .mime = MIME_VIDEO_3GP,
592 .label = LABEL_VIDEO_QCIF15
593 };
594
595 /* Profile for MPEG-4 Part 2 Simple Profile Level 0b with AAC audio,
596 encapsulated in 3GPP */
597 static dlna_profile_t mpeg4_p2_3gpp_sp_l0b_aac = {
598 .id = "MPEG4_P2_3GPP_SP_L0B_AAC",
599 .mime = MIME_VIDEO_3GP,
600 .label = LABEL_VIDEO_QCIF15
601 };
602
603 /* Profile for MPEG-4 Part 2 Simple Profile Level 0b with AMR audio,
604 encapsulated in 3GPP */
605 static dlna_profile_t mpeg4_p2_3gpp_sp_l0b_amr = {
606 .id = "MPEG4_P2_3GPP_SP_L0B_AMR",
607 .mime = MIME_VIDEO_3GP,
608 .label = LABEL_VIDEO_QCIF15
609 };
610
611 /* Profile for MPEG-4 H.263 Profile 3 Level 10 with AMR audio,
612 encapsulated in 3GPP */
613 static dlna_profile_t mpeg4_h263_3gpp_p3_l10_amr = {
614 .id = "MPEG4_H263_3GPP_P3_L10_AMR",
615 .mime = MIME_VIDEO_3GP,
616 .label = LABEL_VIDEO_QCIF15
617 };
618
619 static const struct {
620 dlna_profile_t *profile;
621 dlna_container_type_t st;
622 mpeg4_video_profile_t vp;
623 audio_profile_t ap;
624 } mpeg4_profiles_mapping[] = {
625 /* MPEG-4 Container */
626 { &mpeg4_p2_mp4_sp_aac, CT_MP4,
627 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_AAC },
628 { &mpeg4_p2_mp4_sp_heaac, CT_MP4,
629 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_AAC_HE_L2 },
630 { &mpeg4_p2_mp4_sp_atrac3plus, CT_MP4,
631 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_ATRAC },
632 { &mpeg4_p2_mp4_sp_aac_ltp, CT_MP4,
633 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_AAC_LTP },
634
635 { &mpeg4_p2_mp4_sp_l2_aac, CT_MP4,
636 MPEG4_VIDEO_PROFILE_P2_SP_L2, AUDIO_PROFILE_AAC },
637 { &mpeg4_p2_mp4_sp_l2_amr, CT_MP4,
638 MPEG4_VIDEO_PROFILE_P2_SP_L2, AUDIO_PROFILE_AMR },
639
640 { &mpeg4_p2_mp4_sp_vga_aac, CT_MP4,
641 MPEG4_VIDEO_PROFILE_P2_SP_L3_VGA, AUDIO_PROFILE_AAC },
642 { &mpeg4_p2_mp4_sp_vga_heaac, CT_MP4,
643 MPEG4_VIDEO_PROFILE_P2_SP_L3_VGA, AUDIO_PROFILE_AAC_HE_L2 },
644
645 { &mpeg4_p2_mp4_asp_aac, CT_MP4,
646 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_AAC },
647 { &mpeg4_p2_mp4_asp_heaac, CT_MP4,
648 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_AAC_HE_L2 },
649 { &mpeg4_p2_mp4_asp_heaac_mult5, CT_MP4,
650 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_AAC_HE_MULT5 },
651 { &mpeg4_p2_mp4_asp_actrac3plus, CT_MP4,
652 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_ATRAC },
653
654 { &mpeg4_p2_mp4_asp_l5_so_aac, CT_MP4,
655 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_AAC },
656 { &mpeg4_p2_mp4_asp_l5_so_heaac, CT_MP4,
657 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_AAC_HE_L2 },
658 { &mpeg4_p2_mp4_asp_l5_so_heaac_mult5, CT_MP4,
659 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_AAC_HE_MULT5 },
660
661 { &mpeg4_p2_mp4_asp_l4_so_aac, CT_MP4,
662 MPEG4_VIDEO_PROFILE_P2_ASP_L4, AUDIO_PROFILE_AAC },
663 { &mpeg4_p2_mp4_asp_l4_so_heaac, CT_MP4,
664 MPEG4_VIDEO_PROFILE_P2_ASP_L4, AUDIO_PROFILE_AAC_HE_L2 },
665 { &mpeg4_p2_mp4_asp_l4_so_heaac_mult5, CT_MP4,
666 MPEG4_VIDEO_PROFILE_P2_ASP_L4, AUDIO_PROFILE_AAC_HE_MULT5 },
667
668 { &mpeg4_h263_mp4_p0_l10_aac, CT_MP4,
669 MPEG4_VIDEO_PROFILE_H263, AUDIO_PROFILE_AAC },
670 { &mpeg4_h263_mp4_p0_l10_aac_ltp, CT_MP4,
671 MPEG4_VIDEO_PROFILE_H263, AUDIO_PROFILE_AAC_LTP },
672
673 /* MPEG-TS Container */
674 { &mpeg4_p2_ts_sp_aac, CT_MPEG_TRANSPORT_STREAM_DLNA_NO_TS,
675 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_AAC },
676 { &mpeg4_p2_ts_sp_aac_t, CT_MPEG_TRANSPORT_STREAM_DLNA,
677 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_AAC },
678 { &mpeg4_p2_ts_sp_aac_iso, CT_MPEG_TRANSPORT_STREAM,
679 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_AAC },
680
681 { &mpeg4_p2_ts_sp_mpeg1_l3, CT_MPEG_TRANSPORT_STREAM_DLNA_NO_TS,
682 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_MP3 },
683 { &mpeg4_p2_ts_sp_mpeg1_l3_t, CT_MPEG_TRANSPORT_STREAM_DLNA,
684 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_MP3 },
685 { &mpeg4_p2_ts_sp_mpeg1_l3_iso, CT_MPEG_TRANSPORT_STREAM,
686 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_MP3 },
687
688 { &mpeg4_p2_ts_sp_ac3, CT_MPEG_TRANSPORT_STREAM_DLNA_NO_TS,
689 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_AC3 },
690 { &mpeg4_p2_ts_sp_ac3_t, CT_MPEG_TRANSPORT_STREAM_DLNA,
691 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_AC3 },
692 { &mpeg4_p2_ts_sp_ac3_iso, CT_MPEG_TRANSPORT_STREAM,
693 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_AC3 },
694
695 { &mpeg4_p2_ts_sp_mpeg2_l2, CT_MPEG_TRANSPORT_STREAM_DLNA_NO_TS,
696 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_MP2 },
697 { &mpeg4_p2_ts_sp_mpeg2_l2_t, CT_MPEG_TRANSPORT_STREAM_DLNA,
698 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_MP2 },
699 { &mpeg4_p2_ts_sp_mpeg2_l2_iso, CT_MPEG_TRANSPORT_STREAM,
700 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_MP2 },
701
702 { &mpeg4_p2_ts_asp_aac, CT_MPEG_TRANSPORT_STREAM_DLNA_NO_TS,
703 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_AAC },
704 { &mpeg4_p2_ts_asp_aac_t, CT_MPEG_TRANSPORT_STREAM_DLNA,
705 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_AAC },
706 { &mpeg4_p2_ts_asp_aac_iso, CT_MPEG_TRANSPORT_STREAM,
707 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_AAC },
708
709 { &mpeg4_p2_ts_asp_mpeg1_l3, CT_MPEG_TRANSPORT_STREAM_DLNA_NO_TS,
710 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_MP3 },
711 { &mpeg4_p2_ts_asp_mpeg1_l3_t, CT_MPEG_TRANSPORT_STREAM_DLNA,
712 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_MP3 },
713 { &mpeg4_p2_ts_asp_mpeg1_l3_iso, CT_MPEG_TRANSPORT_STREAM,
714 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_MP3 },
715
716 { &mpeg4_p2_ts_asp_ac3, CT_MPEG_TRANSPORT_STREAM_DLNA_NO_TS,
717 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_AC3 },
718 { &mpeg4_p2_ts_asp_ac3_t, CT_MPEG_TRANSPORT_STREAM_DLNA,
719 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_AC3 },
720 { &mpeg4_p2_ts_asp_ac3_iso, CT_MPEG_TRANSPORT_STREAM,
721 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_AC3 },
722
723 { &mpeg4_p2_ts_co_ac3, CT_MPEG_TRANSPORT_STREAM_DLNA_NO_TS,
724 MPEG4_VIDEO_PROFILE_P2_ASP_L4, AUDIO_PROFILE_AC3 },
725 { &mpeg4_p2_ts_co_ac3_t, CT_MPEG_TRANSPORT_STREAM_DLNA,
726 MPEG4_VIDEO_PROFILE_P2_ASP_L4, AUDIO_PROFILE_AC3 },
727 { &mpeg4_p2_ts_co_ac3_iso, CT_MPEG_TRANSPORT_STREAM,
728 MPEG4_VIDEO_PROFILE_P2_ASP_L4, AUDIO_PROFILE_AC3 },
729
730 { &mpeg4_p2_ts_co_mpeg2_l2, CT_MPEG_TRANSPORT_STREAM_DLNA_NO_TS,
731 MPEG4_VIDEO_PROFILE_P2_ASP_L4, AUDIO_PROFILE_MP2 },
732 { &mpeg4_p2_ts_co_mpeg2_l2_t, CT_MPEG_TRANSPORT_STREAM_DLNA,
733 MPEG4_VIDEO_PROFILE_P2_ASP_L4, AUDIO_PROFILE_MP2 },
734 { &mpeg4_p2_ts_co_mpeg2_l2_iso, CT_MPEG_TRANSPORT_STREAM,
735 MPEG4_VIDEO_PROFILE_P2_ASP_L4, AUDIO_PROFILE_MP2 },
736
737 /* ASF Container */
738 { &mpeg4_p2_asf_sp_g726, CT_ASF,
739 MPEG4_VIDEO_PROFILE_P2_SP_L3, AUDIO_PROFILE_G726 },
740 { &mpeg4_p2_asf_asp_l5_so_g726, CT_ASF,
741 MPEG4_VIDEO_PROFILE_P2_ASP_L5, AUDIO_PROFILE_G726 },
742 { &mpeg4_p2_asf_asp_l4_so_g726, CT_ASF,
743 MPEG4_VIDEO_PROFILE_P2_ASP_L4, AUDIO_PROFILE_G726 },
744
745 /* 3GPP Container */
746 { &mpeg4_h263_3gpp_p0_l10_amr_wbplus, CT_3GP,
747 MPEG4_VIDEO_PROFILE_H263, AUDIO_PROFILE_AMR_WB },
748 { &mpeg4_p2_3gpp_sp_l0b_aac, CT_3GP,
749 MPEG4_VIDEO_PROFILE_P2_SP_L0B, AUDIO_PROFILE_AAC },
750 { &mpeg4_p2_3gpp_sp_l0b_amr, CT_3GP,
751 MPEG4_VIDEO_PROFILE_P2_SP_L0B, AUDIO_PROFILE_AMR },
752 { &mpeg4_h263_3gpp_p3_l10_amr, CT_3GP,
753 MPEG4_VIDEO_PROFILE_H263, AUDIO_PROFILE_AMR },
754
755 { NULL, 0, 0, 0 }
756 };
757
758 static mpeg4_vcodec_type_t
759 mpeg4_get_vcodec (AVCodecContext *vc)
760 {
761 int i;
762
763 if (!vc)
764 return MPEG4_VCODEC_INVALID;
765
766 for (i = 0; avf_vcodec_mapping[i].codec_id != -1; i++)
767 if (vc->codec_id == (unsigned int) avf_vcodec_mapping[i].codec_id)
768 return avf_vcodec_mapping[i].type;
769
770 return MPEG4_VCODEC_INVALID;
771 }
772
773 static inline int
774 is_valid_video_profile (video_properties_t res[], int size,
775 AVStream *vs, AVCodecContext *vc)
776 {
777 int i;
778
779 for (i = 0; i < size / (int) sizeof (video_properties_t); i++)
780 {
781 if (res[i].width == vc->width &&
782 res[i].height == vc->height &&
783 (vs->r_frame_rate.num / vs->r_frame_rate.num)
784 <= (res[i].fps_num / res[i].fps_den))
785 return 1;
786 }
787
788 return 0;
789 }
790
791 static mpeg4_video_profile_t
792 mpeg4_video_get_profile (mpeg4_vcodec_type_t vctype,
793 AVStream *vs, AVCodecContext *vc)
794 {
795 if (!vs || !vc)
796 return MPEG4_VIDEO_PROFILE_INVALID;
797
798 if (vctype == MPEG4_VCODEC_H263)
799 {
800 if (vc->bit_rate > 64000) /* max bitrate is 64 kbps */
801 return MPEG4_VIDEO_PROFILE_INVALID;
802
803 if (is_valid_video_profile (profile_h263_res,
804 sizeof (profile_h263_res), vs, vc))
805 return MPEG4_VIDEO_PROFILE_H263;
806
807 return MPEG4_VIDEO_PROFILE_INVALID;
808 }
809 else if (vctype == MPEG4_VCODEC_P2)
810 {
811 if (vc->bit_rate <= 128000) /* SP_L2 and SP_L0B */
812 {
813 if (is_valid_video_profile (profile_p2_sp_l0b_res,
814 sizeof (profile_p2_sp_l0b_res), vs, vc))
815 return MPEG4_VIDEO_PROFILE_P2_SP_L0B;
816
817 if (is_valid_video_profile (profile_p2_sp_l2_res,
818 sizeof (profile_p2_sp_l2_res), vs, vc))
819 return MPEG4_VIDEO_PROFILE_P2_SP_L2;
820
821 return MPEG4_VIDEO_PROFILE_INVALID;
822 }
823 else if (vc->bit_rate <= 384000) /* SP_L3 */
824 {
825 if (is_valid_video_profile (profile_p2_sp_l3_co_res,
826 sizeof (profile_p2_sp_l3_co_res), vs, vc))
827 return MPEG4_VIDEO_PROFILE_P2_SP_L3;
828
829 return MPEG4_VIDEO_PROFILE_INVALID;
830 }
831 else if (vc->bit_rate <= 2000000) /* CO and ASP_L4 */
832 {
833 if (is_valid_video_profile (profile_p2_sp_l3_co_res,
834 sizeof (profile_p2_sp_l3_co_res), vs, vc))
835 return MPEG4_VIDEO_PROFILE_P2_ASP_L4;
836
837 if (is_valid_video_profile (profile_p2_asp_l4_res,
838 sizeof (profile_p2_asp_l4_res), vs, vc))
839 return MPEG4_VIDEO_PROFILE_P2_ASP_L4;
840
841 return MPEG4_VIDEO_PROFILE_INVALID;
842 }
843 else if (vc->bit_rate <= 3000000) /* SP_L3_VGA */
844 {
845 if (is_valid_video_profile (profile_p2_sp_l3_vga_res,
846 sizeof (profile_p2_sp_l3_vga_res), vs, vc))
847 return MPEG4_VIDEO_PROFILE_P2_SP_L3_VGA;
848
849 return MPEG4_VIDEO_PROFILE_INVALID;
850 }
851 else if (vc->bit_rate <= 8000000) /* ASP_L5 */
852 {
853 if (is_valid_video_profile (profile_p2_asp_l5_res,
854 sizeof (profile_p2_asp_l5_res), vs, vc))
855 return MPEG4_VIDEO_PROFILE_P2_ASP_L5;
856
857 return MPEG4_VIDEO_PROFILE_INVALID;
858 }
859
860 return MPEG4_VIDEO_PROFILE_INVALID;
861 }
862
863 return MPEG4_VIDEO_PROFILE_INVALID;
864 }
865
866 static dlna_profile_t *
867 probe_mpeg4_part2 (AVFormatContext *ctx,
868 dlna_container_type_t st,
869 av_codecs_t *codecs)
870 {
871 mpeg4_vcodec_type_t vctype;
872 mpeg4_video_profile_t vp;
873 audio_profile_t ap;
874 int i;
875
876 if (!stream_ctx_is_av (codecs))
877 return NULL;
878
879 vctype = mpeg4_get_vcodec (codecs->vc);
880 if (vctype == MPEG4_VCODEC_INVALID)
881 return NULL;
882
883 /* check for a supported container */
884 if (st != CT_ASF &&
885 st != CT_3GP &&
886 st != CT_MP4 &&
887 st != CT_MPEG_TRANSPORT_STREAM &&
888 st != CT_MPEG_TRANSPORT_STREAM_DLNA &&
889 st != CT_MPEG_TRANSPORT_STREAM_DLNA_NO_TS)
890 return NULL;
891
892 /* ensure we have a valid video codec bit rate */
893 if (codecs->vc->bit_rate == 0)
894 codecs->vc->bit_rate = codecs->ac->bit_rate ?
895 ctx->bit_rate - codecs->ac->bit_rate : ctx->bit_rate;
896
897 /* check for valid video profile */
898 vp = mpeg4_video_get_profile (vctype, codecs->vs, codecs->vc);
899 if (vp == MPEG4_VIDEO_PROFILE_INVALID)
900 return NULL;
901
902 /* check for valid audio profile */
903 ap = audio_profile_guess (codecs->ac);
904 if (ap == AUDIO_PROFILE_INVALID)
905 return NULL;
906
907 /* AAC fixup: _320 profiles are audio-only profiles */
908 if (ap == AUDIO_PROFILE_AAC_320)
909 ap = AUDIO_PROFILE_AAC;
910 if (ap == AUDIO_PROFILE_AAC_HE_L2_320)
911 ap = AUDIO_PROFILE_AAC_HE_L2;
912
913 /* find profile according to container type, video and audio profiles */
914 for (i = 0; mpeg4_profiles_mapping[i].profile; i++)
915 if (mpeg4_profiles_mapping[i].st == st &&
916 mpeg4_profiles_mapping[i].vp == vp &&
917 mpeg4_profiles_mapping[i].ap == ap)
918 return mpeg4_profiles_mapping[i].profile;
919
920 return NULL;
921 }
922
923 dlna_registered_profile_t dlna_profile_av_mpeg4_part2 = {
924 .id = DLNA_PROFILE_AV_MPEG4_PART2,
925 .class = DLNA_CLASS_AV,
926 .extensions = "mov,hdmov,mp4,3gp,3gpp,asf,mpg,mpeg,mpe,mp2t,ts",
927 .probe = probe_mpeg4_part2,
928 .next = NULL
929 };