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;
|
|
24 int mf_fps = 25;
|
|
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
|
4565
|
37 fname=malloc( strlen( filename ) + 32 );
|
|
38 mf=calloc( 1,sizeof( mf_t ) );
|
|
39
|
|
40 if ( !strchr( filename,'%' ) )
|
|
41 {
|
|
42 strcpy( fname,filename );
|
|
43 if ( !strchr( filename,'*' ) ) strcat( fname,"*" );
|
4549
|
44
|
4565
|
45 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname );
|
|
46
|
|
47 if ( glob( fname,0,NULL,&gg ) )
|
|
48 { free( mf ); free( fname ); return 0; }
|
|
49
|
|
50 mf->nr_of_files=gg.gl_pathc;
|
|
51 mf->names=malloc( gg.gl_pathc * sizeof( char* ) );
|
|
52
|
|
53 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) );
|
4549
|
54
|
4565
|
55 for( i=0;i < gg.gl_pathc;i++ )
|
|
56 {
|
|
57 stat( gg.gl_pathv[i],&fs );
|
|
58 if( S_ISDIR( fs.st_mode ) ) continue;
|
|
59 mf->names[i]=strdup( gg.gl_pathv[i] );
|
|
60 // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] );
|
|
61 }
|
|
62 globfree( &gg );
|
|
63 goto exit_mf;
|
|
64 }
|
4549
|
65
|
4565
|
66 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",filename );
|
|
67
|
|
68 while ( error_count < 5 )
|
4549
|
69 {
|
4565
|
70 sprintf( fname,filename,count++ );
|
|
71 if ( stat( fname,&fs ) )
|
|
72 {
|
|
73 error_count++;
|
|
74 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname );
|
|
75 }
|
|
76 else
|
|
77 {
|
|
78 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) );
|
|
79 mf->names[mf->nr_of_files]=strdup( fname );
|
|
80 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] );
|
|
81 mf->nr_of_files++;
|
|
82 }
|
4549
|
83 }
|
|
84
|
4565
|
85 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files );
|
|
86
|
|
87 exit_mf:
|
4549
|
88 free( fname );
|
|
89 stream->priv=(void*)mf;
|
|
90 return 1;
|
|
91 }
|
|
92
|