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