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

Generalize

This commit is contained in:
Daniil Gentili 2017-07-04 14:50:02 +01:00
parent 7c9f44c498
commit 18d7f16b85
8 changed files with 84 additions and 74 deletions

View File

@ -9,10 +9,11 @@
include $(CLEAR_VARS) include $(CLEAR_VARS)
DEFINES = -DLIBTGVOIP_CUSTOM -DWEBRTC_POSIX -DTGVOIP_USE_DESKTOP_DSP -DWEBRTC_APM_DEBUG_DUMP=0
INCLUDES = -Ilibtgvoip -I/usr/include/opus -I/usr/local/ssl/include/ -Ilibtgvoip/webrtc_dsp INCLUDES = -Ilibtgvoip -I/usr/include/opus -I/usr/local/ssl/include/ -Ilibtgvoip/webrtc_dsp
LDINCLUDES = -L/usr/local/ssl/lib LDINCLUDES = -L/usr/local/ssl/lib
CXXFLAGS = ${INCLUDES} -O0 -Wall -c -std=c++11 -fpic -finline-functions -ffast-math -fno-strict-aliasing -DUSE_KISS_FFT -DFIXED_POINT -DPHP_LIBTGVOIP -DWEBRTC_POSIX -DTGVOIP_USE_DESKTOP_DSP -DWEBRTC_APM_DEBUG_DUMP=0 -g -DTGVOIP_USE_CXX11_LIB -o CXXFLAGS = ${INCLUDES} -O0 -Wall -c -std=c++11 -fpic -finline-functions -ffast-math -fno-strict-aliasing -DUSE_KISS_FFT -DFIXED_POINT -DPHP_LIBTGVOIP -DWEBRTC_POSIX -DTGVOIP_USE_DESKTOP_DSP -DWEBRTC_APM_DEBUG_DUMP=0 -g -DTGVOIP_USE_CXX11_LIB -DTGVOIP_OTHER ${DEFINES} -o
CFLAGS = ${INCLUDES} -O0 -DUSE_KISS_FFT -fexceptions -fpic -DPHP_LIBTGVOIP -DWEBRTC_POSIX -DTGVOIP_USE_DESKTOP_DSP -DWEBRTC_APM_DEBUG_DUMP=0 -g CFLAGS = ${INCLUDES} -O0 -DUSE_KISS_FFT -fexceptions -fpic ${DEFINES} -g
LFLAGS = -shared ${LDINCLUDES} -pthread -lphpcpp -lopus -lpthread -lstdc++ -lcrypto -lssl -lm -Wl,-z,defs LFLAGS = -shared ${LDINCLUDES} -pthread -lphpcpp -lopus -lpthread -lstdc++ -lcrypto -lssl -lm -Wl,-z,defs

View File

@ -5,7 +5,7 @@
// //
#include "AudioInputPHP.h" #include "AudioInputModule.h"
#include <stdio.h> #include <stdio.h>
#include "../libtgvoip/logging.h" #include "../libtgvoip/logging.h"
@ -13,32 +13,32 @@ using namespace tgvoip;
using namespace tgvoip::audio; using namespace tgvoip::audio;
AudioInputPHP::AudioInputPHP(void* controller){ AudioInputModule::AudioInputModule(std::string deviceID, void* controller){
wrapper = (VoIP *)((VoIPController *)controller)->implData; wrapper = (VoIP *)((VoIPController *)controller)->implData;
} }
AudioInputPHP::~AudioInputPHP(){ AudioInputModule::~AudioInputModule(){
} }
void AudioInputPHP::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels) { void AudioInputModule::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels) {
wrapper->configureAudioInput((int32_t)sampleRate, (int32_t)bitsPerSample, (int32_t)channels); wrapper->configureAudioInput(sampleRate, bitsPerSample, channels);
} }
void AudioInputPHP::Start(){ void AudioInputModule::Start(){
if(running) if(running)
return; return;
running = true; running = true;
wrapper->startInput(); wrapper->startInput();
} }
void AudioInputPHP::Stop(){ void AudioInputModule::Stop(){
wrapper->stopInput(); wrapper->stopInput();
running = false; running = false;
} }
bool AudioInputPHP::writeFrames(const char* data){ bool AudioInputModule::writeFrames(const char* data){
if (running) { if (running) {
LOGE("STARTED"); LOGE("STARTED");
unsigned char* buf = (unsigned char*) malloc(960*2); unsigned char* buf = (unsigned char*) malloc(960*2);
@ -54,3 +54,6 @@ bool AudioInputPHP::writeFrames(const char* data){
return false; return false;
}*/ }*/
} }
void AudioInputModule::EnumerateDevices(std::vector<AudioInputDevice>& devs) {
}

View File

@ -17,16 +17,18 @@ using namespace tgvoip;
using namespace tgvoip::audio; using namespace tgvoip::audio;
namespace tgvoip{ namespace audio{ namespace tgvoip{ namespace audio{
class AudioInputPHP : public AudioInput{ class AudioInputModule : public AudioInput{
public: public:
AudioInputPHP(void* controller); AudioInputModule(std::string deviceID, void* controller);
virtual ~AudioInputPHP(); virtual ~AudioInputModule();
virtual void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels); virtual void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels);
virtual void Start(); virtual void Start();
virtual void Stop(); virtual void Stop();
bool writeFrames(const char* data); bool writeFrames(const char* data);
static void EnumerateDevices(std::vector<AudioInputDevice>& devs);
private: private:
VoIP* wrapper; VoIP* wrapper;

View File

@ -0,0 +1,55 @@
//
// 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.
//
#include "AudioOutputModule.h"
#include <stdio.h>
#include "../libtgvoip/logging.h"
using namespace tgvoip;
using namespace tgvoip::audio;
AudioOutputModule::AudioOutputModule(std::string deviceID, void* controller){
wrapper = (VoIP *)((VoIPController *)controller)->implData;
}
AudioOutputModule::~AudioOutputModule(){
}
void AudioOutputModule::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels){
wrapper->configureAudioOutput(sampleRate, bitsPerSample, channels);
}
void AudioOutputModule::Start(){
if(running)
return;
running = true;
wrapper->startOutput();
}
void AudioOutputModule::Stop(){
if(!running)
return;
wrapper->stopOutput();
running = false;
}
bool AudioOutputModule::IsPlaying(){
return running;
}
float AudioOutputModule::GetLevel(){
return wrapper->getOutputLevel();
}
unsigned char* AudioOutputModule::readFrames() {
unsigned char* buf = (unsigned char *) malloc(960*2);
InvokeCallback(buf, 960*2);
return buf;
}
void AudioOutputModule::EnumerateDevices(std::vector<AudioOutputDevice>& devs) {
}

View File

@ -12,18 +12,19 @@
#include "../libtgvoip/VoIPController.h" #include "../libtgvoip/VoIPController.h"
namespace tgvoip{ namespace audio{ namespace tgvoip{ namespace audio{
class AudioOutputPHP : public AudioOutput{ class AudioOutputModule : public AudioOutput{
public: public:
AudioOutputPHP(void* controller); AudioOutputModule(std::string deviceID, void* controller);
virtual ~AudioOutputPHP(); virtual ~AudioOutputModule();
virtual void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels); virtual void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels);
virtual void Start(); virtual void Start();
virtual void Stop(); virtual void Stop();
virtual bool IsPlaying() override; virtual bool IsPlaying() override;
virtual float GetLevel() override; virtual float GetLevel() override;
unsigned char* readFrames(); unsigned char* readFrames();
static void EnumerateDevices(std::vector<AudioOutputDevice>& devs);
private: private:
VoIP* wrapper; VoIP* wrapper;

View File

@ -1,52 +0,0 @@
//
// 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.
//
#include "AudioOutputPHP.h"
#include <stdio.h>
#include "../libtgvoip/logging.h"
using namespace tgvoip;
using namespace tgvoip::audio;
AudioOutputPHP::AudioOutputPHP(void* controller){
wrapper = (VoIP *)((VoIPController*)controller)->implData;
}
AudioOutputPHP::~AudioOutputPHP(){
}
void AudioOutputPHP::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels){
wrapper->configureAudioOutput((int32_t)sampleRate, (int32_t)bitsPerSample, (int32_t)channels);
}
void AudioOutputPHP::Start(){
if(running)
return;
running = true;
wrapper->startOutput();
}
void AudioOutputPHP::Stop(){
if(!running)
return;
wrapper->stopOutput();
running = false;
}
bool AudioOutputPHP::IsPlaying(){
return running;
}
float AudioOutputPHP::GetLevel(){
return wrapper->getOutputLevel();
}
unsigned char* AudioOutputPHP::readFrames() {
unsigned char* buf = (unsigned char *) malloc(960*2);
InvokeCallback(buf, 960*2);
return buf;
}

@ -1 +1 @@
Subproject commit 97f24e7bda8a4a904671a300d9d271e4485cd248 Subproject commit 831d646b852892c451362c0efc3356401d5d706a

View File

@ -18,8 +18,8 @@ If not, see <http://www.gnu.org/licenses/>.
#include "libtgvoip/VoIPServerConfig.h" #include "libtgvoip/VoIPServerConfig.h"
#include "audio/AudioInputPHP.h" #include "audio/AudioInputModule.h"
#include "audio/AudioOutputPHP.h" #include "audio/AudioOutputModule.h"
using namespace tgvoip; using namespace tgvoip;
using namespace tgvoip::audio; using namespace tgvoip::audio;
@ -100,13 +100,13 @@ void VoIP::release()
Php::Value VoIP::writeFrames(Php::Parameters &params) Php::Value VoIP::writeFrames(Php::Parameters &params)
{ {
AudioInputPHP *in = (AudioInputPHP *)(intptr_t)inst; AudioInputModule *in = (AudioInputModule *)(intptr_t)inst;
return in->writeFrames(params[0]); return in->writeFrames(params[0]);
} }
Php::Value VoIP::readFrames() Php::Value VoIP::readFrames()
{ {
AudioOutputPHP *out = (AudioOutputPHP *)(intptr_t)inst; AudioOutputModule *out = (AudioOutputModule *)(intptr_t)inst;
return out->readFrames(); return out->readFrames();
} }