mirror of
https://github.com/danog/php-libtgvoip.git
synced 2024-11-26 20:04:48 +01:00
Generalize
This commit is contained in:
parent
7c9f44c498
commit
18d7f16b85
5
Makefile
5
Makefile
@ -9,10 +9,11 @@
|
||||
|
||||
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
|
||||
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
|
||||
CFLAGS = ${INCLUDES} -O0 -DUSE_KISS_FFT -fexceptions -fpic -DPHP_LIBTGVOIP -DWEBRTC_POSIX -DTGVOIP_USE_DESKTOP_DSP -DWEBRTC_APM_DEBUG_DUMP=0 -g
|
||||
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 ${DEFINES} -g
|
||||
|
||||
LFLAGS = -shared ${LDINCLUDES} -pthread -lphpcpp -lopus -lpthread -lstdc++ -lcrypto -lssl -lm -Wl,-z,defs
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
//
|
||||
|
||||
|
||||
#include "AudioInputPHP.h"
|
||||
#include "AudioInputModule.h"
|
||||
#include <stdio.h>
|
||||
#include "../libtgvoip/logging.h"
|
||||
|
||||
@ -13,32 +13,32 @@ using namespace tgvoip;
|
||||
using namespace tgvoip::audio;
|
||||
|
||||
|
||||
AudioInputPHP::AudioInputPHP(void* controller){
|
||||
AudioInputModule::AudioInputModule(std::string deviceID, void* controller){
|
||||
wrapper = (VoIP *)((VoIPController *)controller)->implData;
|
||||
}
|
||||
|
||||
|
||||
AudioInputPHP::~AudioInputPHP(){
|
||||
AudioInputModule::~AudioInputModule(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
void AudioInputPHP::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels) {
|
||||
wrapper->configureAudioInput((int32_t)sampleRate, (int32_t)bitsPerSample, (int32_t)channels);
|
||||
void AudioInputModule::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels) {
|
||||
wrapper->configureAudioInput(sampleRate, bitsPerSample, channels);
|
||||
}
|
||||
|
||||
void AudioInputPHP::Start(){
|
||||
void AudioInputModule::Start(){
|
||||
if(running)
|
||||
return;
|
||||
running = true;
|
||||
wrapper->startInput();
|
||||
}
|
||||
|
||||
void AudioInputPHP::Stop(){
|
||||
void AudioInputModule::Stop(){
|
||||
wrapper->stopInput();
|
||||
running = false;
|
||||
}
|
||||
bool AudioInputPHP::writeFrames(const char* data){
|
||||
bool AudioInputModule::writeFrames(const char* data){
|
||||
if (running) {
|
||||
LOGE("STARTED");
|
||||
unsigned char* buf = (unsigned char*) malloc(960*2);
|
||||
@ -54,3 +54,6 @@ bool AudioInputPHP::writeFrames(const char* data){
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
|
||||
void AudioInputModule::EnumerateDevices(std::vector<AudioInputDevice>& devs) {
|
||||
}
|
@ -17,16 +17,18 @@ using namespace tgvoip;
|
||||
using namespace tgvoip::audio;
|
||||
|
||||
namespace tgvoip{ namespace audio{
|
||||
class AudioInputPHP : public AudioInput{
|
||||
class AudioInputModule : public AudioInput{
|
||||
|
||||
public:
|
||||
AudioInputPHP(void* controller);
|
||||
virtual ~AudioInputPHP();
|
||||
AudioInputModule(std::string deviceID, void* controller);
|
||||
virtual ~AudioInputModule();
|
||||
|
||||
virtual void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels);
|
||||
virtual void Start();
|
||||
virtual void Stop();
|
||||
bool writeFrames(const char* data);
|
||||
static void EnumerateDevices(std::vector<AudioInputDevice>& devs);
|
||||
|
||||
private:
|
||||
|
||||
VoIP* wrapper;
|
55
audio/AudioOutputModule.cpp
Normal file
55
audio/AudioOutputModule.cpp
Normal 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) {
|
||||
}
|
@ -12,18 +12,19 @@
|
||||
#include "../libtgvoip/VoIPController.h"
|
||||
|
||||
namespace tgvoip{ namespace audio{
|
||||
class AudioOutputPHP : public AudioOutput{
|
||||
class AudioOutputModule : public AudioOutput{
|
||||
|
||||
public:
|
||||
|
||||
AudioOutputPHP(void* controller);
|
||||
virtual ~AudioOutputPHP();
|
||||
AudioOutputModule(std::string deviceID, void* controller);
|
||||
virtual ~AudioOutputModule();
|
||||
virtual void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels);
|
||||
virtual void Start();
|
||||
virtual void Stop();
|
||||
virtual bool IsPlaying() override;
|
||||
virtual float GetLevel() override;
|
||||
unsigned char* readFrames();
|
||||
static void EnumerateDevices(std::vector<AudioOutputDevice>& devs);
|
||||
|
||||
private:
|
||||
VoIP* wrapper;
|
@ -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
|
8
main.cpp
8
main.cpp
@ -18,8 +18,8 @@ If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "libtgvoip/VoIPServerConfig.h"
|
||||
|
||||
#include "audio/AudioInputPHP.h"
|
||||
#include "audio/AudioOutputPHP.h"
|
||||
#include "audio/AudioInputModule.h"
|
||||
#include "audio/AudioOutputModule.h"
|
||||
|
||||
using namespace tgvoip;
|
||||
using namespace tgvoip::audio;
|
||||
@ -100,13 +100,13 @@ void VoIP::release()
|
||||
|
||||
Php::Value VoIP::writeFrames(Php::Parameters ¶ms)
|
||||
{
|
||||
AudioInputPHP *in = (AudioInputPHP *)(intptr_t)inst;
|
||||
AudioInputModule *in = (AudioInputModule *)(intptr_t)inst;
|
||||
return in->writeFrames(params[0]);
|
||||
}
|
||||
|
||||
Php::Value VoIP::readFrames()
|
||||
{
|
||||
AudioOutputPHP *out = (AudioOutputPHP *)(intptr_t)inst;
|
||||
AudioOutputModule *out = (AudioOutputModule *)(intptr_t)inst;
|
||||
return out->readFrames();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user