From 4a5044fc04be69439139240180deb5e79d7d513c Mon Sep 17 00:00:00 2001 From: Guenter Bartsch Date: Sat, 23 Mar 2002 20:09:56 +0000 Subject: oops, forgotten files CVS patchset: 1621 CVS date: 2002/03/23 20:09:56 --- src/input/net_buf_ctrl.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++ src/input/net_buf_ctrl.h | 36 +++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 src/input/net_buf_ctrl.c create mode 100644 src/input/net_buf_ctrl.h diff --git a/src/input/net_buf_ctrl.c b/src/input/net_buf_ctrl.c new file mode 100644 index 000000000..49c41b296 --- /dev/null +++ b/src/input/net_buf_ctrl.c @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2000-2002 the xine project + * + * 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 + * 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 + * + * network buffering control + */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include "net_buf_ctrl.h" + +#define DEFAULT_LOW_WATER_MARK 2 +#define DEFAULT_HIGH_WATER_MARK 5 + +struct nbc_s { + + xine_t *xine; + + int buffering; + int low_water_mark; + int high_water_mark; + +}; + +void nbc_check_buffers (nbc_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, + "net_buf_ctl: buffering (%d/%d)...\n", fifo_fill, this->high_water_mark); + } + + if (fifo_filllow_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, "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->metronom->set_option (this->xine->metronom, METRONOM_SCR_ADJUSTABLE, 0); + this->xine->audio_out->audio_paused = 2; + this->buffering = 1; + + } else if ( (fifo_fill>this->high_water_mark) && (this->buffering)) { + this->xine->metronom->set_speed (this->xine->metronom, SPEED_NORMAL); + this->xine->metronom->set_option (this->xine->metronom, METRONOM_SCR_ADJUSTABLE, 1); + this->xine->audio_out->audio_paused = 0; + this->buffering = 0; + + this->xine->osd_renderer->hide (this->xine->osd, 0); + } + +} + +void nbc_close (nbc_t *this) { + this->xine->metronom->set_option (this->xine->metronom, METRONOM_SCR_ADJUSTABLE, 1); + free (this); +} + +nbc_t *nbc_init (xine_t *xine) { + + nbc_t *this = (nbc_t *) malloc (sizeof (nbc_t)); + + this->xine = xine; + this->buffering = 0; + this->low_water_mark = DEFAULT_LOW_WATER_MARK; + this->high_water_mark = DEFAULT_HIGH_WATER_MARK; + + return this; +} + diff --git a/src/input/net_buf_ctrl.h b/src/input/net_buf_ctrl.h new file mode 100644 index 000000000..32347a2ab --- /dev/null +++ b/src/input/net_buf_ctrl.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2000-2002 the xine project + * + * 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 + * 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 + * + * network buffering control + */ + +#ifndef HAVE_NET_BUF_CTRL_H +#define HAVE_NET_BUF_CTRL_H + +#include "xine_internal.h" + +typedef struct nbc_s nbc_t; + +nbc_t *nbc_init (xine_t *xine); + +void nbc_check_buffers (nbc_t *this); + +void nbc_close (nbc_t *this); + +#endif -- cgit v1.2.3