diff options
Diffstat (limited to 'src/input/librtsp')
-rw-r--r-- | src/input/librtsp/rtsp.c | 40 | ||||
-rw-r--r-- | src/input/librtsp/rtsp.h | 9 | ||||
-rw-r--r-- | src/input/librtsp/rtsp_session.c | 8 |
3 files changed, 47 insertions, 10 deletions
diff --git a/src/input/librtsp/rtsp.c b/src/input/librtsp/rtsp.c index b1f92ce6a..15cef3066 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.2 2002/12/14 00:02:31 holstsn Exp $ + * $Id: rtsp.c,v 1.3 2002/12/16 21:50:55 holstsn Exp $ * * a minimalistic implementation of rtsp protocol, * *not* RFC 2326 compilant yet. @@ -301,11 +301,17 @@ static void rtsp_put(rtsp_t *s, const char *string) { static int rtsp_get_code(const char *string) { char buf[4]; - int code; - - memcpy(buf, string+strlen(rtsp_protocol_version)+1, 3); - buf[3]=0; - code=atoi(buf); + int code=0; + + if (!strncmp(string, rtsp_protocol_version, strlen(rtsp_protocol_version))) + { + memcpy(buf, string+strlen(rtsp_protocol_version)+1, 3); + buf[3]=0; + code=atoi(buf); + } else if (!strncmp(string, "SET_PARAMETER",8)) + { + return RTSP_STATUS_SET_PARAMETER; + } if(code != 200) printf("librtsp: server responds: '%s'\n",string); @@ -367,8 +373,12 @@ static int rtsp_get_answers(rtsp_t *s) { if (!strncmp(answer,"Cseq:",5)) { sscanf(answer,"Cseq: %u",&answer_seq); if (s->cseq != answer_seq) { +#ifdef LOG printf("librtsp: warning: Cseq mismatch. got %u, assumed %u", answer_seq, s->cseq); - } +#endif + s->cseq=answer_seq; + } else + s->cseq++; } if (!strncmp(answer,"Server:",7)) { sscanf(answer,"Server: %s",s->buffer); @@ -397,13 +407,26 @@ static int rtsp_get_answers(rtsp_t *s) { } while (strlen(answer)!=0); *answer_ptr=NULL; - s->cseq++; rtsp_schedule_standard(s); return code; } /* + * send an ok message + */ + +int rtsp_send_ok(rtsp_t *s) { + char cseq[16]; + + rtsp_put(s, "RTSP/1.0 200 OK"); + sprintf(cseq,"CSeq: %u", s->cseq); + rtsp_put(s, cseq); + rtsp_put(s, ""); + +} + +/* * implementation of must-have rtsp requests; functions return * server status code. */ @@ -568,6 +591,7 @@ rtsp_t *rtsp_connect(const char *mrl, const char *user_agent) { s->host=NULL; s->port=554; /* rtsp standard port */ s->path=NULL; + s->mrl=NULL; s->mrl=strdup(mrl); s->server=NULL; diff --git a/src/input/librtsp/rtsp.h b/src/input/librtsp/rtsp.h index 346ef59af..02e838da6 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.1 2002/12/12 22:14:56 holstsn Exp $ + * $Id: rtsp.h,v 1.2 2002/12/16 21:50:55 holstsn Exp $ * * a minimalistic implementation of rtsp protocol, * *not* RFC 2326 compilant yet. @@ -35,6 +35,11 @@ #define uint8_t unsigned char #endif +/* some codes returned by rtsp_request_* functions */ + +#define RTSP_STATUS_SET_PARAMETER 10 +#define RTSP_STATUS_OK 200 + typedef struct rtsp_s rtsp_t; rtsp_t* rtsp_connect (const char *mrl, const char *user_agent); @@ -46,6 +51,8 @@ int rtsp_request_setparameter(rtsp_t *s, const char *what); int rtsp_request_play(rtsp_t *s, const char *what); int rtsp_request_tearoff(rtsp_t *s, const char *what); +int rtsp_send_ok(rtsp_t *s); + int rtsp_read_data(rtsp_t *s, char *buffer, unsigned int size); char* rtsp_search_answers(rtsp_t *s, const char *tag); diff --git a/src/input/librtsp/rtsp_session.c b/src/input/librtsp/rtsp_session.c index 3e51ac7a1..04302a7d2 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.3 2002/12/15 16:54:10 holstsn Exp $ + * $Id: rtsp_session.c,v 1.4 2002/12/16 21:50:55 holstsn Exp $ * * high level interface to rtsp servers. */ @@ -97,6 +97,12 @@ connect: rtsp_close(rtsp_session->s); free(server); goto connect; /* *shudder* i made a design mistake somewhere */ + } else + { + printf("rtsp_session: session can not be established.\n"); + rtsp_close(rtsp_session->s); + free(rtsp_session); + return NULL; } } |