mirror of
https://github.com/danog/php-libtgvoip.git
synced 2024-11-30 04:19:26 +01:00
Bugfixes and initial group call API
This commit is contained in:
parent
19d858dafa
commit
a1ed35bdad
33
main.cpp
33
main.cpp
@ -65,7 +65,7 @@ void VoIP::initVoIPController()
|
|||||||
callbacks.upgradeToGroupCallRequested = NULL;
|
callbacks.upgradeToGroupCallRequested = NULL;
|
||||||
inst->SetCallbacks(callbacks);
|
inst->SetCallbacks(callbacks);
|
||||||
inst->SetAudioDataCallbacks([this](int16_t *buffer, size_t size) { this->sendAudioFrame(buffer, size); }, [this](int16_t *buffer, size_t size) { this->recvAudioFrame(buffer, size); });
|
inst->SetAudioDataCallbacks([this](int16_t *buffer, size_t size) { this->sendAudioFrame(buffer, size); }, [this](int16_t *buffer, size_t size) { this->recvAudioFrame(buffer, size); });
|
||||||
inst->Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoIP::deinitVoIPController()
|
void VoIP::deinitVoIPController()
|
||||||
@ -73,10 +73,11 @@ void VoIP::deinitVoIPController()
|
|||||||
if (callState != CALL_STATE_ENDED)
|
if (callState != CALL_STATE_ENDED)
|
||||||
{
|
{
|
||||||
callState = CALL_STATE_ENDED;
|
callState = CALL_STATE_ENDED;
|
||||||
inst->Stop();
|
|
||||||
if (inst)
|
if (inst)
|
||||||
{
|
{
|
||||||
|
inst->Stop();
|
||||||
delete inst;
|
delete inst;
|
||||||
|
inst=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (holdFiles.size())
|
while (holdFiles.size())
|
||||||
@ -141,10 +142,10 @@ Php::Value VoIP::discard(Php::Parameters ¶ms)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Php::Value self(this);
|
Php::Value self(this);
|
||||||
if (!self["configuration"])
|
/*if (!self["configuration"]["auth_key"])
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
if (self["madeline"] && self["madeline"].value().instanceOf("danog\\MadelineProto\\MTProto"))
|
if (self["madeline"] && self["madeline"].value().instanceOf("danog\\MadelineProto\\MTProto"))
|
||||||
{
|
{
|
||||||
Php::Array reason;
|
Php::Array reason;
|
||||||
@ -168,6 +169,7 @@ Php::Value VoIP::discard(Php::Parameters ¶ms)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
debug = true;
|
debug = true;
|
||||||
|
|
||||||
self["madeline"].value().call("discard_call", self["internalStorage"]["callID"].value(), reason, rating, debug);
|
self["madeline"].value().call("discard_call", self["internalStorage"]["callID"].value(), reason, rating, debug);
|
||||||
}
|
}
|
||||||
deinitVoIPController();
|
deinitVoIPController();
|
||||||
@ -239,7 +241,7 @@ Php::Value VoIP::startTheMagic()
|
|||||||
deinitVoIPController();
|
deinitVoIPController();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//inst->Start();
|
inst->Start();
|
||||||
inst->Connect();
|
inst->Connect();
|
||||||
Php::Value self(this);
|
Php::Value self(this);
|
||||||
self["internalStorage"]["created"] = (int64_t)time(NULL);
|
self["internalStorage"]["created"] = (int64_t)time(NULL);
|
||||||
@ -499,9 +501,9 @@ Php::Value VoIP::getDebugString()
|
|||||||
}
|
}
|
||||||
Php::Value VoIP::getStats()
|
Php::Value VoIP::getStats()
|
||||||
{
|
{
|
||||||
|
Php::Value stats;
|
||||||
VoIPController::TrafficStats _stats;
|
VoIPController::TrafficStats _stats;
|
||||||
inst->GetStats(&_stats);
|
inst->GetStats(&_stats);
|
||||||
Php::Value stats;
|
|
||||||
stats["bytesSentWifi"] = (int64_t)_stats.bytesSentWifi;
|
stats["bytesSentWifi"] = (int64_t)_stats.bytesSentWifi;
|
||||||
stats["bytesSentMobile"] = (int64_t)_stats.bytesSentMobile;
|
stats["bytesSentMobile"] = (int64_t)_stats.bytesSentMobile;
|
||||||
stats["bytesRecvdWifi"] = (int64_t)_stats.bytesRecvdWifi;
|
stats["bytesRecvdWifi"] = (int64_t)_stats.bytesRecvdWifi;
|
||||||
@ -509,6 +511,22 @@ Php::Value VoIP::getStats()
|
|||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Php::Value VoIP::getPeerCapabilities()
|
||||||
|
{
|
||||||
|
return (int64_t) inst->GetPeerCapabilities();
|
||||||
|
}
|
||||||
|
void VoIP::requestCallUpgrade()
|
||||||
|
{
|
||||||
|
return inst->RequestCallUpgrade();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoIP::sendGroupCallKey(Php::Parameters ¶ms)
|
||||||
|
{
|
||||||
|
unsigned char *key = (unsigned char *)malloc(256);
|
||||||
|
memcpy(key, params[0], 256);
|
||||||
|
inst->SendGroupCallKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
Php::Value VoIP::getState()
|
Php::Value VoIP::getState()
|
||||||
{
|
{
|
||||||
return state;
|
return state;
|
||||||
@ -573,6 +591,9 @@ extern "C"
|
|||||||
voip.method<&VoIP::getSignalBarsCount>("getSignalBarsCount", Php::Public | Php::Final);
|
voip.method<&VoIP::getSignalBarsCount>("getSignalBarsCount", Php::Public | Php::Final);
|
||||||
voip.method<&VoIP::getDebugString>("getDebugString", Php::Public | Php::Final);
|
voip.method<&VoIP::getDebugString>("getDebugString", Php::Public | Php::Final);
|
||||||
voip.method<&VoIP::getStats>("getStats", Php::Public | Php::Final);
|
voip.method<&VoIP::getStats>("getStats", Php::Public | Php::Final);
|
||||||
|
voip.method<&VoIP::getPeerCapabilities>("getPeerCapabilities", Php::Public | Php::Final);
|
||||||
|
voip.method<&VoIP::sendGroupCallKey>("sendGroupCallKey", Php::Public | Php::Final, {Php::ByVal("key", Php::Type::String)});
|
||||||
|
voip.method<&VoIP::requestCallUpgrade>("requestCallUpgrade", Php::Public | Php::Final);
|
||||||
voip.method<&VoIP::startTheMagic>("startTheMagic", Php::Public | Php::Final);
|
voip.method<&VoIP::startTheMagic>("startTheMagic", Php::Public | Php::Final);
|
||||||
|
|
||||||
voip.method<&VoIP::play>("then", Php::Public | Php::Final, {Php::ByVal("file", Php::Type::String)});
|
voip.method<&VoIP::play>("then", Php::Public | Php::Final, {Php::ByVal("file", Php::Type::String)});
|
||||||
|
3
main.h
3
main.h
@ -81,6 +81,9 @@ public:
|
|||||||
Php::Value getDebugLog();
|
Php::Value getDebugLog();
|
||||||
Php::Value getDebugString();
|
Php::Value getDebugString();
|
||||||
Php::Value getSignalBarsCount();
|
Php::Value getSignalBarsCount();
|
||||||
|
Php::Value getPeerCapabilities();
|
||||||
|
void requestCallUpgrade();
|
||||||
|
void sendGroupCallKey(Php::Parameters ¶ms);
|
||||||
Php::Value debugCtl(Php::Parameters ¶ms);
|
Php::Value debugCtl(Php::Parameters ¶ms);
|
||||||
Php::Value setBitrate(Php::Parameters ¶ms);
|
Php::Value setBitrate(Php::Parameters ¶ms);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user