Mercurial > mplayer.hg
annotate libmpdemux/mf.c @ 31648:a09f02987594
Consistently use types as they are used by the API in ao_coreaudio.
author | adrian |
---|---|
date | Sun, 11 Jul 2010 21:02:53 +0000 |
parents | 32725ca88fed |
children | fcd252bdedd0 |
rev | line source |
---|---|
29238
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
1 /* |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
2 * This file is part of MPlayer. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
3 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
7 * (at your option) any later version. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
8 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
12 * GNU General Public License for more details. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
13 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
25964
diff
changeset
|
17 */ |
19300 | 18 |
19 #include <ctype.h> | |
20 #include <stdio.h> | |
21 #include <stdlib.h> | |
22 #include <string.h> | |
23 #include <unistd.h> | |
24 #include <fcntl.h> | |
25 #include <errno.h> | |
26 #include <sys/types.h> | |
27 #include <sys/stat.h> | |
28 | |
29 #include "config.h" | |
30 | |
31 #ifdef HAVE_GLOB | |
32 #include <glob.h> | |
33 #else | |
34 #include "osdep/glob.h" | |
35 #endif | |
30313
7f7591482564
Add a proper header for our strsep implementation so strsep will
reimar
parents:
29263
diff
changeset
|
36 #include "osdep/strsep.h" |
19300 | 37 |
38 #include "mp_msg.h" | |
39 #include "help_mp.h" | |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
19300
diff
changeset
|
40 #include "stream/stream.h" |
19300 | 41 |
42 #include "mf.h" | |
43 | |
44 int mf_w = 0; //352; // let codecs to detect it | |
45 int mf_h = 0; //288; | |
25964 | 46 double mf_fps = 25.0; |
19300 | 47 char * mf_type = NULL; //"jpg"; |
48 | |
49 mf_t* open_mf(char * filename){ | |
50 #if defined(HAVE_GLOB) || defined(__MINGW32__) | |
51 glob_t gg; | |
52 struct stat fs; | |
53 int i; | |
54 char * fname; | |
55 mf_t * mf; | |
56 int error_count = 0; | |
57 int count = 0; | |
58 | |
59 mf=calloc( 1,sizeof( mf_t ) ); | |
60 | |
61 if( filename[0] == '@' ) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
62 { |
19300 | 63 FILE *lst_f=fopen(filename + 1,"r"); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
64 if ( lst_f ) |
19300 | 65 { |
66 fname=malloc( 255 ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
67 while ( fgets( fname,255,lst_f ) ) |
19300 | 68 { |
69 /* remove spaces from end of fname */ | |
70 char *t=fname + strlen( fname ) - 1; | |
71 while ( t > fname && isspace( *t ) ) *(t--)=0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
72 if ( stat( fname,&fs ) ) |
19300 | 73 { |
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 mf->nr_of_files++; | |
81 } | |
82 } | |
83 fclose( lst_f ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
84 |
19300 | 85 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); |
86 goto exit_mf; | |
87 } | |
88 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] %s is not indirect filelist\n",filename+1 ); | |
89 } | |
90 | |
91 if( strchr( filename,',') ) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
92 { |
19300 | 93 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] filelist: %s\n",filename ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
94 |
19300 | 95 while ( ( fname=strsep( &filename,"," ) ) ) |
96 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
97 if ( stat( fname,&fs ) ) |
19300 | 98 { |
99 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); | |
100 } | |
101 else | |
102 { | |
103 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); | |
104 mf->names[mf->nr_of_files]=strdup( fname ); | |
105 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] ); | |
106 mf->nr_of_files++; | |
107 } | |
108 } | |
109 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
110 |
19300 | 111 goto exit_mf; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
112 } |
19300 | 113 |
114 fname=malloc( strlen( filename ) + 32 ); | |
115 | |
116 if ( !strchr( filename,'%' ) ) | |
117 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
118 strcpy( fname,filename ); |
19300 | 119 if ( !strchr( filename,'*' ) ) strcat( fname,"*" ); |
120 | |
121 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname ); | |
122 | |
123 if ( glob( fname,0,NULL,&gg ) ) | |
124 { free( mf ); free( fname ); return NULL; } | |
125 | |
126 mf->nr_of_files=gg.gl_pathc; | |
127 mf->names=calloc( gg.gl_pathc, sizeof( char* ) ); | |
128 | |
129 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) ); | |
130 | |
131 for( i=0;i < gg.gl_pathc;i++ ) | |
132 { | |
133 stat( gg.gl_pathv[i],&fs ); | |
134 if( S_ISDIR( fs.st_mode ) ) continue; | |
135 mf->names[i]=strdup( gg.gl_pathv[i] ); | |
136 // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] ); | |
137 } | |
138 globfree( &gg ); | |
139 goto exit_mf; | |
140 } | |
141 | |
142 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",filename ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
143 |
19300 | 144 while ( error_count < 5 ) |
145 { | |
146 sprintf( fname,filename,count++ ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
147 if ( stat( fname,&fs ) ) |
19300 | 148 { |
149 error_count++; | |
150 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); | |
151 } | |
152 else | |
153 { | |
154 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); | |
155 mf->names[mf->nr_of_files]=strdup( fname ); | |
156 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] ); | |
157 mf->nr_of_files++; | |
158 } | |
159 } | |
160 | |
161 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); | |
162 | |
163 exit_mf: | |
164 free( fname ); | |
165 return mf; | |
166 #else | |
167 mp_msg(MSGT_STREAM,MSGL_FATAL,"[mf] mf support is disabled on your os\n"); | |
168 return 0; | |
169 #endif | |
170 } |