-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathOpusDecoder.java
More file actions
41 lines (34 loc) · 784 Bytes
/
Copy pathOpusDecoder.java
File metadata and controls
41 lines (34 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package javaforce.codec.opus;
/** opus decoder
*
* @author pquiring
*/
import javaforce.*;
import javaforce.media.*;
public class OpusDecoder {
private MediaAudioDecoder decoder;
public void open() {
decoder = new MediaAudioDecoder();
decoder.start(MediaCoder.AV_CODEC_ID_OPUS, 1, 48000);
}
public void close() {
if (decoder != null) {
decoder.stop();
decoder = null;
}
}
public short[] decode(byte[] data, int off, int length) {
if (decoder == null) {
open();
}
while (true) {
short[] sams = decoder.decode(data, off, length);
if (sams == null || sams.length == 0) {
JFLog.log("OpusDecoder:frame == null:packet=" + length);
break;
}
return sams;
}
return null;
}
}