2015-10-25 14:40:16 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "mumlib/Callback.hpp"
|
2018-07-05 20:19:28 +02:00
|
|
|
#include "mumlib/enums.hpp"
|
2015-10-25 14:40:16 +01:00
|
|
|
|
|
|
|
#include <boost/asio.hpp>
|
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace mumlib {
|
|
|
|
|
2016-04-15 03:13:56 +02:00
|
|
|
constexpr int DEFAULT_OPUS_ENCODER_BITRATE = 16000;
|
2018-03-28 05:37:59 +02:00
|
|
|
constexpr int DEFAULT_OPUS_SAMPLE_RATE = 48000;
|
2018-03-29 04:53:47 +02:00
|
|
|
constexpr int DEFAULT_OPUS_NUM_CHANNELS = 1;
|
2016-04-15 03:13:56 +02:00
|
|
|
|
2015-10-25 14:40:16 +01:00
|
|
|
using namespace std;
|
|
|
|
using namespace boost::asio;
|
|
|
|
|
|
|
|
class MumlibException : public runtime_error {
|
|
|
|
public:
|
|
|
|
MumlibException(string message) : runtime_error(message) { }
|
|
|
|
};
|
|
|
|
|
2016-04-15 03:13:56 +02:00
|
|
|
struct MumlibConfiguration {
|
|
|
|
int opusEncoderBitrate = DEFAULT_OPUS_ENCODER_BITRATE;
|
2018-03-28 05:37:59 +02:00
|
|
|
int opusSampleRate = DEFAULT_OPUS_SAMPLE_RATE;
|
2018-03-29 04:53:47 +02:00
|
|
|
int opusChannels = DEFAULT_OPUS_NUM_CHANNELS;
|
2017-05-28 21:02:45 +02:00
|
|
|
std::string cert_file = "";
|
|
|
|
std::string privkey_file = "";
|
2016-04-15 03:13:56 +02:00
|
|
|
// additional fields will be added in the future
|
|
|
|
};
|
|
|
|
|
2018-04-18 07:43:52 +02:00
|
|
|
struct MumbleUser {
|
|
|
|
int32_t sessionId;
|
|
|
|
string name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MumbleChannel {
|
|
|
|
int32_t channelId;
|
|
|
|
string name;
|
|
|
|
string description;
|
|
|
|
};
|
|
|
|
|
2015-10-25 14:40:16 +01:00
|
|
|
struct _Mumlib_Private;
|
|
|
|
|
|
|
|
|
|
|
|
class Mumlib : boost::noncopyable {
|
|
|
|
public:
|
2018-03-28 05:37:59 +02:00
|
|
|
explicit Mumlib(Callback &callback);
|
2015-10-25 14:40:16 +01:00
|
|
|
|
2015-10-27 23:31:45 +01:00
|
|
|
Mumlib(Callback &callback, io_service &ioService);
|
2015-10-25 14:40:16 +01:00
|
|
|
|
2016-04-15 03:13:56 +02:00
|
|
|
Mumlib(Callback &callback, MumlibConfiguration &configuration);
|
|
|
|
|
|
|
|
Mumlib(Callback &callback, io_service &ioService, MumlibConfiguration &configuration);
|
|
|
|
|
2015-11-17 22:53:57 +01:00
|
|
|
virtual ~Mumlib();
|
2015-10-25 14:40:16 +01:00
|
|
|
|
|
|
|
void connect(string host, int port, string user, string password);
|
|
|
|
|
|
|
|
void disconnect();
|
|
|
|
|
|
|
|
void run();
|
|
|
|
|
|
|
|
ConnectionState getConnectionState();
|
|
|
|
|
2018-03-28 05:37:59 +02:00
|
|
|
int getChannelId();
|
|
|
|
|
2018-04-20 06:43:27 +02:00
|
|
|
vector<MumbleUser> getListAllUser();
|
2018-04-18 07:43:52 +02:00
|
|
|
|
2018-04-20 06:43:27 +02:00
|
|
|
vector<MumbleChannel> getListAllChannel();
|
2018-04-18 07:43:52 +02:00
|
|
|
|
2015-10-25 14:40:16 +01:00
|
|
|
void sendAudioData(int16_t *pcmData, int pcmLength);
|
|
|
|
|
2018-03-20 05:09:25 +01:00
|
|
|
void sendAudioDataTarget(int targetId, int16_t *pcmData, int pcmLength);
|
|
|
|
|
2015-10-30 02:15:02 +01:00
|
|
|
void sendTextMessage(std::string message);
|
|
|
|
|
2015-12-14 02:36:25 +01:00
|
|
|
void joinChannel(int channelId);
|
2015-11-30 20:24:54 +01:00
|
|
|
|
2018-04-18 07:43:52 +02:00
|
|
|
void joinChannel(std::string channelName);
|
|
|
|
|
2019-01-25 09:06:18 +01:00
|
|
|
void sendVoiceTarget(int targetId, mumlib::VoiceTargetType type, int sessionId);
|
2018-03-20 05:09:25 +01:00
|
|
|
|
2019-01-25 09:06:18 +01:00
|
|
|
void sendVoiceTarget(int targetId, mumlib::VoiceTargetType type, std::string name, int &error);
|
2018-04-18 07:43:52 +02:00
|
|
|
|
2018-03-20 05:09:25 +01:00
|
|
|
void sendUserState(mumlib::UserState state, bool val);
|
|
|
|
|
|
|
|
void sendUserState(mumlib::UserState state, std::string value);
|
2018-04-18 07:43:52 +02:00
|
|
|
|
2015-10-25 14:40:16 +01:00
|
|
|
private:
|
|
|
|
_Mumlib_Private *impl;
|
2018-04-18 07:43:52 +02:00
|
|
|
|
2018-04-20 06:43:27 +02:00
|
|
|
int getChannelIdBy(std::string channelName);
|
|
|
|
|
|
|
|
int getUserIdBy(std::string userName);
|
2019-01-25 09:06:18 +01:00
|
|
|
|
|
|
|
bool isSessionIdValid(int sessionId);
|
|
|
|
|
|
|
|
bool isChannelIdValid(int channelId);
|
2015-10-25 14:40:16 +01:00
|
|
|
};
|
2015-11-30 20:24:54 +01:00
|
|
|
}
|