[FFmpeg-devel] [PATCH] avformat: added named pipe protocol

Martin Sliwka martin.sliwka at gmail.com
Fri Jun 15 15:05:06 CEST 2012


Dne 15.6.2012 11:32, Martin Sliwka napsal(a):
> Dne 15.6.2012 2:52, Michael Niedermayer napsal(a):
>> On Thu, Jun 14, 2012 at 01:10:30PM +0200, Martin Sliwka wrote:
>>> The new 'npipe' protocol is copy of 'file' protocol with two 
>>> modifications:
>>> 1) URLProtocol::url_seek is not set
>>> 2) URLProtocol::url_open is set to npipe_open(...) which is same as
>>> file_open(...)
>>> except for protocol name it stripes from file name.
>>>
>>> New protocol is also very similar to already included 'pipe' protocol
>>> which unfortunately can not be safely modified without breaking 
>>> backward
>>> compatibility.
>>>
>>> Reason for this change is that named pipes are not wokring as
>>> seekable inputs.
>>> Problem is that ffio_limit(...) incorrectly limits requested read
>>> size because
>>> avio_size(...) (it's fstat(...) in file_seek(...) in fact) can not
>>> report correct
>>> file size.
>> the correct solution is to check if its a fifo and return 0 instead of
>> the nonsense value from fstat()
>> a patch doing that is welcome
>>
>> also thanks for the testcase
>>
>
> Ok, after some self-education in linux-way of doing things I made this 
> simple and straightforward patch. I tested it on Windows and it works 
> well. Some testing should be made on linux also but I'm unable to get 
> linux version compiled.
>
> Martin
>
> ---
>  libavformat/file.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/libavformat/file.c b/libavformat/file.c
> index db79b5c..59b755d 100644
> --- a/libavformat/file.c
> +++ b/libavformat/file.c
> @@ -99,7 +99,7 @@ static int64_t file_seek(URLContext *h, int64_t pos, 
> int whence)
>      if (whence == AVSEEK_SIZE) {
>          struct stat st;
>          int ret = fstat(fd, &st);
> -        return ret < 0 ? AVERROR(errno) : st.st_size;
> +        return ret < 0 ? AVERROR(errno) : (S_ISFIFO(st.st_mode) ? 0 : 
> st.st_size);
>      }
>      return lseek(fd, pos, whence);
>  }
> -- 
> 1.7.4.1
>

I did tests on Ubuntu 11.04 and fstat(...) is already reporting zero 
size on object created using mkfifo(...) so my patch should be safe.

Would this be enought or there are some other tests required?

Regards,

Martin


More information about the ffmpeg-devel mailing list