Added ASF http server streaming (Not mms streaming).

Fixed one bug in the ASF mms streaming.
Fixed a typo in http.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2490 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
bertrand 2001-10-26 18:26:06 +00:00
parent 35367b99cc
commit 1e7d31cc88
5 changed files with 38 additions and 11 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 );

View File

@ -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;
}