public class FFCodecInputStream extends FFNativePeerInputStream
FFFormatConversionProvider
to convert a FFAudioInputStream
(not just
any AudioInputStream
) to another AudioFormat
.
Note that we take a shortcut:
Instead of converting the data from the source stream, we re-configure the native underpinnings
of the source stream to produce the data we desire. In other words, we manipulate the
encoder and the SwrContext
of the stream originally opened with FFmpeg.
This of course only works, if the stream to convert is also an FFAudioInputStream
.
This needs to be checked in FFFormatConversionProvider
using the FFAudioFormat.PROVIDER
property of the source format.
nativeBuffer, pointer
Constructor and Description |
---|
FFCodecInputStream(AudioFormat targetFormat,
FFAudioInputStream stream) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
close(long pointer)
Closes the native peer and releases all resources held by it.
|
protected void |
fillNativeBuffer()
Fills
FFNativePeerInputStream.nativeBuffer with new data. |
protected boolean |
isOpen()
Indicates whether the underlying native peer is still available.
|
boolean |
isSeekable() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
void |
seek(long time,
TimeUnit timeUnit) |
finalize
available, mark, markSupported, read, reset, skip
public FFCodecInputStream(AudioFormat targetFormat, FFAudioInputStream stream) throws IOException, UnsupportedAudioFileException
public int read(byte[] b, int off, int len) throws IOException
read
in class FFNativePeerInputStream
IOException
public int read() throws IOException
read
in class FFNativePeerInputStream
IOException
protected boolean isOpen()
FFNativePeerInputStream
isOpen
in class FFNativePeerInputStream
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class FFNativePeerInputStream
IOException
protected void close(long pointer) throws IOException
FFNativePeerInputStream
close
in class FFNativePeerInputStream
pointer
- pointerIOException
- if an IO error occursprotected void fillNativeBuffer() throws IOException
FFNativePeerInputStream
FFNativePeerInputStream.nativeBuffer
with new data.fillNativeBuffer
in class FFNativePeerInputStream
IOException
- if an IO error occurspublic boolean isSeekable()
isSeekable
in class FFNativePeerInputStream
FFAudioInputStream.isSeekable()
public void seek(long time, TimeUnit timeUnit) throws UnsupportedOperationException, IOException
seek
in class FFNativePeerInputStream
time
- timetimeUnit
- time unitIOException
- if an IO error occursUnsupportedOperationException
FFAudioInputStream.seek(long, java.util.concurrent.TimeUnit)
Copyright © 2013–2023 tagtraum industries incorporated. All rights reserved.