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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
1
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
2 #include <ctype.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
3 #include <stdio.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
4 #include <stdlib.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
5 #include <string.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
6 #include <unistd.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
7 #include <fcntl.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
8 #include <errno.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
9 #include <sys/types.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
10 #include <sys/stat.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
11
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
12 #include "config.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
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
84b64dece730 enable mf support on mingw32
faust3
parents: 9833
diff changeset
16 #else
84b64dece730 enable mf support on mingw32
faust3
parents: 9833
diff changeset
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
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
20 #include "mp_msg.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
21 #include "help_mp.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
22 #include "stream.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
23
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
24 #include "mf.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
25
9149
ca6dc931f6ea removed nonsense (and confusing) defaults
arpi
parents: 7407
diff changeset
26 int mf_w = 0; //352; // let codecs to detect it
ca6dc931f6ea removed nonsense (and confusing) defaults
arpi
parents: 7407
diff changeset
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
ca6dc931f6ea removed nonsense (and confusing) defaults
arpi
parents: 7407
diff changeset
29 char * mf_type = NULL; //"jpg";
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
30
7407
8780415baa87 stream layer cleanup - part 1
arpi
parents: 5354
diff changeset
31 mf_t* open_mf(char * filename){
9984
84b64dece730 enable mf support on mingw32
faust3
parents: 9833
diff changeset
32 #if defined(HAVE_GLOB) || defined(__MINGW32__)
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
33 glob_t gg;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
34 struct stat fs;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
35 int i;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
36 char * fname;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
37 mf_t * mf;
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
38 int error_count = 0;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
39 int count = 0;
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
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
86a202c1c229 ooops :)
atmos4
parents: 5352
diff changeset
62 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files );
86a202c1c229 ooops :)
atmos4
parents: 5352
diff changeset
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
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
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
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
69 if ( !strchr( filename,'%' ) )
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
70 {
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
71 strcpy( fname,filename );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
72 if ( !strchr( filename,'*' ) ) strcat( fname,"*" );
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
73
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
74 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
75
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
76 if ( glob( fname,0,NULL,&gg ) )
7407
8780415baa87 stream layer cleanup - part 1
arpi
parents: 5354
diff changeset
77 { free( mf ); free( fname ); return NULL; }
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
78
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
79 mf->nr_of_files=gg.gl_pathc;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
80 mf->names=malloc( gg.gl_pathc * sizeof( char* ) );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
81
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
82 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) );
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
83
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
84 for( i=0;i < gg.gl_pathc;i++ )
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
85 {
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
86 stat( gg.gl_pathv[i],&fs );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
87 if( S_ISDIR( fs.st_mode ) ) continue;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
88 mf->names[i]=strdup( gg.gl_pathv[i] );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
89 // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
90 }
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
91 globfree( &gg );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
92 goto exit_mf;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
93 }
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
94
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
95 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",filename );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
96
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
97 while ( error_count < 5 )
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
98 {
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
99 sprintf( fname,filename,count++ );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
100 if ( stat( fname,&fs ) )
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
101 {
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
102 error_count++;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
103 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
104 }
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
105 else
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
106 {
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
107 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
108 mf->names[mf->nr_of_files]=strdup( fname );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
109 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
110 mf->nr_of_files++;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
111 }
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
112 }
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
113
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
114 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
115
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
116 exit_mf:
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
117 free( fname );
7407
8780415baa87 stream layer cleanup - part 1
arpi
parents: 5354
diff changeset
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
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
123 }
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
124