]> git.basschouten.com Git - openhab-addons.git/blob
ba69c9dac1b1ee49dd88b4b7fec18fd3451b1c18
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.voice.pollytts.internal;
14
15 import java.io.IOException;
16 import java.io.InputStream;
17 import java.io.OutputStream;
18
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
24 /**
25  * Implementation of the {@link AudioStream} interface for the {@link PollyTTSService}.
26  * An AudioStream with an {@link InputStream} inside
27  *
28  * @author Robert Hillman - Initial contribution
29  * @author Gwendal Roulleau - Refactor to simple audiostream
30  */
31 @NonNullByDefault
32 public class PollyTTSAudioStream extends AudioStream {
33
34     public InputStream innerInputStream;
35     public AudioFormat audioFormat;
36
37     public PollyTTSAudioStream(InputStream innerInputStream, AudioFormat audioFormat) {
38         super();
39         this.innerInputStream = innerInputStream;
40         this.audioFormat = audioFormat;
41     }
42
43     @Override
44     public AudioFormat getFormat() {
45         return audioFormat;
46     }
47
48     @Override
49     public int read() throws IOException {
50         return innerInputStream.read();
51     }
52
53     @Override
54     public int read(byte @Nullable [] b) throws IOException {
55         return innerInputStream.read(b);
56     }
57
58     @Override
59     public int read(byte @Nullable [] b, int off, int len) throws IOException {
60         return innerInputStream.read(b, off, len);
61     }
62
63     @Override
64     public byte[] readAllBytes() throws IOException {
65         return innerInputStream.readAllBytes();
66     }
67
68     @Override
69     public byte[] readNBytes(int len) throws IOException {
70         return innerInputStream.readNBytes(len);
71     }
72
73     @Override
74     public int readNBytes(byte @Nullable [] b, int off, int len) throws IOException {
75         return innerInputStream.readNBytes(b, off, len);
76     }
77
78     @Override
79     public long skip(long n) throws IOException {
80         return innerInputStream.skip(n);
81     }
82
83     @Override
84     public int available() throws IOException {
85         return innerInputStream.available();
86     }
87
88     @Override
89     public void close() throws IOException {
90         innerInputStream.close();
91     }
92
93     @Override
94     public synchronized void mark(int readlimit) {
95         innerInputStream.mark(readlimit);
96     }
97
98     @Override
99     public synchronized void reset() throws IOException {
100         innerInputStream.reset();
101     }
102
103     @Override
104     public boolean markSupported() {
105         return innerInputStream.markSupported();
106     }
107
108     @Override
109     public long transferTo(@Nullable OutputStream out) throws IOException {
110         return innerInputStream.transferTo(out);
111     }
112 }