Mercurial > mplayer.hg
annotate libmpdemux/mf.c @ 6195:39805251ef61
Downloads w32codecs from M$, script by Tom Lees <tal26 at cam.ac.uk>
author | atmos4 |
---|---|
date | Sun, 26 May 2002 12:50:58 +0000 |
parents | 86a202c1c229 |
children | 8780415baa87 |
rev | line source |
---|---|
4549 | 1 |
2 #include <ctype.h> | |
3 #include <stdio.h> | |
4 #include <stdlib.h> | |
5 #include <string.h> | |
6 #include <unistd.h> | |
7 #include <fcntl.h> | |
8 #include <glob.h> | |
9 #include <errno.h> | |
10 #include <sys/types.h> | |
11 #include <sys/stat.h> | |
12 | |
13 #include "config.h" | |
14 | |
15 #include "mp_msg.h" | |
16 #include "help_mp.h" | |
17 #include "stream.h" | |
18 | |
19 #include "mf.h" | |
20 | |
21 int mf_support = 0; | |
22 int mf_w = 352; | |
23 int mf_h = 288; | |
5352
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
24 float mf_fps = 25.0; |
4549 | 25 char * mf_type = "jpg"; |
26 | |
27 int stream_open_mf(char * filename,stream_t * stream) | |
28 { | |
29 glob_t gg; | |
30 struct stat fs; | |
31 int i; | |
32 char * fname; | |
33 mf_t * mf; | |
4565 | 34 int error_count = 0; |
35 int count = 0; | |
4549 | 36 |
5352
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
37 mf=calloc( 1,sizeof( mf_t ) ); |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
38 |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
39 if( strchr( filename,',') ) |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
40 { |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
41 fname=malloc( 255 ); |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
42 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] filelist: %s\n",filename ); |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
43 |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
44 while ( ( fname=strsep( &filename,"," ) ) ) |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
45 { |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
46 if ( stat( fname,&fs ) ) |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
47 { |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
48 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
49 } |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
50 else |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
51 { |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
52 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
53 mf->names[mf->nr_of_files]=strdup( fname ); |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
54 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] ); |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
55 mf->nr_of_files++; |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
56 } |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
57 } |
5354 | 58 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); |
59 | |
5352
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
60 goto exit_mf; |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
61 } |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
62 |
4565 | 63 fname=malloc( strlen( filename ) + 32 ); |
5352
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
64 |
4565 | 65 if ( !strchr( filename,'%' ) ) |
66 { | |
67 strcpy( fname,filename ); | |
68 if ( !strchr( filename,'*' ) ) strcat( fname,"*" ); | |
4549 | 69 |
4565 | 70 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname ); |
71 | |
72 if ( glob( fname,0,NULL,&gg ) ) | |
73 { free( mf ); free( fname ); return 0; } | |
74 | |
75 mf->nr_of_files=gg.gl_pathc; | |
76 mf->names=malloc( gg.gl_pathc * sizeof( char* ) ); | |
77 | |
78 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) ); | |
4549 | 79 |
4565 | 80 for( i=0;i < gg.gl_pathc;i++ ) |
81 { | |
82 stat( gg.gl_pathv[i],&fs ); | |
83 if( S_ISDIR( fs.st_mode ) ) continue; | |
84 mf->names[i]=strdup( gg.gl_pathv[i] ); | |
85 // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] ); | |
86 } | |
87 globfree( &gg ); | |
88 goto exit_mf; | |
89 } | |
4549 | 90 |
4565 | 91 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",filename ); |
92 | |
93 while ( error_count < 5 ) | |
4549 | 94 { |
4565 | 95 sprintf( fname,filename,count++ ); |
96 if ( stat( fname,&fs ) ) | |
97 { | |
98 error_count++; | |
99 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); | |
100 } | |
101 else | |
102 { | |
103 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); | |
104 mf->names[mf->nr_of_files]=strdup( fname ); | |
105 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] ); | |
106 mf->nr_of_files++; | |
107 } | |
4549 | 108 } |
109 | |
4565 | 110 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); |
111 | |
112 exit_mf: | |
4549 | 113 free( fname ); |
114 stream->priv=(void*)mf; | |
115 return 1; | |
116 } | |
117 |