Mercurial > mplayer.hg
annotate libmpdemux/open.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 | 3bcd52b7b2ae |
children | c52dc92ebf4b |
rev | line source |
---|---|
1467 | 1 |
4343
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
2 #include <ctype.h> |
1467 | 3 #include <stdio.h> |
4 #include <stdlib.h> | |
5 #include <string.h> | |
6 #include <unistd.h> | |
7 #include <fcntl.h> | |
8 | |
9 #include "config.h" | |
1567 | 10 #include "mp_msg.h" |
1584 | 11 #include "help_mp.h" |
1467 | 12 |
1468 | 13 #ifdef __FreeBSD__ |
14 #include <sys/cdrio.h> | |
15 #endif | |
16 | |
4343
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
17 #include "../cfgparser.h" |
1467 | 18 #include "stream.h" |
1482 | 19 #include "demuxer.h" |
4551 | 20 #include "mf.h" |
1467 | 21 |
22 #ifdef STREAMING | |
23 #include "url.h" | |
24 #include "network.h" | |
25 static URL_t* url; | |
26 #endif | |
27 | |
1596 | 28 int dvd_title=0; |
29 int dvd_chapter=1; | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
30 int dvd_last_chapter=0; |
1596 | 31 int dvd_angle=1; |
4222
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
32 char* dvd_device=NULL; |
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
33 char* cdrom_device=NULL; |
5472 | 34 int dvd_nav=0; /* use libdvdnav? */ |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
35 |
5381 | 36 #ifdef USE_DVDNAV |
5472 | 37 #include "dvdnav_stream.h" |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
38 #endif |
1596 | 39 |
40 #ifdef USE_DVDREAD | |
41 | |
1875 | 42 #define DVDREAD_VERSION(maj,min,micro) ((maj)*10000 + (min)*100 + (micro)) |
43 | |
44 /* | |
45 * Try to autodetect the libdvd-0.9.0 library | |
46 * (0.9.0 removed the <dvdread/dvd_udf.h> header, and moved the two defines | |
47 * DVD_VIDEO_LB_LEN and MAX_UDF_FILE_NAME_LEN from it to | |
48 * <dvdread/dvd_reader.h>) | |
49 */ | |
50 #if defined(DVD_VIDEO_LB_LEN) && defined(MAX_UDF_FILE_NAME_LEN) | |
51 #define LIBDVDREAD_VERSION DVDREAD_VERSION(0,9,0) | |
52 #else | |
53 #define LIBDVDREAD_VERSION DVDREAD_VERSION(0,8,0) | |
54 #endif | |
55 | |
2935 | 56 char * dvd_audio_stream_types[8] = |
57 { "ac3","unknown","mpeg1","mpeg2ext","lpcm","unknown","dts" }; | |
1596 | 58 |
6651 | 59 char * dvd_audio_stream_channels[6] = |
60 { "unknown", "stereo", "unknown", "unknown", "unknown", "5.1" }; | |
1596 | 61 #endif |
62 | |
1467 | 63 extern int vcd_get_track_end(int fd,int track); |
64 | |
2790 | 65 #ifdef USE_TV |
66 #include "tv.h" | |
2802 | 67 tvi_handle_t *tv_handler; |
2931 | 68 |
69 extern int stream_open_tv(stream_t *stream, tvi_handle_t *tvh); | |
2790 | 70 #endif |
71 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
72 #ifdef HAVE_CDDA |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
73 stream_t* open_cdda(char* dev,char* track); |
6474 | 74 stream_t* cddb_open(char* dev,char* track); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
75 #endif |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
76 |
1467 | 77 // Open a new stream (stdin/file/vcd/url) |
78 | |
79 stream_t* open_stream(char* filename,int vcd_track,int* file_format){ | |
80 stream_t* stream=NULL; | |
81 int f=-1; | |
82 off_t len; | |
83 #ifdef VCD_CACHE | |
84 int vcd_cache_size=128; | |
85 #endif | |
86 #ifdef __FreeBSD__ | |
87 int bsize = VCD_SECTOR_SIZE; | |
88 #endif | |
89 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
90 #ifdef HAVE_CDDA |
6490
d7605d08b32f
filename can be NULL. Fix the conflict between cdda and dvdnav.
albeu
parents:
6479
diff
changeset
|
91 if(filename && strncmp("cdda://",filename,7) == 0) |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
92 return open_cdda(cdrom_device ? cdrom_device : DEFAULT_CDROM_DEVICE,filename+7); |
6490
d7605d08b32f
filename can be NULL. Fix the conflict between cdda and dvdnav.
albeu
parents:
6479
diff
changeset
|
93 if(filename && strncmp("cddb://",filename,7) == 0) |
6474 | 94 return cddb_open(cdrom_device ? cdrom_device : DEFAULT_CDROM_DEVICE,filename+7); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
95 #endif |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
96 |
1467 | 97 //============ Open VideoCD track ============== |
3261 | 98 #ifdef HAVE_VCD |
1467 | 99 if(vcd_track){ |
100 int ret,ret2; | |
4222
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
101 if(!cdrom_device) cdrom_device=DEFAULT_CDROM_DEVICE; |
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
102 f=open(cdrom_device,O_RDONLY); |
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
103 if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,cdrom_device);return NULL; } |
1467 | 104 vcd_read_toc(f); |
105 ret2=vcd_get_track_end(f,vcd_track); | |
1584 | 106 if(ret2<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n");return NULL;} |
1467 | 107 ret=vcd_seek_to_track(f,vcd_track); |
1584 | 108 if(ret<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");return NULL;} |
1467 | 109 // seek_to_byte+=ret; |
1567 | 110 mp_msg(MSGT_OPEN,MSGL_V,"VCD start byte position: 0x%X end: 0x%X\n",ret,ret2); |
1467 | 111 #ifdef VCD_CACHE |
112 vcd_cache_init(vcd_cache_size); | |
113 #endif | |
114 #ifdef __FreeBSD__ | |
115 if (ioctl (f, CDRIOCSETBLOCKSIZE, &bsize) == -1) { | |
116 perror ( "Error in CDRIOCSETBLOCKSIZE"); | |
117 } | |
118 #endif | |
119 stream=new_stream(f,STREAMTYPE_VCD); | |
120 stream->start_pos=ret; | |
121 stream->end_pos=ret2; | |
122 return stream; | |
123 } | |
3261 | 124 #endif |
1467 | 125 |
1596 | 126 //============ Open DVD title ============== |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
127 #ifdef USE_DVDNAV |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
128 if(dvd_nav){ |
5472 | 129 dvdnav_priv_t *dvdnav_priv; |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
130 int event,len,tmplen=0; |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
131 |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
132 stream=new_stream(-1,STREAMTYPE_DVDNAV); |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
133 if (!stream) { |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
134 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_Exit_error); |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
135 return NULL; |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
136 } |
5472 | 137 |
138 if(!filename) filename=DEFAULT_DVD_DEVICE; | |
139 if (!(dvdnav_priv=new_dvdnav_stream(filename))) { | |
140 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename); | |
141 return NULL; | |
142 } | |
143 | |
144 stream->priv=(void*)dvdnav_priv; | |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
145 return stream; |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
146 } |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
147 #endif |
1596 | 148 #ifdef USE_DVDREAD |
149 if(dvd_title){ | |
2050 | 150 // int ret,ret2; |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
151 dvd_priv_t *d; |
1596 | 152 int ttn,pgc_id,pgn; |
153 dvd_reader_t *dvd; | |
154 dvd_file_t *title; | |
155 ifo_handle_t *vmg_file; | |
156 tt_srpt_t *tt_srpt; | |
157 ifo_handle_t *vts_file; | |
158 /** | |
159 * Open the disc. | |
160 */ | |
4222
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
161 if(!dvd_device) dvd_device=DEFAULT_DVD_DEVICE; |
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
162 dvd = DVDOpen(dvd_device); |
1596 | 163 if( !dvd ) { |
4222
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
164 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,dvd_device); |
1596 | 165 return NULL; |
166 } | |
167 | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
168 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_DVDwait); |
1596 | 169 |
170 /** | |
171 * Load the video manager to find out the information about the titles on | |
172 * this disc. | |
173 */ | |
174 vmg_file = ifoOpen( dvd, 0 ); | |
175 if( !vmg_file ) { | |
176 mp_msg(MSGT_OPEN,MSGL_ERR, "Can't open VMG info!\n"); | |
177 DVDClose( dvd ); | |
178 return NULL; | |
179 } | |
180 tt_srpt = vmg_file->tt_srpt; | |
181 /** | |
182 * Make sure our title number is valid. | |
183 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
184 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumTitles, |
1596 | 185 tt_srpt->nr_of_srpts ); |
186 if( dvd_title < 1 || dvd_title > tt_srpt->nr_of_srpts ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
187 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidTitle, dvd_title); |
1596 | 188 ifoClose( vmg_file ); |
189 DVDClose( dvd ); | |
190 return NULL; | |
191 } | |
192 --dvd_title; // remap 1.. -> 0.. | |
193 /** | |
194 * Make sure the chapter number is valid for this title. | |
195 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
196 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumChapters, |
1596 | 197 tt_srpt->title[dvd_title].nr_of_ptts ); |
198 if( dvd_chapter<1 || dvd_chapter>tt_srpt->title[dvd_title].nr_of_ptts ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
199 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidChapter, dvd_chapter); |
1596 | 200 ifoClose( vmg_file ); |
201 DVDClose( dvd ); | |
202 return NULL; | |
203 } | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
204 if( dvd_last_chapter>0 ) { |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
205 if ( dvd_last_chapter<dvd_chapter || dvd_last_chapter>tt_srpt->title[dvd_title].nr_of_ptts ) { |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
206 mp_msg(MSGT_OPEN,MSGL_ERR, "Invalid DVD last chapter number: %d\n", dvd_last_chapter); |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
207 ifoClose( vmg_file ); |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
208 DVDClose( dvd ); |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
209 return NULL; |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
210 } |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
211 } |
1596 | 212 --dvd_chapter; // remap 1.. -> 0.. |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
213 /* XXX No need to remap dvd_last_chapter */ |
1596 | 214 /** |
215 * Make sure the angle number is valid for this title. | |
216 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
217 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumAngles, |
1596 | 218 tt_srpt->title[dvd_title].nr_of_angles ); |
219 if( dvd_angle<1 || dvd_angle>tt_srpt->title[dvd_title].nr_of_angles ) { | |
1977 | 220 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidAngle, dvd_angle); |
1596 | 221 ifoClose( vmg_file ); |
222 DVDClose( dvd ); | |
223 return NULL; | |
224 } | |
1617 | 225 --dvd_angle; // remap 1.. -> 0.. |
1596 | 226 /** |
227 * Load the VTS information for the title set our title is in. | |
228 */ | |
229 vts_file = ifoOpen( dvd, tt_srpt->title[dvd_title].title_set_nr ); | |
230 if( !vts_file ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
231 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoIFO, |
1596 | 232 tt_srpt->title[dvd_title].title_set_nr ); |
233 ifoClose( vmg_file ); | |
234 DVDClose( dvd ); | |
235 return NULL; | |
236 } | |
237 /** | |
238 * We've got enough info, time to open the title set data. | |
239 */ | |
240 title = DVDOpenFile( dvd, tt_srpt->title[dvd_title].title_set_nr, | |
241 DVD_READ_TITLE_VOBS ); | |
242 if( !title ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
243 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoVOBs, |
1596 | 244 tt_srpt->title[dvd_title].title_set_nr ); |
245 ifoClose( vts_file ); | |
246 ifoClose( vmg_file ); | |
247 DVDClose( dvd ); | |
248 return NULL; | |
249 } | |
250 | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
251 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDopenOk); |
1596 | 252 // store data |
253 d=malloc(sizeof(dvd_priv_t)); memset(d,0,sizeof(dvd_priv_t)); | |
254 d->dvd=dvd; | |
255 d->title=title; | |
256 d->vmg_file=vmg_file; | |
257 d->tt_srpt=tt_srpt; | |
258 d->vts_file=vts_file; | |
259 | |
260 /** | |
2935 | 261 * Check number of audio channels and types |
262 */ | |
263 { | |
264 int ac3aid = 128; | |
265 int mpegaid = 0; | |
266 int pcmaid = 160; | |
267 | |
268 d->nr_of_channels=0; | |
269 | |
270 if ( vts_file->vts_pgcit ) | |
271 { | |
272 int i; | |
273 for ( i=0;i<8;i++ ) | |
274 if ( vts_file->vts_pgcit->pgci_srp[0].pgc->audio_control[i] & 0x8000 ) | |
275 { | |
276 audio_attr_t * audio = &vts_file->vtsi_mat->vts_audio_attr[i]; | |
277 int language = 0; | |
278 char tmp[] = "unknown"; | |
279 | |
280 if ( audio->lang_type == 1 ) | |
281 { | |
282 language=audio->lang_code; | |
283 tmp[0]=language>>8; | |
284 tmp[1]=language&0xff; | |
285 tmp[2]=0; | |
286 } | |
287 | |
288 d->audio_streams[d->nr_of_channels].language=language; | |
289 d->audio_streams[d->nr_of_channels].id=0; | |
290 switch ( audio->audio_format ) | |
291 { | |
292 case 0: // ac3 | |
293 case 6: // dts | |
294 d->audio_streams[d->nr_of_channels].id=ac3aid; | |
295 ac3aid++; | |
296 break; | |
297 case 2: // mpeg layer 1/2/3 | |
298 case 3: // mpeg2 ext | |
299 d->audio_streams[d->nr_of_channels].id=mpegaid; | |
300 mpegaid++; | |
301 break; | |
302 case 4: // lpcm | |
303 d->audio_streams[d->nr_of_channels].id=pcmaid; | |
304 pcmaid++; | |
305 break; | |
306 } | |
307 | |
6651 | 308 d->audio_streams[d->nr_of_channels].type=audio->audio_format; |
309 // Pontscho: to my mind, tha channels: | |
310 // 1 - stereo | |
311 // 5 - 5.1 | |
312 d->audio_streams[d->nr_of_channels].channels=audio->channels; | |
313 mp_msg(MSGT_OPEN,MSGL_V,"[open] audio stream: %d audio format: %s (%s) language: %s aid: %d\n", | |
2935 | 314 d->nr_of_channels, |
315 dvd_audio_stream_types[ audio->audio_format ], | |
6651 | 316 dvd_audio_stream_channels[ audio->channels ], |
2935 | 317 tmp, |
318 d->audio_streams[d->nr_of_channels].id | |
319 ); | |
3753 | 320 |
2935 | 321 d->nr_of_channels++; |
322 } | |
323 } | |
3048 | 324 mp_msg(MSGT_OPEN,MSGL_V,"[open] number of audio channels on disk: %d.\n",d->nr_of_channels ); |
325 } | |
326 | |
327 /** | |
328 * Check number of subtitles and language | |
329 */ | |
330 { | |
331 int i; | |
332 | |
333 d->nr_of_subtitles=0; | |
334 for ( i=0;i<32;i++ ) | |
335 if ( vts_file->vts_pgcit->pgci_srp[0].pgc->subp_control[i] & 0x80000000 ) | |
336 { | |
337 subp_attr_t * subtitle = &vts_file->vtsi_mat->vts_subp_attr[i]; | |
338 int language = 0; | |
339 char tmp[] = "unknown"; | |
340 | |
341 if ( subtitle->type == 1 ) | |
342 { | |
343 language=subtitle->lang_code; | |
344 tmp[0]=language>>8; | |
345 tmp[1]=language&0xff; | |
346 tmp[2]=0; | |
347 } | |
348 | |
349 d->subtitles[ d->nr_of_subtitles ].language=language; | |
350 d->subtitles[ d->nr_of_subtitles ].id=d->nr_of_subtitles; | |
351 | |
352 mp_msg(MSGT_OPEN,MSGL_V,"[open] subtitle ( sid ): %d language: %s\n", | |
353 d->nr_of_subtitles, | |
354 tmp | |
355 ); | |
356 d->nr_of_subtitles++; | |
357 } | |
358 mp_msg(MSGT_OPEN,MSGL_V,"[open] number of subtitles on disk: %d\n",d->nr_of_subtitles ); | |
2935 | 359 } |
360 | |
361 /** | |
1596 | 362 * Determine which program chain we want to watch. This is based on the |
363 * chapter number. | |
364 */ | |
365 ttn = tt_srpt->title[ dvd_title ].vts_ttn; // local | |
366 pgc_id = vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_chapter].pgcn; // local | |
367 pgn = vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_chapter].pgn; // local | |
368 d->cur_pgc = vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; | |
369 d->cur_cell = d->cur_pgc->program_map[pgn-1] - 1; // start playback here | |
370 d->packs_left=-1; // for Navi stuff | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
371 d->angle_seek=0; |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
372 /* XXX dvd_last_chapter is in the range 1..nr_of_ptts */ |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
373 if ( dvd_last_chapter > 0 && dvd_last_chapter < tt_srpt->title[ttn-1].nr_of_ptts ) { |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
374 pgn=vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_last_chapter].pgn; |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
375 d->last_cell=d->cur_pgc->program_map[pgn-1] - 1; |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
376 } |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
377 else |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
378 d->last_cell=d->cur_pgc->nr_of_cells; |
1596 | 379 |
6651 | 380 if( d->cur_pgc->cell_playback[d->cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; |
1596 | 381 d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; |
382 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
383 mp_msg(MSGT_DVD,MSGL_V, "DVD start cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack); | |
384 | |
385 // ... (unimplemented) | |
386 // return NULL; | |
387 stream=new_stream(-1,STREAMTYPE_DVD); | |
388 stream->start_pos=(off_t)d->cur_pack*2048; | |
4390 | 389 stream->end_pos=(off_t)(d->cur_pgc->cell_playback[d->last_cell-1].last_sector)*2048; |
5932
1ebeebca86f3
printf to mp_msg + warning msg from MSGL_INFO to MSGT_WARN
albeu
parents:
5819
diff
changeset
|
390 mp_msg(MSGT_DVD,MSGL_V,"DVD start=%d end=%d \n",d->cur_pack,d->cur_pgc->cell_playback[d->last_cell-1].last_sector); |
1596 | 391 stream->priv=(void*)d; |
392 return stream; | |
393 } | |
394 #endif | |
395 | |
2790 | 396 #ifdef USE_TV |
397 //============ Check for TV-input ==== | |
2931 | 398 if (tv_param_on == 1) |
2790 | 399 { |
2931 | 400 /* create stream */ |
401 stream = new_stream(-1, STREAMTYPE_TV); | |
402 if (!stream) | |
403 return(NULL); | |
404 | |
405 /* create tvi handler */ | |
2790 | 406 tv_handler = tv_begin(); |
407 if (!tv_handler) | |
408 return(NULL); | |
2931 | 409 |
410 /* preinit */ | |
411 if (!tv_init(tv_handler)) | |
412 goto tv_err; | |
413 | |
414 if (!stream_open_tv(stream, tv_handler)) | |
415 goto tv_err; | |
416 | |
417 return(stream); | |
418 | |
419 /* something went wrong - uninit */ | |
420 tv_err: | |
2837 | 421 tv_uninit(tv_handler); |
2802 | 422 return(NULL); |
2790 | 423 } |
424 #endif | |
425 | |
4551 | 426 //============ Check for multi file-input ==== |
427 if (mf_support == 1) | |
428 { | |
429 /* create stream */ | |
430 stream = new_stream(-1, STREAMTYPE_MF); | |
431 if (!stream) | |
432 return(NULL); | |
433 | |
434 if (!stream_open_mf(filename, stream)) | |
435 return(NULL); | |
436 | |
437 return(stream); | |
438 } | |
1467 | 439 |
440 #ifdef STREAMING | |
441 url = url_new(filename); | |
442 if(url) { | |
4251
05affdf4bdcd
Moved network related code from open.c to network.c
bertrand
parents:
4222
diff
changeset
|
443 stream=new_stream(f,STREAMTYPE_STREAM); |
4729
f51bd827ed1c
fixed MP3 ICY detection, return detected file format for open_stream
alex
parents:
4551
diff
changeset
|
444 if( streaming_start( stream, file_format, url )<0){ |
4251
05affdf4bdcd
Moved network related code from open.c to network.c
bertrand
parents:
4222
diff
changeset
|
445 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, filename); |
05affdf4bdcd
Moved network related code from open.c to network.c
bertrand
parents:
4222
diff
changeset
|
446 url_free(url); |
05affdf4bdcd
Moved network related code from open.c to network.c
bertrand
parents:
4222
diff
changeset
|
447 return NULL; |
4046
f732854e3d16
Kept the HTTP connection open after autodetect, so
bertrand
parents:
3753
diff
changeset
|
448 } |
1584 | 449 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ConnToServer, url->hostname ); |
3045
6c14fd789ba5
Changed the order of processing the network opening.
bertrand
parents:
2935
diff
changeset
|
450 url_free(url); |
2315 | 451 return stream; |
1467 | 452 } |
453 #endif | |
454 | |
6320
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
455 //============ Open STDIN or plain FILE ============ |
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
456 if(!strcmp(filename,"-")){ |
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
457 // read from stdin |
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
458 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ReadSTDIN); |
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
459 f=0; // 0=stdin |
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
460 } else { |
1467 | 461 f=open(filename,O_RDONLY); |
1584 | 462 if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);return NULL; } |
6320
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
463 } |
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
464 |
1467 | 465 len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET); |
466 if (len == -1) | |
6320
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
467 return new_stream(f,STREAMTYPE_STREAM); // open as stream |
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
468 |
1467 | 469 #ifdef _LARGEFILE_SOURCE |
1567 | 470 mp_msg(MSGT_OPEN,MSGL_V,"File size is %lld bytes\n", (long long)len); |
1467 | 471 #else |
1567 | 472 mp_msg(MSGT_OPEN,MSGL_V,"File size is %u bytes\n", (unsigned int)len); |
1467 | 473 #endif |
474 stream=new_stream(f,STREAMTYPE_FILE); | |
475 stream->end_pos=len; | |
476 return stream; | |
477 } | |
1596 | 478 |
4343
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
479 int dvd_parse_chapter_range(struct config *conf, const char *range){ |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
480 char *s, *t; |
4344 | 481 conf; /* prevent warning from GCC */ |
482 s = range; | |
4343
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
483 dvd_chapter = 1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
484 dvd_last_chapter = 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
485 if (*range && isdigit(*range)) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
486 dvd_chapter = strtol(range, &s, 10); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
487 if (range == s) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
488 mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
489 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
490 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
491 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
492 if (*s == 0) |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
493 return 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
494 else if (*s != '-') { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
495 mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
496 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
497 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
498 ++s; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
499 if (*s == 0) |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
500 return 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
501 if (! isdigit(*s)) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
502 mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
503 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
504 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
505 dvd_last_chapter = strtol(s, &t, 10); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
506 if (s == t || *t) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
507 mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
508 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
509 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
510 return 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
511 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
512 |
3753 | 513 #ifdef USE_DVDREAD |
1596 | 514 |
3753 | 515 int dvd_aid_from_lang(stream_t *stream, unsigned char* lang){ |
516 dvd_priv_t *d=stream->priv; | |
517 int code,i; | |
518 while(lang && strlen(lang)>=2){ | |
519 code=lang[1]|(lang[0]<<8); | |
520 for(i=0;i<d->nr_of_channels;i++){ | |
521 if(d->audio_streams[i].language==code){ | |
522 mp_msg(MSGT_OPEN,MSGL_INFO,"Selected DVD audio channel: %d language: %c%c\n", | |
523 d->audio_streams[i].id, lang[0],lang[1]); | |
524 return d->audio_streams[i].id; | |
525 } | |
526 // printf("%X != %X (%c%c)\n",code,d->audio_streams[i].language,lang[0],lang[1]); | |
527 } | |
528 lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; | |
529 } | |
5932
1ebeebca86f3
printf to mp_msg + warning msg from MSGL_INFO to MSGT_WARN
albeu
parents:
5819
diff
changeset
|
530 mp_msg(MSGT_OPEN,MSGL_WARN,"No matching DVD audio language found!\n"); |
3753 | 531 return -1; |
532 } | |
533 | |
534 int dvd_sid_from_lang(stream_t *stream, unsigned char* lang){ | |
535 dvd_priv_t *d=stream->priv; | |
536 int code,i; | |
537 while(lang && strlen(lang)>=2){ | |
538 code=lang[1]|(lang[0]<<8); | |
539 for(i=0;i<d->nr_of_subtitles;i++){ | |
540 if(d->subtitles[i].language==code){ | |
541 mp_msg(MSGT_OPEN,MSGL_INFO,"Selected DVD subtitle channel: %d language: %c%c\n", | |
542 d->subtitles[i].id, lang[0],lang[1]); | |
543 return d->subtitles[i].id; | |
544 } | |
545 } | |
546 lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; | |
547 } | |
5932
1ebeebca86f3
printf to mp_msg + warning msg from MSGL_INFO to MSGT_WARN
albeu
parents:
5819
diff
changeset
|
548 mp_msg(MSGT_OPEN,MSGL_WARN,"No matching DVD subtitle language found!\n"); |
3753 | 549 return -1; |
550 } | |
1596 | 551 |
552 static int dvd_next_cell(dvd_priv_t *d){ | |
553 int next_cell=d->cur_cell; | |
1616 | 554 |
555 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next1=0x%X \n",next_cell); | |
1596 | 556 |
557 if( d->cur_pgc->cell_playback[ next_cell ].block_type | |
558 == BLOCK_TYPE_ANGLE_BLOCK ) { | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
559 while(next_cell<d->last_cell){ |
1596 | 560 if( d->cur_pgc->cell_playback[next_cell].block_mode |
561 == BLOCK_MODE_LAST_CELL ) break; | |
562 ++next_cell; | |
563 } | |
564 } | |
1616 | 565 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next2=0x%X \n",next_cell); |
1596 | 566 |
567 ++next_cell; | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
568 if(next_cell>=d->last_cell) return -1; // EOF |
1596 | 569 if( d->cur_pgc->cell_playback[next_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ){ |
570 next_cell+=dvd_angle; | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
571 if(next_cell>=d->last_cell) return -1; // EOF |
1596 | 572 } |
1616 | 573 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next3=0x%X \n",next_cell); |
1596 | 574 return next_cell; |
575 } | |
576 | |
577 int dvd_read_sector(dvd_priv_t *d,unsigned char* data){ | |
578 int len; | |
579 | |
580 if(d->packs_left==0){ | |
581 /** | |
582 * If we're not at the end of this cell, we can determine the next | |
583 * VOBU to display using the VOBU_SRI information section of the | |
584 * DSI. Using this value correctly follows the current angle, | |
585 * avoiding the doubled scenes in The Matrix, and makes our life | |
586 * really happy. | |
587 * | |
588 * Otherwise, we set our next address past the end of this cell to | |
589 * force the code above to go to the next cell in the program. | |
590 */ | |
591 if( d->dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL ) { | |
592 d->cur_pack= d->dsi_pack.dsi_gi.nv_pck_lbn + | |
593 ( d->dsi_pack.vobu_sri.next_vobu & 0x7fffffff ); | |
594 mp_msg(MSGT_DVD,MSGL_DBG2, "Navi new pos=0x%X \n",d->cur_pack); | |
595 } else { | |
596 // end of cell! find next cell! | |
597 mp_msg(MSGT_DVD,MSGL_V, "--- END OF CELL !!! ---\n"); | |
598 d->cur_pack=d->cell_last_pack+1; | |
599 } | |
600 } | |
601 | |
602 read_next: | |
603 | |
604 if(d->cur_pack>d->cell_last_pack){ | |
605 // end of cell! | |
606 int next=dvd_next_cell(d); | |
607 if(next>=0){ | |
608 d->cur_cell=next; | |
609 | |
1615 | 610 // if( d->cur_pgc->cell_playback[d->cur_cell].block_type |
611 // == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; | |
1596 | 612 d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; |
613 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
614 mp_msg(MSGT_DVD,MSGL_V, "DVD next cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack); | |
615 | |
616 } else return -1; // EOF | |
617 } | |
618 | |
619 len = DVDReadBlocks( d->title, d->cur_pack, 1, data ); | |
620 if(!len) return -1; //error | |
621 | |
622 if(data[38]==0 && data[39]==0 && data[40]==1 && data[41]==0xBF && | |
623 data[1024]==0 && data[1025]==0 && data[1026]==1 && data[1027]==0xBF){ | |
624 // found a Navi packet!!! | |
1875 | 625 #if LIBDVDREAD_VERSION >= DVDREAD_VERSION(0,9,0) |
626 navRead_DSI( &d->dsi_pack, &(data[ DSI_START_BYTE ]) ); | |
627 #else | |
1596 | 628 navRead_DSI( &d->dsi_pack, &(data[ DSI_START_BYTE ]), sizeof(dsi_t) ); |
1875 | 629 #endif |
1596 | 630 if(d->cur_pack != d->dsi_pack.dsi_gi.nv_pck_lbn ){ |
631 mp_msg(MSGT_DVD,MSGL_V, "Invalid NAVI packet! lba=0x%X navi=0x%X \n", | |
632 d->cur_pack,d->dsi_pack.dsi_gi.nv_pck_lbn); | |
633 } else { | |
634 // process! | |
635 d->packs_left = d->dsi_pack.dsi_gi.vobu_ea; | |
636 mp_msg(MSGT_DVD,MSGL_DBG2, "Found NAVI packet! lba=0x%X len=%d \n",d->cur_pack,d->packs_left); | |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
637 //navPrint_DSI(&d->dsi_pack); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
638 mp_msg(MSGT_DVD,MSGL_DBG3,"\r### CELL %d: Navi: %d/%d IFO: %d/%d \n",d->cur_cell, |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
639 d->dsi_pack.dsi_gi.vobu_c_idn,d->dsi_pack.dsi_gi.vobu_vob_idn, |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
640 d->cur_pgc->cell_position[d->cur_cell].cell_nr, |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
641 d->cur_pgc->cell_position[d->cur_cell].vob_id_nr); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
642 |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
643 if(d->angle_seek){ |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
644 int i,skip=0; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
645 for(i=0;i<9;i++) // check if all values zero: |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
646 if((skip=d->dsi_pack.sml_agli.data[i].address)!=0) break; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
647 if(skip){ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
648 // sml_agli table has valid data (at least one non-zero): |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
649 d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
650 d->dsi_pack.sml_agli.data[dvd_angle].address; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
651 d->angle_seek=0; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
652 mp_msg(MSGT_DVD,MSGL_V, "Angle-seek synced using sml_agli map! new_lba=0x%X \n",d->cur_pack); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
653 } else { |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
654 // check if we're in the right cell, jump otherwise: |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
655 if( (d->dsi_pack.dsi_gi.vobu_c_idn==d->cur_pgc->cell_position[d->cur_cell].cell_nr) && |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
656 (d->dsi_pack.dsi_gi.vobu_vob_idn==d->cur_pgc->cell_position[d->cur_cell].vob_id_nr) ){ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
657 d->angle_seek=0; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
658 mp_msg(MSGT_DVD,MSGL_V, "Angle-seek synced by cell/vob IDN search! \n"); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
659 } else { |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
660 // wrong angle, skip this vobu: |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
661 d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
662 d->dsi_pack.dsi_gi.vobu_ea; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
663 d->angle_seek=2; // DEBUG |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
664 } |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
665 } |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
666 } |
1596 | 667 } |
668 ++d->cur_pack; | |
669 goto read_next; | |
670 } | |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
671 |
1596 | 672 ++d->cur_pack; |
673 if(d->packs_left>=0) --d->packs_left; | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
674 |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
675 if(d->angle_seek){ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
676 if(d->angle_seek==2) mp_msg(MSGT_DVD,MSGL_V, "!!! warning! reading packet while angle_seek !!!\n"); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
677 goto read_next; // searching for Navi packet |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
678 } |
1596 | 679 |
680 return d->cur_pack-1; | |
681 } | |
682 | |
683 void dvd_seek(dvd_priv_t *d,int pos){ | |
684 d->packs_left=-1; | |
685 d->cur_pack=pos; | |
686 | |
687 // check if we stay in current cell (speedup things, and avoid angle skip) | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
688 if(d->cur_pack>d->cell_last_pack || |
1596 | 689 d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){ |
690 | |
691 // ok, cell change, find the right cell! | |
692 d->cur_cell=0; | |
693 if( d->cur_pgc->cell_playback[d->cur_cell].block_type | |
694 == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; | |
695 | |
696 while(1){ | |
697 int next; | |
698 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
699 if(d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){ | |
700 d->cur_pack=d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; | |
701 break; | |
702 } | |
703 if(d->cur_pack<=d->cell_last_pack) break; // ok, we find it! :) | |
704 next=dvd_next_cell(d); | |
705 if(next<0){ | |
706 // d->cur_pack=d->cell_last_pack+1; | |
707 break; // we're after the last cell | |
708 } | |
709 d->cur_cell=next; | |
710 } | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
711 |
1596 | 712 } |
713 | |
714 mp_msg(MSGT_DVD,MSGL_V, "DVD Seek! lba=0x%X cell=%d packs: 0x%X-0x%X \n", | |
715 d->cur_pack,d->cur_cell,d->cur_pgc->cell_playback[ d->cur_cell ].first_sector,d->cell_last_pack); | |
716 | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
717 // if we're in interleaved multi-angle cell, find the right angle chain! |
1596 | 718 // (read Navi block, and use the seamless angle jump table) |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
719 d->angle_seek=1; |
1596 | 720 |
721 } | |
722 | |
6479 | 723 void dvd_close(dvd_priv_t *d) { |
724 ifoClose(d->vts_file); | |
725 ifoClose(d->vmg_file); | |
726 DVDCloseFile(d->title); | |
727 DVDClose(d->dvd); | |
728 } | |
729 | |
1596 | 730 #endif |