mirror of
https://github.com/danog/libtgvoip.git
synced 2024-11-30 04:39:03 +01:00
Various android bugfixes
This commit is contained in:
parent
1ba8738c9f
commit
5629256fbf
53
Android.mk
53
Android.mk
@ -20,31 +20,34 @@ endif
|
|||||||
|
|
||||||
LOCAL_CFLAGS += $(TGVOIP_ADDITIONAL_CFLAGS)
|
LOCAL_CFLAGS += $(TGVOIP_ADDITIONAL_CFLAGS)
|
||||||
|
|
||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := ./TgVoip.cpp \
|
||||||
./tools/logging.cpp \
|
|
||||||
./VoIPController.cpp \
|
./VoIPController.cpp \
|
||||||
./tools/Buffers.cpp \
|
./tools/Buffers.cpp \
|
||||||
./tools/BlockingQueue.cpp \
|
|
||||||
./audio/AudioInput.cpp \
|
|
||||||
./os/android/AudioInputOpenSLES.cpp \
|
|
||||||
./controller/MediaStreamItf.cpp \
|
|
||||||
./audio/AudioOutput.cpp \
|
|
||||||
./controller/audio/OpusEncoder.cpp \
|
|
||||||
./os/android/AudioOutputOpenSLES.cpp \
|
|
||||||
./controller/net/JitterBuffer.cpp \
|
|
||||||
./controller/audio/OpusDecoder.cpp \
|
|
||||||
./os/android/OpenSLEngineWrapper.cpp \
|
|
||||||
./os/android/AudioInputAndroid.cpp \
|
|
||||||
./os/android/AudioOutputAndroid.cpp \
|
|
||||||
./controller/audio/EchoCanceller.cpp \
|
|
||||||
./controller/net/CongestionControl.cpp \
|
./controller/net/CongestionControl.cpp \
|
||||||
./VoIPServerConfig.cpp \
|
./controller/audio/EchoCanceller.cpp \
|
||||||
./audio/Resampler.cpp \
|
./controller/net/JitterBuffer.cpp \
|
||||||
./controller/net/NetworkSocket.cpp \
|
./tools/logging.cpp \
|
||||||
./os/posix/NetworkSocketPosix.cpp \
|
./controller/media/MediaStreamItf.cpp \
|
||||||
./controller/PacketReassembler.cpp \
|
|
||||||
./tools/MessageThread.cpp \
|
./tools/MessageThread.cpp \
|
||||||
./tools/json11.cpp \
|
./controller/net/NetworkSocket.cpp \
|
||||||
|
./controller/net/Endpoint.cpp \
|
||||||
|
./controller/audio/OpusDecoder.cpp \
|
||||||
|
./controller/audio/OpusEncoder.cpp \
|
||||||
|
./controller/audio/AudioPacketSender.cpp \
|
||||||
|
./controller/net/PacketReassembler.cpp \
|
||||||
|
./controller/protocol/packets/PacketManager.cpp \
|
||||||
|
./controller/protocol/packets/PacketSender.cpp \
|
||||||
|
./controller/protocol/packets/PacketStructs.cpp \
|
||||||
|
./controller/protocol/Stream.cpp \
|
||||||
|
./controller/protocol/protocol/Extra.cpp \
|
||||||
|
./VoIPServerConfig.cpp \
|
||||||
|
./audio/AudioIO.cpp \
|
||||||
|
./audio/AudioInput.cpp \
|
||||||
|
./audio/AudioOutput.cpp \
|
||||||
|
./audio/Resampler.cpp \
|
||||||
|
./audio/AudioInputTester.cpp \
|
||||||
|
./os/posix/NetworkSocketPosix.cpp \
|
||||||
|
\
|
||||||
./audio/AudioIO.cpp \
|
./audio/AudioIO.cpp \
|
||||||
./video/VideoRenderer.cpp \
|
./video/VideoRenderer.cpp \
|
||||||
./video/VideoSource.cpp \
|
./video/VideoSource.cpp \
|
||||||
@ -55,7 +58,13 @@ LOCAL_SRC_FILES := \
|
|||||||
./video/cm256/gf256.$(CPP_NEON) \
|
./video/cm256/gf256.$(CPP_NEON) \
|
||||||
./os/android/VideoSourceAndroid.cpp \
|
./os/android/VideoSourceAndroid.cpp \
|
||||||
./os/android/VideoRendererAndroid.cpp \
|
./os/android/VideoRendererAndroid.cpp \
|
||||||
./client/android/tg_voip_jni.cpp
|
./client/android/tg_voip_jni.cpp \
|
||||||
|
./os/android/AudioInputOpenSLES.cpp \
|
||||||
|
./os/android/AudioOutputOpenSLES.cpp \
|
||||||
|
./os/android/OpenSLEngineWrapper.cpp \
|
||||||
|
./os/android/AudioInputAndroid.cpp \
|
||||||
|
./os/android/AudioOutputAndroid.cpp \
|
||||||
|
./tools/json11.cpp
|
||||||
|
|
||||||
# WebRTC signal processing
|
# WebRTC signal processing
|
||||||
|
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#include <openssl/aes.h>
|
#include <openssl/aes.h>
|
||||||
|
#ifndef ANDROID
|
||||||
#include <openssl/modes.h>
|
#include <openssl/modes.h>
|
||||||
|
#endif
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
#include <openssl/sha.h>
|
#include <openssl/sha.h>
|
||||||
}
|
}
|
||||||
@ -49,7 +51,11 @@ void tgvoip_openssl_aes_ctr_encrypt(uint8_t *inout, size_t length, uint8_t *key,
|
|||||||
{
|
{
|
||||||
AES_KEY akey;
|
AES_KEY akey;
|
||||||
AES_set_encrypt_key(key, 32 * 8, &akey);
|
AES_set_encrypt_key(key, 32 * 8, &akey);
|
||||||
|
#ifdef ANDROID
|
||||||
|
AES_ctr128_encrypt(inout, inout, length, &akey, iv, ecount, num);
|
||||||
|
#else
|
||||||
CRYPTO_ctr128_encrypt(inout, inout, length, &akey, iv, ecount, num, (block128_f)AES_encrypt);
|
CRYPTO_ctr128_encrypt(inout, inout, length, &akey, iv, ecount, num, (block128_f)AES_encrypt);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void tgvoip_openssl_aes_cbc_encrypt(uint8_t *in, uint8_t *out, size_t length, uint8_t *key, uint8_t *iv)
|
void tgvoip_openssl_aes_cbc_encrypt(uint8_t *in, uint8_t *out, size_t length, uint8_t *key, uint8_t *iv)
|
||||||
|
@ -19,13 +19,15 @@
|
|||||||
#include "../../os/android/VideoRendererAndroid.h"
|
#include "../../os/android/VideoRendererAndroid.h"
|
||||||
#include "../../audio/Resampler.h"
|
#include "../../audio/Resampler.h"
|
||||||
#include "../../os/android/JNIUtilities.h"
|
#include "../../os/android/JNIUtilities.h"
|
||||||
#include "../../controller/PrivateDefines.h"
|
#include "../../VoIPController.h"
|
||||||
#include "../../tools/logging.h"
|
#include "../../tools/logging.h"
|
||||||
|
|
||||||
#ifdef TGVOIP_HAS_CONFIG
|
#ifdef TGVOIP_HAS_CONFIG
|
||||||
#include <tgvoip_config.h>
|
#include <tgvoip_config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TGVOIP_NO_GROUP_CALLS 1
|
||||||
|
|
||||||
JavaVM* sharedJVM;
|
JavaVM* sharedJVM;
|
||||||
jfieldID audioRecordInstanceFld=NULL;
|
jfieldID audioRecordInstanceFld=NULL;
|
||||||
jfieldID audioTrackInstanceFld=NULL;
|
jfieldID audioTrackInstanceFld=NULL;
|
||||||
@ -71,6 +73,7 @@ namespace tgvoip {
|
|||||||
jni::AttachAndCallVoidMethod(setSignalBarsMethod, impl->javaObject, count);
|
jni::AttachAndCallVoidMethod(setSignalBarsMethod, impl->javaObject, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void updateGroupCallStreams(VoIPGroupController *cntrlr, unsigned char *streams, size_t len){
|
void updateGroupCallStreams(VoIPGroupController *cntrlr, unsigned char *streams, size_t len){
|
||||||
ImplDataAndroid *impl=(ImplDataAndroid *) cntrlr->implData;
|
ImplDataAndroid *impl=(ImplDataAndroid *) cntrlr->implData;
|
||||||
if(!impl->javaObject)
|
if(!impl->javaObject)
|
||||||
@ -84,7 +87,7 @@ namespace tgvoip {
|
|||||||
env->CallVoidMethod(impl->javaObject, setSelfStreamsMethod, jstreams);
|
env->CallVoidMethod(impl->javaObject, setSelfStreamsMethod, jstreams);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void groupCallKeyReceived(VoIPController *cntrlr, const unsigned char *key){
|
void groupCallKeyReceived(VoIPController *cntrlr, const unsigned char *key){
|
||||||
ImplDataAndroid *impl=(ImplDataAndroid *) cntrlr->implData;
|
ImplDataAndroid *impl=(ImplDataAndroid *) cntrlr->implData;
|
||||||
@ -110,23 +113,24 @@ namespace tgvoip {
|
|||||||
ImplDataAndroid *impl=(ImplDataAndroid *) cntrlr->implData;
|
ImplDataAndroid *impl=(ImplDataAndroid *) cntrlr->implData;
|
||||||
jni::AttachAndCallVoidMethod(callUpgradeRequestReceivedMethod, impl->javaObject);
|
jni::AttachAndCallVoidMethod(callUpgradeRequestReceivedMethod, impl->javaObject);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
|
||||||
void updateParticipantAudioState(VoIPGroupController *cntrlr, int32_t userID, bool enabled){
|
void updateParticipantAudioState(VoIPGroupController *cntrlr, int32_t userID, bool enabled){
|
||||||
ImplDataAndroid *impl=(ImplDataAndroid *) cntrlr->implData;
|
ImplDataAndroid *impl=(ImplDataAndroid *) cntrlr->implData;
|
||||||
jni::AttachAndCallVoidMethod(setParticipantAudioEnabledMethod, impl->javaObject, userID, enabled);
|
jni::AttachAndCallVoidMethod(setParticipantAudioEnabledMethod, impl->javaObject, userID, enabled);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
#pragma mark - VoIPController
|
#pragma mark - VoIPController
|
||||||
|
|
||||||
uint32_t AndroidCodecToFOURCC(std::string mime){
|
uint32_t AndroidCodecToFOURCC(std::string mime){
|
||||||
if(mime=="video/avc")
|
if(mime=="video/avc")
|
||||||
return CODEC_AVC;
|
return Codec::Avc;
|
||||||
else if(mime=="video/hevc")
|
else if(mime=="video/hevc")
|
||||||
return CODEC_HEVC;
|
return Codec::Hevc;
|
||||||
else if(mime=="video/x-vnd.on2.vp8")
|
else if(mime=="video/x-vnd.on2.vp8")
|
||||||
return CODEC_VP8;
|
return Codec::Vp8;
|
||||||
else if(mime=="video/x-vnd.on2.vp9")
|
else if(mime=="video/x-vnd.on2.vp9")
|
||||||
return CODEC_VP9;
|
return Codec::Vp9;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +206,7 @@ namespace tgvoip {
|
|||||||
|
|
||||||
void VoIPController_nativeSetEncryptionKey(JNIEnv* env, jobject thiz, jlong inst, jbyteArray key, jboolean isOutgoing){
|
void VoIPController_nativeSetEncryptionKey(JNIEnv* env, jobject thiz, jlong inst, jbyteArray key, jboolean isOutgoing){
|
||||||
jbyte* akey=env->GetByteArrayElements(key, NULL);
|
jbyte* akey=env->GetByteArrayElements(key, NULL);
|
||||||
((VoIPController*)(intptr_t)inst)->SetEncryptionKey((char *) akey, isOutgoing);
|
((VoIPController*)(intptr_t)inst)->SetEncryptionKey(std::vector<uint8_t>(akey, akey+256), isOutgoing);
|
||||||
env->ReleaseByteArrayElements(key, akey, JNI_ABORT);
|
env->ReleaseByteArrayElements(key, akey, JNI_ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +308,6 @@ namespace tgvoip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VoIPController_nativeDebugCtl(JNIEnv* env, jobject thiz, jlong inst, jint request, jint param){
|
void VoIPController_nativeDebugCtl(JNIEnv* env, jobject thiz, jlong inst, jint request, jint param){
|
||||||
((VoIPController*)(intptr_t)inst)->DebugCtl(request, param);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jstring VoIPController_nativeGetVersion(JNIEnv* env, jclass clasz){
|
jstring VoIPController_nativeGetVersion(JNIEnv* env, jclass clasz){
|
||||||
@ -405,6 +408,7 @@ namespace tgvoip {
|
|||||||
return (jint)tgvoip::audio::Resampler::Convert48To44((int16_t *) env->GetDirectBufferAddress(from), (int16_t *) env->GetDirectBufferAddress(to), (size_t) (env->GetDirectBufferCapacity(from)/2), (size_t) (env->GetDirectBufferCapacity(to)/2));
|
return (jint)tgvoip::audio::Resampler::Convert48To44((int16_t *) env->GetDirectBufferAddress(from), (int16_t *) env->GetDirectBufferAddress(to), (size_t) (env->GetDirectBufferCapacity(from)/2), (size_t) (env->GetDirectBufferCapacity(to)/2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#pragma mark - VoIPGroupController
|
#pragma mark - VoIPGroupController
|
||||||
|
|
||||||
#ifndef TGVOIP_NO_GROUP_CALLS
|
#ifndef TGVOIP_NO_GROUP_CALLS
|
||||||
@ -571,7 +575,7 @@ namespace tgvoip {
|
|||||||
|
|
||||||
extern "C" void tgvoipRegisterNatives(JNIEnv* env){
|
extern "C" void tgvoipRegisterNatives(JNIEnv* env){
|
||||||
jclass controller=env->FindClass(TGVOIP_PACKAGE_PATH "/VoIPController");
|
jclass controller=env->FindClass(TGVOIP_PACKAGE_PATH "/VoIPController");
|
||||||
jclass groupController=env->FindClass(TGVOIP_PACKAGE_PATH "/VoIPGroupController");
|
//jclass groupController=env->FindClass(TGVOIP_PACKAGE_PATH "/VoIPGroupController");
|
||||||
if(env->ExceptionCheck()){
|
if(env->ExceptionCheck()){
|
||||||
env->ExceptionClear(); // is returning NULL from FindClass not enough?
|
env->ExceptionClear(); // is returning NULL from FindClass not enough?
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
#include "controller/audio/OpusDecoder.h"
|
#include "controller/audio/OpusDecoder.h"
|
||||||
#include "audio/Resampler.h"
|
#include "audio/Resampler.h"
|
||||||
#include "tools/logging.h"
|
#include "tools/logging.h"
|
||||||
#include <assert.h>
|
#include <cassert>
|
||||||
#include <math.h>
|
#include <cmath>
|
||||||
|
#include <cstdlib>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#if defined HAVE_CONFIG_H || defined TGVOIP_USE_INSTALLED_OPUS
|
#if defined HAVE_CONFIG_H || defined TGVOIP_USE_INSTALLED_OPUS
|
||||||
@ -52,7 +53,11 @@ void tgvoip::OpusDecoder::Initialize(bool isAsync, bool needEC)
|
|||||||
ecDec = opus_decoder_create(48000, 1, NULL);
|
ecDec = opus_decoder_create(48000, 1, NULL);
|
||||||
else
|
else
|
||||||
ecDec = NULL;
|
ecDec = NULL;
|
||||||
buffer = reinterpret_cast<unsigned char*>(aligned_alloc(2, 8192));
|
#ifdef ANDROID
|
||||||
|
buffer = reinterpret_cast<unsigned char*>(std::malloc(8192));
|
||||||
|
#else
|
||||||
|
buffer = reinterpret_cast<unsigned char*>(std::aligned_alloc(2, 8192));
|
||||||
|
#endif
|
||||||
lastDecoded = NULL;
|
lastDecoded = NULL;
|
||||||
outputBufferSize = 0;
|
outputBufferSize = 0;
|
||||||
echoCanceller = NULL;
|
echoCanceller = NULL;
|
||||||
|
@ -71,7 +71,7 @@ private:
|
|||||||
//BufferPool<JITTER_SLOT_SIZE, JITTER_SLOT_COUNT> bufferPool;
|
//BufferPool<JITTER_SLOT_SIZE, JITTER_SLOT_COUNT> bufferPool;
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
uint32_t step;
|
uint32_t step;
|
||||||
std::array<jitter_packet_t, JITTER_SLOT_COUNT> slots{0};
|
std::array<jitter_packet_t, JITTER_SLOT_COUNT> slots;
|
||||||
std::atomic<int64_t> nextFetchTimestamp{0}; // What frame to read next (protected for GetSeqTooLate)
|
std::atomic<int64_t> nextFetchTimestamp{0}; // What frame to read next (protected for GetSeqTooLate)
|
||||||
std::atomic<double> minDelay{6};
|
std::atomic<double> minDelay{6};
|
||||||
uint32_t minMinDelay;
|
uint32_t minMinDelay;
|
||||||
|
@ -477,12 +477,12 @@ void VoIPController::SendExtra(Wrapped<Extra> &&extra, int64_t endpointId)
|
|||||||
|
|
||||||
auto type = extra.getID();
|
auto type = extra.getID();
|
||||||
LOGV("Sending extra type %s", extra.print().c_str());
|
LOGV("Sending extra type %s", extra.print().c_str());
|
||||||
for (auto &extra : currentExtras)
|
for (auto &curExtra : currentExtras)
|
||||||
{
|
{
|
||||||
if (extra.data.getID() == type && extra.endpointId == endpointId)
|
if (curExtra.data.getID() == type && curExtra.endpointId == endpointId)
|
||||||
{
|
{
|
||||||
extra.seqs.Reset();
|
curExtra.seqs.Reset();
|
||||||
extra.data = std::move(extra.data);
|
curExtra.data = std::move(extra);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ public:
|
|||||||
|
|
||||||
AudioOutputAndroid();
|
AudioOutputAndroid();
|
||||||
virtual ~AudioOutputAndroid();
|
virtual ~AudioOutputAndroid();
|
||||||
virtual void Start();
|
virtual void Start() override;
|
||||||
virtual void Stop();
|
virtual void Stop() override;
|
||||||
virtual bool IsPlaying() override;
|
virtual bool IsPlaying() override;
|
||||||
void HandleCallback(JNIEnv* env, jbyteArray buffer);
|
void HandleCallback(JNIEnv* env, jbyteArray buffer);
|
||||||
static jmethodID initMethod;
|
static jmethodID initMethod;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "VideoRendererAndroid.h"
|
#include "VideoRendererAndroid.h"
|
||||||
#include "JNIUtilities.h"
|
#include "JNIUtilities.h"
|
||||||
#include "../../controller/PrivateDefines.h"
|
#include "../../VoIPController.h"
|
||||||
#include "../../tools/logging.h"
|
#include "../../tools/logging.h"
|
||||||
|
|
||||||
using namespace tgvoip;
|
using namespace tgvoip;
|
||||||
@ -112,16 +112,16 @@ void VideoRendererAndroid::RunThread(){
|
|||||||
}
|
}
|
||||||
std::string codecStr="";
|
std::string codecStr="";
|
||||||
switch(codec){
|
switch(codec){
|
||||||
case CODEC_AVC:
|
case Codec::Avc:
|
||||||
codecStr="video/avc";
|
codecStr="video/avc";
|
||||||
break;
|
break;
|
||||||
case CODEC_HEVC:
|
case Codec::Hevc:
|
||||||
codecStr="video/hevc";
|
codecStr="video/hevc";
|
||||||
break;
|
break;
|
||||||
case CODEC_VP8:
|
case Codec::Vp8:
|
||||||
codecStr="video/x-vnd.on2.vp8";
|
codecStr="video/x-vnd.on2.vp8";
|
||||||
break;
|
break;
|
||||||
case CODEC_VP9:
|
case Codec::Vp9:
|
||||||
codecStr="video/x-vnd.on2.vp9";
|
codecStr="video/x-vnd.on2.vp9";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "VideoSourceAndroid.h"
|
#include "VideoSourceAndroid.h"
|
||||||
#include "JNIUtilities.h"
|
#include "JNIUtilities.h"
|
||||||
#include "../../tools/logging.h"
|
#include "../../tools/logging.h"
|
||||||
#include "../../controller/PrivateDefines.h"
|
#include "../../VoIPController.h"
|
||||||
|
|
||||||
using namespace tgvoip;
|
using namespace tgvoip;
|
||||||
using namespace tgvoip::video;
|
using namespace tgvoip::video;
|
||||||
@ -58,16 +58,16 @@ void VideoSourceAndroid::Reset(uint32_t codec, int maxResolution){
|
|||||||
jni::DoWithJNI([&](JNIEnv* env){
|
jni::DoWithJNI([&](JNIEnv* env){
|
||||||
std::string codecStr="";
|
std::string codecStr="";
|
||||||
switch(codec){
|
switch(codec){
|
||||||
case CODEC_AVC:
|
case Codec::Avc:
|
||||||
codecStr="video/avc";
|
codecStr="video/avc";
|
||||||
break;
|
break;
|
||||||
case CODEC_HEVC:
|
case Codec::Hevc:
|
||||||
codecStr="video/hevc";
|
codecStr="video/hevc";
|
||||||
break;
|
break;
|
||||||
case CODEC_VP8:
|
case Codec::Vp8:
|
||||||
codecStr="video/x-vnd.on2.vp8";
|
codecStr="video/x-vnd.on2.vp8";
|
||||||
break;
|
break;
|
||||||
case CODEC_VP9:
|
case Codec::Vp9:
|
||||||
codecStr="video/x-vnd.on2.vp9";
|
codecStr="video/x-vnd.on2.vp9";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user