diff options
Diffstat (limited to 'src/input/input_net.c')
-rw-r--r-- | src/input/input_net.c | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/src/input/input_net.c b/src/input/input_net.c index a6c72f0dc..ee457df0d 100644 --- a/src/input/input_net.c +++ b/src/input/input_net.c @@ -20,7 +20,7 @@ * Read from a tcp network stream over a lan (put a tweaked mp1e encoder the * other end and you can watch tv anywhere in the house ..) * - * $Id: input_net.c,v 1.42 2003/01/31 14:06:13 miguelfreitas Exp $ + * $Id: input_net.c,v 1.43 2003/04/13 16:02:53 tmattern Exp $ * * how to set up mp1e for use with this plugin: * @@ -80,7 +80,7 @@ typedef struct { input_plugin_t input_plugin; - xine_stream_t *stream; + xine_stream_t *stream; int fh; char *mrl; @@ -298,9 +298,11 @@ static int net_plugin_get_optional_data (input_plugin_t *this_gen, static void net_plugin_dispose (input_plugin_t *this_gen ) { net_input_plugin_t *this = (net_input_plugin_t *) this_gen; - close(this->fh); - this->fh = -1; - + if (this->fh != -1) { + close(this->fh); + this->fh = -1; + } + free (this->mrl); if (this->nbc) { @@ -311,32 +313,13 @@ static void net_plugin_dispose (input_plugin_t *this_gen ) { free (this_gen); } - -static input_plugin_t *net_plugin_open (input_class_t *cls_gen, xine_stream_t *stream, const char *mrl) { - /* net_input_plugin_t *this = (net_input_plugin_t *) this_gen; */ - net_input_plugin_t *this = xine_xmalloc(sizeof(net_input_plugin_t)); +static int net_plugin_open (input_plugin_t *this_gen ) { + net_input_plugin_t *this = (net_input_plugin_t *) this_gen; char *filename; char *pptr; int port = 7658; - this->mrl = strdup(mrl); - this->stream = stream; - - if (!strncasecmp (mrl, "tcp://", 6)) { - filename = (char *) &this->mrl[6]; - - if((!filename) || (strlen(filename) == 0)) { - free (this->mrl); - free (this); - return NULL; - } - - } else { - free (this->mrl); - free (this); - return NULL; - } - + filename = (char *) &this->mrl[6]; pptr=strrchr(filename, ':'); if(pptr) { *pptr++ = 0; @@ -347,24 +330,44 @@ static input_plugin_t *net_plugin_open (input_class_t *cls_gen, xine_stream_t *s this->curpos = 0; if (this->fh == -1) { - free (this->mrl); - free (this); - return NULL; + return 0; } - this->nbc = nbc_init (this->stream); - /* * fill preview buffer */ - this->preview_pos = 0; - this->preview_size = 0; - this->preview_size = read (this->fh, this->preview, MAX_PREVIEW_SIZE); - this->preview_pos = 0; - this->curpos = 0; + this->curpos = 0; + + return 1; +} + +static input_plugin_t *net_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, const char *mrl) { + /* net_input_plugin_t *this = (net_input_plugin_t *) this_gen; */ + net_input_plugin_t *this; + char *filename; + + if (!strncasecmp (mrl, "tcp://", 6)) { + filename = (char *) &mrl[6]; + + if((!filename) || (strlen(filename) == 0)) { + return NULL; + } + } else { + return NULL; + } + this = xine_xmalloc(sizeof(net_input_plugin_t)); + this->mrl = strdup(mrl); + this->stream = stream; + this->fh = -1; + this->curpos = 0; + this->nbc = nbc_init (this->stream); + this->preview_pos = 0; + this->preview_size = 0; + + this->input_plugin.open = net_plugin_open; this->input_plugin.get_capabilities = net_plugin_get_capabilities; this->input_plugin.read = net_plugin_read; this->input_plugin.read_block = net_plugin_read_block; @@ -377,7 +380,6 @@ static input_plugin_t *net_plugin_open (input_class_t *cls_gen, xine_stream_t *s this->input_plugin.dispose = net_plugin_dispose; this->input_plugin.input_class = cls_gen; - return &this->input_plugin; } @@ -408,7 +410,7 @@ static void *init_class (xine_t *xine, void *data) { this->config = xine->config; this->xine = xine; - this->input_class.open_plugin = net_plugin_open; + this->input_class.get_instance = net_class_get_instance; this->input_class.get_description = net_class_get_description; this->input_class.get_identifier = net_class_get_identifier; this->input_class.get_dir = NULL; @@ -425,7 +427,7 @@ static void *init_class (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT, 11, "tcp", XINE_VERSION_CODE, NULL, init_class }, + { PLUGIN_INPUT, 12, "tcp", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; |