diff libmpdemux/network.c @ 10199:0c72c1d0d6a4

Fix redirection in real rtsp connections. Patch by yepyep (sdpplin.c part not committed)
author rtognimp
date Wed, 28 May 2003 21:40:53 +0000
parents 92adc6f5c00c
children 35e306346e59
line wrap: on
line diff
--- a/libmpdemux/network.c	Tue May 27 19:58:28 2003 +0000
+++ b/libmpdemux/network.c	Wed May 28 21:40:53 2003 +0000
@@ -912,8 +912,15 @@
 	rtsp_session_t *rtsp;
 	char *mrl;
 	int port;
+	int redirected, temp;
 	char aport[10];
 	if( stream==NULL ) return -1;
+	
+	temp = 5; // counter so we don't get caught in infinite redirections (you never know)
+	
+	do {
+	
+	redirected = 0;
 
 	fd = connect2Server( stream->streaming_ctrl->url->hostname,
 		port = (stream->streaming_ctrl->url->port ? stream->streaming_ctrl->url->port : 554) );
@@ -925,9 +932,20 @@
 	strcpy(mrl,stream->streaming_ctrl->url->url);
 	strcat(mrl,":");
 	strcat(mrl,aport);
-	rtsp = rtsp_session_start(fd,mrl, stream->streaming_ctrl->url->file,
-		stream->streaming_ctrl->url->hostname, port);
+	rtsp = rtsp_session_start(fd,&mrl, stream->streaming_ctrl->url->file,
+		stream->streaming_ctrl->url->hostname, port, &redirected);
+
+	if ( redirected == 1 ) {
+		url_free(stream->streaming_ctrl->url);
+		stream->streaming_ctrl->url = url_new(mrl);
+		close(fd);
+	}
+
 	free(mrl);
+	temp--;
+
+	} while( (redirected != 0) && (temp > 0) );	
+
 	if(!rtsp) return -1;
 
 	stream->fd=fd;