Mercurial > mplayer.hg
comparison libmpdemux/asf_streaming.c @ 4312:971836f677a9
Added a turn around for badly configured web servers.
author | bertrand |
---|---|
date | Wed, 23 Jan 2002 08:50:30 +0000 |
parents | b84e9861461c |
children | 0d5cba15772b |
comparison
equal
deleted
inserted
replaced
4311:c9f861653fe2 | 4312:971836f677a9 |
---|---|
338 asf_http_streaming_seek( int fd, off_t pos, streaming_ctrl_t *streaming_ctrl ) { | 338 asf_http_streaming_seek( int fd, off_t pos, streaming_ctrl_t *streaming_ctrl ) { |
339 return -1; | 339 return -1; |
340 } | 340 } |
341 | 341 |
342 int | 342 int |
343 asf_http_streaming_type(char *content_type, char *features) { | 343 asf_header_check( HTTP_header_t *http_hdr ) { |
344 ASF_obj_header_t *objh; | |
345 if( http_hdr==NULL ) return -1; | |
346 if( http_hdr->body==NULL || http_hdr->body_size<sizeof(ASF_obj_header_t) ) return -1; | |
347 | |
348 objh = (ASF_obj_header_t*)http_hdr->body; | |
349 if( ASF_LOAD_GUID_PREFIX(objh->guid)==0x75B22630 ) return 0; | |
350 return -1; | |
351 } | |
352 | |
353 int | |
354 asf_http_streaming_type(char *content_type, char *features, HTTP_header_t *http_hdr ) { | |
344 if( content_type==NULL ) return ASF_Unknown_e; | 355 if( content_type==NULL ) return ASF_Unknown_e; |
345 if( !strcasecmp(content_type, "application/octet-stream") ) { | 356 if( !strcasecmp(content_type, "application/octet-stream") ) { |
346 if( features==NULL ) { | 357 if( features==NULL ) { |
347 printf("=====> ASF Prerecorded\n"); | 358 printf("=====> ASF Prerecorded\n"); |
348 return ASF_Prerecorded_e; | 359 return ASF_Prerecorded_e; |
352 } else { | 363 } else { |
353 printf("=====> ASF Prerecorded\n"); | 364 printf("=====> ASF Prerecorded\n"); |
354 return ASF_Prerecorded_e; | 365 return ASF_Prerecorded_e; |
355 } | 366 } |
356 } else { | 367 } else { |
368 // Ok in a perfect world, web servers should be well configured | |
369 // so we could used mime type to know the stream type, | |
370 // but guess what? All of them are not well configured. | |
371 // So we have to check for an asf header :(, but it works :p | |
372 if( asf_header_check( http_hdr )==0 ) { | |
373 printf("=====> ASF Plain text\n"); | |
374 return ASF_PlainText_e; | |
375 } else { | |
376 printf("=====> ASF Redirector\n"); | |
377 return ASF_Redirector_e; | |
378 } | |
379 /* | |
357 if( (!strcasecmp(content_type, "audio/x-ms-wax")) || | 380 if( (!strcasecmp(content_type, "audio/x-ms-wax")) || |
358 (!strcasecmp(content_type, "audio/x-ms-wma")) || | 381 (!strcasecmp(content_type, "audio/x-ms-wma")) || |
359 (!strcasecmp(content_type, "video/x-ms-asf")) || | 382 (!strcasecmp(content_type, "video/x-ms-asf")) || |
360 (!strcasecmp(content_type, "video/x-ms-afs")) || | 383 (!strcasecmp(content_type, "video/x-ms-afs")) || |
361 (!strcasecmp(content_type, "video/x-ms-wvx")) || | 384 (!strcasecmp(content_type, "video/x-ms-wvx")) || |
368 return ASF_PlainText_e; | 391 return ASF_PlainText_e; |
369 } else { | 392 } else { |
370 printf("=====> ASF unknown content-type: %s\n", content_type ); | 393 printf("=====> ASF unknown content-type: %s\n", content_type ); |
371 return ASF_Unknown_e; | 394 return ASF_Unknown_e; |
372 } | 395 } |
396 */ | |
373 } | 397 } |
374 return ASF_Unknown_e; | 398 return ASF_Unknown_e; |
375 } | 399 } |
376 | 400 |
377 HTTP_header_t * | 401 HTTP_header_t * |
530 } | 554 } |
531 } while( comma_ptr!=NULL ); | 555 } while( comma_ptr!=NULL ); |
532 pragma = http_get_next_field( http_hdr ); | 556 pragma = http_get_next_field( http_hdr ); |
533 } | 557 } |
534 | 558 |
535 return asf_http_streaming_type( content_type, features ); | 559 return asf_http_streaming_type( content_type, features, http_hdr ); |
536 } | 560 } |
537 | 561 |
538 int | 562 int |
539 asf_http_streaming_start( stream_t *stream ) { | 563 asf_http_streaming_start( stream_t *stream ) { |
540 HTTP_header_t *http_hdr=NULL; | 564 HTTP_header_t *http_hdr=NULL; |
622 if(ret < 0) return -1; | 646 if(ret < 0) return -1; |
623 if(asf_http_ctrl->n_audio == 0 && asf_http_ctrl->n_video == 0) { | 647 if(asf_http_ctrl->n_audio == 0 && asf_http_ctrl->n_video == 0) { |
624 printf("No stream found\n"); | 648 printf("No stream found\n"); |
625 return -1; | 649 return -1; |
626 } | 650 } |
651 asf_http_ctrl->request++; | |
652 done = 0; | |
653 } else { | |
654 done = 1; | |
627 } | 655 } |
628 asf_http_ctrl->request++; | |
629 done = 0; | |
630 } | 656 } |
631 break; | 657 break; |
632 case ASF_Redirector_e: | 658 case ASF_Redirector_e: |
633 if( http_hdr->body_size>0 ) { | 659 if( http_hdr->body_size>0 ) { |
634 if( streaming_bufferize( stream->streaming_ctrl, http_hdr->body, http_hdr->body_size )<0 ) { | 660 if( streaming_bufferize( stream->streaming_ctrl, http_hdr->body, http_hdr->body_size )<0 ) { |