Package org.openhab.core.audio
Interface AudioHTTPServer
@NonNullByDefault
public interface AudioHTTPServer
This is an interface that is implemented by
AudioServlet
and which allows
exposing audio streams through HTTP.
Streams are only served a single time and then discarded.- Author:
- Kai Kreuzer - Initial contribution
-
Method Summary
Modifier and TypeMethodDescriptionserve
(AudioStream stream) Deprecated.serve
(AudioStream stream, int seconds) Deprecated.serve
(AudioStream stream, int seconds, boolean multiTimeStream) Creates a relative url for a givenAudioStream
where it can be requested one or multiple times within the given time frame.
-
Method Details
-
serve
Deprecated.Creates a relative url for a givenAudioStream
where it can be requested a single time. Note that the HTTP header only contains "Content-length", if the passed stream is an instance ofSizeableAudioStream
. If the client that requests the url expects this header field to be present, make sure to pass such an instance. Streams are closed after having been served.- Parameters:
stream
- the stream to serve on HTTP- Returns:
- the relative URL to access the stream starting with a '/'
-
serve
Deprecated.Creates a relative url for a givenAudioStream
where it can be requested multiple times within the given time frame. This method accepts allAudioStream
s, but it is better to useClonableAudioStream
s. If genericAudioStream
is used, the method tries to add the Clonable capability by storing it in a small memory buffer, e.gByteArrayAudioStream
, or in a cached file if the stream reached the buffer capacity, or fails if the stream is too long. Streams are closed, once they expire.- Parameters:
stream
- the stream to serve on HTTPseconds
- number of seconds for which the stream is available through HTTP- Returns:
- the relative URL to access the stream starting with a '/'
-
serve
Creates a relative url for a givenAudioStream
where it can be requested one or multiple times within the given time frame. This method accepts allAudioStream
s, but if multiTimeStream is set to true it is better to useClonableAudioStream
s. Otherwise, if a genericAudioStream
is used, the method will then try to add the Clonable capability by storing it in a small memory buffer, e.gByteArrayAudioStream
, or in a cached file if the stream reached the buffer capacity, or fails to render the sound completely if the stream is too long. ACompletableFuture
is used to inform the caller that the playback ends in order to clean resources and run delayed task, such as restoring volume. Streams are closed, once they expire.- Parameters:
stream
- the stream to serve on HTTPseconds
- number of seconds for which the stream is available through HTTP. The stream will be deleted only if not started, so you can set a duration shorter than the track's duration.multiTimeStream
- set to true if this stream should be played multiple time, and thus needs to be made Cloneable if it is not already.- Returns:
- information about the
StreamServed
, including the relative URL to access the stream starting with a '/', and a CompletableFuture to know when the playback ends. - Throws:
IOException
- when the stream is not aClonableAudioStream
and we cannot get or store it on disk.
-
serve(AudioStream, int, boolean)