Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.neomedia.jmfext.media.protocol
Class ByteBufferPool

java.lang.Object
  extended by net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.ByteBufferPool

public class ByteBufferPool
extends Object

Represents a pool of ByteBuffers which reduces the allocations and deallocations of ByteBuffers in the Java heap and of native memory in the native heap.

Author:
Lubomir Marinov

Constructor Summary
ByteBufferPool()
           
 
Method Summary
 void close()
          Closes this ByteBufferPool i.e.
 ByteBuffer getFreeBuffer(int capacity)
          Gets a ByteBuffer out of the pool of free ByteBuffers (i.e.
 void returnFreeBuffer(ByteBuffer buffer)
          Returns a specific ByteBuffer into the pool of free ByteBuffers (i.e.
 void returnFreeBuffer(long bufferPtr)
          Returns a specific ByteBuffer given by the pointer to the native memory that it represents into the pool of free ByteBuffers (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteBufferPool

public ByteBufferPool()
Method Detail

close

public void close()
Closes this ByteBufferPool i.e. releases the resource allocated by this ByteBufferPool during its existence and prepares it to be garbage collected.


getFreeBuffer

public ByteBuffer getFreeBuffer(int capacity)
Gets a ByteBuffer out of the pool of free ByteBuffers (i.e. ByteBuffers ready for writing captured media data into them) which is capable to receiving at least capacity number of bytes.

Parameters:
capacity - the minimal number of bytes that the returned ByteBuffer is to be capable of receiving
Returns:
a ByteBuffer which is ready for writing captured media data into and which is capable of receiving at least capacity number of bytes

returnFreeBuffer

public void returnFreeBuffer(ByteBuffer buffer)
Returns a specific ByteBuffer into the pool of free ByteBuffers (i.e. ByteBuffers ready for writing captured media data into them).

Parameters:
buffer - the ByteBuffer to be returned into the pool of free ByteBuffers

returnFreeBuffer

public void returnFreeBuffer(long bufferPtr)
Returns a specific ByteBuffer given by the pointer to the native memory that it represents into the pool of free ByteBuffers (i.e. ByteBuffers ready for writing captured media data into them).

Parameters:
bufferPtr - the pointer to the native memory represented by the ByteBuffer to be returned into the pool of free ByteBuffers

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.