Java源码示例:javazoom.jl.decoder.Decoder

示例1
public Player(InputStream stream, AudioDevice device) throws JavaLayerException
{
	bitstream = new Bitstream(stream);		
	decoder = new Decoder();
			
	if (device!=null)
	{		
		audio = device;
	}
	else
	{			
		FactoryRegistry r = FactoryRegistry.systemRegistry();
		audio = r.createAudioDevice();
	}
	audio.open(decoder);
}
 
示例2
public Player(InputStream stream, AudioDevice device) throws JavaLayerException
{
	bitstream = new Bitstream(stream);		
	decoder = new Decoder();
			
	if (device!=null)
	{		
		audio = device;
	}
	else
	{			
		FactoryRegistry r = FactoryRegistry.systemRegistry();
		audio = r.createAudioDevice();
	}
	audio.open(decoder);
}
 
示例3
public MP3SOUNDDATA(SWFInputStream sis, boolean raw) throws IOException {
    if (!raw) {
        seekSamples = sis.readSI16("seekSamples");
    }
    frames = new ArrayList<>();
    MP3FRAME f;
    Decoder decoder = new Decoder();
    Bitstream bitstream = new Bitstream(new ByteArrayInputStream(sis.readBytesEx(sis.available(), "soundStream")));
    while ((f = MP3FRAME.readFrame(bitstream, decoder)) != null) {
        frames.add(f);
    }
}
 
示例4
public void convert(String sourceName, String destName,
	ProgressListener progressListener, Decoder.Params decoderParams)
	throws JavaLayerException
{
	if (destName.length()==0)
		destName = null;
	try {
		InputStream in = openInput(sourceName);
		convert(in, destName, progressListener, decoderParams);
		in.close();
	} catch(IOException ioe) {
		throw new JavaLayerException(ioe.getLocalizedMessage(), ioe);
	}
}
 
示例5
/**
 * Opens this audio device. 
 * 
 * @param decoder	The decoder that will provide audio data
 *					to this audio device. 
 */
public synchronized void open(Decoder decoder) throws JavaLayerException
{
	if (!isOpen())
	{
		this.decoder = decoder;
		openImpl();
		setOpen(true);
	}
}
 
示例6
public AdvancedPlayer(InputStream stream, AudioDevice device) throws JavaLayerException
{
	bitstream = new Bitstream(stream);

	if (device!=null) audio = device;
	else audio = FactoryRegistry.systemRegistry().createAudioDevice();
	audio.open(decoder = new Decoder());
}
 
示例7
public void convert(String sourceName, String destName,
	ProgressListener progressListener, Decoder.Params decoderParams)
	throws JavaLayerException
{
	if (destName.length()==0)
		destName = null;
	try {
		InputStream in = openInput(sourceName);
		convert(in, destName, progressListener, decoderParams);
		in.close();
	} catch(IOException ioe) {
		throw new JavaLayerException(ioe.getLocalizedMessage(), ioe);
	}
}
 
示例8
/**
 * Opens this audio device. 
 * 
 * @param decoder	The decoder that will provide audio data
 *					to this audio device. 
 */
public synchronized void open(Decoder decoder) throws JavaLayerException
{
	if (!isOpen())
	{
		this.decoder = decoder;
		openImpl();
		setOpen(true);
	}
}
 
示例9
public AdvancedPlayer(InputStream stream, AudioDevice device) throws JavaLayerException {
    bitstream = new Bitstream(stream);

    if (device != null) {
        audio = device;
    } else {
        audio = FactoryRegistry.systemRegistry().createAudioDevice();
    }
    audio.open(decoder = new Decoder());
}
 
示例10
@Override
public void decode(InputStream inputStream) throws Exception {
    Decoder decoder = new Decoder();
    Bitstream bitstream = new Bitstream(inputStream);
    Header header;
    isStopRead = false;
    isGetMp3InfoFinished = false;
    int count = 0;
    while (!isStopRead && (header = bitstream.readFrame()) != null) {
        isDecoding = true;
        long start = System.currentTimeMillis();
        SampleBuffer sampleBuffer = (SampleBuffer) decoder.decodeFrame(header, bitstream);
        // 获取采样率等
        if (!isGetMp3InfoFinished) {
            fireOnDecodeInfo(sampleBuffer.getSampleFrequency(), sampleBuffer.getChannelCount());
            isGetMp3InfoFinished = true;
        }
        short[] buffer = sampleBuffer.getBuffer();
        byte[] pcm = new byte[buffer.length / 2];
        for (int i = 0; i < buffer.length / 2 / 2; i++) {
            int j = i * 2;
            pcm[j] = (byte) (buffer[i] & 0xff);
            pcm[j + 1] = (byte) ((buffer[i] >> 8) & 0xff);
        }
        if (count == 0 || count == 1) {
            byte[] newPcm = avoidNullPcm(pcm);
            if (newPcm != null) {
                fireOnDecodePcm(newPcm);
            }
        } else {
            fireOnDecodePcm(pcm);
        }
        count++;
        bitstream.closeFrame();
        long end = System.currentTimeMillis();
        Log.i(TAG, "after decode pcm.length:" + pcm.length + "," + (end - start));
    }
    isDecoding = false;
    fireOnDecodeFinished();
    inputStream.close();
}
 
示例11
/**
 * Retrieves the decoder that provides audio data to this
 * audio device.
 * 
 * @return The associated decoder. 
 */
protected Decoder getDecoder()
{
	return decoder;	
}
 
示例12
/**
 * Prepares the AudioDevice for playback of audio samples. 
 * @param decoder	The decoder that will be providing the audio
 *					samples. 
 * 
 * If the audio device is already open, this method returns silently. 
 * 
 */
public void open(Decoder decoder) throws JavaLayerException;
 
示例13
/**
 * Retrieves the decoder that provides audio data to this
 * audio device.
 * 
 * @return The associated decoder. 
 */
protected Decoder getDecoder()
{
	return decoder;	
}
 
示例14
/**
 * Prepares the AudioDevice for playback of audio samples. 
 * @param decoder	The decoder that will be providing the audio
 *					samples. 
 * 
 * If the audio device is already open, this method returns silently. 
 * 
 */
public void open(Decoder decoder) throws JavaLayerException;