Methods Summary |
---|
private static boolean | checkIfJDK12()
if (jdkInit)
return (forName3ArgsM != null);
jdkInit = true;
try {
forName3ArgsM = Class.class.getMethod("forName",
new Class[] {
String.class, boolean.class, ClassLoader.class
});
getSystemClassLoaderM = ClassLoader.class.getMethod("getSystemClassLoader", null);
// TODO: may need to invoke RuntimePermission("getClassLoader") privilege
systemClassLoader = (ClassLoader) getSystemClassLoaderM.invoke(ClassLoader.class, null);
getContextClassLoaderM = Thread.class.getMethod("getContextClassLoader", null);
return true;
} catch (Throwable t) {
forName3ArgsM = null;
return false;
}
|
protected void | error()
throw new RuntimeException(getClass().getName() + " PlugIn error");
|
public static java.lang.Class | getClassForName(java.lang.String className)
/**
* Note: if we don't want this functionality
* just replace it with Class.forName(className)
*/
try {
return Class.forName(className);
} catch (Exception e) {
if (!checkIfJDK12()) {
throw new ClassNotFoundException(e.getMessage());
}
} catch (Error e) {
if (!checkIfJDK12()) {
throw e;
}
}
/**
* In jdk1.2 application, when you have jmf.jar in the ext directory and
* you want to access a class that is not in jmf.jar but is in the CLASSPATH,
* you have to load it using the the system class loader.
*/
try {
return (Class) forName3ArgsM.invoke(Class.class, new Object[] {
className, new Boolean(true), systemClassLoader});
} catch (Throwable e) {
}
/**
* In jdk1.2 applet, when you have jmf.jar in the ext directory and
* you want to access a class that is not in jmf.jar but applet codebase,
* you have to load it using the the context class loader.
*/
try {
// TODO: may need to invoke RuntimePermission("getClassLoader") privilege
ClassLoader contextClassLoader =
(ClassLoader) getContextClassLoaderM.invoke(Thread.currentThread(), null);
return (Class) forName3ArgsM.invoke(Class.class, new Object[] {
className, new Boolean(true), contextClassLoader});
} catch (Exception e) {
throw new ClassNotFoundException(e.getMessage());
} catch (Error e) {
throw e;
}
|
public java.lang.Object | getControl(java.lang.String controlType)Return the control based on a control type for the PlugIn.
try {
Class cls = Class.forName(controlType);
Object cs[] = getControls();
for (int i = 0; i < cs.length; i++) {
if (cls.isInstance(cs[i]))
return cs[i];
}
return null;
} catch (Exception e) { // no such controlType or such control
return null;
}
|
public java.lang.Object[] | getControls()no controls
return (Object[]) controls;
|
protected java.lang.Object | getInputData(javax.media.Buffer inBuffer)
Object inData = null;
if (inBuffer instanceof ExtBuffer) {
((ExtBuffer)inBuffer).setNativePreferred(true);
inData = ((ExtBuffer)inBuffer).getNativeData();
}
if (inData == null)
inData = inBuffer.getData();
return inData;
|
protected final long | getNativeData(java.lang.Object data)
if (data instanceof NBA)
return ((NBA)data).getNativeData();
else
return 0;
|
protected java.lang.Object | getOutputData(javax.media.Buffer buffer)
Object data = null;
if (buffer instanceof ExtBuffer) {
data = ((ExtBuffer)buffer).getNativeData();
}
if (data == null)
data = buffer.getData();
return data;
|
public static javax.media.Format | matches(javax.media.Format in, javax.media.Format[] outs)Utility to perform format matching.
for (int i = 0; i < outs.length; i++) {
if (in.matches(outs[i]))
return outs[i];
}
return null;
|
public static boolean | plugInExists(java.lang.String name, int type)Check to see if a particular plugin exists in the registry.
Vector cnames = PlugInManager.getPlugInList(null, null, type);
for (int i = 0; i < cnames.size(); i++) {
if (name.equals((String)(cnames.elementAt(i))))
return true;
}
return false;
|
protected byte[] | validateByteArraySize(javax.media.Buffer buffer, int newSize)validate that the Buffer object's data size is at least newSize.
Object objectArray=buffer.getData();
byte[] typedArray;
if (objectArray instanceof byte[]) { // is correct type AND not null
typedArray=(byte[])objectArray;
if (typedArray.length >= newSize ) { // is sufficient capacity
return typedArray;
}
byte[] tempArray=new byte[newSize]; // re-alloc array
System.arraycopy(typedArray,0,tempArray,0,typedArray.length);
typedArray = tempArray;
} else {
typedArray = new byte[newSize];
}
if (DEBUG) System.out.println(getClass().getName()+
" : allocating byte["+newSize+"] data");
buffer.setData(typedArray);
return typedArray;
|
protected java.lang.Object | validateData(javax.media.Buffer buffer, int length, boolean allowNative)
Format format = buffer.getFormat();
Class dataType = format.getDataType();
if (length < 1 && format != null) {
if (format instanceof VideoFormat)
length = ((VideoFormat)format).getMaxDataLength();
}
if (allowNative && buffer instanceof ExtBuffer &&
((ExtBuffer)buffer).isNativePreferred()) {
ExtBuffer extb = (ExtBuffer) buffer;
if (extb.getNativeData() == null ||
extb.getNativeData().getSize() < length)
extb.setNativeData(new NBA(format.getDataType(), length));
return extb.getNativeData();
} else {
if (dataType == Format.byteArray)
return validateByteArraySize(buffer, length);
else if (dataType == Format.shortArray)
return validateShortArraySize(buffer, length);
else if (dataType == Format.intArray)
return validateIntArraySize(buffer, length);
else {
System.err.println("Error in validateData");
return null;
}
}
|
protected int[] | validateIntArraySize(javax.media.Buffer buffer, int newSize)validate that the Buffer object's data size is at least newSize.
Object objectArray=buffer.getData();
int[] typedArray;
if (objectArray instanceof int[]) { // is correct type AND not null
typedArray=(int[])objectArray;
if (typedArray.length >= newSize ) { // is sufficient capacity
return typedArray;
}
int[] tempArray=new int[newSize]; // re-alloc array
System.arraycopy(typedArray,0,tempArray,0,typedArray.length);
typedArray = tempArray;
} else {
typedArray = new int[newSize];
}
if (DEBUG) System.out.println(getClass().getName()+
" : allocating int["+newSize+"] data");
buffer.setData(typedArray);
return typedArray;
|
protected short[] | validateShortArraySize(javax.media.Buffer buffer, int newSize)validate that the Buffer object's data size is at least newSize.
Object objectArray=buffer.getData();
short[] typedArray;
if (objectArray instanceof short[]) { // is correct type AND not null
typedArray=(short[])objectArray;
if (typedArray.length >= newSize ) { // is sufficient capacity
return typedArray;
}
short[] tempArray=new short[newSize]; // re-alloc array
System.arraycopy(typedArray,0,tempArray,0,typedArray.length);
typedArray = tempArray;
} else {
typedArray = new short[newSize];
}
if (DEBUG) System.out.println(getClass().getName()+
" : allocating short["+newSize+"] data");
buffer.setData(typedArray);
return typedArray;
|