quicktime.util
Class QTHandleRef

java.lang.Object
  |
  +--quicktime.QTObject
        |
        +--quicktime.util.QTHandleRef
All Implemented Interfaces:
quicktime.jdirect.InterfaceLib, quicktime.jdirect.PrimitivesLib, quicktime.jdirect.QuickTimeLib, quicktime.jdirect.SharedLibrary, com.apple.jdirect.SharedLibrary
Direct Known Subclasses:
AliasHandle, AtomContainer, ColorTable, GDevice, Pict, PixMap, Polygon, QTHandle, QTMIDIPortList, Region, SampleDescription, SGDeviceList, SoundLocalization, StringHandle

public class QTHandleRef
extends QTObject
implements quicktime.jdirect.QuickTimeLib, quicktime.jdirect.PrimitivesLib, quicktime.jdirect.InterfaceLib

A QTHandleRef is a "smart" handle in that it can be either a Reference to a handle which is not disposable, or it can be a real "independent" handle which is automatically disposed on finalization. This class is used as a generic base class for handle based objects. See QTHandle for a user-level handle object.

The default setting is for the Handle to be disposable - subclasses must use the QTHandleRef(int, Object) constructor to create a non-disposable reference For non-disposable handles there are two situations to look out for:
(1) Upon finalization the handle should NOT be disposed - it belongs to a parent struct
(2) The parent object from which the handle is obtained should not be allowed to go away whilst the reference object is alive.
In both situations we must maintain a reference to the parent or owner object. When defining a clone operation subclasses should define it as:
public Object clone() { return new QTHandleSubclass (makeAndCopyHandle (), null); }


Fields inherited from interface quicktime.jdirect.QuickTimeLib
JDirect_MacOSX, libraryInstance, name
 
Method Summary
 void copyFromArray(int handleOffset, byte[] srcArray, int srcOffset, int length)
          An efficient byte[] copy that copies length bytes from the byte array to the handle.
 void copyFromArray(int handleOffset, char[] srcArray, int srcOffset, int length)
          An efficient char[] copy that copies length chars from the byte array to the handle.
 void copyFromArray(int handleOffset, double[] srcArray, int srcOffset, int length)
          An efficient double[] copy that copies length doubles from the byte array to the handle.
 void copyFromArray(int handleOffset, float[] srcArray, int srcOffset, int length)
          An efficient float[] copy that copies length floats from the byte array to the handle.
 void copyFromArray(int handleOffset, int[] srcArray, int srcOffset, int length)
          An efficient int[] copy that copies length ints from the byte array to the handle.
 void copyFromArray(int handleOffset, long[] srcArray, int srcOffset, int length)
          An efficient long[] copy that copies length longs from the byte array to the handle.
 void copyFromArray(int handleOffset, short[] srcArray, int srcOffset, int length)
          An efficient short[] copy that copies length shorts from the byte array to the handle.
 void copyToArray(int handleOffset, byte[] destArray, int destOffset, int length)
          An efficient byte[] copy that copies length bytes from the handle to the byte array.
 void copyToArray(int handleOffset, char[] destArray, int destOffset, int length)
          An efficient char[] copy that copies length chars from the handle to the char array.
 void copyToArray(int handleOffset, double[] destArray, int destOffset, int length)
          An efficient double[] copy that copies length doubles from the handle to the double array.
 void copyToArray(int handleOffset, float[] destArray, int destOffset, int length)
          An efficient float[] copy that copies length floats from the handle to the float array.
 void copyToArray(int handleOffset, int[] destArray, int destOffset, int length)
          An efficient int[] copy that copies length ints from the handle to the int array.
 void copyToArray(int handleOffset, long[] destArray, int destOffset, int length)
          An efficient long[] copy that copies length longs from the handle to the long array.
 void copyToArray(int handleOffset, short[] destArray, int destOffset, int length)
          An efficient short[] copy that copies length shorts from the handle to the short array.
static QTHandleRef fromCompressionDialogState(CompressionDialog cd)
          Retrieves all of the settings for a dialog.
static SCInfo fromSCSequence(SCSequence sc, QDGraphics src, QDRect srcRect)
          Compresses a frame that is sourced by a PixMap from the supplied QDGraphics, returning the compressed data.
 byte[] getBytes()
          Returns a copy of the data of the handle as a byte array
 int getSize()
          This method returns the size (number of bytes) of the handle

QuickTime::GetHandleSize

 boolean inMemory()
          checks this handles purgedness
 boolean isLocked()
          Returns true if the handle is locked otherwise false.
 void lock()
          Locks the relocatable block.
 void lockHigh()
          Moves the relocatable block to the top of the heap and locks it.
 void moveHigh()
          Move the handle to high memory.
 QTPointerRef toQTPointer()
          Locks the handle and returns a pointer object.
 QTPointerRef toQTPointer(int offset, int size)
          Locks the handle and returns a pointer object.
 java.lang.String toString()
          A String representation of the class.
 void unlock()
          Unlocks the relocatable block.
 
Methods inherited from class quicktime.QTObject
disposeQTObject, equals, ID
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

fromSCSequence

public static SCInfo fromSCSequence(SCSequence sc,
                                    QDGraphics src,
                                    QDRect srcRect)
                             throws QTException
Compresses a frame that is sourced by a PixMap from the supplied QDGraphics, returning the compressed data.

QuickTime::SCCompressSequenceFrame()

Parameters:
src - the PixMap's source QDGraphics.
srcRect - you can specify to compress just a part of the pix map by specifying a rectangle - or pass in null to compress the entire pix map.
Returns:
an image data object.

fromCompressionDialogState

public static QTHandleRef fromCompressionDialogState(CompressionDialog cd)
                                              throws QTException
Retrieves all of the settings for a dialog.

QuickTime::SCRequestImageSettings()

See Also:
CompressionDialog.getInfoState()

getSize

public int getSize()
This method returns the size (number of bytes) of the handle

QuickTime::GetHandleSize

Returns:
the size of the handle

getBytes

public byte[] getBytes()
Returns a copy of the data of the handle as a byte array
Returns:
a byte array - copy of handle data

copyToArray

public final void copyToArray(int handleOffset,
                              byte[] destArray,
                              int destOffset,
                              int length)
An efficient byte[] copy that copies length bytes from the handle to the byte array.
Parameters:
handleOffset - the byte offset from the handle to copy the bytes from
destArray - the destination byte array
destOffset - the offset within the byte array to start copying to
length - the number of bytes to copy

copyToArray

public final void copyToArray(int handleOffset,
                              short[] destArray,
                              int destOffset,
                              int length)
An efficient short[] copy that copies length shorts from the handle to the short array.
Parameters:
handleOffset - the byte offset from the handle to copy the shorts from
destArray - the destination short array
destOffset - the offset within the short array to start copying to
length - the number of shorts to copy

copyToArray

public final void copyToArray(int handleOffset,
                              char[] destArray,
                              int destOffset,
                              int length)
An efficient char[] copy that copies length chars from the handle to the char array.
Parameters:
handleOffset - the byte offset from the handle to copy the chars from
destArray - the destination char array
destOffset - the offset within the char array to start copying to
length - the number of chars to copy

copyToArray

public final void copyToArray(int handleOffset,
                              int[] destArray,
                              int destOffset,
                              int length)
An efficient int[] copy that copies length ints from the handle to the int array.
Parameters:
handleOffset - the byte offset from the handle to copy the ints from
destArray - the destination int array
destOffset - the offset within the int array to start copying to
length - the number of ints to copy

copyToArray

public final void copyToArray(int handleOffset,
                              float[] destArray,
                              int destOffset,
                              int length)
An efficient float[] copy that copies length floats from the handle to the float array.
Parameters:
handleOffset - the byte offset from the handle to copy the floats from
destArray - the destination float array
destOffset - the offset within the float array to start copying to
length - the number of floats to copy

copyToArray

public final void copyToArray(int handleOffset,
                              long[] destArray,
                              int destOffset,
                              int length)
An efficient long[] copy that copies length longs from the handle to the long array.
Parameters:
handleOffset - the byte offset from the handle to copy the longs from
destArray - the destination long array
destOffset - the offset within the long array to start copying to
length - the number of longs to copy

copyToArray

public final void copyToArray(int handleOffset,
                              double[] destArray,
                              int destOffset,
                              int length)
An efficient double[] copy that copies length doubles from the handle to the double array.
Parameters:
handleOffset - the byte offset from the handle to copy the doubles from
destArray - the destination double array
destOffset - the offset within the double array to start copying to
length - the number of doubles to copy

copyFromArray

public final void copyFromArray(int handleOffset,
                                byte[] srcArray,
                                int srcOffset,
                                int length)
An efficient byte[] copy that copies length bytes from the byte array to the handle.
Parameters:
handleOffset - how many bytes offset from the base handle to copy to.
srcArray - the byte[] to copy
srcOffset - the nth index within the byte [] to start copying from
length - how many elements of the byte array to copy

copyFromArray

public final void copyFromArray(int handleOffset,
                                short[] srcArray,
                                int srcOffset,
                                int length)
An efficient short[] copy that copies length shorts from the byte array to the handle.
Parameters:
handleOffset - how many bytes offset from the base handle to copy to.
srcArray - the short[] to copy
srcOffset - the nth index within the short array to start copying from
length - how many elements of the short array to copy

copyFromArray

public final void copyFromArray(int handleOffset,
                                char[] srcArray,
                                int srcOffset,
                                int length)
An efficient char[] copy that copies length chars from the byte array to the handle.
Parameters:
handleOffset - how many bytes offset from the base handle to copy to.
srcArray - the char[] to copy
srcOffset - the nth index within the char array to start copying from
length - how many elements of the char array to copy

copyFromArray

public final void copyFromArray(int handleOffset,
                                int[] srcArray,
                                int srcOffset,
                                int length)
An efficient int[] copy that copies length ints from the byte array to the handle.
Parameters:
handleOffset - how many bytes offset from the base handle to copy to.
srcArray - the int[] to copy
srcOffset - the nth index within the int array to start copying from
length - how many elements of the int array to copy

copyFromArray

public final void copyFromArray(int handleOffset,
                                float[] srcArray,
                                int srcOffset,
                                int length)
An efficient float[] copy that copies length floats from the byte array to the handle.
Parameters:
handleOffset - how many bytes offset from the base handle to copy to.
srcArray - the float[] to copy
srcOffset - the nth index within the float array to start copying from
length - how many elements of the float array to copy

copyFromArray

public final void copyFromArray(int handleOffset,
                                long[] srcArray,
                                int srcOffset,
                                int length)
An efficient long[] copy that copies length longs from the byte array to the handle.
Parameters:
handleOffset - how many bytes offset from the base handle to copy to.
srcArray - the long[] to copy
srcOffset - the nth index within the long array to start copying from
length - how many elements of the long array to copy

copyFromArray

public final void copyFromArray(int handleOffset,
                                double[] srcArray,
                                int srcOffset,
                                int length)
An efficient double[] copy that copies length doubles from the byte array to the handle.
Parameters:
handleOffset - how many bytes offset from the base handle to copy to.
srcArray - the double[] to copy
srcOffset - the nth index within the double array to start copying from
length - how many elements of the double array to copy

inMemory

public boolean inMemory()
checks this handles purgedness

isLocked

public final boolean isLocked()
Returns true if the handle is locked otherwise false.

lock

public final void lock()
Locks the relocatable block.

unlock

public final void unlock()
Unlocks the relocatable block.

lockHigh

public void lockHigh()
Moves the relocatable block to the top of the heap and locks it.

QuickTime::HLockHi QuickTime::HLockHi


moveHigh

public final void moveHigh()
Move the handle to high memory. Typically you call this before locking a small handle that is going to be locked for a short period of time.

QuickTime::MoveHHi QuickTime::MoveHHi


toString

public java.lang.String toString()
A String representation of the class.
Overrides:
toString in class QTObject

toQTPointer

public QTPointerRef toQTPointer()
Locks the handle and returns a pointer object. You must keep the handle locked for the lifetime of the returned pointer.
Returns:
an object representing the pointer.

toQTPointer

public QTPointerRef toQTPointer(int offset,
                                int size)
Locks the handle and returns a pointer object. The handle should remain locked for the lifetime of the returned pointer. It will return a pointer that is offset within the handle that has a valid access to size bytes from the offset
Parameters:
offset - the number of bytes to offset within the handle
size - the number of bytes the pointer has valid access to.
Returns:
an object representing the pointer.