summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authornicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-05-15 07:38:42 +0000
committernicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-05-15 07:38:42 +0000
commitce228ac4cdd537b764d9a30502c2725f53c9d9f2 (patch)
treee02ad657f58e5c0e85e82e97b77275d5b96a699b /libmpdemux
parent1e285998e64770dc6abff8701d7d6d271f07647b (diff)
downloadmpv-ce228ac4cdd537b764d9a30502c2725f53c9d9f2.tar.bz2
mpv-ce228ac4cdd537b764d9a30502c2725f53c9d9f2.tar.xz
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15477 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/cue_read.c116
-rw-r--r--libmpdemux/cue_read.h12
-rw-r--r--libmpdemux/open.c36
-rw-r--r--libmpdemux/stream.c12
4 files changed, 113 insertions, 63 deletions
diff --git a/libmpdemux/cue_read.c b/libmpdemux/cue_read.c
index 11e4213b02..1d876e9dad 100644
--- a/libmpdemux/cue_read.c
+++ b/libmpdemux/cue_read.c
@@ -16,6 +16,9 @@
#include "stream.h"
#include "cue_read.h"
+#include "help_mp.h"
+#include "../m_option.h"
+#include "../m_struct.h"
#define byte unsigned char
#define SIZERAW 2352
@@ -32,6 +35,25 @@
#define MODE2_2336 40
#define UNKNOWN -1
+static struct stream_priv_s {
+ char* filename;
+} stream_priv_dflts = {
+ NULL
+};
+
+#define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f)
+/// URL definition
+static m_option_t stream_opts_fields[] = {
+ { "string", ST_OFF(filename), CONF_TYPE_STRING, 0, 0 ,0, NULL},
+ { NULL, NULL, 0, 0, 0, 0, NULL }
+};
+static struct m_struct_st stream_opts = {
+ "cue",
+ sizeof(struct stream_priv_s),
+ &stream_priv_dflts,
+ stream_opts_fields
+};
+
static FILE* fd_cue;
static int fd_bin = 0;
@@ -74,7 +96,7 @@ static struct cue_track_pos {
static int nTracks = 0;
/* presumes Line is preloaded with the "current" line of the file */
-int cue_getTrackinfo(char *Line, tTrack *track)
+static int cue_getTrackinfo(char *Line, tTrack *track)
{
char inum[3];
char min;
@@ -139,7 +161,7 @@ int cue_getTrackinfo(char *Line, tTrack *track)
* on the arrays to have the same size, thus we need to make
* sure the sizes are in sync.
*/
-int cue_find_bin (char *firstline) {
+static int cue_find_bin (char *firstline) {
int i,j;
char s[256];
char t[256];
@@ -251,7 +273,7 @@ static inline int cue_get_msf() {
cue_current_pos.frame);
}
-inline void cue_set_msf(unsigned int sect){
+static inline void cue_set_msf(unsigned int sect){
cue_current_pos.frame=sect%75;
sect=sect/75;
cue_current_pos.second=sect%60;
@@ -278,7 +300,7 @@ static inline int cue_mode_2_sector_size(int mode)
}
-int cue_read_cue (char *in_cue_filename)
+static int cue_read_cue (char *in_cue_filename)
{
struct stat filestat;
char sLine[256];
@@ -410,7 +432,7 @@ int cue_read_cue (char *in_cue_filename)
-int cue_read_toc_entry() {
+static int cue_read_toc_entry() {
int track = cue_current_pos.track - 1;
@@ -440,8 +462,8 @@ int cue_read_toc_entry() {
return 0;
}
-int cue_read_raw(char *buf) {
- int position;
+static int cue_read_raw(char *buf) {
+ unsigned long position;
int track = cue_current_pos.track - 1;
/* get the mode of the bin file part and calc the positon */
@@ -470,7 +492,7 @@ int cue_read_raw(char *buf) {
-int cue_vcd_seek_to_track (int track){
+static int cue_vcd_seek_to_track (int track){
cue_current_pos.track = track;
if (cue_read_toc_entry ())
@@ -479,7 +501,7 @@ int cue_vcd_seek_to_track (int track){
return VCD_SECTOR_DATA * cue_get_msf();
}
-int cue_vcd_get_track_end (int track){
+static int cue_vcd_get_track_end (int track){
cue_current_pos.frame = tracks[track].frame;
cue_current_pos.second = tracks[track].second;
cue_current_pos.minute = tracks[track].minute;
@@ -487,13 +509,13 @@ int cue_vcd_get_track_end (int track){
return VCD_SECTOR_DATA * cue_get_msf();
}
-void cue_vcd_read_toc(){
+static void cue_vcd_read_toc(){
int i;
for (i = 0; i < nTracks; ++i) {
mp_msg(MSGT_OPEN,MSGL_INFO,
"track %02d: format=%d %02d:%02d:%02d\n",
- i,
+ i+1,
tracks[i].mode,
tracks[i].minute,
tracks[i].second,
@@ -505,7 +527,7 @@ void cue_vcd_read_toc(){
static char vcd_buf[VCD_SECTOR_SIZE];
-int cue_vcd_read(char *mem){
+static int cue_vcd_read(stream_t *stream, char *mem, int size) {
if (cue_read_raw(vcd_buf)==-1) return 0; // EOF?
@@ -523,3 +545,73 @@ int cue_vcd_read(char *mem){
return VCD_SECTOR_DATA;
}
+
+static int seek(stream_t *s,off_t newpos) {
+ s->pos=newpos;
+ cue_set_msf(s->pos/VCD_SECTOR_DATA);
+ return 1;
+}
+
+
+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,track = 0;
+ char *filename = NULL, *colon = NULL;
+
+ if(mode != STREAM_READ || !p->filename) {
+ m_struct_free(&stream_opts,opts);
+ return STREAM_UNSUPORTED;
+ }
+ filename = strdup(p->filename);
+ if(!filename) {
+ m_struct_free(&stream_opts,opts);
+ return STREAM_UNSUPORTED;
+ }
+ colon = strstr(filename, ":");
+ if(colon) {
+ if(strlen(colon)>1)
+ track = atoi(colon+1);
+ *colon = 0;
+ }
+ if(!track)
+ track = 1;
+
+ f = cue_read_cue(filename);
+ if(f < 0) {
+ m_struct_free(&stream_opts,opts);
+ return STREAM_UNSUPORTED;
+ }
+ cue_vcd_read_toc();
+ ret2=cue_vcd_get_track_end(track);
+ ret=cue_vcd_seek_to_track(track);
+ if(ret<0){
+ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");
+ return STREAM_UNSUPORTED;
+ }
+ mp_msg(MSGT_OPEN,MSGL_INFO,"CUE stream_open, filename=%s, track=%d, available tracks: %d -> %d\n", filename, track, ret, ret2);
+
+ stream->fd = f;
+ stream->type = STREAMTYPE_VCDBINCUE;
+ stream->sector_size = VCD_SECTOR_DATA;
+ stream->flags = STREAM_READ | STREAM_SEEK_FW;
+ stream->start_pos = ret;
+ stream->end_pos = ret2;
+ stream->fill_buffer = cue_vcd_read;
+ stream->seek = seek;
+
+ free(filename);
+ m_struct_free(&stream_opts,opts);
+ return STREAM_OK;
+}
+
+stream_info_t stream_info_cue = {
+ "CUE track",
+ "cue",
+ "Albeu",
+ "based on the code from ???",
+ open_s,
+ { "cue", NULL },
+ &stream_opts,
+ 1 // Urls are an option string
+};
+
diff --git a/libmpdemux/cue_read.h b/libmpdemux/cue_read.h
index 4cc5d69e6e..b52826bdfa 100644
--- a/libmpdemux/cue_read.h
+++ b/libmpdemux/cue_read.h
@@ -1,7 +1,7 @@
-int cue_read_cue (char *in_cue_filename);
-int cue_vcd_seek_to_track (int track);
-int cue_vcd_get_track_end (int track);
-void cue_vcd_read_toc ();
-int cue_vcd_read(char *mem);
-inline void cue_set_msf(unsigned int sect);
+//int cue_read_cue (char *in_cue_filename);
+//int cue_vcd_seek_to_track (int track);
+//int cue_vcd_get_track_end (int track);
+//void cue_vcd_read_toc ();
+//int cue_vcd_read(char *mem);
+//inline void cue_set_msf(unsigned int sect);
diff --git a/libmpdemux/open.c b/libmpdemux/open.c
index 216f5a2795..33cdbfd57b 100644
--- a/libmpdemux/open.c
+++ b/libmpdemux/open.c
@@ -32,7 +32,6 @@ static URL_t* url;
/// We keep these 2 for the gui atm, but they will be removed.
int dvd_title=0;
-int vcd_track=0;
int dvd_chapter=1;
int dvd_last_chapter=0;
@@ -67,10 +66,6 @@ char * dvd_audio_stream_channels[6] =
{ "mono", "stereo", "unknown", "unknown", "5.1/6.1", "5.1" };
#endif
-#include "cue_read.h"
-
-
-
// Define function about auth the libsmbclient library
// FIXME: I really do not not is this function is properly working
@@ -126,35 +121,6 @@ if(!filename) {
return NULL;
}
-// for opening of vcds in bincue files
-if(strncmp("cue://",filename,6) == 0){
- int ret,ret2;
- char* p = filename + 6;
- vcd_track = 1;
- p = strchr(p,':');
- if(p && p[1] != '\0') {
- vcd_track = strtol(p+1,NULL,0);
- if(vcd_track < 1){
- mp_msg(MSGT_OPEN,MSGL_ERR,"Invalid cue track %s\n",p+1);
- return NULL;
- }
- p[0] = '\0';
- }
- f = cue_read_cue (filename + 6);
- if(p && p[1] != '\0') p[0] = ':';
- if (f == -1) return NULL;
- cue_vcd_read_toc();
- ret2=cue_vcd_get_track_end(vcd_track);
- ret=cue_vcd_seek_to_track(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);
-
- stream=new_stream(f,STREAMTYPE_VCDBINCUE);
- stream->start_pos=ret;
- stream->end_pos=ret2;
- return stream;
-}
-
//============ Open DVD title ==============
#ifdef USE_DVDNAV
@@ -497,7 +463,7 @@ if(strncmp("dvd://",filename,6) == 0){
strncmp("vcd://", filename, 6) && strncmp("dvb://", filename, 6) &&
strncmp("cdda://", filename, 7) && strncmp("cddb://", filename, 7) &&
strncmp("mpst://", filename, 7) && strncmp("tivo://", filename, 7) &&
- strncmp("file://", filename, 7) &&
+ strncmp("file://", filename, 7) && strncmp("cue://", filename, 6) &&
strstr(filename, "://")) {
url = url_new(filename);
}
diff --git a/libmpdemux/stream.c b/libmpdemux/stream.c
index d1e3320afe..fe7e37580d 100644
--- a/libmpdemux/stream.c
+++ b/libmpdemux/stream.c
@@ -35,8 +35,6 @@
extern int verbose; // defined in mplayer.c
void cache_uninit(stream_t *s); // defined in cache2.c
-#include "cue_read.h"
-
//#include "vcd_read_bincue.h"
#ifdef USE_DVDREAD
@@ -68,6 +66,7 @@ extern stream_info_t stream_info_ftp;
extern stream_info_t stream_info_vstream;
#endif
+extern stream_info_t stream_info_cue;
extern stream_info_t stream_info_null;
extern stream_info_t stream_info_file;
@@ -90,6 +89,7 @@ stream_info_t* auto_open_streams[] = {
#ifdef HAVE_VSTREAM
&stream_info_vstream,
#endif
+ &stream_info_cue,
&stream_info_null,
&stream_info_file,
NULL
@@ -203,8 +203,6 @@ int stream_fill_buffer(stream_t *s){
#else
len=read(s->fd,s->buffer,STREAM_BUFFER_SIZE);break;
#endif
- case STREAMTYPE_VCDBINCUE:
- len=cue_vcd_read(s->buffer);break;
#ifdef USE_DVDNAV
case STREAMTYPE_DVDNAV: {
dvdnav_stream_read((dvdnav_priv_t*)s->priv,s->buffer,&len);
@@ -253,8 +251,6 @@ off_t newpos=0;
#else
newpos=pos&(~(STREAM_BUFFER_SIZE-1));break;
#endif
- case STREAMTYPE_VCDBINCUE:
- newpos=(pos/VCD_SECTOR_DATA)*VCD_SECTOR_DATA;break;
case STREAMTYPE_DVD:
newpos=pos/2048; newpos*=2048; break;
default:
@@ -291,10 +287,6 @@ if(newpos==0 || newpos!=s->pos){
if(smbc_lseek(s->fd,s->pos,SEEK_SET)<0) s->eof=1;
break;
#endif
- case STREAMTYPE_VCDBINCUE:
- s->pos=newpos; // real seek
- cue_set_msf(s->pos/VCD_SECTOR_DATA);
- break;
#ifdef USE_DVDNAV
case STREAMTYPE_DVDNAV: {
if (newpos==0) {