2017-02-02 17:24:40 +01:00
|
|
|
//
|
|
|
|
// 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>
|
2017-09-07 07:39:33 +02:00
|
|
|
#include <vector>
|
2017-02-02 17:24:40 +01:00
|
|
|
|
2017-04-28 13:17:56 +02:00
|
|
|
namespace tgvoip{
|
|
|
|
class OpusDecoder {
|
2017-02-02 17:24:40 +01:00
|
|
|
public:
|
|
|
|
virtual void Start();
|
|
|
|
|
|
|
|
virtual void Stop();
|
|
|
|
|
2017-04-28 13:17:56 +02:00
|
|
|
OpusDecoder(MediaStreamItf* dst);
|
|
|
|
virtual ~OpusDecoder();
|
2017-02-02 17:24:40 +01:00
|
|
|
void HandleCallback(unsigned char* data, size_t len);
|
2017-04-28 13:17:56 +02:00
|
|
|
void SetEchoCanceller(EchoCanceller* canceller);
|
2017-02-02 17:24:40 +01:00
|
|
|
void SetFrameDuration(uint32_t duration);
|
|
|
|
void ResetQueue();
|
2017-04-28 13:17:56 +02:00
|
|
|
void SetJitterBuffer(JitterBuffer* jitterBuffer);
|
2017-09-07 07:39:33 +02:00
|
|
|
void AddAudioEffect(AudioEffect* effect);
|
|
|
|
void RemoveAudioEffect(AudioEffect* effect);
|
2017-02-02 17:24:40 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
static size_t Callback(unsigned char* data, size_t len, void* param);
|
|
|
|
static void* StartThread(void* param);
|
|
|
|
void RunThread();
|
2017-04-28 13:17:56 +02:00
|
|
|
::OpusDecoder* dec;
|
2017-07-03 03:42:49 +02:00
|
|
|
BlockingQueue<unsigned char*>* decodedQueue;
|
2017-04-28 13:17:56 +02:00
|
|
|
BufferPool* bufferPool;
|
2017-02-02 17:24:40 +01:00
|
|
|
unsigned char* buffer;
|
|
|
|
unsigned char* lastDecoded;
|
|
|
|
size_t lastDecodedLen, lastDecodedOffset;
|
|
|
|
size_t outputBufferSize;
|
|
|
|
bool running;
|
|
|
|
tgvoip_thread_t thread;
|
2017-04-28 13:17:56 +02:00
|
|
|
Semaphore semaphore;
|
2017-02-02 17:24:40 +01:00
|
|
|
tgvoip_mutex_t mutex;
|
|
|
|
uint32_t frameDuration;
|
2017-04-28 13:17:56 +02:00
|
|
|
EchoCanceller* echoCanceller;
|
|
|
|
JitterBuffer* jitterBuffer;
|
2017-09-07 07:39:33 +02:00
|
|
|
std::vector<AudioEffect*> postProcEffects;
|
2017-02-02 17:24:40 +01:00
|
|
|
};
|
2017-04-28 13:17:56 +02:00
|
|
|
}
|
2017-02-02 17:24:40 +01:00
|
|
|
|
|
|
|
#endif //LIBTGVOIP_OPUSDECODER_H
|