|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.fmj.media.rtp.SSRCGenerator
public class SSRCGenerator
This class was written to generate different kinds of pseudo-random numbers, especially Synchronization SouRCes numbers (SSRC). An SSRC is a 32-bit numeric SSRC identifier carried in the RTP header so as not to be dependent upon the network address, and identifies the source of a stream of RTP packets. All packets from a synchronization source form part of the same timing and sequence number space. The RFC requests those numbers to be random enough to avoid synchronization of the PRNGs and a consequent collision of SSRCs. To avoid this problem, we generate the SSRC with an MD5 hash of information about the local participant. This class is also used as a normal pseudo-random number generator (PRNG) and uses SecureRandom to provide secure seeds to generate good series of random numbers.
Constructor Summary | |
---|---|
SSRCGenerator()
Creates an instance of SSRC Generator. |
Method Summary | |
---|---|
int |
generate()
Generates a random integer using Math.random() to get a fast generation, but SecureRandom to give a good seed to Math.random() and garanties a good randomness. |
int |
generate(int salt)
Generates a random integer using Math.random() to get a fast generation, but SecureRandom to give a good seed to Math.random() and garanties a good randomness. |
static long |
getSecuredSeed()
Generates a secured seed that can be used to initialize a PRNG (like Math.random). |
static byte[] |
getSecuredSeed(int n)
Generates a secured seed that can be used to initialize a PRNG (like Math.random). |
static int |
nextSecuredRandomInt()
Returns an integer generated in a very secure way. |
static long |
nextSecuredRandomLong()
Returns a long generated in a very secure way. |
static short |
nextSecuredRandomShort()
Returns a short integer generated in a very secure way. |
double |
random()
Generates a random double between 0 and 1. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SSRCGenerator()
Method Detail |
---|
public int generate()
public int generate(int salt)
salt
- The "salt" argument is used if we have to generate several SSRCs in
a very close succession (the hashs could be the same depending since
the standard Random PRNG is time-based). This situation is very
unlikely to happen.
public static long getSecuredSeed()
public static byte[] getSecuredSeed(int n)
n
- number of bytes on which to generate the seed
public static long nextSecuredRandomLong()
public static int nextSecuredRandomInt()
public static short nextSecuredRandomShort()
public double random()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |