Mercurial > mplayer.hg
annotate libmpdemux/stream_dvd.c @ 18181:afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
author | nicodvb |
---|---|
date | Sat, 22 Apr 2006 13:05:01 +0000 |
parents | 71f9a4e7fd9d |
children | 4231482179b6 |
rev | line source |
---|---|
15518 | 1 |
2 | |
3 #include <ctype.h> | |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
6 #include <string.h> | |
7 #include <unistd.h> | |
8 #include <fcntl.h> | |
9 #include <string.h> | |
10 | |
11 #include "config.h" | |
12 #include "mp_msg.h" | |
13 #include "help_mp.h" | |
14 | |
15 #ifdef __FreeBSD__ | |
16 #include <sys/cdrio.h> | |
17 #endif | |
18 | |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
19 #define FIRST_AC3_AID 128 |
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
20 #define FIRST_DTS_AID 136 |
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
21 #define FIRST_MPG_AID 0 |
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
22 #define FIRST_PCM_AID 160 |
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
23 |
15518 | 24 #include "stream.h" |
17012 | 25 #include "m_option.h" |
26 #include "m_struct.h" | |
15518 | 27 |
28 /// We keep these 2 for the gui atm, but they will be removed. | |
17191
6ac0b5f0d1ed
fix compilation when dvdkit and dvdread are not available
nicodvb
parents:
17012
diff
changeset
|
29 extern int dvd_title; |
6ac0b5f0d1ed
fix compilation when dvdkit and dvdread are not available
nicodvb
parents:
17012
diff
changeset
|
30 extern int dvd_chapter; |
6ac0b5f0d1ed
fix compilation when dvdkit and dvdread are not available
nicodvb
parents:
17012
diff
changeset
|
31 extern int dvd_last_chapter; |
6ac0b5f0d1ed
fix compilation when dvdkit and dvdread are not available
nicodvb
parents:
17012
diff
changeset
|
32 extern char* dvd_device; |
15518 | 33 int dvd_angle=1; |
34 | |
17191
6ac0b5f0d1ed
fix compilation when dvdkit and dvdread are not available
nicodvb
parents:
17012
diff
changeset
|
35 #ifdef HAVE_DVD |
15518 | 36 #ifdef USE_DVDREAD |
17257 | 37 #define LIBDVDREAD_VERSION(maj,min,micro) ((maj)*10000 + (min)*100 + (micro)) |
15518 | 38 /* |
39 * Try to autodetect the libdvd-0.9.0 library | |
40 * (0.9.0 removed the <dvdread/dvd_udf.h> header, and moved the two defines | |
41 * DVD_VIDEO_LB_LEN and MAX_UDF_FILE_NAME_LEN from it to | |
42 * <dvdread/dvd_reader.h>) | |
43 */ | |
17257 | 44 #ifndef DVDREAD_VERSION |
15518 | 45 #if defined(DVD_VIDEO_LB_LEN) && defined(MAX_UDF_FILE_NAME_LEN) |
17257 | 46 #define DVDREAD_VERSION LIBDVDREAD_VERSION(0,9,0) |
15518 | 47 #else |
17257 | 48 #define DVDREAD_VERSION LIBDVDREAD_VERSION(0,8,0) |
49 #endif | |
15518 | 50 #endif |
51 | |
52 char * dvd_audio_stream_types[8] = { "ac3","unknown","mpeg1","mpeg2ext","lpcm","unknown","dts" }; | |
53 char * dvd_audio_stream_channels[6] = { "mono", "stereo", "unknown", "unknown", "5.1/6.1", "5.1" }; | |
54 #endif | |
55 | |
56 | |
57 static struct stream_priv_s { | |
58 int title; | |
59 } stream_priv_dflts = { | |
60 1 | |
61 }; | |
62 | |
63 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f) | |
64 /// URL definition | |
65 static m_option_t stream_opts_fields[] = { | |
66 { "hostname", ST_OFF(title), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL }, | |
67 { NULL, NULL, 0, 0, 0, 0, NULL } | |
68 }; | |
69 static struct m_struct_st stream_opts = { | |
70 "dvd", | |
71 sizeof(struct stream_priv_s), | |
72 &stream_priv_dflts, | |
73 stream_opts_fields | |
74 }; | |
75 | |
76 int dvd_parse_chapter_range(m_option_t *conf, const char *range) { | |
77 const char *s; | |
78 char *t; | |
79 if (!range) | |
80 return M_OPT_MISSING_PARAM; | |
81 s = range; | |
82 dvd_chapter = 1; | |
83 dvd_last_chapter = 0; | |
84 if(*range && isdigit(*range)) { | |
85 dvd_chapter = strtol(range, &s, 10); | |
86 if(range == s) { | |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16770
diff
changeset
|
87 mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_DVDinvalidChapterRange, range); |
15518 | 88 return M_OPT_INVALID; |
89 } | |
90 } | |
91 if(*s == 0) | |
92 return 0; | |
93 else if(*s != '-') { | |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16770
diff
changeset
|
94 mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_DVDinvalidChapterRange, range); |
15518 | 95 return M_OPT_INVALID; |
96 } | |
97 ++s; | |
98 if(*s == 0) | |
99 return 0; | |
100 if(! isdigit(*s)) { | |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16770
diff
changeset
|
101 mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_DVDinvalidChapterRange, range); |
15518 | 102 return M_OPT_INVALID; |
103 } | |
104 dvd_last_chapter = strtol(s, &t, 10); | |
105 if (s == t || *t) { | |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16770
diff
changeset
|
106 mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_DVDinvalidChapterRange, range); |
15518 | 107 return M_OPT_INVALID; |
108 } | |
109 return 0; | |
110 } | |
111 | |
112 #ifdef USE_DVDREAD | |
113 int dvd_chapter_from_cell(dvd_priv_t* dvd,int title,int cell) | |
114 { | |
115 pgc_t * cur_pgc; | |
116 ptt_info_t* ptt; | |
117 int chapter = cell; | |
118 int pgc_id,pgn; | |
119 if(title < 0 || cell < 0){ | |
120 return 0; | |
121 } | |
122 /* for most DVD's chapter == cell */ | |
123 /* but there are more complecated cases... */ | |
124 if(chapter >= dvd->vmg_file->tt_srpt->title[title].nr_of_ptts) { | |
125 chapter = dvd->vmg_file->tt_srpt->title[title].nr_of_ptts-1; | |
126 } | |
127 title = dvd->tt_srpt->title[title].vts_ttn-1; | |
128 ptt = dvd->vts_file->vts_ptt_srpt->title[title].ptt; | |
129 while(chapter >= 0) { | |
130 pgc_id = ptt[chapter].pgcn; | |
131 pgn = ptt[chapter].pgn; | |
132 cur_pgc = dvd->vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; | |
133 if(cell >= cur_pgc->program_map[pgn-1]-1) { | |
134 return chapter; | |
135 } | |
136 --chapter; | |
137 } | |
138 /* didn't find a chapter ??? */ | |
139 return chapter; | |
140 } | |
141 | |
142 int dvd_aid_from_lang(stream_t *stream, unsigned char* lang) { | |
143 dvd_priv_t *d=stream->priv; | |
144 int code,i; | |
145 if(lang) { | |
146 while(strlen(lang)>=2) { | |
147 code=lang[1]|(lang[0]<<8); | |
148 for(i=0;i<d->nr_of_channels;i++) { | |
149 if(d->audio_streams[i].language==code) { | |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16770
diff
changeset
|
150 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_DVDaudioChannel, |
15518 | 151 d->audio_streams[i].id, lang[0],lang[1]); |
152 return d->audio_streams[i].id; | |
153 } | |
154 //printf("%X != %X (%c%c)\n",code,d->audio_streams[i].language,lang[0],lang[1]); | |
155 } | |
156 lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; | |
157 } | |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16770
diff
changeset
|
158 mp_msg(MSGT_OPEN,MSGL_WARN,MSGTR_DVDnoMatchingAudio); |
15518 | 159 } |
160 return -1; | |
161 } | |
162 | |
163 int dvd_number_of_subs(stream_t *stream) { | |
164 dvd_priv_t *d; | |
165 if (!stream) return -1; | |
166 d = stream->priv; | |
167 if (!d) return -1; | |
168 return d->nr_of_subtitles; | |
169 } | |
170 | |
171 int dvd_lang_from_sid(stream_t *stream, int id) { | |
172 dvd_priv_t *d; | |
173 if (!stream) return 0; | |
174 d = stream->priv; | |
175 if (!d) return 0; | |
176 if (id >= d->nr_of_subtitles) return 0; | |
177 return d->subtitles[id].language; | |
178 } | |
179 | |
180 int dvd_sid_from_lang(stream_t *stream, unsigned char* lang) { | |
181 dvd_priv_t *d=stream->priv; | |
182 int code,i; | |
183 while(lang && strlen(lang)>=2) { | |
184 code=lang[1]|(lang[0]<<8); | |
185 for(i=0;i<d->nr_of_subtitles;i++) { | |
186 if(d->subtitles[i].language==code) { | |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16770
diff
changeset
|
187 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_DVDsubtitleChannel, i, lang[0],lang[1]); |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
188 return i; |
15518 | 189 } |
190 } | |
191 lang+=2; | |
192 while (lang[0]==',' || lang[0]==' ') ++lang; | |
193 } | |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16770
diff
changeset
|
194 mp_msg(MSGT_OPEN,MSGL_WARN,MSGTR_DVDnoMatchingSubtitle); |
15518 | 195 return -1; |
196 } | |
197 | |
198 static int dvd_next_cell(dvd_priv_t *d) { | |
199 int next_cell=d->cur_cell; | |
200 | |
15551
f62be65f7df3
Reduce senseless spamminess of DVD playback in verbose mode.
diego
parents:
15518
diff
changeset
|
201 mp_msg(MSGT_DVD,MSGL_DBG2, "dvd_next_cell: next1=0x%X \n",next_cell); |
15518 | 202 if( d->cur_pgc->cell_playback[ next_cell ].block_type == BLOCK_TYPE_ANGLE_BLOCK ) { |
203 while(next_cell<d->last_cell) { | |
204 if( d->cur_pgc->cell_playback[next_cell].block_mode == BLOCK_MODE_LAST_CELL ) | |
205 break; | |
206 ++next_cell; | |
207 } | |
208 } | |
15551
f62be65f7df3
Reduce senseless spamminess of DVD playback in verbose mode.
diego
parents:
15518
diff
changeset
|
209 mp_msg(MSGT_DVD,MSGL_DBG2, "dvd_next_cell: next2=0x%X \n",next_cell); |
15518 | 210 |
211 ++next_cell; | |
212 if(next_cell>=d->last_cell) | |
213 return -1; // EOF | |
214 if(d->cur_pgc->cell_playback[next_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) { | |
215 next_cell+=dvd_angle; | |
216 if(next_cell>=d->last_cell) | |
217 return -1; // EOF | |
218 } | |
15551
f62be65f7df3
Reduce senseless spamminess of DVD playback in verbose mode.
diego
parents:
15518
diff
changeset
|
219 mp_msg(MSGT_DVD,MSGL_DBG2, "dvd_next_cell: next3=0x%X \n",next_cell); |
15518 | 220 return next_cell; |
221 } | |
222 | |
223 int dvd_read_sector(dvd_priv_t *d,unsigned char* data) { | |
224 int len; | |
225 | |
226 if(d->packs_left==0) { | |
227 /** | |
228 * If we're not at the end of this cell, we can determine the next | |
229 * VOBU to display using the VOBU_SRI information section of the | |
230 * DSI. Using this value correctly follows the current angle, | |
231 * avoiding the doubled scenes in The Matrix, and makes our life | |
232 * really happy. | |
233 * | |
234 * Otherwise, we set our next address past the end of this cell to | |
235 * force the code above to go to the next cell in the program. | |
236 */ | |
237 if(d->dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL) { | |
238 d->cur_pack= d->dsi_pack.dsi_gi.nv_pck_lbn + ( d->dsi_pack.vobu_sri.next_vobu & 0x7fffffff ); | |
239 mp_msg(MSGT_DVD,MSGL_DBG2, "Navi new pos=0x%X \n",d->cur_pack); | |
240 } else { | |
241 // end of cell! find next cell! | |
242 mp_msg(MSGT_DVD,MSGL_V, "--- END OF CELL !!! ---\n"); | |
243 d->cur_pack=d->cell_last_pack+1; | |
244 } | |
245 } | |
246 | |
247 read_next: | |
248 if(d->cur_pack>d->cell_last_pack) { | |
249 // end of cell! | |
250 int next=dvd_next_cell(d); | |
251 if(next>=0) { | |
252 d->cur_cell=next; | |
253 // if( d->cur_pgc->cell_playback[d->cur_cell].block_type | |
254 // == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; | |
255 d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; | |
256 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
257 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); | |
258 } else | |
259 return -1; // EOF | |
260 } | |
261 | |
262 len = DVDReadBlocks(d->title, d->cur_pack, 1, data); | |
263 if(!len) return -1; //error | |
264 | |
265 if(data[38]==0 && data[39]==0 && data[40]==1 && data[41]==0xBF && | |
266 data[1024]==0 && data[1025]==0 && data[1026]==1 && data[1027]==0xBF) { | |
267 // found a Navi packet!!! | |
17257 | 268 #if DVDREAD_VERSION >= LIBDVDREAD_VERSION(0,9,0) |
15518 | 269 navRead_DSI(&d->dsi_pack, &(data[ DSI_START_BYTE ])); |
270 #else | |
271 navRead_DSI(&d->dsi_pack, &(data[ DSI_START_BYTE ]), sizeof(dsi_t)); | |
272 #endif | |
273 if(d->cur_pack != d->dsi_pack.dsi_gi.nv_pck_lbn ) { | |
274 mp_msg(MSGT_DVD,MSGL_V, "Invalid NAVI packet! lba=0x%X navi=0x%X \n", | |
275 d->cur_pack,d->dsi_pack.dsi_gi.nv_pck_lbn); | |
276 } else { | |
277 // process! | |
278 d->packs_left = d->dsi_pack.dsi_gi.vobu_ea; | |
279 mp_msg(MSGT_DVD,MSGL_DBG2, "Found NAVI packet! lba=0x%X len=%d \n",d->cur_pack,d->packs_left); | |
280 //navPrint_DSI(&d->dsi_pack); | |
281 mp_msg(MSGT_DVD,MSGL_DBG3,"\r### CELL %d: Navi: %d/%d IFO: %d/%d \n",d->cur_cell, | |
282 d->dsi_pack.dsi_gi.vobu_c_idn,d->dsi_pack.dsi_gi.vobu_vob_idn, | |
283 d->cur_pgc->cell_position[d->cur_cell].cell_nr, | |
284 d->cur_pgc->cell_position[d->cur_cell].vob_id_nr); | |
285 | |
286 if(d->angle_seek) { | |
287 int i,skip=0; | |
288 #if defined(__GNUC__) && ( defined(__sparc__) || defined(hpux) ) | |
289 // workaround for a bug in the sparc/hpux version of gcc 2.95.X ... 3.2, | |
290 // it generates incorrect code for unaligned access to a packed | |
291 // structure member, resulting in an mplayer crash with a SIGBUS | |
292 // signal. | |
293 // | |
294 // See also gcc problem report PR c/7847: | |
295 // http://gcc.gnu.org/cgi-bin/gnatsweb.pl?database=gcc&cmd=view+audit-trail&pr=7847 | |
296 for(i=0;i<9;i++) { // check if all values zero: | |
297 typeof(d->dsi_pack.sml_agli.data[i].address) tmp_addr; | |
298 memcpy(&tmp_addr,&d->dsi_pack.sml_agli.data[i].address,sizeof(tmp_addr)); | |
299 if((skip=tmp_addr)!=0) break; | |
300 } | |
301 #else | |
302 for(i=0;i<9;i++) // check if all values zero: | |
303 if((skip=d->dsi_pack.sml_agli.data[i].address)!=0) break; | |
304 #endif | |
305 if(skip) { | |
306 // sml_agli table has valid data (at least one non-zero): | |
307 d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+ | |
308 d->dsi_pack.sml_agli.data[dvd_angle].address; | |
309 d->angle_seek=0; | |
310 mp_msg(MSGT_DVD,MSGL_V, "Angle-seek synced using sml_agli map! new_lba=0x%X \n",d->cur_pack); | |
311 } else { | |
312 // check if we're in the right cell, jump otherwise: | |
313 if( (d->dsi_pack.dsi_gi.vobu_c_idn==d->cur_pgc->cell_position[d->cur_cell].cell_nr) && | |
314 (d->dsi_pack.dsi_gi.vobu_vob_idn==d->cur_pgc->cell_position[d->cur_cell].vob_id_nr) ){ | |
315 d->angle_seek=0; | |
316 mp_msg(MSGT_DVD,MSGL_V, "Angle-seek synced by cell/vob IDN search! \n"); | |
317 } else { | |
318 // wrong angle, skip this vobu: | |
319 d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+ | |
320 d->dsi_pack.dsi_gi.vobu_ea; | |
321 d->angle_seek=2; // DEBUG | |
322 } | |
323 } | |
324 } | |
325 } | |
326 ++d->cur_pack; | |
327 goto read_next; | |
328 } | |
329 | |
330 ++d->cur_pack; | |
331 if(d->packs_left>=0) --d->packs_left; | |
332 | |
333 if(d->angle_seek) { | |
334 if(d->angle_seek==2) mp_msg(MSGT_DVD,MSGL_V, "!!! warning! reading packet while angle_seek !!!\n"); | |
335 goto read_next; // searching for Navi packet | |
336 } | |
337 | |
338 return d->cur_pack-1; | |
339 } | |
340 | |
341 void dvd_seek(dvd_priv_t *d,int pos) { | |
342 d->packs_left=-1; | |
343 d->cur_pack=pos; | |
344 | |
345 // check if we stay in current cell (speedup things, and avoid angle skip) | |
346 if(d->cur_pack>d->cell_last_pack || | |
347 d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector) { | |
348 | |
349 // ok, cell change, find the right cell! | |
350 d->cur_cell=0; | |
351 if(d->cur_pgc->cell_playback[d->cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) | |
352 d->cur_cell+=dvd_angle; | |
353 | |
354 while(1) { | |
355 int next; | |
356 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
357 if(d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector) { | |
358 d->cur_pack=d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; | |
359 break; | |
360 } | |
361 if(d->cur_pack<=d->cell_last_pack) break; // ok, we find it! :) | |
362 next=dvd_next_cell(d); | |
363 if(next<0) { | |
364 //d->cur_pack=d->cell_last_pack+1; | |
365 break; // we're after the last cell | |
366 } | |
367 d->cur_cell=next; | |
368 } | |
369 } | |
370 | |
371 mp_msg(MSGT_DVD,MSGL_V, "DVD Seek! lba=0x%X cell=%d packs: 0x%X-0x%X \n", | |
372 d->cur_pack,d->cur_cell,d->cur_pgc->cell_playback[ d->cur_cell ].first_sector,d->cell_last_pack); | |
373 | |
374 // if we're in interleaved multi-angle cell, find the right angle chain! | |
375 // (read Navi block, and use the seamless angle jump table) | |
376 d->angle_seek=1; | |
377 } | |
378 | |
379 void dvd_close(dvd_priv_t *d) { | |
380 ifoClose(d->vts_file); | |
381 ifoClose(d->vmg_file); | |
382 DVDCloseFile(d->title); | |
383 DVDClose(d->dvd); | |
384 dvd_chapter = 1; | |
385 dvd_last_chapter = 0; | |
386 } | |
387 | |
388 #endif | |
389 | |
390 static int fill_buffer(stream_t *s, char *but, int len) | |
391 { | |
392 #ifdef USE_DVDREAD | |
393 if(s->type == STREAMTYPE_DVD) { | |
394 off_t pos=dvd_read_sector(s->priv,s->buffer); | |
395 if(pos>=0) { | |
396 len=2048; // full sector | |
397 s->pos=2048*pos-len; | |
398 } else len=-1; // error | |
399 } | |
400 #endif | |
401 return len; | |
402 } | |
403 | |
404 static int seek(stream_t *s, off_t newpos) { | |
405 #ifdef USE_DVDREAD | |
406 s->pos=newpos; // real seek | |
407 dvd_seek(s->priv,s->pos/2048); | |
408 #endif | |
409 return 1; | |
410 } | |
411 | |
412 static void stream_dvd_close(stream_t *s) { | |
413 #ifdef USE_DVDREAD | |
414 dvd_close(s->priv); | |
415 #endif | |
416 } | |
417 | |
16544
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
418 /** |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
419 \brief Converts DVD time structure to milliseconds. |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
420 \param *dev the DVD time structure to convert |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
421 \return returns the time in milliseconds |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
422 */ |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
423 static int dvdtimetomsec(dvd_time_t *dt) |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
424 { |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
425 static int framerates[4] = {0, 2500, 0, 2997}; |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
426 int framerate = framerates[(dt->frame_u & 0xc0) >> 6]; |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
427 int msec = (((dt->hour & 0xf0) >> 3) * 5 + (dt->hour & 0x0f)) * 3600000; |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
428 msec += (((dt->minute & 0xf0) >> 3) * 5 + (dt->minute & 0x0f)) * 60000; |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
429 msec += (((dt->second & 0xf0) >> 3) * 5 + (dt->second & 0x0f)) * 1000; |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
430 if(framerate > 0) |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
431 msec += (((dt->frame_u & 0x30) >> 3) * 5 + (dt->frame_u & 0x0f)) * 100000 / framerate; |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
432 return msec; |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
433 } |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
434 |
18091
71f9a4e7fd9d
remove vts_no parameter from mp_get_titleset_length - it is not only useless,
reimar
parents:
18078
diff
changeset
|
435 static int mp_get_titleset_length(ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no) |
17698
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
436 { |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
437 int vts_ttn; ///< title number within video title set |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
438 int pgc_no; ///< program chain number |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
439 int msec; ///< time length in milliseconds |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
440 |
17817
560617cdcc3b
init msec in mp_get_titleset_length() before using it; closes cid 251
nicodvb
parents:
17698
diff
changeset
|
441 msec=0; |
17698
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
442 if(!vts_file || !tt_srpt) |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
443 return 0; |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
444 |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
445 if(vts_file->vtsi_mat && vts_file->vts_pgcit) |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
446 { |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
447 vts_ttn = tt_srpt->title[title_no].vts_ttn - 1; |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
448 pgc_no = vts_file->vts_ptt_srpt->title[vts_ttn].ptt[0].pgcn - 1; |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
449 msec = dvdtimetomsec(&vts_file->vts_pgcit->pgci_srp[pgc_no].pgc->playback_time); |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
450 } |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
451 return msec; |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
452 } |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
453 |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
454 |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
455 static int mp_describe_titleset(dvd_reader_t *dvd, tt_srpt_t *tt_srpt, int vts_no) |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
456 { |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
457 ifo_handle_t *vts_file; |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
458 int title_no, msec=0; |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
459 |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
460 vts_file = ifoOpen(dvd, vts_no); |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
461 if(!vts_file) |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
462 return 0; |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
463 |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
464 if(!vts_file->vtsi_mat || !vts_file->vts_pgcit) |
18078
aeb937690d3d
missing ifoClose and return 1. Patch by kiriuja (mplayer-patches at en-directo net)
reimar
parents:
18071
diff
changeset
|
465 { |
aeb937690d3d
missing ifoClose and return 1. Patch by kiriuja (mplayer-patches at en-directo net)
reimar
parents:
18071
diff
changeset
|
466 ifoClose(vts_file); |
17698
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
467 return 0; |
18078
aeb937690d3d
missing ifoClose and return 1. Patch by kiriuja (mplayer-patches at en-directo net)
reimar
parents:
18071
diff
changeset
|
468 } |
17698
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
469 |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
470 for(title_no = 0; title_no < tt_srpt->nr_of_srpts; title_no++) |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
471 { |
18071
1e144ef9759b
do not print the title length from a non-matching titleset.
reimar
parents:
17817
diff
changeset
|
472 if (tt_srpt->title[title_no].title_set_nr != vts_no) |
1e144ef9759b
do not print the title length from a non-matching titleset.
reimar
parents:
17817
diff
changeset
|
473 continue; |
18091
71f9a4e7fd9d
remove vts_no parameter from mp_get_titleset_length - it is not only useless,
reimar
parents:
18078
diff
changeset
|
474 msec = mp_get_titleset_length(vts_file, tt_srpt, title_no); |
17698
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
475 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_DVD_TITLE_%d_LENGTH=%d.%03d\n", title_no + 1, msec / 1000, msec % 1000); |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
476 } |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
477 ifoClose(vts_file); |
18078
aeb937690d3d
missing ifoClose and return 1. Patch by kiriuja (mplayer-patches at en-directo net)
reimar
parents:
18071
diff
changeset
|
478 return 1; |
17698
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
479 } |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
480 |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
481 static int control(stream_t *stream,int cmd,void* arg) |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
482 { |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
483 switch(cmd) |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
484 { |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
485 case STREAM_CTRL_GET_TIME_LENGTH: |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
486 { |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
487 dvd_priv_t *d = stream->priv; |
18091
71f9a4e7fd9d
remove vts_no parameter from mp_get_titleset_length - it is not only useless,
reimar
parents:
18078
diff
changeset
|
488 *((unsigned int *)arg) = mp_get_titleset_length(d->vts_file, d->tt_srpt, d->cur_title-1); |
17698
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
489 return 1; |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
490 } |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
491 } |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
492 return STREAM_UNSUPORTED; |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
493 } |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
494 |
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
495 |
15518 | 496 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { |
497 struct stream_priv_s* p = (struct stream_priv_s*)opts; | |
498 char *filename; | |
499 | |
500 filename = strdup(stream->url); | |
501 mp_msg(MSGT_OPEN,MSGL_V,"URL: %s\n", filename); | |
502 dvd_title = p->title; | |
503 #ifdef USE_DVDREAD | |
504 if(1){ | |
505 //int ret,ret2; | |
506 dvd_priv_t *d; | |
507 int ttn,pgc_id,pgn; | |
508 dvd_reader_t *dvd; | |
509 dvd_file_t *title; | |
510 ifo_handle_t *vmg_file; | |
511 tt_srpt_t *tt_srpt; | |
512 ifo_handle_t *vts_file; | |
513 /** | |
514 * Open the disc. | |
515 */ | |
516 if(!dvd_device) dvd_device=strdup(DEFAULT_DVD_DEVICE); | |
517 #ifdef SYS_DARWIN | |
518 /* Dynamic DVD drive selection on Darwin */ | |
519 if(!strcmp(dvd_device, "/dev/rdiskN")) { | |
520 int i; | |
521 char *temp_device = malloc((strlen(dvd_device)+1)*sizeof(char)); | |
522 | |
523 for (i = 1; i < 10; i++) { | |
524 sprintf(temp_device, "/dev/rdisk%d", i); | |
525 dvd = DVDOpen(temp_device); | |
526 if(!dvd) { | |
527 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,temp_device); | |
528 } else { | |
17490
acef9166db2f
MPlayer OSX port: Add a call to UDFFindFile to verify that we are opening a valid udf image. Patch by Emanuele Giaquita <emanuele.giaquinta@gmail.com>
nplourde
parents:
17257
diff
changeset
|
529 #if DVDREAD_VERSION <= LIBDVDREAD_VERSION(0,9,4) |
acef9166db2f
MPlayer OSX port: Add a call to UDFFindFile to verify that we are opening a valid udf image. Patch by Emanuele Giaquita <emanuele.giaquinta@gmail.com>
nplourde
parents:
17257
diff
changeset
|
530 int len; |
acef9166db2f
MPlayer OSX port: Add a call to UDFFindFile to verify that we are opening a valid udf image. Patch by Emanuele Giaquita <emanuele.giaquinta@gmail.com>
nplourde
parents:
17257
diff
changeset
|
531 if(!UDFFindFile(dvd,"/",&len)) { |
acef9166db2f
MPlayer OSX port: Add a call to UDFFindFile to verify that we are opening a valid udf image. Patch by Emanuele Giaquita <emanuele.giaquinta@gmail.com>
nplourde
parents:
17257
diff
changeset
|
532 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,temp_device); |
acef9166db2f
MPlayer OSX port: Add a call to UDFFindFile to verify that we are opening a valid udf image. Patch by Emanuele Giaquita <emanuele.giaquinta@gmail.com>
nplourde
parents:
17257
diff
changeset
|
533 DVDClose(dvd); |
acef9166db2f
MPlayer OSX port: Add a call to UDFFindFile to verify that we are opening a valid udf image. Patch by Emanuele Giaquita <emanuele.giaquinta@gmail.com>
nplourde
parents:
17257
diff
changeset
|
534 } else |
acef9166db2f
MPlayer OSX port: Add a call to UDFFindFile to verify that we are opening a valid udf image. Patch by Emanuele Giaquita <emanuele.giaquinta@gmail.com>
nplourde
parents:
17257
diff
changeset
|
535 #endif |
acef9166db2f
MPlayer OSX port: Add a call to UDFFindFile to verify that we are opening a valid udf image. Patch by Emanuele Giaquita <emanuele.giaquinta@gmail.com>
nplourde
parents:
17257
diff
changeset
|
536 { |
15518 | 537 free(temp_device); |
538 break; | |
17490
acef9166db2f
MPlayer OSX port: Add a call to UDFFindFile to verify that we are opening a valid udf image. Patch by Emanuele Giaquita <emanuele.giaquinta@gmail.com>
nplourde
parents:
17257
diff
changeset
|
539 } |
15518 | 540 } |
541 } | |
542 | |
543 if(!dvd) { | |
544 m_struct_free(&stream_opts,opts); | |
545 return STREAM_UNSUPORTED; | |
546 } | |
547 } else | |
548 #endif /* SYS_DARWIN */ | |
549 { | |
550 dvd = DVDOpen(dvd_device); | |
551 if(!dvd) { | |
552 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,dvd_device); | |
553 m_struct_free(&stream_opts,opts); | |
554 return STREAM_UNSUPORTED; | |
555 } | |
556 } | |
557 | |
558 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_DVDwait); | |
559 | |
560 /** | |
561 * Load the video manager to find out the information about the titles on | |
562 * this disc. | |
563 */ | |
564 vmg_file = ifoOpen(dvd, 0); | |
565 if(!vmg_file) { | |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16770
diff
changeset
|
566 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoVMG); |
15518 | 567 DVDClose( dvd ); |
568 m_struct_free(&stream_opts,opts); | |
569 return STREAM_UNSUPORTED; | |
570 } | |
571 tt_srpt = vmg_file->tt_srpt; | |
16544
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
572 if (identify) |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
573 { |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
574 unsigned char discid [16]; ///< disk ID, a 128 bit MD5 sum |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
575 int vts_no; ///< video title set number |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
576 int title_no; ///< title number |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
577 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_DVD_TITLES=%d\n", tt_srpt->nr_of_srpts); |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
578 for (title_no = 0; title_no < tt_srpt->nr_of_srpts; title_no++) |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
579 { |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
580 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_DVD_TITLE_%d_CHAPTERS=%d\n", title_no + 1, tt_srpt->title[title_no].nr_of_ptts); |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
581 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_DVD_TITLE_%d_ANGLES=%d\n", title_no + 1, tt_srpt->title[title_no].nr_of_angles); |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
582 } |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
583 for (vts_no = 1; vts_no <= vmg_file->vts_atrt->nr_of_vtss; vts_no++) |
17698
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
584 mp_describe_titleset(dvd, tt_srpt, vts_no); |
16544
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
585 if (DVDDiscID(dvd, discid) >= 0) |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
586 { |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
587 int i; |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
588 char buf[33]; |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
589 for (i = 0; i < 16; i ++) |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
590 sprintf(buf+2*i, "%02X", discid[i]); |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
591 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_DVD_DISC_ID=%s\n", buf); |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
592 } |
a10adcba312f
Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents:
15551
diff
changeset
|
593 } |
15518 | 594 /** |
595 * Make sure our title number is valid. | |
596 */ | |
597 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumTitles, tt_srpt->nr_of_srpts ); | |
598 if(dvd_title < 1 || dvd_title > tt_srpt->nr_of_srpts) { | |
599 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidTitle, dvd_title); | |
600 ifoClose( vmg_file ); | |
601 DVDClose( dvd ); | |
602 m_struct_free(&stream_opts,opts); | |
603 return STREAM_UNSUPORTED; | |
604 } | |
605 --dvd_title; // remap 1.. -> 0.. | |
606 /** | |
607 * Make sure the chapter number is valid for this title. | |
608 */ | |
609 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumChapters, tt_srpt->title[dvd_title].nr_of_ptts); | |
610 if(dvd_chapter<1 || dvd_chapter>tt_srpt->title[dvd_title].nr_of_ptts) { | |
611 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidChapter, dvd_chapter); | |
612 ifoClose( vmg_file ); | |
613 DVDClose( dvd ); | |
614 m_struct_free(&stream_opts,opts); | |
615 return STREAM_UNSUPORTED; | |
616 } | |
617 if(dvd_last_chapter>0) { | |
618 if(dvd_last_chapter<dvd_chapter || dvd_last_chapter>tt_srpt->title[dvd_title].nr_of_ptts) { | |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16770
diff
changeset
|
619 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidLastChapter, dvd_last_chapter); |
15518 | 620 ifoClose( vmg_file ); |
621 DVDClose( dvd ); | |
622 m_struct_free(&stream_opts,opts); | |
623 return STREAM_UNSUPORTED; | |
624 } | |
625 } | |
626 --dvd_chapter; // remap 1.. -> 0.. | |
627 /* XXX No need to remap dvd_last_chapter */ | |
628 /** | |
629 * Make sure the angle number is valid for this title. | |
630 */ | |
631 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumAngles, tt_srpt->title[dvd_title].nr_of_angles); | |
632 if(dvd_angle<1 || dvd_angle>tt_srpt->title[dvd_title].nr_of_angles) { | |
633 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidAngle, dvd_angle); | |
634 ifoClose( vmg_file ); | |
635 DVDClose( dvd ); | |
636 m_struct_free(&stream_opts,opts); | |
637 return STREAM_UNSUPORTED; | |
638 } | |
639 --dvd_angle; // remap 1.. -> 0.. | |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
640 |
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
641 ttn = tt_srpt->title[dvd_title].vts_ttn - 1; |
15518 | 642 /** |
643 * Load the VTS information for the title set our title is in. | |
644 */ | |
645 vts_file = ifoOpen( dvd, tt_srpt->title[dvd_title].title_set_nr ); | |
646 if(!vts_file) { | |
647 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoIFO, tt_srpt->title[dvd_title].title_set_nr ); | |
648 ifoClose( vmg_file ); | |
649 DVDClose( dvd ); | |
650 m_struct_free(&stream_opts,opts); | |
651 return STREAM_UNSUPORTED; | |
652 } | |
653 /** | |
654 * We've got enough info, time to open the title set data. | |
655 */ | |
656 title = DVDOpenFile(dvd, tt_srpt->title[dvd_title].title_set_nr, DVD_READ_TITLE_VOBS); | |
657 if(!title) { | |
658 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoVOBs, tt_srpt->title[dvd_title].title_set_nr); | |
659 ifoClose( vts_file ); | |
660 ifoClose( vmg_file ); | |
661 DVDClose( dvd ); | |
662 m_struct_free(&stream_opts,opts); | |
663 return STREAM_UNSUPORTED; | |
664 } | |
665 | |
666 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDopenOk); | |
667 // store data | |
668 d=malloc(sizeof(dvd_priv_t)); memset(d,0,sizeof(dvd_priv_t)); | |
669 d->dvd=dvd; | |
670 d->title=title; | |
671 d->vmg_file=vmg_file; | |
672 d->tt_srpt=tt_srpt; | |
673 d->vts_file=vts_file; | |
17698
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
674 d->cur_title = dvd_title+1; |
15518 | 675 |
676 /** | |
677 * Check number of audio channels and types | |
678 */ | |
679 { | |
680 d->nr_of_channels=0; | |
681 if(vts_file->vts_pgcit) { | |
682 int i; | |
683 for(i=0;i<8;i++) | |
16770
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
684 #ifdef USE_MPDVDKIT |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
685 if(vts_file->vts_pgcit->pgci_srp[ttn].pgc->audio_control[i].present) { |
16770
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
686 #else |
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
687 if(vts_file->vts_pgcit->pgci_srp[ttn].pgc->audio_control[i] & 0x8000) { |
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
688 #endif |
15518 | 689 audio_attr_t * audio = &vts_file->vtsi_mat->vts_audio_attr[i]; |
690 int language = 0; | |
691 char tmp[] = "unknown"; | |
692 | |
693 if(audio->lang_type == 1) { | |
694 language=audio->lang_code; | |
695 tmp[0]=language>>8; | |
696 tmp[1]=language&0xff; | |
697 tmp[2]=0; | |
698 } | |
699 | |
700 d->audio_streams[d->nr_of_channels].language=language; | |
16770
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
701 #ifdef USE_MPDVDKIT |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
702 d->audio_streams[d->nr_of_channels].id=vts_file->vts_pgcit->pgci_srp[ttn].pgc->audio_control[i].s_audio; |
16770
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
703 #else |
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
704 d->audio_streams[d->nr_of_channels].id=vts_file->vts_pgcit->pgci_srp[ttn].pgc->audio_control[i] >> 8 & 7; |
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
705 #endif |
15518 | 706 switch(audio->audio_format) { |
707 case 0: // ac3 | |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
708 d->audio_streams[d->nr_of_channels].id+=FIRST_AC3_AID; |
15518 | 709 break; |
710 case 6: // dts | |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
711 d->audio_streams[d->nr_of_channels].id+=FIRST_DTS_AID; |
15518 | 712 break; |
713 case 2: // mpeg layer 1/2/3 | |
714 case 3: // mpeg2 ext | |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
715 d->audio_streams[d->nr_of_channels].id+=FIRST_MPG_AID; |
15518 | 716 break; |
717 case 4: // lpcm | |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
718 d->audio_streams[d->nr_of_channels].id+=FIRST_PCM_AID; |
15518 | 719 break; |
720 } | |
721 | |
722 d->audio_streams[d->nr_of_channels].type=audio->audio_format; | |
723 // Pontscho: to my mind, tha channels: | |
724 // 1 - stereo | |
725 // 5 - 5.1 | |
726 d->audio_streams[d->nr_of_channels].channels=audio->channels; | |
727 mp_msg(MSGT_OPEN,MSGL_V,"[open] audio stream: %d audio format: %s (%s) language: %s aid: %d\n", | |
728 d->nr_of_channels, | |
729 dvd_audio_stream_types[ audio->audio_format ], | |
730 dvd_audio_stream_channels[ audio->channels ], | |
731 tmp, | |
732 d->audio_streams[d->nr_of_channels].id | |
733 ); | |
734 if(identify) { | |
735 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", d->audio_streams[d->nr_of_channels].id); | |
736 if(language && tmp[0]) | |
737 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AID_%d_LANG=%s\n", d->audio_streams[d->nr_of_channels].id, tmp); | |
738 } | |
739 | |
740 d->nr_of_channels++; | |
741 } | |
742 } | |
743 mp_msg(MSGT_OPEN,MSGL_V,"[open] number of audio channels on disk: %d.\n",d->nr_of_channels ); | |
744 } | |
745 | |
746 /** | |
747 * Check number of subtitles and language | |
748 */ | |
749 { | |
750 int i; | |
751 | |
752 d->nr_of_subtitles=0; | |
753 for(i=0;i<32;i++) | |
16770
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
754 #ifdef USE_MPDVDKIT |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
755 if(vts_file->vts_pgcit->pgci_srp[ttn].pgc->subp_control[i].present) { |
16770
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
756 #else |
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
757 if(vts_file->vts_pgcit->pgci_srp[ttn].pgc->subp_control[i] & 0x80000000) { |
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
758 #endif |
15518 | 759 subp_attr_t * subtitle = &vts_file->vtsi_mat->vts_subp_attr[i]; |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
760 video_attr_t *video = &vts_file->vtsi_mat->vts_video_attr; |
15518 | 761 int language = 0; |
762 char tmp[] = "unknown"; | |
763 | |
764 if(subtitle->type == 1) { | |
765 language=subtitle->lang_code; | |
766 tmp[0]=language>>8; | |
767 tmp[1]=language&0xff; | |
768 tmp[2]=0; | |
769 } | |
770 | |
771 d->subtitles[ d->nr_of_subtitles ].language=language; | |
772 d->subtitles[ d->nr_of_subtitles ].id=d->nr_of_subtitles; | |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
773 if(video->display_aspect_ratio == 0) /* 4:3 */ |
16770
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
774 #ifdef USE_MPDVDKIT |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
775 d->subtitles[d->nr_of_subtitles].id = vts_file->vts_pgcit->pgci_srp[ttn].pgc->subp_control[i].s_4p3; |
16770
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
776 #else |
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
777 d->subtitles[d->nr_of_subtitles].id = vts_file->vts_pgcit->pgci_srp[ttn].pgc->subp_control[i] >> 24 & 31; |
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
778 #endif |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
779 else if(video->display_aspect_ratio == 3) /* 16:9 */ |
16770
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
780 #ifdef USE_MPDVDKIT |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
781 d->subtitles[d->nr_of_subtitles].id = vts_file->vts_pgcit->pgci_srp[ttn].pgc->subp_control[i].s_lbox; |
16770
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
782 #else |
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
783 d->subtitles[d->nr_of_subtitles].id = vts_file->vts_pgcit->pgci_srp[ttn].pgc->subp_control[i] >> 8 & 31; |
a580febbb306
ugly hack to make it work again with external libdvdread
reimar
parents:
16649
diff
changeset
|
784 #endif |
15518 | 785 |
786 mp_msg(MSGT_OPEN,MSGL_V,"[open] subtitle ( sid ): %d language: %s\n", d->nr_of_subtitles, tmp); | |
787 if(identify) { | |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
788 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", d->subtitles[d->nr_of_subtitles].id); |
15518 | 789 if(language && tmp[0]) |
790 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_SID_%d_LANG=%s\n", d->nr_of_subtitles, tmp); | |
791 } | |
792 d->nr_of_subtitles++; | |
793 } | |
794 mp_msg(MSGT_OPEN,MSGL_V,"[open] number of subtitles on disk: %d\n",d->nr_of_subtitles ); | |
795 } | |
796 | |
797 /** | |
798 * Determine which program chain we want to watch. This is based on the | |
799 * chapter number. | |
800 */ | |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
801 pgc_id = vts_file->vts_ptt_srpt->title[ttn].ptt[dvd_chapter].pgcn; // local |
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
802 pgn = vts_file->vts_ptt_srpt->title[ttn].ptt[dvd_chapter].pgn; // local |
15518 | 803 d->cur_pgc = vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; |
804 d->cur_cell = d->cur_pgc->program_map[pgn-1] - 1; // start playback here | |
805 d->packs_left=-1; // for Navi stuff | |
806 d->angle_seek=0; | |
807 /* XXX dvd_last_chapter is in the range 1..nr_of_ptts */ | |
808 if(dvd_last_chapter > 0 && dvd_last_chapter < tt_srpt->title[dvd_title].nr_of_ptts) { | |
16649
e1d6fbd607e0
Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and
reimar
parents:
16544
diff
changeset
|
809 pgn=vts_file->vts_ptt_srpt->title[ttn].ptt[dvd_last_chapter].pgn; |
15518 | 810 d->last_cell=d->cur_pgc->program_map[pgn-1] - 1; |
811 } else | |
812 d->last_cell=d->cur_pgc->nr_of_cells; | |
813 | |
814 if(d->cur_pgc->cell_playback[d->cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) | |
815 d->cur_cell+=dvd_angle; | |
816 d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; | |
817 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
818 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); | |
819 | |
820 // ... (unimplemented) | |
821 // return NULL; | |
822 stream->type = STREAMTYPE_DVD; | |
823 stream->sector_size = 2048; | |
824 stream->flags = STREAM_READ | STREAM_SEEK; | |
825 stream->fill_buffer = fill_buffer; | |
826 stream->seek = seek; | |
17698
14830cce6098
implement STREAM_CTRL_GET_TIME_LENGTH to return the duration of the dvd currently playing
nicodvb
parents:
17490
diff
changeset
|
827 stream->control = control; |
15518 | 828 stream->close = stream_dvd_close; |
829 stream->start_pos = (off_t)d->cur_pack*2048; | |
830 stream->end_pos = (off_t)(d->cur_pgc->cell_playback[d->last_cell-1].last_sector)*2048; | |
831 mp_msg(MSGT_DVD,MSGL_V,"DVD start=%d end=%d \n",d->cur_pack,d->cur_pgc->cell_playback[d->last_cell-1].last_sector); | |
832 stream->priv = (void*)d; | |
833 return STREAM_OK; | |
834 } | |
835 #endif | |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16770
diff
changeset
|
836 mp_msg(MSGT_DVD,MSGL_ERR,MSGTR_NoDVDSupport); |
15518 | 837 m_struct_free(&stream_opts,opts); |
838 return STREAM_UNSUPORTED; | |
839 } | |
840 | |
841 | |
842 stream_info_t stream_info_dvd = { | |
843 "DVD stream", | |
844 "null", | |
845 "", | |
846 "", | |
847 open_s, | |
848 { "dvd", NULL }, | |
849 &stream_opts, | |
850 1 // Urls are an option string | |
851 }; | |
17191
6ac0b5f0d1ed
fix compilation when dvdkit and dvdread are not available
nicodvb
parents:
17012
diff
changeset
|
852 #endif |