[FFmpeg-devel] Correctly fill the SSRC field in RTP packets
Tue Mar 25 16:02:55 CET 2008
On Tue, Mar 25, 2008 at 03:18:35PM +0100, Luca Abeni wrote:
> Reimar D?ffinger wrote:
> >> I think this would require some kind of "global context" (shared
> >> between all the AVFormatContexts) for the counter, right? Wouldn't
> >> this break multithreaded applications?
> > I think it might be better to have a kind of "muxer user data" field in
> > AVFormatContext and use that to set all this kind of stuff, or at least
> > something like that...
> In this way, a user would have to fill the field with a proper value,
> right? I do not like this idea too much, because I believe a user does
> not want to cope with the details of SSRC and similar stuff, but the
> library should select a reasonable value.
That is assuming the library _can_ select a reasonable value.
> > If it really was random, that was bad because it modifies global state,
> > and a library should not do that. Also (being pedantic) a random number
> > in no way guarantees uniqueness
> I am not going to propose to use random values (in fact, I do not use
> random() in my patch :), but I suspect the point of using random is that
> if the random numbers generator is good enough the probability to have
> unique SSRCs is very high.
Well, I think that with 32 bit the probability is high enough that you
can actually expect it to happen to users.
> My patch does not ensure uniqueness either, but it ensures that the SSRC
> is unique inside a session (which is the reasonable thing to guarantee,
> in my opinion).
Actually, on 64 bit systems even your patch does not ensure this.
IMHO a 32 bit value is just too small to ensure a good level of uniqueness
without global assignment of those numbers.
Note also, that doing this assignment in the rtp muxer will cause quite
some pain if someone wants to e.g. combine a premuxed rtp stream sent
directly with one created on-the-fly with the rtpmuxer (assuming this is
possible, I don't really know that...).
I think that ideally the streaming layer should set ssrc, but I see no
usable way to do that...
More information about the ffmpeg-devel