Пример #1
0
  @Test
  public void testDiffTimestamps() {
    int a;
    int b;

    a = 0;
    b = 1;
    assertEquals(-1, RTMPUtils.diffTimestamps(a, b));
    assertEquals(1, RTMPUtils.diffTimestamps(b, a));

    a = Integer.MAX_VALUE;
    b = Integer.MIN_VALUE;
    assertEquals(-1, RTMPUtils.diffTimestamps(a, b));
    assertEquals(1, RTMPUtils.diffTimestamps(b, a));

    a = Integer.MAX_VALUE;
    b = 0;
    assertEquals(Integer.MAX_VALUE, RTMPUtils.diffTimestamps(a, b));
    assertEquals(-Integer.MAX_VALUE, RTMPUtils.diffTimestamps(b, a));

    a = -1;
    b = 0;
    assertEquals(0xFFFFFFFFL, RTMPUtils.diffTimestamps(a, b));
    assertEquals(-0xFFFFFFFFL, RTMPUtils.diffTimestamps(b, a));

    a = Integer.MIN_VALUE;
    b = 0;
    assertEquals(0x80000000L, RTMPUtils.diffTimestamps(a, b));
    assertEquals(-0x80000000L, RTMPUtils.diffTimestamps(b, a));
  }
Пример #2
0
  public void testDecodingHeader() {

    if (log.isDebugEnabled()) {
      log.debug("Testing");
      /*
      log.debug(""+(0x03 >> 6));
      log.debug(""+(0x43 >> 6));
      log.debug(""+(0x83 >> 6));
      log.debug(""+((byte)(((byte)0xC3) >> 6)));
      */
    }
    byte test;
    test = 0x03;
    if (log.isDebugEnabled()) {
      log.debug(HexDump.byteArrayToHexString(new byte[] {test}));
      log.debug("" + test);
      log.debug("" + RTMPUtils.decodeHeaderSize(test, 1));
    }
    assertEquals(0, RTMPUtils.decodeHeaderSize(test, 1));
    test = (byte) (0x43);
    if (log.isDebugEnabled()) {
      log.debug(HexDump.byteArrayToHexString(new byte[] {test}));
      log.debug("" + test);
      log.debug("" + RTMPUtils.decodeHeaderSize(test, 1));
    }
    assertEquals(1, RTMPUtils.decodeHeaderSize(test, 1));
    test = (byte) (0x83);
    if (log.isDebugEnabled()) {
      log.debug(HexDump.byteArrayToHexString(new byte[] {test}));
      log.debug("" + test);
      log.debug("" + RTMPUtils.decodeHeaderSize(test, 1));
    }
    assertEquals(-2, RTMPUtils.decodeHeaderSize(test, 1));
    test = (byte) (0xC3 - 256);
    if (log.isDebugEnabled()) {
      log.debug(HexDump.byteArrayToHexString(new byte[] {test}));
      log.debug("" + test);
      log.debug("" + RTMPUtils.decodeHeaderSize(test, 1));
    }
    assertEquals(-1, RTMPUtils.decodeHeaderSize(test, 1));
  }