Mercurial > mplayer.hg
annotate libmpdemux/stream.c @ 9798:02449faf87dd
MINGW32 port
author | faust3 |
---|---|
date | Wed, 02 Apr 2003 16:52:00 +0000 |
parents | f67d87b2d3c7 |
children | 2f02809d32a8 |
rev | line source |
---|---|
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
1 |
1430 | 2 #include <stdio.h> |
3 #include <stdlib.h> | |
4 #include <unistd.h> | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
5 |
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
6 #include <sys/types.h> |
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
7 #include <sys/stat.h> |
9798 | 8 #ifndef __MINGW32__ |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
9 #include <sys/ioctl.h> |
6814 | 10 #include <sys/wait.h> |
9798 | 11 #endif |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
12 #include <fcntl.h> |
2322 | 13 #include <signal.h> |
9794 | 14 #include <strings.h> |
578 | 15 |
1430 | 16 #include "config.h" |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1642
diff
changeset
|
17 #include "mp_msg.h" |
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1642
diff
changeset
|
18 #include "help_mp.h" |
9380 | 19 #include "../osdep/shmem.h" |
578 | 20 |
21 #include "stream.h" | |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
22 #include "demuxer.h" |
578 | 23 |
9794 | 24 #include "../m_option.h" |
25 #include "../m_struct.h" | |
26 | |
27 | |
578 | 28 extern int verbose; // defined in mplayer.c |
1 | 29 |
8812 | 30 #include "cue_read.h" |
31 | |
3261 | 32 #ifdef HAVE_VCD |
33 | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
692
diff
changeset
|
34 #ifdef __FreeBSD__ |
2310 | 35 #include "vcd_read_fbsd.h" |
5872 | 36 #elif defined(__NetBSD__) |
37 #include "vcd_read_nbsd.h" | |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
692
diff
changeset
|
38 #else |
2310 | 39 #include "vcd_read.h" |
958
162a78d3cc08
FreeBSD support by Vladimir Kushnir vkushnir@Alfacom.net
arpi_esp
parents:
692
diff
changeset
|
40 #endif |
1 | 41 |
3261 | 42 #endif |
43 | |
8812 | 44 //#include "vcd_read_bincue.h" |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
45 |
1595 | 46 #ifdef USE_DVDREAD |
8344 | 47 int dvd_read_sector(dvd_priv_t *d,unsigned char* data); |
48 void dvd_seek(dvd_priv_t *d,int pos); | |
6814 | 49 void dvd_close(dvd_priv_t *d); |
1595 | 50 #endif |
51 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
52 #ifdef HAVE_CDDA |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
53 int read_cdda(stream_t* s); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
54 void seek_cdda(stream_t* s); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
55 void close_cdda(stream_t* s); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
56 #endif |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
57 |
7630
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
58 #ifdef LIBSMBCLIENT |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
59 #include "libsmbclient.h" |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
60 #endif |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
61 |
9794 | 62 extern stream_info_t stream_info_file; |
63 | |
64 stream_info_t* auto_open_streams[] = { | |
65 &stream_info_file, | |
66 NULL | |
67 }; | |
68 | |
69 stream_t* open_stream_plugin(stream_info_t* sinfo,char* filename,int mode, | |
70 char** options, int* file_format, int* ret) { | |
71 void* arg = NULL; | |
72 stream_t* s; | |
73 m_struct_t* desc = (m_struct_t*)sinfo->opts; | |
74 | |
75 // Parse options | |
76 if(desc) { | |
77 arg = m_struct_alloc(desc); | |
78 if(sinfo->opts_url) { | |
79 m_option_t url_opt = | |
80 { "stream url", arg , CONF_TYPE_CUSTOM_URL, 0, 0 ,0, sinfo->opts }; | |
81 if(m_option_parse(&url_opt,"stream url",filename,arg,M_CONFIG_FILE) < 0) { | |
82 mp_msg(MSGT_OPEN,MSGL_ERR, "URL parsing failed on url %s\n",filename); | |
83 m_struct_free(desc,arg); | |
84 return NULL; | |
85 } | |
86 } | |
87 if(options) { | |
88 int i; | |
89 for(i = 0 ; options[i] != NULL ; i += 2) { | |
90 mp_msg(MSGT_OPEN,MSGL_DBG2, "Set stream arg %s=%s\n", | |
91 options[i],options[i+1]); | |
92 if(!m_struct_set(desc,arg,options[i],options[i+1])) | |
93 mp_msg(MSGT_OPEN,MSGL_WARN, "Failed to set stream option %s=%s\n", | |
94 options[i],options[i+1]); | |
95 } | |
96 } | |
97 } | |
98 s = new_stream(-2,-2); | |
99 s->url=strdup(filename); | |
100 s->flags |= mode; | |
101 *ret = sinfo->open(s,mode,arg,file_format); | |
102 if((*ret) != STREAM_OK) { | |
103 free(s->url); | |
104 free(s); | |
105 return NULL; | |
106 } | |
107 if(s->type <= -2) | |
108 mp_msg(MSGT_OPEN,MSGL_WARN, "Warning streams need a type !!!!\n"); | |
109 if(s->flags & STREAM_SEEK && !s->seek) | |
110 s->flags &= ~STREAM_SEEK; | |
111 if(s->seek && !(s->flags & STREAM_SEEK)) | |
112 s->flags &= STREAM_SEEK; | |
113 | |
114 | |
115 mp_msg(MSGT_OPEN,MSGL_V, "STREAM: [%s] %s\n",sinfo->name,filename); | |
116 mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Description: %s\n",sinfo->info); | |
117 mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Author: %s\n", sinfo->author); | |
118 mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Comment: %s\n", sinfo->comment); | |
119 | |
120 return s; | |
121 } | |
122 | |
123 | |
124 stream_t* open_stream_full(char* filename,int mode, char** options, int* file_format) { | |
125 int i,j,l,r; | |
126 stream_info_t* sinfo; | |
127 stream_t* s; | |
128 | |
129 for(i = 0 ; auto_open_streams[i] ; i++) { | |
130 sinfo = auto_open_streams[i]; | |
131 if(!sinfo->protocols) { | |
132 mp_msg(MSGT_OPEN,MSGL_WARN, "Stream type %s have protocols == NULL, it's a bug\n"); | |
133 continue; | |
134 } | |
135 for(j = 0 ; sinfo->protocols[j] ; j++) { | |
136 l = strlen(sinfo->protocols[j]); | |
137 // l == 0 => Don't do protocol matching (ie network and filenames) | |
138 if((l == 0) || ((strncmp(sinfo->protocols[j],filename,l) == 0) && | |
139 (strncmp("://",filename+l,3) == 0))) { | |
140 *file_format = DEMUXER_TYPE_UNKNOWN; | |
141 s = open_stream_plugin(sinfo,filename,mode,options,file_format,&r); | |
142 if(s) return s; | |
143 if(r != STREAM_UNSUPORTED) { | |
144 mp_msg(MSGT_OPEN,MSGL_ERR, "Failed to open %s\n",filename); | |
145 return NULL; | |
146 } | |
147 break; | |
148 } | |
149 } | |
150 } | |
151 | |
152 mp_msg(MSGT_OPEN,MSGL_ERR, "No stream found to handle url %s\n",filename); | |
153 return NULL; | |
154 } | |
155 | |
1 | 156 //=================== STREAMER ========================= |
157 | |
158 int stream_fill_buffer(stream_t *s){ | |
159 int len; | |
9787
c3b63fb0e8db
Added a test for "s->fd == NULL" to the start of "stream_fill_buffer()".
rsf
parents:
9610
diff
changeset
|
160 if (s->fd == NULL || s->eof) { s->buf_pos = s->buf_len = 0; return 0; } |
1 | 161 switch(s->type){ |
7630
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
162 #ifdef LIBSMBCLIENT |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
163 case STREAMTYPE_SMB: |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
164 len=smbc_read(s->fd,s->buffer,STREAM_BUFFER_SIZE); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
165 break; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
166 #endif |
692 | 167 case STREAMTYPE_STREAM: |
3044
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
168 #ifdef STREAMING |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
169 if( s->streaming_ctrl!=NULL ) { |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
170 len=s->streaming_ctrl->streaming_read(s->fd,s->buffer,STREAM_BUFFER_SIZE, s->streaming_ctrl);break; |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
171 } else { |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
172 len=read(s->fd,s->buffer,STREAM_BUFFER_SIZE);break; |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
173 } |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
174 #else |
1 | 175 len=read(s->fd,s->buffer,STREAM_BUFFER_SIZE);break; |
3044
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
176 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
177 #ifdef HAVE_CDDA |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
178 case STREAMTYPE_CDDA: |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
179 len = read_cdda(s); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
180 break; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
181 #endif |
3261 | 182 #ifdef HAVE_VCD |
1 | 183 case STREAMTYPE_VCD: |
184 len=vcd_read(s->fd,s->buffer);break; | |
185 #endif | |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
186 case STREAMTYPE_VCDBINCUE: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
187 len=cue_vcd_read(s->buffer);break; |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
5133
diff
changeset
|
188 #ifdef USE_DVDNAV |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
5133
diff
changeset
|
189 case STREAMTYPE_DVDNAV: { |
5472 | 190 dvdnav_stream_read((dvdnav_priv_t*)s->priv,s->buffer,&len); |
191 if (len==0) return 0; // this was an event, so repeat the read | |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
5133
diff
changeset
|
192 break; |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
5133
diff
changeset
|
193 } |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
5133
diff
changeset
|
194 #endif |
1595 | 195 #ifdef USE_DVDREAD |
196 case STREAMTYPE_DVD: { | |
197 off_t pos=dvd_read_sector(s->priv,s->buffer); | |
198 if(pos>=0){ | |
199 len=2048; // full sector | |
200 s->pos=2048*pos-len; | |
201 } else len=-1; // error | |
202 break; | |
203 } | |
204 #endif | |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
205 case STREAMTYPE_DS: |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
206 len = demux_read_data((demux_stream_t*)s->priv,s->buffer,STREAM_BUFFER_SIZE); |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
207 break; |
9610 | 208 |
209 #ifdef HAS_DVBIN_SUPPORT | |
210 case STREAMTYPE_DVB: | |
211 len = dvb_streaming_read(s->fd, s->buffer, STREAM_BUFFER_SIZE, s->priv); | |
212 break; | |
213 #endif | |
214 | |
215 | |
216 | |
9794 | 217 default: |
218 len= s->fill_buffer ? s->fill_buffer(s,s->buffer,STREAM_BUFFER_SIZE) : 0; | |
1 | 219 } |
220 if(len<=0){ s->eof=1; s->buf_pos=s->buf_len=0; return 0; } | |
221 s->buf_pos=0; | |
222 s->buf_len=len; | |
223 s->pos+=len; | |
224 // printf("[%d]",len);fflush(stdout); | |
225 return len; | |
226 } | |
227 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
228 int stream_seek_long(stream_t *s,off_t pos){ |
6814 | 229 off_t newpos=0; |
1 | 230 |
2144 | 231 // if(verbose>=3) printf("seek_long to 0x%X\n",(unsigned int)pos); |
1 | 232 |
233 s->buf_pos=s->buf_len=0; | |
234 | |
235 switch(s->type){ | |
7630
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
236 case STREAMTYPE_SMB: |
692 | 237 case STREAMTYPE_STREAM: |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
238 #ifdef _LARGEFILE_SOURCE |
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
239 newpos=pos&(~((long long)STREAM_BUFFER_SIZE-1));break; |
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
240 #else |
492 | 241 newpos=pos&(~(STREAM_BUFFER_SIZE-1));break; |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
242 #endif |
1 | 243 case STREAMTYPE_VCD: |
244 newpos=(pos/VCD_SECTOR_DATA)*VCD_SECTOR_DATA;break; | |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
245 case STREAMTYPE_VCDBINCUE: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
246 newpos=(pos/VCD_SECTOR_DATA)*VCD_SECTOR_DATA;break; |
1595 | 247 case STREAMTYPE_DVD: |
248 newpos=pos/2048; newpos*=2048; break; | |
8524 | 249 #ifdef HAVE_CDDA |
250 case STREAMTYPE_CDDA: | |
251 newpos=(pos/VCD_SECTOR_SIZE)*VCD_SECTOR_SIZE;break; | |
252 #endif | |
9794 | 253 default: |
254 // Round on sector size | |
255 if(s->sector_size) | |
256 newpos=(pos/s->sector_size)*s->sector_size; | |
257 else { // Otherwise on the buffer size | |
258 #ifdef _LARGEFILE_SOURCE | |
259 newpos=pos&(~((long long)STREAM_BUFFER_SIZE-1));break; | |
260 #else | |
261 newpos=pos&(~(STREAM_BUFFER_SIZE-1));break; | |
262 #endif | |
263 } | |
264 break; | |
1 | 265 } |
266 | |
2050 | 267 if(verbose>=3){ |
268 #ifdef _LARGEFILE_SOURCE | |
269 printf("s->pos=%llX newpos=%llX new_bufpos=%llX buflen=%X \n", | |
270 (long long)s->pos,(long long)newpos,(long long)pos,s->buf_len); | |
271 #else | |
272 printf("s->pos=%X newpos=%X new_bufpos=%X buflen=%X \n", | |
273 (unsigned int)s->pos,newpos,pos,s->buf_len); | |
274 #endif | |
275 } | |
276 | |
1 | 277 pos-=newpos; |
278 | |
279 if(newpos==0 || newpos!=s->pos){ | |
280 switch(s->type){ | |
7630
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
281 #ifdef LIBSMBCLIENT |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
282 case STREAMTYPE_SMB: |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
283 s->pos=newpos; // real seek |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
284 if(smbc_lseek(s->fd,s->pos,SEEK_SET)<0) s->eof=1; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
285 break; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
286 #endif |
3261 | 287 #ifdef HAVE_VCD |
1 | 288 case STREAMTYPE_VCD: |
692 | 289 s->pos=newpos; // real seek |
1 | 290 vcd_set_msf(s->pos/VCD_SECTOR_DATA); |
291 break; | |
3261 | 292 #endif |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
293 case STREAMTYPE_VCDBINCUE: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
294 s->pos=newpos; // real seek |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
295 cue_set_msf(s->pos/VCD_SECTOR_DATA); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
8524
diff
changeset
|
296 break; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
297 #ifdef HAVE_CDDA |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
298 case STREAMTYPE_CDDA: { |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
299 s->pos=newpos; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
300 seek_cdda(s); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
301 break; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
302 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
303 #endif |
5472 | 304 #ifdef USE_DVDNAV |
305 case STREAMTYPE_DVDNAV: { | |
306 if (newpos==0) { | |
307 if (dvdnav_stream_reset((dvdnav_priv_t*)s->priv)) | |
308 s->pos=0; | |
309 } | |
310 if(newpos!=s->pos){ | |
311 mp_msg(MSGT_STREAM,MSGL_INFO,"Cannot seek in DVDNAV streams yet!\n"); | |
312 return 1; | |
313 } | |
314 break; | |
315 } | |
316 #endif | |
1595 | 317 #ifdef USE_DVDREAD |
318 case STREAMTYPE_DVD: | |
319 s->pos=newpos; // real seek | |
320 dvd_seek(s->priv,s->pos/2048); | |
321 break; | |
322 #endif | |
692 | 323 case STREAMTYPE_STREAM: |
324 //s->pos=newpos; // real seek | |
3044
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
325 // Some streaming protocol allow to seek backward and forward |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
326 // A function call that return -1 can tell that the protocol |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
327 // doesn't support seeking. |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
328 #ifdef STREAMING |
8929
c5ca1ae42555
check if seeking supported, otherwise fallback to null reading
arpi
parents:
8812
diff
changeset
|
329 if( s->streaming_ctrl!=NULL && s->streaming_ctrl->streaming_seek ) { |
3044
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
330 if( s->streaming_ctrl->streaming_seek( s->fd, pos, s->streaming_ctrl )<0 ) { |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
331 mp_msg(MSGT_STREAM,MSGL_INFO,"Stream not seekable!\n"); |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
332 return 1; |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
333 } |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
334 } |
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
335 #else |
692 | 336 if(newpos<s->pos){ |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1642
diff
changeset
|
337 mp_msg(MSGT_STREAM,MSGL_INFO,"Cannot seek backward in linear streams!\n"); |
692 | 338 return 1; |
339 } | |
340 while(s->pos<newpos){ | |
341 if(stream_fill_buffer(s)<=0) break; // EOF | |
342 } | |
3044
606bb6943ae9
Added a network read function call and a seek network function call.
bertrand
parents:
2790
diff
changeset
|
343 #endif |
692 | 344 break; |
7408 | 345 default: |
9794 | 346 // This should at the beginning as soon as all streams are converted |
347 if(!s->seek) | |
348 return 0; | |
349 // Now seek | |
350 if(!s->seek(s,newpos)) { | |
351 mp_msg(MSGT_STREAM,MSGL_ERR, "Seek failed\n"); | |
352 return 0; | |
353 } | |
1 | 354 } |
355 // putchar('.');fflush(stdout); | |
356 //} else { | |
357 // putchar('%');fflush(stdout); | |
358 } | |
359 | |
360 stream_fill_buffer(s); | |
1999 | 361 if(pos>=0 && pos<=s->buf_len){ |
1 | 362 s->buf_pos=pos; // byte position in sector |
363 return 1; | |
364 } | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1642
diff
changeset
|
365 |
1999 | 366 // if(pos==s->buf_len) printf("XXX Seek to last byte of file -> EOF\n"); |
367 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
368 #ifdef _LARGEFILE_SOURCE |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1642
diff
changeset
|
369 mp_msg(MSGT_STREAM,MSGL_V,"stream_seek: WARNING! Can't seek to 0x%llX !\n",(long long)(pos+newpos)); |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
370 #else |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1642
diff
changeset
|
371 mp_msg(MSGT_STREAM,MSGL_V,"stream_seek: WARNING! Can't seek to 0x%X !\n",(pos+newpos)); |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1177
diff
changeset
|
372 #endif |
1 | 373 return 0; |
374 } | |
375 | |
376 | |
377 void stream_reset(stream_t *s){ | |
378 if(s->eof){ | |
379 s->pos=0; //ftell(f); | |
380 // s->buf_pos=s->buf_len=0; | |
381 s->eof=0; | |
382 } | |
383 //stream_seek(s,0); | |
384 } | |
385 | |
2144 | 386 stream_t* new_memory_stream(unsigned char* data,int len){ |
387 stream_t *s=malloc(sizeof(stream_t)+len); | |
6892
b8e0b1c54940
10000l - didn't clear new stream struct, causing possible sig11 in cache layer
arpi
parents:
6814
diff
changeset
|
388 memset(s,0,sizeof(stream_t)); |
2144 | 389 s->fd=-1; |
390 s->type=STREAMTYPE_MEMORY; | |
391 s->buf_pos=0; s->buf_len=len; | |
392 s->start_pos=0; s->end_pos=len; | |
393 stream_reset(s); | |
394 s->pos=len; | |
395 memcpy(s->buffer,data,len); | |
396 return s; | |
397 } | |
398 | |
1 | 399 stream_t* new_stream(int fd,int type){ |
400 stream_t *s=malloc(sizeof(stream_t)); | |
3291 | 401 if(s==NULL) return NULL; |
402 memset(s,0,sizeof(stream_t)); | |
403 | |
1 | 404 s->fd=fd; |
405 s->type=type; | |
180 | 406 s->buf_pos=s->buf_len=0; |
598 | 407 s->start_pos=s->end_pos=0; |
1642 | 408 s->priv=NULL; |
7407 | 409 s->url=NULL; |
2322 | 410 s->cache_pid=0; |
1 | 411 stream_reset(s); |
412 return s; | |
413 } | |
414 | |
415 void free_stream(stream_t *s){ | |
6138
523014df7d32
big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents:
5982
diff
changeset
|
416 // printf("\n*** free_stream() called ***\n"); |
9798 | 417 #ifdef USE_STREAM_CACHE |
4893 | 418 if(s->cache_pid) { |
5982 | 419 // kill(s->cache_pid,SIGTERM); |
420 kill(s->cache_pid,SIGKILL); | |
4893 | 421 waitpid(s->cache_pid,NULL,0); |
6810 | 422 shmem_free(s->cache_data); |
4893 | 423 } |
9798 | 424 #endif |
6300
c31d15532695
file descriptor leak - found by Marc Espie <espie@nerim.net>
arpi
parents:
6138
diff
changeset
|
425 if(s->fd>0) close(s->fd); |
6479 | 426 switch(s->type) { |
7630
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
427 #ifdef LIBSMBCLIENT |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
428 case STREAMTYPE_SMB: |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
429 smbc_close(s->fd); |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
430 break; |
4c51ce16c4a2
smb:// (samba client) support by Vladimir Moushkov <vlindos_mpdev@abv.bg>
arpi
parents:
7408
diff
changeset
|
431 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
432 #ifdef HAVE_CDDA |
6479 | 433 case STREAMTYPE_CDDA: |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
434 close_cdda(s); |
6479 | 435 break; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6300
diff
changeset
|
436 #endif |
9610 | 437 #ifdef HAS_DVBIN_SUPPORT |
438 case STREAMTYPE_DVB: | |
439 dvbin_close(s->priv); | |
440 break; | |
441 #endif | |
442 | |
6479 | 443 #ifdef USE_DVDREAD |
444 case STREAMTYPE_DVD: | |
445 dvd_close(s->priv); | |
446 #endif | |
9794 | 447 default: |
448 if(s->close) s->close(s); | |
449 } | |
450 // Disabled atm, i don't like that. s->priv can be anything after all | |
451 // streams should destroy their priv on close | |
452 //if(s->priv) free(s->priv); | |
453 if(s->url) free(s->url); | |
1 | 454 free(s); |
455 } | |
456 | |
5133
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
457 stream_t* new_ds_stream(demux_stream_t *ds) { |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
458 stream_t* s = new_stream(-1,STREAMTYPE_DS); |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
459 s->priv = ds; |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
460 return s; |
9841a86d66f9
Initial ogg demuxer. No seeking, a/v sync is broken. Support avi
albeu
parents:
4893
diff
changeset
|
461 } |