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