[FFmpeg-devel] [PATCH] add timeout to udp_read

Stefano Sabatini stefano.sabatini-lala
Mon Nov 16 01:00:57 CET 2009


On date Sunday 2009-11-15 23:41:08 +0100, Hagen Schmidt encoded:
[...]
> Index: doc/ffplay-doc.texi
> ===================================================================
> --- doc/ffplay-doc.texi	(revision 20541)
> +++ doc/ffplay-doc.texi	(working copy)
> @@ -115,6 +115,8 @@
>  refers to the list of all the input subtitle streams. If it is greater
>  than the number of subtitle streams minus one, then the last one is
>  selected, if it is negative the subtitle rendering is disabled.
> + at item -nto @var{milli_seconds}
> +Set timeout in milliseconds when opening a network stream shall be aborted.
>  @end table

Please make more clear this sentence.

>  @section While playing
> Index: ffplay.c
> ===================================================================
> --- ffplay.c	(revision 20541)
> +++ ffplay.c	(working copy)
> @@ -1864,9 +1864,16 @@
>  /* since we have only one decoding thread, we can use a global
>     variable instead of a thread local variable */
>  static VideoState *global_video_state;
> +static int64_t reference_time = 0;
> +static uint64_t timeout_network = UINT64_MAX;
>  
>  static int decode_interrupt_cb(void)
>  {
> +    if (reference_time && (av_gettime() - reference_time) / 1000 > timeout_network) {
> +        fprintf(stderr, "Timeout for receiving network stream expired after %llu msec\n",
> +                (av_gettime() - reference_time) / 1000);

msec is ambiguous, please specify milliseconds or microseconds.

> +        return 1;
> +    }
>      return (global_video_state && global_video_state->abort_request);
>  }
>  
> @@ -1897,7 +1904,9 @@
>      ap->time_base= (AVRational){1, 25};
>      ap->pix_fmt = frame_pix_fmt;
>  
> +    reference_time = av_gettime();
>      err = av_open_input_file(&ic, is->filename, is->iformat, 0, ap);
> +    reference_time = 0;
>      if (err < 0) {
>          print_error(is->filename, err);
>          ret = -1;
> @@ -2452,6 +2461,13 @@
>      return 0;
>  }
>  
> +static int opt_timeout_network(const char *opt, const char *arg)
> +{
> +    /* reduced max boundary due to the precision of double at UINT64_MAX */
> +    timeout_network = parse_number_or_die(opt, arg, 0, 0, UINT64_MAX - 20000);

Missing the type for parse_number_or_die(), I suppose it is OPT_INT64.

[...]

Regards.
-- 
FFmpeg = Foolish and Forgiving Multimedia Patchable Easy Gargoyle



More information about the ffmpeg-devel mailing list