Mercurial > mplayer.hg
annotate libmpdemux/mf.c @ 18077:cede662f40a5
timestamps are 33 bits long, so they don't fit in an unsigned int; 10l
author | nicodvb |
---|---|
date | Tue, 11 Apr 2006 20:05:24 +0000 |
parents | cd540846d052 |
children | 4928dd61f136 |
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 |
17012 | 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 |
17050
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
43 if( filename[0] == '@' ) |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
44 { |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
45 FILE *lst_f=fopen(filename + 1,"r"); |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
46 if ( lst_f ) |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
47 { |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
48 fname=malloc( 255 ); |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
49 while ( fgets( fname,255,lst_f ) ) |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
50 { |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
51 /* remove spaces from end of fname */ |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
52 char *t=fname + strlen( fname ) - 1; |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
53 while ( t > fname && isspace( *t ) ) *(t--)=0; |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
54 if ( stat( fname,&fs ) ) |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
55 { |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
56 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
57 } |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
58 else |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
59 { |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
60 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
61 mf->names[mf->nr_of_files]=strdup( fname ); |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
62 mf->nr_of_files++; |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
63 } |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
64 } |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
65 fclose( lst_f ); |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
66 |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
67 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
68 goto exit_mf; |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
69 } |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
70 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] %s is not indirect filelist\n",filename+1 ); |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
71 } |
cd540846d052
Add support to get the list of files from a file containing one filename
albeu
parents:
17012
diff
changeset
|
72 |
5352
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
73 if( strchr( filename,',') ) |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
74 { |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
75 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
|
76 |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
77 while ( ( fname=strsep( &filename,"," ) ) ) |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
78 { |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
79 if ( stat( fname,&fs ) ) |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
80 { |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
81 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
|
82 } |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
83 else |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
84 { |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
85 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
|
86 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
|
87 // 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
|
88 mf->nr_of_files++; |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
89 } |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
90 } |
5354 | 91 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); |
92 | |
5352
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
93 goto exit_mf; |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
94 } |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
95 |
4565 | 96 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
|
97 |
4565 | 98 if ( !strchr( filename,'%' ) ) |
99 { | |
100 strcpy( fname,filename ); | |
101 if ( !strchr( filename,'*' ) ) strcat( fname,"*" ); | |
4549 | 102 |
4565 | 103 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname ); |
104 | |
105 if ( glob( fname,0,NULL,&gg ) ) | |
7407 | 106 { free( mf ); free( fname ); return NULL; } |
4565 | 107 |
108 mf->nr_of_files=gg.gl_pathc; | |
109 mf->names=malloc( gg.gl_pathc * sizeof( char* ) ); | |
110 | |
111 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) ); | |
4549 | 112 |
4565 | 113 for( i=0;i < gg.gl_pathc;i++ ) |
114 { | |
115 stat( gg.gl_pathv[i],&fs ); | |
116 if( S_ISDIR( fs.st_mode ) ) continue; | |
117 mf->names[i]=strdup( gg.gl_pathv[i] ); | |
118 // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] ); | |
119 } | |
120 globfree( &gg ); | |
121 goto exit_mf; | |
122 } | |
4549 | 123 |
4565 | 124 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",filename ); |
125 | |
126 while ( error_count < 5 ) | |
4549 | 127 { |
4565 | 128 sprintf( fname,filename,count++ ); |
129 if ( stat( fname,&fs ) ) | |
130 { | |
131 error_count++; | |
132 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); | |
133 } | |
134 else | |
135 { | |
136 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); | |
137 mf->names[mf->nr_of_files]=strdup( fname ); | |
138 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] ); | |
139 mf->nr_of_files++; | |
140 } | |
4549 | 141 } |
142 | |
4565 | 143 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); |
144 | |
145 exit_mf: | |
4549 | 146 free( fname ); |
7407 | 147 return mf; |
9833
9cdbcd86c176
temporary disable mf support for systems without glob
faust3
parents:
9746
diff
changeset
|
148 #else |
9cdbcd86c176
temporary disable mf support for systems without glob
faust3
parents:
9746
diff
changeset
|
149 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
|
150 return 0; |
9cdbcd86c176
temporary disable mf support for systems without glob
faust3
parents:
9746
diff
changeset
|
151 #endif |
4549 | 152 } |
153 |