29238
|
1 /*
|
|
2 * This file is part of MPlayer.
|
|
3 *
|
|
4 * MPlayer 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 * MPlayer 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 along
|
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
17 */
|
9006
|
18
|
|
19 #include <stdio.h>
|
|
20 #include <stdlib.h>
|
|
21 #include <string.h>
|
35903
|
22 #include <strings.h>
|
9006
|
23
|
|
24 #include "config.h"
|
34174
|
25 #include "mp_msg.h"
|
22605
|
26 #include "stream/stream.h"
|
9006
|
27 #include "demuxer.h"
|
|
28
|
|
29 /*
|
|
30 * An autodetection based on the extension is not a good idea, but we don't care ;-)
|
30068
|
31 *
|
30070
|
32 * You should not add anything here where autodetection can be easily fixed except in
|
30068
|
33 * order to speed up auto-detection, in particular for formats that are often streamed.
|
|
34 * In particular you should not normally add any DEMUXER_TYPE_LAVF, adding the
|
|
35 * format to preferred_list in libmpdemux/demuxer_lavf.c will usually achieve
|
|
36 * the same effect in a much more reliable way.
|
9006
|
37 */
|
|
38 static struct {
|
19110
|
39 const char *extension;
|
9006
|
40 int demuxer_type;
|
|
41 } extensions_table[] = {
|
9134
|
42 // { "mpeg", DEMUXER_TYPE_MPEG_PS },
|
|
43 // { "mpg", DEMUXER_TYPE_MPEG_PS },
|
|
44 // { "mpe", DEMUXER_TYPE_MPEG_PS },
|
9008
|
45 { "vob", DEMUXER_TYPE_MPEG_PS },
|
|
46 { "m2v", DEMUXER_TYPE_MPEG_PS },
|
9006
|
47 { "avi", DEMUXER_TYPE_AVI },
|
|
48 { "asx", DEMUXER_TYPE_ASF },
|
|
49 { "asf", DEMUXER_TYPE_ASF },
|
|
50 { "wmv", DEMUXER_TYPE_ASF },
|
|
51 { "wma", DEMUXER_TYPE_ASF },
|
|
52 { "viv", DEMUXER_TYPE_VIVO },
|
9008
|
53 { "vivo", DEMUXER_TYPE_VIVO },
|
9006
|
54 { "rm", DEMUXER_TYPE_REAL },
|
9008
|
55 { "rmvb", DEMUXER_TYPE_REAL },
|
9006
|
56 { "ra", DEMUXER_TYPE_REAL },
|
|
57 { "y4m", DEMUXER_TYPE_Y4M },
|
|
58 { "mp3", DEMUXER_TYPE_AUDIO },
|
9008
|
59 { "wav", DEMUXER_TYPE_AUDIO },
|
11004
|
60 { "flac", DEMUXER_TYPE_AUDIO },
|
|
61 { "fla", DEMUXER_TYPE_AUDIO },
|
9006
|
62 { "ogg", DEMUXER_TYPE_OGG },
|
9008
|
63 { "ogm", DEMUXER_TYPE_OGG },
|
9134
|
64 // { "pls", DEMUXER_TYPE_PLAYLIST },
|
|
65 // { "m3u", DEMUXER_TYPE_PLAYLIST },
|
9008
|
66 { "xm", DEMUXER_TYPE_XMMS },
|
|
67 { "mod", DEMUXER_TYPE_XMMS },
|
|
68 { "s3m", DEMUXER_TYPE_XMMS },
|
|
69 { "it", DEMUXER_TYPE_XMMS },
|
|
70 { "mid", DEMUXER_TYPE_XMMS },
|
|
71 { "midi", DEMUXER_TYPE_XMMS },
|
12477
|
72 { "nsv", DEMUXER_TYPE_NSV },
|
13072
|
73 { "nsa", DEMUXER_TYPE_NSV },
|
17580
|
74 { "mpc", DEMUXER_TYPE_MPC },
|
27341
|
75 #ifdef CONFIG_WIN32DLL
|
14693
|
76 { "avs", DEMUXER_TYPE_AVS },
|
|
77 #endif
|
16363
|
78 { "302", DEMUXER_TYPE_LAVF },
|
15035
|
79 { "264", DEMUXER_TYPE_H264_ES },
|
15061
|
80 { "26l", DEMUXER_TYPE_H264_ES },
|
20103
|
81 { "ac3", DEMUXER_TYPE_LAVF },
|
24429
|
82 { "ape", DEMUXER_TYPE_LAVF },
|
|
83 { "apl", DEMUXER_TYPE_LAVF },
|
27482
|
84 { "eac3",DEMUXER_TYPE_LAVF },
|
24429
|
85 { "mac", DEMUXER_TYPE_LAVF },
|
27101
|
86 { "str", DEMUXER_TYPE_LAVF },
|
30067
|
87 { "cdg", DEMUXER_TYPE_LAVF },
|
35141
|
88 { "tak", DEMUXER_TYPE_LAVF },
|
22920
|
89
|
|
90 // At least the following are hacks against broken autodetection
|
|
91 // that should not be there
|
|
92
|
9006
|
93 };
|
|
94
|
|
95 int demuxer_type_by_filename(char* filename){
|
|
96 int i;
|
|
97 char* extension=strrchr(filename,'.');
|
9079
|
98 mp_msg(MSGT_OPEN, MSGL_V, "Searching demuxer type for filename %s ext: %s\n",filename,extension);
|
9006
|
99 if(extension) {
|
|
100 ++extension;
|
|
101 // mp_msg(MSGT_CPLAYER,MSGL_DBG2,"Extension: %s\n", extension );
|
|
102 // Look for the extension in the extensions table
|
|
103 for( i=0 ; i<(sizeof(extensions_table)/sizeof(extensions_table[0])) ; i++ ) {
|
|
104 if( !strcasecmp(extension, extensions_table[i].extension) ) {
|
9079
|
105 mp_msg(MSGT_OPEN, MSGL_V, "Trying demuxer %d based on filename extension\n",extensions_table[i].demuxer_type);
|
9006
|
106 return extensions_table[i].demuxer_type;
|
|
107 }
|
|
108 }
|
|
109 }
|
|
110 return DEMUXER_TYPE_UNKNOWN;
|
|
111 }
|