Package org.openhab.core.audio.utils
Class AudioFormatMatcher
java.lang.Object
org.openhab.core.audio.utils.AudioFormatMatcher
Utility class for audio format negotiation and matching between audio sources, sinks, and voice services.
- Author:
- Florian Hotze - Initial contribution
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable AudioFormatgetBestMatch(Set<AudioFormat> inputs, Set<AudioFormat> outputs) Determines the best matching audio format between inputs and outputs without transcoding.static @Nullable AudioFormatgetBestMatchWithTranscoding(Set<AudioFormat> sourceSupportedFormats, Set<AudioFormat> targetSupportedFormats) Determines the best matching audio format between source formats and target formats, taking transcoding capabilities into account.static @Nullable AudioFormatgetPreferredFormat(Set<AudioFormat> audioFormats) Determines a preferred concrete audio format from a set of supported formats.static booleanisPcmCodec(@Nullable String codec) Returns whether the given codec is a PCM codec.static booleanisPcmFormat(AudioFormat format) static booleanisWaveFormat(AudioFormat format)
-
Method Details
-
isPcmCodec
Returns whether the given codec is a PCM codec.- Parameters:
codec- a codec- Returns:
- true if the codec is a PCM codec, false otherwise
-
getPreferredFormat
Determines a preferred concrete audio format from a set of supported formats. Prefers PCM (uncontainerized signed PCM) over WAVE container formats and fills default attributes if abstract.- Parameters:
audioFormats- set of candidate audio formats- Returns:
- a preferred concrete audio format, or null if none could be determined
-
isPcmFormat
-
isWaveFormat
-
getBestMatch
Determines the best matching audio format between inputs and outputs without transcoding.- Parameters:
inputs- candidate input formatsoutputs- candidate output formats- Returns:
- the best matching audio format, or null if incompatible
-
getBestMatchWithTranscoding
public static @Nullable AudioFormat getBestMatchWithTranscoding(Set<AudioFormat> sourceSupportedFormats, Set<AudioFormat> targetSupportedFormats) Determines the best matching audio format between source formats and target formats, taking transcoding capabilities into account.- Parameters:
sourceSupportedFormats- candidate source formatstargetSupportedFormats- candidate target formats- Returns:
- a format suitable for the source (and transcoding if needed), or null if none
-