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