SsrcGenerator { public static long generateSsrc() { UUID uuid = UUID.randomUUID(); long leastSignificantBits = uuid.getLeastSignificantBits(); byte[] data = uIntLongToByteWord(leastSignificantBits); return bytesToUIntLong(data, 0); }  static long generateSsrc(); static final int MAX_SIZE; }
@Test public void testUniquenessAndSize() { int iterations = 1000; List<Long> ssrcs = new ArrayList<Long>(iterations); for (int i = 0; i < iterations; i++) { long ssrc = SsrcGenerator.generateSsrc(); int size = Long.SIZE - Long.numberOfLeadingZeros(ssrc); Assert.assertFalse(ssrcs.contains(Long.valueOf(ssrc))); Assert.assertTrue(SsrcGenerator.MAX_SIZE >= size); ssrcs.add(ssrc); } }