changeset 10171:92adc6f5c00c

Recognize ra and rm extensions even with query strings, eg: rstp://www.addr.com/file.rm?var=123 Based on an idea by Felix Buenemann
author rtognimp
date Fri, 23 May 2003 19:41:37 +0000
parents 2f9e8ff57e9e
children 3241b7ca2b2c
files libmpdemux/network.c
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/network.c	Fri May 23 17:39:33 2003 +0000
+++ b/libmpdemux/network.c	Fri May 23 19:41:37 2003 +0000
@@ -528,7 +528,7 @@
 int
 autodetectProtocol(streaming_ctrl_t *streaming_ctrl, int *fd_out, int *file_format) {
 	HTTP_header_t *http_hdr;
-	unsigned int i;
+	unsigned int i, j;
 	int fd=-1;
 	int redirect;
 	int auth_retry=0;
@@ -586,17 +586,28 @@
 			// Checking for Real rtsp://
 			// Extension based detection, should be replaced with something based on server answer
 			extension = NULL;
-			if( url->file!=NULL )
-				for( i=strlen(url->file) ; i>0 ; i-- )
+			if( url->file!=NULL ) {
+				j = strlen(url->file);
+				for( i=j; i>0 ; i-- ) {
+					if( url->file[i]=='?' )
+						j = i;
 					if( url->file[i]=='.' ) {
-						extension=(url->file)+i+1;
+						extension = calloc(j-i, 1);
+						for ( i++; i < j; i++)
+							extension[strlen(extension)]=url->file[i];
+						extension[strlen(extension)]=0;
 						break;
+					}
+				}
 			}
 			if (extension != NULL && (!strcasecmp(extension, "rm")
 			    || !strcasecmp(extension, "ra"))) {
 				*file_format = DEMUXER_TYPE_REAL;
+				free(extension);
 				return 0;
 			}
+			if (extension != NULL)
+				free(extension);
 			mp_msg(MSGT_NETWORK,MSGL_INFO,"Not a Realmedia rtsp url. Trying standard rtsp protocol.\n");
 #ifdef STREAMING_LIVE_DOT_COM
 			*file_format = DEMUXER_TYPE_RTP;