configure: minor cleanups
[mplayer.git] / libmpdemux / extension.c
blob1d2ffb832e4a38ebe88dfd1a9f2c3a6cb180efdb
1 /*
2 * This file is part of MPlayer.
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.
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.
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.
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
23 #include "config.h"
25 #include "stream/stream.h"
26 #include "demuxer.h"
29 * An autodetection based on the extension is not a good idea, but we don't care ;-)
31 * You should not add anything here where autodetection can be easily fixed except in
32 * order to speed up auto-detection, in particular for formats that are often streamed.
33 * In particular you should not normally add any DEMUXER_TYPE_LAVF, adding the
34 * format to preferred_list in libmpdemux/demuxer_lavf.c will usually achieve
35 * the same effect in a much more reliable way.
37 static struct {
38 const char *extension;
39 int demuxer_type;
40 } extensions_table[] = {
41 // { "mpeg", DEMUXER_TYPE_MPEG_PS },
42 // { "mpg", DEMUXER_TYPE_MPEG_PS },
43 // { "mpe", DEMUXER_TYPE_MPEG_PS },
44 { "vob", DEMUXER_TYPE_MPEG_PS },
45 { "m2v", DEMUXER_TYPE_MPEG_PS },
46 { "avi", DEMUXER_TYPE_AVI },
47 { "asx", DEMUXER_TYPE_ASF },
48 { "asf", DEMUXER_TYPE_ASF },
49 { "wmv", DEMUXER_TYPE_ASF },
50 { "wma", DEMUXER_TYPE_ASF },
51 { "viv", DEMUXER_TYPE_VIVO },
52 { "vivo", DEMUXER_TYPE_VIVO },
53 { "rm", DEMUXER_TYPE_REAL },
54 { "rmvb", DEMUXER_TYPE_REAL },
55 { "ra", DEMUXER_TYPE_REAL },
56 { "y4m", DEMUXER_TYPE_Y4M },
57 { "mp3", DEMUXER_TYPE_AUDIO },
58 { "wav", DEMUXER_TYPE_AUDIO },
59 { "flac", DEMUXER_TYPE_AUDIO },
60 { "fla", DEMUXER_TYPE_AUDIO },
61 { "ogg", DEMUXER_TYPE_OGG },
62 { "ogm", DEMUXER_TYPE_OGG },
63 // { "pls", DEMUXER_TYPE_PLAYLIST },
64 // { "m3u", DEMUXER_TYPE_PLAYLIST },
65 { "xm", DEMUXER_TYPE_XMMS },
66 { "mod", DEMUXER_TYPE_XMMS },
67 { "s3m", DEMUXER_TYPE_XMMS },
68 { "it", DEMUXER_TYPE_XMMS },
69 { "mid", DEMUXER_TYPE_XMMS },
70 { "midi", DEMUXER_TYPE_XMMS },
71 { "nsv", DEMUXER_TYPE_NSV },
72 { "nsa", DEMUXER_TYPE_NSV },
73 { "mpc", DEMUXER_TYPE_MPC },
74 #ifdef CONFIG_WIN32DLL
75 { "avs", DEMUXER_TYPE_AVS },
76 #endif
77 { "302", DEMUXER_TYPE_LAVF },
78 { "264", DEMUXER_TYPE_H264_ES },
79 { "26l", DEMUXER_TYPE_H264_ES },
80 { "ac3", DEMUXER_TYPE_LAVF },
81 { "ape", DEMUXER_TYPE_LAVF },
82 { "apl", DEMUXER_TYPE_LAVF },
83 { "eac3",DEMUXER_TYPE_LAVF },
84 { "mac", DEMUXER_TYPE_LAVF },
85 { "str", DEMUXER_TYPE_LAVF },
86 { "cdg", DEMUXER_TYPE_LAVF },
88 // At least the following are hacks against broken autodetection
89 // that should not be there
93 int demuxer_type_by_filename(char* filename){
94 int i;
95 char* extension=strrchr(filename,'.');
96 mp_msg(MSGT_OPEN, MSGL_V, "Searching demuxer type for filename %s ext: %s\n",filename,extension);
97 if(extension) {
98 ++extension;
99 // mp_msg(MSGT_CPLAYER,MSGL_DBG2,"Extension: %s\n", extension );
100 // Look for the extension in the extensions table
101 for( i=0 ; i<(sizeof(extensions_table)/sizeof(extensions_table[0])) ; i++ ) {
102 if( !strcasecmp(extension, extensions_table[i].extension) ) {
103 mp_msg(MSGT_OPEN, MSGL_V, "Trying demuxer %d based on filename extension\n",extensions_table[i].demuxer_type);
104 return extensions_table[i].demuxer_type;
108 return DEMUXER_TYPE_UNKNOWN;