diff options
-rw-r--r-- | src/input/librtsp/rtsp.c | 33 | ||||
-rw-r--r-- | src/input/librtsp/rtsp.h | 6 | ||||
-rw-r--r-- | src/input/librtsp/rtsp_session.c | 6 | ||||
-rw-r--r-- | src/input/librtsp/rtsp_session.h | 4 |
4 files changed, 29 insertions, 20 deletions
diff --git a/src/input/librtsp/rtsp.c b/src/input/librtsp/rtsp.c index 1bdfcef2d..89d693b7c 100644 --- a/src/input/librtsp/rtsp.c +++ b/src/input/librtsp/rtsp.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: rtsp.c,v 1.9 2003/04/10 02:30:48 miguelfreitas Exp $ + * $Id: rtsp.c,v 1.10 2003/04/13 19:02:07 miguelfreitas Exp $ * * a minimalistic implementation of rtsp protocol, * *not* RFC 2326 compilant yet. @@ -50,6 +50,8 @@ struct rtsp_s { + xine_stream_t *stream; + int s; char *host; @@ -169,15 +171,16 @@ static int write_stream(int s, const char *buf, int len) { return total; } -static ssize_t read_stream(int fd, void *buf, size_t count) { - +static ssize_t read_stream(rtsp_t *s, void *buf, size_t count) { + +#if 0 ssize_t ret, total; total = 0; while (total < count) { - ret=read (fd, ((uint8_t*)buf)+total, count-total); + ret=read (s->s, ((uint8_t*)buf)+total, count-total); if (ret<0) { if(errno == EAGAIN) { @@ -185,12 +188,12 @@ static ssize_t read_stream(int fd, void *buf, size_t count) { struct timeval timeout; FD_ZERO (&rset); - FD_SET (fd, &rset); + FD_SET (s->s, &rset); timeout.tv_sec = 30; timeout.tv_usec = 0; - if (select (fd+1, &rset, NULL, NULL, &timeout) <= 0) { + if (select (s->s+1, &rset, NULL, NULL, &timeout) <= 0) { return -1; } continue; @@ -206,6 +209,11 @@ static ssize_t read_stream(int fd, void *buf, size_t count) { } return total; +#else + + return xine_read_abort(s->stream, s->s, buf, count ); + +#endif } /* @@ -255,7 +263,7 @@ static char *rtsp_get(rtsp_t *s) { char *string; while (n<BUF_SIZE) { - read_stream(s->s, &s->buffer[n], 1); + read_stream(s, &s->buffer[n], 1); if ((s->buffer[n-1]==0x0d)&&(s->buffer[n]==0x0a)) break; n++; } @@ -531,7 +539,7 @@ int rtsp_read_data(rtsp_t *s, char *buffer, unsigned int size) { int i,seq; if (size>=4) { - i=read_stream(s->s, buffer, 4); + i=read_stream(s, buffer, 4); if (i<4) return i; if ((buffer[0]=='S')&&(buffer[1]=='E')&&(buffer[2]=='T')&&(buffer[3]=='_')) { @@ -559,14 +567,14 @@ int rtsp_read_data(rtsp_t *s, char *buffer, unsigned int size) { sprintf(rest,"CSeq: %u", seq); rtsp_put(s, rest); rtsp_put(s, ""); - i=read_stream(s->s, buffer, size); + i=read_stream(s, buffer, size); } else { - i=read_stream(s->s, buffer+4, size-4); + i=read_stream(s, buffer+4, size-4); i+=4; } } else - i=read_stream(s->s, buffer, size); + i=read_stream(s, buffer, size); #ifdef LOG printf("librtsp: << %d of %d bytes\n", i, size); #endif @@ -578,7 +586,7 @@ int rtsp_read_data(rtsp_t *s, char *buffer, unsigned int size) { * connect to a rtsp server */ -rtsp_t *rtsp_connect(const char *mrl, const char *user_agent) { +rtsp_t *rtsp_connect(xine_stream_t *stream, const char *mrl, const char *user_agent) { rtsp_t *s=malloc(sizeof(rtsp_t)); char *mrl_ptr=strdup(mrl); @@ -599,6 +607,7 @@ rtsp_t *rtsp_connect(const char *mrl, const char *user_agent) { s->scheduled[i]=NULL; } + s->stream=stream; s->host=NULL; s->port=554; /* rtsp standard port */ s->path=NULL; diff --git a/src/input/librtsp/rtsp.h b/src/input/librtsp/rtsp.h index 02e838da6..d970602cd 100644 --- a/src/input/librtsp/rtsp.h +++ b/src/input/librtsp/rtsp.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: rtsp.h,v 1.2 2002/12/16 21:50:55 holstsn Exp $ + * $Id: rtsp.h,v 1.3 2003/04/13 19:02:07 miguelfreitas Exp $ * * a minimalistic implementation of rtsp protocol, * *not* RFC 2326 compilant yet. @@ -27,7 +27,7 @@ #define HAVE_RTSP_H /*#include <inttypes.h> */ -/*#include "xine_internal.h" */ +#include "xine_internal.h" #ifdef __CYGWIN__ #define uint32_t unsigned int @@ -42,7 +42,7 @@ typedef struct rtsp_s rtsp_t; -rtsp_t* rtsp_connect (const char *mrl, const char *user_agent); +rtsp_t* rtsp_connect (xine_stream_t *stream, const char *mrl, const char *user_agent); int rtsp_request_options(rtsp_t *s, const char *what); int rtsp_request_describe(rtsp_t *s, const char *what); diff --git a/src/input/librtsp/rtsp_session.c b/src/input/librtsp/rtsp_session.c index d78f0d12c..b051fb7fb 100644 --- a/src/input/librtsp/rtsp_session.c +++ b/src/input/librtsp/rtsp_session.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: rtsp_session.c,v 1.9 2003/02/11 16:20:40 heikos Exp $ + * $Id: rtsp_session.c,v 1.10 2003/04/13 19:02:08 miguelfreitas Exp $ * * high level interface to rtsp servers. */ @@ -61,7 +61,7 @@ struct rtsp_session_s { }; -rtsp_session_t *rtsp_session_start(char *mrl) { +rtsp_session_t *rtsp_session_start(xine_stream_t *stream, char *mrl) { rtsp_session_t *rtsp_session=malloc(sizeof(rtsp_session_t)); char *server; @@ -72,7 +72,7 @@ rtsp_session_t *rtsp_session_start(char *mrl) { connect: /* connect to server */ - rtsp_session->s=rtsp_connect(mrl_line,NULL); + rtsp_session->s=rtsp_connect(stream, mrl_line,NULL); if (!rtsp_session->s) { printf("rtsp_session: failed to connect to server %s\n", mrl_line); diff --git a/src/input/librtsp/rtsp_session.h b/src/input/librtsp/rtsp_session.h index c287118e3..156030625 100644 --- a/src/input/librtsp/rtsp_session.h +++ b/src/input/librtsp/rtsp_session.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: rtsp_session.h,v 1.4 2003/01/31 14:06:18 miguelfreitas Exp $ + * $Id: rtsp_session.h,v 1.5 2003/04/13 19:02:08 miguelfreitas Exp $ * * high level interface to rtsp servers. */ @@ -27,7 +27,7 @@ typedef struct rtsp_session_s rtsp_session_t; -rtsp_session_t *rtsp_session_start(char *mrl); +rtsp_session_t *rtsp_session_start(xine_stream_t *stream, char *mrl); int rtsp_session_read(rtsp_session_t *session, char *data, int len); |