comparison mplayer.c @ 692:14a2f35921a0

allow playing from stdin
author arpi_esp
date Thu, 03 May 2001 23:32:56 +0000
parents 617ae66624b3
children 823261fc56b3
comparison
equal deleted inserted replaced
691:3693fd4c4ec2 692:14a2f35921a0
551 stream->start_pos=ret; 551 stream->start_pos=ret;
552 stream->end_pos=ret2; 552 stream->end_pos=ret2;
553 } else { 553 } else {
554 //============ Open plain FILE ============ 554 //============ Open plain FILE ============
555 int len; 555 int len;
556 f=open(filename,O_RDONLY); 556 if(!strcmp(filename,"-")){
557 if(f<0){ printf("File not found: '%s'\n",filename);return 1; } 557 // read from stdin
558 len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET); 558 printf("Reading from stdin...\n");
559 stream=new_stream(f,STREAMTYPE_FILE); 559 f=0; // 0=stdin
560 stream->end_pos=len; 560 stream=new_stream(f,STREAMTYPE_STREAM);
561 } else {
562 f=open(filename,O_RDONLY);
563 if(f<0){ printf("File not found: '%s'\n",filename);return 1; }
564 len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET);
565 stream=new_stream(f,STREAMTYPE_FILE);
566 stream->end_pos=len;
567 }
561 } 568 }
562 569
563 #ifdef HAVE_LIBCSS 570 #ifdef HAVE_LIBCSS
564 if (dvdimportkey) { 571 if (dvdimportkey) {
565 if (dvd_import_key(dvdimportkey)) { 572 if (dvd_import_key(dvdimportkey)) {
656 //sh_video=d_video->sh;sh_video->ds=d_video; 663 //sh_video=d_video->sh;sh_video->ds=d_video;
657 664
658 switch(file_format){ 665 switch(file_format){
659 case DEMUXER_TYPE_AVI: { 666 case DEMUXER_TYPE_AVI: {
660 //---- AVI header: 667 //---- AVI header:
661 read_avi_header(demuxer,index_mode); 668 read_avi_header(demuxer,f?index_mode:-2);
662 stream_reset(demuxer->stream); 669 stream_reset(demuxer->stream);
663 stream_seek(demuxer->stream,demuxer->movi_start); 670 stream_seek(demuxer->stream,demuxer->movi_start);
664 demuxer->idx_pos=0; 671 demuxer->idx_pos=0;
665 demuxer->idx_pos_a=0; 672 demuxer->idx_pos_a=0;
666 demuxer->idx_pos_v=0; 673 demuxer->idx_pos_v=0;
1155 #endif 1162 #endif
1156 1163
1157 #ifdef USE_TERMCAP 1164 #ifdef USE_TERMCAP
1158 load_termcap(NULL); // load key-codes 1165 load_termcap(NULL); // load key-codes
1159 #endif 1166 #endif
1160 getch2_enable(); 1167 if(f) getch2_enable();
1161 1168
1162 //========= Catch terminate signals: ================ 1169 //========= Catch terminate signals: ================
1163 // terminate requests: 1170 // terminate requests:
1164 signal(SIGTERM,exit_sighandler); // kill 1171 signal(SIGTERM,exit_sighandler); // kill
1165 signal(SIGHUP,exit_sighandler); // kill -HUP / xterm closed 1172 signal(SIGHUP,exit_sighandler); // kill -HUP / xterm closed
1634 printf("\n------ PAUSED -------\r");fflush(stdout); 1641 printf("\n------ PAUSED -------\r");fflush(stdout);
1635 while( 1642 while(
1636 #ifdef HAVE_LIRC 1643 #ifdef HAVE_LIRC
1637 lirc_mp_getinput()<=0 && 1644 lirc_mp_getinput()<=0 &&
1638 #endif 1645 #endif
1639 getch2(20)<=0 && mplayer_get_key()<=0){ 1646 (!f || getch2(20)<=0) && mplayer_get_key()<=0){
1640 video_out->check_events(); 1647 video_out->check_events();
1641 } 1648 }
1642 osd_function=OSD_PLAY; 1649 osd_function=OSD_PLAY;
1643 } 1650 }
1644 1651
1651 int c; 1658 int c;
1652 while( 1659 while(
1653 #ifdef HAVE_LIRC 1660 #ifdef HAVE_LIRC
1654 (c=lirc_mp_getinput())>0 || 1661 (c=lirc_mp_getinput())>0 ||
1655 #endif 1662 #endif
1656 (c=getch2(0))>0 || (c=mplayer_get_key())>0) switch(c){ 1663 (f && (c=getch2(0)))>0 || (c=mplayer_get_key())>0) switch(c){
1657 // seek 10 sec 1664 // seek 10 sec
1658 case KEY_RIGHT: 1665 case KEY_RIGHT:
1659 osd_function=OSD_FFW; 1666 osd_function=OSD_FFW;
1660 rel_seek_secs+=10;break; 1667 rel_seek_secs+=10;break;
1661 case KEY_LEFT: 1668 case KEY_LEFT: