2 * Copyright (c) 2010-2024 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.voice.mimic.internal;
15 import java.io.IOException;
16 import java.io.InputStream;
17 import java.io.OutputStream;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.core.audio.AudioFormat;
22 import org.openhab.core.audio.AudioStream;
23 import org.openhab.core.audio.SizeableAudioStream;
26 * An AudioStream with an {@link InputStream} inside
28 * @author Gwendal Roulleau - Initial contribution
31 public class InputStreamAudioStream extends AudioStream implements SizeableAudioStream {
33 public InputStream innerInputStream;
34 public AudioFormat audioFormat;
37 public InputStreamAudioStream(InputStream innerInputStream, AudioFormat audioFormat, long length) {
39 this.innerInputStream = innerInputStream;
40 this.audioFormat = audioFormat;
45 public AudioFormat getFormat() {
50 public int read() throws IOException {
51 return innerInputStream.read();
55 public int read(byte @Nullable [] b) throws IOException {
56 return innerInputStream.read(b);
60 public int read(byte @Nullable [] b, int off, int len) throws IOException {
61 return innerInputStream.read(b, off, len);
65 public byte[] readAllBytes() throws IOException {
66 return innerInputStream.readAllBytes();
70 public byte[] readNBytes(int len) throws IOException {
71 return innerInputStream.readNBytes(len);
75 public int readNBytes(byte @Nullable [] b, int off, int len) throws IOException {
76 return innerInputStream.readNBytes(b, off, len);
80 public long skip(long n) throws IOException {
81 return innerInputStream.skip(n);
85 public int available() throws IOException {
86 return innerInputStream.available();
90 public void close() throws IOException {
91 innerInputStream.close();
95 public synchronized void mark(int readlimit) {
96 innerInputStream.mark(readlimit);
100 public synchronized void reset() throws IOException {
101 innerInputStream.reset();
105 public boolean markSupported() {
106 return innerInputStream.markSupported();
110 public long transferTo(@Nullable OutputStream out) throws IOException {
111 return innerInputStream.transferTo(out);
115 public long length() {