comparison libmpdemux/network.c @ 4729:f51bd827ed1c

fixed MP3 ICY detection, return detected file format for open_stream
author alex
date Sat, 16 Feb 2002 21:48:59 +0000
parents 17cf55182029
children 330462dd5569
comparison
equal deleted inserted replaced
4728:dab19bd91cde 4729:f51bd827ed1c
32 static struct { 32 static struct {
33 char *mime_type; 33 char *mime_type;
34 int demuxer_type; 34 int demuxer_type;
35 } mime_type_table[] = { 35 } mime_type_table[] = {
36 // MP3 streaming, some MP3 streaming server answer with audio/mpeg 36 // MP3 streaming, some MP3 streaming server answer with audio/mpeg
37 { "audio/mpeg", DEMUXER_TYPE_MPEG_PS }, 37 { "audio/mpeg", DEMUXER_TYPE_AUDIO },
38 // MPEG streaming 38 // MPEG streaming
39 { "video/mpeg", DEMUXER_TYPE_MPEG_PS }, 39 { "video/mpeg", DEMUXER_TYPE_MPEG_PS },
40 // AVI ??? => video/x-msvideo 40 // AVI ??? => video/x-msvideo
41 { "video/x-msvideo", DEMUXER_TYPE_AVI }, 41 { "video/x-msvideo", DEMUXER_TYPE_AVI },
42 // MOV => video/quicktime 42 // MOV => video/quicktime
66 { "wmv", DEMUXER_TYPE_ASF }, 66 { "wmv", DEMUXER_TYPE_ASF },
67 { "wma", DEMUXER_TYPE_ASF }, 67 { "wma", DEMUXER_TYPE_ASF },
68 { "viv", DEMUXER_TYPE_VIVO }, 68 { "viv", DEMUXER_TYPE_VIVO },
69 { "rm", DEMUXER_TYPE_REAL }, 69 { "rm", DEMUXER_TYPE_REAL },
70 { "y4m", DEMUXER_TYPE_Y4M }, 70 { "y4m", DEMUXER_TYPE_Y4M },
71 { "mp3", DEMUXER_TYPE_AUDIO },
72 { "wav", DEMUXER_TYPE_AUDIO },
71 }; 73 };
72 74
73 streaming_ctrl_t * 75 streaming_ctrl_t *
74 streaming_ctrl_new( ) { 76 streaming_ctrl_new( ) {
75 streaming_ctrl_t *streaming_ctrl; 77 streaming_ctrl_t *streaming_ctrl;
398 streaming_ctrl->data = (void*)http_hdr; 400 streaming_ctrl->data = (void*)http_hdr;
399 401
400 // Check if the response is an ICY status_code reason_phrase 402 // Check if the response is an ICY status_code reason_phrase
401 if( !strcasecmp(http_hdr->protocol, "ICY") ) { 403 if( !strcasecmp(http_hdr->protocol, "ICY") ) {
402 // Ok, we have detected an mp3 streaming 404 // Ok, we have detected an mp3 streaming
403 *file_format = DEMUXER_TYPE_MPEG_PS; 405 *file_format = DEMUXER_TYPE_AUDIO;
404 return 0; 406 return 0;
405 } 407 }
406 408
407 switch( http_hdr->status_code ) { 409 switch( http_hdr->status_code ) {
408 case 200: // OK 410 case 200: // OK
656 streaming_ctrl->status = streaming_playing_e; 658 streaming_ctrl->status = streaming_playing_e;
657 return 0; 659 return 0;
658 } 660 }
659 661
660 int 662 int
661 streaming_start(stream_t *stream, int demuxer_type, URL_t *url) { 663 streaming_start(stream_t *stream, int *demuxer_type, URL_t *url) {
662 int ret; 664 int ret;
663 if( stream==NULL ) return -1; 665 if( stream==NULL ) return -1;
664 666
665 stream->streaming_ctrl = streaming_ctrl_new(); 667 stream->streaming_ctrl = streaming_ctrl_new();
666 if( stream->streaming_ctrl==NULL ) { 668 if( stream->streaming_ctrl==NULL ) {
667 return -1; 669 return -1;
668 } 670 }
669 stream->streaming_ctrl->url = check4proxies( url ); 671 stream->streaming_ctrl->url = check4proxies( url );
670 ret = autodetectProtocol( stream->streaming_ctrl, &stream->fd, &demuxer_type ); 672 ret = autodetectProtocol( stream->streaming_ctrl, &stream->fd, demuxer_type );
671 if( ret<0 ) { 673 if( ret<0 ) {
672 return -1; 674 return -1;
673 } 675 }
674 ret = -1; 676 ret = -1;
675 677
681 } 683 }
682 stream->fd = -1; 684 stream->fd = -1;
683 ret = rtp_streaming_start( stream ); 685 ret = rtp_streaming_start( stream );
684 } else 686 } else
685 // For connection-oriented streams, we can usually determine the streaming type. 687 // For connection-oriented streams, we can usually determine the streaming type.
686 switch( demuxer_type ) { 688 switch( *demuxer_type ) {
687 case DEMUXER_TYPE_ASF: 689 case DEMUXER_TYPE_ASF:
688 // Send the appropriate HTTP request 690 // Send the appropriate HTTP request
689 // Need to filter the network stream. 691 // Need to filter the network stream.
690 // ASF raw stream is encapsulated. 692 // ASF raw stream is encapsulated.
691 ret = asf_streaming_start( stream ); 693 ret = asf_streaming_start( stream );
692 if( ret<0 ) { 694 if( ret<0 ) {
693 printf("asf_streaming_start failed\n"); 695 printf("asf_streaming_start failed\n");
694 } 696 }
695 break; 697 break;
698 case DEMUXER_TYPE_MPEG_ES:
699 case DEMUXER_TYPE_MPEG_PS:
696 case DEMUXER_TYPE_AVI: 700 case DEMUXER_TYPE_AVI:
697 case DEMUXER_TYPE_MOV: 701 case DEMUXER_TYPE_MOV:
698 case DEMUXER_TYPE_MPEG_ES: 702 case DEMUXER_TYPE_VIVO:
699 case DEMUXER_TYPE_MPEG_PS: 703 case DEMUXER_TYPE_FLI:
704 case DEMUXER_TYPE_REAL:
705 case DEMUXER_TYPE_Y4M:
706 case DEMUXER_TYPE_FILM:
707 case DEMUXER_TYPE_ROQ:
708 case DEMUXER_TYPE_AUDIO:
700 case DEMUXER_TYPE_UNKNOWN: 709 case DEMUXER_TYPE_UNKNOWN:
701 // Generic start, doesn't need to filter 710 // Generic start, doesn't need to filter
702 // the network stream, it's a raw stream 711 // the network stream, it's a raw stream
703 ret = nop_streaming_start( stream ); 712 ret = nop_streaming_start( stream );
704 if( ret<0 ) { 713 if( ret<0 ) {