mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-26 15:21:41 +01:00
[doorbird] Support for more audio streams (#15189)
* [doorbird] Support for more audio streams And proper use of a synchronous base class. --------- Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>
This commit is contained in:
parent
94a761f84e
commit
11512a9db9
@ -13,7 +13,6 @@
|
|||||||
package org.openhab.binding.doorbird.internal.audio;
|
package org.openhab.binding.doorbird.internal.audio;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -23,9 +22,8 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.doorbird.internal.handler.DoorbellHandler;
|
import org.openhab.binding.doorbird.internal.handler.DoorbellHandler;
|
||||||
import org.openhab.core.audio.AudioFormat;
|
import org.openhab.core.audio.AudioFormat;
|
||||||
import org.openhab.core.audio.AudioSink;
|
import org.openhab.core.audio.AudioSinkSync;
|
||||||
import org.openhab.core.audio.AudioStream;
|
import org.openhab.core.audio.AudioStream;
|
||||||
import org.openhab.core.audio.FixedLengthAudioStream;
|
|
||||||
import org.openhab.core.audio.UnsupportedAudioFormatException;
|
import org.openhab.core.audio.UnsupportedAudioFormatException;
|
||||||
import org.openhab.core.audio.UnsupportedAudioStreamException;
|
import org.openhab.core.audio.UnsupportedAudioStreamException;
|
||||||
import org.openhab.core.library.types.PercentType;
|
import org.openhab.core.library.types.PercentType;
|
||||||
@ -37,18 +35,13 @@ import org.openhab.core.library.types.PercentType;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class DoorbirdAudioSink implements AudioSink {
|
public class DoorbirdAudioSink extends AudioSinkSync {
|
||||||
|
|
||||||
private static final HashSet<AudioFormat> SUPPORTED_FORMATS = new HashSet<>();
|
private static final Set<AudioFormat> SUPPORTED_FORMATS = Set.of(AudioFormat.WAV);
|
||||||
private static final HashSet<Class<? extends AudioStream>> SUPPORTED_STREAMS = new HashSet<>();
|
private static final Set<Class<? extends AudioStream>> SUPPORTED_STREAMS = Set.of(AudioStream.class);
|
||||||
|
|
||||||
private DoorbellHandler doorbellHandler;
|
private DoorbellHandler doorbellHandler;
|
||||||
|
|
||||||
static {
|
|
||||||
SUPPORTED_FORMATS.add(AudioFormat.WAV);
|
|
||||||
SUPPORTED_STREAMS.add(FixedLengthAudioStream.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DoorbirdAudioSink(DoorbellHandler doorbellHandler) {
|
public DoorbirdAudioSink(DoorbellHandler doorbellHandler) {
|
||||||
this.doorbellHandler = doorbellHandler;
|
this.doorbellHandler = doorbellHandler;
|
||||||
}
|
}
|
||||||
@ -64,7 +57,7 @@ public class DoorbirdAudioSink implements AudioSink {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(@Nullable AudioStream audioStream)
|
protected void processSynchronously(@Nullable AudioStream audioStream)
|
||||||
throws UnsupportedAudioFormatException, UnsupportedAudioStreamException {
|
throws UnsupportedAudioFormatException, UnsupportedAudioStreamException {
|
||||||
if (audioStream == null) {
|
if (audioStream == null) {
|
||||||
return;
|
return;
|
||||||
@ -93,6 +86,6 @@ public class DoorbirdAudioSink implements AudioSink {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVolume(PercentType volume) {
|
public void setVolume(PercentType volume) {
|
||||||
// NOT IMPLEMENTED
|
throw new UnsupportedOperationException("Volume can not be set");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user