diff options
author | Guenter Bartsch <guenter@users.sourceforge.net> | 2002-10-26 22:50:52 +0000 |
---|---|---|
committer | Guenter Bartsch <guenter@users.sourceforge.net> | 2002-10-26 22:50:52 +0000 |
commit | 799a8c755b1ec87a799f1a18e9ccfea04ef1897c (patch) | |
tree | 54945f533388ebc09ed37e54770cb9fb974e77b0 /src | |
parent | 549e07167100fc654422dbaa0b9056162ceac606 (diff) | |
download | xine-lib-799a8c755b1ec87a799f1a18e9ccfea04ef1897c.tar.gz xine-lib-799a8c755b1ec87a799f1a18e9ccfea04ef1897c.tar.bz2 |
timeouts for mms, send progress report events, introduce verbosity engine parameter (not implemented yet), document new plugin loader in changelog
CVS patchset: 3029
CVS date: 2002/10/26 22:50:52
Diffstat (limited to 'src')
-rw-r--r-- | src/demuxers/demux_avi.c | 13 | ||||
-rw-r--r-- | src/input/input_dvd.c | 32 | ||||
-rw-r--r-- | src/input/input_http.c | 5 | ||||
-rw-r--r-- | src/input/input_mms.c | 4 | ||||
-rw-r--r-- | src/input/mms.c | 180 | ||||
-rw-r--r-- | src/input/mms.h | 5 | ||||
-rw-r--r-- | src/input/net_buf_ctrl.c | 26 |
7 files changed, 192 insertions, 73 deletions
diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index 896f054ca..24e3d8be0 100644 --- a/src/demuxers/demux_avi.c +++ b/src/demuxers/demux_avi.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_avi.c,v 1.128 2002/10/26 22:00:50 guenter Exp $ + * $Id: demux_avi.c,v 1.129 2002/10/26 22:50:52 guenter Exp $ * * demultiplexer for avi streams * @@ -426,16 +426,17 @@ static long idx_grow(demux_avi_t *this, long (*stopper)(demux_avi_t *, void *), /* send event to frontend about index generation progress */ xine_event_t event; - xine_idx_progress_data_t idx; + xine_progress_data_t prg; off_t file_len; file_len = this->input->get_length (this->input); - idx.percent = 100 * this->idx_grow.nexttagoffset / file_len; + prg.description = _("Restoring index..."); + prg.percent = 100 * this->idx_grow.nexttagoffset / file_len; - event.type = XINE_EVENT_BUILDING_INDEX; - event.data = &idx; - event.data_length = sizeof (xine_idx_progress_data_t); + event.type = XINE_EVENT_PROGRESS; + event.data = &prg; + event.data_length = sizeof (xine_progress_data_t); xine_event_send (this->stream, &event); } diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c index cc77a0e04..c3d3874c9 100644 --- a/src/input/input_dvd.c +++ b/src/input/input_dvd.c @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_dvd.c,v 1.105 2002/10/26 20:15:21 mroi Exp $ + * $Id: input_dvd.c,v 1.106 2002/10/26 22:50:52 guenter Exp $ * */ @@ -150,6 +150,8 @@ typedef struct { int32_t region; int32_t language; + char *filelist2[MAX_DIR_ENTRIES]; + } dvd_input_class_t; typedef struct { @@ -178,7 +180,6 @@ typedef struct { int num_mrls; */ char filelist[MAX_DIR_ENTRIES][MAX_STR_LEN]; - char *filelist2[MAX_DIR_ENTRIES]; char ui_title[MAX_STR_LEN + 1]; /* special buffer handling for libdvdnav caching */ @@ -1449,19 +1450,16 @@ static xine_mrl_t **dvd_class_get_dir (input_class_t *this_gen, *nFiles = 0; return NULL; } +#endif + +static char ** dvd_class_get_autoplay_list (input_class_t *this_gen, + int *num_files) { -static char **dvd_class_get_autoplay_list (input_class_t *this_gen, - int *nFiles) { dvd_input_class_t *this = (dvd_input_class_t *) this_gen; int i; trace_print("get_autoplay_list entered\n"); - /* Close the plugin is opened */ - if(this->opened) { - dvdnav_close(this->dvdnav); - this->dvdnav = NULL; - this->opened = 0; - } +#if 0 /* rebuild thie MRL browser list */ dvd_build_mrl_list(this); *nFiles = this->num_mrls; @@ -1472,9 +1470,15 @@ static char **dvd_class_get_autoplay_list (input_class_t *this_gen, this->filelist2[i] = &(this->filelist[i][0]); } this->filelist2[*nFiles] = NULL; + +#endif + + this->filelist2[0] = "dvd://"; + this->filelist2[1] = NULL; + *num_files = 1; + return this->filelist2; } -#endif void dvd_class_dispose(input_class_t *this_gen) { dvd_input_class_t *this = (dvd_input_class_t*)this_gen; @@ -1565,10 +1569,9 @@ static void *init_class (xine_t *xine, void *data) { this->input_class.get_description = dvd_class_get_description; /* this->input_class.get_dir = dvd_class_get_dir; - this->input_class.get_autoplay_list = dvd_class_get_autoplay_list; */ this->input_class.get_dir = NULL; - this->input_class.get_autoplay_list = NULL; + this->input_class.get_autoplay_list = dvd_class_get_autoplay_list; this->input_class.dispose = dvd_class_dispose; this->input_class.eject_media = dvd_class_eject_media; @@ -1659,6 +1662,9 @@ static void *init_class (xine_t *xine, void *data) { /* * $Log: input_dvd.c,v $ + * Revision 1.106 2002/10/26 22:50:52 guenter + * timeouts for mms, send progress report events, introduce verbosity engine parameter (not implemented yet), document new plugin loader in changelog + * * Revision 1.105 2002/10/26 20:15:21 mroi * first step in getting dvd events back * diff --git a/src/input/input_http.c b/src/input/input_http.c index 0d4e5e696..c5fdb1aa4 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -238,7 +238,7 @@ static int http_plugin_parse_url (char *urlbuf, char **user, char **password, } static int http_plugin_basicauth (const char *user, const char *password, - char* dest, int len) { + char* dest, int len) { static char *enctable="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; char *tmp; char *sptr; @@ -296,9 +296,6 @@ static int http_plugin_basicauth (const char *user, const char *password, } static off_t http_plugin_read (input_plugin_t *this_gen, - char *buf, off_t nlen) ; - -static off_t http_plugin_read (input_plugin_t *this_gen, char *buf, off_t nlen) { http_input_plugin_t *this = (http_input_plugin_t *) this_gen; off_t n, num_bytes; diff --git a/src/input/input_mms.c b/src/input/input_mms.c index 4bfee4697..9e6b1165f 100644 --- a/src/input/input_mms.c +++ b/src/input/input_mms.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: input_mms.c,v 1.21 2002/10/23 21:19:42 guenter Exp $ + * $Id: input_mms.c,v 1.22 2002/10/26 22:50:52 guenter Exp $ * * mms input plugin based on work from major mms */ @@ -258,7 +258,7 @@ static input_plugin_t *open_plugin (input_class_t *cls_gen, xine_stream_t *strea printf ("input_mms: trying to open '%s'\n", mrl); #endif - mms = mms_connect (mrl); + mms = mms_connect (stream, mrl); if (!mms) { free (mrl); diff --git a/src/input/mms.c b/src/input/mms.c index 3605e5cea..f62430971 100644 --- a/src/input/mms.c +++ b/src/input/mms.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: mms.c,v 1.11 2002/10/02 15:54:51 mroi Exp $ + * $Id: mms.c,v 1.12 2002/10/26 22:50:52 guenter Exp $ * * based on work from major mms * utility functions to handle communication with an mms server @@ -41,6 +41,7 @@ #include <stdlib.h> #include <time.h> +#include "xine_internal.h" #include "xineutils.h" #include "bswap.h" @@ -78,7 +79,7 @@ struct mms_s { char str[1024]; /* scratch buffer to built strings */ /* receive buffer */ - char buf[BUF_SIZE]; + uint8_t buf[BUF_SIZE]; int buf_size; int buf_read; @@ -95,6 +96,39 @@ struct mms_s { /* network/socket utility functions */ +static ssize_t read_timeout(int fd, void *buf, size_t count) { + + ssize_t ret, total; + int timeout; + + timeout = 30; total = 0; + + while (total < count) { + + while ( ((ret=read (fd, buf+total, count-total)) < 0) + && ( (errno == EINPROGRESS) || (errno == EAGAIN)) + && (timeout>0)) { + + sleep (1); +#ifdef LOG + printf ("mms: read in progress...%d, %d/%d\n", errno, total, count); +#endif + timeout--; + } + + if (ret<0) + return ret; + else + total += ret; + } + +#ifdef LOG + printf ("mms: read completed %d/%d\n", total, count); +#endif + + return total; +} + static int host_connect_attempt(struct in_addr ia, int port) { int s; @@ -106,6 +140,10 @@ static int host_connect_attempt(struct in_addr ia, int port) { return -1; } + /* put socket in non-blocking mode */ + + fcntl (s, F_SETFL, fcntl (s, F_GETFL) | O_NONBLOCK); + sin.sin_family = AF_INET; sin.sin_addr = ia; sin.sin_port = htons(port); @@ -157,17 +195,26 @@ static void put_32 (mms_t *this, uint32_t value) { } static int send_data (int s, char *buf, int len) { - int total; + int total, timeout; - total = 0; + total = 0; timeout = 30; while (total < len){ int n; n = write (s, &buf[total], len - total); + +#ifdef LOG + printf ("mms: sending data, %d of %d\n", n, len); +#endif + if (n > 0) total += n; - else if (n < 0 && errno != EAGAIN) - return total; + else if (n < 0) { + if ((timeout>0) && ((errno == EAGAIN) || (errno == EINPROGRESS))) { + sleep (1); timeout--; + } else + return -1; + } } return total; } @@ -300,19 +347,33 @@ static void print_answer (char *data, int len) { } -static void get_answer (mms_t *this) { +static int get_answer (mms_t *this) { int command = 0x1b; while (command == 0x1b) { - int len; + int len, length; - len = read (this->s, this->buf, BUF_SIZE) ; - if (!len) { + len = read_timeout (this->s, this->buf, 12); + if (len != 12) { printf ("\nalert! eof\n"); - return; + return 0; + } + + length = get_32 (this->buf, 8); + +#ifdef LOG + printf ("\n\npacket length: %d\n", length); +#endif + + len = read_timeout (this->s, this->buf+12, length+4) ; + if (len<=0) { + printf ("alert! eof\n"); + return 0; } + len += 12; + print_answer (this->buf, len); command = get_32 (this->buf, 36) & 0xFFFF; @@ -321,34 +382,20 @@ static void get_answer (mms_t *this) { send_command (this, 0x1b, 0, 0, 0); } + return 1; } static int receive (int s, char *buf, size_t count) { - ssize_t len, total; - - total = 0; - - while (total < count) { - len = read (s, &buf[total], count-total); - if (len < 0) { - perror ("read error:"); - return 0; - } - - total += len; - -#ifdef LOG - if (len != 0) { - printf ("[%d/%d]", total, count); - fflush (stdout); - } -#endif + ssize_t len; + len = read_timeout (s, buf, count); + if (len < 0) { + perror ("read error:"); + return 0; } - return 1; - + return len; } static void get_header (mms_t *this) { @@ -616,7 +663,22 @@ void mms_gen_guid(char guid[]) { guid[36] = '\0'; } -mms_t *mms_connect (const char *url_) { +static void report_progress (xine_stream_t *stream, int p) { + + xine_event_t event; + xine_progress_data_t prg; + + prg.description = _("Connecting MMS server..."); + prg.percent = p; + + event.type = XINE_EVENT_PROGRESS; + event.data = &prg; + event.data_length = sizeof (xine_progress_data_t); + + xine_event_send (stream, &event); +} + +mms_t *mms_connect (xine_stream_t *stream, const char *url_) { mms_t *this; char *url = NULL; char *url1 = NULL; @@ -629,6 +691,8 @@ mms_t *mms_connect (const char *url_) { if(!url_) return NULL; + report_progress (stream, 0); + url = strdup (url_); port = MMS_PORT; url1 = mms_connect_common(&s, &port, url, &host, &path, &file); @@ -638,6 +702,8 @@ mms_t *mms_connect (const char *url_) { return NULL; } + report_progress (stream, 10); + this = (mms_t*) malloc (sizeof (mms_t)); this->url = url; @@ -670,11 +736,16 @@ mms_t *mms_connect (const char *url_) { send_command (this, 1, 0, 0x0004000b, strlen(this->str) * 2 + 8); printf("libmms: before read \n"); - len = read (this->s, this->buf, BUF_SIZE) ; - if (len > 0) - print_answer (this->buf, len); - else + + if (!get_answer (this)) { printf ("libmms: read failed: %s\n", strerror(errno)); + close (this->s); + free (url); + free (this); + return NULL; + } + + report_progress (stream, 20); /* cmd2 */ @@ -682,9 +753,15 @@ mms_t *mms_connect (const char *url_) { memset (this->scmd_body, 0, 8); send_command (this, 2, 0, 0, 28 * 2 + 8); - len = read (this->s, this->buf, BUF_SIZE) ; - if (len) - print_answer (this->buf, len); + if (!get_answer (this)) { + printf ("libmms: read failed: %s\n", strerror(errno)); + close (this->s); + free (url); + free (this); + return NULL; + } + + report_progress (stream, 30); /* 0x5 */ @@ -694,20 +771,25 @@ mms_t *mms_connect (const char *url_) { get_answer (this); - /* 0x15 */ + report_progress (stream, 40); + /* 0x15 */ memset (this->scmd_body, 0, 40); this->scmd_body[32] = 2; send_command (this, 0x15, 1, 0, 40); + get_answer (this); + this->num_stream_ids = 0; get_header (this); interp_header (this); + report_progress (stream, 50); + /* 0x33 */ memset (this->scmd_body, 0, 40); @@ -725,6 +807,8 @@ mms_t *mms_connect (const char *url_) { get_answer (this); + report_progress (stream, 75); + /* 0x07 */ @@ -738,7 +822,12 @@ mms_t *mms_connect (const char *url_) { send_command (this, 0x07, 1, 0xFFFF | this->stream_ids[0] << 16, 24); + + report_progress (stream, 100); + +#ifdef LOG printf(" mms_connect: passed\n" ); +#endif return this; } @@ -752,9 +841,12 @@ static int get_media_packet (mms_t *this) { } #ifdef LOG - for (i = 0; i < 8; i++) - printf ("pre_header[%d] = %02x (%d)\n", - i, pre_header[i], pre_header[i]); + { + int i; + for (i = 0; i < 8; i++) + printf ("pre_header[%d] = %02x (%d)\n", + i, pre_header[i], pre_header[i]); + } #endif if (pre_header[4] == 0x04) { diff --git a/src/input/mms.h b/src/input/mms.h index 9e535315a..c78782a05 100644 --- a/src/input/mms.h +++ b/src/input/mms.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: mms.h,v 1.6 2002/09/06 18:13:11 mroi Exp $ + * $Id: mms.h,v 1.7 2002/10/26 22:50:52 guenter Exp $ * * libmms public header */ @@ -26,11 +26,12 @@ #define HAVE_MMS_H #include <inttypes.h> +#include "xine_internal.h" typedef struct mms_s mms_t; char* mms_connect_common(int *s ,int *port, char *url, char **host, char **path, char **file); -mms_t* mms_connect (const char *url); +mms_t* mms_connect (xine_stream_t *stream, const char *url); int mms_read (mms_t *this, char *data, int len); uint32_t mms_get_length (mms_t *this); diff --git a/src/input/net_buf_ctrl.c b/src/input/net_buf_ctrl.c index 6302ca9dc..bedd061ba 100644 --- a/src/input/net_buf_ctrl.c +++ b/src/input/net_buf_ctrl.c @@ -33,7 +33,9 @@ #define DEFAULT_LOW_WATER_MARK 2 #define DEFAULT_HIGH_WATER_MARK 5 +/* #define LOG +*/ struct nbc_s { @@ -45,6 +47,23 @@ struct nbc_s { }; +static void report_progress (xine_stream_t *stream, int p) { + + xine_event_t event; + xine_progress_data_t prg; + + prg.description = _("Buffering..."); + prg.percent = p; + + event.type = XINE_EVENT_PROGRESS; + event.data = &prg; + event.data_length = sizeof (xine_progress_data_t); + + xine_event_send (stream, &event); +} + + + void nbc_check_buffers (nbc_t *this) { int fifo_fill; @@ -53,12 +72,15 @@ void nbc_check_buffers (nbc_t *this) { if (this->stream->audio_fifo) { fifo_fill += 8*this->stream->audio_fifo->size(this->stream->audio_fifo); } -#ifdef LOG if (this->buffering) { + + report_progress (this->stream, fifo_fill*100 / this->high_water_mark); + +#ifdef LOG printf ("net_buf_ctl: buffering (%d/%d)...\n", fifo_fill, this->high_water_mark); - } #endif + } if (fifo_fill<this->low_water_mark) { if (!this->buffering) { |