annotate libmpdemux/open.c @ 5739:b7e0cf4cb7a9

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