diff options
-rw-r--r-- | src/input/input_rtsp.c | 14 | ||||
-rw-r--r-- | src/input/libreal/real.c | 28 | ||||
-rw-r--r-- | src/input/librtsp/rtsp.c | 4 | ||||
-rw-r--r-- | src/input/librtsp/rtsp_session.c | 22 |
4 files changed, 51 insertions, 17 deletions
diff --git a/src/input/input_rtsp.c b/src/input/input_rtsp.c index ad483bde8..2accc1515 100644 --- a/src/input/input_rtsp.c +++ b/src/input/input_rtsp.c @@ -68,6 +68,7 @@ typedef struct { rtsp_session_t *rtsp; char *mrl; + char *public_mrl; off_t curpos; @@ -187,13 +188,16 @@ static void rtsp_plugin_dispose (input_plugin_t *this_gen) { if(this->mrl) free(this->mrl); + if(this->public_mrl) + free(this->public_mrl); + free (this); } static char* rtsp_plugin_get_mrl (input_plugin_t *this_gen) { rtsp_input_plugin_t *this = (rtsp_input_plugin_t *) this_gen; - return this->mrl; + return this->public_mrl; } static int rtsp_plugin_get_optional_data (input_plugin_t *this_gen, @@ -230,7 +234,13 @@ static input_plugin_t *open_plugin (input_class_t *cls_gen, xine_stream_t *strea this = (rtsp_input_plugin_t *) xine_xmalloc (sizeof (rtsp_input_plugin_t)); this->rtsp = rtsp; - this->mrl = mrl; + this->mrl = mrl; + /* since we handle only real streams yet, we can savely add + * an .rm extention to force handling by demux_real. + */ + this->public_mrl = xine_xmalloc (sizeof (char)*(strlen(this->mrl)+10)); + sprintf(this->public_mrl, "%s.rm", this->mrl); + this->nbc = nbc_init (stream); this->input_plugin.get_capabilities = rtsp_plugin_get_capabilities; diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c index 344526864..908629316 100644 --- a/src/input/libreal/real.c +++ b/src/input/libreal/real.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: real.c,v 1.1 2002/12/12 22:14:55 holstsn Exp $ + * $Id: real.c,v 1.2 2002/12/14 00:02:31 holstsn Exp $ * * special functions for real streams. * adopted from joschkas real tools. @@ -880,6 +880,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwid char buf[256]; char *mrl=rtsp_get_mrl(rtsp_session); unsigned int size; + int status; /* get challenge */ challenge1=strdup(rtsp_search_answers(rtsp_session,"RealChallenge1")); @@ -892,10 +893,16 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwid sprintf(buf, "Bandwidth: %u", bandwidth); rtsp_schedule_field(rtsp_session, buf); rtsp_schedule_field(rtsp_session, "Require: com.real.retain-entity-for-setup"); - rtsp_request_describe(rtsp_session,NULL); + status=rtsp_request_describe(rtsp_session,NULL); + + if (status != 200) return NULL; /* receive description */ - size=atoi(rtsp_search_answers(rtsp_session,"Content-length")); + size=0; + if (!rtsp_search_answers(rtsp_session,"Content-length")) + printf("real: got no Content-length!\n"); + else + size=atoi(rtsp_search_answers(rtsp_session,"Content-length")); if (!rtsp_search_answers(rtsp_session,"ETag")) printf("real: got no ETag!\n"); @@ -921,7 +928,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwid h->cont->title, h->cont->copyright, h->cont->author, h->prop->num_streams); #endif - /* setup our 2 streams */ + /* setup our streams */ real_calc_response_and_checksum (challenge2, checksum, challenge1); sprintf(buf, "RealChallenge2: %s, sd=%s", challenge2, checksum); rtsp_schedule_field(rtsp_session, buf); @@ -930,14 +937,15 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwid rtsp_schedule_field(rtsp_session, "Transport: x-pn-tng/tcp;mode=play,rtp/avp/tcp;unicast;mode=play"); sprintf(buf, "%s/streamid=0", mrl); rtsp_request_setup(rtsp_session,buf); - - rtsp_schedule_field(rtsp_session, "Transport: x-pn-tng/tcp;mode=play,rtp/avp/tcp;unicast;mode=play"); - sprintf(buf, "If-Match: %s", session_id); - rtsp_schedule_field(rtsp_session, buf); - sprintf(buf, "%s/streamid=1", mrl); - rtsp_request_setup(rtsp_session,buf); + if (h->prop->num_streams > 1) { + rtsp_schedule_field(rtsp_session, "Transport: x-pn-tng/tcp;mode=play,rtp/avp/tcp;unicast;mode=play"); + sprintf(buf, "If-Match: %s", session_id); + rtsp_schedule_field(rtsp_session, buf); + sprintf(buf, "%s/streamid=1", mrl); + rtsp_request_setup(rtsp_session,buf); + } /* set stream parameter (bandwidth) with our subscribe string */ rtsp_schedule_field(rtsp_session, subscribe); rtsp_request_setparameter(rtsp_session,NULL); diff --git a/src/input/librtsp/rtsp.c b/src/input/librtsp/rtsp.c index f851de9c4..b1f92ce6a 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.1 2002/12/12 22:14:55 holstsn Exp $ + * $Id: rtsp.c,v 1.2 2002/12/14 00:02:31 holstsn Exp $ * * a minimalistic implementation of rtsp protocol, * *not* RFC 2326 compilant yet. @@ -654,7 +654,7 @@ char *rtsp_search_answers(rtsp_t *s, const char *tag) { answer=s->answers; while (*answer) { - if (!strncmp(*answer,tag,strlen(tag))) { + if (!strncasecmp(*answer,tag,strlen(tag))) { ptr=strchr(*answer,':'); ptr++; while(*ptr==' ') ptr++; diff --git a/src/input/librtsp/rtsp_session.c b/src/input/librtsp/rtsp_session.c index fb728bab9..b522c777f 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.1 2002/12/12 22:14:56 holstsn Exp $ + * $Id: rtsp_session.c,v 1.2 2002/12/14 00:02:31 holstsn Exp $ * * high level interface to rtsp servers. */ @@ -64,14 +64,17 @@ rtsp_session_t *rtsp_session_start(char *mrl) { rtsp_session_t *rtsp_session=malloc(sizeof(rtsp_session_t)); char *server; + char *mrl_line=strdup(mrl); rmff_header_t *h; uint32_t bandwidth=10485800; +connect: + /* connect to server */ - rtsp_session->s=rtsp_connect(mrl,NULL); + rtsp_session->s=rtsp_connect(mrl_line,NULL); if (!rtsp_session->s) { - printf("rtsp_session: failed to connect to server\n"); + printf("rtsp_session: failed to connect to server %s\n", mrl_line); free(rtsp_session); return NULL; } @@ -84,6 +87,19 @@ rtsp_session_t *rtsp_session_start(char *mrl) { /* we are talking to a real server ... */ h=real_setup_and_get_header(rtsp_session->s, bandwidth); + if (!h) { + /* got an redirect? */ + if (rtsp_search_answers(rtsp_session->s, "Location")) + { + free(mrl_line); + mrl_line=strdup(rtsp_search_answers(rtsp_session->s, "Location")); + printf("rtsp_session: redirected to %s\n", mrl_line); + rtsp_close(rtsp_session->s); + free(server); + goto connect; /* *shudder* i made a design mistake somewhere */ + } + } + rtsp_session->header_len=rmff_dump_header(h,rtsp_session->header,1024); memcpy(rtsp_session->recv, rtsp_session->header, rtsp_session->header_len); |