1
0
mirror of https://github.com/danog/php-libtgvoip.git synced 2024-11-27 04:14:43 +01:00
php-libtgvoip/AudioInputPHP.cpp

45 lines
1007 B
C++
Raw Normal View History

//
// 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 "AudioInputPHP.h"
#include <stdio.h>
#include "libtgvoip/logging.h"
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-19 15:39:45 +02:00
AudioInputPHP::~AudioInputPHP(){
}
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);
}
void AudioInputPHP::Start(){
2017-06-19 15:39:45 +02:00
if(running)
return;
startMethod();
}
void AudioInputPHP::Stop(){
2017-06-19 15:39:45 +02:00
stopMethod();
}
2017-06-19 15:39:45 +02:00
void AudioInputPHP::writeFrames(Php::Parameters &params){
if(!running)
return;
2017-06-19 15:39:45 +02:00
unsigned char * buf;
memcpy(buf, params[0], 960*2);
InvokeCallback(buf, 960*2);
}