annotate open.c @ 2113:42291b22243f

mp-iso-arial-ize
author gabucino
date Sat, 06 Oct 2001 19:28:04 +0000
parents 18f4dd5d568f
children
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
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
2 #include <stdio.h>
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
3 #include <stdlib.h>
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
4 #include <string.h>
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
5 #include <unistd.h>
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
6 #include <fcntl.h>
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
7
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
8 #include "config.h"
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1482
diff changeset
9 #include "mp_msg.h"
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
10 #include "help_mp.h"
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
11
1468
fbed9c34069c freebsd fix
arpi
parents: 1467
diff changeset
12 #ifdef __FreeBSD__
fbed9c34069c freebsd fix
arpi
parents: 1467
diff changeset
13 #include <sys/cdrio.h>
fbed9c34069c freebsd fix
arpi
parents: 1467
diff changeset
14 #endif
fbed9c34069c freebsd fix
arpi
parents: 1467
diff changeset
15
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
16 #include "stream.h"
1482
4800d1c58dab --enable-streaming fix
arpi
parents: 1468
diff changeset
17 #include "demuxer.h"
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
18
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
19 #ifdef STREAMING
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
20 #include "url.h"
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
21 #include "network.h"
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
22 static URL_t* url;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
23 #endif
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
24
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
25 int dvd_title=0;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
26 int dvd_chapter=1;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
27 int dvd_angle=1;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
28
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
29 #ifdef USE_DVDREAD
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
30
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
31 #include <dvdread/dvd_reader.h>
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
32 #include <dvdread/ifo_types.h>
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
33 #include <dvdread/ifo_read.h>
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
34 #include <dvdread/nav_read.h>
1875
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
35
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
36 #define DVDREAD_VERSION(maj,min,micro) ((maj)*10000 + (min)*100 + (micro))
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
37
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
38 /*
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
39 * Try to autodetect the libdvd-0.9.0 library
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
40 * (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
41 * 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
42 * <dvdread/dvd_reader.h>)
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
43 */
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
44 #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
45 #define LIBDVDREAD_VERSION DVDREAD_VERSION(0,9,0)
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
46 #else
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
47 #define LIBDVDREAD_VERSION DVDREAD_VERSION(0,8,0)
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
48 #endif
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
49
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
50
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
51 typedef struct {
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
52 dvd_reader_t *dvd;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
53 dvd_file_t *title;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
54 ifo_handle_t *vmg_file;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
55 tt_srpt_t *tt_srpt;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
56 ifo_handle_t *vts_file;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
57 vts_ptt_srpt_t *vts_ptt_srpt;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
58 pgc_t *cur_pgc;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
59 //
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
60 int cur_cell;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
61 int cur_pack;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
62 int cell_last_pack;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
63 // Navi:
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
64 int packs_left;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
65 dsi_t dsi_pack;
1609
84199d075839 ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents: 1596
diff changeset
66 int angle_seek;
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
67 } dvd_priv_t;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
68
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
69 #endif
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
70
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
71 extern int vcd_get_track_end(int fd,int track);
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
72
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
73 // Open a new stream (stdin/file/vcd/url)
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
74
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
75 stream_t* open_stream(char* filename,int vcd_track,int* file_format){
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
76 stream_t* stream=NULL;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
77 int f=-1;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
78 off_t len;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
79 #ifdef VCD_CACHE
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
80 int vcd_cache_size=128;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
81 #endif
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
82 #ifdef __FreeBSD__
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
83 int bsize = VCD_SECTOR_SIZE;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
84 #endif
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
85
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
86 //============ Open VideoCD track ==============
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
87 if(vcd_track){
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
88 int ret,ret2;
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
89 if(!filename) filename=DEFAULT_CDROM_DEVICE;
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
90 f=open(filename,O_RDONLY);
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
91 if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,filename);return NULL; }
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
92 vcd_read_toc(f);
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
93 ret2=vcd_get_track_end(f,vcd_track);
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
94 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
95 ret=vcd_seek_to_track(f,vcd_track);
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
96 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
97 // seek_to_byte+=ret;
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1482
diff changeset
98 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
99 #ifdef VCD_CACHE
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
100 vcd_cache_init(vcd_cache_size);
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
101 #endif
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
102 #ifdef __FreeBSD__
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
103 if (ioctl (f, CDRIOCSETBLOCKSIZE, &bsize) == -1) {
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
104 perror ( "Error in CDRIOCSETBLOCKSIZE");
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
105 }
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
106 #endif
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
107 stream=new_stream(f,STREAMTYPE_VCD);
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
108 stream->start_pos=ret;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
109 stream->end_pos=ret2;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
110 return stream;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
111 }
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
112
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
113 //============ Open DVD title ==============
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
114 #ifdef USE_DVDREAD
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
115 if(dvd_title){
2050
18f4dd5d568f -Wall warnings fixed
arpi
parents: 1977
diff changeset
116 // int ret,ret2;
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
117 dvd_priv_t *d;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
118 int ttn,pgc_id,pgn;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
119 dvd_reader_t *dvd;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
120 dvd_file_t *title;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
121 ifo_handle_t *vmg_file;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
122 tt_srpt_t *tt_srpt;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
123 ifo_handle_t *vts_file;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
124 /**
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
125 * Open the disc.
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
126 */
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
127 if(!filename) filename=DEFAULT_DVD_DEVICE;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
128 dvd = DVDOpen(filename);
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
129 if( !dvd ) {
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1899
diff changeset
130 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename);
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
131 return NULL;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
132 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
133
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1899
diff changeset
134 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_DVDwait);
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
135
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
136 /**
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
137 * Load the video manager to find out the information about the titles on
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
138 * this disc.
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
139 */
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
140 vmg_file = ifoOpen( dvd, 0 );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
141 if( !vmg_file ) {
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
142 mp_msg(MSGT_OPEN,MSGL_ERR, "Can't open VMG info!\n");
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
143 DVDClose( dvd );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
144 return NULL;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
145 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
146 tt_srpt = vmg_file->tt_srpt;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
147 /**
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
148 * Make sure our title number is valid.
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
149 */
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1899
diff changeset
150 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumTitles,
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
151 tt_srpt->nr_of_srpts );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
152 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
153 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidTitle, dvd_title);
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
154 ifoClose( vmg_file );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
155 DVDClose( dvd );
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 --dvd_title; // remap 1.. -> 0..
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
159 /**
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
160 * Make sure the chapter number is valid for this title.
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
161 */
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1899
diff changeset
162 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumChapters,
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
163 tt_srpt->title[dvd_title].nr_of_ptts );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
164 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
165 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidChapter, dvd_chapter);
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
166 ifoClose( vmg_file );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
167 DVDClose( dvd );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
168 return NULL;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
169 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
170 --dvd_chapter; // remap 1.. -> 0..
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
171 /**
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
172 * Make sure the angle number is valid for this title.
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
173 */
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1899
diff changeset
174 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumAngles,
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
175 tt_srpt->title[dvd_title].nr_of_angles );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
176 if( dvd_angle<1 || dvd_angle>tt_srpt->title[dvd_title].nr_of_angles ) {
1977
63634ecec611 faszom. typo.
arpi
parents: 1973
diff changeset
177 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidAngle, dvd_angle);
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
178 ifoClose( vmg_file );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
179 DVDClose( dvd );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
180 return NULL;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
181 }
1617
9e73b71b0cfa argh. yet another ugly bug: missing --dvd_angle
arpi
parents: 1616
diff changeset
182 --dvd_angle; // remap 1.. -> 0..
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
183 /**
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
184 * Load the VTS information for the title set our title is in.
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
185 */
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
186 vts_file = ifoOpen( dvd, tt_srpt->title[dvd_title].title_set_nr );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
187 if( !vts_file ) {
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1899
diff changeset
188 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoIFO,
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
189 tt_srpt->title[dvd_title].title_set_nr );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
190 ifoClose( vmg_file );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
191 DVDClose( dvd );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
192 return NULL;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
193 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
194 /**
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
195 * We've got enough info, time to open the title set data.
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
196 */
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
197 title = DVDOpenFile( dvd, tt_srpt->title[dvd_title].title_set_nr,
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
198 DVD_READ_TITLE_VOBS );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
199 if( !title ) {
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1899
diff changeset
200 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoVOBs,
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
201 tt_srpt->title[dvd_title].title_set_nr );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
202 ifoClose( vts_file );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
203 ifoClose( vmg_file );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
204 DVDClose( dvd );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
205 return NULL;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
206 }
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_DVDopenOk);
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
209 // store data
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
210 d=malloc(sizeof(dvd_priv_t)); memset(d,0,sizeof(dvd_priv_t));
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
211 d->dvd=dvd;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
212 d->title=title;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
213 d->vmg_file=vmg_file;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
214 d->tt_srpt=tt_srpt;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
215 d->vts_file=vts_file;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
216
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
217 /**
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
218 * Determine which program chain we want to watch. This is based on the
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
219 * chapter number.
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
220 */
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
221 ttn = tt_srpt->title[ dvd_title ].vts_ttn; // local
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
222 pgc_id = vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_chapter].pgcn; // local
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
223 pgn = vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_chapter].pgn; // local
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
224 d->cur_pgc = vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
225 d->cur_cell = d->cur_pgc->program_map[pgn-1] - 1; // start playback here
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
226 d->packs_left=-1; // for Navi stuff
1609
84199d075839 ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents: 1596
diff changeset
227 d->angle_seek=0;
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
228
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
229 if( d->cur_pgc->cell_playback[d->cur_cell].block_type
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
230 == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
231 d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
232 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
233 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
234
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
235 // ... (unimplemented)
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
236 // return NULL;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
237 stream=new_stream(-1,STREAMTYPE_DVD);
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
238 stream->start_pos=(off_t)d->cur_pack*2048;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
239 //stream->end_pos=0;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
240 stream->priv=(void*)d;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
241 return stream;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
242 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
243 #endif
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
244
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
245 //============ Open STDIN ============
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
246 if(!strcmp(filename,"-")){
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
247 // read from stdin
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
248 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ReadSTDIN);
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
249 f=0; // 0=stdin
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
250 stream=new_stream(f,STREAMTYPE_STREAM);
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
251 return stream;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
252 }
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
253
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
254 #ifdef STREAMING
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
255 url = url_new(filename);
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
256 if(url) {
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
257 (*file_format)=autodetectProtocol( url, &f );
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
258 if( (*file_format)==DEMUXER_TYPE_UNKNOWN ) {
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
259 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, filename);
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
260 url_free(url);
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
261 return NULL;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
262 }
1899
cf4165e34c13 pointer fix
arpi
parents: 1875
diff changeset
263 f=streaming_start( &url, f, *file_format );
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
264 if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, url->url); return NULL; }
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
265 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ConnToServer, url->hostname );
1467
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
266 stream=new_stream(f,STREAMTYPE_STREAM);
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
267 return NULL;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
268 }
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
269 #endif
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
270
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
271 //============ Open plain FILE ============
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
272 f=open(filename,O_RDONLY);
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
273 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
274 len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET);
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
275 if (len == -1)
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
276 perror("Error: lseek failed to obtain video file size");
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
277 else
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
278 if(verbose)
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
279 #ifdef _LARGEFILE_SOURCE
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1482
diff changeset
280 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
281 #else
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1482
diff changeset
282 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
283 #endif
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
284 stream=new_stream(f,STREAMTYPE_FILE);
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
285 stream->end_pos=len;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
286 return stream;
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
287
f352e1e951ba stream opening -> open.c, initialframes ignored
arpi
parents:
diff changeset
288 }
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
289
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
290
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
291 #ifdef USE_DVDREAD
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
292
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
293 static int dvd_next_cell(dvd_priv_t *d){
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
294 int next_cell=d->cur_cell;
1616
a3b4579e3806 some debug messages
arpi
parents: 1615
diff changeset
295
a3b4579e3806 some debug messages
arpi
parents: 1615
diff changeset
296 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next1=0x%X \n",next_cell);
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
297
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
298 if( d->cur_pgc->cell_playback[ next_cell ].block_type
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
299 == BLOCK_TYPE_ANGLE_BLOCK ) {
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
300 while(next_cell<d->cur_pgc->nr_of_cells){
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
301 if( d->cur_pgc->cell_playback[next_cell].block_mode
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
302 == BLOCK_MODE_LAST_CELL ) break;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
303 ++next_cell;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
304 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
305 }
1616
a3b4579e3806 some debug messages
arpi
parents: 1615
diff changeset
306 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next2=0x%X \n",next_cell);
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
307
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
308 ++next_cell;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
309 if(next_cell>=d->cur_pgc->nr_of_cells) return -1; // EOF
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
310 if( d->cur_pgc->cell_playback[next_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ){
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
311 next_cell+=dvd_angle;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
312 if(next_cell>=d->cur_pgc->nr_of_cells) return -1; // EOF
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
313 }
1616
a3b4579e3806 some debug messages
arpi
parents: 1615
diff changeset
314 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next3=0x%X \n",next_cell);
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
315 return next_cell;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
316 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
317
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
318 int dvd_read_sector(dvd_priv_t *d,unsigned char* data){
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
319 int len;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
320
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
321 if(d->packs_left==0){
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
322 /**
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
323 * If we're not at the end of this cell, we can determine the next
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
324 * VOBU to display using the VOBU_SRI information section of the
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
325 * DSI. Using this value correctly follows the current angle,
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
326 * avoiding the doubled scenes in The Matrix, and makes our life
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
327 * really happy.
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
328 *
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
329 * Otherwise, we set our next address past the end of this cell to
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
330 * force the code above to go to the next cell in the program.
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
331 */
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
332 if( d->dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL ) {
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
333 d->cur_pack= d->dsi_pack.dsi_gi.nv_pck_lbn +
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
334 ( d->dsi_pack.vobu_sri.next_vobu & 0x7fffffff );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
335 mp_msg(MSGT_DVD,MSGL_DBG2, "Navi new pos=0x%X \n",d->cur_pack);
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
336 } else {
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
337 // end of cell! find next cell!
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
338 mp_msg(MSGT_DVD,MSGL_V, "--- END OF CELL !!! ---\n");
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
339 d->cur_pack=d->cell_last_pack+1;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
340 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
341 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
342
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
343 read_next:
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
344
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
345 if(d->cur_pack>d->cell_last_pack){
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
346 // end of cell!
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
347 int next=dvd_next_cell(d);
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
348 if(next>=0){
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
349 d->cur_cell=next;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
350
1615
4e4eb37a4b76 removed double +angle stuff
arpi
parents: 1609
diff changeset
351 // if( d->cur_pgc->cell_playback[d->cur_cell].block_type
4e4eb37a4b76 removed double +angle stuff
arpi
parents: 1609
diff changeset
352 // == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle;
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
353 d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
354 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
355 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
356
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
357 } else return -1; // EOF
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
358 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
359
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
360 len = DVDReadBlocks( d->title, d->cur_pack, 1, data );
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
361 if(!len) return -1; //error
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
362
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
363 if(data[38]==0 && data[39]==0 && data[40]==1 && data[41]==0xBF &&
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
364 data[1024]==0 && data[1025]==0 && data[1026]==1 && data[1027]==0xBF){
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
365 // found a Navi packet!!!
1875
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
366 #if LIBDVDREAD_VERSION >= DVDREAD_VERSION(0,9,0)
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
367 navRead_DSI( &d->dsi_pack, &(data[ DSI_START_BYTE ]) );
73c771050065 Add support for libdvdread-0.9.0
jkeil
parents: 1617
diff changeset
368 #else
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
369 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
370 #endif
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
371 if(d->cur_pack != d->dsi_pack.dsi_gi.nv_pck_lbn ){
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
372 mp_msg(MSGT_DVD,MSGL_V, "Invalid NAVI packet! lba=0x%X navi=0x%X \n",
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
373 d->cur_pack,d->dsi_pack.dsi_gi.nv_pck_lbn);
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
374 } else {
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
375 // process!
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
376 d->packs_left = d->dsi_pack.dsi_gi.vobu_ea;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
377 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
378 if(d->angle_seek){
84199d075839 ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents: 1596
diff changeset
379 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
380 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
381 d->angle_seek=0;
84199d075839 ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents: 1596
diff changeset
382 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
383 }
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
384 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
385 ++d->cur_pack;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
386 goto read_next;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
387 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
388
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
389 ++d->cur_pack;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
390 if(d->packs_left>=0) --d->packs_left;
1609
84199d075839 ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents: 1596
diff changeset
391
84199d075839 ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents: 1596
diff changeset
392 if(d->angle_seek) goto read_next; // searching for Navi packet
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
393
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
394 return d->cur_pack-1;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
395 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
396
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
397 void dvd_seek(dvd_priv_t *d,int pos){
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
398 d->packs_left=-1;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
399 d->cur_pack=pos;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
400
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
401 // 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
402 if(d->cur_pack>d->cell_last_pack ||
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
403 d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
404
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
405 // ok, cell change, find the right cell!
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
406 d->cur_cell=0;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
407 if( d->cur_pgc->cell_playback[d->cur_cell].block_type
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
408 == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
409
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
410 while(1){
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
411 int next;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
412 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
413 if(d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
414 d->cur_pack=d->cur_pgc->cell_playback[ d->cur_cell ].first_sector;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
415 break;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
416 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
417 if(d->cur_pack<=d->cell_last_pack) break; // ok, we find it! :)
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
418 next=dvd_next_cell(d);
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
419 if(next<0){
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
420 // d->cur_pack=d->cell_last_pack+1;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
421 break; // we're after the last cell
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
422 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
423 d->cur_cell=next;
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
424 }
1609
84199d075839 ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents: 1596
diff changeset
425
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
426 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
427
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
428 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
429 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
430
1609
84199d075839 ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents: 1596
diff changeset
431 // if we're in interleaved multi-angle cell, find the right angle chain!
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
432 // (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
433 d->angle_seek=1;
1596
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
434
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
435 }
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
436
fc0e9953bc2d libDVDread support
arpi
parents: 1584
diff changeset
437 #endif