mirror of
https://github.com/danog/libtgvoip.git
synced 2024-11-30 04:39:03 +01:00
Mark more methods as override, fixes for android
This commit is contained in:
parent
18c7f84476
commit
23fafdf575
@ -1,7 +1,7 @@
|
|||||||
LOCAL_PATH := $(call my-dir)
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
LOCAL_MODULE := voip
|
LOCAL_MODULE := voip
|
||||||
LOCAL_CPPFLAGS := -Wall -std=c++11 -DANDROID -finline-functions -ffast-math -Os -fno-strict-aliasing -O3 -frtti -D__STDC_LIMIT_MACROS -Wno-unknown-pragmas
|
LOCAL_CPPFLAGS := -Wall -std=c++17 -DANDROID -finline-functions -ffast-math -Os -fno-strict-aliasing -O3 -frtti -D__STDC_LIMIT_MACROS -Wno-unknown-pragmas
|
||||||
LOCAL_CFLAGS := -O3 -DUSE_KISS_FFT -fexceptions -DWEBRTC_APM_DEBUG_DUMP=0 -DWEBRTC_POSIX -DWEBRTC_ANDROID -D__STDC_LIMIT_MACROS -DFIXED_POINT -DWEBRTC_NS_FLOAT
|
LOCAL_CFLAGS := -O3 -DUSE_KISS_FFT -fexceptions -DWEBRTC_APM_DEBUG_DUMP=0 -DWEBRTC_POSIX -DWEBRTC_ANDROID -D__STDC_LIMIT_MACROS -DFIXED_POINT -DWEBRTC_NS_FLOAT
|
||||||
LOCAL_EXPORT_LDLIBS := -llog -lOpenSLES
|
LOCAL_EXPORT_LDLIBS := -llog -lOpenSLES
|
||||||
|
|
||||||
@ -23,7 +23,6 @@ LOCAL_CFLAGS += $(TGVOIP_ADDITIONAL_CFLAGS)
|
|||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := \
|
||||||
./tools/logging.cpp \
|
./tools/logging.cpp \
|
||||||
./VoIPController.cpp \
|
./VoIPController.cpp \
|
||||||
./VoIPGroupController.cpp \
|
|
||||||
./tools/Buffers.cpp \
|
./tools/Buffers.cpp \
|
||||||
./tools/BlockingQueue.cpp \
|
./tools/BlockingQueue.cpp \
|
||||||
./audio/AudioInput.cpp \
|
./audio/AudioInput.cpp \
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
AUTOMAKE_OPTIONS = foreign
|
AUTOMAKE_OPTIONS = foreign
|
||||||
|
|
||||||
CFLAGS = -Wall -DHAVE_CONFIG_H -Wno-unknown-pragmas -g
|
CFLAGS = -Wall -DHAVE_CONFIG_H -Wno-unknown-pragmas -g -Wsuggest-override
|
||||||
|
|
||||||
lib_LTLIBRARIES = libtgvoip.la
|
lib_LTLIBRARIES = libtgvoip.la
|
||||||
|
|
||||||
|
@ -2274,9 +2274,10 @@ CCAS = @CCAS@
|
|||||||
CCASDEPMODE = @CCASDEPMODE@
|
CCASDEPMODE = @CCASDEPMODE@
|
||||||
CCASFLAGS = @CCASFLAGS@ $(am__append_9) $(am__append_20)
|
CCASFLAGS = @CCASFLAGS@ $(am__append_9) $(am__append_20)
|
||||||
CCDEPMODE = @CCDEPMODE@
|
CCDEPMODE = @CCDEPMODE@
|
||||||
CFLAGS = -Wall -DHAVE_CONFIG_H -Wno-unknown-pragmas -g $(am__append_8) \
|
CFLAGS = -Wall -DHAVE_CONFIG_H -Wno-unknown-pragmas -g \
|
||||||
$(am__append_11) $(am__append_13) $(am__append_15) \
|
-Wsuggest-override $(am__append_8) $(am__append_11) \
|
||||||
$(am__append_19) $(am__append_24)
|
$(am__append_13) $(am__append_15) $(am__append_19) \
|
||||||
|
$(am__append_24)
|
||||||
CPP = @CPP@
|
CPP = @CPP@
|
||||||
CPPFLAGS = @CPPFLAGS@
|
CPPFLAGS = @CPPFLAGS@
|
||||||
CXX = @CXX@
|
CXX = @CXX@
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
#ifndef TGVOIP_USE_CUSTOM_CRYPTO
|
#ifndef TGVOIP_USE_CUSTOM_CRYPTO
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#include <openssl/sha.h>
|
|
||||||
#include <openssl/aes.h>
|
#include <openssl/aes.h>
|
||||||
#include <openssl/modes.h>
|
#include <openssl/modes.h>
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
#include <openssl/sha.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
void tgvoip_openssl_aes_ige_encrypt(uint8_t *in, uint8_t *out, size_t length, uint8_t *key, uint8_t *iv)
|
void tgvoip_openssl_aes_ige_encrypt(uint8_t *in, uint8_t *out, size_t length, uint8_t *key, uint8_t *iv)
|
||||||
@ -198,13 +198,13 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void setOnStateUpdated(std::function<void(TgVoipState)> onStateUpdated)
|
void setOnStateUpdated(std::function<void(TgVoipState)> onStateUpdated) override
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_onStateUpdated);
|
std::lock_guard<std::mutex> lock(m_onStateUpdated);
|
||||||
onStateUpdated_ = onStateUpdated;
|
onStateUpdated_ = onStateUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setOnSignalBarsUpdated(std::function<void(int)> onSignalBarsUpdated)
|
void setOnSignalBarsUpdated(std::function<void(int)> onSignalBarsUpdated) override
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_onSignalBarsUpdated);
|
std::lock_guard<std::mutex> lock(m_onSignalBarsUpdated);
|
||||||
onSignalBarsUpdated_ = onSignalBarsUpdated;
|
onSignalBarsUpdated_ = onSignalBarsUpdated;
|
||||||
|
@ -13,12 +13,6 @@
|
|||||||
#include "controller/protocol/VersionInfo.h"
|
#include "controller/protocol/VersionInfo.h"
|
||||||
#include "controller/protocol/protocol/Index.h"
|
#include "controller/protocol/protocol/Index.h"
|
||||||
|
|
||||||
#if defined HAVE_CONFIG_H || defined TGVOIP_USE_INSTALLED_OPUS
|
|
||||||
#include <opus/opus.h>
|
|
||||||
#else
|
|
||||||
#include <opus/opus.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
#include "controller/net/NetworkSocket.h"
|
#include "controller/net/NetworkSocket.h"
|
||||||
#include "os/android/AudioInputAndroid.h"
|
#include "os/android/AudioInputAndroid.h"
|
||||||
|
@ -55,7 +55,7 @@ public:
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::shared_ptr<AudioOutput> *GetOutput()
|
virtual std::shared_ptr<AudioOutput> GetOutput()
|
||||||
{
|
{
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,11 @@
|
|||||||
#include "../protocol/packets/PacketSender.h"
|
#include "../protocol/packets/PacketSender.h"
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#if defined HAVE_CONFIG_H || defined TGVOIP_USE_INSTALLED_OPUS
|
||||||
|
#include <opus/opus.h>
|
||||||
|
#else
|
||||||
|
#include "opus.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace tgvoip
|
namespace tgvoip
|
||||||
{
|
{
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
#ifndef LIBTGVOIP_ECHOCANCELLER_H
|
#ifndef LIBTGVOIP_ECHOCANCELLER_H
|
||||||
#define LIBTGVOIP_ECHOCANCELLER_H
|
#define LIBTGVOIP_ECHOCANCELLER_H
|
||||||
|
|
||||||
#include "tools/threading.h"
|
|
||||||
#include "tools/Buffers.h"
|
|
||||||
#include "tools/BlockingQueue.h"
|
|
||||||
#include "controller/media/MediaStreamItf.h"
|
#include "controller/media/MediaStreamItf.h"
|
||||||
|
#include "tools/BlockingQueue.h"
|
||||||
|
#include "tools/Buffers.h"
|
||||||
|
#include "tools/threading.h"
|
||||||
#include "tools/utils.h"
|
#include "tools/utils.h"
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc
|
||||||
@ -25,32 +25,32 @@ class EchoCanceller
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TGVOIP_DISALLOW_COPY_AND_ASSIGN(EchoCanceller);
|
TGVOIP_DISALLOW_COPY_AND_ASSIGN(EchoCanceller);
|
||||||
EchoCanceller(bool enableAEC, bool enableNS, bool enableAGC);
|
EchoCanceller(bool enableAEC, bool enableNS, bool enableAGC);
|
||||||
virtual ~EchoCanceller();
|
virtual ~EchoCanceller();
|
||||||
virtual void Start();
|
virtual void Start();
|
||||||
virtual void Stop();
|
virtual void Stop();
|
||||||
void SpeakerOutCallback(unsigned char *data, size_t len);
|
void SpeakerOutCallback(unsigned char *data, size_t len);
|
||||||
void Enable(bool enabled);
|
void Enable(bool enabled);
|
||||||
void ProcessInput(int16_t *inOut, size_t numSamples, bool &hasVoice);
|
void ProcessInput(int16_t *inOut, size_t numSamples, bool &hasVoice);
|
||||||
void SetAECStrength(int strength);
|
void SetAECStrength(int strength);
|
||||||
void SetVoiceDetectionEnabled(bool enabled);
|
void SetVoiceDetectionEnabled(bool enabled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool enableAEC;
|
bool enableAEC;
|
||||||
bool enableAGC;
|
bool enableAGC;
|
||||||
bool enableNS;
|
bool enableNS;
|
||||||
bool enableVAD = false;
|
bool enableVAD = false;
|
||||||
bool isOn;
|
bool isOn;
|
||||||
#ifndef TGVOIP_NO_DSP
|
#ifndef TGVOIP_NO_DSP
|
||||||
webrtc::AudioProcessing *apm = NULL;
|
webrtc::AudioProcessing *apm = NULL;
|
||||||
webrtc::AudioFrame *audioFrame = NULL;
|
webrtc::AudioFrame *audioFrame = NULL;
|
||||||
void RunBufferFarendThread();
|
void RunBufferFarendThread();
|
||||||
bool didBufferFarend;
|
bool didBufferFarend;
|
||||||
Thread *bufferFarendThread;
|
Thread *bufferFarendThread;
|
||||||
BlockingQueue<Buffer> *farendQueue;
|
BlockingQueue<Buffer> *farendQueue;
|
||||||
BufferPool<960 * 2, 10> farendBufferPool;
|
BufferPool<960 * 2, 10> farendBufferPool;
|
||||||
bool running;
|
bool running;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,29 +60,29 @@ namespace effects
|
|||||||
class AudioEffect
|
class AudioEffect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~AudioEffect() = 0;
|
virtual ~AudioEffect() = 0;
|
||||||
virtual void Process(int16_t *inOut, size_t numSamples) = 0;
|
virtual void Process(int16_t *inOut, size_t numSamples) = 0;
|
||||||
virtual void SetPassThrough(bool passThrough);
|
virtual void SetPassThrough(bool passThrough);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool passThrough = false;
|
bool passThrough = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Volume : public AudioEffect
|
class Volume : public AudioEffect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Volume();
|
Volume();
|
||||||
virtual ~Volume();
|
virtual ~Volume();
|
||||||
virtual void Process(int16_t *inOut, size_t numSamples);
|
virtual void Process(int16_t *inOut, size_t numSamples) override;
|
||||||
/**
|
/**
|
||||||
* Level is (0.0, 2.0]
|
* Level is (0.0, 2.0]
|
||||||
*/
|
*/
|
||||||
void SetLevel(float level);
|
void SetLevel(float level);
|
||||||
float GetLevel();
|
float GetLevel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float level = 1.0f;
|
float level = 1.0f;
|
||||||
float multiplier = 1.0f;
|
float multiplier = 1.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace effects
|
} // namespace effects
|
||||||
|
@ -11,6 +11,11 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#if defined HAVE_CONFIG_H || defined TGVOIP_USE_INSTALLED_OPUS
|
||||||
|
#include <opus/opus.h>
|
||||||
|
#else
|
||||||
|
#include "opus.h"
|
||||||
|
#endif
|
||||||
#include "VoIPController.h"
|
#include "VoIPController.h"
|
||||||
|
|
||||||
#define PACKET_SIZE (960 * 2)
|
#define PACKET_SIZE (960 * 2)
|
||||||
|
@ -7,17 +7,17 @@
|
|||||||
#ifndef LIBTGVOIP_OPUSDECODER_H
|
#ifndef LIBTGVOIP_OPUSDECODER_H
|
||||||
#define LIBTGVOIP_OPUSDECODER_H
|
#define LIBTGVOIP_OPUSDECODER_H
|
||||||
|
|
||||||
|
#include "controller/audio/EchoCanceller.h"
|
||||||
#include "controller/media/MediaStreamItf.h"
|
#include "controller/media/MediaStreamItf.h"
|
||||||
#include "tools/threading.h"
|
#include "controller/net/JitterBuffer.h"
|
||||||
#include "tools/BlockingQueue.h"
|
#include "tools/BlockingQueue.h"
|
||||||
#include "tools/Buffers.h"
|
#include "tools/Buffers.h"
|
||||||
#include "controller/audio/EchoCanceller.h"
|
#include "tools/threading.h"
|
||||||
#include "controller/net/JitterBuffer.h"
|
|
||||||
#include "tools/utils.h"
|
#include "tools/utils.h"
|
||||||
|
#include <atomic>
|
||||||
|
#include <memory>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
|
||||||
#include <atomic>
|
|
||||||
|
|
||||||
|
|
||||||
struct OpusDecoder;
|
struct OpusDecoder;
|
||||||
@ -27,56 +27,56 @@ namespace tgvoip
|
|||||||
class OpusDecoder
|
class OpusDecoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TGVOIP_DISALLOW_COPY_AND_ASSIGN(OpusDecoder);
|
TGVOIP_DISALLOW_COPY_AND_ASSIGN(OpusDecoder);
|
||||||
virtual void Start();
|
virtual void Start();
|
||||||
|
|
||||||
virtual void Stop();
|
virtual void Stop();
|
||||||
|
|
||||||
OpusDecoder(const std::shared_ptr<MediaStreamItf> &dst, bool isAsync, bool needEC);
|
OpusDecoder(const std::shared_ptr<MediaStreamItf> &dst, bool isAsync, bool needEC);
|
||||||
OpusDecoder(const std::unique_ptr<MediaStreamItf> &dst, bool isAsync, bool needEC);
|
OpusDecoder(const std::unique_ptr<MediaStreamItf> &dst, bool isAsync, bool needEC);
|
||||||
virtual ~OpusDecoder();
|
virtual ~OpusDecoder();
|
||||||
size_t HandleCallback(unsigned char *data, size_t len);
|
size_t HandleCallback(unsigned char *data, size_t len);
|
||||||
void SetEchoCanceller(const std::shared_ptr<EchoCanceller> &canceller);
|
void SetEchoCanceller(const std::shared_ptr<EchoCanceller> &canceller);
|
||||||
void SetFrameDuration(uint32_t duration);
|
void SetFrameDuration(uint32_t duration);
|
||||||
void SetJitterBuffer(const std::shared_ptr<JitterBuffer> &jitterBuffer);
|
void SetJitterBuffer(const std::shared_ptr<JitterBuffer> &jitterBuffer);
|
||||||
void SetDTX(bool enable);
|
void SetDTX(bool enable);
|
||||||
void SetLevelMeter(const std::shared_ptr<AudioLevelMeter> &levelMeter);
|
void SetLevelMeter(const std::shared_ptr<AudioLevelMeter> &levelMeter);
|
||||||
void AddAudioEffect(const std::shared_ptr<effects::AudioEffect> &effect);
|
void AddAudioEffect(const std::shared_ptr<effects::AudioEffect> &effect);
|
||||||
void RemoveAudioEffect(const std::shared_ptr<effects::AudioEffect> &effect);
|
void RemoveAudioEffect(const std::shared_ptr<effects::AudioEffect> &effect);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Initialize(bool isAsync, bool needEC);
|
void Initialize(bool isAsync, bool needEC);
|
||||||
static size_t Callback(unsigned char *data, size_t len, void *param);
|
static size_t Callback(unsigned char *data, size_t len, void *param);
|
||||||
void RunThread();
|
void RunThread();
|
||||||
int DecodeNextFrame();
|
int DecodeNextFrame();
|
||||||
::OpusDecoder *dec;
|
::OpusDecoder *dec;
|
||||||
::OpusDecoder *ecDec;
|
::OpusDecoder *ecDec;
|
||||||
BlockingQueue<Buffer> *decodedQueue;
|
BlockingQueue<Buffer> *decodedQueue;
|
||||||
BufferPool<960 * 2, 32> bufferPool;
|
BufferPool<960 * 2, 32> bufferPool;
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
unsigned char *lastDecoded;
|
unsigned char *lastDecoded;
|
||||||
unsigned char *processedBuffer;
|
unsigned char *processedBuffer;
|
||||||
size_t outputBufferSize;
|
size_t outputBufferSize;
|
||||||
std::atomic<bool> running;
|
std::atomic<bool> running;
|
||||||
Thread *thread;
|
Thread *thread;
|
||||||
Semaphore *semaphore;
|
Semaphore *semaphore;
|
||||||
uint32_t frameDuration;
|
uint32_t frameDuration;
|
||||||
std::shared_ptr<EchoCanceller> echoCanceller;
|
std::shared_ptr<EchoCanceller> echoCanceller;
|
||||||
std::shared_ptr<JitterBuffer> jitterBuffer;
|
std::shared_ptr<JitterBuffer> jitterBuffer;
|
||||||
std::shared_ptr<AudioLevelMeter> levelMeter;
|
std::shared_ptr<AudioLevelMeter> levelMeter;
|
||||||
int consecutiveLostPackets;
|
int consecutiveLostPackets;
|
||||||
bool enableDTX;
|
bool enableDTX;
|
||||||
size_t silentPacketCount;
|
size_t silentPacketCount;
|
||||||
std::vector<std::shared_ptr<effects::AudioEffect>> postProcEffects;
|
std::vector<std::shared_ptr<effects::AudioEffect>> postProcEffects;
|
||||||
//bool async;
|
//bool async;
|
||||||
std::atomic<bool> async;
|
std::atomic<bool> async;
|
||||||
alignas(2) unsigned char nextBuffer[8192];
|
alignas(2) unsigned char nextBuffer[8192];
|
||||||
alignas(2) unsigned char decodeBuffer[8192];
|
alignas(2) unsigned char decodeBuffer[8192];
|
||||||
size_t nextLen;
|
size_t nextLen;
|
||||||
unsigned int packetsPerFrame;
|
unsigned int packetsPerFrame;
|
||||||
ptrdiff_t remainingDataLen;
|
ptrdiff_t remainingDataLen;
|
||||||
bool prevWasEC;
|
bool prevWasEC;
|
||||||
int16_t prevLastSample;
|
int16_t prevLastSample;
|
||||||
};
|
};
|
||||||
} // namespace tgvoip
|
} // namespace tgvoip
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#if defined HAVE_CONFIG_H || defined TGVOIP_USE_INSTALLED_OPUS
|
#if defined HAVE_CONFIG_H || defined TGVOIP_USE_INSTALLED_OPUS
|
||||||
#include <opus/opus.h>
|
#include <opus/opus.h>
|
||||||
#else
|
#else
|
||||||
#include <opus/opus.h>
|
#include "opus.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -7,13 +7,13 @@
|
|||||||
#ifndef LIBTGVOIP_MEDIASTREAMINPUT_H
|
#ifndef LIBTGVOIP_MEDIASTREAMINPUT_H
|
||||||
#define LIBTGVOIP_MEDIASTREAMINPUT_H
|
#define LIBTGVOIP_MEDIASTREAMINPUT_H
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <memory>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "tools/threading.h"
|
|
||||||
#include "tools/BlockingQueue.h"
|
#include "tools/BlockingQueue.h"
|
||||||
#include "tools/Buffers.h"
|
#include "tools/Buffers.h"
|
||||||
|
#include "tools/threading.h"
|
||||||
|
#include <memory>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace tgvoip
|
namespace tgvoip
|
||||||
{
|
{
|
||||||
@ -23,72 +23,72 @@ class EchoCanceller;
|
|||||||
class MediaStreamItf
|
class MediaStreamItf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void Start() = 0;
|
virtual void Start() = 0;
|
||||||
virtual void Stop() = 0;
|
virtual void Stop() = 0;
|
||||||
void SetCallback(size_t (*f)(unsigned char *, size_t, void *), void *param);
|
void SetCallback(size_t (*f)(unsigned char *, size_t, void *), void *param);
|
||||||
|
|
||||||
//protected:
|
//protected:
|
||||||
size_t InvokeCallback(unsigned char *data, size_t length);
|
size_t InvokeCallback(unsigned char *data, size_t length);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t (*callback)(unsigned char *, size_t, void *) = NULL;
|
size_t (*callback)(unsigned char *, size_t, void *) = NULL;
|
||||||
void *callbackParam;
|
void *callbackParam;
|
||||||
Mutex callbackMutex;
|
Mutex callbackMutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AudioMixer : public MediaStreamItf
|
class AudioMixer : public MediaStreamItf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AudioMixer();
|
AudioMixer();
|
||||||
virtual ~AudioMixer();
|
virtual ~AudioMixer();
|
||||||
void SetOutput(MediaStreamItf *output);
|
void SetOutput(MediaStreamItf *output);
|
||||||
virtual void Start();
|
virtual void Start() override;
|
||||||
virtual void Stop();
|
virtual void Stop() override;
|
||||||
void AddInput(std::shared_ptr<MediaStreamItf> input);
|
void AddInput(std::shared_ptr<MediaStreamItf> input);
|
||||||
void RemoveInput(std::shared_ptr<MediaStreamItf> input);
|
void RemoveInput(std::shared_ptr<MediaStreamItf> input);
|
||||||
void SetInputVolume(std::shared_ptr<MediaStreamItf> input, float volumeDB);
|
void SetInputVolume(std::shared_ptr<MediaStreamItf> input, float volumeDB);
|
||||||
void SetEchoCanceller(EchoCanceller *aec);
|
void SetEchoCanceller(EchoCanceller *aec);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RunThread();
|
void RunThread();
|
||||||
struct MixerInput
|
struct MixerInput
|
||||||
{
|
{
|
||||||
std::shared_ptr<MediaStreamItf> source;
|
std::shared_ptr<MediaStreamItf> source;
|
||||||
float multiplier;
|
float multiplier;
|
||||||
};
|
};
|
||||||
Mutex inputsMutex;
|
Mutex inputsMutex;
|
||||||
void DoCallback(unsigned char *data, size_t length);
|
void DoCallback(unsigned char *data, size_t length);
|
||||||
static size_t OutputCallback(unsigned char *data, size_t length, void *arg);
|
static size_t OutputCallback(unsigned char *data, size_t length, void *arg);
|
||||||
std::vector<MixerInput> inputs;
|
std::vector<MixerInput> inputs;
|
||||||
Thread *thread;
|
Thread *thread;
|
||||||
BufferPool<960 * 2, 16> bufferPool;
|
BufferPool<960 * 2, 16> bufferPool;
|
||||||
BlockingQueue<Buffer> processedQueue;
|
BlockingQueue<Buffer> processedQueue;
|
||||||
Semaphore semaphore;
|
Semaphore semaphore;
|
||||||
EchoCanceller *echoCanceller;
|
EchoCanceller *echoCanceller;
|
||||||
bool running;
|
bool running;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CallbackWrapper : public MediaStreamItf
|
class CallbackWrapper : public MediaStreamItf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CallbackWrapper(){};
|
CallbackWrapper(){};
|
||||||
virtual ~CallbackWrapper(){};
|
virtual ~CallbackWrapper(){};
|
||||||
virtual void Start(){};
|
virtual void Start() override{};
|
||||||
virtual void Stop(){};
|
virtual void Stop() override{};
|
||||||
};
|
};
|
||||||
|
|
||||||
class AudioLevelMeter
|
class AudioLevelMeter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AudioLevelMeter();
|
AudioLevelMeter();
|
||||||
float GetLevel();
|
float GetLevel();
|
||||||
void Update(int16_t *samples, size_t count);
|
void Update(int16_t *samples, size_t count);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int16_t absMax;
|
int16_t absMax;
|
||||||
int16_t count;
|
int16_t count;
|
||||||
int8_t currentLevel;
|
int8_t currentLevel;
|
||||||
int16_t currentLevelFullRange;
|
int16_t currentLevelFullRange;
|
||||||
};
|
};
|
||||||
}; // namespace tgvoip
|
}; // namespace tgvoip
|
||||||
|
|
||||||
|
@ -169,17 +169,17 @@ class NetworkSocketTCPObfuscated : public NetworkSocketWrapper
|
|||||||
public:
|
public:
|
||||||
NetworkSocketTCPObfuscated(const std::shared_ptr<NetworkSocket> &wrapped);
|
NetworkSocketTCPObfuscated(const std::shared_ptr<NetworkSocket> &wrapped);
|
||||||
virtual ~NetworkSocketTCPObfuscated();
|
virtual ~NetworkSocketTCPObfuscated();
|
||||||
virtual std::shared_ptr<NetworkSocket> GetWrapped();
|
virtual std::shared_ptr<NetworkSocket> GetWrapped() override;
|
||||||
virtual void InitConnection();
|
virtual void InitConnection() override;
|
||||||
virtual void Send(NetworkPacket &&packet) override;
|
virtual void Send(NetworkPacket &&packet) override;
|
||||||
virtual NetworkPacket Receive(size_t maxLen) override;
|
virtual NetworkPacket Receive(size_t maxLen) override;
|
||||||
virtual void Open();
|
virtual void Open() override;
|
||||||
virtual void Close();
|
virtual void Close() override;
|
||||||
virtual void Connect(const NetworkAddress address, uint16_t port);
|
virtual void Connect(const NetworkAddress address, uint16_t port) override;
|
||||||
virtual bool OnReadyToSend();
|
virtual bool OnReadyToSend() override;
|
||||||
|
|
||||||
virtual bool IsFailed();
|
virtual bool IsFailed() override;
|
||||||
virtual bool IsReadyToSend()
|
virtual bool IsReadyToSend() override
|
||||||
{
|
{
|
||||||
return readyToSend && wrapped->IsReadyToSend();
|
return readyToSend && wrapped->IsReadyToSend();
|
||||||
};
|
};
|
||||||
@ -199,15 +199,15 @@ public:
|
|||||||
virtual void Send(NetworkPacket &&packet) override;
|
virtual void Send(NetworkPacket &&packet) override;
|
||||||
virtual NetworkPacket Receive(size_t maxLen) override;
|
virtual NetworkPacket Receive(size_t maxLen) override;
|
||||||
virtual void Open() override;
|
virtual void Open() override;
|
||||||
virtual void Close();
|
virtual void Close() override;
|
||||||
virtual void Connect(const NetworkAddress address, uint16_t port);
|
virtual void Connect(const NetworkAddress address, uint16_t port) override;
|
||||||
virtual std::shared_ptr<NetworkSocket> GetWrapped();
|
virtual std::shared_ptr<NetworkSocket> GetWrapped() override;
|
||||||
virtual void InitConnection();
|
virtual void InitConnection() override;
|
||||||
virtual bool IsFailed();
|
virtual bool IsFailed() override;
|
||||||
virtual NetworkAddress GetConnectedAddress();
|
virtual NetworkAddress GetConnectedAddress() override;
|
||||||
virtual uint16_t GetConnectedPort();
|
virtual uint16_t GetConnectedPort() override;
|
||||||
virtual bool OnReadyToSend();
|
virtual bool OnReadyToSend() override;
|
||||||
virtual bool OnReadyToReceive();
|
virtual bool OnReadyToReceive() override;
|
||||||
|
|
||||||
bool NeedSelectForSending();
|
bool NeedSelectForSending();
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ public:
|
|||||||
uint8_t streamId;
|
uint8_t streamId;
|
||||||
uint8_t flags = 0;
|
uint8_t flags = 0;
|
||||||
|
|
||||||
uint8_t getID() const
|
uint8_t getID() const override
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ public:
|
|||||||
|
|
||||||
Array<Wrapped<Bytes>> data;
|
Array<Wrapped<Bytes>> data;
|
||||||
|
|
||||||
uint8_t getID() const
|
uint8_t getID() const override
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
@ -175,7 +175,7 @@ struct ExtraNetworkChanged : public Extra
|
|||||||
|
|
||||||
uint8_t flags = 0;
|
uint8_t flags = 0;
|
||||||
|
|
||||||
uint8_t getID() const
|
uint8_t getID() const override
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ public:
|
|||||||
NetworkAddress address;
|
NetworkAddress address;
|
||||||
uint16_t port = 0;
|
uint16_t port = 0;
|
||||||
|
|
||||||
uint8_t getID() const
|
uint8_t getID() const override
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
@ -218,7 +218,7 @@ struct ExtraIpv6Endpoint : public Extra
|
|||||||
NetworkAddress address;
|
NetworkAddress address;
|
||||||
uint16_t port = 0;
|
uint16_t port = 0;
|
||||||
|
|
||||||
uint8_t getID() const
|
uint8_t getID() const override
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ struct ExtraGroupCallKey : public Extra
|
|||||||
|
|
||||||
Buffer key;
|
Buffer key;
|
||||||
|
|
||||||
uint8_t getID() const
|
uint8_t getID() const override
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
@ -258,7 +258,7 @@ struct ExtraGroupCallUpgrade : public Extra
|
|||||||
bool parse(const BufferInputStream &in, const VersionInfo &ver) override { return true; };
|
bool parse(const BufferInputStream &in, const VersionInfo &ver) override { return true; };
|
||||||
void serialize(BufferOutputStream &out, const VersionInfo &ver) const override{};
|
void serialize(BufferOutputStream &out, const VersionInfo &ver) const override{};
|
||||||
|
|
||||||
uint8_t getID() const
|
uint8_t getID() const override
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ struct ExtraInit : public Extra
|
|||||||
Array<UInt32> decoders;
|
Array<UInt32> decoders;
|
||||||
uint8_t maxResolution;
|
uint8_t maxResolution;
|
||||||
|
|
||||||
uint8_t getID() const
|
uint8_t getID() const override
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
@ -320,7 +320,7 @@ struct ExtraInitAck : public Extra
|
|||||||
|
|
||||||
Array<ExtraStreamInfo> streams;
|
Array<ExtraStreamInfo> streams;
|
||||||
|
|
||||||
uint8_t getID() const
|
uint8_t getID() const override
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ struct ExtraPing : public Extra
|
|||||||
bool parse(const BufferInputStream &in, const VersionInfo &ver) override { return true; };
|
bool parse(const BufferInputStream &in, const VersionInfo &ver) override { return true; };
|
||||||
void serialize(BufferOutputStream &out, const VersionInfo &ver) const override{};
|
void serialize(BufferOutputStream &out, const VersionInfo &ver) const override{};
|
||||||
|
|
||||||
uint8_t getID() const
|
uint8_t getID() const override
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
@ -363,7 +363,7 @@ struct ExtraPong : public Extra
|
|||||||
|
|
||||||
uint32_t seq = 0;
|
uint32_t seq = 0;
|
||||||
|
|
||||||
uint8_t getID() const
|
uint8_t getID() const override
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ struct Bytes : public Serializable,
|
|||||||
virtual ~Bytes() = default;
|
virtual ~Bytes() = default;
|
||||||
Bytes() = default;
|
Bytes() = default;
|
||||||
|
|
||||||
bool parse(const BufferInputStream &in, const VersionInfo &ver)
|
bool parse(const BufferInputStream &in, const VersionInfo &ver) override
|
||||||
{
|
{
|
||||||
setData(std::make_unique<Buffer>(in.GetLength()));
|
setData(std::make_unique<Buffer>(in.GetLength()));
|
||||||
return in.TryRead(*getData());
|
return in.TryRead(*getData());
|
||||||
@ -368,16 +368,16 @@ struct OutputBytes : public Bytes
|
|||||||
OutputBytes() = default;
|
OutputBytes() = default;
|
||||||
OutputBytes(Buffer &&_data) : data(std::make_unique<Buffer>(std::move(_data))){};
|
OutputBytes(Buffer &&_data) : data(std::make_unique<Buffer>(std::move(_data))){};
|
||||||
|
|
||||||
virtual Buffer *getData()
|
virtual Buffer *getData() override
|
||||||
{
|
{
|
||||||
return data.get();
|
return data.get();
|
||||||
}
|
}
|
||||||
virtual const Buffer *getData() const
|
virtual const Buffer *getData() const override
|
||||||
{
|
{
|
||||||
return data.get();
|
return data.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setData(std::unique_ptr<Buffer> &&buf)
|
virtual void setData(std::unique_ptr<Buffer> &&buf) override
|
||||||
{
|
{
|
||||||
data = std::move(buf);
|
data = std::move(buf);
|
||||||
}
|
}
|
||||||
@ -390,15 +390,15 @@ struct InputBytes : public Bytes
|
|||||||
InputBytes() = default;
|
InputBytes() = default;
|
||||||
InputBytes(std::shared_ptr<Buffer> _data) : data(_data){};
|
InputBytes(std::shared_ptr<Buffer> _data) : data(_data){};
|
||||||
|
|
||||||
virtual Buffer *getData()
|
virtual Buffer *getData() override
|
||||||
{
|
{
|
||||||
return data.get();
|
return data.get();
|
||||||
}
|
}
|
||||||
virtual const Buffer *getData() const
|
virtual const Buffer *getData() const override
|
||||||
{
|
{
|
||||||
return data.get();
|
return data.get();
|
||||||
}
|
}
|
||||||
virtual void setData(std::unique_ptr<Buffer> &&buf)
|
virtual void setData(std::unique_ptr<Buffer> &&buf) override
|
||||||
{
|
{
|
||||||
data = std::move(buf);
|
data = std::move(buf);
|
||||||
}
|
}
|
||||||
@ -416,7 +416,7 @@ struct UInt32 : public Serializable,
|
|||||||
{
|
{
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
bool parse(const BufferInputStream &in, const VersionInfo &ver)
|
bool parse(const BufferInputStream &in, const VersionInfo &ver) override
|
||||||
{
|
{
|
||||||
return in.TryRead(data);
|
return in.TryRead(data);
|
||||||
}
|
}
|
||||||
|
@ -756,7 +756,7 @@
|
|||||||
[
|
[
|
||||||
'"<(OS)" == "mac"', {
|
'"<(OS)" == "mac"', {
|
||||||
'xcode_settings': {
|
'xcode_settings': {
|
||||||
'CLANG_CXX_LANGUAGE_STANDARD': 'c++11',
|
'CLANG_CXX_LANGUAGE_STANDARD': 'c++17',
|
||||||
'ALWAYS_SEARCH_USER_PATHS': 'NO',
|
'ALWAYS_SEARCH_USER_PATHS': 'NO',
|
||||||
},
|
},
|
||||||
'defines': [
|
'defines': [
|
||||||
|
@ -24,7 +24,7 @@ class SocketSelectCancellerPosix : public SocketSelectCanceller
|
|||||||
public:
|
public:
|
||||||
SocketSelectCancellerPosix();
|
SocketSelectCancellerPosix();
|
||||||
virtual ~SocketSelectCancellerPosix();
|
virtual ~SocketSelectCancellerPosix();
|
||||||
virtual void CancelSelect();
|
virtual void CancelSelect() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int pipeRead;
|
int pipeRead;
|
||||||
|
Loading…
Reference in New Issue
Block a user