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
FieldsModifier and TypeFieldDescriptionstatic final AudioFormatstatic final StringAAC Codecstatic final StringMP3 Codecstatic final StringPCM A-lawstatic final StringPCM Signedstatic final StringPCM u-lawstatic final StringPCM Unsignedstatic final StringVorbis Codecstatic final StringAudioCodecencoded data without any container header or footer, e.g.static final StringOGG container formatstatic final StringMicrosofts wave container formatstatic final AudioFormatstatic final AudioFormatstatic final AudioFormat -
Constructor Summary
ConstructorsConstructorDescriptionAudioFormat(@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 TypeMethodDescriptionbooleanstatic @Nullable AudioFormatgetBestMatch(Set<AudioFormat> inputs, Set<AudioFormat> outputs) Determines the best match between a list of audio formats supported by a source and a sink.@Nullable IntegerGets bit depth@Nullable IntegerGets bit rate@Nullable IntegerGets channel number@Nullable StringgetCodec()Gets codec@Nullable StringGets container@Nullable LongGets frequencystatic @Nullable AudioFormatgetPreferredFormat(Set<AudioFormat> audioFormats) Gets the first concrete AudioFormat in the passed set or a preferred one based on 16bit, 16KHz, big endian defaultinthashCode()@Nullable BooleanIs big endian?booleanisCompatible(@Nullable AudioFormat audioFormat) Determines if the passed AudioFormat is compatible with this AudioFormat.toString()
-
Field Details
-
MP3
-
WAV
-
OGG
-
AAC
-
CONTAINER_NONE
AudioCodecencoded 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
-