1
0
mirror of https://github.com/danog/php-libtgvoip.git synced 2024-11-26 20:04:48 +01:00
php-libtgvoip/audio/AudioInputPHP.cpp

48 lines
1.0 KiB
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.
//
2017-06-22 14:48:52 +02:00
#include "AudioInputPHP.h"
#include <stdio.h>
2017-06-22 14:48:52 +02:00
#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);
2017-06-19 16:07:24 +02:00
delete buf;
2017-06-19 23:38:03 +02:00
}