[Mplayer-cvslog] CVS: main/libmpdemux network.c,1.40,1.41

Atmosfear atmos4 at mplayerhq.hu
Sat Apr 27 22:42:05 CEST 2002


Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv20745/libmpdemux

Modified Files:
	network.c 
Log Message:
Add some info prints to ICY code and handle return codes ICY specific, also avoid printing
content length in http if no Content-Length field in header.


Index: network.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/network.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- network.c	27 Apr 2002 19:15:18 -0000	1.40
+++ network.c	27 Apr 2002 20:42:02 -0000	1.41
@@ -416,17 +416,45 @@
 			
 			// Check if the response is an ICY status_code reason_phrase
 			if( !strcasecmp(http_hdr->protocol, "ICY") ) {
-				// Ok, we have detected an mp3 streaming
-				*file_format = DEMUXER_TYPE_AUDIO;
+				switch( http_hdr->status_code ) {
+					case 200: { // OK
+						char *field_data = NULL;
+						// note: I skip icy-notice1 and 2, as they contain html <BR>
+						// and are IMHO useless info ::atmos
+						if( (field_data = http_get_field(http_hdr, "icy-name")) != NULL )
+							printf("Name   : %s\n", field_data); field_data = NULL;
+						if( (field_data = http_get_field(http_hdr, "icy-genre")) != NULL )
+							printf("Genre  : %s\n", field_data); field_data = NULL;
+						if( (field_data = http_get_field(http_hdr, "icy-url")) != NULL )
+							printf("Website: %s\n", field_data); field_data = NULL;
+						// XXX: does this really mean public server? ::atmos
+						if( (field_data = http_get_field(http_hdr, "icy-pub")) != NULL )
+							printf("Public : %s\n", atoi(field_data)?"yes":"no"); field_data = NULL;
+						if( (field_data = http_get_field(http_hdr, "icy-br")) != NULL )
+							printf("Bitrate: %skbit/s\n", field_data); field_data = NULL;
+						// Ok, we have detected an mp3 stream
+						*file_format = DEMUXER_TYPE_AUDIO;
+						return 0;
+					}
+					case 404: // Resource Not Found
+						printf("Error: ICY-Server couldn't find requested stream, skipping!\n");
+						return -1;
+					default:
+						printf("Error: unhandled ICY-Errorcode, contact MPlayer developers!\n");
+						return -1;
+				}
 			}
-			
+
+			// Assume standard http if not ICY			
 			switch( http_hdr->status_code ) {
 				case 200: // OK
 					// Look if we can use the Content-Type
 					content_type = http_get_field( http_hdr, "Content-Type" );
 					if( content_type!=NULL ) {
+						char *content_length = NULL;
 						printf("Content-Type: [%s]\n", content_type );
-						printf("Content-Length: [%s]\n", http_get_field(http_hdr, "Content-Length") );
+						if( (content_length = http_get_field(http_hdr, "Content-Length")) != NULL)
+							printf("Content-Length: [%s]\n", http_get_field(http_hdr, "Content-Length"));
 						// Check in the mime type table for a demuxer type
 						for( i=0 ; i<(sizeof(mime_type_table)/sizeof(mime_type_table[0])) ; i++ ) {
 							if( !strcasecmp( content_type, mime_type_table[i].mime_type ) ) {




More information about the MPlayer-cvslog mailing list