Package org.openhab.core.audio
Class AudioFormat
java.lang.Object
org.openhab.core.audio.AudioFormat
An audio format definition
- Author:
- Harald Kuhn - Initial contribution, Kelly Davis - Modified to match discussion in #584, Kai Kreuzer - Moved class, included constants, added toString
-
Field Summary
Modifier and TypeFieldDescriptionstatic final AudioFormat
static final String
AAC Codecstatic final String
MP3 Codecstatic final String
PCM A-lawstatic final String
PCM Signedstatic final String
PCM u-lawstatic final String
PCM Unsignedstatic final String
Vorbis Codecstatic final String
AudioCodec
encoded data without any container header or footer, e.g.static final String
OGG container formatstatic final String
Microsofts wave container formatstatic final AudioFormat
static final AudioFormat
static final AudioFormat
-
Constructor Summary
ConstructorDescriptionAudioFormat
(@Nullable String container, @Nullable String codec, @Nullable Boolean bigEndian, @Nullable Integer bitDepth, @Nullable Integer bitRate, @Nullable Long frequency) Constructs an instance with the specified properties.AudioFormat
(@Nullable String container, @Nullable String codec, @Nullable Boolean bigEndian, @Nullable Integer bitDepth, @Nullable Integer bitRate, @Nullable Long frequency, @Nullable Integer channels) Constructs an instance with the specified properties. -
Method Summary
Modifier and TypeMethodDescriptionboolean
static @Nullable AudioFormat
getBestMatch
(Set<AudioFormat> inputs, Set<AudioFormat> outputs) Determines the best match between a list of audio formats supported by a source and a sink.@Nullable Integer
Gets bit depth@Nullable Integer
Gets bit rate@Nullable Integer
Gets channel number@Nullable String
getCodec()
Gets codec@Nullable String
Gets container@Nullable Long
Gets frequencystatic @Nullable AudioFormat
getPreferredFormat
(Set<AudioFormat> audioFormats) Gets the first concrete AudioFormat in the passed set or a preferred one based on 16bit, 16KHz, big endian defaultint
hashCode()
@Nullable Boolean
Is big endian?boolean
isCompatible
(@Nullable AudioFormat audioFormat) Determines if the passed AudioFormat is compatible with this AudioFormat.toString()
-
Field Details
-
MP3
-
WAV
-
OGG
-
AAC
-
CONTAINER_NONE
AudioCodec
encoded data without any container header or footer, e.g. MP3 is a non-container format- See Also:
-
CONTAINER_WAVE
Microsofts wave container format -
CONTAINER_OGG
OGG container format- See Also:
-
CODEC_PCM_SIGNED
PCM Signed- See Also:
-
CODEC_PCM_UNSIGNED
PCM Unsigned- See Also:
-
CODEC_PCM_ALAW
PCM A-law- See Also:
-
CODEC_PCM_ULAW
PCM u-law- See Also:
-
CODEC_MP3
MP3 Codec- See Also:
-
CODEC_VORBIS
Vorbis Codec- See Also:
-
CODEC_AAC
AAC Codec- See Also:
-
-
Constructor Details
-
AudioFormat
public AudioFormat(@Nullable String container, @Nullable String codec, @Nullable Boolean bigEndian, @Nullable Integer bitDepth, @Nullable Integer bitRate, @Nullable Long frequency) Constructs an instance with the specified properties. Note that any properties that are null indicate that the corresponding AudioFormat allows any value for the property. Concretely this implies that if, for example, one passed null for the value of frequency, this would mean the created AudioFormat allowed for any valid frequency.- Parameters:
container
- The container for the audiocodec
- The audio codecbigEndian
- If the audo data is big endianbitDepth
- The bit depth of the audo databitRate
- The bit rate of the audiofrequency
- The frequency at which the audio was sampled
-
AudioFormat
public AudioFormat(@Nullable String container, @Nullable String codec, @Nullable Boolean bigEndian, @Nullable Integer bitDepth, @Nullable Integer bitRate, @Nullable Long frequency, @Nullable Integer channels) Constructs an instance with the specified properties. Note that any properties that are null indicate that the corresponding AudioFormat allows any value for the property. Concretely this implies that if, for example, one passed null for the value of frequency, this would mean the created AudioFormat allowed for any valid frequency.- Parameters:
container
- The container for the audiocodec
- The audio codecbigEndian
- If the audo data is big endianbitDepth
- The bit depth of the audo databitRate
- The bit rate of the audiofrequency
- The frequency at which the audio was sampledchannels
- The number of channels
-
-
Method Details
-
getCodec
Gets codec- Returns:
- The codec
-
getContainer
Gets container- Returns:
- The container
-
isBigEndian
Is big endian?- Returns:
- If format is big endian
-
getBitDepth
Gets bit depth- Returns:
- Bit depth
- See Also:
-
getBitRate
Gets bit rate- Returns:
- Bit rate
- See Also:
-
getFrequency
Gets frequency- Returns:
- The frequency
-
getChannels
Gets channel number- Returns:
- The number of channels
-
isCompatible
Determines if the passed AudioFormat is compatible with this AudioFormat. This AudioFormat is compatible with the passed AudioFormat if both have the same value for all non-null members of this instance. -
getBestMatch
Determines the best match between a list of audio formats supported by a source and a sink.- Parameters:
inputs
- the supported audio formats of an audio sourceoutputs
- the supported audio formats of an audio sink- Returns:
- the best matching format or null, if source and sink are incompatible
-
getPreferredFormat
Gets the first concrete AudioFormat in the passed set or a preferred one based on 16bit, 16KHz, big endian default- Parameters:
audioFormats
- The AudioFormats from which to choose- Returns:
- The preferred AudioFormat or null if none could be determined. A passed concrete format is preferred adding default values to an abstract AudioFormat in the passed set.
-
equals
-
hashCode
public int hashCode() -
toString
-