diff options
author | albeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-04-09 07:31:11 +0000 |
---|---|---|
committer | albeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-04-09 07:31:11 +0000 |
commit | fef9433a4baa37d4420ed4acebababaffbc59830 (patch) | |
tree | d69429ccdb85cf5580f2f5b72823488ab68575e7 /libmpdemux | |
parent | 8b8e15be5a5a01fa81d7320cf57f27a150b04b58 (diff) | |
download | mpv-fef9433a4baa37d4420ed4acebababaffbc59830.tar.bz2 mpv-fef9433a4baa37d4420ed4acebababaffbc59830.tar.xz |
Port vcd to the new API
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9887 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/Makefile | 2 | ||||
-rw-r--r-- | libmpdemux/open.c | 31 | ||||
-rw-r--r-- | libmpdemux/stream.c | 36 | ||||
-rw-r--r-- | libmpdemux/stream.h | 3 | ||||
-rw-r--r-- | libmpdemux/stream_vcd.c | 142 |
5 files changed, 149 insertions, 65 deletions
diff --git a/libmpdemux/Makefile b/libmpdemux/Makefile index 3a1e093086..21cd4443da 100644 --- a/libmpdemux/Makefile +++ b/libmpdemux/Makefile @@ -3,7 +3,7 @@ LIBNAME = libmpdemux.a include ../config.mak -SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_pva.c demux_viv.c demuxer.c dvdauth.c dvdnav_stream.c open.c parse_es.c stream.c stream_file.c stream_netstream.c tv.c tvi_dummy.c tvi_v4l.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c demux_bmp.c cdda.c demux_rawaudio.c demux_rawvideo.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_oss.c audio_in.c demux_smjpeg.c cue_read.c extension.c demux_gif.c demux_ts.c +SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_pva.c demux_viv.c demuxer.c dvdauth.c dvdnav_stream.c open.c parse_es.c stream.c stream_file.c stream_netstream.c stream_vcd.c tv.c tvi_dummy.c tvi_v4l.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c demux_bmp.c cdda.c demux_rawaudio.c demux_rawvideo.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_oss.c audio_in.c demux_smjpeg.c cue_read.c extension.c demux_gif.c demux_ts.c ifeq ($(XMMS_PLUGINS),yes) SRCS += demux_xmms.c endif diff --git a/libmpdemux/open.c b/libmpdemux/open.c index 463d73ef99..38b208d70f 100644 --- a/libmpdemux/open.c +++ b/libmpdemux/open.c @@ -144,37 +144,6 @@ if(!filename) { return NULL; } -//============ Open VideoCD track ============== -#ifdef HAVE_VCD -if(strncmp("vcd://",filename,6) == 0){ - int ret,ret2; - if(!cdrom_device) cdrom_device=strdup(DEFAULT_CDROM_DEVICE); - f=open(cdrom_device,O_RDONLY); - if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,cdrom_device);return NULL; } - vcd_track = filename[6] == '\0' ? 1 : strtol(filename+6,NULL,0); - if(vcd_track < 1){ - mp_msg(MSGT_OPEN,MSGL_ERR,"Invalid vcd track %s\n",filename+6); - return NULL; - } - vcd_read_toc(f); - ret2=vcd_get_track_end(f,vcd_track); - if(ret2<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n");return NULL;} - ret=vcd_seek_to_track(f,vcd_track); - if(ret<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");return NULL;} - mp_msg(MSGT_OPEN,MSGL_V,"VCD start byte position: 0x%X end: 0x%X\n",ret,ret2); -#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; -} -#endif - - // for opening of vcds in bincue files if(strncmp("cue://",filename,6) == 0){ int ret,ret2; diff --git a/libmpdemux/stream.c b/libmpdemux/stream.c index 6e3f0dae34..ad878d334c 100644 --- a/libmpdemux/stream.c +++ b/libmpdemux/stream.c @@ -29,18 +29,6 @@ extern int verbose; // defined in mplayer.c #include "cue_read.h" -#ifdef HAVE_VCD - -#ifdef __FreeBSD__ -#include "vcd_read_fbsd.h" -#elif defined(__NetBSD__) -#include "vcd_read_nbsd.h" -#else -#include "vcd_read.h" -#endif - -#endif - //#include "vcd_read_bincue.h" #ifdef USE_DVDREAD @@ -49,16 +37,13 @@ void dvd_seek(dvd_priv_t *d,int pos); void dvd_close(dvd_priv_t *d); #endif -#ifdef HAVE_CDDA -int read_cdda(stream_t* s); -void seek_cdda(stream_t* s); -void close_cdda(stream_t* s); -#endif - #ifdef LIBSMBCLIENT #include "libsmbclient.h" #endif +#ifdef HAVE_VCD +extern stream_info_t stream_info_vcd; +#endif #ifdef HAVE_CDDA extern stream_info_t stream_info_cdda; #endif @@ -68,6 +53,9 @@ extern stream_info_t stream_info_netstream; extern stream_info_t stream_info_file; stream_info_t* auto_open_streams[] = { +#ifdef HAVE_VCD + &stream_info_vcd, +#endif #ifdef HAVE_CDDA &stream_info_cdda, #endif @@ -186,10 +174,6 @@ int stream_fill_buffer(stream_t *s){ #else len=read(s->fd,s->buffer,STREAM_BUFFER_SIZE);break; #endif -#ifdef HAVE_VCD - case STREAMTYPE_VCD: - len=vcd_read(s->fd,s->buffer);break; -#endif case STREAMTYPE_VCDBINCUE: len=cue_vcd_read(s->buffer);break; #ifdef USE_DVDNAV @@ -247,8 +231,6 @@ off_t newpos=0; #else newpos=pos&(~(STREAM_BUFFER_SIZE-1));break; #endif - case STREAMTYPE_VCD: - newpos=(pos/VCD_SECTOR_DATA)*VCD_SECTOR_DATA;break; case STREAMTYPE_VCDBINCUE: newpos=(pos/VCD_SECTOR_DATA)*VCD_SECTOR_DATA;break; case STREAMTYPE_DVD: @@ -287,12 +269,6 @@ if(newpos==0 || newpos!=s->pos){ if(smbc_lseek(s->fd,s->pos,SEEK_SET)<0) s->eof=1; break; #endif -#ifdef HAVE_VCD - case STREAMTYPE_VCD: - s->pos=newpos; // real seek - vcd_set_msf(s->pos/VCD_SECTOR_DATA); - break; -#endif case STREAMTYPE_VCDBINCUE: s->pos=newpos; // real seek cue_set_msf(s->pos/VCD_SECTOR_DATA); diff --git a/libmpdemux/stream.h b/libmpdemux/stream.h index 8fd5ea7f79..3c3b547289 100644 --- a/libmpdemux/stream.h +++ b/libmpdemux/stream.h @@ -51,9 +51,6 @@ #include "network.h" #endif -int vcd_seek_to_track(int fd,int track); -void vcd_read_toc(int fd); - struct stream_st; typedef struct stream_info_st { const char *info; diff --git a/libmpdemux/stream_vcd.c b/libmpdemux/stream_vcd.c new file mode 100644 index 0000000000..d2427055b2 --- /dev/null +++ b/libmpdemux/stream_vcd.c @@ -0,0 +1,142 @@ + +#include "config.h" + +#ifdef HAVE_VCD +#include "mp_msg.h" +#include "stream.h" +#include "help_mp.h" +#include "../m_option.h" +#include "../m_struct.h" + +#include <stdlib.h> +#include <unistd.h> +#include <sys/ioctl.h> +#include <errno.h> + +#ifdef __FreeBSD__ +#include <sys/cdrio.h> +#include "vcd_read_fbsd.h" +#elif defined(__NetBSD__) +#include "vcd_read_nbsd.h" +#else +#include "vcd_read.h" +#endif + +static struct stream_priv_s { + int track; + char* device; +} stream_priv_dflts = { + 1, + DEFAULT_CDROM_DEVICE +}; + +#define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f) +/// URL definition +static m_option_t stream_opts_fields[] = { + { "track", ST_OFF(track), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL }, + { "device", ST_OFF(device), CONF_TYPE_STRING, 0, 0 ,0, NULL}, + /// For url parsing + { "hostname", ST_OFF(track), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL }, + { "filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0 ,0, NULL}, + { NULL, NULL, 0, 0, 0, 0, NULL } +}; +static struct m_struct_st stream_opts = { + "vcd", + sizeof(struct stream_priv_s), + &stream_priv_dflts, + stream_opts_fields +}; + +static int fill_buffer(stream_t *s, char* buffer, int max_len){ + return vcd_read(s->priv,buffer); +} + +static int seek(stream_t *s,off_t newpos) { + s->pos = newpos; + vcd_set_msf(s->priv,s->pos/VCD_SECTOR_DATA); + return 1; +} + +static void close_s(stream_t *stream) { + free(stream->priv); +} + +static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { + struct stream_priv_s* p = (struct stream_priv_s*)opts; + int ret,ret2,f; + mp_vcd_priv_t* vcd; +#ifdef __FreeBSD__ + int bsize = VCD_SECTOR_SIZE; +#endif + + if(mode != STREAM_READ) { + m_struct_free(&stream_opts,opts); + return STREAM_UNSUPORTED; + } + + f=open(p->device,O_RDONLY); + if(f<0){ + mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,p->device); + close(f); + m_struct_free(&stream_opts,opts); + return STREAM_ERROR; + } + + vcd = vcd_read_toc(f); + if(!vcd) { + mp_msg(MSGT_OPEN,MSGL_ERR,"Failed to get cd toc\n"); + close(f); + m_struct_free(&stream_opts,opts); + return STREAM_ERROR; + } + ret2=vcd_get_track_end(vcd,p->track); + if(ret2<0){ + mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n"); + close(f); + free(vcd); + m_struct_free(&stream_opts,opts); + return STREAM_ERROR; + } + ret=vcd_seek_to_track(vcd,p->track); + if(ret<0){ + mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n"); + close(f); + free(vcd); + m_struct_free(&stream_opts,opts); + return STREAM_ERROR; + } + mp_msg(MSGT_OPEN,MSGL_V,"VCD start byte position: 0x%X end: 0x%X\n",ret,ret2); + +#ifdef __FreeBSD__ + if (ioctl (f, CDRIOCSETBLOCKSIZE, &bsize) == -1) { + mp_msg(MSGT_OPEN,MSGL_WARN,"Error in CDRIOCSETBLOCKSIZE"); + } +#endif + + stream->fd = f; + stream->type = STREAMTYPE_VCD; + stream->sector_size = VCD_SECTOR_DATA; + stream->start_pos=ret; + stream->end_pos=ret2; + stream->priv = vcd; + + stream->fill_buffer = fill_buffer; + stream->seek = seek; + stream->close = close_s; + + m_struct_free(&stream_opts,opts); + return STREAM_OK; +} + +stream_info_t stream_info_vcd = { + "Video CD", + "vcd", + "Albeu", + "based on the code from ???", + open_s, + { "vcd", NULL }, + &stream_opts, + 1 // Urls are an option string +}; + +#endif |