1 /*****************************************************************************
2 * input_dvd.c: DVD raw reading plugin.
4 * This plugins should handle all the known specificities of the DVD format,
5 * especially the 2048 bytes logical block size.
7 * -input_netlist used to read packets
8 * -dvd_ifo for ifo parsing and analyse
9 * -dvd_css for unscrambling
10 * -dvd_udf to find files
11 *****************************************************************************
12 * Copyright (C) 1998-2001 VideoLAN
13 * $Id: input_dvd.c,v 1.23 2001/03/02 13:47:01 sam Exp $
15 * Author: Stéphane Borel <stef@via.ecp.fr>
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
30 *****************************************************************************/
32 #define MODULE_NAME dvd
33 #include "modules_inner.h"
35 /*****************************************************************************
37 *****************************************************************************/
43 #include <netinet/in.h>
46 #include <sys/types.h>
63 #include "stream_control.h"
64 #include "input_ext-intf.h"
65 #include "input_ext-dec.h"
69 #include "dvd_netlist.h"
72 #include "input_dvd.h"
73 #include "mpeg_system.h"
79 /*****************************************************************************
81 *****************************************************************************/
90 /* The ISO 639 language codes.
91 * Language names with * prefix are not spelled in their own language
93 { " ", "Not Specified" },
95 { "ab", "*Abkhazian" },
96 { "af", "*Afrikaans" },
99 { "as", "*Assamese" },
101 { "az", "*Azerbaijani" },
102 { "ba", "*Bashkir" },
103 { "be", "*Byelorussian" },
104 { "bg", "*Bulgarian" },
106 { "bi", "*Bislama" },
107 { "bn", "*Bengali; Bangla" },
108 { "bo", "*Tibetan" },
110 { "ca", "*Catalan" },
111 { "co", "*Corsican" },
112 { "cs", "*Czech(Ceske)" },
116 { "dz", "*Bhutani" },
119 { "eo", "*Esperanto" },
121 { "et", "*Estonian" },
123 { "fa", "*Persian" },
126 { "fo", "*Faroese" },
127 { "fr", "Francais" },
128 { "fy", "*Frisian" },
130 { "gd", "*Scots Gaelic" },
131 { "gl", "*Galician" },
132 { "gn", "*Guarani" },
133 { "gu", "*Gujarati" },
135 { "he", "*Hebrew" }, /* formerly iw */
137 { "hr", "Hrvatski" }, /* Croatian */
139 { "hy", "*Armenian" },
140 { "ia", "*Interlingua" },
141 { "id", "*Indonesian" }, /* formerly in */
142 { "ie", "*Interlingue" },
143 { "ik", "*Inupiak" },
144 { "in", "*Indonesian" }, /* replaced by id */
145 { "is", "Islenska" },
146 { "it", "Italiano" },
147 { "iu", "*Inuktitut" },
148 { "iw", "*Hebrew" }, /* replaced by he */
149 { "ja", "*Japanese" },
150 { "ji", "*Yiddish" }, /* replaced by yi */
151 { "jw", "*Javanese" },
152 { "ka", "*Georgian" },
154 { "kl", "*Greenlandic" },
155 { "km", "*Cambodian" },
156 { "kn", "*Kannada" },
158 { "ks", "*Kashmiri" },
159 { "ku", "*Kurdish" },
160 { "ky", "*Kirghiz" },
162 { "ln", "*Lingala" },
163 { "lo", "*Laothian" },
164 { "lt", "*Lithuanian" },
165 { "lv", "*Latvian, Lettish" },
166 { "mg", "*Malagasy" },
168 { "mk", "*Macedonian" },
169 { "ml", "*Malayalam" },
170 { "mn", "*Mongolian" },
171 { "mo", "*Moldavian" },
172 { "mr", "*Marathi" },
174 { "mt", "*Maltese" },
175 { "my", "*Burmese" },
178 { "nl", "Nederlands" },
180 { "oc", "*Occitan" },
181 { "om", "*(Afan) Oromo" },
183 { "pa", "*Punjabi" },
185 { "ps", "*Pashto, Pushto" },
186 { "pt", "Portugues" },
187 { "qu", "*Quechua" },
188 { "rm", "*Rhaeto-Romance" },
189 { "rn", "*Kirundi" },
190 { "ro", "*Romanian" },
191 { "ru", "*Russian" },
192 { "rw", "*Kinyarwanda" },
193 { "sa", "*Sanskrit" },
196 { "sh", "*Serbo-Croatian" },
197 { "si", "*Sinhalese" },
199 { "sl", "*Slovenian" },
203 { "sq", "*Albanian" },
204 { "sr", "*Serbian" },
205 { "ss", "*Siswati" },
206 { "st", "*Sesotho" },
207 { "su", "*Sundanese" },
209 { "sw", "*Swahili" },
214 { "ti", "*Tigrinya" },
215 { "tk", "*Turkmen" },
216 { "tl", "*Tagalog" },
217 { "tn", "*Setswana" },
219 { "tr", "*Turkish" },
224 { "uk", "*Ukrainian" },
227 { "vi", "*Vietnamese" },
228 { "vo", "*Volapuk" },
231 { "yi", "*Yiddish" }, /* formerly ji */
234 { "zh", "*Chinese" },
239 /*****************************************************************************
241 *****************************************************************************/
242 static int DVDProbe ( probedata_t *p_data );
243 static int DVDCheckCSS ( struct input_thread_s * );
244 static int DVDRead ( struct input_thread_s *, data_packet_t ** );
245 static void DVDInit ( struct input_thread_s * );
246 static void DVDEnd ( struct input_thread_s * );
247 static void DVDSeek ( struct input_thread_s *, off_t );
248 static int DVDSetArea ( struct input_thread_s *, int, int, int, int );
249 static int DVDRewind ( struct input_thread_s * );
251 /*****************************************************************************
252 * Functions exported as capabilities. They are declared as static so that
253 * we don't pollute the namespace too much.
254 *****************************************************************************/
255 void _M( input_getfunctions )( function_list_t * p_function_list )
257 #define input p_function_list->functions.input
258 p_function_list->pf_probe = DVDProbe;
259 input.pf_init = DVDInit;
260 input.pf_open = input_FileOpen;
261 input.pf_close = input_FileClose;
262 input.pf_end = DVDEnd;
263 input.pf_read = DVDRead;
264 input.pf_set_area = DVDSetArea;
265 input.pf_demux = input_DemuxPS;
266 input.pf_new_packet = DVDNewPacket;
267 input.pf_new_pes = DVDNewPES;
268 input.pf_delete_packet = DVDDeletePacket;
269 input.pf_delete_pes = DVDDeletePES;
270 input.pf_rewind = DVDRewind;
271 input.pf_seek = DVDSeek;
276 * Local tools to decode some data in ifo
279 /*****************************************************************************
280 * Language: gives the long language name from the two-letters ISO-639 code
281 *****************************************************************************/
282 static char * Language( u16 i_code )
286 while( memcmp( lang_tbl[i].p_code, &i_code, 2 ) &&
287 lang_tbl[i].p_lang_long[0] )
292 return lang_tbl[i].p_lang_long;
296 * Data reading functions
299 /*****************************************************************************
300 * DVDProbe: verifies that the stream is a PS stream
301 *****************************************************************************/
302 static int DVDProbe( probedata_t *p_data )
304 input_thread_t * p_input = (input_thread_t *)p_data;
306 char * psz_name = p_input->p_source;
310 if( TestMethod( INPUT_METHOD_VAR, "dvd" ) )
315 if( ( strlen(psz_name) > 4 ) && !strncasecmp( psz_name, "dvd:", 4 ) )
317 /* If the user specified "dvd:" then it's probably a DVD */
322 i_handle = open( psz_name, 0 );
332 /*****************************************************************************
333 * DVDCheckCSS: check the stream
334 *****************************************************************************/
335 static int DVDCheckCSS( input_thread_t * p_input )
337 return CSSTest( p_input->i_handle );
340 /*****************************************************************************
341 * DVDChapterSelect: find the cell corresponding to requested chapter
342 *****************************************************************************/
343 static int DVDChapterSelect( thread_dvd_data_t * p_dvd, int i_chapter )
351 p_pgc = &p_dvd->ifo.vts.pgci_ti.p_srp[0].pgc;
353 /* Find cell index in Program chain for current chapter */
354 i_index = p_pgc->prg_map.pi_entry_cell[i_chapter-1] - 1;
356 /* Search for cell_index in cell adress_table */
358 while( p_pgc->p_cell_pos_inf[i_index].i_vob_id >
359 p_dvd->ifo.vts.c_adt.p_cell_inf[i_cell].i_vob_id )
363 while( p_pgc->p_cell_pos_inf[i_index].i_cell_id >
364 p_dvd->ifo.vts.c_adt.p_cell_inf[i_cell].i_cell_id )
369 i_start_cell = i_cell;
371 p_dvd->i_start = p_dvd->ifo.vts.i_pos + DVD_LB_SIZE *
372 (off_t)( p_dvd->ifo.vts.mat.i_tt_vobs_ssector +
373 p_dvd->ifo.vts.c_adt.p_cell_inf[i_start_cell].i_ssector );
377 i_end_cell = i_start_cell + p_pgc->i_cell_nb - 1;
378 p_dvd->i_size = (off_t)DVD_LB_SIZE *
379 ( p_dvd->ifo.vts.c_adt.p_cell_inf[i_end_cell].i_esector -
380 p_dvd->ifo.vts.c_adt.p_cell_inf[i_start_cell].i_ssector + 1 );
381 p_dvd->i_chapter_nb = p_pgc->i_cell_nb;
382 intf_WarnMsg( 3, "DVD: Start cell: %d End Cell: %d",
383 i_start_cell, i_end_cell );
389 /*****************************************************************************
390 * DVDSetArea: initialize input data for title x, chapter y.
391 * It should be called for each user navigation request, and to change
392 * audio or sub-picture streams.
394 * Take care that i_title starts from 0 (vmg) and i_chapter start from 1.
395 * i_audio, i_spu start from 1 ; 0 means off.
396 * A negative value for an argument means it does not change
397 *****************************************************************************/
398 static int DVDSetArea( input_thread_t * p_input,
399 int i_title, int i_chapter,
400 int i_audio, int i_spu )
402 thread_dvd_data_t * p_method;
403 es_descriptor_t * p_es;
413 p_method = (thread_dvd_data_t*)p_input->p_plugin_data;
415 vlc_mutex_lock( &p_input->stream.stream_lock );
420 * We have to load all title information
423 /* Change the default area */
424 p_input->stream.p_selected_area = p_input->stream.pp_areas[i_title];
426 /* Ifo VTS, and CSS reading */
427 p_method->ifo.i_title = i_title;
428 IfoReadVTS( &(p_method->ifo) );
429 intf_WarnMsg( 2, "Ifo: VTS initialized" );
431 if( p_method->b_encrypted )
433 p_method->css.i_title = i_title;
434 p_method->css.i_title_pos =
435 p_method->ifo.vts.i_pos +
436 p_method->ifo.vts.mat.i_tt_vobs_ssector * DVD_LB_SIZE;
437 CSSGetKey( &(p_method->css) );
438 intf_WarnMsg( 2, "css info: VTS key initialized" );
442 * Set selected title start and size
444 DVDChapterSelect( p_method, 1 );
446 /* start is : beginning of vts + offset to vobs + offset to vob x */
449 lseek( p_input->i_handle, p_method->i_start, SEEK_SET );
451 intf_WarnMsg( 2, "DVD: vobstart at: %lld", p_method->i_start );
452 intf_WarnMsg( 2, "DVD: stream size: %lld", p_method->i_size );
453 intf_WarnMsg( 2, "DVD: number of chapters: %lld",
454 p_method->i_chapter_nb );
456 /* Area definition */
457 p_input->stream.p_selected_area->i_start = p_method->i_start;
458 p_input->stream.p_selected_area->i_size = p_method->i_size;
459 p_input->stream.p_selected_area->i_part_nb = p_method->i_chapter_nb;
462 * Destroy obsolete ES by reinitializing program 0
463 * and find all ES in title with ifo data
465 if( p_input->stream.pp_programs != NULL )
467 input_DelProgram( p_input, p_input->stream.pp_programs[0] );
470 input_AddProgram( p_input, 0, sizeof( stream_ps_data_t ) );
474 /* ES 0 -> video MPEG2 */
475 p_es = input_AddES( p_input, p_input->stream.pp_programs[0], 0xe0, 0 );
476 p_es->i_stream_id = 0xe0;
477 p_es->i_type = MPEG2_VIDEO_ES;
478 input_SelectES( p_input, p_es );
479 intf_WarnMsg( 1, "DVD: Video MPEG2 stream" );
481 /* Audio ES, in the order they appear in .ifo */
482 i_nb = p_method->ifo.vts.mat.i_audio_nb;
487 for( i = 1 ; i <= i_nb ; i++ )
491 fprintf( stderr, "Audio %d: %x %x %x %x %x %x %x\n", i,
492 p_method->ifo.vts.mat.p_audio_atrt[i].i_num_channels,
493 p_method->ifo.vts.mat.p_audio_atrt[i].i_coding_mode,
494 p_method->ifo.vts.mat.p_audio_atrt[i].i_multichannel_extension,
495 p_method->ifo.vts.mat.p_audio_atrt[i].i_type,
496 p_method->ifo.vts.mat.p_audio_atrt[i].i_appl_mode,
497 p_method->ifo.vts.mat.p_audio_atrt[i].i_foo,
498 p_method->ifo.vts.mat.p_audio_atrt[i].i_bar );
501 switch( p_method->ifo.vts.mat.p_audio_atrt[i].i_coding_mode )
504 i_id = ( ( 0x7f + i ) << 8 ) | 0xbd;
505 p_es = input_AddES( p_input,
506 p_input->stream.pp_programs[0], i_id, 0 );
507 p_es->i_stream_id = 0xbd;
508 p_es->i_type = AC3_AUDIO_ES;
510 strcpy( p_es->psz_desc, Language( hton16(
511 p_method->ifo.vts.mat.p_audio_atrt[i-1].i_lang_code ) ) );
515 case 0x03: /* MPEG audio */
517 p_es = input_AddES( p_input,
518 p_input->stream.pp_programs[0], i_id, 0 );
519 p_es->i_stream_id = i_id;
520 p_es->i_type = MPEG2_AUDIO_ES;
522 strcpy( p_es->psz_desc, Language( hton16(
523 p_method->ifo.vts.mat.p_audio_atrt[i-1].i_lang_code ) ) );
526 case 0x04: /* LPCM */
528 intf_ErrMsg( "DVD: LPCM audio not handled yet" );
532 intf_ErrMsg( "DVD: DTS audio not handled yet" );
536 intf_ErrMsg( "DVD: unkown audio" );
539 intf_WarnMsg( 1, "DVD: Audio stream %d %s\t(0x%x)",
540 i, p_es->psz_desc, i_id );
544 i_nb = p_method->ifo.vts.mat.i_subpic_nb;
548 for( i = 1 ; i <= i_nb ; i++ )
552 i_id = ( i_sub_pic++ << 8 ) | 0xbd;
553 p_es = input_AddES( p_input,
554 p_input->stream.pp_programs[0], i_id, 0 );
555 p_es->i_stream_id = 0xbd;
556 p_es->i_type = DVD_SPU_ES;
557 strcpy( p_es->psz_desc, Language( hton16(
558 p_method->ifo.vts.mat.p_subpic_atrt[i-1].i_lang_code ) ) );
559 intf_WarnMsg( 1, "DVD: SPU stream %d %s\t(0x%x)",
560 i, p_es->psz_desc, i_id );
562 /* The before the last spu has a 0x0 prefix */
564 ( p_method->ifo.vts.mat.p_subpic_atrt[i].i_prefix == 0 );
571 * Select requested ES
573 if( ( i_audio >= 0 ) || ( i_title >= 0 ) )
576 /* Audio: we check it is in the range and
577 * default it to the first if not */
578 if( i_audio > p_method->ifo.vts.mat.i_audio_nb )
583 p_es = p_input->stream.pp_programs[0]->pp_es[i_audio];
585 /* We can only have one audio channel */
586 /* Look for a preselected one */
588 for( i = 0 ; i < p_input->stream.i_selected_es_number ; i++ )
590 if( p_input->stream.pp_selected_es[i]->b_audio )
600 if( p_input->stream.pp_selected_es[i_index] != p_es )
602 input_UnSelectES( p_input,
603 p_input->stream.pp_selected_es[i_index] );
604 input_SelectES( p_input, p_es );
605 intf_WarnMsg( 1, "DVD: Audio %d selected -> %s (0x%x)",
606 i_audio, p_es->psz_desc, p_es->i_id );
611 input_SelectES( p_input, p_es );
612 intf_WarnMsg( 1, "DVD: Audio %d selected -> %s (0x%x)",
613 i_audio, p_es->psz_desc, p_es->i_id );
617 if( ( i_spu >= 0 ) || ( i_title >= 0 ) )
619 /* For spu: no one if none or a not existed one requested */
620 if( ( i_spu <= p_method->ifo.vts.mat.i_subpic_nb ) && ( i_spu > 0 ) )
622 input_SelectES( p_input, ( p_es = p_input->stream.pp_programs[0]->
623 pp_es[ i_spu + p_method->ifo.vts.mat.i_audio_nb ] ) );
625 intf_WarnMsg( 1, "DVD: SPU %d selected -> %s (0x%x)",
626 i_spu, p_es->psz_desc, p_es->i_id );
634 if( ( i_chapter > 0 ) &&
635 ( i_chapter <= p_input->stream.p_selected_area->i_part_nb ) )
637 DVDChapterSelect( p_method, i_chapter );
639 p_input->stream.p_selected_area->i_part = i_chapter;
641 DVDSeek( p_input, p_method->i_start -
642 p_input->stream.p_selected_area->i_start );
644 intf_WarnMsg( 2, "DVD: Chapter %d start at: %lld", i_chapter,
645 p_input->stream.p_selected_area->i_tell );
648 /* No PSM to read in DVD mode, we already have all information */
649 p_input->stream.pp_programs[0]->b_is_ok = 1;
651 vlc_mutex_unlock( &p_input->stream.stream_lock );
656 /*****************************************************************************
657 * DVDInit: initializes DVD structures
658 *****************************************************************************/
659 static void DVDInit( input_thread_t * p_input )
661 thread_dvd_data_t * p_method;
668 if( (p_method = malloc( sizeof(thread_dvd_data_t) )) == NULL )
670 intf_ErrMsg( "Out of memory" );
671 p_input->b_error = 1;
675 p_input->p_plugin_data = (void *)p_method;
676 p_input->p_method_data = NULL;
678 p_method->i_fd = p_input->i_handle;
680 p_method->i_block_once = 32;
681 p_input->i_read_once = 128;
683 p_method->b_encrypted = DVDCheckCSS( p_input );
685 lseek( p_input->i_handle, 0, SEEK_SET );
687 /* Reading structures initialisation */
688 DVDNetlistInit( p_input, 4096, 16384, 4096, DVD_LB_SIZE,
689 p_method->i_block_once );
690 intf_WarnMsg( 2, "DVD: Netlist initialized" );
692 /* Ifo initialisation */
693 p_method->ifo = IfoInit( p_input->i_handle );
694 intf_WarnMsg( 2, "Ifo: VMG initialized" );
696 /* CSS initialisation */
697 if( p_method->b_encrypted )
699 p_method->css = CSSInit( p_input->i_handle );
701 if( ( p_input->b_error = p_method->css.b_error ) )
703 intf_ErrMsg( "css error: fatal failure" );
706 intf_WarnMsg( 2, "css info: initialized" );
709 /* Initialize ES structures */
710 input_InitStream( p_input, sizeof( stream_ps_data_t ) );
712 /* Set stream and area data */
713 vlc_mutex_lock( &p_input->stream.stream_lock );
715 /* FIXME: We consider here that one title is one title set
716 * it is not true !!! */
718 intf_WarnMsg( 2, "DVD: Number of titles: %d",
719 p_method->ifo.vmg.mat.i_tts_nb );
721 #define area p_input->stream.pp_areas
722 /* We start from 1 here since area 0 is reserved for video_ts.vob */
723 for( i = 1 ; i <= p_method->ifo.vmg.mat.i_tts_nb ; i++ )
725 input_AddArea( p_input );
727 /* Should not be so simple eventually :
728 * are title Program Chains, or still something else ? */
731 /* Absolute start offset and size
732 * We can only set that with vts ifo, so we do it during the
733 * first call to DVDSetArea */
734 area[i]->i_start = 0;
737 /* Number of chapter */
738 area[i]->i_part_nb = 0;
740 /* Offset to vts_i_0.ifo */
741 area[i]->i_plugin_data = p_method->ifo.i_off +
742 ( p_method->ifo.vmg.ptt_srpt.p_tts[i-1].i_ssector * DVD_LB_SIZE );
746 vlc_mutex_unlock( &p_input->stream.stream_lock );
748 /* Get requested title - if none try to find one where is the movie */
749 i_title = main_GetIntVariable( INPUT_TITLE_VAR,
750 p_method->ifo.vmg.ptt_srpt.p_tts[0].i_tts_nb );
751 if( i_title <= 0 || i_title >= p_method->ifo.vmg.mat.i_tts_nb )
753 i_title = p_method->ifo.vmg.ptt_srpt.p_tts[0].i_tts_nb;
756 /* Get requested chapter - if none defaults to first one */
757 i_chapter = main_GetIntVariable( INPUT_CHAPTER_VAR, 1 );
763 /* For audio: first one if none or a not existing one specified */
764 i_audio = main_GetIntVariable( INPUT_CHANNEL_VAR, 1 );
767 main_PutIntVariable( INPUT_CHANNEL_VAR, 1 );
771 i_spu = main_GetIntVariable( INPUT_SUBTITLE_VAR, 0 );
773 DVDSetArea( p_input, i_title, i_chapter, i_audio, i_spu );
778 /*****************************************************************************
779 * DVDEnd: frees unused data
780 *****************************************************************************/
781 static void DVDEnd( input_thread_t * p_input )
783 /* FIXME: check order of calls */
784 // CSSEnd( p_input );
785 // IfoEnd( (ifo_t*)(&p_input->p_plugin_data->ifo ) );
786 free( p_input->stream.p_demux_data );
787 free( p_input->p_plugin_data );
788 DVDNetlistEnd( p_input );
791 /*****************************************************************************
792 * DVDRead: reads data packets into the netlist.
793 *****************************************************************************
794 * Returns -1 in case of error, 0 if everything went well, and 1 in case of
796 *****************************************************************************/
797 static int DVDRead( input_thread_t * p_input,
798 data_packet_t ** pp_packets )
800 thread_dvd_data_t * p_method;
801 netlist_t * p_netlist;
802 struct iovec * p_vec;
803 struct data_packet_s * pp_data[p_input->i_read_once];
810 p_method = ( thread_dvd_data_t * ) p_input->p_plugin_data;
811 p_netlist = ( netlist_t * ) p_input->p_method_data;
813 /* Get an iovec pointer */
814 if( ( p_vec = DVDGetiovec( p_netlist ) ) == NULL )
816 intf_ErrMsg( "DVD: read error" );
821 readv( p_input->i_handle, p_vec, p_method->i_block_once );
823 /* Update netlist indexes */
824 DVDMviovec( p_netlist, p_method->i_block_once, pp_data );
827 /* Read headers to compute payload length */
828 for( i_iovec = 0 ; i_iovec < p_method->i_block_once ; i_iovec++ )
830 if( p_method->b_encrypted )
832 CSSDescrambleSector( p_method->css.pi_title_key,
833 p_vec[i_iovec].iov_base );
834 ((u8*)(p_vec[i_iovec].iov_base))[0x14] &= 0x8F;
839 while( i_pos < p_netlist->i_buffer_size )
841 pi_cur = (u8*)(p_vec[i_iovec].iov_base + i_pos);
844 if( U32_AT( pi_cur ) != 0x1BA )
846 /* That's the case for all packets, except pack header. */
847 i_packet_size = U16_AT( pi_cur + 4 );
848 pp_packets[i_packet] = DVDNewPtr( p_netlist );
853 if( ( pi_cur[4] & 0xC0 ) == 0x40 )
858 else if( ( pi_cur[4] & 0xF0 ) == 0x20 )
865 intf_ErrMsg( "Unable to determine stream type" );
869 pp_packets[i_packet] = pp_data[i_iovec];
873 (*pp_data[i_iovec]->pi_refcount)++;
875 pp_packets[i_packet]->pi_refcount = pp_data[i_iovec]->pi_refcount;
877 pp_packets[i_packet]->p_buffer = pp_data[i_iovec]->p_buffer;
879 pp_packets[i_packet]->p_payload_start =
880 pp_packets[i_packet]->p_buffer + i_pos;
882 pp_packets[i_packet]->p_payload_end =
883 pp_packets[i_packet]->p_payload_start + i_packet_size + 6;
886 i_pos += i_packet_size + 6;
890 pp_packets[i_packet] = NULL;
892 vlc_mutex_lock( &p_input->stream.stream_lock );
893 p_input->stream.p_selected_area->i_tell +=
894 p_method->i_block_once *DVD_LB_SIZE;
895 vlc_mutex_unlock( &p_input->stream.stream_lock );
901 /*****************************************************************************
902 * DVDRewind : reads a stream backward
903 *****************************************************************************/
904 static int DVDRewind( input_thread_t * p_input )
909 /*****************************************************************************
910 * DVDSeek : Goes to a given position on the stream ; this one is used by the
911 * input and translate chronological position from input to logical postion
913 *****************************************************************************/
914 static void DVDSeek( input_thread_t * p_input, off_t i_off )
916 thread_dvd_data_t * p_method;
919 p_method = ( thread_dvd_data_t * )p_input->p_plugin_data;
921 /* We have to take care of offset of beginning of title */
922 i_pos = i_off + p_input->stream.p_selected_area->i_start;
924 /* With DVD, we have to be on a sector boundary */
925 i_pos = i_pos & (~0x7ff);
927 i_pos = lseek( p_input->i_handle, i_pos, SEEK_SET );
929 p_input->stream.p_selected_area->i_tell = i_pos -
930 p_input->stream.p_selected_area->i_start;