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