Mercurial > pt1.oyama
annotate libdlna-0.2.3/src/av_mpeg1.c @ 130:cc3e3f370aec
tune for streaming.
author | Naoya OYAMA <naoya.oyama@gmail.com> |
---|---|
date | Sun, 10 Oct 2010 22:44:28 +0900 |
parents | 4f6d9621ee00 |
children |
rev | line source |
---|---|
129
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
1 /* |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
2 * libdlna: reference DLNA standards implementation. |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2007 Benjamin Zores <ben@geexbox.org> |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
4 * |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
5 * This file is part of libdlna. |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
6 * |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
7 * libdlna is free software; you can redistribute it and/or |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
11 * |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
12 * libdlna is distributed in the hope that it will be useful, |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
16 * |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
18 * License along with libdlna; if not, write to the Free Software |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
19 * Foundation, Inc, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
20 */ |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
21 |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
22 #include <stdlib.h> |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
23 #include <string.h> |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
24 |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
25 #include "dlna_internals.h" |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
26 #include "profiles.h" |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
27 |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
28 /* MPEG-1 video with 2 channel MPEG-1 Layer2 audio |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
29 encapsulated in MPEG-1 system */ |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
30 static dlna_profile_t mpeg1 = { |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
31 .id = "MPEG1", |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
32 .mime = MIME_VIDEO_MPEG, |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
33 .label = LABEL_VIDEO_CIF30 |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
34 }; |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
35 |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
36 static dlna_profile_t * |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
37 probe_mpeg1 (AVFormatContext *ctx dlna_unused, |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
38 dlna_container_type_t st dlna_unused, |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
39 av_codecs_t *codecs) |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
40 { |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
41 if (!stream_ctx_is_av (codecs)) |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
42 return NULL; |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
43 |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
44 /* check for MPEG-1 video codec */ |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
45 if (codecs->vc->codec_id != CODEC_ID_MPEG1VIDEO) |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
46 return NULL; |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
47 |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
48 /* video bitrate must be CBR at 1,151,929.1 bps */ |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
49 if (codecs->vc->bit_rate != 1150000) |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
50 return NULL; |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
51 |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
52 /* supported resolutions: |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
53 - 352x288 @ 25 Hz (PAL) |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
54 - 352x240 @ 29.97 Hz (NTSC) |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
55 - 352x240 @ 23.976 Hz |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
56 */ |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
57 if (codecs->vc->width == 352 && codecs->vc->height == 288) |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
58 { |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
59 if (codecs->vs->r_frame_rate.num != 25 && |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
60 codecs->vs->r_frame_rate.den != 1) |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
61 return NULL; |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
62 } |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
63 else if (codecs->vc->width == 352 && codecs->vc->height == 240) |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
64 { |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
65 if ((codecs->vs->r_frame_rate.num != 30000 && |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
66 codecs->vs->r_frame_rate.den != 1001) || |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
67 (codecs->vs->r_frame_rate.num != 24000 && |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
68 codecs->vs->r_frame_rate.den != 1001)) |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
69 return NULL; |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
70 } |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
71 else |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
72 return NULL; |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
73 |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
74 /* check for MPEG-1 Layer-2 audio codec */ |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
75 if (codecs->ac->codec_id != CODEC_ID_MP2) |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
76 return NULL; |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
77 |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
78 /* supported channels: stereo only */ |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
79 if (codecs->ac->channels != 2) |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
80 return NULL; |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
81 |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
82 /* supported sampling rate: 44.1 kHz only */ |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
83 if (codecs->ac->sample_rate != 44100) |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
84 return NULL; |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
85 |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
86 /* supported bitrate: 224 Kbps only */ |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
87 if (codecs->ac->bit_rate != 224000) |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
88 return NULL; |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
89 |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
90 return &mpeg1; |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
91 } |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
92 |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
93 dlna_registered_profile_t dlna_profile_av_mpeg1 = { |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
94 .id = DLNA_PROFILE_AV_MPEG1, |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
95 .class = DLNA_CLASS_AV, |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
96 .extensions = "mpg,mpeg,mpe,m1v", |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
97 .probe = probe_mpeg1, |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
98 .next = NULL |
4f6d9621ee00
add multi session streaming & add depending librarys.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
diff
changeset
|
99 }; |