Mercurial > mplayer.hg
changeset 2489:0ecc1b4f7cf8
Added ASF http server streaming (Not mms streaming).
Fixed one bug in the ASF mms streaming.
Fixed a typo in http.
author | bertrand |
---|---|
date | Fri, 26 Oct 2001 18:26:06 +0000 |
parents | 383a4f3870e0 |
children | e5a6dd35b88e |
files | libmpdemux/asf.h libmpdemux/asf_streaming.c libmpdemux/http.c libmpdemux/http.h libmpdemux/network.c |
diffstat | 5 files changed, 38 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/asf.h Fri Oct 26 17:22:01 2001 +0000 +++ b/libmpdemux/asf.h Fri Oct 26 18:26:06 2001 +0000 @@ -113,7 +113,8 @@ ASF_Unknown_e, ASF_Live_e, ASF_Prerecorded_e, - ASF_Redirector_e + ASF_Redirector_e, + ASF_PlainText_e } ASF_StreamType_e;
--- a/libmpdemux/asf_streaming.c Fri Oct 26 17:22:01 2001 +0000 +++ b/libmpdemux/asf_streaming.c Fri Oct 26 18:26:06 2001 +0000 @@ -20,7 +20,7 @@ char *buffer; int drop_packet; int ret; -printf("asf_streaming_read\n"); +printf("asf_http_streaming_read\n"); ret = asf_streaming( streaming_ctrl->buffer->buffer, streaming_ctrl->buffer->length, &drop_packet ); printf("ret: %d\n", ret); if( ret<0 ) return -1; @@ -42,6 +42,25 @@ return ret; } +int +asf_http_read( streaming_ctrl_t *streaming_ctrl ) { + char *buffer; + unsigned int length = streaming_ctrl->buffer->length; + + buffer = (char*)malloc(length); + if( buffer==NULL ) { + printf("Memory allocation failed\n"); + return -1; + } + + net_fifo_pop( streaming_ctrl->buffer, buffer, length ); + + write( streaming_ctrl->fd_pipe_in, buffer, length ); + + free( buffer ); + return length; +} + int asf_streaming(char *data, int length, int *drop_packet ) { ASF_stream_chunck_t *stream_chunck=(ASF_stream_chunck_t*)data; @@ -115,6 +134,9 @@ (!strcasecmp(content_type, "video/x-ms-wma")) ) { printf("=====> ASF Redirector\n"); return ASF_Redirector_e; + } else if( !strcasecmp(content_type, "text/plain") ) { + printf("=====> ASF Plain text\n"); + return ASF_PlainText_e; } else { printf("=====> ASF unknown content-type: %s\n", content_type ); return ASF_Unknown_e; @@ -239,11 +261,11 @@ } streaming_type = asf_http_streaming_type( content_type, features ); - +/* if( http_hdr->body_size>0 ) { asf_streaming( http_hdr->body, http_hdr->body_size, NULL); } - +*/ return 0; } @@ -289,7 +311,7 @@ return -1; } http_response_append( http_hdr, buffer, i ); - } while( !http_is_header_entired( http_hdr ) ); + } while( !http_is_header_entire( http_hdr ) ); //http_hdr->buffer[http_hdr->buffer_len]='\0'; //printf("[%s]\n", http_hdr->buffer ); if( asf_http_parse_response(http_hdr)<0 ) { @@ -300,8 +322,8 @@ switch( streaming_type ) { case ASF_Live_e: case ASF_Prerecorded_e: + case ASF_PlainText_e: if( http_hdr->body_size>0 ) { -printf("--- 0x%02X\n", streaming_ctrl->buffer ); net_fifo_push( streaming_ctrl->buffer, http_hdr->body, http_hdr->body_size ); } else { ASF_stream_chunck_t *ptr; @@ -342,8 +364,12 @@ } while(!done); streaming_ctrl->fd_net = fd; - streaming_ctrl->streaming_read = asf_http_streaming_read; - streaming_ctrl->prebuffer_size = 10000; + if( streaming_type==ASF_PlainText_e ) { + streaming_ctrl->streaming_read = asf_http_read; + } else { + streaming_ctrl->streaming_read = asf_http_streaming_read; + } + streaming_ctrl->prebuffer_size = 20000; streaming_ctrl->buffering = 1; streaming_ctrl->status = streaming_playing_e;
--- a/libmpdemux/http.c Fri Oct 26 17:22:01 2001 +0000 +++ b/libmpdemux/http.c Fri Oct 26 18:26:06 2001 +0000 @@ -62,7 +62,7 @@ } int -http_is_header_entired( HTTP_header_t *http_hdr ) { +http_is_header_entire( HTTP_header_t *http_hdr ) { if( http_hdr==NULL ) return -1; if( strstr(http_hdr->buffer, "\r\n\r\n")==NULL ) return 0;
--- a/libmpdemux/http.h Fri Oct 26 17:22:01 2001 +0000 +++ b/libmpdemux/http.h Fri Oct 26 18:26:06 2001 +0000 @@ -31,7 +31,7 @@ void http_free( HTTP_header_t *http_hdr ); int http_response_append( HTTP_header_t *http_hdr, char *data, int length ); int http_response_parse( HTTP_header_t *http_hdr ); -int http_is_header_entired( HTTP_header_t *http_hdr ); +int http_is_header_entire( HTTP_header_t *http_hdr ); char* http_build_request( HTTP_header_t *http_hdr ); char* http_get_field( HTTP_header_t *http_hdr, const char *field_name ); char* http_get_next_field( HTTP_header_t *http_hdr );
--- a/libmpdemux/network.c Fri Oct 26 17:22:01 2001 +0000 +++ b/libmpdemux/network.c Fri Oct 26 18:26:06 2001 +0000 @@ -256,7 +256,7 @@ printf("Read failed\n"); } http_response_append( http_hdr, response, i ); - } while( !http_is_header_entired( http_hdr ) ); + } while( !http_is_header_entire( http_hdr ) ); http_response_parse( http_hdr ); return http_hdr; }