PlugInManagerpublic class PlugInManager extends Object The PlugInManager is used to search for installed plug-ins and
register new plug-ins.
Plug-in Types
JMF defines several types of plug-ins, such as codecs, demultiplexers, and renderers.
Custom plug-in types can also be registered.
The predefined plug-in types are:
- DEMULTIPLEXER = 1
- CODEC = 2
- EFFECT = 3
- RENDERER = 4
- MULTIPLEXER = 5
This PlugInManager is a wrapper for the actual implementation, which it
expects to find in javax.media.pim.PlugInManager . If this implementation
exists and is an instance of javax.media.PlugInManager , all calls to
javax.media.PlugInManager are redirected to javax.media.pim.PlugInManager .
If the implementation is not found, all calls to javax.media.PlugInManager methods
will fail and return null or invalid data. |
Fields Summary |
---|
private static PlugInManager | pim | public static final int | DEMULTIPLEXERDemultiplexer plug-in type. | public static final int | CODECCodec plug-in type. | public static final int | EFFECTEffect plug-in type. | public static final int | RENDERERRenderer plug-in type. | public static final int | MULTIPLEXERMultiplexer plug-in type. | private static Method | mGetPlugInList | private static Method | mSetPlugInList | private static Method | mCommit | private static Method | mAddPlugIn | private static Method | mRemovePlugIn | private static Method | mGetSupportedInputFormats | private static Method | mGetSupportedOutputFormats | private static Format[] | emptyFormat |
Methods Summary |
---|
public static boolean | addPlugIn(java.lang.String classname, javax.media.Format[] in, javax.media.Format[] out, int type)Registers a new plug-in. This plug-in is automatically appended
to the list of plug-ins searched when a Processor is created.
Registration will fail if a plug-in of the same name
already exists. The commit method has to be called to make the
addition permanent.
if (pim != null && mAddPlugIn != null) {
Object params[] = new Object[4];
params[0] = classname;
params[1] = in;
params[2] = out;
params[3] = new Integer(type);
Object result = runMethod(mAddPlugIn, params);
if (result != null)
return ((Boolean)result).booleanValue();
else
return false;
} else
return false;
| public static void | commit()Commits any changes made to the plug-in list.
The commit method must be called when a plug-in is added or removed
to make the change permanent.
Changes to the search
order can also be made permanent by calling commit .
if (pim != null && mCommit != null) {
runMethod(mCommit, null);
}
| public static java.util.Vector | getPlugInList(javax.media.Format input, javax.media.Format output, int type)Builds a list of plug-ins that satisfy the specified plug-in type and input and
output formats. Either or both of the formats can be null.
If input is null, getPlugInList
returns a list of plug-ins of the specified type that match the output format. If output is
null, getPlugInList returns a list of plug-ins of the specified type that match the input format.
If both parameters are null, getPlugInList returns a list of all of the
plug-ins of the specified type.
if (pim != null && mGetPlugInList != null) {
Object params[] = new Object[3];
params[0] = input;
params[1] = output;
params[2] = new Integer(type);
return (Vector) runMethod(mGetPlugInList, params);
} else
return new Vector(1);
| public static javax.media.Format[] | getSupportedInputFormats(java.lang.String className, int type)Gets a list of the input formats that the specified plug-in supports.
if (pim != null && mGetSupportedInputFormats != null) {
Object params[] = new Object[2];
params[0] = className;
params[1] = new Integer(type);
Object result = runMethod(mGetSupportedInputFormats, params);
return (Format[]) result;
} else
return emptyFormat;
| public static javax.media.Format[] | getSupportedOutputFormats(java.lang.String className, int type)Gets a list of the output formats that the specified plug-in supports.
if (pim != null && mGetSupportedOutputFormats != null) {
Object params[] = new Object[2];
params[0] = className;
params[1] = new Integer(type);
Object result = runMethod(mGetSupportedOutputFormats, params);
return (Format[]) result;
} else
return emptyFormat;
| public static boolean | removePlugIn(java.lang.String classname, int type)Removes an existing plug-in from the registry. The commit method has
to be called to make this change permanent.
if (pim != null && mRemovePlugIn != null) {
Object params[] = new Object[2];
params[0] = classname;
params[1] = new Integer(type);
Object result = runMethod(mRemovePlugIn, params);
if (result != null)
return ((Boolean)result).booleanValue();
else
return false;
} else
return false;
| static java.lang.Object | runMethod(java.lang.reflect.Method m, java.lang.Object[] params)
// Look for javax.media.pim.PlugInManager
Class classPIM = null;
try {
classPIM = Class.forName("javax.media.pim.PlugInManager");
if (classPIM != null) {
Object tryPIM = classPIM.newInstance();
if (tryPIM instanceof PlugInManager) {
pim = (PlugInManager) tryPIM;
mGetSupportedInputFormats =
PackageManager.getDeclaredMethod(classPIM, "getSupportedInputFormats",
new Class[] {String.class, int.class});
mGetSupportedOutputFormats =
PackageManager.getDeclaredMethod(classPIM, "getSupportedOutputFormats",
new Class[] {String.class, int.class});
mGetPlugInList =
PackageManager.getDeclaredMethod(classPIM, "getPlugInList",
new Class[] { Format.class,
Format.class,
int.class} );
mSetPlugInList =
PackageManager.getDeclaredMethod(classPIM, "setPlugInList",
new Class[] {Vector.class, int.class});
mAddPlugIn =
PackageManager.getDeclaredMethod(classPIM, "addPlugIn",
new Class[] {String.class,
Format.formatArray,
Format.formatArray,
int.class});
mRemovePlugIn =
PackageManager.getDeclaredMethod(classPIM, "removePlugIn",
new Class[] {String.class, int.class});
mCommit =
PackageManager.getDeclaredMethod(classPIM, "commit", null);
}
}
} catch (ClassNotFoundException e) {
System.err.println(e);
} catch (InstantiationException e) {
System.err.println(e);
} catch (IllegalAccessException e) {
System.err.println(e);
} catch (SecurityException e) {
System.err.println(e);
} catch (NoSuchMethodException e) {
System.err.println(e);
}
try {
return m.invoke(null, params);
} catch (IllegalAccessException iae) {
System.err.println(iae);
} catch (IllegalArgumentException iare) {
System.err.println(iare);
} catch (InvocationTargetException ite) {
System.err.println(ite);
}
return null;
| public static void | setPlugInList(java.util.Vector plugins, int type)Sets the search order for the plug-ins of the specified type. This enables
you to control what plug-in is selected when multiple plug-ins of a particular
type support the same input and output formats. (The first match is selected by
the Processor .)
This list is valid
for the duration of the session only, unless commit is
called.
if (pim != null && mSetPlugInList != null) {
Object params[] = new Object[2];
params[0] = plugins;
params[1] = new Integer(type);
runMethod(mSetPlugInList, params);
}
|
|