diff --git a/asfheader.c b/asfheader.c index 5c32362698..aa036b528d 100644 --- a/asfheader.c +++ b/asfheader.c @@ -180,6 +180,9 @@ if(verbose){ // case 0x33000890: return "guid_index_chunk"; } // switch GUID + + if((*((unsigned int*)&objh.guid))==0x75b22636) break; // movi chunk + if(!stream_seek(demuxer->stream,endpos)) break; } // while EOF diff --git a/aviheader.c b/aviheader.c index 8870ce23d7..63712a70fe 100644 --- a/aviheader.c +++ b/aviheader.c @@ -49,6 +49,7 @@ while(1){ demuxer->movi_start=stream_tell(demuxer->stream); demuxer->movi_end=demuxer->movi_start+len; if(verbose>=1) printf("Found movie at 0x%X - 0x%X\n",demuxer->movi_start,demuxer->movi_end); + if(index_mode==-2) break; // reading from non-seekable source (stdin) len=(len+1)&(~1); stream_skip(demuxer->stream,len); } diff --git a/mplayer.c b/mplayer.c index 3340e376ae..a9b68fd486 100644 --- a/mplayer.c +++ b/mplayer.c @@ -553,11 +553,18 @@ if(vcd_track){ } else { //============ Open plain FILE ============ int len; - f=open(filename,O_RDONLY); - if(f<0){ printf("File not found: '%s'\n",filename);return 1; } - len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET); - stream=new_stream(f,STREAMTYPE_FILE); - stream->end_pos=len; + if(!strcmp(filename,"-")){ + // read from stdin + printf("Reading from stdin...\n"); + f=0; // 0=stdin + stream=new_stream(f,STREAMTYPE_STREAM); + } else { + f=open(filename,O_RDONLY); + if(f<0){ printf("File not found: '%s'\n",filename);return 1; } + len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET); + stream=new_stream(f,STREAMTYPE_FILE); + stream->end_pos=len; + } } #ifdef HAVE_LIBCSS @@ -658,7 +665,7 @@ d_dvdsub=demuxer->sub; switch(file_format){ case DEMUXER_TYPE_AVI: { //---- AVI header: - read_avi_header(demuxer,index_mode); + read_avi_header(demuxer,f?index_mode:-2); stream_reset(demuxer->stream); stream_seek(demuxer->stream,demuxer->movi_start); demuxer->idx_pos=0; @@ -1157,7 +1164,7 @@ int osd_last_pts=-303; #ifdef USE_TERMCAP load_termcap(NULL); // load key-codes #endif - getch2_enable(); + if(f) getch2_enable(); //========= Catch terminate signals: ================ // terminate requests: @@ -1636,7 +1643,7 @@ switch(sh_video->codec->driver){ #ifdef HAVE_LIRC lirc_mp_getinput()<=0 && #endif - getch2(20)<=0 && mplayer_get_key()<=0){ + (!f || getch2(20)<=0) && mplayer_get_key()<=0){ video_out->check_events(); } osd_function=OSD_PLAY; @@ -1653,7 +1660,7 @@ switch(sh_video->codec->driver){ #ifdef HAVE_LIRC (c=lirc_mp_getinput())>0 || #endif - (c=getch2(0))>0 || (c=mplayer_get_key())>0) switch(c){ + (f && (c=getch2(0)))>0 || (c=mplayer_get_key())>0) switch(c){ // seek 10 sec case KEY_RIGHT: osd_function=OSD_FFW; diff --git a/stream.c b/stream.c index dcfdaab74c..5f69194f16 100644 --- a/stream.c +++ b/stream.c @@ -24,6 +24,7 @@ int stream_fill_buffer(stream_t *s){ if(s->eof){ s->buf_pos=s->buf_len=0; return 0; } switch(s->type){ case STREAMTYPE_FILE: + case STREAMTYPE_STREAM: len=read(s->fd,s->buffer,STREAM_BUFFER_SIZE);break; case STREAMTYPE_VCD: #ifdef VCD_CACHE @@ -55,6 +56,7 @@ if(verbose>=3){ switch(s->type){ case STREAMTYPE_FILE: + case STREAMTYPE_STREAM: newpos=pos&(~(STREAM_BUFFER_SIZE-1));break; case STREAMTYPE_VCD: newpos=(pos/VCD_SECTOR_DATA)*VCD_SECTOR_DATA;break; @@ -63,18 +65,29 @@ if(verbose>=3){ pos-=newpos; if(newpos==0 || newpos!=s->pos){ - s->pos=newpos; // real seek switch(s->type){ case STREAMTYPE_FILE: + s->pos=newpos; // real seek if(lseek(s->fd,s->pos,SEEK_SET)<0) s->eof=1; break; case STREAMTYPE_VCD: + s->pos=newpos; // real seek #ifdef VCD_CACHE vcd_cache_seek(s->pos/VCD_SECTOR_DATA); #else vcd_set_msf(s->pos/VCD_SECTOR_DATA); #endif break; + case STREAMTYPE_STREAM: + //s->pos=newpos; // real seek + if(newpospos){ + printf("Cannot seek backward in linear streams!\n"); + return 1; + } + while(s->pos2*STREAM_BUFFER_SIZE){ + if(len<0 || (len>2*STREAM_BUFFER_SIZE && s->type!=STREAMTYPE_STREAM)){ // negative or big skip! stream_seek(s,stream_tell(s)+len); return;