2017-07-01 15:12:52 +02:00
|
|
|
/*
|
|
|
|
Copyright 2016-2017 Daniil Gentili
|
|
|
|
(https://daniil.it)
|
|
|
|
This file is part of php-libtgvoip.
|
|
|
|
php-libtgvoip is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
The PWRTelegram API is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along with php-libtgvoip.
|
|
|
|
If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2018-09-02 20:12:51 +02:00
|
|
|
|
2017-07-01 19:40:28 +02:00
|
|
|
#ifndef PHPLIBTGVOIP_H
|
|
|
|
#define PHPLIBTGVOIP_H
|
2017-07-01 15:12:52 +02:00
|
|
|
|
2019-03-29 14:07:22 +01:00
|
|
|
#ifndef TGVOIP_USE_CALLBACK_AUDIO_IO
|
|
|
|
#define TGVOIP_USE_CALLBACK_AUDIO_IO
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WEBRTC_LINUX
|
|
|
|
#define WEBRTC_LINUX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WEBRTC_POSIX
|
|
|
|
#define WEBRTC_POSIX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef TGVOIP_USE_DESKTOP_DSP
|
|
|
|
#define TGVOIP_USE_DESKTOP_DSP
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WEBRTC_APM_DEBUG_DUMP
|
|
|
|
#define WEBRTC_APM_DEBUG_DUMP 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WEBRTC_NS_FLOAT
|
|
|
|
#define WEBRTC_NS_FLOAT
|
|
|
|
#endif
|
|
|
|
|
2017-07-01 15:12:52 +02:00
|
|
|
#include "libtgvoip/VoIPController.h"
|
2017-07-13 18:03:33 +02:00
|
|
|
/*
|
2017-07-06 18:12:49 +02:00
|
|
|
#include <php.h>
|
|
|
|
#include <php_ini.h>
|
2017-07-13 18:03:33 +02:00
|
|
|
#include <ext/standard/info.h>*/
|
2017-07-01 15:12:52 +02:00
|
|
|
#include <phpcpp.h>
|
2017-07-11 21:11:23 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "libtgvoip/threading.h"
|
|
|
|
#include <queue>
|
2017-07-01 15:12:52 +02:00
|
|
|
|
2017-07-10 00:06:50 +02:00
|
|
|
#define AUDIO_STATE_NONE -1
|
|
|
|
#define AUDIO_STATE_CREATED 0
|
|
|
|
#define AUDIO_STATE_CONFIGURED 1
|
|
|
|
#define AUDIO_STATE_RUNNING 2
|
|
|
|
|
2017-07-20 16:02:53 +02:00
|
|
|
#define CALL_STATE_NONE -1
|
|
|
|
#define CALL_STATE_REQUESTED 0
|
2017-07-18 20:46:22 +02:00
|
|
|
#define CALL_STATE_INCOMING 1
|
|
|
|
#define CALL_STATE_ACCEPTED 2
|
|
|
|
#define CALL_STATE_CONFIRMED 3
|
|
|
|
#define CALL_STATE_READY 4
|
|
|
|
#define CALL_STATE_ENDED 5
|
2017-07-18 19:16:27 +02:00
|
|
|
|
2018-09-02 20:12:51 +02:00
|
|
|
|
2017-07-01 15:12:52 +02:00
|
|
|
using namespace tgvoip;
|
|
|
|
using namespace tgvoip::audio;
|
2017-07-01 19:40:28 +02:00
|
|
|
|
2017-07-18 19:16:27 +02:00
|
|
|
namespace tgvoip
|
|
|
|
{
|
|
|
|
namespace audio
|
|
|
|
{
|
2017-07-10 12:30:13 +02:00
|
|
|
class AudioInputModule;
|
|
|
|
class AudioOutputModule;
|
2017-07-18 19:16:27 +02:00
|
|
|
}
|
|
|
|
}
|
2019-03-29 14:07:22 +01:00
|
|
|
|
|
|
|
|
2019-03-29 20:00:38 +01:00
|
|
|
class VoIPServerConfigInternal : public Php::Base
|
2019-03-29 14:07:22 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static void update(Php::Parameters ¶ms);
|
|
|
|
};
|
|
|
|
|
2017-07-10 00:06:50 +02:00
|
|
|
class VoIP : public Php::Base
|
|
|
|
{
|
2017-07-18 19:16:27 +02:00
|
|
|
public:
|
2017-07-23 17:49:47 +02:00
|
|
|
void __construct(Php::Parameters ¶ms);
|
2019-03-29 14:07:22 +01:00
|
|
|
void setCall(Php::Parameters ¶ms);
|
2017-07-23 17:49:47 +02:00
|
|
|
void initVoIPController();
|
|
|
|
Php::Value discard(Php::Parameters ¶ms);
|
|
|
|
Php::Value accept();
|
|
|
|
void deinitVoIPController();
|
|
|
|
void __wakeup();
|
|
|
|
Php::Value __sleep();
|
|
|
|
|
2017-07-31 20:54:34 +02:00
|
|
|
Php::Value startTheMagic();
|
2017-07-23 17:49:47 +02:00
|
|
|
|
2018-09-02 20:12:51 +02:00
|
|
|
void recvAudioFrame(int16_t* data, size_t size);
|
|
|
|
void sendAudioFrame(int16_t* data, size_t size);
|
|
|
|
|
2017-07-23 17:49:47 +02:00
|
|
|
Php::Value getVisualization();
|
|
|
|
void setVisualization(Php::Parameters ¶ms);
|
|
|
|
|
|
|
|
Php::Value play(Php::Parameters ¶ms);
|
|
|
|
Php::Value playOnHold(Php::Parameters ¶ms);
|
|
|
|
Php::Value setOutputFile(Php::Parameters ¶ms);
|
|
|
|
Php::Value unsetOutputFile();
|
|
|
|
|
|
|
|
Php::Value getVersion();
|
|
|
|
Php::Value getPreferredRelayID();
|
|
|
|
Php::Value getLastError();
|
|
|
|
Php::Value getStats();
|
|
|
|
Php::Value getDebugLog();
|
|
|
|
Php::Value getDebugString();
|
2017-08-21 18:20:37 +02:00
|
|
|
Php::Value getSignalBarsCount();
|
2018-09-04 15:49:20 +02:00
|
|
|
Php::Value getPeerCapabilities();
|
2019-03-29 14:07:22 +01:00
|
|
|
static Php::Value getConnectionMaxLayer();
|
2018-09-04 15:49:20 +02:00
|
|
|
void requestCallUpgrade();
|
|
|
|
void sendGroupCallKey(Php::Parameters ¶ms);
|
2017-08-03 17:30:54 +02:00
|
|
|
Php::Value debugCtl(Php::Parameters ¶ms);
|
|
|
|
Php::Value setBitrate(Php::Parameters ¶ms);
|
2017-07-23 17:49:47 +02:00
|
|
|
|
|
|
|
Php::Value setMicMute(Php::Parameters ¶ms);
|
2017-07-26 08:31:52 +02:00
|
|
|
Php::Value setMadeline(Php::Parameters ¶ms);
|
2017-07-23 17:49:47 +02:00
|
|
|
|
|
|
|
Php::Value getProtocol();
|
|
|
|
Php::Value getState();
|
|
|
|
Php::Value isPlaying();
|
|
|
|
Php::Value isDestroyed();
|
|
|
|
Php::Value whenCreated();
|
|
|
|
Php::Value isCreator();
|
|
|
|
Php::Value getOtherID();
|
|
|
|
Php::Value getCallID();
|
|
|
|
Php::Value getCallState();
|
2017-09-08 14:04:56 +02:00
|
|
|
Php::Value close();
|
2017-07-23 17:49:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
int state = STATE_CREATED;
|
|
|
|
|
|
|
|
bool playing = false;
|
|
|
|
bool destroyed = false;
|
|
|
|
|
|
|
|
void parseConfig();
|
|
|
|
void parseProxyConfig();
|
2018-09-02 20:12:51 +02:00
|
|
|
int otherID;
|
|
|
|
|
|
|
|
private:
|
2017-07-23 17:49:47 +02:00
|
|
|
std::queue<FILE *> inputFiles;
|
|
|
|
std::queue<FILE *> holdFiles;
|
2018-09-02 20:12:51 +02:00
|
|
|
Mutex inputMutex;
|
2017-07-23 17:49:47 +02:00
|
|
|
|
|
|
|
FILE *outputFile;
|
2018-09-02 20:12:51 +02:00
|
|
|
Mutex outputMutex;
|
2017-07-20 16:24:17 +02:00
|
|
|
|
2018-09-02 20:12:51 +02:00
|
|
|
size_t readInput;
|
|
|
|
size_t readOutput;
|
2017-07-23 17:49:47 +02:00
|
|
|
int callState = CALL_STATE_NONE;
|
|
|
|
VoIPController *inst;
|
2017-07-01 19:40:28 +02:00
|
|
|
};
|
|
|
|
|
2017-07-04 03:04:22 +02:00
|
|
|
#endif
|