JavaDecoderpublic class JavaDecoder extends AudioCodec Title:
Description:
Copyright: Copyright (c) 2004
Company: |
Fields Summary |
---|
private int | peer | private boolean | outputDone | private static final boolean | DEBUG | private static boolean | bigEndian |
Constructors Summary |
---|
public JavaDecoder()
////////////////////////////////////////////////////////////////////////////
// Variables
try {
//System.loadLibrary("fobs4jmf");
NativeLibraryFinder.loadLibrary(JavaDecoder.class, "fobs4jmf");
System.out.println("Fobs4JMF - Native shared library found");
bigEndian = isBigEndian();
if(bigEndian == false)
{
System.out.println("Little Endian");
}
else
{
System.out.println("Big Endian");
}
}
catch (UnsatisfiedLinkError e) {
System.out.println("Fobs4JMF - Native shared library NOT found");
e.printStackTrace();
throw new ExceptionInInitializerError(e.getMessage());
}
System.out.println("AVCODEC: Constructor");
supportedInputFormats = new AudioFormat[] {
new AudioFormat("twos"),
new AudioFormat("raw "),
new AudioFormat("ulaw"),
new AudioFormat("alaw"),
new AudioFormat("ima4"),
new AudioFormat("MAC3"),
new AudioFormat("MAC6"),
new AudioFormat(".mp3"),
new AudioFormat("mp4a"),
new AudioFormat("samr"),
new AudioFormat("sawb"),
new AudioFormat("alac")
};
defaultOutputFormats = new AudioFormat[] {
new WavAudioFormat("")};
PLUGIN_NAME = "Fobs Audio Decoder";
|
Methods Summary |
---|
public boolean | checkFormat(javax.media.Format format)
return super.checkFormat(format);
| public void | close()
System.out.println("AVCODEC: close");
close_codec( peer );
| private native boolean | close_codec(int peer)
| private native boolean | convert(int peer, java.lang.Object inData, long inDataBytes, int inOffset, java.lang.Object outData, long outDataBytes, long length, double dts)
| boolean | decodeData(javax.media.Buffer inputBuffer, javax.media.Buffer outputBuffer)
int outMaxLength=131072;//outputFormat.getMaxDataLength();
int inputLength = inputBuffer.getLength();
//byte [] outData = (byte [])validateByteArraySize(outputBuffer,outMaxLength );//outputBuffer.getData();
int [] outData = (int [])validateIntArraySize(outputBuffer,outMaxLength );
long outDataBytes = getNativeData(outData);
byte[] inputData = (byte [])inputBuffer.getData();
long inDataBytes = getNativeData(inputData);
if (inputLength <= 0) {
return false;
}
boolean res = convert(peer, inputData, inDataBytes, inputBuffer.getOffset(), outData, outDataBytes, inputLength, inputBuffer.getTimeStamp()/1000000000.0);
int size = lastAudioSize(peer);
outputBuffer.setLength(size);
return res;
| public void | finalize()
close();
| protected javax.media.Format[] | getMatchingOutputFormats(javax.media.Format in)
System.out.println("AVCODEC: getMatchingOutputFormats");
if (in == null)
return new Format[] { new AudioFormat(AudioFormat.LINEAR) };
AudioFormat af =(AudioFormat) in;
supportedOutputFormats = new AudioFormat[] {
new WavAudioFormat(AudioFormat.LINEAR,
af.getSampleRate(),
af.getSampleSizeInBits(),
af.getChannels(),
af.getFrameSizeInBits(),
(int)(af.getFrameSizeInBits() * af.getSampleRate()/8.0),
af.getEndian(),
af.getSigned(),
(float)af.getFrameRate(), // No FRAME_RATE specified
af.getDataType(),
new byte[0])
};
return supportedOutputFormats;
| private native void | init()
| private native void | init_decoding(int peer, int width, int height)
| private static native boolean | isBigEndian()
| private native int | lastAudioSize(int peer)
| public void | open()
System.out.println("AVCODEC: open");
init();
if (peer == 0)
throw new ResourceUnavailableException("Unable to initialize");
if (inputFormat == null)
throw new ResourceUnavailableException("No input format selected");
if (outputFormat == null)
throw new ResourceUnavailableException("No output format selected");
// init_decoding(peer, videoWidth, videoHeight);
if (!open_codec(peer, inputFormat.getEncoding()))
throw new ResourceUnavailableException("Couldn't open codec for " + inputFormat.toString());
| private native boolean | open_codec(int peer, java.lang.String codec)
| public int | process(javax.media.Buffer inputBuffer, javax.media.Buffer outputBuffer)
if (!checkInputBuffer(inputBuffer) ) {
return BUFFER_PROCESSED_FAILED;
}
if (isEOM(inputBuffer) ) {
propagateEOM(outputBuffer);
return BUFFER_PROCESSED_OK;
}
int outMaxLength=131072;//outputFormat.getMaxDataLength();
Object outDataTmp = getOutputData(outputBuffer);
if ( outDataTmp == null || outputBuffer.getFormat() != outputFormat ||
!outputBuffer.getFormat().equals(outputFormat) ) {
outputBuffer.setLength(outMaxLength);
outputBuffer.setFormat(outputFormat);
}
outDataTmp = validateData(outputBuffer, 0, true);
boolean ret = decodeData(inputBuffer,outputBuffer);
if (ret) {
updateOutput(outputBuffer,outputFormat, outMaxLength, 0);
return BUFFER_PROCESSED_OK;
}
else {
if (DEBUG)
System.out.println("[JavaDecoder] : returning OUTPUT_BUFFER_NOT_FILLED; ");
return OUTPUT_BUFFER_NOT_FILLED;
}
| public void | reset()
System.out.println("AVCODEC: reset");
try {
close();
open();
}
catch(Exception e) {
e.printStackTrace();
}
| public javax.media.Format | setInputFormat(javax.media.Format format)Set the data input format.
System.out.println("AVCODEC: setInputFormat");
if (super.setInputFormat(format) != null) {
AudioFormat af =(AudioFormat)format;
outputFormat = new WavAudioFormat(AudioFormat.LINEAR,
af.getSampleRate(),
af.getSampleSizeInBits(),
af.getChannels(),
af.getFrameSizeInBits(),
(int)(af.getFrameSizeInBits() * af.getSampleRate()/8.0),
af.getEndian(),
af.getSigned(),
(float)af.getFrameRate(), // No FRAME_RATE specified
af.getDataType(),
new byte[0]);
return format;
}
else
return null;
|
|