]> git.basschouten.com Git - openhab-addons.git/blob
04bfeee8d41551d6ed73e0618fd3f39fb34dc51f
[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.voicerss.internal;
14
15 import java.io.IOException;
16 import java.io.InputStream;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.core.audio.AudioFormat;
20 import org.openhab.core.audio.AudioStream;
21 import org.openhab.core.audio.SizeableAudioStream;
22
23 /**
24  * Implementation of the {@link AudioStream} interface for the
25  * {@link VoiceRSSTTSService}. It simply uses a {@link AudioStream}.
26  *
27  * @author Laurent Garnier - Initial contribution
28  */
29 @NonNullByDefault
30 public class VoiceRSSRawAudioStream extends AudioStream implements SizeableAudioStream {
31
32     private InputStream inputStream;
33     private AudioFormat format;
34     private long length;
35
36     public VoiceRSSRawAudioStream(InputStream inputStream, AudioFormat format, long length) {
37         this.inputStream = inputStream;
38         this.format = format;
39         this.length = length;
40     }
41
42     public InputStream getInputStream() {
43         return inputStream;
44     }
45
46     @Override
47     public AudioFormat getFormat() {
48         return format;
49     }
50
51     @Override
52     public long length() {
53         return length;
54     }
55
56     @Override
57     public int read() throws IOException {
58         return inputStream.read();
59     }
60
61     @Override
62     public void close() throws IOException {
63         inputStream.close();
64     }
65 }