summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2002-01-10 21:42:50 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2002-01-10 21:42:50 +0000
commit8ad96f32c2c1602b1f9799025ce811fddb0067d1 (patch)
tree051d5dd44d132b3225bdf8046b29b25e25fcc8b2
parent57312d1a4a94e1e607466bc528cd578ffa31ed6f (diff)
downloadxine-lib-8ad96f32c2c1602b1f9799025ce811fddb0067d1.tar.gz
xine-lib-8ad96f32c2c1602b1f9799025ce811fddb0067d1.tar.bz2
more tcp streaming support, new scr plugin which cannot be pushed by audio out
CVS patchset: 1388 CVS date: 2002/01/10 21:42:50
-rw-r--r--src/input/Makefile.am4
-rw-r--r--src/input/input_net.c41
-rw-r--r--src/input/strict_scr.c142
-rw-r--r--src/input/strict_scr.h44
4 files changed, 226 insertions, 5 deletions
diff --git a/src/input/Makefile.am b/src/input/Makefile.am
index 752025027..b5ef1728f 100644
--- a/src/input/Makefile.am
+++ b/src/input/Makefile.am
@@ -30,7 +30,7 @@ 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
+xineplug_inp_net_la_SOURCES = input_net.c strict_scr.c
xineplug_inp_net_la_LDFLAGS = -avoid-version -module
xineplug_inp_vcd_la_SOURCES = input_vcd.c
@@ -49,7 +49,7 @@ 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
+noinst_HEADERS = dvd_udf.h read_cache.h strict_scr.h
EXTRA_DIST = input_dvd.c dvd_udf.c input_vcd.c read_cache.c
diff --git a/src/input/input_net.c b/src/input/input_net.c
index 545440644..107b9d18e 100644
--- a/src/input/input_net.c
+++ b/src/input/input_net.c
@@ -40,6 +40,7 @@
#include "xine_internal.h"
#include "xineutils.h"
#include "input_plugin.h"
+#include "strict_scr.h"
extern int errno;
@@ -83,6 +84,8 @@ typedef struct {
int buffering;
+ strictscr_t *scr;
+
} net_input_plugin_t;
/* **************************************************************** */
@@ -207,16 +210,43 @@ 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);
+
return 1;
}
-/*
- *
- */
+#define LOW_WATER_MARK 50
+#define HIGH_WATER_MARK 100
+
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;
+
+ fifo_fill = this->xine->video_fifo->size(this->xine->video_fifo);
+
+ if (fifo_fill<LOW_WATER_MARK) {
+
+ this->xine->metronom->set_speed (this->xine->metronom, SPEED_PAUSE);
+ this->buffering = 1;
+ this->scr->adjustable = 0;
+ printf ("input_net: buffering...\n");
+
+ } 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 ("input_net: buffering...done\n");
+ }
+
+ /*
+ printf ("input_net: read at pts %d\n",
+ this->xine->metronom->get_current_time (this->xine->metronom));
+ */
+ /*
if (this->curpos==0) {
this->xine->metronom->set_speed (this->xine->metronom, SPEED_PAUSE);
@@ -227,6 +257,7 @@ static off_t net_plugin_read (input_plugin_t *this_gen,
this->buffering = 0;
printf ("input_net: buffering...finished\n");
}
+*/
total=0;
while (total<len){
@@ -315,6 +346,8 @@ 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);
}
/*
@@ -404,6 +437,8 @@ input_plugin_t *init_input_plugin (int iface, xine_t *xine) {
this->config = config;
this->curpos = 0;
this->buffering = 0;
+
+ this->scr = strictscr_init ();
return (input_plugin_t *) this;
}
diff --git a/src/input/strict_scr.c b/src/input/strict_scr.c
new file mode 100644
index 000000000..ba045418e
--- /dev/null
+++ b/src/input/strict_scr.c
@@ -0,0 +1,142 @@
+/*
+ * 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.1 2002/01/10 21:42:50 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, uint32_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, uint32_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 uint32_t strictscr_get_current (scr_plugin_t *scr) {
+ strictscr_t *this = (strictscr_t*) scr;
+
+ struct timeval tv;
+ uint32_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
new file mode 100644
index 000000000..934060c4c
--- /dev/null
+++ b/src/input/strict_scr.h
@@ -0,0 +1,44 @@
+/*
+ * 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;
+ uint32_t cur_pts;
+ double speed_factor;
+
+ int adjustable;
+
+ pthread_mutex_t lock;
+
+} strictscr_t;
+
+strictscr_t* strictscr_init () ;
+
+#endif
+