[FFmpeg-devel] av_open_input_file

Stefano Sabatini stefano.sabatini-lala
Sat Dec 11 10:22:46 CET 2010


On date Friday 2010-12-10 16:43:04 -0800, Fabrizio Milo aka misto encoded:
> Then the patch is much easier:
> 
> diff --git a/libavformat/avio.c b/libavformat/avio.c
> index 9a4d735..33e6e58 100644
> --- a/libavformat/avio.c
> +++ b/libavformat/avio.c
> @@ -190,7 +190,7 @@ int url_alloc(URLContext **puc, const char
> *filename, int flags)
>          up = up->next;
>      }
>      *puc = NULL;
> -    return AVERROR(ENOENT);
> +    return AVERROR(ENOSYS);
>  }
> 
>  int url_open(URLContext **puc, const char *filename, int flags)
> 
> I would go with ENOSYS: operation not supported.
> 
> ENOENT will and should be returned by the protocol->open() function
> 
> We are allocating memory here not validating the data itself.

Consider the case: url_alloc(&uc, "foo:bar.mov", flags)

this may fail either because:
1) the protocol "foo" exists but is not registered
2) the protocol "foo" doesn't exist at all

in the first case we should use ENOSYS, in the second maybe EINVAL is
better as it may be a *configuration* error of the user supplying
invalid parameters.

The problem is that url_alloc() has no way to distinguish between 1)
and 2), so I suppose it's safe to use ENOSYS (but I still believe an
UNKNOWN_FORMAT may help in this case).
-- 
FFmpeg = Fabulous and Foolish Magnificient Purposeless Enigmatic Guru



More information about the ffmpeg-devel mailing list