Class IMediaData
- java.lang.Object
-
- com.avpkit.ferry.RefCounted
-
- com.avpkit.core.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
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_TIME_STAMP_FORMATThe default time stamp format.-
Fields inherited from class com.avpkit.ferry.RefCounted
swigCMemOwn
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedIMediaData(long cPtr, boolean cMemoryOwn)Internal Only.protectedIMediaData(long cPtr, boolean cMemoryOwn, java.util.concurrent.atomic.AtomicLong ref)Internal Only.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IMediaDatacopyReference()Create a new IMediaData object that is actually referring to the exact same underlying native object.voiddelete()Releases this instance of IMediaData and frees any underlying native memory.booleanequals(java.lang.Object obj)Compares two values, returning true if the underlying objects in native code are the same object.voidget(int srcPos, byte[] dest, int destPos, int length)Absolute bulk get method.voidget(int srcPos, char[] dest, int destPos, int length)Absolute bulk get method.voidget(int srcPos, double[] dest, int destPos, int length)Absolute bulk get method.voidget(int srcPos, float[] dest, int destPos, int length)Absolute bulk get method.voidget(int srcPos, int[] dest, int destPos, int length)Absolute bulk get method.voidget(int srcPos, long[] dest, int destPos, int length)Absolute bulk get method.voidget(int srcPos, short[] dest, int destPos, int length)Absolute bulk get method.java.nio.ByteBuffergetByteBuffer()Gets the underlyingByteBufferfor thisIMediaDataobject.java.nio.ByteBuffergetByteBuffer(java.util.concurrent.atomic.AtomicReference<JNIReference> ref)Gets the underlyingByteBufferfor thisIMediaDataobject.static longgetCPtr(IMediaData obj)Internal Only.IBuffergetData()Get any underlying raw data available for this object.protected IBuffergetData_internal()Get any underlying raw data available for this object.
IBuffergetDataCached()Get any underlying raw data available for this object, but do not create a new Java wrapping object for it.java.lang.StringgetFormattedTimeStamp()Get a string representation of the time stamp for thisIMediaData.java.lang.StringgetFormattedTimeStamp(java.lang.String format)Get a string representation of the time stamp for thisIMediaData.longgetMyCPtr()Internal Only.intgetSize()Get the size in bytes of the raw data available for this object.
IRationalgetTimeBase()Get the time base that time stamps of this object are represented in.
Caller must release the returned value.
longgetTimeStamp()Get the time stamp of this object in getTimeBase() units.
inthashCode()Get a hashable value for this object.booleanisKey()Is this object a key object? i.e.voidput(byte[] src, int srcPos, int destPos, int length)Absolute bulk put method.voidput(char[] src, int srcPos, int destPos, int length)Absolute bulk put method.voidput(double[] src, int srcPos, int destPos, int length)Absolute bulk put method.voidput(float[] src, int srcPos, int destPos, int length)Absolute bulk put method.voidput(int[] src, int srcPos, int destPos, int length)Absolute bulk put method.voidput(long[] src, int srcPos, int destPos, int length)Absolute bulk put method.voidput(short[] src, int srcPos, int destPos, int length)Absolute bulk put method.voidsetData(IBuffer buffer)Sets the underlying buffer used by this object.protected voidsetData_internal(IBuffer buffer)Sets the underlying buffer used by this object.voidsetTimeBase(IRational aBase)Set the time base that time stamps of this object are represented in.
voidsetTimeStamp(long aTimeStamp)Set the time stamp for this object in getTimeBase() units.
-
Methods inherited from class com.avpkit.ferry.RefCounted
acquire, getCPtr, getCurrentRefCount, getJavaRefCount, release
-
-
-
-
Field Detail
-
DEFAULT_TIME_STAMP_FORMAT
public static final java.lang.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, java.util.concurrent.atomic.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:
getMyCPtrin classRefCounted- 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:
copyReferencein classRefCounted- Returns:
- the new Java object.
-
equals
public boolean equals(java.lang.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:
equalsin classjava.lang.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:
hashCodein classjava.lang.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
IBufferreturned fromgetData(), but may be more efficient in someJNIMemoryManager.MemoryModelconfigurations.- 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
IBufferreturned fromgetData(), but may be more efficient in someJNIMemoryManager.MemoryModelconfigurations.- 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
IBufferreturned fromgetData(), but may be more efficient in someJNIMemoryManager.MemoryModelconfigurations.- 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
IBufferreturned fromgetData(), but may be more efficient in someJNIMemoryManager.MemoryModelconfigurations.- 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
IBufferreturned fromgetData(), but may be more efficient in someJNIMemoryManager.MemoryModelconfigurations.- 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
IBufferreturned fromgetData(), but may be more efficient in someJNIMemoryManager.MemoryModelconfigurations.- 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
IBufferreturned fromgetData(), but may be more efficient in someJNIMemoryManager.MemoryModelconfigurations.- 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
IBufferreturned fromgetData(), but may be more efficient in someJNIMemoryManager.MemoryModelconfigurations.- 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
IBufferreturned fromgetData(), but may be more efficient in someJNIMemoryManager.MemoryModelconfigurations.- 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
IBufferreturned fromgetData(), but may be more efficient in someJNIMemoryManager.MemoryModelconfigurations.- 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
IBufferreturned fromgetData(), but may be more efficient in someJNIMemoryManager.MemoryModelconfigurations.- 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
IBufferreturned fromgetData(), but may be more efficient in someJNIMemoryManager.MemoryModelconfigurations.- 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
IBufferreturned fromgetData(), but may be more efficient in someJNIMemoryManager.MemoryModelconfigurations.- 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
IBufferreturned fromgetData(), but may be more efficient in someJNIMemoryManager.MemoryModelconfigurations.- See Also:
IBuffer.get(int, double[], int, int)
-
getByteBuffer
public java.nio.ByteBuffer getByteBuffer()
Gets the underlyingByteBufferfor thisIMediaDataobject. Users may modify the contents of the ByteBuffer and their changes will be reflected in the underlying memory. SeeIBufferfor 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 java.nio.ByteBuffer getByteBuffer(java.util.concurrent.atomic.AtomicReference<JNIReference> ref)
Gets the underlyingByteBufferfor thisIMediaDataobject. Users may modify the contents of the ByteBuffer and their changes will be reflected in the underlying memory. SeeIBufferfor 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 aJNIReferenceobject 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 java.lang.String getFormattedTimeStamp()
Get a string representation of the time stamp for thisIMediaData. 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 java.lang.String getFormattedTimeStamp(java.lang.String format)
Get a string representation of the time stamp for thisIMediaData. The format of the resulting string is specified by the format parameter. SeeFormatterfor 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
IMediaDatamay 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 AVPKit object has a
RefCounted.delete()method that you can use. Once you callRefCounted.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 youRefCounted.delete()it).- Overrides:
deletein classRefCounted
-
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.
- Parameters:
aBase- the new time base. If null an exception is thrown.
-
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,
and is not simultaneously in use by another part of the system.
- Parameters:
buffer- The buffer to set. If null, this method
is ignored.
-
-