diff options
author | bertrand <bertrand@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-01-19 09:04:02 +0000 |
---|---|---|
committer | bertrand <bertrand@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-01-19 09:04:02 +0000 |
commit | 46ae846897316e0a89569da6a6c687c59c1842b8 (patch) | |
tree | 8390de996f17d30a46fdabfdaac365d5d4e6593f /libmpdemux | |
parent | 4e3acc51b64df7d0c74c23a7027d7a32e8f9f672 (diff) |
Moved network related code from open.c to network.c
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4252 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/network.c | 35 | ||||
-rw-r--r-- | libmpdemux/network.h | 8 | ||||
-rw-r--r-- | libmpdemux/open.c | 17 |
3 files changed, 30 insertions, 30 deletions
diff --git a/libmpdemux/network.c b/libmpdemux/network.c index 22f305daeb..8464a8eaa2 100644 --- a/libmpdemux/network.c +++ b/libmpdemux/network.c @@ -83,6 +83,9 @@ streaming_ctrl_new( ) { 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 @@ connect2Server(char *host, int port) { 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 @@ check4proxies( URL_t *url ) { 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 @@ extension=NULL; 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 @@ nop_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *stream_ctr //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 @@ nop_streaming_start( stream_t *stream ) { 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 @@ rtp_streaming_start( stream_t *stream ) { } 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 @@ streaming_start(stream_t *stream, int demuxer_type) { } if( ret<0 ) { - free( stream->streaming_ctrl ); + streaming_ctrl_free( stream->streaming_ctrl ); + stream->streaming_ctrl = NULL; } return ret; } diff --git a/libmpdemux/network.h b/libmpdemux/network.h index e1ead7f19c..e4d3c6e72e 100644 --- a/libmpdemux/network.h +++ b/libmpdemux/network.h @@ -38,13 +38,7 @@ typedef struct streaming_control { 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); diff --git a/libmpdemux/open.c b/libmpdemux/open.c index 8b135ac997..6165e3e6bb 100644 --- a/libmpdemux/open.c +++ b/libmpdemux/open.c @@ -374,24 +374,13 @@ tv_err: #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; } |