annotate libmpdemux/extension.c @ 20356:90ee83c6c312

r20358: Make documentation links point to the online version. r20361: remove some DivX version numbers remove two leftover paragraphs from r20341 (Remove obsolete parts, some updates)
author kraymer
date Sun, 22 Oct 2006 13:43:49 +0000
parents 9c7de33d0e17
children 4d81dbdf46b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9006
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
1
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
2 #include <stdio.h>
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
3 #include <stdlib.h>
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
4 #include <string.h>
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
5
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
6 #include "config.h"
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
7
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
8 #include "stream.h"
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
9 #include "demuxer.h"
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
10
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
11 /*
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
12 * An autodetection based on the extension is not a good idea, but we don't care ;-)
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
13 */
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
14 static struct {
19110
08888397444e marks several strings inside structs as const when they hold just
reynaldo
parents: 18931
diff changeset
15 const char *extension;
9006
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
16 int demuxer_type;
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
17 } extensions_table[] = {
9134
f033fdd54da3 - mpeg extensions removed, it causes misdetction of renamed avi/asf files
arpi
parents: 9079
diff changeset
18 // { "mpeg", DEMUXER_TYPE_MPEG_PS },
f033fdd54da3 - mpeg extensions removed, it causes misdetction of renamed avi/asf files
arpi
parents: 9079
diff changeset
19 // { "mpg", DEMUXER_TYPE_MPEG_PS },
f033fdd54da3 - mpeg extensions removed, it causes misdetction of renamed avi/asf files
arpi
parents: 9079
diff changeset
20 // { "mpe", DEMUXER_TYPE_MPEG_PS },
9008
654bc667a450 - added some more
arpi
parents: 9006
diff changeset
21 { "vob", DEMUXER_TYPE_MPEG_PS },
654bc667a450 - added some more
arpi
parents: 9006
diff changeset
22 { "m2v", DEMUXER_TYPE_MPEG_PS },
18931
da91dc728556 lavf demuxer works better for gxf
reimar
parents: 17580
diff changeset
23 { "gxf", DEMUXER_TYPE_LAVF },
19924
fade77acf2c3 Try .mxf with libavformat first, works around a too greedy mpeg-demuxer
reimar
parents: 19110
diff changeset
24 { "mxf", DEMUXER_TYPE_LAVF },
9006
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
25 { "avi", DEMUXER_TYPE_AVI },
9134
f033fdd54da3 - mpeg extensions removed, it causes misdetction of renamed avi/asf files
arpi
parents: 9079
diff changeset
26 { "mp4", DEMUXER_TYPE_MOV },
9006
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
27 { "mov", DEMUXER_TYPE_MOV },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
28 { "qt", DEMUXER_TYPE_MOV },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
29 { "asx", DEMUXER_TYPE_ASF },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
30 { "asf", DEMUXER_TYPE_ASF },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
31 { "wmv", DEMUXER_TYPE_ASF },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
32 { "wma", DEMUXER_TYPE_ASF },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
33 { "viv", DEMUXER_TYPE_VIVO },
9008
654bc667a450 - added some more
arpi
parents: 9006
diff changeset
34 { "vivo", DEMUXER_TYPE_VIVO },
9006
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
35 { "rm", DEMUXER_TYPE_REAL },
9008
654bc667a450 - added some more
arpi
parents: 9006
diff changeset
36 { "rmvb", DEMUXER_TYPE_REAL },
9006
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
37 { "ra", DEMUXER_TYPE_REAL },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
38 { "y4m", DEMUXER_TYPE_Y4M },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
39 { "mp3", DEMUXER_TYPE_AUDIO },
9008
654bc667a450 - added some more
arpi
parents: 9006
diff changeset
40 { "wav", DEMUXER_TYPE_AUDIO },
11004
d48eccbbb984 FLAC decoding support via imported libmpflac.
lumag
parents: 9134
diff changeset
41 { "flac", DEMUXER_TYPE_AUDIO },
d48eccbbb984 FLAC decoding support via imported libmpflac.
lumag
parents: 9134
diff changeset
42 { "fla", DEMUXER_TYPE_AUDIO },
9006
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
43 { "ogg", DEMUXER_TYPE_OGG },
9008
654bc667a450 - added some more
arpi
parents: 9006
diff changeset
44 { "ogm", DEMUXER_TYPE_OGG },
9134
f033fdd54da3 - mpeg extensions removed, it causes misdetction of renamed avi/asf files
arpi
parents: 9079
diff changeset
45 // { "pls", DEMUXER_TYPE_PLAYLIST },
f033fdd54da3 - mpeg extensions removed, it causes misdetction of renamed avi/asf files
arpi
parents: 9079
diff changeset
46 // { "m3u", DEMUXER_TYPE_PLAYLIST },
9008
654bc667a450 - added some more
arpi
parents: 9006
diff changeset
47 { "xm", DEMUXER_TYPE_XMMS },
654bc667a450 - added some more
arpi
parents: 9006
diff changeset
48 { "mod", DEMUXER_TYPE_XMMS },
654bc667a450 - added some more
arpi
parents: 9006
diff changeset
49 { "s3m", DEMUXER_TYPE_XMMS },
654bc667a450 - added some more
arpi
parents: 9006
diff changeset
50 { "it", DEMUXER_TYPE_XMMS },
654bc667a450 - added some more
arpi
parents: 9006
diff changeset
51 { "mid", DEMUXER_TYPE_XMMS },
654bc667a450 - added some more
arpi
parents: 9006
diff changeset
52 { "midi", DEMUXER_TYPE_XMMS },
12175
da8e39bfe121 nsv (Nullsoft streaming video) demuxer
rtognimp
parents: 11004
diff changeset
53 { "vqf", DEMUXER_TYPE_XMMS },
12477
1550ef7117c4 Add detection of nsa streamed by aol ultravox server
rtognimp
parents: 12175
diff changeset
54 { "nsv", DEMUXER_TYPE_NSV },
13072
aad5a7c76f34 nut is only handled by lavf, speed up detection
alex
parents: 12477
diff changeset
55 { "nsa", DEMUXER_TYPE_NSV },
17580
65530e552f6f add mpc extension so that playback starts faster.
reimar
parents: 16363
diff changeset
56 { "mpc", DEMUXER_TYPE_MPC },
14693
37116118ab6a avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents: 13072
diff changeset
57 #ifdef USE_WIN32DLL
37116118ab6a avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents: 13072
diff changeset
58 { "avs", DEMUXER_TYPE_AVS },
37116118ab6a avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents: 13072
diff changeset
59 #endif
14751
4ace49a63a22 swf and flv through libavformat
alex
parents: 14693
diff changeset
60 { "nut", DEMUXER_TYPE_LAVF },
4ace49a63a22 swf and flv through libavformat
alex
parents: 14693
diff changeset
61 { "swf", DEMUXER_TYPE_LAVF },
15035
20dd98ab393f filename-based detection for h264 ES
lorenm
parents: 14751
diff changeset
62 { "flv", DEMUXER_TYPE_LAVF },
16363
8ffb17ddad95 10l, typo in last commit
reimar
parents: 16362
diff changeset
63 { "302", DEMUXER_TYPE_LAVF },
15035
20dd98ab393f filename-based detection for h264 ES
lorenm
parents: 14751
diff changeset
64 { "264", DEMUXER_TYPE_H264_ES },
15061
b5a2f518791d demux ac3 by means of lavf by default
nicodvb
parents: 15035
diff changeset
65 { "26l", DEMUXER_TYPE_H264_ES },
20103
9c7de33d0e17 WavPack files contain a complete, valid RIFF tag, so use extension (.wv)
reimar
parents: 19924
diff changeset
66 { "ac3", DEMUXER_TYPE_LAVF },
9c7de33d0e17 WavPack files contain a complete, valid RIFF tag, so use extension (.wv)
reimar
parents: 19924
diff changeset
67 { "wv", DEMUXER_TYPE_LAVF },
9006
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
68 };
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
69
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
70 int demuxer_type_by_filename(char* filename){
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
71 int i;
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
72 char* extension=strrchr(filename,'.');
9079
b1ea14b9694b cosmetic for 0.90, printf->mp_msg (hm..probably arpi will piss of me?:)
alex
parents: 9008
diff changeset
73 mp_msg(MSGT_OPEN, MSGL_V, "Searching demuxer type for filename %s ext: %s\n",filename,extension);
9006
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
74 if(extension) {
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
75 ++extension;
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
76 // mp_msg(MSGT_CPLAYER,MSGL_DBG2,"Extension: %s\n", extension );
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
77 // Look for the extension in the extensions table
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
78 for( i=0 ; i<(sizeof(extensions_table)/sizeof(extensions_table[0])) ; i++ ) {
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
79 if( !strcasecmp(extension, extensions_table[i].extension) ) {
9079
b1ea14b9694b cosmetic for 0.90, printf->mp_msg (hm..probably arpi will piss of me?:)
alex
parents: 9008
diff changeset
80 mp_msg(MSGT_OPEN, MSGL_V, "Trying demuxer %d based on filename extension\n",extensions_table[i].demuxer_type);
9006
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
81 return extensions_table[i].demuxer_type;
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
82 }
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
83 }
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
84 }
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
85 return DEMUXER_TYPE_UNKNOWN;
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
86 }
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
87