1
0
mirror of https://github.com/danog/php-libtgvoip.git synced 2024-11-30 04:19:26 +01:00
This commit is contained in:
Daniil Gentili 2017-06-27 13:02:31 +02:00
parent 353d52ca65
commit c8b40b1e62
5 changed files with 10 additions and 10 deletions

View File

@ -17,6 +17,7 @@ AudioInputPHP::AudioInputPHP(Php::Value callbacks){
startMethod = callbacks["start"];
stopMethod = callbacks["stop"];
configureMethod = callbacks["configure"];
running = false;
}
@ -39,11 +40,12 @@ void AudioInputPHP::Stop(){
stopMethod();
running = false;
}
void AudioInputPHP::writeFrames(Php::Parameters &params){
bool AudioInputPHP::writeFrames(const char* data){
if(!running)
return;
return false;
unsigned char * buf;
memcpy(buf, params[0], 960*2);
memcpy(buf, data, 960*2);
InvokeCallback(buf, 960*2);
delete buf;
return true;
}

View File

@ -7,7 +7,6 @@
#ifndef LIBTGVOIP_AUDIOINPUTPHP_H
#define LIBTGVOIP_AUDIOINPUTPHP_H
#include "phpcpp.h"
#include "../libtgvoip/audio/AudioInput.h"
#include "../libtgvoip/threading.h"
@ -21,7 +20,7 @@ public:
virtual void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels);
virtual void Start();
virtual void Stop();
void writeFrames(Php::Parameters &params);
bool writeFrames(const char* data);
private:
Php::Value configureMethod;
Php::Value startMethod;

View File

@ -47,7 +47,7 @@ float AudioOutputPHP::GetLevel(){
return (double)getLevelMethod();
}
Php::Value AudioOutputPHP::readFrames() {
unsigned char* AudioOutputPHP::readFrames() {
unsigned char* buf;
InvokeCallback(buf, 960*2);
return buf;

View File

@ -8,7 +8,6 @@
#define LIBTGVOIP_AUDIOOUTPUTPHP_H
#include "../libtgvoip/audio/AudioOutput.h"
#include "phpcpp.h"
namespace tgvoip{ namespace audio{
class AudioOutputPHP : public AudioOutput{
@ -22,7 +21,7 @@ public:
virtual void Stop();
virtual bool IsPlaying() override;
virtual float GetLevel() override;
Php::Value readFrames();
unsigned char* readFrames();
private:
Php::Value configureMethod;

View File

@ -94,9 +94,9 @@ public:
}
void writeFrames(Php::Parameters &params) {
Php::Value writeFrames(Php::Parameters &params) {
AudioInputPHP* in=(AudioInputPHP*)(intptr_t)inst;
in->writeFrames(params);
return in->writeFrames(params[0]);
}
Php::Value readFrames() {