annotate libmpdemux/extension.c @ 9006:d00997f12257

extension-based filetype detection for headerless files (mp3 vs mpeg, etc) inspired by patch by Fabian Franz <FabianFranz@gmx.de>
author arpi
date Sun, 19 Jan 2003 00:21:54 +0000
parents
children 654bc667a450
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 {
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
15 char *extension;
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[] = {
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
18 { "mpeg", DEMUXER_TYPE_MPEG_PS },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
19 { "mpg", DEMUXER_TYPE_MPEG_PS },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
20 { "mpe", DEMUXER_TYPE_MPEG_ES },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
21 { "avi", DEMUXER_TYPE_AVI },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
22 { "mov", DEMUXER_TYPE_MOV },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
23 { "qt", DEMUXER_TYPE_MOV },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
24 { "asx", DEMUXER_TYPE_ASF },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
25 { "asf", DEMUXER_TYPE_ASF },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
26 { "wmv", DEMUXER_TYPE_ASF },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
27 { "wma", DEMUXER_TYPE_ASF },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
28 { "viv", DEMUXER_TYPE_VIVO },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
29 { "rm", DEMUXER_TYPE_REAL },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
30 { "ra", DEMUXER_TYPE_REAL },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
31 { "y4m", DEMUXER_TYPE_Y4M },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
32 { "mp3", DEMUXER_TYPE_AUDIO },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
33 { "ogg", DEMUXER_TYPE_OGG },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
34 { "wav", DEMUXER_TYPE_AUDIO },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
35 { "pls", DEMUXER_TYPE_PLAYLIST },
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
36 { "m3u", DEMUXER_TYPE_PLAYLIST }
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
37 };
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
38
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
39 int demuxer_type_by_filename(char* filename){
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
40 int i;
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
41 char* extension=strrchr(filename,'.');
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
42 printf("Searching demuxer type for filename %s ext: %s\n",filename,extension);
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
43 if(extension) {
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
44 ++extension;
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
45 // 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
46 // Look for the extension in the extensions table
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
47 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
48 if( !strcasecmp(extension, extensions_table[i].extension) ) {
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
49 printf("\n!!! trying demuxer %d based on filename extension\n",extensions_table[i].demuxer_type);
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
50 return extensions_table[i].demuxer_type;
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
51 }
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
52 }
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
53 }
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
54 return DEMUXER_TYPE_UNKNOWN;
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
55 }
d00997f12257 extension-based filetype detection for headerless files (mp3 vs mpeg, etc)
arpi
parents:
diff changeset
56