annotate libmpdemux/mf.c @ 6794:77980ab4e296

- add preferences support (first try) - fix some playlist bug - fix some equ bug - fix some redraw bug - fix dvd playing - fix file open dialog box - etc.
author pontscho
date Thu, 25 Jul 2002 20:26:38 +0000
parents 86a202c1c229
children 8780415baa87
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 <glob.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
9 #include <errno.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
10 #include <sys/types.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
11 #include <sys/stat.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
12
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
13 #include "config.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
14
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
15 #include "mp_msg.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
16 #include "help_mp.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
17 #include "stream.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
18
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
19 #include "mf.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
20
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
21 int mf_support = 0;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
22 int mf_w = 352;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
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
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
25 char * mf_type = "jpg";
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
26
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
27 int stream_open_mf(char * filename,stream_t * stream)
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
28 {
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
29 glob_t gg;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
30 struct stat fs;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
31 int i;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
32 char * fname;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
33 mf_t * mf;
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
34 int error_count = 0;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
35 int count = 0;
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
36
5352
cf2882606e72 Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents: 4565
diff changeset
37 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
38
cf2882606e72 Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents: 4565
diff changeset
39 if( strchr( filename,',') )
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 fname=malloc( 255 );
cf2882606e72 Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents: 4565
diff changeset
42 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
43
cf2882606e72 Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents: 4565
diff changeset
44 while ( ( fname=strsep( &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 if ( stat( fname,&fs ) )
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 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
49 }
cf2882606e72 Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents: 4565
diff changeset
50 else
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 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
53 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
54 // 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
55 mf->nr_of_files++;
cf2882606e72 Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents: 4565
diff changeset
56 }
cf2882606e72 Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents: 4565
diff changeset
57 }
5354
86a202c1c229 ooops :)
atmos4
parents: 5352
diff changeset
58 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files );
86a202c1c229 ooops :)
atmos4
parents: 5352
diff changeset
59
5352
cf2882606e72 Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents: 4565
diff changeset
60 goto exit_mf;
cf2882606e72 Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents: 4565
diff changeset
61 }
cf2882606e72 Fileslist support for mf demuxer, delemited by ',' and change mf fps to float.
atmos4
parents: 4565
diff changeset
62
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
63 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
64
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
65 if ( !strchr( filename,'%' ) )
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
66 {
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
67 strcpy( fname,filename );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
68 if ( !strchr( filename,'*' ) ) strcat( fname,"*" );
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
69
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
70 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
71
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
72 if ( glob( fname,0,NULL,&gg ) )
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
73 { free( mf ); free( fname ); return 0; }
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
74
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
75 mf->nr_of_files=gg.gl_pathc;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
76 mf->names=malloc( gg.gl_pathc * sizeof( char* ) );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
77
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
78 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
79
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
80 for( i=0;i < gg.gl_pathc;i++ )
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
81 {
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
82 stat( gg.gl_pathv[i],&fs );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
83 if( S_ISDIR( fs.st_mode ) ) continue;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
84 mf->names[i]=strdup( gg.gl_pathv[i] );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
85 // 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
86 }
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
87 globfree( &gg );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
88 goto exit_mf;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
89 }
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
90
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
91 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",filename );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
92
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
93 while ( error_count < 5 )
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
94 {
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
95 sprintf( fname,filename,count++ );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
96 if ( stat( fname,&fs ) )
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
97 {
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
98 error_count++;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
99 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
100 }
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
101 else
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
102 {
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
103 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
104 mf->names[mf->nr_of_files]=strdup( fname );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
105 // 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
106 mf->nr_of_files++;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
107 }
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
108 }
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
109
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
110 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
111
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
112 exit_mf:
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
113 free( fname );
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
114 stream->priv=(void*)mf;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
115 return 1;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
116 }
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
117