2001-08-09 01:17:24 +00:00
|
|
|
|
2002-01-24 23:02:59 +00:00
|
|
|
#include <ctype.h>
|
2001-08-09 01:17:24 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
2001-08-17 00:40:25 +00:00
|
|
|
#include "mp_msg.h"
|
2001-08-18 20:32:09 +00:00
|
|
|
#include "help_mp.h"
|
2001-08-09 01:17:24 +00:00
|
|
|
|
2001-08-09 15:47:40 +00:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <sys/cdrio.h>
|
|
|
|
#endif
|
|
|
|
|
2002-01-24 23:02:59 +00:00
|
|
|
#include "../cfgparser.h"
|
2001-08-09 01:17:24 +00:00
|
|
|
#include "stream.h"
|
2001-08-11 12:46:01 +00:00
|
|
|
#include "demuxer.h"
|
2002-02-06 20:16:35 +00:00
|
|
|
#include "mf.h"
|
2001-08-09 01:17:24 +00:00
|
|
|
|
|
|
|
#ifdef STREAMING
|
|
|
|
#include "url.h"
|
|
|
|
#include "network.h"
|
2002-11-06 23:54:29 +00:00
|
|
|
extern int streaming_start( stream_t *stream, int *demuxer_type, URL_t *url);
|
2002-08-05 00:39:07 +00:00
|
|
|
#ifdef STREAMING_LIVE_DOT_COM
|
|
|
|
#include "demux_rtp.h"
|
|
|
|
int isSDPFile = 0;
|
|
|
|
#endif
|
2001-08-09 01:17:24 +00:00
|
|
|
static URL_t* url;
|
|
|
|
#endif
|
|
|
|
|
2001-08-20 21:20:03 +00:00
|
|
|
int dvd_title=0;
|
|
|
|
int dvd_chapter=1;
|
2002-01-21 09:44:31 +00:00
|
|
|
int dvd_last_chapter=0;
|
2001-08-20 21:20:03 +00:00
|
|
|
int dvd_angle=1;
|
2002-01-17 20:40:07 +00:00
|
|
|
char* dvd_device=NULL;
|
|
|
|
char* cdrom_device=NULL;
|
2002-04-03 17:55:31 +00:00
|
|
|
int dvd_nav=0; /* use libdvdnav? */
|
2002-03-28 20:40:21 +00:00
|
|
|
|
2002-03-28 22:45:09 +00:00
|
|
|
#ifdef USE_DVDNAV
|
2002-04-03 17:55:31 +00:00
|
|
|
#include "dvdnav_stream.h"
|
2002-03-28 20:40:21 +00:00
|
|
|
#endif
|
2001-08-20 21:20:03 +00:00
|
|
|
|
|
|
|
#ifdef USE_DVDREAD
|
|
|
|
|
2001-09-09 18:02:50 +00:00
|
|
|
#define DVDREAD_VERSION(maj,min,micro) ((maj)*10000 + (min)*100 + (micro))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to autodetect the libdvd-0.9.0 library
|
|
|
|
* (0.9.0 removed the <dvdread/dvd_udf.h> header, and moved the two defines
|
|
|
|
* DVD_VIDEO_LB_LEN and MAX_UDF_FILE_NAME_LEN from it to
|
|
|
|
* <dvdread/dvd_reader.h>)
|
|
|
|
*/
|
|
|
|
#if defined(DVD_VIDEO_LB_LEN) && defined(MAX_UDF_FILE_NAME_LEN)
|
|
|
|
#define LIBDVDREAD_VERSION DVDREAD_VERSION(0,9,0)
|
|
|
|
#else
|
|
|
|
#define LIBDVDREAD_VERSION DVDREAD_VERSION(0,8,0)
|
|
|
|
#endif
|
|
|
|
|
2001-11-16 22:26:57 +00:00
|
|
|
char * dvd_audio_stream_types[8] =
|
|
|
|
{ "ac3","unknown","mpeg1","mpeg2ext","lpcm","unknown","dts" };
|
2001-08-20 21:20:03 +00:00
|
|
|
|
2002-07-05 23:47:00 +00:00
|
|
|
char * dvd_audio_stream_channels[6] =
|
|
|
|
{ "unknown", "stereo", "unknown", "unknown", "unknown", "5.1" };
|
2001-08-20 21:20:03 +00:00
|
|
|
#endif
|
|
|
|
|
2001-08-09 01:17:24 +00:00
|
|
|
extern int vcd_get_track_end(int fd,int track);
|
|
|
|
|
2001-11-09 23:46:06 +00:00
|
|
|
#ifdef USE_TV
|
|
|
|
#include "tv.h"
|
2001-11-16 21:30:10 +00:00
|
|
|
|
|
|
|
extern int stream_open_tv(stream_t *stream, tvi_handle_t *tvh);
|
2001-11-09 23:46:06 +00:00
|
|
|
#endif
|
|
|
|
|
2002-06-11 14:29:51 +00:00
|
|
|
#ifdef HAVE_CDDA
|
|
|
|
stream_t* open_cdda(char* dev,char* track);
|
2002-09-17 19:52:27 +00:00
|
|
|
#ifdef STREAMING
|
2002-06-21 06:15:36 +00:00
|
|
|
stream_t* cddb_open(char* dev,char* track);
|
2002-06-11 14:29:51 +00:00
|
|
|
#endif
|
2002-09-17 19:52:27 +00:00
|
|
|
#endif
|
2002-06-11 14:29:51 +00:00
|
|
|
|
2002-10-06 18:03:12 +00:00
|
|
|
// Define function about auth the libsmbclient library
|
|
|
|
// FIXME: I really do not not is this function is properly working
|
|
|
|
|
|
|
|
#ifdef LIBSMBCLIENT
|
|
|
|
|
|
|
|
#include "libsmbclient.h"
|
|
|
|
|
|
|
|
static char smb_password[15];
|
|
|
|
static char smb_username[15];
|
|
|
|
|
|
|
|
static void smb_auth_fn(const char *server, const char *share,
|
|
|
|
char *workgroup, int wgmaxlen, char *username, int unmaxlen,
|
|
|
|
char *password, int pwmaxlen)
|
|
|
|
{
|
|
|
|
char temp[128];
|
|
|
|
|
|
|
|
strcpy(temp, "LAN");
|
|
|
|
if (temp[strlen(temp) - 1] == 0x0a)
|
|
|
|
temp[strlen(temp) - 1] = 0x00;
|
|
|
|
|
|
|
|
if (temp[0]) strncpy(workgroup, temp, wgmaxlen - 1);
|
|
|
|
|
|
|
|
strcpy(temp, smb_username);
|
|
|
|
if (temp[strlen(temp) - 1] == 0x0a)
|
|
|
|
temp[strlen(temp) - 1] = 0x00;
|
|
|
|
|
|
|
|
if (temp[0]) strncpy(username, temp, unmaxlen - 1);
|
|
|
|
|
|
|
|
strcpy(temp, smb_password);
|
|
|
|
if (temp[strlen(temp) - 1] == 0x0a)
|
|
|
|
temp[strlen(temp) - 1] = 0x00;
|
|
|
|
|
|
|
|
if (temp[0]) strncpy(password, temp, pwmaxlen - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2001-08-09 01:17:24 +00:00
|
|
|
// Open a new stream (stdin/file/vcd/url)
|
|
|
|
|
|
|
|
stream_t* open_stream(char* filename,int vcd_track,int* file_format){
|
|
|
|
stream_t* stream=NULL;
|
|
|
|
int f=-1;
|
|
|
|
off_t len;
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
int bsize = VCD_SECTOR_SIZE;
|
|
|
|
#endif
|
|
|
|
|
2002-06-11 14:29:51 +00:00
|
|
|
#ifdef HAVE_CDDA
|
2002-06-21 22:52:01 +00:00
|
|
|
if(filename && strncmp("cdda://",filename,7) == 0)
|
2002-06-11 14:29:51 +00:00
|
|
|
return open_cdda(cdrom_device ? cdrom_device : DEFAULT_CDROM_DEVICE,filename+7);
|
2002-09-17 19:52:27 +00:00
|
|
|
#ifdef STREAMING
|
2002-06-21 22:52:01 +00:00
|
|
|
if(filename && strncmp("cddb://",filename,7) == 0)
|
2002-06-21 06:15:36 +00:00
|
|
|
return cddb_open(cdrom_device ? cdrom_device : DEFAULT_CDROM_DEVICE,filename+7);
|
2002-06-11 14:29:51 +00:00
|
|
|
#endif
|
2002-09-17 19:52:27 +00:00
|
|
|
#endif
|
2002-06-11 14:29:51 +00:00
|
|
|
|
2001-08-09 01:17:24 +00:00
|
|
|
//============ Open VideoCD track ==============
|
2001-12-01 23:40:24 +00:00
|
|
|
#ifdef HAVE_VCD
|
2001-08-09 01:17:24 +00:00
|
|
|
if(vcd_track){
|
|
|
|
int ret,ret2;
|
2002-01-17 20:40:07 +00:00
|
|
|
if(!cdrom_device) cdrom_device=DEFAULT_CDROM_DEVICE;
|
|
|
|
f=open(cdrom_device,O_RDONLY);
|
|
|
|
if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,cdrom_device);return NULL; }
|
2001-08-09 01:17:24 +00:00
|
|
|
vcd_read_toc(f);
|
|
|
|
ret2=vcd_get_track_end(f,vcd_track);
|
2001-08-18 20:32:09 +00:00
|
|
|
if(ret2<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n");return NULL;}
|
2001-08-09 01:17:24 +00:00
|
|
|
ret=vcd_seek_to_track(f,vcd_track);
|
2001-08-18 20:32:09 +00:00
|
|
|
if(ret<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");return NULL;}
|
2001-08-17 00:40:25 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_V,"VCD start byte position: 0x%X end: 0x%X\n",ret,ret2);
|
2001-08-09 01:17:24 +00:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
if (ioctl (f, CDRIOCSETBLOCKSIZE, &bsize) == -1) {
|
|
|
|
perror ( "Error in CDRIOCSETBLOCKSIZE");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
stream=new_stream(f,STREAMTYPE_VCD);
|
|
|
|
stream->start_pos=ret;
|
|
|
|
stream->end_pos=ret2;
|
|
|
|
return stream;
|
|
|
|
}
|
2001-12-01 23:40:24 +00:00
|
|
|
#endif
|
2001-08-09 01:17:24 +00:00
|
|
|
|
2001-08-20 21:20:03 +00:00
|
|
|
//============ Open DVD title ==============
|
2002-03-28 20:40:21 +00:00
|
|
|
#ifdef USE_DVDNAV
|
|
|
|
if(dvd_nav){
|
2002-04-03 17:55:31 +00:00
|
|
|
dvdnav_priv_t *dvdnav_priv;
|
2002-03-28 20:40:21 +00:00
|
|
|
int event,len,tmplen=0;
|
|
|
|
|
|
|
|
stream=new_stream(-1,STREAMTYPE_DVDNAV);
|
|
|
|
if (!stream) {
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_Exit_error);
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-04-03 17:55:31 +00:00
|
|
|
|
|
|
|
if(!filename) filename=DEFAULT_DVD_DEVICE;
|
|
|
|
if (!(dvdnav_priv=new_dvdnav_stream(filename))) {
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
stream->priv=(void*)dvdnav_priv;
|
2002-03-28 20:40:21 +00:00
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
#endif
|
2001-08-20 21:20:03 +00:00
|
|
|
#ifdef USE_DVDREAD
|
|
|
|
if(dvd_title){
|
2001-10-02 21:45:41 +00:00
|
|
|
// int ret,ret2;
|
2002-03-28 20:40:21 +00:00
|
|
|
dvd_priv_t *d;
|
2001-08-20 21:20:03 +00:00
|
|
|
int ttn,pgc_id,pgn;
|
|
|
|
dvd_reader_t *dvd;
|
|
|
|
dvd_file_t *title;
|
|
|
|
ifo_handle_t *vmg_file;
|
|
|
|
tt_srpt_t *tt_srpt;
|
|
|
|
ifo_handle_t *vts_file;
|
|
|
|
/**
|
|
|
|
* Open the disc.
|
|
|
|
*/
|
2002-01-17 20:40:07 +00:00
|
|
|
if(!dvd_device) dvd_device=DEFAULT_DVD_DEVICE;
|
|
|
|
dvd = DVDOpen(dvd_device);
|
2001-08-20 21:20:03 +00:00
|
|
|
if( !dvd ) {
|
2002-01-17 20:40:07 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,dvd_device);
|
2001-08-20 21:20:03 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-26 21:35:14 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_DVDwait);
|
2001-08-20 21:20:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load the video manager to find out the information about the titles on
|
|
|
|
* this disc.
|
|
|
|
*/
|
|
|
|
vmg_file = ifoOpen( dvd, 0 );
|
|
|
|
if( !vmg_file ) {
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR, "Can't open VMG info!\n");
|
|
|
|
DVDClose( dvd );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
tt_srpt = vmg_file->tt_srpt;
|
|
|
|
/**
|
|
|
|
* Make sure our title number is valid.
|
|
|
|
*/
|
2001-09-26 21:35:14 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumTitles,
|
2001-08-20 21:20:03 +00:00
|
|
|
tt_srpt->nr_of_srpts );
|
|
|
|
if( dvd_title < 1 || dvd_title > tt_srpt->nr_of_srpts ) {
|
2001-09-26 21:35:14 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidTitle, dvd_title);
|
2001-08-20 21:20:03 +00:00
|
|
|
ifoClose( vmg_file );
|
|
|
|
DVDClose( dvd );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
--dvd_title; // remap 1.. -> 0..
|
|
|
|
/**
|
|
|
|
* Make sure the chapter number is valid for this title.
|
|
|
|
*/
|
2001-09-26 21:35:14 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumChapters,
|
2001-08-20 21:20:03 +00:00
|
|
|
tt_srpt->title[dvd_title].nr_of_ptts );
|
|
|
|
if( dvd_chapter<1 || dvd_chapter>tt_srpt->title[dvd_title].nr_of_ptts ) {
|
2001-09-26 21:35:14 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidChapter, dvd_chapter);
|
2001-08-20 21:20:03 +00:00
|
|
|
ifoClose( vmg_file );
|
|
|
|
DVDClose( dvd );
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-01-21 09:44:31 +00:00
|
|
|
if( dvd_last_chapter>0 ) {
|
|
|
|
if ( dvd_last_chapter<dvd_chapter || dvd_last_chapter>tt_srpt->title[dvd_title].nr_of_ptts ) {
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR, "Invalid DVD last chapter number: %d\n", dvd_last_chapter);
|
|
|
|
ifoClose( vmg_file );
|
|
|
|
DVDClose( dvd );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2001-08-20 21:20:03 +00:00
|
|
|
--dvd_chapter; // remap 1.. -> 0..
|
2002-01-21 09:44:31 +00:00
|
|
|
/* XXX No need to remap dvd_last_chapter */
|
2001-08-20 21:20:03 +00:00
|
|
|
/**
|
|
|
|
* Make sure the angle number is valid for this title.
|
|
|
|
*/
|
2001-09-26 21:35:14 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumAngles,
|
2001-08-20 21:20:03 +00:00
|
|
|
tt_srpt->title[dvd_title].nr_of_angles );
|
|
|
|
if( dvd_angle<1 || dvd_angle>tt_srpt->title[dvd_title].nr_of_angles ) {
|
2001-09-27 00:19:07 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidAngle, dvd_angle);
|
2001-08-20 21:20:03 +00:00
|
|
|
ifoClose( vmg_file );
|
|
|
|
DVDClose( dvd );
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-08-22 08:24:29 +00:00
|
|
|
--dvd_angle; // remap 1.. -> 0..
|
2001-08-20 21:20:03 +00:00
|
|
|
/**
|
|
|
|
* Load the VTS information for the title set our title is in.
|
|
|
|
*/
|
|
|
|
vts_file = ifoOpen( dvd, tt_srpt->title[dvd_title].title_set_nr );
|
|
|
|
if( !vts_file ) {
|
2001-09-26 21:35:14 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoIFO,
|
2001-08-20 21:20:03 +00:00
|
|
|
tt_srpt->title[dvd_title].title_set_nr );
|
|
|
|
ifoClose( vmg_file );
|
|
|
|
DVDClose( dvd );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* We've got enough info, time to open the title set data.
|
|
|
|
*/
|
|
|
|
title = DVDOpenFile( dvd, tt_srpt->title[dvd_title].title_set_nr,
|
|
|
|
DVD_READ_TITLE_VOBS );
|
|
|
|
if( !title ) {
|
2001-09-26 21:35:14 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoVOBs,
|
2001-08-20 21:20:03 +00:00
|
|
|
tt_srpt->title[dvd_title].title_set_nr );
|
|
|
|
ifoClose( vts_file );
|
|
|
|
ifoClose( vmg_file );
|
|
|
|
DVDClose( dvd );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-26 21:35:14 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDopenOk);
|
2001-08-20 21:20:03 +00:00
|
|
|
// store data
|
|
|
|
d=malloc(sizeof(dvd_priv_t)); memset(d,0,sizeof(dvd_priv_t));
|
|
|
|
d->dvd=dvd;
|
|
|
|
d->title=title;
|
|
|
|
d->vmg_file=vmg_file;
|
|
|
|
d->tt_srpt=tt_srpt;
|
|
|
|
d->vts_file=vts_file;
|
|
|
|
|
2001-11-16 22:26:57 +00:00
|
|
|
/**
|
|
|
|
* Check number of audio channels and types
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
int ac3aid = 128;
|
|
|
|
int mpegaid = 0;
|
|
|
|
int pcmaid = 160;
|
|
|
|
|
|
|
|
d->nr_of_channels=0;
|
|
|
|
|
|
|
|
if ( vts_file->vts_pgcit )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for ( i=0;i<8;i++ )
|
|
|
|
if ( vts_file->vts_pgcit->pgci_srp[0].pgc->audio_control[i] & 0x8000 )
|
|
|
|
{
|
|
|
|
audio_attr_t * audio = &vts_file->vtsi_mat->vts_audio_attr[i];
|
|
|
|
int language = 0;
|
|
|
|
char tmp[] = "unknown";
|
|
|
|
|
|
|
|
if ( audio->lang_type == 1 )
|
|
|
|
{
|
|
|
|
language=audio->lang_code;
|
|
|
|
tmp[0]=language>>8;
|
|
|
|
tmp[1]=language&0xff;
|
|
|
|
tmp[2]=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
d->audio_streams[d->nr_of_channels].language=language;
|
|
|
|
d->audio_streams[d->nr_of_channels].id=0;
|
|
|
|
switch ( audio->audio_format )
|
|
|
|
{
|
|
|
|
case 0: // ac3
|
|
|
|
case 6: // dts
|
|
|
|
d->audio_streams[d->nr_of_channels].id=ac3aid;
|
|
|
|
ac3aid++;
|
|
|
|
break;
|
|
|
|
case 2: // mpeg layer 1/2/3
|
|
|
|
case 3: // mpeg2 ext
|
|
|
|
d->audio_streams[d->nr_of_channels].id=mpegaid;
|
|
|
|
mpegaid++;
|
|
|
|
break;
|
|
|
|
case 4: // lpcm
|
|
|
|
d->audio_streams[d->nr_of_channels].id=pcmaid;
|
|
|
|
pcmaid++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-07-05 23:47:00 +00:00
|
|
|
d->audio_streams[d->nr_of_channels].type=audio->audio_format;
|
|
|
|
// Pontscho: to my mind, tha channels:
|
|
|
|
// 1 - stereo
|
|
|
|
// 5 - 5.1
|
|
|
|
d->audio_streams[d->nr_of_channels].channels=audio->channels;
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_V,"[open] audio stream: %d audio format: %s (%s) language: %s aid: %d\n",
|
2001-11-16 22:26:57 +00:00
|
|
|
d->nr_of_channels,
|
|
|
|
dvd_audio_stream_types[ audio->audio_format ],
|
2002-07-05 23:47:00 +00:00
|
|
|
dvd_audio_stream_channels[ audio->channels ],
|
2001-11-16 22:26:57 +00:00
|
|
|
tmp,
|
|
|
|
d->audio_streams[d->nr_of_channels].id
|
|
|
|
);
|
2001-12-26 00:16:09 +00:00
|
|
|
|
2001-11-16 22:26:57 +00:00
|
|
|
d->nr_of_channels++;
|
|
|
|
}
|
|
|
|
}
|
2001-11-21 10:30:59 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_V,"[open] number of audio channels on disk: %d.\n",d->nr_of_channels );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check number of subtitles and language
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
d->nr_of_subtitles=0;
|
|
|
|
for ( i=0;i<32;i++ )
|
|
|
|
if ( vts_file->vts_pgcit->pgci_srp[0].pgc->subp_control[i] & 0x80000000 )
|
|
|
|
{
|
|
|
|
subp_attr_t * subtitle = &vts_file->vtsi_mat->vts_subp_attr[i];
|
|
|
|
int language = 0;
|
|
|
|
char tmp[] = "unknown";
|
|
|
|
|
|
|
|
if ( subtitle->type == 1 )
|
|
|
|
{
|
|
|
|
language=subtitle->lang_code;
|
|
|
|
tmp[0]=language>>8;
|
|
|
|
tmp[1]=language&0xff;
|
|
|
|
tmp[2]=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
d->subtitles[ d->nr_of_subtitles ].language=language;
|
|
|
|
d->subtitles[ d->nr_of_subtitles ].id=d->nr_of_subtitles;
|
|
|
|
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_V,"[open] subtitle ( sid ): %d language: %s\n",
|
|
|
|
d->nr_of_subtitles,
|
|
|
|
tmp
|
|
|
|
);
|
|
|
|
d->nr_of_subtitles++;
|
|
|
|
}
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_V,"[open] number of subtitles on disk: %d\n",d->nr_of_subtitles );
|
2001-11-16 22:26:57 +00:00
|
|
|
}
|
|
|
|
|
2001-08-20 21:20:03 +00:00
|
|
|
/**
|
|
|
|
* Determine which program chain we want to watch. This is based on the
|
|
|
|
* chapter number.
|
|
|
|
*/
|
|
|
|
ttn = tt_srpt->title[ dvd_title ].vts_ttn; // local
|
|
|
|
pgc_id = vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_chapter].pgcn; // local
|
|
|
|
pgn = vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_chapter].pgn; // local
|
|
|
|
d->cur_pgc = vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc;
|
|
|
|
d->cur_cell = d->cur_pgc->program_map[pgn-1] - 1; // start playback here
|
|
|
|
d->packs_left=-1; // for Navi stuff
|
2001-08-21 20:12:48 +00:00
|
|
|
d->angle_seek=0;
|
2002-01-21 09:44:31 +00:00
|
|
|
/* XXX dvd_last_chapter is in the range 1..nr_of_ptts */
|
2002-07-30 19:19:16 +00:00
|
|
|
if ( dvd_last_chapter > 0 && dvd_last_chapter < tt_srpt->title[dvd_title].nr_of_ptts ) {
|
2002-01-21 09:44:31 +00:00
|
|
|
pgn=vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_last_chapter].pgn;
|
|
|
|
d->last_cell=d->cur_pgc->program_map[pgn-1] - 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
d->last_cell=d->cur_pgc->nr_of_cells;
|
2001-08-20 21:20:03 +00:00
|
|
|
|
2002-07-05 23:47:00 +00:00
|
|
|
if( d->cur_pgc->cell_playback[d->cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle;
|
2001-08-20 21:20:03 +00:00
|
|
|
d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector;
|
|
|
|
d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector;
|
|
|
|
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);
|
|
|
|
|
|
|
|
// ... (unimplemented)
|
|
|
|
// return NULL;
|
|
|
|
stream=new_stream(-1,STREAMTYPE_DVD);
|
|
|
|
stream->start_pos=(off_t)d->cur_pack*2048;
|
2002-01-27 19:23:43 +00:00
|
|
|
stream->end_pos=(off_t)(d->cur_pgc->cell_playback[d->last_cell-1].last_sector)*2048;
|
2002-05-02 10:32:55 +00:00
|
|
|
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);
|
2001-08-20 21:20:03 +00:00
|
|
|
stream->priv=(void*)d;
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-09-15 20:51:55 +00:00
|
|
|
//============ Check for TV-input or multi-file input ====
|
|
|
|
if( (mf_support == 1)
|
2001-11-09 23:46:06 +00:00
|
|
|
#ifdef USE_TV
|
2002-09-15 20:51:55 +00:00
|
|
|
|| (tv_param_on == 1)
|
2001-11-09 23:46:06 +00:00
|
|
|
#endif
|
2002-09-15 20:51:55 +00:00
|
|
|
){
|
2002-02-06 20:16:35 +00:00
|
|
|
/* create stream */
|
2002-09-15 19:47:49 +00:00
|
|
|
stream = new_stream(-1, STREAMTYPE_DUMMY);
|
|
|
|
if (!stream) return(NULL);
|
2002-09-15 20:51:55 +00:00
|
|
|
stream->url=filename?strdup(filename):NULL;
|
2002-02-06 20:16:35 +00:00
|
|
|
return(stream);
|
|
|
|
}
|
2001-08-09 01:17:24 +00:00
|
|
|
|
|
|
|
#ifdef STREAMING
|
|
|
|
url = url_new(filename);
|
|
|
|
if(url) {
|
2002-10-06 18:03:12 +00:00
|
|
|
if (strcmp(url->protocol, "smb")==0){
|
|
|
|
#ifdef LIBSMBCLIENT
|
|
|
|
|
|
|
|
// we need init of libsmbclient
|
|
|
|
int err;
|
|
|
|
|
|
|
|
// FIXME: HACK: make the username/password global varaibles
|
|
|
|
// so the auth_fn function should grab it ...
|
|
|
|
// i cannot thing other way...
|
|
|
|
err = smbc_init(smb_auth_fn, 10); /* Initialize things */
|
|
|
|
// libsmbclient using
|
|
|
|
if (err < 0) {
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBInitError,err);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
f=smbc_open(filename, O_RDONLY, 0666);
|
|
|
|
|
|
|
|
// cannot open the file, outputs that
|
|
|
|
// MSGTR_FileNotFound -> MSGTR_SMBFileNotFound
|
|
|
|
if(f<0){
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBFileNotFound,filename);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
len=smbc_lseek(f,0,SEEK_END);
|
|
|
|
smbc_lseek(f,0,SEEK_SET);
|
|
|
|
// FIXME: I really wonder is such situation -> but who cares ;)
|
|
|
|
// if (len == -1)
|
|
|
|
// return new_stream(f,STREAMTYPE_STREAM); // open as stream
|
|
|
|
url_free(url);
|
|
|
|
stream=new_stream(f,STREAMTYPE_SMB);
|
|
|
|
stream->end_pos=len;
|
|
|
|
return stream;
|
|
|
|
#else
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBNotCompiled,filename);
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
2001-08-09 01:17:24 +00:00
|
|
|
stream=new_stream(f,STREAMTYPE_STREAM);
|
2002-02-16 21:48:59 +00:00
|
|
|
if( streaming_start( stream, file_format, url )<0){
|
2001-11-20 22:48:43 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, filename);
|
2002-01-19 09:04:02 +00:00
|
|
|
url_free(url);
|
2001-11-20 22:48:43 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2002-01-19 09:04:02 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ConnToServer, url->hostname );
|
2001-11-20 22:48:43 +00:00
|
|
|
url_free(url);
|
2001-10-20 20:35:12 +00:00
|
|
|
return stream;
|
2001-08-09 01:17:24 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-06-07 00:42:08 +00:00
|
|
|
//============ Open STDIN or plain FILE ============
|
|
|
|
if(!strcmp(filename,"-")){
|
|
|
|
// read from stdin
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ReadSTDIN);
|
|
|
|
f=0; // 0=stdin
|
|
|
|
} else {
|
2001-08-09 01:17:24 +00:00
|
|
|
f=open(filename,O_RDONLY);
|
2001-08-18 20:32:09 +00:00
|
|
|
if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);return NULL; }
|
2002-06-07 00:42:08 +00:00
|
|
|
}
|
|
|
|
|
2001-08-09 01:17:24 +00:00
|
|
|
len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET);
|
|
|
|
if (len == -1)
|
2002-06-07 00:42:08 +00:00
|
|
|
return new_stream(f,STREAMTYPE_STREAM); // open as stream
|
|
|
|
|
2001-08-09 01:17:24 +00:00
|
|
|
#ifdef _LARGEFILE_SOURCE
|
2001-08-17 00:40:25 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_V,"File size is %lld bytes\n", (long long)len);
|
2001-08-09 01:17:24 +00:00
|
|
|
#else
|
2001-08-17 00:40:25 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_V,"File size is %u bytes\n", (unsigned int)len);
|
2001-08-09 01:17:24 +00:00
|
|
|
#endif
|
2002-08-05 00:39:07 +00:00
|
|
|
|
|
|
|
#ifdef STREAMING_LIVE_DOT_COM
|
|
|
|
// Check for a special case: a SDP file:
|
|
|
|
if (isSDPFile) {
|
|
|
|
return stream_open_sdp(f, len, file_format);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-08-09 01:17:24 +00:00
|
|
|
stream=new_stream(f,STREAMTYPE_FILE);
|
|
|
|
stream->end_pos=len;
|
|
|
|
return stream;
|
|
|
|
}
|
2001-08-20 21:20:03 +00:00
|
|
|
|
2002-01-24 23:02:59 +00:00
|
|
|
int dvd_parse_chapter_range(struct config *conf, const char *range){
|
2002-09-22 02:33:28 +00:00
|
|
|
const char *s;
|
|
|
|
char *t;
|
2002-11-06 23:54:29 +00:00
|
|
|
/* conf; prevent warning from GCC */
|
2002-01-25 12:54:52 +00:00
|
|
|
s = range;
|
2002-01-24 23:02:59 +00:00
|
|
|
dvd_chapter = 1;
|
|
|
|
dvd_last_chapter = 0;
|
|
|
|
if (*range && isdigit(*range)) {
|
|
|
|
dvd_chapter = strtol(range, &s, 10);
|
|
|
|
if (range == s) {
|
|
|
|
mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (*s == 0)
|
|
|
|
return 0;
|
|
|
|
else if (*s != '-') {
|
|
|
|
mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
++s;
|
|
|
|
if (*s == 0)
|
|
|
|
return 0;
|
|
|
|
if (! isdigit(*s)) {
|
|
|
|
mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
dvd_last_chapter = strtol(s, &t, 10);
|
|
|
|
if (s == t || *t) {
|
|
|
|
mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-08-20 21:20:03 +00:00
|
|
|
#ifdef USE_DVDREAD
|
2002-10-22 22:45:30 +00:00
|
|
|
int dvd_chapter_from_cell(dvd_priv_t* dvd,int title,int cell)
|
|
|
|
{
|
|
|
|
pgc_t * cur_pgc;
|
|
|
|
ptt_info_t* ptt;
|
|
|
|
int chapter = cell;
|
|
|
|
int pgc_id,pgn;
|
|
|
|
if(title < 0 || cell < 0){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* for most DVD's chapter == cell */
|
|
|
|
/* but there are more complecated cases... */
|
|
|
|
if(chapter >= dvd->vmg_file->tt_srpt->title[title].nr_of_ptts){
|
|
|
|
chapter = dvd->vmg_file->tt_srpt->title[title].nr_of_ptts-1;
|
|
|
|
}
|
|
|
|
title = dvd->tt_srpt->title[title].vts_ttn-1;
|
|
|
|
ptt = dvd->vts_file->vts_ptt_srpt->title[title].ptt;
|
|
|
|
while(chapter >= 0){
|
|
|
|
pgc_id = ptt[chapter].pgcn;
|
|
|
|
pgn = ptt[chapter].pgn;
|
|
|
|
cur_pgc = dvd->vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc;
|
|
|
|
if(cell >= cur_pgc->program_map[pgn-1]-1){
|
|
|
|
return chapter;
|
|
|
|
}
|
|
|
|
--chapter;
|
|
|
|
}
|
|
|
|
/* didn't find a chapter ??? */
|
|
|
|
return chapter;
|
|
|
|
}
|
2001-08-20 21:20:03 +00:00
|
|
|
|
2001-12-26 00:16:09 +00:00
|
|
|
int dvd_aid_from_lang(stream_t *stream, unsigned char* lang){
|
|
|
|
dvd_priv_t *d=stream->priv;
|
|
|
|
int code,i;
|
|
|
|
while(lang && strlen(lang)>=2){
|
|
|
|
code=lang[1]|(lang[0]<<8);
|
|
|
|
for(i=0;i<d->nr_of_channels;i++){
|
|
|
|
if(d->audio_streams[i].language==code){
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_INFO,"Selected DVD audio channel: %d language: %c%c\n",
|
|
|
|
d->audio_streams[i].id, lang[0],lang[1]);
|
|
|
|
return d->audio_streams[i].id;
|
|
|
|
}
|
|
|
|
// printf("%X != %X (%c%c)\n",code,d->audio_streams[i].language,lang[0],lang[1]);
|
|
|
|
}
|
|
|
|
lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang;
|
|
|
|
}
|
2002-05-02 10:32:55 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_WARN,"No matching DVD audio language found!\n");
|
2001-12-26 00:16:09 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dvd_sid_from_lang(stream_t *stream, unsigned char* lang){
|
|
|
|
dvd_priv_t *d=stream->priv;
|
|
|
|
int code,i;
|
|
|
|
while(lang && strlen(lang)>=2){
|
|
|
|
code=lang[1]|(lang[0]<<8);
|
|
|
|
for(i=0;i<d->nr_of_subtitles;i++){
|
|
|
|
if(d->subtitles[i].language==code){
|
|
|
|
mp_msg(MSGT_OPEN,MSGL_INFO,"Selected DVD subtitle channel: %d language: %c%c\n",
|
|
|
|
d->subtitles[i].id, lang[0],lang[1]);
|
|
|
|
return d->subtitles[i].id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang;
|
|
|
|
}
|
2002-05-02 10:32:55 +00:00
|
|
|
mp_msg(MSGT_OPEN,MSGL_WARN,"No matching DVD subtitle language found!\n");
|
2001-12-26 00:16:09 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2001-08-20 21:20:03 +00:00
|
|
|
static int dvd_next_cell(dvd_priv_t *d){
|
|
|
|
int next_cell=d->cur_cell;
|
2001-08-21 22:20:41 +00:00
|
|
|
|
|
|
|
mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next1=0x%X \n",next_cell);
|
2001-08-20 21:20:03 +00:00
|
|
|
|
|
|
|
if( d->cur_pgc->cell_playback[ next_cell ].block_type
|
|
|
|
== BLOCK_TYPE_ANGLE_BLOCK ) {
|
2002-01-21 09:44:31 +00:00
|
|
|
while(next_cell<d->last_cell){
|
2001-08-20 21:20:03 +00:00
|
|
|
if( d->cur_pgc->cell_playback[next_cell].block_mode
|
|
|
|
== BLOCK_MODE_LAST_CELL ) break;
|
|
|
|
++next_cell;
|
|
|
|
}
|
|
|
|
}
|
2001-08-21 22:20:41 +00:00
|
|
|
mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next2=0x%X \n",next_cell);
|
2001-08-20 21:20:03 +00:00
|
|
|
|
|
|
|
++next_cell;
|
2002-01-21 09:44:31 +00:00
|
|
|
if(next_cell>=d->last_cell) return -1; // EOF
|
2001-08-20 21:20:03 +00:00
|
|
|
if( d->cur_pgc->cell_playback[next_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ){
|
|
|
|
next_cell+=dvd_angle;
|
2002-01-21 09:44:31 +00:00
|
|
|
if(next_cell>=d->last_cell) return -1; // EOF
|
2001-08-20 21:20:03 +00:00
|
|
|
}
|
2001-08-21 22:20:41 +00:00
|
|
|
mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next3=0x%X \n",next_cell);
|
2001-08-20 21:20:03 +00:00
|
|
|
return next_cell;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dvd_read_sector(dvd_priv_t *d,unsigned char* data){
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if(d->packs_left==0){
|
|
|
|
/**
|
|
|
|
* If we're not at the end of this cell, we can determine the next
|
|
|
|
* VOBU to display using the VOBU_SRI information section of the
|
|
|
|
* DSI. Using this value correctly follows the current angle,
|
|
|
|
* avoiding the doubled scenes in The Matrix, and makes our life
|
|
|
|
* really happy.
|
|
|
|
*
|
|
|
|
* Otherwise, we set our next address past the end of this cell to
|
|
|
|
* force the code above to go to the next cell in the program.
|
|
|
|
*/
|
|
|
|
if( d->dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL ) {
|
|
|
|
d->cur_pack= d->dsi_pack.dsi_gi.nv_pck_lbn +
|
|
|
|
( d->dsi_pack.vobu_sri.next_vobu & 0x7fffffff );
|
|
|
|
mp_msg(MSGT_DVD,MSGL_DBG2, "Navi new pos=0x%X \n",d->cur_pack);
|
|
|
|
} else {
|
|
|
|
// end of cell! find next cell!
|
|
|
|
mp_msg(MSGT_DVD,MSGL_V, "--- END OF CELL !!! ---\n");
|
|
|
|
d->cur_pack=d->cell_last_pack+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
read_next:
|
|
|
|
|
|
|
|
if(d->cur_pack>d->cell_last_pack){
|
|
|
|
// end of cell!
|
|
|
|
int next=dvd_next_cell(d);
|
|
|
|
if(next>=0){
|
|
|
|
d->cur_cell=next;
|
|
|
|
|
2001-08-21 22:15:19 +00:00
|
|
|
// if( d->cur_pgc->cell_playback[d->cur_cell].block_type
|
|
|
|
// == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle;
|
2001-08-20 21:20:03 +00:00
|
|
|
d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector;
|
|
|
|
d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector;
|
|
|
|
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);
|
|
|
|
|
|
|
|
} else return -1; // EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
len = DVDReadBlocks( d->title, d->cur_pack, 1, data );
|
|
|
|
if(!len) return -1; //error
|
|
|
|
|
|
|
|
if(data[38]==0 && data[39]==0 && data[40]==1 && data[41]==0xBF &&
|
|
|
|
data[1024]==0 && data[1025]==0 && data[1026]==1 && data[1027]==0xBF){
|
|
|
|
// found a Navi packet!!!
|
2001-09-09 18:02:50 +00:00
|
|
|
#if LIBDVDREAD_VERSION >= DVDREAD_VERSION(0,9,0)
|
|
|
|
navRead_DSI( &d->dsi_pack, &(data[ DSI_START_BYTE ]) );
|
|
|
|
#else
|
2001-08-20 21:20:03 +00:00
|
|
|
navRead_DSI( &d->dsi_pack, &(data[ DSI_START_BYTE ]), sizeof(dsi_t) );
|
2001-09-09 18:02:50 +00:00
|
|
|
#endif
|
2001-08-20 21:20:03 +00:00
|
|
|
if(d->cur_pack != d->dsi_pack.dsi_gi.nv_pck_lbn ){
|
|
|
|
mp_msg(MSGT_DVD,MSGL_V, "Invalid NAVI packet! lba=0x%X navi=0x%X \n",
|
|
|
|
d->cur_pack,d->dsi_pack.dsi_gi.nv_pck_lbn);
|
|
|
|
} else {
|
|
|
|
// process!
|
|
|
|
d->packs_left = d->dsi_pack.dsi_gi.vobu_ea;
|
|
|
|
mp_msg(MSGT_DVD,MSGL_DBG2, "Found NAVI packet! lba=0x%X len=%d \n",d->cur_pack,d->packs_left);
|
2002-07-23 23:36:44 +00:00
|
|
|
//navPrint_DSI(&d->dsi_pack);
|
|
|
|
mp_msg(MSGT_DVD,MSGL_DBG3,"\r### CELL %d: Navi: %d/%d IFO: %d/%d \n",d->cur_cell,
|
|
|
|
d->dsi_pack.dsi_gi.vobu_c_idn,d->dsi_pack.dsi_gi.vobu_vob_idn,
|
|
|
|
d->cur_pgc->cell_position[d->cur_cell].cell_nr,
|
|
|
|
d->cur_pgc->cell_position[d->cur_cell].vob_id_nr);
|
|
|
|
|
2001-08-21 20:12:48 +00:00
|
|
|
if(d->angle_seek){
|
2002-07-23 23:36:44 +00:00
|
|
|
int i,skip=0;
|
2002-09-06 13:31:33 +00:00
|
|
|
#if defined(__GNUC__) && defined(__sparc__)
|
|
|
|
// workaround for a bug in the sparc version of gcc 2.95.X ... 3.2,
|
|
|
|
// it generates incorrect code for unaligned access to a packed
|
|
|
|
// structure member, resulting in an mplayer crash with a SIGBUS
|
|
|
|
// signal.
|
|
|
|
//
|
|
|
|
// See also gcc problem report PR c/7847:
|
|
|
|
// http://gcc.gnu.org/cgi-bin/gnatsweb.pl?database=gcc&cmd=view+audit-trail&pr=7847
|
|
|
|
for(i=0;i<9;i++){ // check if all values zero:
|
|
|
|
typeof(d->dsi_pack.sml_agli.data[i].address) tmp_addr;
|
|
|
|
memcpy(&tmp_addr,&d->dsi_pack.sml_agli.data[i].address,sizeof(tmp_addr));
|
|
|
|
if((skip=tmp_addr)!=0) break;
|
|
|
|
}
|
|
|
|
#else
|
2002-07-23 23:36:44 +00:00
|
|
|
for(i=0;i<9;i++) // check if all values zero:
|
|
|
|
if((skip=d->dsi_pack.sml_agli.data[i].address)!=0) break;
|
2002-09-06 13:31:33 +00:00
|
|
|
#endif
|
2002-07-23 23:36:44 +00:00
|
|
|
if(skip){
|
|
|
|
// sml_agli table has valid data (at least one non-zero):
|
|
|
|
d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+
|
|
|
|
d->dsi_pack.sml_agli.data[dvd_angle].address;
|
|
|
|
d->angle_seek=0;
|
|
|
|
mp_msg(MSGT_DVD,MSGL_V, "Angle-seek synced using sml_agli map! new_lba=0x%X \n",d->cur_pack);
|
|
|
|
} else {
|
|
|
|
// check if we're in the right cell, jump otherwise:
|
|
|
|
if( (d->dsi_pack.dsi_gi.vobu_c_idn==d->cur_pgc->cell_position[d->cur_cell].cell_nr) &&
|
|
|
|
(d->dsi_pack.dsi_gi.vobu_vob_idn==d->cur_pgc->cell_position[d->cur_cell].vob_id_nr) ){
|
|
|
|
d->angle_seek=0;
|
|
|
|
mp_msg(MSGT_DVD,MSGL_V, "Angle-seek synced by cell/vob IDN search! \n");
|
|
|
|
} else {
|
|
|
|
// wrong angle, skip this vobu:
|
|
|
|
d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+
|
|
|
|
d->dsi_pack.dsi_gi.vobu_ea;
|
|
|
|
d->angle_seek=2; // DEBUG
|
|
|
|
}
|
|
|
|
}
|
2001-08-21 20:12:48 +00:00
|
|
|
}
|
2001-08-20 21:20:03 +00:00
|
|
|
}
|
|
|
|
++d->cur_pack;
|
|
|
|
goto read_next;
|
|
|
|
}
|
2002-07-23 23:36:44 +00:00
|
|
|
|
2001-08-20 21:20:03 +00:00
|
|
|
++d->cur_pack;
|
|
|
|
if(d->packs_left>=0) --d->packs_left;
|
2001-08-21 20:12:48 +00:00
|
|
|
|
2002-07-23 23:36:44 +00:00
|
|
|
if(d->angle_seek){
|
|
|
|
if(d->angle_seek==2) mp_msg(MSGT_DVD,MSGL_V, "!!! warning! reading packet while angle_seek !!!\n");
|
|
|
|
goto read_next; // searching for Navi packet
|
|
|
|
}
|
2001-08-20 21:20:03 +00:00
|
|
|
|
|
|
|
return d->cur_pack-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dvd_seek(dvd_priv_t *d,int pos){
|
|
|
|
d->packs_left=-1;
|
|
|
|
d->cur_pack=pos;
|
|
|
|
|
|
|
|
// check if we stay in current cell (speedup things, and avoid angle skip)
|
2001-08-21 20:12:48 +00:00
|
|
|
if(d->cur_pack>d->cell_last_pack ||
|
2001-08-20 21:20:03 +00:00
|
|
|
d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){
|
|
|
|
|
|
|
|
// ok, cell change, find the right cell!
|
|
|
|
d->cur_cell=0;
|
|
|
|
if( d->cur_pgc->cell_playback[d->cur_cell].block_type
|
|
|
|
== BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle;
|
|
|
|
|
|
|
|
while(1){
|
|
|
|
int next;
|
|
|
|
d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector;
|
|
|
|
if(d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){
|
|
|
|
d->cur_pack=d->cur_pgc->cell_playback[ d->cur_cell ].first_sector;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(d->cur_pack<=d->cell_last_pack) break; // ok, we find it! :)
|
|
|
|
next=dvd_next_cell(d);
|
|
|
|
if(next<0){
|
|
|
|
// d->cur_pack=d->cell_last_pack+1;
|
|
|
|
break; // we're after the last cell
|
|
|
|
}
|
|
|
|
d->cur_cell=next;
|
|
|
|
}
|
2001-08-21 20:12:48 +00:00
|
|
|
|
2001-08-20 21:20:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mp_msg(MSGT_DVD,MSGL_V, "DVD Seek! lba=0x%X cell=%d packs: 0x%X-0x%X \n",
|
|
|
|
d->cur_pack,d->cur_cell,d->cur_pgc->cell_playback[ d->cur_cell ].first_sector,d->cell_last_pack);
|
|
|
|
|
2001-08-21 20:12:48 +00:00
|
|
|
// if we're in interleaved multi-angle cell, find the right angle chain!
|
2001-08-20 21:20:03 +00:00
|
|
|
// (read Navi block, and use the seamless angle jump table)
|
2001-08-21 20:12:48 +00:00
|
|
|
d->angle_seek=1;
|
2001-08-20 21:20:03 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-06-21 16:26:40 +00:00
|
|
|
void dvd_close(dvd_priv_t *d) {
|
|
|
|
ifoClose(d->vts_file);
|
|
|
|
ifoClose(d->vmg_file);
|
|
|
|
DVDCloseFile(d->title);
|
|
|
|
DVDClose(d->dvd);
|
|
|
|
}
|
|
|
|
|
2001-08-20 21:20:03 +00:00
|
|
|
#endif
|