diff options
-rw-r--r-- | src/input/Makefile.am | 10 | ||||
-rw-r--r-- | src/input/input_http.c | 83 | ||||
-rw-r--r-- | src/input/input_mms.c | 74 | ||||
-rw-r--r-- | src/input/input_net.c | 65 | ||||
-rw-r--r-- | src/input/input_stdin_fifo.c | 95 | ||||
-rw-r--r-- | src/input/strict_scr.c | 142 | ||||
-rw-r--r-- | src/input/strict_scr.h | 44 | ||||
-rw-r--r-- | src/xine-engine/metronom.c | 39 | ||||
-rw-r--r-- | src/xine-engine/metronom.h | 18 | ||||
-rw-r--r-- | src/xine-engine/xine.c | 6 |
10 files changed, 131 insertions, 445 deletions
diff --git a/src/input/Makefile.am b/src/input/Makefile.am index b09bc480e..cd966234e 100644 --- a/src/input/Makefile.am +++ b/src/input/Makefile.am @@ -30,29 +30,29 @@ xineplug_inp_file_la_LDFLAGS = -avoid-version -module xineplug_inp_dvd_la_SOURCES = input_dvd.c dvd_udf.c read_cache.c xineplug_inp_dvd_la_LDFLAGS = -avoid-version -module -xineplug_inp_net_la_SOURCES = input_net.c strict_scr.c +xineplug_inp_net_la_SOURCES = input_net.c net_buf_ctrl.c xineplug_inp_net_la_LDFLAGS = -avoid-version -module -xineplug_inp_mms_la_SOURCES = input_mms.c strict_scr.c mms.c asxparser.c +xineplug_inp_mms_la_SOURCES = input_mms.c net_buf_ctrl.c mms.c asxparser.c xineplug_inp_mms_la_LDFLAGS = -avoid-version -module xineplug_inp_vcd_la_SOURCES = input_vcd.c xineplug_inp_vcd_la_LDFLAGS = -avoid-version -module -xineplug_inp_stdin_fifo_la_SOURCES = input_stdin_fifo.c strict_scr.c +xineplug_inp_stdin_fifo_la_SOURCES = input_stdin_fifo.c net_buf_ctrl.c xineplug_inp_stdin_fifo_la_LDFLAGS = -avoid-version -module xineplug_inp_rtp_la_SOURCES = input_rtp.c xineplug_inp_rtp_la_LDFLAGS = -avoid-version -module -xineplug_inp_http_la_SOURCES = input_http.c +xineplug_inp_http_la_SOURCES = input_http.c net_buf_ctrl.c xineplug_inp_http_la_LDFLAGS = -avoid-version -module xineplug_inp_cda_la_SOURCES = input_cda.c xineplug_inp_cda_la_LDFLAGS = -avoid-version -module include_HEADERS = input_plugin.h -noinst_HEADERS = dvd_udf.h read_cache.h strict_scr.h mms.h +noinst_HEADERS = dvd_udf.h read_cache.h net_buf_ctrl.h mms.h EXTRA_DIST = input_dvd.c dvd_udf.c input_vcd.c read_cache.c diff --git a/src/input/input_http.c b/src/input/input_http.c index 8968dd77d..3c1c081c4 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -1,7 +1,7 @@ /* - * Copyright (C) 2000-2001 the xine project + * Copyright (C) 2000-2002 the xine project * - * This file is part of xine, a unix video player. + * This file is part of xine, a free video player. * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,29 +39,10 @@ #include "xine_internal.h" #include "xineutils.h" #include "input_plugin.h" +#include "net_buf_ctrl.h" extern int errno; -#ifdef __GNUC__ -#define LOG_MSG_STDERR(xine, message, args...) { \ - xine_log(xine, XINE_LOG_MSG, message, ##args); \ - fprintf(stderr, message, ##args); \ - } -#define LOG_MSG(xine, message, args...) { \ - xine_log(xine, XINE_LOG_MSG, message, ##args); \ - printf(message, ##args); \ - } -#else -#define LOG_MSG_STDERR(xine, ...) { \ - xine_log(xine, XINE_LOG_MSG, __VA_ARGS__); \ - fprintf(stderr, __VA_ARGS__); \ - } -#define LOG_MSG(xine, ...) { \ - xine_log(xine, XINE_LOG_MSG, __VA_ARGS__); \ - printf(__VA_ARGS__); \ - } -#endif - #define BUFSIZE 1024 #define DEFAULT_HTTP_PORT 80 @@ -75,6 +56,8 @@ typedef struct { char *mrl; config_values_t *config; + nbc_t *nbc; + off_t curpos; off_t contentlength; @@ -106,7 +89,7 @@ static int http_plugin_host_connect_attempt(struct in_addr ia, int port, xine_t s=socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (s==-1) { - LOG_MSG(xine, _("input_http: failed to open socket\n")); + xine_log (xine, XINE_LOG_MSG, _("input_http: failed to open socket\n")); return -1; } @@ -115,7 +98,7 @@ static int http_plugin_host_connect_attempt(struct in_addr ia, int port, xine_t sin.sin_port = htons(port); if (connect(s, (struct sockaddr *)&sin, sizeof(sin))==-1 && errno != EINPROGRESS) { - LOG_MSG(xine, _("input_http: cannot connect to host\n")); + xine_log (xine, XINE_LOG_MSG, _("input_http: cannot connect to host\n")); close(s); return -1; } @@ -130,7 +113,7 @@ static int http_plugin_host_connect(const char *host, int port, xine_t *xine) { h=gethostbyname(host); if (h==NULL) { - LOG_MSG(xine, _("input_http: unable to resolve >%s<\n"), host); + xine_log (xine, XINE_LOG_MSG, _("input_http: unable to resolve >%s<\n"), host); return -1; } @@ -142,7 +125,7 @@ static int http_plugin_host_connect(const char *host, int port, xine_t *xine) { return s; } - LOG_MSG(xine, _("http: unable to connect to >%s<\n"), host); + xine_log (xine, XINE_LOG_MSG, _("http: unable to connect to >%s<\n"), host); return -1; } @@ -346,7 +329,9 @@ static int http_plugin_open (input_plugin_t *this_gen, char *mrl) { sprintf(buf, "%s\n", buf); - LOG_MSG(this->xine, buf); +#ifdef LOG + printf (buf); +#endif } if (proxy != NULL) @@ -397,8 +382,10 @@ static int http_plugin_open (input_plugin_t *this_gen, char *mrl) { return 0 ; } +#ifdef LOG printf ("input_http: request sent: >%s<\n", this->buf); +#endif /* read and parse reply */ done = 0; len = 0; linenum = 0; @@ -414,10 +401,10 @@ static int http_plugin_open (input_plugin_t *this_gen, char *mrl) { switch (errno) { case EAGAIN: - LOG_MSG(this->xine, _("input_http: EAGAIN\n")); + xine_log (this->xine, XINE_LOG_MSG, _("input_http: EAGAIN\n")); continue; default: - LOG_MSG(this->xine, _("input_http: read error\n")); + xine_log (this->xine, XINE_LOG_MSG, _("input_http: read error\n")); return 0; } } @@ -434,7 +421,9 @@ static int http_plugin_open (input_plugin_t *this_gen, char *mrl) { linenum++; - LOG_MSG(this->xine, _("input_http: answer: >%s<\n"), this->buf); +#ifdef LOG + printf ("input_http: answer: >%s<\n", this->buf); +#endif if (linenum == 1) { @@ -444,17 +433,17 @@ static int http_plugin_open (input_plugin_t *this_gen, char *mrl) { if (sscanf(this->buf, "HTTP/%d.%d %d %[^\015\012]", &httpver, &httpsub, &httpcode, httpstatus) != 4) { - LOG_MSG(this->xine, _("input_http: invalid http answer\n")); + xine_log (this->xine, XINE_LOG_MSG, _("input_http: invalid http answer\n")); return 0; } if (httpcode >= 300 && httpcode < 400) { - LOG_MSG(this->xine, _("input_http: 3xx redirection not implemented: >%d %s<\n"), + xine_log (this->xine, XINE_LOG_MSG, _("input_http: 3xx redirection not implemented: >%d %s<\n"), httpcode, httpstatus); return 0; } if (httpcode < 200 || httpcode >= 300) { - LOG_MSG(this->xine, _("input_http: http status not 2xx: >%d %s<\n"), + xine_log (this->xine, XINE_LOG_MSG, _("input_http: http status not 2xx: >%d %s<\n"), httpcode, httpstatus); return 0; } @@ -463,14 +452,14 @@ static int http_plugin_open (input_plugin_t *this_gen, char *mrl) { off_t contentlength; if (sscanf(this->buf, "Content-Length: %Ld", &contentlength) == 1) { - LOG_MSG(this->xine, _("input_http: content length = %Ld bytes\n"), contentlength); + xine_log (this->xine, XINE_LOG_MSG, _("input_http: content length = %Ld bytes\n"), contentlength); this->contentlength = contentlength; } } if (!strncasecmp(this->buf, "Location: ", 10)) { - LOG_MSG(this->xine, _("input_http: Location redirection not implemented\n")); + xine_log (this->xine, XINE_LOG_MSG, _("input_http: Location redirection not implemented\n")); return 0; } } @@ -483,7 +472,11 @@ static int http_plugin_open (input_plugin_t *this_gen, char *mrl) { len ++; } - LOG_MSG(this->xine, _("input_http: end of headers\n")); +#ifdef LOG + printf ("input_http: end of headers\n"); +#endif + + this->nbc = nbc_init (this->xine); return 1; } @@ -493,6 +486,8 @@ static off_t http_plugin_read (input_plugin_t *this_gen, http_input_plugin_t *this = (http_input_plugin_t *) this_gen; off_t n, num_bytes; + nbc_check_buffers (this->nbc); + num_bytes = 0; while (num_bytes < nlen) { @@ -503,10 +498,10 @@ static off_t http_plugin_read (input_plugin_t *this_gen, switch (errno) { case EAGAIN: - LOG_MSG(this->xine, _("input_http: EAGAIN\n")); + xine_log (this->xine, XINE_LOG_MSG, _("input_http: EAGAIN\n")); continue; default: - LOG_MSG(this->xine, _("input_http: read error\n")); + xine_log (this->xine, XINE_LOG_MSG, _("input_http: read error\n")); return 0; } } @@ -533,6 +528,8 @@ static buf_element_t *http_plugin_read_block (input_plugin_t *this_gen, fifo_buf http_input_plugin_t *this = (http_input_plugin_t *) this_gen; buf_element_t *buf = fifo->buffer_pool_alloc (fifo); + nbc_check_buffers (this->nbc); + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,NULL); pthread_cleanup_push( pool_release_buffer, buf ); @@ -544,7 +541,7 @@ static buf_element_t *http_plugin_read_block (input_plugin_t *this_gen, fifo_buf pthread_testcancel(); num_bytes = read (this->fh, buf->mem + total_bytes, todo-total_bytes); if (num_bytes < 0) { - LOG_MSG(this->xine, _("input_http: read error (%s)\n"), strerror (errno)); + xine_log (this->xine, XINE_LOG_MSG, _("input_http: read error (%s)\n"), strerror (errno)); buf->free_buffer (buf); buf = NULL; break; @@ -593,6 +590,11 @@ static void http_plugin_close (input_plugin_t *this_gen) { close(this->fh); this->fh = -1; + + if (this->nbc) { + nbc_close (this->nbc); + this->nbc = NULL; + } } static void http_plugin_stop (input_plugin_t *this_gen) { @@ -626,7 +628,7 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) { config_values_t *config; if (iface != 5) { - LOG_MSG(xine, + xine_log (xine, XINE_LOG_PLUGIN, _("http input plugin doesn't support plugin API version %d.\n" "PLUGIN DISABLED.\n" "This means there's a version mismatch between xine and this input" @@ -662,6 +664,7 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) { this->fh = -1; this->config = config; this->curpos = 0; + this->nbc = NULL; return (input_plugin_t *) this; } diff --git a/src/input/input_mms.c b/src/input/input_mms.c index 507155584..0c78e3c7f 100644 --- a/src/input/input_mms.c +++ b/src/input/input_mms.c @@ -41,7 +41,7 @@ #include "input_plugin.h" #include "mms.h" -#include "strict_scr.h" +#include "net_buf_ctrl.h" extern int errno; @@ -65,11 +65,7 @@ typedef struct { off_t curpos; - int buffering; - int low_water_mark; - int high_water_mark; - - strictscr_t *scr; + nbc_t *nbc; char scratch[1025]; @@ -112,14 +108,8 @@ static int mms_plugin_open (input_plugin_t *this_gen, char *mrl) { return 0; } - this->curpos = 0; - this->buffering = 0; - this->low_water_mark = DEFAULT_LOW_WATER_MARK; - this->high_water_mark = DEFAULT_HIGH_WATER_MARK; - - /* register our scr plugin */ - this->scr->scr.start (&this->scr->scr, this->xine->metronom->get_current_time (this->xine->metronom)); - this->xine->metronom->register_scr (this->xine->metronom, &this->scr->scr); + this->curpos = 0; + this->nbc = nbc_init (this->xine); return 1; } @@ -127,56 +117,13 @@ static off_t mms_plugin_read (input_plugin_t *this_gen, char *buf, off_t len) { mms_input_plugin_t *this = (mms_input_plugin_t *) this_gen; off_t n; - int fifo_fill; #ifdef LOG printf ("mms_plugin_read: %lld bytes ...\n", len); #endif - fifo_fill = this->xine->video_fifo->size(this->xine->video_fifo); - if (this->xine->audio_fifo) { - fifo_fill += 8*this->xine->audio_fifo->size(this->xine->audio_fifo); - } - - if (this->buffering) { - xine_log (this->xine, XINE_LOG_MSG, - "input_mms: buffering (%d/%d)...\n", fifo_fill, this->high_water_mark); - } - - if (fifo_fill<this->low_water_mark) { - - if (!this->buffering) { - - this->xine->osd_renderer->filled_rect (this->xine->osd, 0, 0, 299, 99, 0); - this->xine->osd_renderer->render_text (this->xine->osd, 5, 30, "mms: buffering...", OSD_TEXT1); - this->xine->osd_renderer->show (this->xine->osd, 0); - - /* give video_out time to display osd before pause */ - sleep (1); - - if (this->high_water_mark<150) { - - /* increase marks to adapt to stream/network needs */ - - this->high_water_mark += 10; - this->low_water_mark = this->high_water_mark/4; - } - } - - this->xine->metronom->set_speed (this->xine->metronom, SPEED_PAUSE); - this->xine->audio_out->audio_paused = 2; - this->buffering = 1; - this->scr->adjustable = 0; - - } else if ( (fifo_fill>this->high_water_mark) && (this->buffering)) { - this->xine->metronom->set_speed (this->xine->metronom, SPEED_NORMAL); - this->xine->audio_out->audio_paused = 0; - this->buffering = 0; - this->scr->adjustable = 1; - - this->xine->osd_renderer->hide (this->xine->osd, 0); - } + nbc_check_buffers (this->nbc); n = mms_read (this->mms, buf, len); this->curpos += n; @@ -312,7 +259,10 @@ static void mms_plugin_close (input_plugin_t *this_gen) { this->mms = NULL; } - this->xine->metronom->unregister_scr (this->xine->metronom, &this->scr->scr); + if (this->nbc) { + nbc_close (this->nbc); + this->nbc = NULL; + } } static void mms_plugin_stop (input_plugin_t *this_gen) { @@ -392,11 +342,7 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) { this->mrl = NULL; this->config = config; this->curpos = 0; - this->buffering = 0; - this->low_water_mark = DEFAULT_LOW_WATER_MARK; - this->high_water_mark = DEFAULT_HIGH_WATER_MARK; - - this->scr = strictscr_init (); + this->nbc = NULL; return &this->input_plugin; } diff --git a/src/input/input_net.c b/src/input/input_net.c index cdb0c383a..066d90258 100644 --- a/src/input/input_net.c +++ b/src/input/input_net.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2000-2002 the xine project * - * This file is part of xine, a unix video player. + * This file is part of xine, a free video player. * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,7 +54,7 @@ #include "xine_internal.h" #include "xineutils.h" #include "input_plugin.h" -#include "strict_scr.h" +#include "net_buf_ctrl.h" extern int errno; @@ -71,7 +71,6 @@ extern int errno; #endif #define NET_BS_LEN 2324 -#define PREBUF_SIZE 100000 typedef struct { input_plugin_t input_plugin; @@ -84,9 +83,7 @@ typedef struct { off_t curpos; - int buffering; - - strictscr_t *scr; + nbc_t *nbc; } net_input_plugin_t; @@ -164,9 +161,8 @@ static int net_plugin_open (input_plugin_t *this_gen, char *mrl) { sscanf(pptr,"%d", &port); } - this->fh = host_connect(filename, port, this->xine); + this->fh = host_connect(filename, port, this->xine); this->curpos = 0; - this->buffering = 0; if (this->fh == -1) { return 0; @@ -174,9 +170,7 @@ static int net_plugin_open (input_plugin_t *this_gen, char *mrl) { this->mrl = strdup(mrl); /* FIXME: small memory leak */ - /* register our scr plugin */ - - this->xine->metronom->register_scr (this->xine->metronom, &this->scr->scr); + this->nbc = nbc_init (this->xine); return 1; } @@ -188,49 +182,13 @@ static off_t net_plugin_read (input_plugin_t *this_gen, char *buf, off_t len) { net_input_plugin_t *this = (net_input_plugin_t *) this_gen; off_t n, total; - int fifo_fill, video_fill, audio_fill; - - video_fill = this->xine->video_fifo->size(this->xine->video_fifo); - - if (this->xine->audio_fifo) - audio_fill = this->xine->audio_fifo->size(this->xine->audio_fifo); - else - audio_fill = 0; - - if (audio_fill > video_fill) - fifo_fill = audio_fill; - else - fifo_fill = video_fill; - -#ifdef LOG - printf ("input_net: fifo_fill: %d, time is %d\n", fifo_fill, - this->xine->metronom->get_current_time (this->xine->metronom)); -#endif - - if (fifo_fill<LOW_WATER_MARK) { - - this->xine->metronom->set_speed (this->xine->metronom, SPEED_PAUSE); - this->scr->adjustable = 0; - if (!this->buffering) { - this->buffering = 1; - printf ("input_net: buffering...\n"); - } else { - this->buffering++; - if ((this->buffering % 100) == 0) - printf ("."); fflush(stdout); - } - - } else if ( (fifo_fill>HIGH_WATER_MARK) && (this->buffering)) { - this->xine->metronom->set_speed (this->xine->metronom, SPEED_NORMAL); - this->buffering = 0; - this->scr->adjustable = 1; - printf ("\ninput_net: buffering...done\n"); - } #ifdef LOG printf ("input_net: reading %d bytes...\n", len); #endif + nbc_check_buffers (this->nbc); + total=0; while (total<len){ n = read (this->fh, &buf[total], len-total); @@ -321,7 +279,10 @@ static void net_plugin_close (input_plugin_t *this_gen) { close(this->fh); this->fh = -1; - this->xine->metronom->unregister_scr (this->xine->metronom, &this->scr->scr); + if (this->nbc) { + nbc_close (this->nbc); + this->nbc = NULL; + } } /* @@ -410,9 +371,7 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) { this->mrl = NULL; this->config = config; this->curpos = 0; - this->buffering = 0; - - this->scr = strictscr_init (); + this->nbc = NULL; return (input_plugin_t *) this; } diff --git a/src/input/input_stdin_fifo.c b/src/input/input_stdin_fifo.c index 5325be5d4..117f22fa8 100644 --- a/src/input/input_stdin_fifo.c +++ b/src/input/input_stdin_fifo.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_stdin_fifo.c,v 1.21 2002/03/19 20:06:57 guenter Exp $ + * $Id: input_stdin_fifo.c,v 1.22 2002/03/23 18:56:55 guenter Exp $ */ #ifdef HAVE_CONFIG_H @@ -39,7 +39,7 @@ #include "xine_internal.h" #include "xineutils.h" #include "input_plugin.h" -#include "strict_scr.h" +#include "net_buf_ctrl.h" /* #define LOG @@ -66,11 +66,7 @@ typedef struct { off_t preview_size; off_t preview_pos; - strictscr_t *scr; - - int buffering; - int low_water_mark; - int high_water_mark; + nbc_t *nbc; char scratch[1025]; @@ -129,87 +125,29 @@ static int stdin_plugin_open(input_plugin_t *this_gen, char *mrl) { } /* - * fill preview buffer + * buffering control */ - this->preview_size = stdin_plugin_read (&this->input_plugin, this->preview, - PREVIEW_SIZE); - this->preview_pos = 0; + this->nbc = nbc_init (this->xine); /* - * buffering control + * fill preview buffer */ - this->curpos = 0; - this->buffering = 0; - this->low_water_mark = DEFAULT_LOW_WATER_MARK; - this->high_water_mark = DEFAULT_HIGH_WATER_MARK; - - /* register our scr plugin */ - this->scr->scr.start (&this->scr->scr, this->xine->metronom->get_current_time (this->xine->metronom)); - this->xine->metronom->register_scr (this->xine->metronom, &this->scr->scr); + this->preview_size = stdin_plugin_read (&this->input_plugin, this->preview, + PREVIEW_SIZE); + this->preview_pos = 0; return 1; } -static void check_fifo_buffers (stdin_input_plugin_t *this) { - - int fifo_fill; - - fifo_fill = this->xine->video_fifo->size(this->xine->video_fifo); - if (this->xine->audio_fifo) { - fifo_fill += 8*this->xine->audio_fifo->size(this->xine->audio_fifo); - } - - if (this->buffering) { - xine_log (this->xine, XINE_LOG_MSG, - "stdin: buffering (%d/%d)...\n", - fifo_fill, this->high_water_mark); - } - - if (fifo_fill<this->low_water_mark) { - - if (!this->buffering) { - - this->xine->osd_renderer->filled_rect (this->xine->osd, 0, 0, 299, 99, 0); - this->xine->osd_renderer->render_text (this->xine->osd, 5, 30, "stdin: buffering...", OSD_TEXT1); - this->xine->osd_renderer->show (this->xine->osd, 0); - - /* give video_out time to display osd before pause */ - sleep (1); - - if (this->high_water_mark<150) { - - /* increase marks to adapt to stream/network needs */ - - this->high_water_mark += 10; - this->low_water_mark = this->high_water_mark/4; - } - } - - this->xine->metronom->set_speed (this->xine->metronom, SPEED_PAUSE); - this->xine->audio_out->audio_paused = 2; - this->buffering = 1; - this->scr->adjustable = 0; - - } else if ( (fifo_fill>this->high_water_mark) && (this->buffering)) { - this->xine->metronom->set_speed (this->xine->metronom, SPEED_NORMAL); - this->xine->audio_out->audio_paused = 0; - this->buffering = 0; - this->scr->adjustable = 1; - - this->xine->osd_renderer->hide (this->xine->osd, 0); - } - -} - static off_t stdin_plugin_read (input_plugin_t *this_gen, char *buf, off_t todo) { stdin_input_plugin_t *this = (stdin_input_plugin_t *) this_gen; off_t num_bytes, total_bytes; - check_fifo_buffers (this); + nbc_check_buffers (this->nbc); total_bytes = 0; @@ -366,6 +304,11 @@ static char* stdin_plugin_get_mrl (input_plugin_t *this_gen) { static void stdin_plugin_close(input_plugin_t *this_gen) { stdin_input_plugin_t *this = (stdin_input_plugin_t *) this_gen; + if (this->nbc) { + nbc_close (this->nbc); + this->nbc = NULL; + } + close(this->fh); this->fh = -1; } @@ -442,11 +385,7 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) { this->mrl = NULL; this->config = config; this->curpos = 0; - this->buffering = 0; - this->low_water_mark = DEFAULT_LOW_WATER_MARK; - this->high_water_mark = DEFAULT_HIGH_WATER_MARK; - - this->scr = strictscr_init (); - + this->nbc = NULL; + return (input_plugin_t *) this; } diff --git a/src/input/strict_scr.c b/src/input/strict_scr.c deleted file mode 100644 index a0c78f1f3..000000000 --- a/src/input/strict_scr.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2002 the xine project - * - * This file is part of xine, a unix video player. - * - * xine is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * xine is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - * $Id: strict_scr.c,v 1.2 2002/02/09 07:13:23 guenter Exp $ - * - * scr plugin that may not allow others to adjust it (used for streaming) - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <string.h> - -#include "xine_internal.h" -#include "strict_scr.h" - -static int strictscr_get_priority (scr_plugin_t *scr) { - return 100; /* very high priority */ -} - -/* Only call this when already mutex locked */ -static void strictscr_set_pivot (strictscr_t *this) { - - struct timeval tv; - uint32_t pts; - double pts_calc; - - gettimeofday(&tv, NULL); - pts_calc = (tv.tv_sec - this->cur_time.tv_sec) * this->speed_factor; - pts_calc += (tv.tv_usec - this->cur_time.tv_usec) * this->speed_factor / 1e6; - pts = this->cur_pts + pts_calc; - -/* This next part introduces a one off inaccuracy - * to the scr due to rounding tv to pts. - */ - this->cur_time.tv_sec=tv.tv_sec; - this->cur_time.tv_usec=tv.tv_usec; - this->cur_pts=pts; - - return ; -} - -static int strictscr_set_speed (scr_plugin_t *scr, int speed) { - strictscr_t *this = (strictscr_t*) scr; - - pthread_mutex_lock (&this->lock); - - strictscr_set_pivot( this ); - this->speed_factor = (double) speed * 90000.0 / 4.0; - - pthread_mutex_unlock (&this->lock); - - return speed; -} - -static void strictscr_adjust (scr_plugin_t *scr, int64_t vpts) { - - strictscr_t *this = (strictscr_t*) scr; - struct timeval tv; - - if (this->adjustable) { - - pthread_mutex_lock (&this->lock); - - gettimeofday(&tv, NULL); - this->cur_time.tv_sec=tv.tv_sec; - this->cur_time.tv_usec=tv.tv_usec; - this->cur_pts = vpts; - - pthread_mutex_unlock (&this->lock); - } -} - -static void strictscr_start (scr_plugin_t *scr, int64_t start_vpts) { - strictscr_t *this = (strictscr_t*) scr; - - pthread_mutex_lock (&this->lock); - - gettimeofday(&this->cur_time, NULL); - this->cur_pts = start_vpts; - - pthread_mutex_unlock (&this->lock); -} - -static int64_t strictscr_get_current (scr_plugin_t *scr) { - strictscr_t *this = (strictscr_t*) scr; - - struct timeval tv; - int64_t pts; - double pts_calc; - pthread_mutex_lock (&this->lock); - - gettimeofday(&tv, NULL); - - pts_calc = (tv.tv_sec - this->cur_time.tv_sec) * this->speed_factor; - pts_calc += (tv.tv_usec - this->cur_time.tv_usec) * this->speed_factor / 1e6; - - pts = this->cur_pts + pts_calc; - - pthread_mutex_unlock (&this->lock); - - return pts; -} - -strictscr_t* strictscr_init () { - strictscr_t *this; - - this = malloc(sizeof(*this)); - memset(this, 0, sizeof(*this)); - - this->scr.interface_version = 2; - this->scr.get_priority = strictscr_get_priority; - this->scr.set_speed = strictscr_set_speed; - this->scr.adjust = strictscr_adjust; - this->scr.start = strictscr_start; - this->scr.get_current = strictscr_get_current; - strictscr_set_speed (&this->scr, SPEED_NORMAL); - - this->adjustable = 0; - - pthread_mutex_init (&this->lock, NULL); - - return this; -} - diff --git a/src/input/strict_scr.h b/src/input/strict_scr.h deleted file mode 100644 index 39d8bb8bf..000000000 --- a/src/input/strict_scr.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2002 the xine project - * - * This file is part of xine, a unix video player. - * - * xine is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * xine is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - * scr plugin that may not allow others to adjust it (used for streaming) - */ - -#ifndef HAVE_STRICT_SCR_H -#define HAVE_STRICT_SCR_H - -#include "metronom.h" - -typedef struct strictscr_s { - scr_plugin_t scr; - - struct timeval cur_time; - int64_t cur_pts; - double speed_factor; - - int adjustable; - - pthread_mutex_t lock; - -} strictscr_t; - -strictscr_t* strictscr_init () ; - -#endif - diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c index a3652b02b..416d74467 100644 --- a/src/xine-engine/metronom.c +++ b/src/xine-engine/metronom.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: metronom.c,v 1.73 2002/03/23 13:28:35 miguelfreitas Exp $ + * $Id: metronom.c,v 1.74 2002/03/23 18:56:56 guenter Exp $ */ #ifdef HAVE_CONFIG_H @@ -223,7 +223,8 @@ static void metronom_resume_clock(metronom_t *this) { static void metronom_adjust_clock(metronom_t *this, int64_t desired_pts) { - this->scr_master->adjust(this->scr_master, desired_pts); + if (this->scr_adjustable) + this->scr_master->adjust(this->scr_master, desired_pts); } static int metronom_set_speed (metronom_t *this, int speed) { @@ -503,19 +504,36 @@ static int64_t metronom_got_audio_samples (metronom_t *this, int64_t pts, return vpts; } -static void metronom_set_av_offset (metronom_t *this, int32_t pts) { +static void metronom_set_option (metronom_t *this, int option, int64_t value) { pthread_mutex_lock (&this->lock); - this->av_offset = pts; + switch (option) { + case METRONOM_AV_OFFSET: + this->av_offset = value; + printf ("metronom: av_offset=%lld pts\n", this->av_offset); + break; + case METRONOM_SCR_ADJUSTABLE: + this->scr_adjustable = value; + break; + default: + printf ("metronom: unknown option in set_option: %d\n", + option); + } pthread_mutex_unlock (&this->lock); - - printf ("metronom: av_offset=%d pts\n", pts); } -static int32_t metronom_get_av_offset (metronom_t *this) { - return this->av_offset; +static int64_t metronom_get_option (metronom_t *this, int option) { + switch (option) { + case METRONOM_AV_OFFSET: + return this->av_offset; + case METRONOM_SCR_ADJUSTABLE: + return this->scr_adjustable; + } + printf ("metronom: unknown option in get_option: %d\n", + option); + return 0; } static scr_plugin_t* get_master_scr(metronom_t *this) { @@ -628,8 +646,8 @@ metronom_t * metronom_init (int have_audio, void *xine) { this->got_spu_packet = metronom_got_spu_packet; this->handle_audio_discontinuity = metronom_handle_audio_discontinuity; this->handle_video_discontinuity = metronom_handle_video_discontinuity; - this->set_av_offset = metronom_set_av_offset; - this->get_av_offset = metronom_get_av_offset; + this->set_option = metronom_set_option; + this->get_option = metronom_get_option; this->start_clock = metronom_start_clock; this->stop_clock = metronom_stop_clock; this->resume_clock = metronom_resume_clock; @@ -640,6 +658,7 @@ metronom_t * metronom_init (int have_audio, void *xine) { this->set_speed = metronom_set_speed; this->exit = metronom_exit; + this->scr_adjustable = 1; this->scr_list = calloc(MAX_SCR_PROVIDERS, sizeof(void*)); this->register_scr(this, unixscr_init()); diff --git a/src/xine-engine/metronom.h b/src/xine-engine/metronom.h index edddd2061..4f7d9ebb7 100644 --- a/src/xine-engine/metronom.h +++ b/src/xine-engine/metronom.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: metronom.h,v 1.24 2002/03/23 13:28:36 miguelfreitas Exp $ + * $Id: metronom.h,v 1.25 2002/03/23 18:56:56 guenter Exp $ * * metronom: general pts => virtual calculation/assoc * @@ -144,12 +144,10 @@ struct metronom_s { void (*handle_video_discontinuity) (metronom_t *this, int type, int64_t disc_off); /* - * manually correct audio <-> video sync - * (this constant value is added to video vpts) + * set/get options for metronom, constants see below */ - void (*set_av_offset) (metronom_t *this, int32_t pts); - - int32_t (*get_av_offset) (metronom_t *this); + void (*set_option) (metronom_t *this, int option, int64_t value); + int64_t (*get_option) (metronom_t *this, int option); /* * system clock reference (SCR) functions @@ -227,6 +225,7 @@ struct metronom_s { scr_plugin_t* scr_master; scr_plugin_t** scr_list; pthread_t sync_thread; + int scr_adjustable; pthread_mutex_t lock; @@ -242,6 +241,13 @@ struct metronom_s { metronom_t *metronom_init (int have_audio, void *xine); /* + * metronom options + */ + +#define METRONOM_SCR_ADJUSTABLE 1 +#define METRONOM_AV_OFFSET 2 + +/* * SCR (system clock reference) plugins */ diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index f69b944e8..2a8b6b071 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.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: xine.c,v 1.111 2002/03/18 19:34:17 guenter Exp $ + * $Id: xine.c,v 1.112 2002/03/23 18:56:56 guenter Exp $ * * top-level xine functions * @@ -664,11 +664,11 @@ int xine_check_version(int major, int minor, int sub) { */ void xine_set_av_offset (xine_t *this, int offset_pts) { - this->metronom->set_av_offset (this->metronom, offset_pts); + this->metronom->set_option (this->metronom, METRONOM_AV_OFFSET, offset_pts); } int xine_get_av_offset (xine_t *this) { - return this->metronom->get_av_offset (this->metronom); + return this->metronom->get_option (this->metronom, METRONOM_AV_OFFSET); } /* |