2017-06-18 19:32:20 +02:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
|
2017-06-22 14:48:52 +02:00
|
|
|
|
2017-06-18 19:32:20 +02:00
|
|
|
#include "AudioInputPHP.h"
|
|
|
|
#include <stdio.h>
|
2017-06-22 14:48:52 +02:00
|
|
|
#include "../libtgvoip/logging.h"
|
2017-06-18 19:32:20 +02:00
|
|
|
|
|
|
|
using namespace tgvoip;
|
|
|
|
using namespace tgvoip::audio;
|
|
|
|
|
|
|
|
|
2017-06-19 15:39:45 +02:00
|
|
|
AudioInputPHP::AudioInputPHP(Php::Value callbacks){
|
|
|
|
startMethod = callbacks["start"];
|
|
|
|
stopMethod = callbacks["stop"];
|
|
|
|
configureMethod = callbacks["configure"];
|
2017-06-18 19:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-19 15:39:45 +02:00
|
|
|
AudioInputPHP::~AudioInputPHP(){
|
2017-06-18 19:32:20 +02:00
|
|
|
|
|
|
|
}
|
2017-06-19 15:39:45 +02:00
|
|
|
void AudioInputPHP::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels) {
|
|
|
|
configureMethod((int32_t)sampleRate, (int32_t)bitsPerSample, (int32_t)channels);
|
2017-06-18 19:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void AudioInputPHP::Start(){
|
2017-06-19 15:39:45 +02:00
|
|
|
if(running)
|
|
|
|
return;
|
|
|
|
startMethod();
|
2017-06-18 19:32:20 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioInputPHP::Stop(){
|
2017-06-19 15:39:45 +02:00
|
|
|
stopMethod();
|
2017-06-18 19:32:20 +02:00
|
|
|
}
|
2017-06-19 15:39:45 +02:00
|
|
|
void AudioInputPHP::writeFrames(Php::Parameters ¶ms){
|
2017-06-18 19:32:20 +02:00
|
|
|
if(!running)
|
|
|
|
return;
|
2017-06-19 15:39:45 +02:00
|
|
|
unsigned char * buf;
|
|
|
|
memcpy(buf, params[0], 960*2);
|
|
|
|
InvokeCallback(buf, 960*2);
|
2017-06-19 16:07:24 +02:00
|
|
|
delete buf;
|
2017-06-19 23:38:03 +02:00
|
|
|
}
|