Package com.xuggle.ferry

Examples of com.xuggle.ferry.IBuffer


    {
      directByteBuffer.put(i, (byte)i);
    }
   
    //
    IBuffer ibuf = IBuffer.make(null, directByteBuffer, 0, numBytes);
    assertNotNull(ibuf);
   
    ByteBuffer outputDirectByteBuffer = ibuf.getByteBuffer(0, numBytes);
    assertNotNull(numBytes);
    assertEquals(numBytes, outputDirectByteBuffer.capacity());
    for(int i = 0; i < numBytes; i++)
    {
      assertEquals(i, outputDirectByteBuffer.get(i));
View Full Code Here


    {
      directByteBuffer.put(i, (byte)i);
    }
   
    //
    IBuffer ibuf = IBuffer.make(null, directByteBuffer, 0, numBytes);
    assertNotNull(ibuf);
   
    ByteBuffer outputDirectByteBuffer = ibuf.getByteBuffer(0, numBytes);
    assertNotNull(numBytes);
    assertEquals(numBytes, outputDirectByteBuffer.capacity());
    for(int i = 0; i < numBytes; i++)
    {
      assertEquals(i, outputDirectByteBuffer.get(i));
View Full Code Here

   * will occur.
   */
  @Test
  public void testNoLeakingMemoryOnDirectAccess()
  {
    IBuffer buf = IBuffer.make(null, 1024*1024); // 1 MB
    assertNotNull(buf);
    for(int i = 0; i < 100000; i++)
    {
      java.nio.ByteBuffer nativeBytes = buf.getByteBuffer(0, buf.getBufferSize());
      // and we do nothing with the outBytes
      assertEquals(nativeBytes.limit(), buf.getBufferSize());
      nativeBytes = null;
    }
  }
View Full Code Here

   * scope and is collected.
   */
  @Test(timeout=5000)
  public void testDirectByteBufferCanBeAccessedAfterIBufferDisappears()
  {
    IBuffer buf = IBuffer.make(null, 1024*1024); // 1 MB
    assertNotNull(buf);
   
    assertEquals(1, buf.getCurrentRefCount());

    java.nio.ByteBuffer jbuf = buf.getByteBuffer(0, buf.getBufferSize());
    assertNotNull(buf);
   
    // now release the reference
    buf.delete();
    buf = null;

    // in versions prior to 1.22, this would have caused a hard
    // crash, but with 1.22 the getByteBuffer should have incremented
    // the native ref count until this java ByteBuffer gets collected
View Full Code Here

   * returned ByteBuffer to native order
   */
  @Test
  public void testByteOrderIsCorrect()
  {
    IBuffer buf = IBuffer.make(null, 1024*1024); // 1 MB
    assertNotNull(buf);
   
    assertEquals(1, buf.getCurrentRefCount());

    java.nio.ByteBuffer jbuf = buf.getByteBuffer(0, buf.getBufferSize());
    assertNotNull(buf);
   
    // Set 4 bytes that have a pattern that is reversible.  On a big
    // endian machine this is FOO and on a little endian it's BAR
    jbuf.put(0, (byte)0xFF);
View Full Code Here

  }
 
  @Test
  public void testGetInvalidArgs()
  {
    IBuffer buf = IBuffer.make(null, 1);
   
    byte[] in = new byte[]{ 0x38, 0x2C };
    byte[] out = new byte[]{ 0x53, 0x7C};
    try {
      buf.put(in, 0, 0, 2);
      fail("should fail on 2 bytes");
    } catch (IndexOutOfBoundsException e) {}
    try {
      buf.get(0, out, 0, 2);
      fail("should fail on 2 bytes");
    } catch (IndexOutOfBoundsException e) {}
    try {
      buf.put(in, -1, 0, 1);
      fail("should fail on 2 bytes");
    } catch (IndexOutOfBoundsException e) {}
    try {
      buf.get(-1, out, 0, 1);
      fail("should fail on 2 bytes");
    } catch (IndexOutOfBoundsException e) {}
    try {
      buf.put(in, 0, -1, 1);
      fail("should fail on 2 bytes");
    } catch (IndexOutOfBoundsException e) {}
    try {
      buf.get(0, out, -1, 1);
      fail("should fail on 2 bytes");
    } catch (IndexOutOfBoundsException e) {}
    try {
      buf.put(in, 0, 1, 1);
      fail("should fail on 2 bytes");
    } catch (IndexOutOfBoundsException e) {}
    try {
      buf.get(0, out, 3, 1);
      fail("should fail on 2 bytes");
    } catch (IndexOutOfBoundsException e) {}
    try {
      buf.put(in, 3, 0, 1);
      fail("should fail on 2 bytes");
    } catch (IndexOutOfBoundsException e) {}
    try {
      buf.get(1, out, 0, 1);
      fail("should fail on 2 bytes");
    } catch (IndexOutOfBoundsException e) {}
    buf.put(in, 0, 0, 1);
    buf.get(0, out, 0, 1);
    assertEquals(in[0], out[0]);
    assertNotSame(in[1], out[1]);
   
    buf.delete();
  }
View Full Code Here

    retval = mCoder.open(null, null);
    assertTrue("Could not open codec", retval >= 0);
    int extraDataSize = mCoder.getExtraDataSize();
    assertEquals(expected.length, extraDataSize);

    IBuffer buffer = mCoder.getExtraData();
    assertNotNull(buffer);
    assertEquals(extraDataSize, buffer.getBufferSize());
    retval = mCoder.close();
    assertTrue("Could not close codec", retval >= 0);
    byte[] actual = new byte[expected.length];
    buffer.get(0, actual, 0, actual.length);
    for(int i = 0; i < expected.length; i++)
      assertEquals("differ at: "+i, expected[i], actual[i]);
  }
View Full Code Here

  }
 
  @Test
  public void testReadingSamplesIntoIBuffer()
  {
    IBuffer buffer = IBuffer.make(null, 192000*2);
    Helper h = new Helper();
   
    h.setupReadingObject(h.sampleFile);
   
    int retval = -1;
View Full Code Here

    samples.setComplete(true, sampleRate, sampleRate,
        channels, IAudioSamples.Format.FMT_S16, 0);
    assertTrue(samples.isComplete());
   
    IBuffer buffer;
    buffer = samples.getData();
    assertEquals(IBuffer.Type.IBUFFER_SINT16, buffer.getType());

    samples.setComplete(true, sampleRate, sampleRate,
        channels, IAudioSamples.Format.FMT_S32, 0);
    assertTrue(samples.isComplete());
    buffer = samples.getData();
    assertEquals(IBuffer.Type.IBUFFER_SINT32, buffer.getType());
}
View Full Code Here

TOP

Related Classes of com.xuggle.ferry.IBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.