diff --git a/libmpdemux/asf.h b/libmpdemux/asf.h index 8d35563cda..6a0391c745 100644 --- a/libmpdemux/asf.h +++ b/libmpdemux/asf.h @@ -113,7 +113,8 @@ typedef enum { ASF_Unknown_e, ASF_Live_e, ASF_Prerecorded_e, - ASF_Redirector_e + ASF_Redirector_e, + ASF_PlainText_e } ASF_StreamType_e; diff --git a/libmpdemux/asf_streaming.c b/libmpdemux/asf_streaming.c index 5205a143b6..3008370441 100644 --- a/libmpdemux/asf_streaming.c +++ b/libmpdemux/asf_streaming.c @@ -20,7 +20,7 @@ asf_http_streaming_read( streaming_ctrl_t *streaming_ctrl ) { 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 @@ printf("0x%02X\n", *((unsigned int*)(buffer+sizeof(ASF_stream_chunck_t))) ); 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 @@ asf_http_streaming_type(char *content_type, char *features) { (!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 @@ asf_http_parse_response( HTTP_header_t *http_hdr ) { } 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 @@ printf("read: %d\n", i ); 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 @@ printf("read: %d\n", i ); 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 @@ printf("read: %d\n", i ); } 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; diff --git a/libmpdemux/http.c b/libmpdemux/http.c index 75157fccf0..65c2f7c28d 100644 --- a/libmpdemux/http.c +++ b/libmpdemux/http.c @@ -62,7 +62,7 @@ http_response_append( HTTP_header_t *http_hdr, char *response, int length ) { } 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; diff --git a/libmpdemux/http.h b/libmpdemux/http.h index f8919288ae..7f07264bbc 100644 --- a/libmpdemux/http.h +++ b/libmpdemux/http.h @@ -31,7 +31,7 @@ HTTP_header_t* http_new_header(); 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 ); diff --git a/libmpdemux/network.c b/libmpdemux/network.c index 45299b8e4d..c80c49376e 100644 --- a/libmpdemux/network.c +++ b/libmpdemux/network.c @@ -256,7 +256,7 @@ http_read_response( int fd ) { 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; }