Mercurial > mplayer.hg
annotate libmpdemux/mf.c @ 29358:7b2a6a462bfc
Fix indentation broken in last patch
author | reimar |
---|---|
date | Fri, 26 Jun 2009 15:39:35 +0000 |
parents | 0f1b5b68af32 |
children | 7f7591482564 |
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 | |
36 | |
37 #include "mp_msg.h" | |
38 #include "help_mp.h" | |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
19300
diff
changeset
|
39 #include "stream/stream.h" |
19300 | 40 |
41 #include "mf.h" | |
42 | |
43 int mf_w = 0; //352; // let codecs to detect it | |
44 int mf_h = 0; //288; | |
25964 | 45 double mf_fps = 25.0; |
19300 | 46 char * mf_type = NULL; //"jpg"; |
47 | |
48 mf_t* open_mf(char * filename){ | |
49 #if defined(HAVE_GLOB) || defined(__MINGW32__) | |
50 glob_t gg; | |
51 struct stat fs; | |
52 int i; | |
53 char * fname; | |
54 mf_t * mf; | |
55 int error_count = 0; | |
56 int count = 0; | |
57 | |
58 mf=calloc( 1,sizeof( mf_t ) ); | |
59 | |
60 if( filename[0] == '@' ) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
61 { |
19300 | 62 FILE *lst_f=fopen(filename + 1,"r"); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
63 if ( lst_f ) |
19300 | 64 { |
65 fname=malloc( 255 ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
66 while ( fgets( fname,255,lst_f ) ) |
19300 | 67 { |
68 /* remove spaces from end of fname */ | |
69 char *t=fname + strlen( fname ) - 1; | |
70 while ( t > fname && isspace( *t ) ) *(t--)=0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
71 if ( stat( fname,&fs ) ) |
19300 | 72 { |
73 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); | |
74 } | |
75 else | |
76 { | |
77 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); | |
78 mf->names[mf->nr_of_files]=strdup( fname ); | |
79 mf->nr_of_files++; | |
80 } | |
81 } | |
82 fclose( lst_f ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
83 |
19300 | 84 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); |
85 goto exit_mf; | |
86 } | |
87 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] %s is not indirect filelist\n",filename+1 ); | |
88 } | |
89 | |
90 if( strchr( filename,',') ) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
91 { |
19300 | 92 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] filelist: %s\n",filename ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
93 |
19300 | 94 while ( ( fname=strsep( &filename,"," ) ) ) |
95 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
96 if ( stat( fname,&fs ) ) |
19300 | 97 { |
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 } | |
107 } | |
108 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
|
109 |
19300 | 110 goto exit_mf; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
111 } |
19300 | 112 |
113 fname=malloc( strlen( filename ) + 32 ); | |
114 | |
115 if ( !strchr( filename,'%' ) ) | |
116 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
117 strcpy( fname,filename ); |
19300 | 118 if ( !strchr( filename,'*' ) ) strcat( fname,"*" ); |
119 | |
120 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname ); | |
121 | |
122 if ( glob( fname,0,NULL,&gg ) ) | |
123 { free( mf ); free( fname ); return NULL; } | |
124 | |
125 mf->nr_of_files=gg.gl_pathc; | |
126 mf->names=calloc( gg.gl_pathc, sizeof( char* ) ); | |
127 | |
128 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) ); | |
129 | |
130 for( i=0;i < gg.gl_pathc;i++ ) | |
131 { | |
132 stat( gg.gl_pathv[i],&fs ); | |
133 if( S_ISDIR( fs.st_mode ) ) continue; | |
134 mf->names[i]=strdup( gg.gl_pathv[i] ); | |
135 // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] ); | |
136 } | |
137 globfree( &gg ); | |
138 goto exit_mf; | |
139 } | |
140 | |
141 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
|
142 |
19300 | 143 while ( error_count < 5 ) |
144 { | |
145 sprintf( fname,filename,count++ ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
146 if ( stat( fname,&fs ) ) |
19300 | 147 { |
148 error_count++; | |
149 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); | |
150 } | |
151 else | |
152 { | |
153 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); | |
154 mf->names[mf->nr_of_files]=strdup( fname ); | |
155 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] ); | |
156 mf->nr_of_files++; | |
157 } | |
158 } | |
159 | |
160 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); | |
161 | |
162 exit_mf: | |
163 free( fname ); | |
164 return mf; | |
165 #else | |
166 mp_msg(MSGT_STREAM,MSGL_FATAL,"[mf] mf support is disabled on your os\n"); | |
167 return 0; | |
168 #endif | |
169 } | |
170 |