mirror of
https://github.com/danog/php-libtgvoip.git
synced 2024-11-26 20:04:48 +01:00
Fixed stuff
This commit is contained in:
parent
40c71ca52e
commit
f8894e8c1f
@ -17,6 +17,7 @@ AudioInputPHP::AudioInputPHP(Php::Value callbacks){
|
||||
startMethod = callbacks["start"];
|
||||
stopMethod = callbacks["stop"];
|
||||
configureMethod = callbacks["configure"];
|
||||
call = callbacks["call"];
|
||||
}
|
||||
|
||||
|
||||
@ -24,18 +25,18 @@ AudioInputPHP::~AudioInputPHP(){
|
||||
|
||||
}
|
||||
void AudioInputPHP::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels) {
|
||||
configureMethod((int32_t)sampleRate, (int32_t)bitsPerSample, (int32_t)channels);
|
||||
configureMethod(static_cast<VoIP*> call, (int32_t)sampleRate, (int32_t)bitsPerSample, (int32_t)channels);
|
||||
}
|
||||
|
||||
void AudioInputPHP::Start(){
|
||||
if(running)
|
||||
return;
|
||||
startMethod();
|
||||
startMethod(static_cast<VoIP*> call);
|
||||
|
||||
}
|
||||
|
||||
void AudioInputPHP::Stop(){
|
||||
stopMethod();
|
||||
stopMethod(static_cast<VoIP*> call);
|
||||
}
|
||||
void AudioInputPHP::writeFrames(Php::Parameters ¶ms){
|
||||
if(!running)
|
||||
|
@ -26,6 +26,7 @@ private:
|
||||
Php::Value configureMethod;
|
||||
Php::Value startMethod;
|
||||
Php::Value stopMethod;
|
||||
void* call;
|
||||
bool running;
|
||||
};
|
||||
}}
|
||||
|
@ -17,23 +17,24 @@ AudioOutputPHP::AudioOutputPHP(Php::Value callbacks){
|
||||
stopMethod = callbacks["stop"];
|
||||
configureMethod = callbacks["configure"];
|
||||
getLevelMethod = callbacks["get_level"];
|
||||
call = callbacks["call"];
|
||||
}
|
||||
|
||||
void AudioOutputPHP::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels){
|
||||
configureMethod((int32_t)sampleRate, (int32_t)bitsPerSample, (int32_t)channels);
|
||||
configureMethod(static_cast<VoIP*> call, (int32_t)sampleRate, (int32_t)bitsPerSample, (int32_t)channels);
|
||||
}
|
||||
|
||||
void AudioOutputPHP::Start(){
|
||||
if(running)
|
||||
return;
|
||||
running = true;
|
||||
startMethod();
|
||||
startMethod(static_cast<VoIP*> call);
|
||||
}
|
||||
|
||||
void AudioOutputPHP::Stop(){
|
||||
if(!running)
|
||||
return;
|
||||
stopMethod();
|
||||
stopMethod(static_cast<VoIP*> call);
|
||||
running = false;
|
||||
}
|
||||
|
||||
@ -42,7 +43,7 @@ bool AudioOutputPHP::IsPlaying(){
|
||||
}
|
||||
|
||||
float AudioOutputPHP::GetLevel(){
|
||||
return (double)getLevelMethod();
|
||||
return (double)getLevelMethod(static_cast<VoIP*> call);
|
||||
}
|
||||
|
||||
Php::Value AudioOutputPHP::readFrames() {
|
||||
@ -50,22 +51,3 @@ Php::Value AudioOutputPHP::readFrames() {
|
||||
InvokeCallback(buf, 960*2);
|
||||
return buf;
|
||||
}
|
||||
/*
|
||||
AudioOutputPHP::~AudioOutputPHP(){
|
||||
JNIEnv* env=NULL;
|
||||
bool didAttach=false;
|
||||
sharedJVM->GetEnv((void**) &env, JNI_VERSION_1_6);
|
||||
if(!env){
|
||||
sharedJVM->AttachCurrentThread(&env, NULL);
|
||||
didAttach=true;
|
||||
}
|
||||
|
||||
env->CallVoidMethod(javaObject, releaseMethod);
|
||||
env->DeleteGlobalRef(javaObject);
|
||||
javaObject=NULL;
|
||||
|
||||
if(didAttach){
|
||||
sharedJVM->DetachCurrentThread();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -30,6 +30,7 @@ private:
|
||||
Php::Value stopMethod;
|
||||
Php::Value isPlayingMethod;
|
||||
Php::Value getLevelMethod;
|
||||
void* call;
|
||||
bool running;
|
||||
};
|
||||
}}
|
||||
|
17
main.cpp
17
main.cpp
@ -50,6 +50,10 @@ public:
|
||||
|
||||
void __construct(Php::Parameters ¶ms) {
|
||||
setStateMethod = params[0];
|
||||
madeline = params[3];
|
||||
current_call = params[4];
|
||||
params[1]["call"] = static_cast<void*>(this);
|
||||
params[2]["call"] = static_cast<void*>(this);
|
||||
inst=new VoIPController(params[1], params[2]);
|
||||
inst->implData = static_cast<void*>(this);
|
||||
inst->SetStateCallback([](tgvoip::VoIPController *controller, int state) {
|
||||
@ -200,12 +204,14 @@ public:
|
||||
}
|
||||
|
||||
void updateConnectionState(VoIPController* cntrlr, int state) {
|
||||
setStateMethod(state);
|
||||
setStateMethod(this, state);
|
||||
}
|
||||
private:
|
||||
|
||||
VoIPController* inst;
|
||||
Php::Value setStateMethod;
|
||||
Php::Value madeline;
|
||||
Php::Value current_call;
|
||||
|
||||
};
|
||||
|
||||
@ -231,6 +237,8 @@ extern "C" {
|
||||
Php::ByVal("setStateCallable", Php::Type::Callable),
|
||||
Php::ByVal("inputCallables", Php::Type::Array),
|
||||
Php::ByVal("outputCallables", Php::Type::Array),
|
||||
Php::ByRef("madelineProto", Php::Type::Object),
|
||||
Php::ByRef("currentCall", Php::Type::Array),
|
||||
});
|
||||
voip.method<&VoIP::setEncryptionKey> ("setEncryptionKey", {
|
||||
Php::ByVal("key", Php::Type::String),
|
||||
@ -242,9 +250,11 @@ extern "C" {
|
||||
voip.method<&VoIP::setMicMute> ("setMicMute", {
|
||||
Php::ByVal("type", Php::Type::Bool),
|
||||
});
|
||||
/*
|
||||
voip.method<&VoIP::setNativeBufferSize> ("setNativeBufferSize", {
|
||||
Php::ByVal("type", Php::Type::Numeric),
|
||||
});
|
||||
*/
|
||||
voip.method<&VoIP::debugCtl> ("debugCtl", {
|
||||
Php::ByVal("request", Php::Type::Numeric),
|
||||
Php::ByVal("param", Php::Type::Numeric),
|
||||
@ -252,9 +262,9 @@ extern "C" {
|
||||
voip.method<&VoIP::setConfig> ("setConfig", { // jdouble recvTimeout, jdouble initTimeout, jint dataSavingMode, jboolean enableAEC, jboolean enableNS, jboolean enableAGC, jstring logFilePath
|
||||
Php::ByVal("recvTimeout", Php::Type::Float),
|
||||
Php::ByVal("initTimeout", Php::Type::Float),
|
||||
Php::ByVal("dataSavingMode", Php::Type::Numeric),
|
||||
Php::ByVal("enableAEC", Php::Type::Bool),
|
||||
Php::ByVal("dataSavingMode", Php::Type::Bool),
|
||||
Php::ByVal("enableAEC", Php::Type::Bool),
|
||||
Php::ByVal("enableNS", Php::Type::Bool),
|
||||
Php::ByVal("enableAGC", Php::Type::Bool),
|
||||
Php::ByVal("logFilePath", Php::Type::String, false),
|
||||
Php::ByVal("statsDumpFilePath", Php::Type::String, false),
|
||||
@ -281,6 +291,7 @@ extern "C" {
|
||||
Php::ByVal("frames", Php::Type::String)
|
||||
});
|
||||
|
||||
voip.constant("STATE_READY_TO_INIT", 0);
|
||||
voip.constant("STATE_WAIT_INIT", 1);
|
||||
voip.constant("STATE_WAIT_INIT_ACK", 2);
|
||||
voip.constant("STATE_ESTABLISHED", 3);
|
||||
|
Loading…
Reference in New Issue
Block a user