[Mplayer-cvslog] CVS: main/libmpdemux network.h,1.9,1.10 network.c,1.27,1.28 open.c,1.31,1.32

Bertrand Baudet bertrand at mplayer.dev.hu
Sat Jan 19 10:04:04 CET 2002


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

Modified Files:
	network.h network.c open.c 
Log Message:
Moved network related code from open.c to network.c


Index: network.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/network.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- network.h	14 Jan 2002 06:44:30 -0000	1.9
+++ network.h	19 Jan 2002 09:04:02 -0000	1.10
@@ -38,13 +38,7 @@
 	void *data;
 } streaming_ctrl_t;
 
-streaming_ctrl_t *streaming_ctrl_new();
-void streaming_ctrl_free( streaming_ctrl_t *streaming_ctrl );
-
-int autodetectProtocol( streaming_ctrl_t *streaming_ctrl, int *fd_out, int *file_format );
-URL_t* check4proxies( URL_t *url );
-
-//int streaming_start( stream_t *stream, int demuxer_type );
+//int streaming_start( stream_t *stream, int demuxer_type, URL_t *url );
 
 int streaming_bufferize( streaming_ctrl_t *streaming_ctrl, char *buffer, int size);
 

Index: network.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/network.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- network.c	18 Jan 2002 11:05:29 -0000	1.27
+++ network.c	19 Jan 2002 09:04:02 -0000	1.28
@@ -83,6 +83,9 @@
 void
 streaming_ctrl_free( streaming_ctrl_t *streaming_ctrl ) {
 	if( streaming_ctrl==NULL ) return;
+	if( streaming_ctrl->url ) url_free( streaming_ctrl->url );
+	if( streaming_ctrl->buffer ) free( streaming_ctrl->buffer );
+	if( streaming_ctrl->data ) free( streaming_ctrl->data );
 	free( streaming_ctrl );
 }
 
@@ -177,6 +180,7 @@
 
 URL_t*
 check4proxies( URL_t *url ) {
+	if( url==NULL ) return NULL;
 	if( !strcasecmp(url->protocol, "http_proxy") ) {
 			printf("Using HTTP proxy: http://%s:%d\n", url->hostname, url->port );
 			return url;
@@ -207,7 +211,7 @@
 			sprintf( new_url, "http_proxy://%s:%d/%s", proxy_url->hostname, proxy_url->port, url->url);
 			tmp_url = url_new( new_url );
 			if( tmp_url==NULL ) {
-					return url;
+				return url;
 			}
 			url_free( url );
 			url = tmp_url;
@@ -444,7 +448,7 @@
 
 int
 streaming_bufferize( streaming_ctrl_t *streaming_ctrl, char *buffer, int size) {
-printf("streaming_bufferize\n");
+//printf("streaming_bufferize\n");
 	streaming_ctrl->buffer = (char*)malloc(size);
 	if( streaming_ctrl->buffer==NULL ) {
 		printf("Memory allocation failed\n");
@@ -461,19 +465,19 @@
 //printf("nop_streaming_read\n");
 	if( stream_ctrl->buffer_size!=0 ) {
 		int buffer_len = stream_ctrl->buffer_size-stream_ctrl->buffer_pos;
-printf("%d bytes in buffer\n", stream_ctrl->buffer_size);
+//printf("%d bytes in buffer\n", stream_ctrl->buffer_size);
 		len = (size<buffer_len)?size:buffer_len;
 		memcpy( buffer, (stream_ctrl->buffer)+(stream_ctrl->buffer_pos), len );
 		stream_ctrl->buffer_pos += len;
-printf("buffer_pos = %d\n", stream_ctrl->buffer_pos );
+//printf("buffer_pos = %d\n", stream_ctrl->buffer_pos );
 		if( stream_ctrl->buffer_pos>=stream_ctrl->buffer_size ) {
 			free( stream_ctrl->buffer );
 			stream_ctrl->buffer = NULL;
 			stream_ctrl->buffer_size = 0;
 			stream_ctrl->buffer_pos = 0;
-printf("buffer cleaned\n");
+//printf("buffer cleaned\n");
 		}
-printf("read %d bytes from buffer\n", len );
+//printf("read %d bytes from buffer\n", len );
 	}
 
 	if( len<size ) {
@@ -529,6 +533,7 @@
 		if( http_hdr->body_size>0 ) {
 			if( streaming_bufferize( stream->streaming_ctrl, http_hdr->body, http_hdr->body_size )<0 ) {
 				http_free( http_hdr );
+				stream->streaming_ctrl->data = NULL;
 				return -1;
 			}
 		}
@@ -651,9 +656,20 @@
 }
 
 int
-streaming_start(stream_t *stream, int demuxer_type) {
-	int ret=-1;
+streaming_start(stream_t *stream, int demuxer_type, URL_t *url) {
+	int ret;
 	if( stream==NULL ) return -1;
+
+	stream->streaming_ctrl = streaming_ctrl_new();
+	if( stream->streaming_ctrl==NULL ) {
+		return -1;
+	}
+	stream->streaming_ctrl->url = check4proxies( url_copy(url) );
+	ret = autodetectProtocol( stream->streaming_ctrl, &stream->fd, &demuxer_type );
+	if( ret<0 ) {
+		return -1;
+	}
+	ret = -1;
 	
 	// For RTP streams, we usually don't know the stream type until we open it.
 	if( !strcasecmp( stream->streaming_ctrl->url->protocol, "rtp")) {
@@ -693,7 +709,8 @@
 	}
 
 	if( ret<0 ) {
-		free( stream->streaming_ctrl );
+		streaming_ctrl_free( stream->streaming_ctrl );
+		stream->streaming_ctrl = NULL;
 	} 
 	return ret;
 }

Index: open.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/open.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- open.c	17 Jan 2002 20:40:07 -0000	1.31
+++ open.c	19 Jan 2002 09:04:02 -0000	1.32
@@ -374,24 +374,13 @@
 #ifdef STREAMING
   url = url_new(filename);
   if(url) {
-	streaming_ctrl_t *streaming_ctrl;
-	streaming_ctrl = streaming_ctrl_new();
-	if( streaming_ctrl==NULL ) return NULL;
-	url = check4proxies( url );
-	streaming_ctrl->url = url_copy( url );
-	if( autodetectProtocol( streaming_ctrl, &f, file_format )<0 ) {
-		mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_UnableOpenURL, filename );
-		return NULL;
-	}
-        mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ConnToServer, url->hostname );
         stream=new_stream(f,STREAMTYPE_STREAM);
-	stream->streaming_ctrl = streaming_ctrl;
-	//if( streaming_start( stream , url, *file_format )<0){
-	if( streaming_start( stream, *file_format )<0){
+	if( streaming_start( stream, *file_format, url )<0){
           mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, filename);
-          url_free(url);
+	  url_free(url);
 	  return NULL;
 	}
+        mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ConnToServer, url->hostname );
 	url_free(url);
 	return stream;
   }




More information about the MPlayer-cvslog mailing list