quicktime.util
Class QTUtils

java.lang.Object
  |
  +--quicktime.util.QTUtils
All Implemented Interfaces:
quicktime.jdirect.InterfaceLib, quicktime.jdirect.PrimitivesLib, quicktime.jdirect.QuickTimeLib, quicktime.jdirect.SharedLibrary, com.apple.jdirect.SharedLibrary

public final class QTUtils
extends java.lang.Object
implements quicktime.jdirect.QuickTimeLib

This provides a set of routines to convert between types that the QT calls expect and the basic Java classes and types

Some of the structures in QT are kept in their native BigEndian format.

These conversions are generally done for you where they are required in the get/set methods of the classes concerned.


Fields inherited from interface quicktime.jdirect.QuickTimeLib
JDirect_MacOSX, libraryInstance, name
 
Method Summary
static void checkFreeMemory()
          This call will ensure that a reserved amount of application heap memory on the MacOS is free.
static int convertEventModifier(int javaEvtMod)
          Convert the modifier values in java InputEvents to those expected by QT.
static int convertKeyValue(int javaKeyValue)
          Convert the key values in java KeyEvents to those expected by QT.
static java.lang.String CString2String(byte[] str, int offset)
          Converts a CString into a java.lang.String.
static void endianFlip(java.lang.Object src, int srcOffset, EndianDescriptor ed)
          This will flip the supplied src object's fields according to the characteristics of the supplied EndianDescriptor.
static void endianFlip(java.lang.Object src, int srcOffset, java.lang.Object dest, int destOffset, EndianDescriptor ed)
          This will flip the supplied src object's fields according to the characteristics of the supplied EndianDescriptor and copy these flipped values to the destination object.
static short endianFlip16(short s)
          This will flip the endian order of a 16bit value
static int endianFlip32(int i)
          This will flip the endian order of a 32bit value
static long endianFlip64(long l)
          This will flip the endian order of a 64bit value
static float Fix2X(int fix)
          Convert a float to a 16.16 Fixed format
static float Fract2X(int fract)
          Convert a 2.30 Fract format to a float
static java.lang.String fromOSType(int osType)
          Converts an int into a 4 character string representing an OSType.
static java.lang.String PString2String(byte[] pString, int offset)
          Converts a PString into a java.lang.String.
static void reclaimMemory()
          Reclaim as much memory as possible and ensure that all finalize methods are called on objects which have been collected.
static float ShortFix2X(short fix)
          Convert a 8.8 Fixed format to a float
static byte[] String2CString(java.lang.String str)
          Convert a java.lang.String to a CString byte array.
static byte[] String2PString(java.lang.String str, int len)
          Convert a java.lang.String to a PString byte array.
static int toOSType(char a, char b, char c, char d)
          Converts four characters into an OSType int
static int toOSType(java.lang.String str)
          Converts an OSType (4 character) string into an int.
static int UByte2Int(byte b)
          converts an unsigned byte to int.
static float UFix2X(int fix)
          Convert a 16.16 Unsigned Fixed format to a float
static long UInt2Long(int i)
          converts an unsigned int to long.
static int UShort2Int(short s)
          converts an unsigned short to int.
static int X2Fix(float x)
          Convert a float to a 16.16 Fixed format
static int X2Fract(float x)
          Converts a float to a 2.30 Fract format
static short X2ShortFix(float x)
          Convert a float to a 8.8 Fixed format
static int X2UFix(float x)
          Convert a 16.16 Unsigned Fixed format to a float
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

convertEventModifier

public static int convertEventModifier(int javaEvtMod)
Convert the modifier values in java InputEvents to those expected by QT.

convertKeyValue

public static int convertKeyValue(int javaKeyValue)
Convert the key values in java KeyEvents to those expected by QT.

X2Fix

public static int X2Fix(float x)
Convert a float to a 16.16 Fixed format

Fix2X

public static float Fix2X(int fix)
Convert a float to a 16.16 Fixed format

X2UFix

public static int X2UFix(float x)
Convert a 16.16 Unsigned Fixed format to a float

UFix2X

public static float UFix2X(int fix)
Convert a 16.16 Unsigned Fixed format to a float

X2Fract

public static int X2Fract(float x)
Converts a float to a 2.30 Fract format

Fract2X

public static float Fract2X(int fract)
Convert a 2.30 Fract format to a float

X2ShortFix

public static short X2ShortFix(float x)
Convert a float to a 8.8 Fixed format

ShortFix2X

public static float ShortFix2X(short fix)
Convert a 8.8 Fixed format to a float

UByte2Int

public static int UByte2Int(byte b)
converts an unsigned byte to int.

UShort2Int

public static int UShort2Int(short s)
converts an unsigned short to int.

UInt2Long

public static long UInt2Long(int i)
converts an unsigned int to long.

String2CString

public static byte[] String2CString(java.lang.String str)
Convert a java.lang.String to a CString byte array.
Parameters:
str - the String to convert

String2PString

public static byte[] String2PString(java.lang.String str,
                                    int len)
Convert a java.lang.String to a PString byte array.
Parameters:
str - the String to convert
len - the maximum length of the Pstring, max length is 255.

CString2String

public static java.lang.String CString2String(byte[] str,
                                              int offset)
Converts a CString into a java.lang.String. The offset specifies where the C string begins and it terminates at the first 0 value that it finds.

PString2String

public static java.lang.String PString2String(byte[] pString,
                                              int offset)
Converts a PString into a java.lang.String. The offset specifies where the count byte is within the byte array that is passed in - typically 0.

toOSType

public static final int toOSType(java.lang.String str)
Converts an OSType (4 character) string into an int.

toOSType

public static final int toOSType(char a,
                                 char b,
                                 char c,
                                 char d)
Converts four characters into an OSType int

fromOSType

public static java.lang.String fromOSType(int osType)
Converts an int into a 4 character string representing an OSType. The OSType int is presumed to be the right endian layout.

reclaimMemory

public static void reclaimMemory()
Reclaim as much memory as possible and ensure that all finalize methods are called on objects which have been collected.

checkFreeMemory

public static void checkFreeMemory()
                            throws UtilException
This call will ensure that a reserved amount of application heap memory on the MacOS is free. If this amount of memory is not free a memFullErr will be thrown.

endianFlip16

public static short endianFlip16(short s)
This will flip the endian order of a 16bit value
Parameters:
s - the value to flip
Returns:
the flipped value
See Also:
EndianOrder

endianFlip32

public static int endianFlip32(int i)
This will flip the endian order of a 32bit value
Parameters:
i - the value to flip
Returns:
the flipped value
See Also:
EndianOrder

endianFlip64

public static long endianFlip64(long l)
This will flip the endian order of a 64bit value
Parameters:
l - the value to flip
Returns:
the flipped value
See Also:
EndianOrder

endianFlip

public static void endianFlip(java.lang.Object src,
                              int srcOffset,
                              EndianDescriptor ed)
                       throws UtilException
This will flip the supplied src object's fields according to the characteristics of the supplied EndianDescriptor. The EndianDescriptor will be applied to the src object at the specified (srcOffset) number of bytes from the beginning of the src object. The flipping is done in place, so the srcObject will be flipped upon the completion of this method. Any fields that are not described or accounted for by the EndianDescriptor will not be flipped.
Parameters:
src - the object to flip
srcOffset - the number of bytes from the start of the src object that the supplied endian descriptor will be applied.
ed - the EndianDescriptor that will describe how the object should be flipped. This may NOT be null.
See Also:
EndianOrder

endianFlip

public static void endianFlip(java.lang.Object src,
                              int srcOffset,
                              java.lang.Object dest,
                              int destOffset,
                              EndianDescriptor ed)
                       throws UtilException
This will flip the supplied src object's fields according to the characteristics of the supplied EndianDescriptor and copy these flipped values to the destination object. The EndianDescriptor will be applied to the src object at the specified (srcOffset) number of bytes from the beginning of the src object and the flipped values will be copied to the specified (destOffset) number of bytes into the destination object. Any fields that are not described or accounted for by the EndianDescriptor will not be flipped or copied.
Parameters:
src - the object to flip
srcOffset - the number of bytes from the start of the src object that the supplied endian descriptor will be applied.
dest - the object that will be the flipped version of the source object.
destOffset - the number of bytes from the start of the dest object that the flipped values will be copied too.
ed - the EndianDescriptor that will describe how the object should be flipped. This may NOT be null.
See Also:
EndianOrder