[FFmpeg-devel] [PATCH] Make libavformat/avio.c:url_open return EILSEQ error code in case of unrecognized protocol prefix
Stefano Sabatini
stefano.sabatini-lala
Thu Oct 18 10:32:21 CEST 2007
On date Wednesday 2007-10-17 10:09:16 +0100, M?ns Rullg?rd encoded:
>
> Stefano Sabatini wrote:
> > On date Tuesday 2007-10-16 22:07:23 +0200, Michael Niedermayer encoded:
> > [...]
> >> > Suggested log: $subject
> >> >
> >> > Rationale: in avcodec.h are defined the various error codes.
> >> >
> >> > ENOENT corresponds to the error:
> >> > "No such file or directory."
> >> >
> >> > which doesn't seem really descriptive about the error encountered in
> >> > this case (unrecognized protocol).
> >> >
> >> > EILSEQ corresponds to the error
> >> > "unknown format."
> >> >
> >> > and seems more adequate in this case.
> >> >
> >> > This patch also indirectly changes the error message issued, so we'll
> >> > have now:
> >> >
> >> > stefano at geppetto ~/s/m/samples> ffmpeg -i foo:movie.avi
> >> > [...]
> >> > foo:movie.avi: Unknown format
> >> >
> >> > rather than:
> >> > stefano at geppetto ~/s/m/samples> ffmpeg -i foo:movie.avi
> >> > FFmpeg version SVN-r10755, Copyright (c) 2000-2007 Fabrice Bellard, et al.
> >> > [...]
> >> > foo:movie.avi: No such file or directory
> >>
> >> besides the question about appropriateness of EILSEQ
> >> (Invalid or incomplete multibyte or wide character)
> >> "Unknown format" is hardly better than "No such file or directory"
> >
> > Could you suggest a better error code to use, or should we define a
> > new one?
>
> ENOENT seems perfectly reasonable to me. There is after all no such
> file, or there would be no error.
This isn't correct, if we have a file named like "foo:movie.avi" and
we try to open it ffmpeg will tell it doesn't exist.
The cause of the problem in this case is the fact that url_open can't
recognize the protocol prefix, so it should just tell it.
I also proposed as my first solution to try to open the file using the
file protocol if the protocol string fails to be recognized as in
"foo:movie.avi", that is to consider it exactly as it was
"file:foo:movie.avi, but I don't consider that a clean solution.
> EINVAL could perhaps also be considered correct in this case.
> EILSEQ is certainly wrong.
EILSEQ used in the sense of "Invalid or incomplete multibyte or wide
character" is certainly wrong, EINVAL in the sense "invalid data
found" (like in avcodec.h) isn't completely exact (the data in the
file could be just right, the problem is that we can't simply read
it or the protocol don't exist).
Regards.
--
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)
More information about the ffmpeg-devel
mailing list