aboutsummaryrefslogtreecommitdiffhomepage
path: root/libmpdemux
diff options
context:
space:
mode:
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/network.c35
-rw-r--r--libmpdemux/network.h8
-rw-r--r--libmpdemux/open.c17
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;
}