Mercurial > mplayer.hg
annotate libmpdemux/mf.c @ 9984:84b64dece730
enable mf support on mingw32
author | faust3 |
---|---|
date | Fri, 25 Apr 2003 10:20:15 +0000 |
parents | 9cdbcd86c176 |
children | 6ff3379a0862 |
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 <errno.h> | |
9 #include <sys/types.h> | |
10 #include <sys/stat.h> | |
11 | |
12 #include "config.h" | |
13 | |
9833
9cdbcd86c176
temporary disable mf support for systems without glob
faust3
parents:
9746
diff
changeset
|
14 #ifdef HAVE_GLOB |
9cdbcd86c176
temporary disable mf support for systems without glob
faust3
parents:
9746
diff
changeset
|
15 #include <glob.h> |
9984 | 16 #else |
17 #include "../osdep/glob.h" | |
9833
9cdbcd86c176
temporary disable mf support for systems without glob
faust3
parents:
9746
diff
changeset
|
18 #endif |
9cdbcd86c176
temporary disable mf support for systems without glob
faust3
parents:
9746
diff
changeset
|
19 |
4549 | 20 #include "mp_msg.h" |
21 #include "help_mp.h" | |
22 #include "stream.h" | |
23 | |
24 #include "mf.h" | |
25 | |
9149 | 26 int mf_w = 0; //352; // let codecs to detect it |
27 int mf_h = 0; //288; | |
5352
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
28 float mf_fps = 25.0; |
9149 | 29 char * mf_type = NULL; //"jpg"; |
4549 | 30 |
7407 | 31 mf_t* open_mf(char * filename){ |
9984 | 32 #if defined(HAVE_GLOB) || defined(__MINGW32__) |
4549 | 33 glob_t gg; |
34 struct stat fs; | |
35 int i; | |
36 char * fname; | |
37 mf_t * mf; | |
4565 | 38 int error_count = 0; |
39 int count = 0; | |
4549 | 40 |
5352
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
41 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
|
42 |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
43 if( strchr( filename,',') ) |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
44 { |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
45 fname=malloc( 255 ); |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
46 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
|
47 |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
48 while ( ( fname=strsep( &filename,"," ) ) ) |
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 if ( stat( fname,&fs ) ) |
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 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
|
53 } |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
54 else |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
55 { |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
56 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
|
57 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
|
58 // 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
|
59 mf->nr_of_files++; |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
60 } |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
61 } |
5354 | 62 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); |
63 | |
5352
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
64 goto exit_mf; |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
65 } |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
66 |
4565 | 67 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
|
68 |
4565 | 69 if ( !strchr( filename,'%' ) ) |
70 { | |
71 strcpy( fname,filename ); | |
72 if ( !strchr( filename,'*' ) ) strcat( fname,"*" ); | |
4549 | 73 |
4565 | 74 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname ); |
75 | |
76 if ( glob( fname,0,NULL,&gg ) ) | |
7407 | 77 { free( mf ); free( fname ); return NULL; } |
4565 | 78 |
79 mf->nr_of_files=gg.gl_pathc; | |
80 mf->names=malloc( gg.gl_pathc * sizeof( char* ) ); | |
81 | |
82 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) ); | |
4549 | 83 |
4565 | 84 for( i=0;i < gg.gl_pathc;i++ ) |
85 { | |
86 stat( gg.gl_pathv[i],&fs ); | |
87 if( S_ISDIR( fs.st_mode ) ) continue; | |
88 mf->names[i]=strdup( gg.gl_pathv[i] ); | |
89 // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] ); | |
90 } | |
91 globfree( &gg ); | |
92 goto exit_mf; | |
93 } | |
4549 | 94 |
4565 | 95 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",filename ); |
96 | |
97 while ( error_count < 5 ) | |
4549 | 98 { |
4565 | 99 sprintf( fname,filename,count++ ); |
100 if ( stat( fname,&fs ) ) | |
101 { | |
102 error_count++; | |
103 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); | |
104 } | |
105 else | |
106 { | |
107 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); | |
108 mf->names[mf->nr_of_files]=strdup( fname ); | |
109 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] ); | |
110 mf->nr_of_files++; | |
111 } | |
4549 | 112 } |
113 | |
4565 | 114 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); |
115 | |
116 exit_mf: | |
4549 | 117 free( fname ); |
7407 | 118 return mf; |
9833
9cdbcd86c176
temporary disable mf support for systems without glob
faust3
parents:
9746
diff
changeset
|
119 #else |
9cdbcd86c176
temporary disable mf support for systems without glob
faust3
parents:
9746
diff
changeset
|
120 mp_msg(MSGT_STREAM,MSGL_FATAL,"[mf] mf support is disabled on your os\n"); |
9cdbcd86c176
temporary disable mf support for systems without glob
faust3
parents:
9746
diff
changeset
|
121 return 0; |
9cdbcd86c176
temporary disable mf support for systems without glob
faust3
parents:
9746
diff
changeset
|
122 #endif |
4549 | 123 } |
124 |