1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-12-02 09:37:52 +01:00
libtgvoip/OpusEncoder.h

60 lines
1.5 KiB
C
Raw Permalink Normal View History

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_OPUSENCODER_H
#define LIBTGVOIP_OPUSENCODER_H
#include "MediaStreamItf.h"
#include "opus.h"
#include "threading.h"
#include "BlockingQueue.h"
#include "BufferPool.h"
#include "EchoCanceller.h"
#include <stdint.h>
namespace tgvoip{
class OpusEncoder : public MediaStreamItf{
2017-02-02 17:24:40 +01:00
public:
OpusEncoder(MediaStreamItf* source);
virtual ~OpusEncoder();
2017-02-02 17:24:40 +01:00
virtual void Start();
virtual void Stop();
void SetBitrate(uint32_t bitrate);
void SetEchoCanceller(EchoCanceller* aec);
2017-02-02 17:24:40 +01:00
void SetOutputFrameDuration(uint32_t duration);
void SetPacketLoss(int percent);
2017-03-30 16:06:59 +02:00
int GetPacketLoss();
2017-02-02 17:24:40 +01:00
uint32_t GetBitrate();
private:
static size_t Callback(unsigned char* data, size_t len, void* param);
static void* StartThread(void* arg);
void RunThread();
void Encode(unsigned char* data, size_t len);
MediaStreamItf* source;
::OpusEncoder* enc;
2017-02-02 17:24:40 +01:00
unsigned char buffer[4096];
uint32_t requestedBitrate;
uint32_t currentBitrate;
tgvoip_thread_t thread;
BlockingQueue<unsigned char*> queue;
BufferPool bufferPool;
EchoCanceller* echoCanceller;
2017-02-02 17:24:40 +01:00
int complexity;
bool running;
uint32_t frameDuration;
2017-03-30 16:06:59 +02:00
int packetLossPercent;
uint32_t mediumCorrectionBitrate;
uint32_t strongCorrectionBitrate;
double mediumCorrectionMultiplier;
double strongCorrectionMultiplier;
2017-02-02 17:24:40 +01:00
};
}
2017-02-02 17:24:40 +01:00
#endif //LIBTGVOIP_OPUSENCODER_H