Class FlacStream
- All Implemented Interfaces:
Closeable,AutoCloseable,AudioStream,Device.Player,PcmWriter
fileEncoder.-
Nested Class Summary
Nested classes/interfaces inherited from interface net.avadeaux.klipspringer.codec.AudioStream
AudioStream.Factory -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Device.BitLayoutThe bit layout for PCM data sent to a FLAC stream.static final booleanTrue if OGG FLAC is supported. -
Constructor Summary
ConstructorsConstructorDescriptionFlacStream(PcmFormat format, boolean ogg, int comprLevel, int bufferFrames, double writeaheadSecs, double timeoutSecs, int holdingBytes, WritableByteChannel channel, Executor keepAlivePool, double keepAliveTimeoutSecs) Creates a FLAC stream with the given specifications and destination channel. -
Method Summary
Modifier and TypeMethodDescriptionstatic PcmWriterfileEncoder(String fileName, PcmFormat dataFormat, int comprLevel) Gets a player that encodes to a file rather than a stream.layout()Gets the bit layout expected by the player.static PcmFormatselectFormat(AudioFormat fmt) Selects format suitable for FLAC streaming with the same semantics asPcmFormat.Selector.selectFormat(AudioFormat).Methods inherited from class net.avadeaux.klipspringer.codec.ExternalEncodedStream
close, drain, format, playedMillis, streaming, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.avadeaux.klipspringer.codec.AudioStream
qualityMethods inherited from interface net.avadeaux.klipspringer.codec.Device.Player
bufferedFrames, canPause, pause, unpause
-
Field Details
-
BIT_LAYOUT
The bit layout for PCM data sent to a FLAC stream. -
oggSupported
public static final boolean oggSupportedTrue if OGG FLAC is supported. This is set to false if libFLAC is subject to an issue that renders the number of samples in an encoding chunk unknown.
-
-
Constructor Details
-
FlacStream
public FlacStream(PcmFormat format, boolean ogg, int comprLevel, int bufferFrames, double writeaheadSecs, double timeoutSecs, int holdingBytes, WritableByteChannel channel, Executor keepAlivePool, double keepAliveTimeoutSecs) throws IOException Creates a FLAC stream with the given specifications and destination channel.The
holdingBytesparameter is used when streaming to recipient that does not begin to process the input until it has accumulated a certain amount of compressed data, causing the recipient to potentially stall when receiving highly compressible sound (such as silence). In particular, web browsers sometimes do this. When streaming to a web browser, a reasonable value to prevent stalling is 49152. When the destination is a file or something else that does not process audio in real time, it can be set to 0.If
keepAliveExecis non-null, it is used byExternalEncodedStream.close()to execute a wait loop that terminates when either the recipient has sent callback notification of having played (almost) all the data it has been sent, or no callback is made forkeepAliveTimeoutSecsseconds. (See alsoExternalEncodedStream.drain().)- Throws:
IOException
-
-
Method Details
-
selectFormat
Selects format suitable for FLAC streaming with the same semantics asPcmFormat.Selector.selectFormat(AudioFormat).- Throws:
UnsupportedFormatException
-
layout
Description copied from interface:Device.PlayerGets the bit layout expected by the player. If the player is produced by aFactory, the layout should match the value returned byDevice.Player.Factory.layout(PcmFormat), and if the player is associated with a device, this should match what is returned byDevice.layout(PcmFormat). Default returnsDevice.BitLayout.LSB. Default returnsDevice.BitLayout.LSB. -
fileEncoder
public static PcmWriter fileEncoder(String fileName, PcmFormat dataFormat, int comprLevel) throws IOException Gets a player that encodes to a file rather than a stream.- Throws:
IOException
-