Mercurial > mplayer.hg
annotate libmpdemux/mf.c @ 7925:6e937de68683
Gregory Kovriga added
author | arpi |
---|---|
date | Sat, 26 Oct 2002 15:06:50 +0000 |
parents | 8780415baa87 |
children | ca6dc931f6ea |
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 | |
7407 | 27 mf_t* open_mf(char * filename){ |
4549 | 28 glob_t gg; |
29 struct stat fs; | |
30 int i; | |
31 char * fname; | |
32 mf_t * mf; | |
4565 | 33 int error_count = 0; |
34 int count = 0; | |
4549 | 35 |
5352
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
36 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
|
37 |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
38 if( strchr( filename,',') ) |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
39 { |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
40 fname=malloc( 255 ); |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
41 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
|
42 |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
43 while ( ( fname=strsep( &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 if ( stat( fname,&fs ) ) |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
46 { |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
47 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
|
48 } |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
49 else |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
50 { |
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
51 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
|
52 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
|
53 // 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
|
54 mf->nr_of_files++; |
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 } |
5354 | 57 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); |
58 | |
5352
cf2882606e72
Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents:
4565
diff
changeset
|
59 goto exit_mf; |
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 |
4565 | 62 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
|
63 |
4565 | 64 if ( !strchr( filename,'%' ) ) |
65 { | |
66 strcpy( fname,filename ); | |
67 if ( !strchr( filename,'*' ) ) strcat( fname,"*" ); | |
4549 | 68 |
4565 | 69 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname ); |
70 | |
71 if ( glob( fname,0,NULL,&gg ) ) | |
7407 | 72 { free( mf ); free( fname ); return NULL; } |
4565 | 73 |
74 mf->nr_of_files=gg.gl_pathc; | |
75 mf->names=malloc( gg.gl_pathc * sizeof( char* ) ); | |
76 | |
77 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) ); | |
4549 | 78 |
4565 | 79 for( i=0;i < gg.gl_pathc;i++ ) |
80 { | |
81 stat( gg.gl_pathv[i],&fs ); | |
82 if( S_ISDIR( fs.st_mode ) ) continue; | |
83 mf->names[i]=strdup( gg.gl_pathv[i] ); | |
84 // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] ); | |
85 } | |
86 globfree( &gg ); | |
87 goto exit_mf; | |
88 } | |
4549 | 89 |
4565 | 90 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",filename ); |
91 | |
92 while ( error_count < 5 ) | |
4549 | 93 { |
4565 | 94 sprintf( fname,filename,count++ ); |
95 if ( stat( fname,&fs ) ) | |
96 { | |
97 error_count++; | |
98 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); | |
99 } | |
100 else | |
101 { | |
102 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); | |
103 mf->names[mf->nr_of_files]=strdup( fname ); | |
104 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] ); | |
105 mf->nr_of_files++; | |
106 } | |
4549 | 107 } |
108 | |
4565 | 109 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); |
110 | |
111 exit_mf: | |
4549 | 112 free( fname ); |
7407 | 113 return mf; |
4549 | 114 } |
115 |