[FFmpeg-devel] [PATCH] ffserver: improve error feedback in open_input_stream()

Stefano Sabatini stefasab at gmail.com
Thu Nov 28 23:10:47 CET 2013


On date Thursday 2013-11-28 21:29:15 +0100, Clément Bœsch encoded:
> On Thu, Nov 28, 2013 at 09:07:04PM +0100, Stefano Sabatini wrote:
> > ---
> >  ffserver.c | 25 ++++++++++++++++---------
> >  1 file changed, 16 insertions(+), 9 deletions(-)
> > 
> > diff --git a/ffserver.c b/ffserver.c
> > index 0243a98..342c5fa 100644
> > --- a/ffserver.c
> > +++ b/ffserver.c
> > @@ -2184,8 +2184,10 @@ static int open_input_stream(HTTPContext *c, const char *info)
> >          buf_size = FFM_PACKET_SIZE;
> >          /* compute position (absolute time) */
> >          if (av_find_info_tag(buf, sizeof(buf), "date", info)) {
> > -            if ((ret = av_parse_time(&stream_pos, buf, 0)) < 0)
> > +            if ((ret = av_parse_time(&stream_pos, buf, 0)) < 0) {
> > +                http_log("Invalid date specification '%s' for stream\n", buf);
> >                  return ret;
> > +            }
> >          } else if (av_find_info_tag(buf, sizeof(buf), "buffer", info)) {
> >              int prebuffer = strtol(buf, 0, 10);
> >              stream_pos = av_gettime() - prebuffer * (int64_t)1000000;
> > @@ -2196,18 +2198,22 @@ static int open_input_stream(HTTPContext *c, const char *info)
> >          buf_size = 0;
> >          /* compute position (relative time) */
> >          if (av_find_info_tag(buf, sizeof(buf), "date", info)) {
> > -            if ((ret = av_parse_time(&stream_pos, buf, 1)) < 0)
> > +            if ((ret = av_parse_time(&stream_pos, buf, 1)) < 0) {
> > +                http_log("Invalid date specification '%s' for stream\n", buf);
> >                  return ret;
> > +            }
> >          } else
> >              stream_pos = 0;
> >      }
> > -    if (input_filename[0] == '\0')
> > -        return -1;
> > +    if (!input_filename[0]) {
> > +        http_log("No filename was specified for stream\n");
> > +        return AVERROR(EINVAL);
> > +    }
> >  
> 

> Can this be triggered if there is [File ""], or really if there are not
> File entry? If that's the first case it should be an error such as
> "Invalid empty file name in feed".

In that case it would abort with:
Thu Nov 28 23:08:46 2013 Could not open output feed file ''

The check is probably redundant, but I kept it because removing it
would be unrelated to the patch.

> 
> >      /* open stream */
> >      if ((ret = avformat_open_input(&s, input_filename, c->stream->ifmt, &c->stream->in_opts)) < 0) {
> > -        http_log("could not open %s: %d\n", input_filename, ret);
> > -        return -1;
> > +        http_log("Could not open input %s: %s\n", input_filename, av_err2str(ret));
> > +        return ret;
> 
> input '%s' for consistency.

Fixed.

> 
> >      }
> >  
> >      /* set buffer size */
> > @@ -2215,10 +2221,11 @@ static int open_input_stream(HTTPContext *c, const char *info)
> >  
> >      s->flags |= AVFMT_FLAG_GENPTS;
> >      c->fmt_in = s;
> > -    if (strcmp(s->iformat->name, "ffm") && avformat_find_stream_info(c->fmt_in, NULL) < 0) {
> > -        http_log("Could not find stream info '%s'\n", input_filename);
> > +    if (strcmp(s->iformat->name, "ffm") &&
> > +        (ret = avformat_find_stream_info(c->fmt_in, NULL)) < 0) {
> > +        http_log("Could not find stream info for input '%s'\n", input_filename);
> >          avformat_close_input(&s);
> > -        return -1;
> > +        return ret;
> 
> Rest looks OK

Will push it soon, thanks.
-- 
FFmpeg = Fantastic and Furious Multipurpose Proud Enigmatic Geek


More information about the ffmpeg-devel mailing list