summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2002-04-28 15:33:06 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2002-04-28 15:33:06 +0000
commit17b3df83ade38db78800028474a36b42822f09ee (patch)
tree04c4be703e207c75f294fab10ed6568e9dad7b25
parent2f8c9ba5832fccd79bc950a66ab7f08f0d037d80 (diff)
downloadxine-lib-17b3df83ade38db78800028474a36b42822f09ee.tar.gz
xine-lib-17b3df83ade38db78800028474a36b42822f09ee.tar.bz2
mms cleanup, removing asx parser (will be moved to xine-util/frontends
CVS patchset: 1797 CVS date: 2002/04/28 15:33:06
-rw-r--r--src/input/Makefile.am2
-rw-r--r--src/input/asxparser.c261
-rw-r--r--src/input/input_mms.c59
-rw-r--r--src/input/mms.c48
-rw-r--r--src/input/mms.h29
5 files changed, 40 insertions, 359 deletions
diff --git a/src/input/Makefile.am b/src/input/Makefile.am
index 03c5c2e71..1ba11e519 100644
--- a/src/input/Makefile.am
+++ b/src/input/Makefile.am
@@ -34,7 +34,7 @@ xineplug_inp_net_la_SOURCES = input_net.c net_buf_ctrl.c
xineplug_inp_net_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
xineplug_inp_net_la_LDFLAGS = -avoid-version -module
-xineplug_inp_mms_la_SOURCES = input_mms.c net_buf_ctrl.c mms.c asxparser.c
+xineplug_inp_mms_la_SOURCES = input_mms.c net_buf_ctrl.c mms.c
xineplug_inp_mms_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
xineplug_inp_mms_la_LDFLAGS = -avoid-version -module
diff --git a/src/input/asxparser.c b/src/input/asxparser.c
deleted file mode 100644
index ea58b857d..000000000
--- a/src/input/asxparser.c
+++ /dev/null
@@ -1,261 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <errno.h>
-#include "mms.h"
-
-
-extern char *mms_url_s[];
-extern char *mms_url_e[];
-
-void asx_find_entries(char* buff,char *url, char** fname,
- int *IsNotFinished )
-{
- int res;
- int delta;
- int delta1=0;
- char *ptr;
- char* ptre=NULL;
- char* ptre1=NULL;
-
-
-
- delta=mms_start_where(buff);
- if(delta < 0)
- return ;
-
- ptr=buff+delta;
- if(!strncasecmp(ptr,"HREF",4)){
- char* lastsl;
- lastsl=(char*)strchr(ptr,'/');
- if(lastsl)
- ptr=lastsl;
- lastsl=(char*)strrchr(url,'/');
- if(lastsl)
- delta1=lastsl-url;
- }
- ptre1=(char*)strstr(ptr, "#");
- if (!ptre1)
- ptre1=(char*)strstr(ptr, "?");
- if (!ptre)
- ptre=(char*)strstr(ptr, "\"/>");
- if (!ptre)
- ptre=(char*)strstr(ptr, "\" ");
- if (!ptre)
- ptre=(char*)strstr(ptr, "\"\t");
- if (!ptre)
- ptre=(char*)strstr(ptr, "\"\n");
- if (!ptre)
- ptre=(char*)strstr(ptr, "\t");
- if (!ptre)
- ptre=(char*)strstr(ptr, "\r");
- if (!ptre)
- ptre=(char*)strstr(ptr, "\n");
- if (!ptre)
- ptre=(char*)strstr(ptr, " ");
-
- if( ((ptre > ptre1) && ptre1) || (!ptre && ptre1) )
- ptre=ptre1;
-
- if(!ptre){
- char *ptr1;
-
- ptr1=(char*)strrchr(ptr,'.');
-
- if(!ptr1)
- goto cont;
-
-
- if (!mms_url_is(ptr1+1, mms_url_e)) {
-
- }
- else
- ptre=ptr1+4;
-
-
-
- }
- cont:
- printf("TEST 1 \n");
- if (!ptre)
- return ;
-
- printf("TEST 2 \n");
- res=(int)(ptre-ptr);
- if(res<=0)
- return ;
- if ( !delta1 ){
- (*fname)=(char*)realloc((*fname),res+2);
- memcpy(*fname,ptr,res);
- (*fname)[res]=0;
- }
- else{
- (*fname)=(char*)realloc((*fname),res+2+delta1+1);
- memcpy(*fname,url,delta1+1);
- memcpy(*fname+delta1,ptr,res+2);
- (*fname)[res+delta1+1]=0;
- }
-
- printf("asxparser path is %s \n", *fname);
- return ;
-}
-void first_request(char* buff,char* host, char* file,int *len)
-{
- char *ptr;
-
- bzero(buff,*len);
- ptr=buff;
- ptr+=sprintf(ptr,"GET %s HTTP/1.0\r\n",file);
- ptr+=sprintf(ptr,"Accept: */*\r\n");
- ptr+=sprintf(ptr,"User-Agent: NSPlayer/7.0.0.1956\r\n");
- ptr+=sprintf(ptr,"Host: %s\r\n", host);
- ptr+=sprintf(ptr,"Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=0:0,request-context=1,max-duration=0\r\n");
- ptr+=sprintf(ptr,"Pragma: xClientGUID=%s\r\n", "{33715801-BAB3-9D85-24E9-03B90328270A}");
-
- ptr+=sprintf(ptr,"Connection: Keep-Alive\r\n\r\n");
-
- *len =(int)ptr-(int)buff;
-}
-
-int mms_read_nb (int d, char *buf, int blen)
-{
- int ret;
- int aread=0;
-
- fcntl (d, F_SETFL, O_NONBLOCK);
-
- while (aread < blen){
- ret = read (d, buf+aread, blen - aread);
- /* printf ("ret =%d aread =%d \n",ret, aread); */
-
- if (ret==-1) {
- if (errno==EAGAIN){
- continue;
- }
- fcntl (d, F_SETFL, ~O_NONBLOCK);
- return -1;
- }
- aread+=ret;
- if ( ret >0 )
- continue;
- if (!ret ){
- fcntl (d, F_SETFL, ~O_NONBLOCK);
- /* printf ("aread = %d \n", aread); */
- return aread;
- }
- }
- fcntl (d, F_SETFL, ~O_NONBLOCK);
- return aread;
-}
-
-int asx_parse (char* fname, char** rname)
-{
- char* ptr=NULL;
- char buff[10000];
- int res;
- int IsNotFinished=0;
- char *url, *host=NULL, *hostend=NULL;
- char buff1[10000];
- int s ,l;
- char notyetconnected=1;
-
- printf ("in asxparser \n");
- if(!fname)
- return 1;
-
- ptr=(char*)strrchr(fname,'.');
-
- if(!ptr)
- return 1;
-
-
- if( mms_start_where(fname) < 0 ){
- FILE *fp;
- /* probably it is asx file on the disk*/
- fp=fopen(fname,"r");
- if(!fp)
- return 1;
- fread(buff,sizeof(buff),1,fp);
- fclose(fp);
- printf ("asxparser: buff =%s \n",buff );
- goto proc;
- }
-
- strncpy(buff1,fname,sizeof(buff1));
- /* extract hostname/test/connect */
- conn:
-
- url=mms_connect_common(&s,80,buff1,&host,&hostend,NULL,NULL);
- if(!url)
- return 1;
-
- printf("asxparser: connect passed \n");
-
- notyetconnected=0;
- l=sizeof(buff);
- first_request(buff, host,hostend, &l);
- write(s,buff,l);
-
- res=mms_read_nb(s,buff, sizeof(buff));
- printf("asxparser: answer1=::%s:: \n %d byte received \n",buff,res);
-
- /*
- if(mms_start_where(buff) < 0){
- l=sizeof(buff);
- second_request(buff, host,hostend, &l);
- write(s,buff,l);
-
- res=read(s,buff, sizeof(buff));
- printf("asxparser: answer2=%s %d byte received\n",buff,res);
-}
-
- */
- close(s);
-
- free(host);
-
-
- if(res<1){
- char *ext;
-
- ext=strrchr(buff1,'.');
-
- if(mms_url_is(buff1,mms_url_s)
- && ext && mms_url_is(ext+1, mms_url_e)){
- printf("asxparser: using url received from browser \n");
- return 0;
- }
- printf("asxparser: no success fname=%s ext=%s \n",fname,ext);
- return 1;
- }
-
-
- proc:
- asx_find_entries(buff,fname,rname,&IsNotFinished);
- if(notyetconnected && *rname){
- strncpy(buff1,*rname,sizeof(buff1));
- goto conn;
- }
- printf("asx_parser passed \n");
- return 0;
-
-}
-
-
-char *strupr(char *string)
-{
- char *s;
-
- if (string)
- {
- for (s = string; *s; ++s)
- *s = toupper(*s);
- }
- return string;
-}
-
diff --git a/src/input/input_mms.c b/src/input/input_mms.c
index 16caaaae9..969d534b6 100644
--- a/src/input/input_mms.c
+++ b/src/input/input_mms.c
@@ -1,14 +1,14 @@
-/*
- * Copyright (C) 2000-2001 major mms
+/*
+ * Copyright (C) 2002 the xine project
*
- * This file is part of xine-mms
+ * This file is part of xine, a free video player.
*
- * xine-mms is free software; you can redistribute it and/or modify
+ * 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-mms is distributed in the hope that it will be useful,
+ * 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.
@@ -17,7 +17,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * input plugin for mms network streams
+ * $Id: input_mms.c,v 1.11 2002/04/28 15:33:06 guenter Exp $
+ *
+ * mms input plugin based on work from major mms
*/
#ifdef HAVE_CONFIG_H
@@ -50,9 +52,6 @@ extern int errno;
#define FNDELAY O_NDELAY
#endif
-#define DEFAULT_LOW_WATER_MARK 1
-#define DEFAULT_HIGH_WATER_MARK 5
-
typedef struct {
input_plugin_t input_plugin;
@@ -71,51 +70,19 @@ typedef struct {
} mms_input_plugin_t;
-extern char *mms_url_s[];
-extern char *mms_url_e[];
static int mms_plugin_open (input_plugin_t *this_gen, char *mrl) {
- char* nmrl=NULL;
- char* uptr;
- int error_id;
-
mms_input_plugin_t *this = (mms_input_plugin_t *) this_gen;
-
- if (strncmp (mrl, "mms://", 6)) {
- error_id=asx_parse(mrl,&nmrl);
-
- if(error_id)
- return 0;
- }
-
- if(!nmrl)
- nmrl=mrl;
-
- printf("mms_plugin_open: using mrl <%s> \n", nmrl);
-
- uptr=strdup(nmrl);
- if (!mms_url_is(nmrl,mms_url_s)){
-
- return 0;
- }
-
-
- this->mrl = strdup(nmrl); /* FIXME: small memory leak */
- 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: contacting...", OSD_TEXT1);
- this->xine->osd_renderer->show (this->xine->osd, 0);
+ printf ("input_mms: trying to open '%s'\n", mrl);
- this->mms = mms_connect (nmrl);
+ this->mms = mms_connect (mrl);
- this->xine->osd_renderer->hide (this->xine->osd, 0);
-
- if (!this->mms){
-
+ if (!this->mms)
return 0;
- }
-
+
+ this->mrl = strdup(mrl); /* FIXME: small memory leak */
this->curpos = 0;
this->nbc = nbc_init (this->xine);
return 1;
diff --git a/src/input/mms.c b/src/input/mms.c
index 16db5b162..d1ae8558d 100644
--- a/src/input/mms.c
+++ b/src/input/mms.c
@@ -1,14 +1,14 @@
-/*
- * Copyright (C) 2000-2001 major mms
+/*
+ * Copyright (C) 2002 the xine project
*
- * This file is part of libmms
+ * This file is part of xine, a free video player.
*
- * libmms is free software; you can redistribute it and/or modify
+ * 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.
*
- * libmms is distributed in the hope that it will be useful,
+ * 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.
@@ -17,6 +17,9 @@
* 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.5 2002/04/28 15:33:06 guenter Exp $
+ *
+ * based on work from major mms
* utility functions to handle communication with an mms server
*/
@@ -55,9 +58,6 @@
#define CMD_HEADER_LEN 48
#define CMD_BODY_LEN 1024
-char *mms_url_s[]={"MMS://","MMSU://","MMST://","HTTP://", "HREF",NULL};
-char *mms_url_e[]={"ASF","WMF","WMV","WMA",NULL};
-
struct mms_s {
int s;
@@ -510,12 +510,12 @@ static void interp_header (mms_t *this) {
}
}
+char *mms_url_s[]={"MMS://","MMSU://","MMST://", NULL};
-int mms_url_is(char* url, char** mms_url) {
+static int mms_valid_url (char* url, char** mms_url) {
int i=0;
int len;
- printf("libmms: mms_url_is l=%d \n",strlen(mms_url[0]));
if(!url )
return 0;
@@ -529,28 +529,6 @@ int mms_url_is(char* url, char** mms_url) {
return 0;
}
-int mms_start_where(char* url) {
- int i=0;
- int delta;
- char *p;
- char* uptr;
-
- if (!url)
- return -1;
- uptr=strdup(url);
- uptr=strupr(uptr);
- while(mms_url_s[i]){
- if((p=strstr(uptr,mms_url_s[i]))){
- delta=p-uptr;
- free(uptr);
- return delta;
- }
- i++;
- }
- free(uptr);
- return -1;
-}
-
char* mms_connect_common(int *s, int port, char *url, char **host, char** hostend,
char **path, char **file) {
@@ -558,15 +536,13 @@ char* mms_connect_common(int *s, int port, char *url, char **host, char** hosten
int proto_len;
char *forport;
- if(!(proto_len=mms_url_is(url,mms_url_s))){
+ if (!(proto_len=mms_valid_url(url,mms_url_s))){
- printf ("libmms: invalid url >%s< (should be mms:// http:// - style)\n", url);
+ printf ("libmms: invalid url >%s< (should be mms:// - style)\n", url);
return NULL;
}
-
-
/* extract hostname */
printf ("libmms: extracting host name \n");
diff --git a/src/input/mms.h b/src/input/mms.h
index 31f5ab0f7..c7a7e6233 100644
--- a/src/input/mms.h
+++ b/src/input/mms.h
@@ -1,14 +1,14 @@
-/*
- * Copyright (C) 2000-2001 major mms
+/*
+ * Copyright (C) 2002 the xine project
*
- * This file is part of libmms
+ * This file is part of xine, a free video player.
*
- * xine-mms is free software; you can redistribute it and/or modify
+ * 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-mms is distributed in the hope that it will be useful,
+ * 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.
@@ -17,6 +17,8 @@
* 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.4 2002/04/28 15:33:06 guenter Exp $
+ *
* libmms public header
*/
@@ -27,19 +29,16 @@
typedef struct mms_s mms_t;
-char *strupr(char *string);
-int asx_parse (char* fname, char** rname);
-int mms_start_where(char* url);
-int mms_url_is(char* url, char** mms_url);
-char* mms_connect_common(int *s ,int port,char *url, char **host , char** hostend,
- char **path,char **file);
-mms_t *mms_connect (char *url);
+char* strupr(char *string);
+char* mms_connect_common(int *s ,int port,char *url, char **host , char** hostend,
+ char **path,char **file);
+mms_t* mms_connect (char *url);
-int mms_read (mms_t *this, char *data, int len);
+int mms_read (mms_t *this, char *data, int len);
uint32_t mms_get_length (mms_t *this);
-void mms_close (mms_t *this);
+void mms_close (mms_t *this);
-int mms_peek_header (mms_t *this, char *data);
+int mms_peek_header (mms_t *this, char *data);
#endif