[FFmpeg-devel] AVRandomState usage in ffserver/RTP/RTSP
Stefano Sabatini
stefano.sabatini-lala
Thu Feb 5 20:43:22 CET 2009
On date Monday 2009-01-26 21:13:08 +0100, Stefano Sabatini encoded:
> On date Wednesday 2009-01-21 22:26:30 +0100, Stefano Sabatini encoded:
> > On date Wednesday 2009-01-21 21:13:49 +0100, Michael Niedermayer encoded:
> > > On Wed, Jan 21, 2009 at 08:21:58PM +0100, Stefano Sabatini wrote:
> > > > On date Tuesday 2009-01-20 12:01:36 -0800, Baptiste Coudurier encoded:
> > > > > Stefano Sabatini wrote:
> > > > > > On date Monday 2009-01-19 00:18:04 +0100, Stefano Sabatini encoded:
> > > > > >> On date Tuesday 2009-01-06 22:50:44 +0100, Stefano Sabatini encoded:
> > > > > > [...]
> > > > > >>> Index: ffmpeg/ffserver.c
> > > > > >>> ===================================================================
> > > > > >>> --- ffmpeg.orig/ffserver.c 2009-01-05 17:24:43.000000000 +0100
> > > > > >>> +++ ffmpeg/ffserver.c 2009-01-05 17:31:35.000000000 +0100
> > > > > >>> @@ -4468,6 +4468,7 @@
> > > > > >>> int main(int argc, char **argv)
> > > > > >>> {
> > > > > >>> struct sigaction sigact;
> > > > > >>> + struct timeval tv;
> > > > > >>>
> > > > > >>> av_register_all();
> > > > > >>>
> > > > > >>> @@ -4483,7 +4484,8 @@
> > > > > >>>
> > > > > >>> unsetenv("http_proxy"); /* Kill the http_proxy */
> > > > > >>>
> > > > > >>> - av_random_init(&random_state, av_gettime() + (getpid() << 16));
> > > > > >>> + gettimeofday(&tv, NULL);
> > > > > >>> + av_random_init(&random_state, tv.tv_usec);
> > > > > >>>
> > > > > >>> memset(&sigact, 0, sizeof(sigact));
> > > > > >>> sigact.sa_handler = handle_child_exit;
> > > > > >> Ping?
> > > > > >
> > > > > > Ping2.
> > > > > >
> > > > >
> > > > > I'd say it's better, yes, any other opinion ?
> > > >
> > > > I'd say if it's OK with you and there are no better ideas I'll
> > > > apply it in a week.
> > >
> > > i suggest /dev/(u)random, if its unavailable something less good can always
> > > be used as fallback
> >
> > Uh, what about this?
> >
> > Regards.
> > --
> > FFmpeg = Frightening & Fostering Moronic Prodigious Evanescent Gadget
>
> > Index: ffserver.c
> > ===================================================================
> > --- ffserver.c (revision 16713)
> > +++ ffserver.c (working copy)
> > @@ -4467,6 +4467,24 @@
> > { NULL },
> > };
> >
> > +static unsigned int get_random_uint()
> > +{
> > + struct timeval tv;
> > + unsigned int ret;
> > + int size = sizeof(ret);
> > + int fd = open("/dev/urandom", O_RDONLY);
> > +
> > + if (fd < 0 || read(fd, &ret, size) < size) {
> > + /* cannot read from /dev/urandom, fallback to timeval microseconds */
> > + gettimeofday(&tv, NULL);
> > + ret = tv.tv_usec;
> > + }
> > + if (fd >= 0)
> > + close(fd);
> > +
> > + return ret;
> > +}
> > +
> > int main(int argc, char **argv)
> > {
> > struct sigaction sigact;
> > @@ -4485,7 +4503,7 @@
> >
> > unsetenv("http_proxy"); /* Kill the http_proxy */
> >
> > - av_random_init(&random_state, av_gettime() + (getpid() << 16));
> > + av_random_init(&random_state, get_random_uint());
> >
> > memset(&sigact, 0, sizeof(sigact));
> > sigact.sa_handler = handle_child_exit;
>
> Ping.
Ping2.
Rethinking at it, maybe something more general like:
int av_random_write(uint8_t *dst, unsigned int *dst_size);
would be more appropriate?
Regards.
--
FFmpeg = Fierce Fantastic MultiPurpose Energized Gorilla
More information about the ffmpeg-devel
mailing list