com.xuggle.xuggler
Class IMediaData

Package class diagram package IMediaData
java.lang.Object
  extended by com.xuggle.ferry.RefCounted
      extended by com.xuggle.xuggler.IMediaData
Direct Known Subclasses:
IAudioSamples, IMediaDataWrapper, IPacket, IVideoPicture

public class IMediaData
extends RefCounted

The parent class of all media objects than can be gotten from an IStream.


Field Summary
static String DEFAULT_TIME_STAMP_FORMAT
          The default time stamp format.
 
Fields inherited from class com.xuggle.ferry.RefCounted
swigCMemOwn
 
Constructor Summary
protected IMediaData(long cPtr, boolean cMemoryOwn)
          Internal Only.
protected IMediaData(long cPtr, boolean cMemoryOwn, AtomicLong ref)
          Internal Only.
 
Method Summary
 IMediaData copyReference()
          Create a new IMediaData object that is actually referring to the exact same underlying native object.
 void delete()
          Releases this instance of IMediaData and frees any underlying native memory.
 boolean equals(Object obj)
          Compares two values, returning true if the underlying objects in native code are the same object.
 void get(int srcPos, byte[] dest, int destPos, int length)
          Absolute bulk get method.
 void get(int srcPos, char[] dest, int destPos, int length)
          Absolute bulk get method.
 void get(int srcPos, double[] dest, int destPos, int length)
          Absolute bulk get method.
 void get(int srcPos, float[] dest, int destPos, int length)
          Absolute bulk get method.
 void get(int srcPos, int[] dest, int destPos, int length)
          Absolute bulk get method.
 void get(int srcPos, long[] dest, int destPos, int length)
          Absolute bulk get method.
 void get(int srcPos, short[] dest, int destPos, int length)
          Absolute bulk get method.
 ByteBuffer getByteBuffer()
          Gets the underlying ByteBuffer for this IMediaData object.
 ByteBuffer getByteBuffer(AtomicReference<JNIReference> ref)
          Gets the underlying ByteBuffer for this IMediaData object.
static long getCPtr(IMediaData obj)
          Internal Only.
protected  IBuffer getData_internal()
          Get any underlying raw data available for this object.
 IBuffer getData()
          Get any underlying raw data available for this object.
 IBuffer getDataCached()
          Get any underlying raw data available for this object, but do not create a new Java wrapping object for it.
 String getFormattedTimeStamp()
          Get a string representation of the time stamp for this IMediaData.
 String getFormattedTimeStamp(String format)
          Get a string representation of the time stamp for this IMediaData.
 long getMyCPtr()
          Internal Only.
 int getSize()
          Get the size in bytes of the raw data available for this object.
 IRational getTimeBase()
          Get the time base that time stamps of this object are represented in.
 long getTimeStamp()
          Get the time stamp of this object in getTimeBase() units.
 int hashCode()
          Get a hashable value for this object.
 boolean isKey()
          Is this object a key object? i.e.
 void put(byte[] src, int srcPos, int destPos, int length)
          Absolute bulk put method.
 void put(char[] src, int srcPos, int destPos, int length)
          Absolute bulk put method.
 void put(double[] src, int srcPos, int destPos, int length)
          Absolute bulk put method.
 void put(float[] src, int srcPos, int destPos, int length)
          Absolute bulk put method.
 void put(int[] src, int srcPos, int destPos, int length)
          Absolute bulk put method.
 void put(long[] src, int srcPos, int destPos, int length)
          Absolute bulk put method.
 void put(short[] src, int srcPos, int destPos, int length)
          Absolute bulk put method.
protected  void setData_internal(IBuffer buffer)
          Sets the underlying buffer used by this object.
 void setData(IBuffer buffer)
          Sets the underlying buffer used by this object.
 void setTimeBase(IRational aBase)
          Set the time base that time stamps of this object are represented in.
 void setTimeStamp(long aTimeStamp)
          Set the time stamp for this object in getTimeBase() units.
 
Methods inherited from class com.xuggle.ferry.RefCounted
acquire, getCPtr, getCurrentRefCount, getJavaRefCount, release
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIME_STAMP_FORMAT

public static final String DEFAULT_TIME_STAMP_FORMAT
The default time stamp format.

See Also:
Constant Field Values
Constructor Detail

IMediaData

protected IMediaData(long cPtr,
                     boolean cMemoryOwn)
Internal Only.


IMediaData

protected IMediaData(long cPtr,
                     boolean cMemoryOwn,
                     AtomicLong ref)
Internal Only.

Method Detail

getCPtr

public static long getCPtr(IMediaData obj)
Internal Only. Not part of public API. Get the raw value of the native object that obj is proxying for.

Parameters:
obj - The java proxy object for a native object.
Returns:
The raw pointer obj is proxying for.

getMyCPtr

public long getMyCPtr()
Internal Only. Not part of public API. Get the raw value of the native object that we're proxying for.

Overrides:
getMyCPtr in class RefCounted
Returns:
The raw pointer we're proxying for.

copyReference

public IMediaData copyReference()
Create a new IMediaData object that is actually referring to the exact same underlying native object.

Overrides:
copyReference in class RefCounted
Returns:
the new Java object.

equals

public boolean equals(Object obj)
Compares two values, returning true if the underlying objects in native code are the same object. That means you can have two different Java objects, but when you do a comparison, you'll find out they are the EXACT same object.

Overrides:
equals in class Object
Returns:
True if the underlying native object is the same. False otherwise.

hashCode

public int hashCode()
Get a hashable value for this object.

Overrides:
hashCode in class Object
Returns:
the hashable value.

put

public void put(byte[] src,
                int srcPos,
                int destPos,
                int length)
Absolute bulk put method.

This method delegates to the same put method on the underlying IBuffer returned from getData() , but may be more efficient in some JNIMemoryManager.MemoryModel configurations.

See Also:
IBuffer.put(byte[], int, int, int)

get

public void get(int srcPos,
                byte[] dest,
                int destPos,
                int length)
Absolute bulk get method.

This method delegates to the same get method on the underlying IBuffer returned from getData() , but may be more efficient in some JNIMemoryManager.MemoryModel configurations.

See Also:
IBuffer.get(int, byte[], int, int)

put

public void put(char[] src,
                int srcPos,
                int destPos,
                int length)
Absolute bulk put method.

This method delegates to the same put method on the underlying IBuffer returned from getData() , but may be more efficient in some JNIMemoryManager.MemoryModel configurations.

See Also:
IBuffer.put(char[], int, int, int)

get

public void get(int srcPos,
                char[] dest,
                int destPos,
                int length)
Absolute bulk get method.

This method delegates to the same get method on the underlying IBuffer returned from getData() , but may be more efficient in some JNIMemoryManager.MemoryModel configurations.

See Also:
IBuffer.get(int, char[], int, int)

put

public void put(short[] src,
                int srcPos,
                int destPos,
                int length)
Absolute bulk put method.

This method delegates to the same put method on the underlying IBuffer returned from getData() , but may be more efficient in some JNIMemoryManager.MemoryModel configurations.

See Also:
IBuffer.put(short[], int, int, int)

get

public void get(int srcPos,
                short[] dest,
                int destPos,
                int length)
Absolute bulk get method.

This method delegates to the same get method on the underlying IBuffer returned from getData() , but may be more efficient in some JNIMemoryManager.MemoryModel configurations.

See Also:
IBuffer.get(int, short[], int, int)

put

public void put(int[] src,
                int srcPos,
                int destPos,
                int length)
Absolute bulk put method.

This method delegates to the same put method on the underlying IBuffer returned from getData() , but may be more efficient in some JNIMemoryManager.MemoryModel configurations.

See Also:
IBuffer.put(int[], int, int, int)

get

public void get(int srcPos,
                int[] dest,
                int destPos,
                int length)
Absolute bulk get method.

This method delegates to the same get method on the underlying IBuffer returned from getData() , but may be more efficient in some JNIMemoryManager.MemoryModel configurations.

See Also:
IBuffer.get(int, int[], int, int)

put

public void put(long[] src,
                int srcPos,
                int destPos,
                int length)
Absolute bulk put method.

This method delegates to the same put method on the underlying IBuffer returned from getData() , but may be more efficient in some JNIMemoryManager.MemoryModel configurations.

See Also:
IBuffer.put(long[], int, int, int)

get

public void get(int srcPos,
                long[] dest,
                int destPos,
                int length)
Absolute bulk get method.

This method delegates to the same get method on the underlying IBuffer returned from getData() , but may be more efficient in some JNIMemoryManager.MemoryModel configurations.

See Also:
IBuffer.get(int, long[], int, int)

put

public void put(float[] src,
                int srcPos,
                int destPos,
                int length)
Absolute bulk put method.

This method delegates to the same put method on the underlying IBuffer returned from getData() , but may be more efficient in some JNIMemoryManager.MemoryModel configurations.

See Also:
IBuffer.put(float[], int, int, int)

get

public void get(int srcPos,
                float[] dest,
                int destPos,
                int length)
Absolute bulk get method.

This method delegates to the same get method on the underlying IBuffer returned from getData() , but may be more efficient in some JNIMemoryManager.MemoryModel configurations.

See Also:
IBuffer.get(int, float[], int, int)

put

public void put(double[] src,
                int srcPos,
                int destPos,
                int length)
Absolute bulk put method.

This method delegates to the same put method on the underlying IBuffer returned from getData() , but may be more efficient in some JNIMemoryManager.MemoryModel configurations.

See Also:
IBuffer.put(double[], int, int, int)

get

public void get(int srcPos,
                double[] dest,
                int destPos,
                int length)
Absolute bulk get method.

This method delegates to the same get method on the underlying IBuffer returned from getData() , but may be more efficient in some JNIMemoryManager.MemoryModel configurations.

See Also:
IBuffer.get(int, double[], int, int)

getByteBuffer

public ByteBuffer getByteBuffer()
Gets the underlying ByteBuffer for this IMediaData object. Users may modify the contents of the ByteBuffer and their changes will be reflected in the underlying memory. See IBuffer for the warnings associated with the use of raw memory. The buffer position and mark are initialized to zero, and the limit is initialized to the number of elements in the buffer.

This is a convenience method to allow you to avoid getting the IBuffer object that has the actual data.

Returns:
The underlying ByteBuffer
See Also:
IBuffer.getByteBuffer(int, int)

getByteBuffer

public ByteBuffer getByteBuffer(AtomicReference<JNIReference> ref)
Gets the underlying ByteBuffer for this IMediaData object. Users may modify the contents of the ByteBuffer and their changes will be reflected in the underlying memory. See IBuffer for the warnings associated with the use of raw memory. The buffer position and mark are initialized to zero, and the limit is initialized to the number of elements in the buffer.

This is a convenience method to allow you to avoid getting the IBuffer object that has the actual data.

Parameters:
ref - A reference that on return from this method will contain a JNIReference object that can be used for explicit memory management.
Returns:
The underlying ByteBuffer
See Also:
IBuffer.getByteBuffer(int, int, java.util.concurrent.atomic.AtomicReference)

getFormattedTimeStamp

public String getFormattedTimeStamp()
Get a string representation of the time stamp for this IMediaData. The time is formatted as: HH:MM:SS.ms

Returns:
the printable string form of the time stamp of this media
See Also:
getFormattedTimeStamp(String), DEFAULT_TIME_STAMP_FORMAT

getFormattedTimeStamp

public String getFormattedTimeStamp(String format)
Get a string representation of the time stamp for this IMediaData. The format of the resulting string is specified by the format parameter. See Formatter for details on how to specify formats, however a good place to start is with the following format: %1$tH:%1$tM:%1$tS.%1$tL

Parameters:
format - the format for the time stamp string
Returns:
the printable string form of the timestamp
See Also:
getFormattedTimeStamp(), DEFAULT_TIME_STAMP_FORMAT, Formatter

getData

public IBuffer getData()
Get any underlying raw data available for this object.

Returns:
The raw data, or null if not accessible.

setData

public void setData(IBuffer buffer)
Sets the underlying buffer used by this object.

This is an advanced method and is not recommended for use by those who don't fully understand how IBuffers work. Implementations of IMediaData may behave in undefined ways if the buffer you pass in is not big enough for what you ask them to do (e.g. they may discard your buffer and allocate a larger one if they need more space). It is up to the caller to ensure the buffer passed in is large enough, and is not simultaneously in use by another part of the system.

Parameters:
buffer - The buffer to set. If null, this method is ignored.
Since:
3.2

getDataCached

public IBuffer getDataCached()
Get any underlying raw data available for this object, but do not create a new Java wrapping object for it.

Do not call RefCounted.delete() on the returned value.

Returns:
The raw data, or null if not accessible.
Since:
3.2

delete

public void delete()
Releases this instance of IMediaData and frees any underlying native memory.

Releases any underlying native memory and marks this object as invalid.

Normally Ferry manages when to release native memory.

In the unlikely event you want to control EXACTLY when a native object is released, each Xuggler object has a RefCounted.delete() method that you can use. Once you call RefCounted.delete(), you must ENSURE your object is never referenced again from that Java object -- Ferry tries to help you avoid crashes if you accidentally use an object after deletion but on this but we cannot offer 100% protection (specifically if another thread is accessing that object EXACTLY when you RefCounted.delete() it).

Overrides:
delete in class RefCounted

getTimeStamp

public long getTimeStamp()
Get the time stamp of this object in getTimeBase() units.

Returns:
the time stamp

setTimeStamp

public void setTimeStamp(long aTimeStamp)
Set the time stamp for this object in getTimeBase() units.

Parameters:
aTimeStamp - The time stamp

getTimeBase

public IRational getTimeBase()
Get the time base that time stamps of this object are represented in. Caller must release the returned value.

Returns:
the time base.

setTimeBase

public void setTimeBase(IRational aBase)
Set the time base that time stamps of this object are represented in.


getData_internal

protected IBuffer getData_internal()
Get any underlying raw data available for this object.

Returns:
The raw data, or null if not accessible.

getSize

public int getSize()
Get the size in bytes of the raw data available for this object.

Returns:
the size in bytes, or -1 if it cannot be computed.

isKey

public boolean isKey()
Is this object a key object? i.e. it can be interpreted without needing any other media objects

Returns:
true if it's a key, false if not

setData_internal

protected void setData_internal(IBuffer buffer)
Sets the underlying buffer used by this object.

This is an advanced method and is not recommended for use by those who don't fully understand how IBuffers work. Implementations of IMediaData may behave in undefined ways if the buffer you pass in is not big enough for what you ask them to do (e.g. they may discard your buffer and allocate a larger one if they need more space). It is up to the caller to ensure the buffer passed in is large enough,

Parameters:
buffer - The buffer to set. If null, this method is ignored.


Copyright © 2008, 2010 Xuggle