forked from grishka/libtgvoip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpusDecoder.h
56 lines (47 loc) · 1.36 KB
/
OpusDecoder.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// libtgvoip is free and unencumbered public domain software.
// For more information, see http://unlicense.org or the UNLICENSE file
// you should have received with this source code distribution.
//
#ifndef LIBTGVOIP_OPUSDECODER_H
#define LIBTGVOIP_OPUSDECODER_H
#include "MediaStreamItf.h"
#include "opus.h"
#include "threading.h"
#include "BlockingQueue.h"
#include "BufferPool.h"
#include "EchoCanceller.h"
#include "JitterBuffer.h"
#include <stdio.h>
class COpusDecoder {
public:
virtual void Start();
virtual void Stop();
COpusDecoder(CMediaStreamItf* dst);
virtual ~COpusDecoder();
void HandleCallback(unsigned char* data, size_t len);
void SetEchoCanceller(CEchoCanceller* canceller);
void SetFrameDuration(uint32_t duration);
void ResetQueue();
void SetJitterBuffer(CJitterBuffer* jitterBuffer);
private:
static size_t Callback(unsigned char* data, size_t len, void* param);
static void* StartThread(void* param);
void RunThread();
OpusDecoder* dec;
CBlockingQueue* decodedQueue;
CBufferPool* bufferPool;
unsigned char* buffer;
unsigned char* lastDecoded;
size_t lastDecodedLen, lastDecodedOffset;
int packetsNeeded;
size_t outputBufferSize;
bool running;
tgvoip_thread_t thread;
tgvoip_lock_t lock;
tgvoip_mutex_t mutex;
uint32_t frameDuration;
CEchoCanceller* echoCanceller;
CJitterBuffer* jitterBuffer;
};
#endif //LIBTGVOIP_OPUSDECODER_H