blob: 5ca3292c0deeb8c93e72ca17a840e339b044c688 (
plain) (
blame)
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
42
43
|
using namespace Napi;
#define FRAME_SIZE 960
#define MAX_FRAME_SIZE 6 * 960
#define MAX_PACKET_SIZE 3 * 1276
#define BITRATE 64000
class OpusEncoder : public ObjectWrap<OpusEncoder> {
private:
OpusEncoder* encoder;
OpusDecoder* decoder;
opus_int32 rate;
int channels;
int application;
unsigned char outOpus[MAX_PACKET_SIZE];
opus_int16* outPcm;
protected:
int EnsureEncoder();
int EnsureDecoder();
public:
static Object Init(Napi::Env env, Object exports);
OpusEncoder(const CallbackInfo& args);
~OpusEncoder();
Napi::Value Encode(const CallbackInfo& args);
Napi::Value Decode(const CallbackInfo& args);
void ApplyEncoderCTL(const CallbackInfo& args);
void ApplyDecoderCTL(const CallbackInfo& args);
void SetBitrate(const CallbackInfo& args);
Napi::Value GetBitrate(const CallbackInfo& args);
};
|