Package org.openhab.core.audio
Class PipedAudioStream
java.lang.Object
java.io.InputStream
org.openhab.core.audio.AudioStream
org.openhab.core.audio.PipedAudioStream
- All Implemented Interfaces:
Closeable,AutoCloseable
This is an implementation of an
AudioStream used to transmit raw audio data to a sink.
It just pipes the audio through it, the default pipe size is equal to 0.5 seconds of audio,
the implementation locks if you set a pipe size lower to the byte length used to write.
In order to support audio multiplex out of the box you should create a PipedAudioStream.Group instance
which can be used to create the PipedAudioStream connected to it and then write to all of them though the
group.- Author:
- Miguel Álvarez Díez - Initial contribution
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThePipedAudioStream.Groupis anOutputStreamimplementation that can be use to create one or morePipedAudioStreaminstances and write to them at once. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPipedAudioStream(AudioFormat format, int pipeSize, PipedOutputStream outputStream) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Gets the supported audio formatprotected PipedOutputStreamstatic PipedAudioStream.GroupnewGroup(AudioFormat format) Creates a new piped stream group used to open new streams and write data to them.static PipedAudioStream.GroupnewGroup(AudioFormat format, int pipeSize) Creates a new piped stream group used to open new streams and write data to them.voidAdd a new handler that will be executed on stream close.intread()intread(byte @Nullable [] b) intread(byte @Nullable [] b, int off, int len) Methods inherited from class org.openhab.core.audio.AudioStream
getIdMethods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
PipedAudioStream
protected PipedAudioStream(AudioFormat format, int pipeSize, PipedOutputStream outputStream) throws IOException - Throws:
IOException
-
-
Method Details
-
getFormat
Description copied from class:AudioStreamGets the supported audio format- Specified by:
getFormatin classAudioStream- Returns:
- The supported audio format
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
onClose
Add a new handler that will be executed on stream close. It will be chained to the previous handler if any, and executed in order.- Parameters:
onClose- block to run on stream close
-
getOutputStream
-
newGroup
Creates a new piped stream group used to open new streams and write data to them. Internal pipe size is 0.5s.- Parameters:
format- the audio format of the group audio streams- Returns:
- a group instance
-
newGroup
Creates a new piped stream group used to open new streams and write data to them.- Parameters:
format- the audio format of the group audio streamspipeSize- the pipe size of the created streams- Returns:
- a piped stream group instance
-