Opened 13 years ago

Closed 12 years ago

#653 closed defect (fixed)

ffplay freezes every 30 seconds when playing rtsp stream with authentication

Reported by: imbens Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Using ffplay on Win32 I am trying to play an h264 rtsp stream from an Axis camera. ffplay freezes for approx. 2 seconds every 30 seconds. When looking at the stack av_get_random_seed seems the culprit.
Every 30 seconds ffplay wants to send a keep-alive message. ff_rtsp_send_cmd_with_content_async calls ff_http_auth_create_response. ff_http_auth_create_response calls make_digest_auth. make_digest_auth calls av_get_random_seed. av_get_random_seed calls get_generic_seed. It looks like get_generic_seed takes approx. 1 second to complete.

Change History (7)

comment:1 by reimar, 13 years ago

That seems not surprising, with the low clock precision in Windows that probably can take some time.
Calling timeBeginPeriod(1); somewhere might improve things, but is a hack.
The proper solution would be trying to dynamically load and use SystemFunction036 (aka RtlGenRandom) from advapi32.dll:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694%28v=vs.85%29.aspx

comment:2 by Michael Niedermayer, 13 years ago

that may help getting seeds quicker but idependant of this
no code should call the seed function ad infinitum
it rather should call it to get a seed and use this to seed a PRNG, secure or insecure one depending on the need.

comment:3 by reimar, 13 years ago

There is no such thing as a "secure PRNG", particularly those in lavu have a laughably small state and without regular re-seeding are not suitable even for hash-based authentication IMO.
Plus, it is used relatively rarely in normal use cases.
Thus I consider the code correct in using that function.

comment:4 by reimar, 13 years ago

Forgot to say: even a more suitable PRNG would be not much of a help, you'd still have to initialize the state.
A 50 second startup delay can hardly be considered any less broken than a 2 second hang every 30 seconds.
A different solution is of course to generate the keep-alive asynchronous from a separate thread, but that seems quite messy.

in reply to:  3 comment:5 by Michael Niedermayer, 13 years ago

Replying to reimar:

There is no such thing as a "secure PRNG", particularly those in lavu have a laughably small state and without regular re-seeding are not suitable even for hash-based authentication IMO.

I wonder if you dont maybe overestimate the security of concatenating 2 32bit seeds of my generic seed generator compared to a better seeded SHA1 based PRNG.

comment:6 by Michael Niedermayer, 13 years ago

Of course if you can get strong random numbers quickly on all supported platforms then calling the seed function every 30seconds is no problem.

comment:7 by Michael Niedermayer, 12 years ago

Resolution: fixed
Status: newclosed

This should have been fixed by Martin Storsjö in 1093383d6cf7112d54b849e29c739e957d157b25

Note: See TracTickets for help on using tickets.