[MPlayer-cvslog] r35395 - in trunk/stream: asf_streaming.c http.c network.c network.h pnm.c stream_live555.c stream_nemesi.c stream_rtsp.c

reimar subversion at mplayerhq.hu
Sat Nov 10 14:19:29 CET 2012


Author: reimar
Date: Sat Nov 10 14:19:29 2012
New Revision: 35395

Log:
Add url_new_with_proxy function to reduce code duplication and memleaks.

Modified:
   trunk/stream/asf_streaming.c
   trunk/stream/http.c
   trunk/stream/network.c
   trunk/stream/network.h
   trunk/stream/pnm.c
   trunk/stream/stream_live555.c
   trunk/stream/stream_nemesi.c
   trunk/stream/stream_rtsp.c

Modified: trunk/stream/asf_streaming.c
==============================================================================
--- trunk/stream/asf_streaming.c	Sat Nov 10 14:18:38 2012	(r35394)
+++ trunk/stream/asf_streaming.c	Sat Nov 10 14:19:29 2012	(r35395)
@@ -826,16 +826,12 @@ err_out:
 }
 
 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
-	URL_t *url;
-
 	stream->streaming_ctrl = streaming_ctrl_new();
 	if( stream->streaming_ctrl==NULL ) {
 		return STREAM_ERROR;
 	}
 	stream->streaming_ctrl->bandwidth = network_bandwidth;
-	url = url_new(stream->url);
-	stream->streaming_ctrl->url = check4proxies(url);
-	url_free(url);
+	stream->streaming_ctrl->url = url_new_with_proxy(stream->url);
 
 	mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_MPDEMUX_ASF_InfoStreamASFURL, stream->url);
 	if((!strncmp(stream->url, "http", 4)) && (*file_format!=DEMUXER_TYPE_ASF && *file_format!=DEMUXER_TYPE_UNKNOWN)) {

Modified: trunk/stream/http.c
==============================================================================
--- trunk/stream/http.c	Sat Nov 10 14:18:38 2012	(r35394)
+++ trunk/stream/http.c	Sat Nov 10 14:19:29 2012	(r35395)
@@ -217,7 +217,6 @@ static int scast_streaming_start(stream_
 static int nop_streaming_start( stream_t *stream ) {
 	HTTP_header_t *http_hdr = NULL;
 	char *next_url=NULL;
-	URL_t *rd_url=NULL;
 	int fd,ret;
 	if( stream==NULL ) return -1;
 
@@ -247,12 +246,9 @@ static int nop_streaming_start( stream_t
 				ret=-1;
 				next_url = http_get_field( http_hdr, "Location" );
 
-				if (next_url != NULL)
-					rd_url=url_new(next_url);
-
-				if (next_url != NULL && rd_url != NULL) {
+				if (next_url != NULL) {
 					mp_msg(MSGT_NETWORK,MSGL_STATUS,"Redirected: Using this url instead %s\n",next_url);
-							stream->streaming_ctrl->url=check4proxies(rd_url);
+							stream->streaming_ctrl->url=url_new_with_proxy(next_url);
 					ret=nop_streaming_start(stream); //recursively get streaming started
 				} else {
 					mp_msg(MSGT_NETWORK,MSGL_ERR,"Redirection failed\n");
@@ -890,16 +886,13 @@ static int fixup_open(stream_t *stream,i
 
 static int open_s1(stream_t *stream,int mode, void* opts, int* file_format) {
 	int seekable=0;
-	URL_t *url;
 
 	stream->streaming_ctrl = streaming_ctrl_new();
 	if( stream->streaming_ctrl==NULL ) {
 		return STREAM_ERROR;
 	}
 	stream->streaming_ctrl->bandwidth = network_bandwidth;
-	url = url_new(stream->url);
-	stream->streaming_ctrl->url = check4proxies(url);
-	url_free(url);
+	stream->streaming_ctrl->url = url_new_with_proxy(stream->url);
 
 	mp_msg(MSGT_OPEN, MSGL_V, "STREAM_HTTP(1), URL: %s\n", stream->url);
 	seekable = http_streaming_start(stream, file_format);
@@ -919,16 +912,13 @@ static int open_s1(stream_t *stream,int 
 
 static int open_s2(stream_t *stream,int mode, void* opts, int* file_format) {
 	int seekable=0;
-	URL_t *url;
 
 	stream->streaming_ctrl = streaming_ctrl_new();
 	if( stream->streaming_ctrl==NULL ) {
 		return STREAM_ERROR;
 	}
 	stream->streaming_ctrl->bandwidth = network_bandwidth;
-	url = url_new(stream->url);
-	stream->streaming_ctrl->url = check4proxies(url);
-	url_free(url);
+	stream->streaming_ctrl->url = url_new_with_proxy(stream->url);
 
 	mp_msg(MSGT_OPEN, MSGL_V, "STREAM_HTTP(2), URL: %s\n", stream->url);
 	seekable = http_streaming_start(stream, file_format);

Modified: trunk/stream/network.c
==============================================================================
--- trunk/stream/network.c	Sat Nov 10 14:18:38 2012	(r35394)
+++ trunk/stream/network.c	Sat Nov 10 14:19:29 2012	(r35395)
@@ -186,6 +186,14 @@ check4proxies( const URL_t *url ) {
 	return url_out;
 }
 
+URL_t *url_new_with_proxy(const char *urlstr)
+{
+	URL_t *url = url_new(urlstr);
+	URL_t *url_with_proxy = check4proxies(url);
+	url_free(url);
+	return url_with_proxy;
+}
+
 int
 http_send_request( URL_t *url, off_t pos ) {
 	HTTP_header_t *http_hdr;

Modified: trunk/stream/network.h
==============================================================================
--- trunk/stream/network.h	Sat Nov 10 14:18:38 2012	(r35394)
+++ trunk/stream/network.h	Sat Nov 10 14:19:29 2012	(r35395)
@@ -84,6 +84,7 @@ HTTP_header_t *http_read_response(int fd
 
 int http_authenticate(HTTP_header_t *http_hdr, URL_t *url, int *auth_retry);
 URL_t* check4proxies(const URL_t *url);
+URL_t *url_new_with_proxy(const char *urlstr);
 
 void fixup_network_stream_cache(stream_t *stream);
 int http_seek(stream_t *stream, off_t pos);

Modified: trunk/stream/pnm.c
==============================================================================
--- trunk/stream/pnm.c	Sat Nov 10 14:18:38 2012	(r35394)
+++ trunk/stream/pnm.c	Sat Nov 10 14:19:29 2012	(r35395)
@@ -821,7 +821,6 @@ static int pnm_streaming_read( int fd, c
 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
   int fd;
   pnm_t *pnm;
-  URL_t *url;
 
   mp_msg(MSGT_OPEN, MSGL_INFO, "STREAM_PNM, URL: %s\n", stream->url);
   stream->streaming_ctrl = streaming_ctrl_new();
@@ -829,9 +828,7 @@ static int open_s(stream_t *stream,int m
     return STREAM_ERROR;
 
   stream->streaming_ctrl->bandwidth = network_bandwidth;
-  url = url_new(stream->url);
-  stream->streaming_ctrl->url = check4proxies(url);
-  url_free(url);
+  stream->streaming_ctrl->url = url_new_with_proxy(stream->url);
 
   fd = connect2Server( stream->streaming_ctrl->url->hostname,
     stream->streaming_ctrl->url->port ? stream->streaming_ctrl->url->port : 7070,1 );

Modified: trunk/stream/stream_live555.c
==============================================================================
--- trunk/stream/stream_live555.c	Sat Nov 10 14:18:38 2012	(r35394)
+++ trunk/stream/stream_live555.c	Sat Nov 10 14:19:29 2012	(r35395)
@@ -40,16 +40,12 @@ static int rtsp_streaming_start(stream_t
 
 
 static int open_live_rtsp_sip(stream_t *stream,int mode, void* opts, int* file_format) {
-  URL_t *url;
-
   stream->streaming_ctrl = streaming_ctrl_new();
   if( stream->streaming_ctrl==NULL ) {
     return STREAM_ERROR;
   }
   stream->streaming_ctrl->bandwidth = network_bandwidth;
-  url = url_new(stream->url);
-  stream->streaming_ctrl->url = check4proxies(url);
-  url_free(url);
+  stream->streaming_ctrl->url = url_new_with_proxy(stream->url);
 
   mp_msg(MSGT_OPEN, MSGL_INFO, "STREAM_LIVE555, URL: %s\n", stream->url);
 

Modified: trunk/stream/stream_nemesi.c
==============================================================================
--- trunk/stream/stream_nemesi.c	Sat Nov 10 14:18:38 2012	(r35394)
+++ trunk/stream/stream_nemesi.c	Sat Nov 10 14:19:29 2012	(r35395)
@@ -47,7 +47,6 @@ static int rtsp_streaming_seek(int fd, o
 static int rtsp_streaming_open (stream_t *stream, int mode, void *opts,
                                 int *file_format)
 {
-    URL_t *url;
     stream->fd = -1;
 
     mp_msg (MSGT_OPEN, MSGL_V, "STREAM_RTSP, URL: %s\n", stream->url);
@@ -56,8 +55,7 @@ static int rtsp_streaming_open (stream_t
     return STREAM_ERROR;
 
     stream->streaming_ctrl->bandwidth = network_bandwidth;
-    url = url_new(stream->url);
-    stream->streaming_ctrl->url = check4proxies(url);
+    stream->streaming_ctrl->url = url_new_with_proxy(stream->url);
     stream->streaming_ctrl->streaming_seek = rtsp_streaming_seek;
 
     *file_format = DEMUXER_TYPE_RTP_NEMESI;

Modified: trunk/stream/stream_rtsp.c
==============================================================================
--- trunk/stream/stream_rtsp.c	Sat Nov 10 14:18:38 2012	(r35394)
+++ trunk/stream/stream_rtsp.c	Sat Nov 10 14:19:29 2012	(r35395)
@@ -141,16 +141,13 @@ rtsp_streaming_close (struct stream *s)
 static int
 rtsp_streaming_open (stream_t *stream, int mode, void *opts, int *file_format)
 {
-  URL_t *url;
-
   mp_msg (MSGT_OPEN, MSGL_V, "STREAM_RTSP, URL: %s\n", stream->url);
   stream->streaming_ctrl = streaming_ctrl_new ();
   if (!stream->streaming_ctrl)
     return STREAM_ERROR;
 
   stream->streaming_ctrl->bandwidth = network_bandwidth;
-  url = url_new (stream->url);
-  stream->streaming_ctrl->url = check4proxies (url);
+  stream->streaming_ctrl->url = url_new_with_proxy(stream->url);
 
   stream->fd = -1;
   index_mode = -1; /* prevent most RTSP streams from locking due to -idx */


More information about the MPlayer-cvslog mailing list