[MPlayer-cvslog] CVS: main/libmpdemux stream.c, 1.74, 1.75 open.c, 1.103, 1.104 cue_read.c, 1.7, 1.8 cue_read.h, 1.1, 1.2
Nico Sabbi CVS
syncmail at mplayerhq.hu
Sun May 15 09:38:44 CEST 2005
CVS change done by Nico Sabbi CVS
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv29235
Modified Files:
stream.c open.c cue_read.c cue_read.h
Log Message:
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
Index: stream.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/stream.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- stream.c 12 May 2005 22:07:11 -0000 1.74
+++ stream.c 15 May 2005 07:38:42 -0000 1.75
@@ -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_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 @@
#ifdef HAVE_VSTREAM
&stream_info_vstream,
#endif
+ &stream_info_cue,
&stream_info_null,
&stream_info_file,
NULL
@@ -203,8 +203,6 @@
#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 @@
#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(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) {
Index: open.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/open.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -r1.103 -r1.104
--- open.c 14 May 2005 08:15:37 -0000 1.103
+++ open.c 15 May 2005 07:38:42 -0000 1.104
@@ -32,7 +32,6 @@
/// 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 @@
{ "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 @@
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 @@
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);
}
Index: cue_read.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/cue_read.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- cue_read.c 25 Jun 2004 16:49:51 -0000 1.7
+++ cue_read.c 15 May 2005 07:38:42 -0000 1.8
@@ -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 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 @@
* 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 @@
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 @@
}
-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_toc_entry() {
+static int cue_read_toc_entry() {
int track = cue_current_pos.track - 1;
@@ -440,8 +462,8 @@
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_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 @@
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 @@
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 @@
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 @@
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
+};
+
Index: cue_read.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/cue_read.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cue_read.h 5 Jan 2003 23:51:05 -0000 1.1
+++ cue_read.h 15 May 2005 07:38:42 -0000 1.2
@@ -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);
More information about the MPlayer-cvslog
mailing list