Methods Summary |
---|
private native boolean | ACMProcess(long nativeHandle, byte[] input, int inputOffset, int inputLength, javax.media.Buffer inputBuffer, byte[] output, int outputLength, javax.media.Buffer outputBuffer)Does the ACM codec processing
|
public void | close()Closes the plug-in component and releases resources. No more data
will be accepted by the plug-in after a call to this method. The
plug-in can be reinstated after being closed by calling
open .
closeACMStream(nativeHandle);
|
private native void | closeACMStream(long nativeHandle)Closes the ACM stream used for transcoding.
|
private native void | fillSupportedInputFormats()Fills the supportedInputFormat Vector with the ACM supported input
formats.
|
private native void | fillSupportedOutputFormats(javax.media.format.AudioFormat input)Fills the supportedOutputFormat Vector with the ACM supported output
formats.
|
public javax.media.Format[] | getBaseInputFormats()An array of format objects that cover the generic input formats
that this plugin supports. For example, a VideoRenderer may not
know the exact RGBFormat it supports, so it returns a dummy RGBFormat
with mostly unspecified values.
Format[] formats = new Format[1];
formats[0] = new AudioFormat(null);
return formats;
|
public javax.media.Format[] | getBaseOutputFormats()An array of format objects that cover the generic output formats
that this plugin supports. For example, a Codec may not
know the exact output RGBFormat it supports, so it returns a dummy
RGBFormat with mostly unspecified values.
return getBaseInputFormats();
|
public java.lang.Object | getControl(java.lang.String controlType)Obtain the object that implements the specified
Class or Interface
The full class or interface name must be used.
If the control is not supported then null
is returned.
// no controls implemented
return null;
|
public java.lang.Object[] | getControls()Obtain the collection of objects that
control the object that implements this interface.
If no controls are supported, a zero length
array is returned.
com.sun.media.JMFSecurityManager.loadLibrary("jmacm");
// no controls implemented
return new Control[0];
|
private native int | getDestinationBufferSize(long nativeHandle, int input)Gets the estimated size of the destination data.
|
public java.lang.String | getName()Returns a descriptive name for the plug-in.
This is a user readable string.
return "ACM Wrapper Codec";
|
public javax.media.Format[] | getSupportedInputFormats()Lists the possible input formats supported by this plug-in.
if (inputFormats != null)
return inputFormats;
else {
supportedInputFormats = new Vector();
fillSupportedInputFormats();
int size = supportedInputFormats.size();
inputFormats = new AudioFormat[size];
for (int index = 0; index < size; index++) {
inputFormats[index] = (AudioFormat)supportedInputFormats.elementAt(index);
}
return inputFormats;
}
|
public javax.media.Format[] | getSupportedOutputFormats(javax.media.Format input)Lists the possible output formats of the processed data.
If input is non-null, then it lists the possible
output formats given that the input buffer is of the format specified
by input . If input is null, then it lists
all possible output formats that this plug-in advertises.
if (input == null) {
outputFormats= new AudioFormat[1];
outputFormats[0] = new AudioFormat(null);
return outputFormats;
}
if (!(input instanceof AudioFormat)) {
outputFormats = new AudioFormat[0];
return outputFormats;
}
else {
/* fillSuppotedFormats(input) is called since each call to
getSupportedOutputFoprmats(input) can have a different
parameter and we wouldn't like to hold all supported formats
for all input possibilites ahead (will be a huge overhead */
supportedOutputFormats = new Vector();
fillSupportedOutputFormats((AudioFormat)input);
int size = supportedOutputFormats.size();
outputFormats = new AudioFormat[size];
for (int index = 0; index < size; index++)
outputFormats[index] = (AudioFormat)supportedOutputFormats.elementAt(index);
return outputFormats;
}
|
public void | open()Opens the plug-in software or hardware component and acquires
necessary resources. If all the needed resources could not be
acquired, it throws a ResourceUnavailableException. Buffer should not
be passed into the plug-in without first calling this method.
nativeHandle = openACMStream(inputFormat, outputFormat);
if (nativeHandle == 0)
throw new ResourceUnavailableException("ACM stream coun't been opened");
|
private native long | openACMStream(javax.media.format.AudioFormat inputFormat, javax.media.format.AudioFormat outputFormat)Opens an ACM stream to be used for transcoding
|
public int | process(javax.media.Buffer input, javax.media.Buffer output)Process the media
// shouldn't it be done in the module ?
if (input.isEOM()) {
output.setLength(0) ;
output.setEOM(true);
return BUFFER_PROCESSED_OK;
}
int oldInputOffset = input.getOffset();
// preper destination data
int destLength = getDestinationBufferSize(nativeHandle, input.getLength());
if (output.getData() == null ||
destLength > ((byte[])output.getData()).length) {
byte[] destination = new byte[destLength];
output.setData(destination);
}
output.setLength(destLength);
output.setOffset(0);
output.setFormat(outputFormat);
if (!ACMProcess(nativeHandle, (byte[])input.getData(), input.getOffset(),
input.getLength(), input, (byte[])output.getData(),
output.getLength(), output))
return BUFFER_PROCESSED_FAILED;
if (oldInputOffset != input.getOffset())
return BUFFER_PROCESSED_OK | INPUT_BUFFER_NOT_CONSUMED;
else
return BUFFER_PROCESSED_OK;
|
public void | reset()Resets the state of the plug-in. Typically at end of media or when media
is repositioned.
resetACMStream(nativeHandle);
|
private native void | resetACMStream(long nativeHandle)Resets the ACM stream.
|
public javax.media.Format | setInputFormat(javax.media.Format format)Set the buffer input format.
if (!(format instanceof AudioFormat)) {
return null;
}
inputFormat = (AudioFormat)format;
return format;
|
public javax.media.Format | setOutputFormat(javax.media.Format format)Set the buffer output format.
if (!(format instanceof AudioFormat))
return null;
outputFormat = (AudioFormat)format;
return format;
|