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

Hagen Schmidt kragen
Mon Sep 14 22:29:53 CEST 2009


On 11.09.2009 at 02:43, Michael Niedermayer wrote:
[...]
> >  doc/ffplay-doc.texi |    3 +++
> >  ffplay.c            |   11 ++++++++++-
> >  2 files changed, 13 insertions(+), 1 deletion(-)
> > b63886a8e1ea76ca2c5dab7f0ef9d3ab5a96cdd2  timeout.diff
> > Index: ffplay.c
> > =================================================================
> >== --- ffplay.c	(Revision 19799)
> > +++ ffplay.c	(Arbeitskopie)
> > @@ -1863,10 +1863,14 @@
> >  /* 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 int timeout_network = 0;
> > +static int timeout_expired = 0;
> >
> >  static int decode_interrupt_cb(void)
> >  {
> > -    return (global_video_state &&
> > global_video_state->abort_request); +    return
> > (global_video_state && global_video_state->abort_request) || +   
> >        (timeout_expired = reference_time && timeout_network &&
> > av_gettime() - reference_time > timeout_network * 1000000); }
> >
> >  /* this thread gets the stream from the disk or the network */
> > @@ -1896,8 +1900,12 @@
> >      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) {
> > +        if (timeout_expired)
> > +            fprintf(stderr, "Timeout expired during opening
> > network stream after %i seconds\n", timeout_network);
> 
> the error message could be printed by decode_interrupt_cb()
> nicer if the code is used more than once ...
ok, done

> [...]
> 
> > Index: doc/ffplay-doc.texi
> > =================================================================
> >== --- doc/ffplay-doc.texi	(Revision 19799)
> > +++ doc/ffplay-doc.texi	(Arbeitskopie)
> > @@ -102,6 +102,9 @@
> >  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{seconds}
> > +Set timeout in seconds when opening a network stream shall be
> > aborted. +Default is 0 which waits endlessly.
> 
> seconds seems like a somewhat big unit for a timeout
ok, changed unit to milliseconds.
Thanks for all hints.

Hagen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: timeout.diff
Type: text/x-patch
Size: 2463 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090914/9f388133/attachment.bin>



More information about the ffmpeg-devel mailing list