changeset 12879:542d1d2200c1

reduced code complexity, and also made consistent with other parts
author alex
date Wed, 21 Jul 2004 10:18:29 +0000
parents ed7d73d336ad
children d3846c4e163c
files libmpdemux/asf_streaming.c
diffstat 1 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/asf_streaming.c	Wed Jul 21 10:10:32 2004 +0000
+++ b/libmpdemux/asf_streaming.c	Wed Jul 21 10:18:29 2004 +0000
@@ -47,22 +47,21 @@
 
 int
 asf_streaming_start( stream_t *stream, int *demuxer_type) {
-    char *proto_s = stream->streaming_ctrl->url->protocol;
-    int protolen = strlen(proto_s), fd = -1;
+    char *proto = stream->streaming_ctrl->url->protocol;
+    int fd = -1;
 
     // Is protocol even valid mms,mmsu,mmst,http,http_proxy?
-    if (!(
-        (protolen==4 && (!strcasecmp( proto_s, "mmst") || !strcasecmp (proto_s,"mmsu") ||
-        !strcasecmp( proto_s, "http"))) ||
-        (protolen==3 && !strcasecmp(proto_s,"mms")) ||
-        (protolen==10 && !strcasecmp(proto_s,"http_proxy"))
-        )) {
-        mp_msg(MSGT_NETWORK,MSGL_ERR,"Unknown protocol: %s\n", proto_s );
+    if (!(!strncasecmp(proto, "mmst", 4) || !strncasecmp(proto, "mmsu", 4) ||
+	!strncasecmp(proto, "http_proxy", 10) || !strncasecmp(proto, "mms", 3) ||
+	!strncasecmp(proto, "http", 4)))
+    {
+        mp_msg(MSGT_NETWORK,MSGL_ERR,"Unknown protocol: %s\n", proto );
         return -1;
     }
 
     // Is protocol mms or mmsu?
-    if ( protolen==3 || (protolen==4 &&  !strcasecmp( proto_s, "mmsu")) ) {
+    if (!strncasecmp(proto, "mmsu", 4) || !strncasecmp(proto, "mms", 3))
+    {
 		mp_msg(MSGT_NETWORK,MSGL_V,"Trying ASF/UDP...\n");
 		//fd = asf_mmsu_streaming_start( stream );
 		if( fd>-1 ) return fd; //mmsu support is not implemented yet - using this code
@@ -71,7 +70,8 @@
 	}
 
     //Is protocol mms or mmst?
-    if (protolen==3 ||  (protolen==4 && !strcasecmp( proto_s, "mmst")) ) {
+    if (!strncasecmp(proto, "mmst", 4) || !strncasecmp(proto, "mms", 3))
+    {
 		mp_msg(MSGT_NETWORK,MSGL_V,"Trying ASF/TCP...\n");
 		fd = asf_mmst_streaming_start( stream );
 		if( fd>-1 ) return fd;
@@ -80,7 +80,9 @@
 	}
 
     //Is protocol http, http_proxy, or mms? 
-    if  (protolen==10 || protolen==3 || (protolen==4 && !strcasecmp(proto_s,"http")) ) {
+    if (!strncasecmp(proto, "http_proxy", 10) || !strncasecmp(proto, "http", 4) ||
+	!strncasecmp(proto, "mms", 3))
+    {
 		mp_msg(MSGT_NETWORK,MSGL_V,"Trying ASF/HTTP...\n");
 		fd = asf_http_streaming_start( stream, demuxer_type );
 		if( fd>-1 ) return fd;