comparison mplayer.c @ 748:717e4677d9ce

stime compile bug fixed. and GUI_MSG macro defined.
author pontscho
date Thu, 10 May 2001 09:13:36 +0000
parents cd1f0d4de0b8
children ebc90219f934
comparison
equal deleted inserted replaced
747:cc99cea3c7bd 748:717e4677d9ce
12 12
13 #include <signal.h> 13 #include <signal.h>
14 14
15 #include <sys/ioctl.h> 15 #include <sys/ioctl.h>
16 #include <unistd.h> 16 #include <unistd.h>
17 #include <time.h>
17 #include <sys/mman.h> 18 #include <sys/mman.h>
18 19
19 #include <sys/types.h> 20 #include <sys/types.h>
20 #include <sys/wait.h> 21 #include <sys/wait.h>
21 #include <sys/time.h> 22 #include <sys/time.h>
87 88
88 #include "help_mp.h" 89 #include "help_mp.h"
89 90
90 #define DEBUG if(0) 91 #define DEBUG if(0)
91 #ifdef HAVE_GUI 92 #ifdef HAVE_GUI
92 int nogui=1; // new 93 int nogui=1;
93 #endif 94 #endif
94 int verbose=0; 95 int verbose=0;
95 96
96 #define ABS(x) (((x)>=0)?(x):(-(x))) 97 #define ABS(x) (((x)>=0)?(x):(-(x)))
97 98
352 353
353 extern void avi_fixate(); 354 extern void avi_fixate();
354 355
355 #ifdef HAVE_GUI 356 #ifdef HAVE_GUI
356 #include "../Gui/mplayer/psignal.h" 357 #include "../Gui/mplayer/psignal.h"
358 #define GUI_MSG(x) if ( !nogui ) { mplSendMessage( x ); usleep( 10000 ); }
359 #else
360 #define GUI_MSG(x)
357 #endif 361 #endif
358 362
359 void exit_player(char* how){ 363 void exit_player(char* how){
360 364
361 #ifdef HAVE_GUI 365 #ifdef HAVE_GUI
581 } 585 }
582 586
583 // check codec.conf 587 // check codec.conf
584 if(!parse_codec_cfg(get_path("codecs.conf"))){ 588 if(!parse_codec_cfg(get_path("codecs.conf"))){
585 printf("(copy/link DOCS/codecs.conf to ~/.mplayer/codecs.conf)\n"); 589 printf("(copy/link DOCS/codecs.conf to ~/.mplayer/codecs.conf)\n");
586 #ifdef HAVE_GUI 590 GUI_MSG( mplCodecConfNotFound )
587 if ( !nogui ) { mplSendMessage( mplCodecConfNotFound ); usleep( 10000 ); }
588 #endif
589 exit(1); 591 exit(1);
590 } 592 }
591 593
592 // check font 594 // check font
593 if(font_name){ 595 if(font_name){
649 651
650 #ifdef HAVE_LIBCSS 652 #ifdef HAVE_LIBCSS
651 if (dvdimportkey) { 653 if (dvdimportkey) {
652 if (dvd_import_key(dvdimportkey)) { 654 if (dvd_import_key(dvdimportkey)) {
653 fprintf(stderr,"Error processing DVD KEY.\n"); 655 fprintf(stderr,"Error processing DVD KEY.\n");
654 #ifdef HAVE_GUI 656 GUI_MSG( mplErrorDVDKeyProcess )
655 if ( !nogui ) { mplSendMessage( mplErrorDVDKeyProcess ); usleep( 10000 ); }
656 #endif
657 exit(1); 657 exit(1);
658 } 658 }
659 printf("DVD command line requested key is stored for descrambling.\n"); 659 printf("DVD command line requested key is stored for descrambling.\n");
660 } 660 }
661 if (dvd_device) { 661 if (dvd_device) {
662 if (dvd_auth(dvd_device,f)) { 662 if (dvd_auth(dvd_device,f)) {
663 #ifdef HAVE_GUI 663 GUI_MSG( mplErrorDVDAuth )
664 if ( !nogui ) { mplSendMessage( mplErrorDVDAuth ); usleep( 10000 ); }
665 #endif
666 exit(0); 664 exit(0);
667 } 665 }
668 printf("DVD auth sequence seems to be OK.\n"); 666 printf("DVD auth sequence seems to be OK.\n");
669 } 667 }
670 #endif 668 #endif
737 } 735 }
738 //=============== Unknown, exiting... =========================== 736 //=============== Unknown, exiting... ===========================
739 if(file_format==DEMUXER_TYPE_UNKNOWN){ 737 if(file_format==DEMUXER_TYPE_UNKNOWN){
740 printf("============= Sorry, this file format not recognized/supported ===============\n"); 738 printf("============= Sorry, this file format not recognized/supported ===============\n");
741 printf("=== If this file is an AVI, ASF or MPEG stream, please contact the author! ===\n"); 739 printf("=== If this file is an AVI, ASF or MPEG stream, please contact the author! ===\n");
742 #ifdef HAVE_GUI 740 GUI_MSG( mplUnknowFileType )
743 if ( !nogui ) { mplSendMessage( mplUnknowFileType ); usleep( 10000 ); }
744 #endif
745 exit(1); 741 exit(1);
746 } 742 }
747 //====== File format recognized, set up these for compatibility: ========= 743 //====== File format recognized, set up these for compatibility: =========
748 d_audio=demuxer->audio; 744 d_audio=demuxer->audio;
749 d_video=demuxer->video; 745 d_video=demuxer->video;
790 if(a_pos!=-1) break; 786 if(a_pos!=-1) break;
791 } 787 }
792 } 788 }
793 if(v_pos==-1){ 789 if(v_pos==-1){
794 printf("AVI_NI: missing video stream!? contact the author, it may be a bug :(\n"); 790 printf("AVI_NI: missing video stream!? contact the author, it may be a bug :(\n");
795 #ifdef HAVE_GUI 791 GUI_MSG( mplErrorAVINI )
796 if ( !nogui ) { mplSendMessage( mplErrorAVINI ); usleep( 10000 ); }
797 #endif
798 exit(1); 792 exit(1);
799 } 793 }
800 if(a_pos==-1){ 794 if(a_pos==-1){
801 printf("AVI_NI: No audio stream found -> nosound\n"); 795 printf("AVI_NI: No audio stream found -> nosound\n");
802 has_audio=0; 796 has_audio=0;
817 pts_from_bps=1; // force BPS sync! 811 pts_from_bps=1; // force BPS sync!
818 } 812 }
819 } 813 }
820 if(!ds_fill_buffer(d_video)){ 814 if(!ds_fill_buffer(d_video)){
821 printf("AVI: missing video stream!? contact the author, it may be a bug :(\n"); 815 printf("AVI: missing video stream!? contact the author, it may be a bug :(\n");
822 #ifdef HAVE_GUI 816 GUI_MSG( mplAVIErrorMissingVideoStream )
823 if ( !nogui ) { mplSendMessage( mplAVIErrorMissingVideoStream ); usleep( 10000 ); }
824 #endif
825 exit(1); 817 exit(1);
826 } 818 }
827 sh_video=d_video->sh;sh_video->ds=d_video; 819 sh_video=d_video->sh;sh_video->ds=d_video;
828 if(has_audio){ 820 if(has_audio){
829 if(verbose) printf("AVI: Searching for audio stream (id:%d)\n",d_audio->id); 821 if(verbose) printf("AVI: Searching for audio stream (id:%d)\n",d_audio->id);
861 stream_seek(demuxer->stream,demuxer->movi_start); 853 stream_seek(demuxer->stream,demuxer->movi_start);
862 demuxer->idx_pos=0; 854 demuxer->idx_pos=0;
863 // demuxer->endpos=avi_header.movi_end; 855 // demuxer->endpos=avi_header.movi_end;
864 if(!ds_fill_buffer(d_video)){ 856 if(!ds_fill_buffer(d_video)){
865 printf("ASF: missing video stream!? contact the author, it may be a bug :(\n"); 857 printf("ASF: missing video stream!? contact the author, it may be a bug :(\n");
866 #ifdef HAVE_GUI 858 GUI_MSG( mplASFErrorMissingVideoStream )
867 if ( !nogui ) { mplSendMessage( mplASFErrorMissingVideoStream ); usleep( 10000 ); }
868 #endif
869 exit(1); 859 exit(1);
870 } 860 }
871 sh_video=d_video->sh;sh_video->ds=d_video; 861 sh_video=d_video->sh;sh_video->ds=d_video;
872 if(has_audio){ 862 if(has_audio){
873 if(verbose) printf("ASF: Searching for audio stream (id:%d)\n",d_audio->id); 863 if(verbose) printf("ASF: Searching for audio stream (id:%d)\n",d_audio->id);
932 int i=sync_video_packet(d_video); 922 int i=sync_video_packet(d_video);
933 if(i==0x1B3) break; // found it! 923 if(i==0x1B3) break; // found it!
934 if(!i || !skip_video_packet(d_video)){ 924 if(!i || !skip_video_packet(d_video)){
935 if(verbose) printf("NONE :(\n"); 925 if(verbose) printf("NONE :(\n");
936 printf("MPEG: FATAL: EOF while searching for sequence header\n"); 926 printf("MPEG: FATAL: EOF while searching for sequence header\n");
937 #ifdef HAVE_GUI 927 GUI_MSG( mplMPEGErrorSeqHeaderSearch )
938 if ( !nogui ) { mplSendMessage( mplMPEGErrorSeqHeaderSearch ); usleep( 10000 ); }
939 #endif
940 exit(1); 928 exit(1);
941 } 929 }
942 } 930 }
943 if(verbose) printf("OK!\n"); 931 if(verbose) printf("OK!\n");
944 sh_video=d_video->sh;sh_video->ds=d_video; 932 sh_video=d_video->sh;sh_video->ds=d_video;
946 mpeg2_init(); 934 mpeg2_init();
947 // ========= Read & process sequence header & extension ============ 935 // ========= Read & process sequence header & extension ============
948 videobuffer=shmem_alloc(VIDEOBUFFER_SIZE); 936 videobuffer=shmem_alloc(VIDEOBUFFER_SIZE);
949 if(!videobuffer){ 937 if(!videobuffer){
950 printf("Cannot allocate shared memory\n"); 938 printf("Cannot allocate shared memory\n");
951 #ifdef HAVE_GUI 939 GUI_MSG( mplErrorShMemAlloc )
952 if ( !nogui ) { mplSendMessage( mplErrorShMemAlloc ); usleep( 10000 ); }
953 #endif
954 exit(0); 940 exit(0);
955 } 941 }
956 videobuf_len=0; 942 videobuf_len=0;
957 if(!read_video_packet(d_video)){ 943 if(!read_video_packet(d_video)){
958 printf("FATAL: Cannot read sequence header!\n"); 944 printf("FATAL: Cannot read sequence header!\n");
959 #ifdef HAVE_GUI 945 GUI_MSG( mplMPEGErrorCannotReadSeqHeader )
960 if ( !nogui ) { mplSendMessage( mplMPEGErrorCannotReadSeqHeader ); usleep( 10000 ); }
961 #endif
962 exit(1); 946 exit(1);
963 } 947 }
964 if(header_process_sequence_header (picture, &videobuffer[4])) { 948 if(header_process_sequence_header (picture, &videobuffer[4])) {
965 printf ("bad sequence header!\n"); 949 printf ("bad sequence header!\n");
966 #ifdef HAVE_GUI 950 GUI_MSG( mplMPEGErrorBadSeqHeader )
967 if ( !nogui ) { mplSendMessage( mplMPEGErrorBadSeqHeader ); usleep( 10000 ); }
968 #endif
969 exit(1); 951 exit(1);
970 } 952 }
971 if(sync_video_packet(d_video)==0x1B5){ // next packet is seq. ext. 953 if(sync_video_packet(d_video)==0x1B5){ // next packet is seq. ext.
972 videobuf_len=0; 954 videobuf_len=0;
973 if(!read_video_packet(d_video)){ 955 if(!read_video_packet(d_video)){
974 printf("FATAL: Cannot read sequence header extension!\n"); 956 printf("FATAL: Cannot read sequence header extension!\n");
975 #ifdef HAVE_GUI 957 GUI_MSG( mplMPEGErrorCannotReadSeqHeaderExt )
976 if ( !nogui ) { mplSendMessage( mplMPEGErrorCannotReadSeqHeaderExt ); usleep( 10000 ); }
977 #endif
978 exit(1); 958 exit(1);
979 } 959 }
980 if(header_process_extension (picture, &videobuffer[4])) { 960 if(header_process_extension (picture, &videobuffer[4])) {
981 printf ("bad sequence header extension!\n"); 961 printf ("bad sequence header extension!\n");
982 #ifdef HAVE_GUI 962 GUI_MSG( mplMPEGErrorBadSeqHeaderExt )
983 if ( !nogui ) { mplSendMessage( mplMPEGErrorBadSeqHeaderExt ); usleep( 10000 ); }
984 #endif
985 exit(1); 963 exit(1);
986 } 964 }
987 } 965 }
988 // display info: 966 // display info:
989 sh_video->fps=frameratecode2framerate[picture->frame_rate_code]*0.0001f; 967 sh_video->fps=frameratecode2framerate[picture->frame_rate_code]*0.0001f;
1093 if(verbose) printf("vo_debug: query(0x%X) returned 0x%X\n",out_fmt,ret); 1071 if(verbose) printf("vo_debug: query(0x%X) returned 0x%X\n",out_fmt,ret);
1094 if(ret) break; 1072 if(ret) break;
1095 } 1073 }
1096 if(i>=CODECS_MAX_OUTFMT){ 1074 if(i>=CODECS_MAX_OUTFMT){
1097 printf("Sorry, selected video_out device is incompatible with this codec.\n"); 1075 printf("Sorry, selected video_out device is incompatible with this codec.\n");
1098 #ifdef HAVE_GUI 1076 GUI_MSG( mplIncompatibleVideoOutDevice )
1099 if ( !nogui ) { mplSendMessage( mplIncompatibleVideoOutDevice ); usleep( 10000 ); }
1100 #endif
1101 exit(1); 1077 exit(1);
1102 } 1078 }
1103 sh_video->outfmtidx=i; 1079 sh_video->outfmtidx=i;
1104 1080
1105 if(verbose) printf("vo_debug1: out_fmt=0x%08X\n",out_fmt); 1081 if(verbose) printf("vo_debug1: out_fmt=0x%08X\n",out_fmt);
1106 1082
1107 switch(sh_video->codec->driver){ 1083 switch(sh_video->codec->driver){
1108 case 2: { 1084 case 2: {
1109 if(!init_video_codec(sh_video)) { 1085 if(!init_video_codec(sh_video)) {
1110 #ifdef HAVE_GUI 1086 GUI_MSG( mplUnknowError )
1111 if ( !nogui ) { mplSendMessage( mplUnknowError ); usleep( 10000 ); }
1112 #endif
1113 exit(1); 1087 exit(1);
1114 } 1088 }
1115 if(verbose) printf("INFO: Win32 video codec init OK!\n"); 1089 if(verbose) printf("INFO: Win32 video codec init OK!\n");
1116 break; 1090 break;
1117 } 1091 }
1118 case 4: { // Win32/DirectShow 1092 case 4: { // Win32/DirectShow
1119 #ifndef USE_DIRECTSHOW 1093 #ifndef USE_DIRECTSHOW
1120 printf("MPlayer was compiled WITHOUT directshow support!\n"); 1094 printf("MPlayer was compiled WITHOUT directshow support!\n");
1121 #ifdef HAVE_GUI 1095 GUI_MSG( mplCompileWithoutDSSupport )
1122 if ( !nogui ) { mplSendMessage( mplCompileWithoutDSSupport ); usleep( 10000 ); }
1123 #endif
1124 exit(1); 1096 exit(1);
1125 #else 1097 #else
1126 sh_video->our_out_buffer=NULL; 1098 sh_video->our_out_buffer=NULL;
1127 if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, &sh_video->our_out_buffer)){ 1099 if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, &sh_video->our_out_buffer)){
1128 // if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, NULL)){ 1100 // if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, NULL)){
1292 if(video_out->init(sh_video->disp_w,sh_video->disp_h, 1264 if(video_out->init(sh_video->disp_w,sh_video->disp_h,
1293 screen_size_x,screen_size_y, 1265 screen_size_x,screen_size_y,
1294 fullscreen|(vidmode<<1)|(softzoom<<2), 1266 fullscreen|(vidmode<<1)|(softzoom<<2),
1295 title,out_fmt)){ 1267 title,out_fmt)){
1296 printf("FATAL: Cannot initialize video driver!\n"); 1268 printf("FATAL: Cannot initialize video driver!\n");
1297 #ifdef HAVE_GUI 1269 GUI_MSG( mplCantInitVideoDriver )
1298 if ( !nogui ) { mplSendMessage( mplCantInitVideoDriver ); usleep( 10000 ); }
1299 #endif
1300 exit(1); 1270 exit(1);
1301 } 1271 }
1302 if(verbose) printf("INFO: Video OUT driver init OK!\n"); 1272 if(verbose) printf("INFO: Video OUT driver init OK!\n");
1303 1273
1304 fflush(stdout); 1274 fflush(stdout);