2015-11-03 02:13:15 +01:00
|
|
|
#pragma once
|
|
|
|
|
2015-10-30 13:43:06 +01:00
|
|
|
#include <mumlib.hpp>
|
2015-09-28 23:25:12 +02:00
|
|
|
|
2015-11-04 01:22:59 +01:00
|
|
|
#include <log4cpp/Category.hh>
|
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
|
2015-09-28 23:25:12 +02:00
|
|
|
#include <string>
|
|
|
|
#include <stdexcept>
|
|
|
|
|
2017-05-24 22:38:45 +02:00
|
|
|
// 0 = mumble users connected at start; 1 = connect at dial-in
|
|
|
|
// TODO: fix mumlib::TransportException when this option is enabled
|
|
|
|
#define MUM_DELAYED_CONNECT 0
|
2017-05-20 18:17:08 +02:00
|
|
|
|
2015-09-28 23:25:12 +02:00
|
|
|
namespace mumble {
|
|
|
|
|
2017-05-20 18:17:08 +02:00
|
|
|
|
2015-09-28 23:25:12 +02:00
|
|
|
class Exception : public std::runtime_error {
|
|
|
|
public:
|
|
|
|
Exception(const char *message) : std::runtime_error(message) { }
|
|
|
|
};
|
|
|
|
|
2015-10-30 13:43:06 +01:00
|
|
|
class MumlibCallback;
|
|
|
|
|
2016-04-18 01:22:36 +02:00
|
|
|
struct MumbleCommunicatorConfig {
|
|
|
|
std::string user;
|
|
|
|
std::string password;
|
|
|
|
std::string host;
|
2017-05-28 21:16:46 +02:00
|
|
|
std::string cert_file;
|
|
|
|
std::string privkey_file;
|
2016-04-18 01:22:36 +02:00
|
|
|
int opusEncoderBitrate;
|
|
|
|
int port = 0;
|
2017-05-20 18:17:08 +02:00
|
|
|
bool autodeaf;
|
2017-05-24 22:38:45 +02:00
|
|
|
std::string comment;
|
|
|
|
int max_calls = 1;
|
|
|
|
std::string authchan; // config.ini: channelAuthExpression
|
|
|
|
};
|
|
|
|
|
|
|
|
// This is the subset that is of interest to us
|
|
|
|
struct MumbleUserState {
|
|
|
|
int32_t mute;
|
|
|
|
int32_t deaf;
|
|
|
|
int32_t suppress;
|
|
|
|
int32_t self_mute;
|
|
|
|
int32_t self_deaf;
|
|
|
|
int32_t priority_speaker;
|
|
|
|
int32_t recording;
|
2016-04-18 01:22:36 +02:00
|
|
|
};
|
|
|
|
|
2015-11-18 00:17:25 +01:00
|
|
|
class MumbleCommunicator : boost::noncopyable {
|
2015-09-28 23:25:12 +02:00
|
|
|
public:
|
2015-09-29 02:26:45 +02:00
|
|
|
MumbleCommunicator(
|
2015-11-03 02:13:15 +01:00
|
|
|
boost::asio::io_service &ioService);
|
|
|
|
|
2016-04-18 01:22:36 +02:00
|
|
|
void connect(MumbleCommunicatorConfig &config);
|
2017-05-24 22:38:45 +02:00
|
|
|
void onConnect();
|
|
|
|
void onDisconnect();
|
|
|
|
void onCallerAuth();
|
|
|
|
//void onCallerUnauth();
|
2015-09-28 23:25:12 +02:00
|
|
|
|
2015-11-18 00:17:25 +01:00
|
|
|
virtual ~MumbleCommunicator();
|
|
|
|
|
|
|
|
void sendPcmSamples(int16_t *samples, unsigned int length);
|
2015-09-28 23:25:12 +02:00
|
|
|
|
2015-11-18 00:17:25 +01:00
|
|
|
/**
|
|
|
|
* This callback is called when communicator has received samples.
|
2017-05-24 22:38:45 +02:00
|
|
|
* Arguments: call ID, session ID, sequence number, PCM samples, length of samples
|
2015-11-18 00:17:25 +01:00
|
|
|
*/
|
2017-05-24 22:38:45 +02:00
|
|
|
std::function<void(int, int, int, int16_t *, int)> onIncomingPcmSamples;
|
2015-10-16 22:41:37 +02:00
|
|
|
|
2015-11-30 23:24:41 +01:00
|
|
|
/**
|
|
|
|
* This callback is called when a channel state message (e.g. Channel
|
|
|
|
* information) is received. Arguments: channel_id, name
|
|
|
|
*/
|
|
|
|
std::function<void(std::string, int)> onIncomingChannelState;
|
|
|
|
|
|
|
|
std::function<void()> onServerSync;
|
|
|
|
|
2017-05-24 22:38:45 +02:00
|
|
|
std::function<void()> onUserState;
|
|
|
|
|
2015-11-04 00:53:52 +01:00
|
|
|
void sendTextMessage(std::string message);
|
|
|
|
|
2015-11-30 23:24:41 +01:00
|
|
|
void joinChannel(int channel_id);
|
|
|
|
|
2017-05-24 22:38:45 +02:00
|
|
|
void sendUserState(mumlib::UserState field, bool val);
|
|
|
|
|
2017-05-27 18:19:37 +02:00
|
|
|
void sendUserState(mumlib::UserState field, std::string val);
|
|
|
|
|
2017-05-24 22:38:45 +02:00
|
|
|
MumbleUserState userState;
|
|
|
|
|
|
|
|
int callId;
|
2017-05-20 18:17:08 +02:00
|
|
|
|
2016-04-18 01:22:36 +02:00
|
|
|
private:
|
2015-10-30 13:43:06 +01:00
|
|
|
boost::asio::io_service &ioService;
|
2015-09-28 23:25:12 +02:00
|
|
|
|
2015-09-29 02:26:45 +02:00
|
|
|
log4cpp::Category &logger;
|
|
|
|
|
2017-05-20 18:17:08 +02:00
|
|
|
MumbleCommunicatorConfig mumbleConf;
|
|
|
|
|
2016-04-18 01:22:36 +02:00
|
|
|
mumlib::MumlibConfiguration mumConfig;
|
|
|
|
|
2015-10-30 13:43:06 +01:00
|
|
|
std::shared_ptr<mumlib::Mumlib> mum;
|
2015-09-29 02:26:45 +02:00
|
|
|
|
2015-10-30 13:43:06 +01:00
|
|
|
std::unique_ptr<MumlibCallback> callback;
|
|
|
|
|
|
|
|
friend class MumlibCallback;
|
2017-05-20 18:17:08 +02:00
|
|
|
|
2015-09-28 23:25:12 +02:00
|
|
|
};
|
|
|
|
}
|