1
0
mirror of https://github.com/danog/php-libtgvoip.git synced 2024-11-26 20:04:48 +01:00

Fixes I guess

This commit is contained in:
Daniil Gentili 2017-06-17 17:24:34 +02:00
parent da80db0361
commit df5a34f41a
2 changed files with 46 additions and 50 deletions

View File

@ -7,17 +7,6 @@
# You should have received a copy of the GNU General Public License along with php-libtgvoip.
# If not, see <http://www.gnu.org/licenses/>.
#
# Makefile template
#
# This is an example Makefile that can be used by anyone who is building
# his or her own PHP extensions using the PHP-CPP library.
#
# In the top part of this file we have included variables that can be
# altered to fit your configuration, near the bottom the instructions and
# dependencies for the compiler are defined. The deeper you get into this
# file, the less likely it is that you will have to change anything in it.
#
include $(CLEAR_VARS)
@ -45,32 +34,27 @@ MY_DIR := libtgvoip
LOCAL_C_INCLUDES := jni/opus/include jni/boringssl/include/
LOCAL_SRC_FILES := \
$(MY_DIR)/external/speex_dsp/buffer.c \
$(MY_DIR)/external/speex_dsp/fftwrap.c \
$(MY_DIR)/external/speex_dsp/filterbank.c \
$(MY_DIR)/external/speex_dsp/kiss_fft.c \
$(MY_DIR)/external/speex_dsp/kiss_fftr.c \
$(MY_DIR)/external/speex_dsp/mdf.c \
$(MY_DIR)/external/speex_dsp/preprocess.c \
$(MY_DIR)/external/speex_dsp/resample.c \
$(MY_DIR)/external/speex_dsp/scal.c \
$(MY_DIR)/external/speex_dsp/smallft.c \
$(MY_DIR)/VoIPController.cpp \
$(MY_DIR)/BufferInputStream.cpp \
$(MY_DIR)/BufferOutputStream.cpp \
$(MY_DIR)/BlockingQueue.cpp \
$(MY_DIR)/audio/AudioInput.cpp \
$(MY_DIR)/os/android/AudioInputOpenSLES.cpp \
$(MY_DIR)/MediaStreamItf.cpp \
$(MY_DIR)/audio/AudioOutput.cpp \
$(MY_DIR)/OpusEncoder.cpp \
$(MY_DIR)/os/android/AudioOutputOpenSLES.cpp \
$(MY_DIR)/JitterBuffer.cpp \
$(MY_DIR)/OpusDecoder.cpp \
$(MY_DIR)/BufferPool.cpp \
$(MY_DIR)/os/android/OpenSLEngineWrapper.cpp \
$(MY_DIR)/os/android/AudioInputAndroid.cpp \
$(MY_DIR)/EchoCanceller.cpp \
./libtgvoip/logging.cpp \
./libtgvoip/VoIPController.cpp \
./libtgvoip/BufferInputStream.cpp \
./libtgvoip/BufferOutputStream.cpp \
./libtgvoip/BlockingQueue.cpp \
./libtgvoip/audio/AudioInput.cpp \
./libtgvoip/os/android/AudioInputOpenSLES.cpp \
./libtgvoip/MediaStreamItf.cpp \
./libtgvoip/audio/AudioOutput.cpp \
./libtgvoip/OpusEncoder.cpp \
./libtgvoip/os/android/AudioOutputOpenSLES.cpp \
./libtgvoip/JitterBuffer.cpp \
./libtgvoip/OpusDecoder.cpp \
./libtgvoip/BufferPool.cpp \
./libtgvoip/os/android/OpenSLEngineWrapper.cpp \
./libtgvoip/os/android/AudioInputAndroid.cpp \
./libtgvoip/os/android/AudioOutputAndroid.cpp \
./libtgvoip/EchoCanceller.cpp \
./libtgvoip/CongestionControl.cpp \
./libtgvoip/VoIPServerConfig.cpp \
./libtgvoip/NetworkSocket.cpp
include $(BUILD_STATIC_LIBRARY)
@ -93,7 +77,7 @@ NAME = libtgvoip
# one for each extension. Use this variable to specify this directory.
#
INI_DIR = /etc/php7ts/conf.d
INI_DIR = $(shell php --ini | sed '/Scan for additional .ini files in: /!d;s/Scan for additional .ini files in: //')
#

View File

@ -9,6 +9,7 @@ You should have received a copy of the GNU General Public License along with php
If not, see <http://www.gnu.org/licenses/>.
*/
#include <phpcpp.h>
#include <string.h>
#include <wchar.h>
@ -17,6 +18,8 @@ If not, see <http://www.gnu.org/licenses/>.
#include <vector>
#include "libtgvoip/VoIPServerConfig.h"
#include "libtgvoip/VoIPController.h"
#include "libtgvoip/NetworkSocket.h"
//#include "libtgvoip/os/android/AudioOutputOpenSLES.h"
//#include "libtgvoip/os/android/AudioInputOpenSLES.h"
//#include "libtgvoip/os/android/AudioInputAndroid.h"
@ -27,7 +30,7 @@ using namespace tgvoip;
class VoIP : public Php::Base {
public:
void nativeInit(Php::Parameters &params) {
void __construct(Php::Parameters &params) {
/*
if(!CAudioInputAndroid::jniClass) {
jclass cls=env->FindClass("org/telegram/messenger/voip/AudioRecordJNI");
@ -49,10 +52,16 @@ public:
impl_data_android_t* impl=(impl_data_android_t*) malloc(sizeof(impl_data_android_t));
impl->javaObject=env->NewGlobalRef(thiz);
inst=new VoIPController();
inst->implData=impl;
inst->SetStateCallback(updateConnectionState);
*/
if (params.size() == 1) {
setStateMethod = params[0];
}
inst=new VoIPController();
inst->implData = static_cast<void*>(this);
inst->SetStateCallback([](tgvoip::VoIPController *controller, int state) {
static_cast<VoIP*>(controller->implData)->updateConnectionState(controller, state);
});
}
void start() {
@ -81,8 +90,8 @@ public:
std::string peer_tag = params[0][i]["peer_tag"];
IPv4Address v4addr(ip);
IPv6Address v6addr("::0");
tgvoip::IPv4Address v4addr(ip);
tgvoip::IPv6Address v6addr("::0");
unsigned char pTag[16];
if(ipv6 != ""){
@ -204,15 +213,15 @@ public:
return inst->GetDebugLog();
}
private:
Php::Value setStateMethod;
VoIPController* inst;
void updateConnectionState(int state) {
if(setStateMethod) {
void updateConnectionState(VoIPController* cntrlr, int state) {
if (setStateMethod) {
setStateMethod(state);
}
}
private:
VoIPController* inst;
Php::Value setStateMethod;
};
@ -234,6 +243,9 @@ extern "C" {
// description of the class so that PHP knows which methods are accessible
Php::Class<VoIP> voip("VoIP");
voip.method<&VoIP::__construct> ("__construct", {
Php::ByVal("setStateCallable", Php::Type::Callable, false),
});
voip.method<&VoIP::setEncryptionKey> ("setEncryptionKey", {
Php::ByVal("key", Php::Type::String),
Php::ByVal("isOutgoing", Php::Type::Bool),