Complete callbacks.
This commit is contained in:
parent
a54a35265b
commit
58fee46c13
@ -8,6 +8,8 @@ namespace mumlib {
|
|||||||
|
|
||||||
constexpr int SAMPLE_RATE = 48000;
|
constexpr int SAMPLE_RATE = 48000;
|
||||||
|
|
||||||
|
class MumlibException;
|
||||||
|
|
||||||
class AudioException : public MumlibException {
|
class AudioException : public MumlibException {
|
||||||
public:
|
public:
|
||||||
AudioException(string message) : MumlibException(message) { }
|
AudioException(string message) : MumlibException(message) { }
|
||||||
|
@ -10,7 +10,7 @@ namespace mumlib {
|
|||||||
|
|
||||||
class Callback {
|
class Callback {
|
||||||
public:
|
public:
|
||||||
virtual void version_callback(
|
virtual void version(
|
||||||
uint16_t major,
|
uint16_t major,
|
||||||
uint8_t minor,
|
uint8_t minor,
|
||||||
uint8_t patch,
|
uint8_t patch,
|
||||||
@ -18,23 +18,23 @@ namespace mumlib {
|
|||||||
string os,
|
string os,
|
||||||
string os_version) { };
|
string os_version) { };
|
||||||
|
|
||||||
virtual void audio_callback(
|
virtual void audio(
|
||||||
uint8_t *pcm_data,
|
int16_t *pcm_data,
|
||||||
uint32_t pcm_data_size) { };
|
uint32_t pcm_data_size) { };
|
||||||
|
|
||||||
virtual void unsupported_audio_callback(
|
virtual void unsupportedAudio(
|
||||||
uint8_t *encoded_audio_data,
|
uint8_t *encoded_audio_data,
|
||||||
uint32_t encoded_audio_data_size) { };
|
uint32_t encoded_audio_data_size) { };
|
||||||
|
|
||||||
virtual void serversync_callback(
|
virtual void serverSync(
|
||||||
string welcome_text,
|
string welcome_text,
|
||||||
int32_t session,
|
int32_t session,
|
||||||
int32_t max_bandwidth,
|
int32_t max_bandwidth,
|
||||||
int64_t permissions) { };
|
int64_t permissions) { };
|
||||||
|
|
||||||
virtual void channelremove_callback(uint32_t channel_id) { };
|
virtual void channelRemove(uint32_t channel_id) { };
|
||||||
|
|
||||||
virtual void channelstate_callback(
|
virtual void channelState(
|
||||||
string name,
|
string name,
|
||||||
int32_t channel_id,
|
int32_t channel_id,
|
||||||
int32_t parent,
|
int32_t parent,
|
||||||
@ -45,13 +45,13 @@ namespace mumlib {
|
|||||||
bool temporary,
|
bool temporary,
|
||||||
int32_t position) { };
|
int32_t position) { };
|
||||||
|
|
||||||
virtual void userremove_callback(
|
virtual void userRemove(
|
||||||
uint32_t session,
|
uint32_t session,
|
||||||
int32_t actor,
|
int32_t actor,
|
||||||
string reason,
|
string reason,
|
||||||
bool ban) { };
|
bool ban) { };
|
||||||
|
|
||||||
virtual void userstate_callback(
|
virtual void userState(
|
||||||
int32_t session,
|
int32_t session,
|
||||||
int32_t actor,
|
int32_t actor,
|
||||||
string name,
|
string name,
|
||||||
@ -66,8 +66,8 @@ namespace mumlib {
|
|||||||
int32_t priority_speaker,
|
int32_t priority_speaker,
|
||||||
int32_t recording) { };
|
int32_t recording) { };
|
||||||
|
|
||||||
virtual void banlist_callback(
|
virtual void banList(
|
||||||
uint8_t *ip_data,
|
const uint8_t *ip_data,
|
||||||
uint32_t ip_data_size,
|
uint32_t ip_data_size,
|
||||||
uint32_t mask,
|
uint32_t mask,
|
||||||
string name,
|
string name,
|
||||||
@ -76,17 +76,14 @@ namespace mumlib {
|
|||||||
string start,
|
string start,
|
||||||
int32_t duration) { };
|
int32_t duration) { };
|
||||||
|
|
||||||
virtual void textmessage_callback(
|
virtual void textMessage(
|
||||||
uint32_t actor,
|
uint32_t actor,
|
||||||
uint32_t n_session,
|
std::vector<uint32_t> session,
|
||||||
uint32_t *session,
|
std::vector<uint32_t> channel_id,
|
||||||
uint32_t n_channel_id,
|
std::vector<uint32_t> tree_id,
|
||||||
uint32_t *channel_id,
|
|
||||||
uint32_t n_tree_id,
|
|
||||||
uint32_t *tree_id,
|
|
||||||
string message) { };
|
string message) { };
|
||||||
|
|
||||||
virtual void permissiondenied_callback(
|
virtual void permissionDenied(
|
||||||
int32_t permission,
|
int32_t permission,
|
||||||
int32_t channel_id,
|
int32_t channel_id,
|
||||||
int32_t session,
|
int32_t session,
|
||||||
@ -94,64 +91,48 @@ namespace mumlib {
|
|||||||
int32_t deny_type,
|
int32_t deny_type,
|
||||||
string name) { };
|
string name) { };
|
||||||
|
|
||||||
virtual void acl_callback() { };
|
virtual void queryUsers(
|
||||||
|
|
||||||
virtual void queryusers_callback(
|
|
||||||
uint32_t n_ids,
|
uint32_t n_ids,
|
||||||
uint32_t *ids,
|
uint32_t *ids,
|
||||||
uint32_t n_names,
|
uint32_t n_names,
|
||||||
string *names) { };
|
string *names) { };
|
||||||
|
|
||||||
virtual void cryptsetup_callback(
|
virtual void contextActionModify(
|
||||||
uint32_t key_size,
|
|
||||||
uint8_t *key,
|
|
||||||
uint32_t client_nonce_size,
|
|
||||||
uint8_t *client_nonce,
|
|
||||||
uint32_t server_nonce_size,
|
|
||||||
uint8_t *server_nonce) { };
|
|
||||||
|
|
||||||
virtual void contextactionmodify_callback(
|
|
||||||
string action,
|
string action,
|
||||||
string text,
|
string text,
|
||||||
uint32_t m_context,
|
uint32_t m_context,
|
||||||
uint32_t operation) { };
|
uint32_t operation) { };
|
||||||
|
|
||||||
virtual void contextaction_callback(
|
virtual void contextAction(
|
||||||
int32_t session,
|
int32_t session,
|
||||||
int32_t channel_id,
|
int32_t channel_id,
|
||||||
string action) { };
|
string action) { };
|
||||||
|
|
||||||
virtual void userlist_callback(
|
virtual void userList(
|
||||||
uint32_t user_id,
|
uint32_t user_id,
|
||||||
string name,
|
string name,
|
||||||
string last_seen,
|
string last_seen,
|
||||||
int32_t last_channel) { };
|
int32_t last_channel) { };
|
||||||
|
|
||||||
virtual void voicetarget_callback() { };
|
virtual void permissionQuery(
|
||||||
|
|
||||||
virtual void permissionquery_callback(
|
|
||||||
int32_t channel_id,
|
int32_t channel_id,
|
||||||
uint32_t permissions,
|
uint32_t permissions,
|
||||||
int32_t flush) { };
|
int32_t flush) { };
|
||||||
|
|
||||||
virtual void codecversion_callback(
|
virtual void codecVersion(
|
||||||
int32_t alpha,
|
int32_t alpha,
|
||||||
int32_t beta,
|
int32_t beta,
|
||||||
uint32_t prefer_alpha,
|
uint32_t prefer_alpha,
|
||||||
int32_t opus) { };
|
int32_t opus) { };
|
||||||
|
|
||||||
virtual void userstats_callback() { };
|
virtual void serverConfig(
|
||||||
|
|
||||||
virtual void requestblob_callback() { };
|
|
||||||
|
|
||||||
virtual void serverconfig_callback(
|
|
||||||
uint32_t max_bandwidth,
|
uint32_t max_bandwidth,
|
||||||
string welcome_text,
|
string welcome_text,
|
||||||
uint32_t allow_html,
|
uint32_t allow_html,
|
||||||
uint32_t message_length,
|
uint32_t message_length,
|
||||||
uint32_t image_message_length) { };
|
uint32_t image_message_length) { };
|
||||||
|
|
||||||
virtual void suggestconfig_callback(
|
virtual void suggestConfig(
|
||||||
uint32_t version,
|
uint32_t version,
|
||||||
uint32_t positional,
|
uint32_t positional,
|
||||||
uint32_t push_to_talk) { };
|
uint32_t push_to_talk) { };
|
||||||
@ -166,7 +147,7 @@ namespace mumlib {
|
|||||||
|
|
||||||
~BasicCallback();
|
~BasicCallback();
|
||||||
|
|
||||||
virtual void version_callback(
|
virtual void version(
|
||||||
uint16_t major,
|
uint16_t major,
|
||||||
uint8_t minor,
|
uint8_t minor,
|
||||||
uint8_t patch,
|
uint8_t patch,
|
||||||
@ -174,23 +155,23 @@ namespace mumlib {
|
|||||||
string os,
|
string os,
|
||||||
string os_version);
|
string os_version);
|
||||||
|
|
||||||
virtual void audio_callback(
|
virtual void audio(
|
||||||
uint8_t *pcm_data,
|
int16_t *pcm_data,
|
||||||
uint32_t pcm_data_size);
|
uint32_t pcm_data_size);
|
||||||
|
|
||||||
virtual void unsupported_audio_callback(
|
virtual void unsupportedAudio(
|
||||||
uint8_t *encoded_audio_data,
|
uint8_t *encoded_audio_data,
|
||||||
uint32_t encoded_audio_data_size);
|
uint32_t encoded_audio_data_size);
|
||||||
|
|
||||||
virtual void serversync_callback(
|
virtual void serverSync(
|
||||||
string welcome_text,
|
string welcome_text,
|
||||||
int32_t session,
|
int32_t session,
|
||||||
int32_t max_bandwidth,
|
int32_t max_bandwidth,
|
||||||
int64_t permissions);
|
int64_t permissions);
|
||||||
|
|
||||||
virtual void channelremove_callback(uint32_t channel_id);
|
virtual void channelRemove(uint32_t channel_id);
|
||||||
|
|
||||||
virtual void channelstate_callback(
|
virtual void channelState(
|
||||||
string name,
|
string name,
|
||||||
int32_t channel_id,
|
int32_t channel_id,
|
||||||
int32_t parent,
|
int32_t parent,
|
||||||
@ -201,13 +182,13 @@ namespace mumlib {
|
|||||||
bool temporary,
|
bool temporary,
|
||||||
int32_t position);
|
int32_t position);
|
||||||
|
|
||||||
virtual void userremove_callback(
|
virtual void userRemove(
|
||||||
uint32_t session,
|
uint32_t session,
|
||||||
int32_t actor,
|
int32_t actor,
|
||||||
string reason,
|
string reason,
|
||||||
bool ban);
|
bool ban);
|
||||||
|
|
||||||
virtual void userstate_callback(
|
virtual void userState(
|
||||||
int32_t session,
|
int32_t session,
|
||||||
int32_t actor,
|
int32_t actor,
|
||||||
string name,
|
string name,
|
||||||
@ -222,8 +203,8 @@ namespace mumlib {
|
|||||||
int32_t priority_speaker,
|
int32_t priority_speaker,
|
||||||
int32_t recording);
|
int32_t recording);
|
||||||
|
|
||||||
virtual void banlist_callback(
|
virtual void banList(
|
||||||
uint8_t *ip_data,
|
const uint8_t *ip_data,
|
||||||
uint32_t ip_data_size,
|
uint32_t ip_data_size,
|
||||||
uint32_t mask,
|
uint32_t mask,
|
||||||
string name,
|
string name,
|
||||||
@ -232,17 +213,14 @@ namespace mumlib {
|
|||||||
string start,
|
string start,
|
||||||
int32_t duration);
|
int32_t duration);
|
||||||
|
|
||||||
virtual void textmessage_callback(
|
virtual void textMessage(
|
||||||
uint32_t actor,
|
uint32_t actor,
|
||||||
uint32_t n_session,
|
std::vector<uint32_t> session,
|
||||||
uint32_t *session,
|
std::vector<uint32_t> channel_id,
|
||||||
uint32_t n_channel_id,
|
std::vector<uint32_t> tree_id,
|
||||||
uint32_t *channel_id,
|
|
||||||
uint32_t n_tree_id,
|
|
||||||
uint32_t *tree_id,
|
|
||||||
string message);
|
string message);
|
||||||
|
|
||||||
virtual void permissiondenied_callback(
|
virtual void permissionDenied(
|
||||||
int32_t permission,
|
int32_t permission,
|
||||||
int32_t channel_id,
|
int32_t channel_id,
|
||||||
int32_t session,
|
int32_t session,
|
||||||
@ -250,64 +228,48 @@ namespace mumlib {
|
|||||||
int32_t deny_type,
|
int32_t deny_type,
|
||||||
string name);
|
string name);
|
||||||
|
|
||||||
virtual void acl_callback();
|
virtual void queryUsers(
|
||||||
|
|
||||||
virtual void queryusers_callback(
|
|
||||||
uint32_t n_ids,
|
uint32_t n_ids,
|
||||||
uint32_t *ids,
|
uint32_t *ids,
|
||||||
uint32_t n_names,
|
uint32_t n_names,
|
||||||
string *names);
|
string *names);
|
||||||
|
|
||||||
virtual void cryptsetup_callback(
|
virtual void contextActionModify(
|
||||||
uint32_t key_size,
|
|
||||||
uint8_t *key,
|
|
||||||
uint32_t client_nonce_size,
|
|
||||||
uint8_t *client_nonce,
|
|
||||||
uint32_t server_nonce_size,
|
|
||||||
uint8_t *server_nonce);
|
|
||||||
|
|
||||||
virtual void contextactionmodify_callback(
|
|
||||||
string action,
|
string action,
|
||||||
string text,
|
string text,
|
||||||
uint32_t m_context,
|
uint32_t m_context,
|
||||||
uint32_t operation);
|
uint32_t operation);
|
||||||
|
|
||||||
virtual void contextaction_callback(
|
virtual void contextAction(
|
||||||
int32_t session,
|
int32_t session,
|
||||||
int32_t channel_id,
|
int32_t channel_id,
|
||||||
string action);
|
string action);
|
||||||
|
|
||||||
virtual void userlist_callback(
|
virtual void userList(
|
||||||
uint32_t user_id,
|
uint32_t user_id,
|
||||||
string name,
|
string name,
|
||||||
string last_seen,
|
string last_seen,
|
||||||
int32_t last_channel);
|
int32_t last_channel);
|
||||||
|
|
||||||
virtual void voicetarget_callback();
|
virtual void permissionQuery(
|
||||||
|
|
||||||
virtual void permissionquery_callback(
|
|
||||||
int32_t channel_id,
|
int32_t channel_id,
|
||||||
uint32_t permissions,
|
uint32_t permissions,
|
||||||
int32_t flush);
|
int32_t flush);
|
||||||
|
|
||||||
virtual void codecversion_callback(
|
virtual void codecVersion(
|
||||||
int32_t alpha,
|
int32_t alpha,
|
||||||
int32_t beta,
|
int32_t beta,
|
||||||
uint32_t prefer_alpha,
|
uint32_t prefer_alpha,
|
||||||
int32_t opus);
|
int32_t opus);
|
||||||
|
|
||||||
virtual void userstats_callback();
|
virtual void serverConfig(
|
||||||
|
|
||||||
virtual void requestblob_callback();
|
|
||||||
|
|
||||||
virtual void serverconfig_callback(
|
|
||||||
uint32_t max_bandwidth,
|
uint32_t max_bandwidth,
|
||||||
string welcome_text,
|
string welcome_text,
|
||||||
uint32_t allow_html,
|
uint32_t allow_html,
|
||||||
uint32_t message_length,
|
uint32_t message_length,
|
||||||
uint32_t image_message_length);
|
uint32_t image_message_length);
|
||||||
|
|
||||||
virtual void suggestconfig_callback(
|
virtual void suggestConfig(
|
||||||
uint32_t version,
|
uint32_t version,
|
||||||
uint32_t positional,
|
uint32_t positional,
|
||||||
uint32_t push_to_talk);
|
uint32_t push_to_talk);
|
||||||
|
@ -31,7 +31,7 @@ int main(int argc, char *argv[]) {
|
|||||||
log4cpp::Appender *appender1 = new log4cpp::OstreamAppender("console", &std::cout);
|
log4cpp::Appender *appender1 = new log4cpp::OstreamAppender("console", &std::cout);
|
||||||
appender1->setLayout(new log4cpp::BasicLayout());
|
appender1->setLayout(new log4cpp::BasicLayout());
|
||||||
log4cpp::Category &logger = log4cpp::Category::getRoot();
|
log4cpp::Category &logger = log4cpp::Category::getRoot();
|
||||||
logger.setPriority(log4cpp::Priority::WARN);
|
logger.setPriority(log4cpp::Priority::DEBUG);
|
||||||
logger.addAppender(appender1);
|
logger.addAppender(appender1);
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
mumlib::Audio::Audio()
|
mumlib::Audio::Audio()
|
||||||
:
|
:
|
||||||
logger(log4cpp::Category::getInstance("Mumlib.Audio")),
|
logger(log4cpp::Category::getInstance("mumlib.Audio")),
|
||||||
opusDecoder(nullptr),
|
opusDecoder(nullptr),
|
||||||
opusEncoder(nullptr),
|
opusEncoder(nullptr),
|
||||||
outgoingSequenceNumber(1) {
|
outgoingSequenceNumber(1) {
|
||||||
|
195
src/Callback.cpp
195
src/Callback.cpp
@ -9,10 +9,11 @@ using namespace mumlib;
|
|||||||
namespace mumlib {
|
namespace mumlib {
|
||||||
struct _BasicCallback_Private : boost::noncopyable {
|
struct _BasicCallback_Private : boost::noncopyable {
|
||||||
public:
|
public:
|
||||||
_BasicCallback_Private() : logger(log4cpp::Category::getInstance("BasicCallback")) { }
|
_BasicCallback_Private() : logger(log4cpp::Category::getInstance("mumlib.BasicCallback")) { }
|
||||||
|
|
||||||
log4cpp::Category &logger;
|
log4cpp::Category &logger;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mumlib::BasicCallback::BasicCallback() {
|
mumlib::BasicCallback::BasicCallback() {
|
||||||
@ -23,160 +24,102 @@ mumlib::BasicCallback::~BasicCallback() {
|
|||||||
delete impl;
|
delete impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mumlib::BasicCallback::version_callback(
|
void mumlib::BasicCallback::version(
|
||||||
uint16_t major,
|
uint16_t major,
|
||||||
uint8_t minor,
|
uint8_t minor,
|
||||||
uint8_t patch,
|
uint8_t patch,
|
||||||
string release,
|
string release,
|
||||||
string os,
|
string os,
|
||||||
string os_version) {
|
string os_version) {
|
||||||
impl->logger.debug("Version Callback: v%d.%d.%d. %s/%s/%s\n", major, minor, patch, release.c_str(), os.c_str(),
|
impl->logger.debug("version: v%d.%d.%d. %s/%s/%s\n", major, minor, patch, release.c_str(), os.c_str(),
|
||||||
os_version.c_str());
|
os_version.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void mumlib::BasicCallback::audio_callback(
|
void mumlib::BasicCallback::audio(
|
||||||
uint8_t *pcm_data,
|
int16_t *pcmData,
|
||||||
uint32_t pcm_data_size) {
|
uint32_t pcm_data_size) {
|
||||||
impl->logger.debug("Received %d bytes of raw PCM data.", pcm_data_size);
|
impl->logger.debug("audio: %d bytes of raw PCM data.", pcm_data_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mumlib::BasicCallback::unsupported_audio_callback(
|
void BasicCallback::unsupportedAudio(uint8_t *encoded_audio_data, uint32_t encoded_audio_data_size) {
|
||||||
uint8_t *encoded_audio_data,
|
impl->logger.debug("unsupportedAudio: received %d bytes of encoded data.", encoded_audio_data_size);
|
||||||
uint32_t encoded_audio_data_size) {
|
|
||||||
impl->logger.debug("Received %d bytes of encoded audio data.", encoded_audio_data_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mumlib::BasicCallback::serversync_callback(
|
void BasicCallback::serverSync(string welcome_text, int32_t session, int32_t max_bandwidth, int64_t permissions) {
|
||||||
string welcome_text,
|
impl->logger.debug("serverSync: text: %s, session: %d, max bandwidth: %d, permissions: %d", welcome_text.c_str(),
|
||||||
int32_t session,
|
session,
|
||||||
int32_t max_bandwidth,
|
|
||||||
int64_t permissions) {
|
|
||||||
impl->logger.debug("Text: %s, session: %d, max bandwidth: %d, permissions: %d", welcome_text.c_str(), session,
|
|
||||||
max_bandwidth, permissions);
|
max_bandwidth, permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mumlib::BasicCallback::channelremove_callback(uint32_t channel_id) { }
|
void BasicCallback::channelRemove(uint32_t channel_id) {
|
||||||
|
impl->logger.debug("channelRemove: %d", channel_id);
|
||||||
void mumlib::BasicCallback::channelstate_callback(
|
|
||||||
string name,
|
|
||||||
int32_t channel_id,
|
|
||||||
int32_t parent,
|
|
||||||
string description,
|
|
||||||
vector<uint32_t> links,
|
|
||||||
vector<uint32_t> inks_add,
|
|
||||||
vector<uint32_t> links_remove,
|
|
||||||
bool temporary,
|
|
||||||
int32_t position) {
|
|
||||||
impl->logger.debug("Obtained channel state %d: %s, %s", channel_id, name.c_str(), description.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mumlib::BasicCallback::userremove_callback(
|
void BasicCallback::channelState(string name, int32_t channel_id, int32_t parent, string description,
|
||||||
uint32_t session,
|
vector<uint32_t> links, vector<uint32_t> inks_add, vector<uint32_t> links_remove,
|
||||||
int32_t actor,
|
bool temporary, int32_t position) {
|
||||||
string reason,
|
impl->logger.debug("channelState: %d: %s, %s", channel_id, name.c_str(), description.c_str());
|
||||||
bool ban) { }
|
}
|
||||||
|
|
||||||
void mumlib::BasicCallback::userstate_callback(
|
void BasicCallback::userRemove(uint32_t session, int32_t actor, string reason, bool ban) {
|
||||||
int32_t session,
|
impl->logger.debug("userRemove: session: %d, actor: %d, reason: %s, ban: %d.", session, actor, reason.c_str(), ban);
|
||||||
int32_t actor,
|
}
|
||||||
string name,
|
|
||||||
int32_t user_id,
|
|
||||||
int32_t channel_id,
|
|
||||||
int32_t mute,
|
|
||||||
int32_t deaf,
|
|
||||||
int32_t suppress,
|
|
||||||
int32_t self_mute,
|
|
||||||
int32_t self_deaf,
|
|
||||||
string comment,
|
|
||||||
int32_t priority_speaker,
|
|
||||||
int32_t recording) { }
|
|
||||||
|
|
||||||
void mumlib::BasicCallback::banlist_callback(
|
void BasicCallback::userState(int32_t session, int32_t actor, string name, int32_t user_id, int32_t channel_id,
|
||||||
uint8_t *ip_data,
|
int32_t mute, int32_t deaf, int32_t suppress, int32_t self_mute, int32_t self_deaf,
|
||||||
uint32_t ip_data_size,
|
string comment, int32_t priority_speaker, int32_t recording) {
|
||||||
uint32_t mask,
|
impl->logger.debug("userState: %s: mute: %d, deaf: %d, suppress: %d, self mute: %d, self deaf: %d",
|
||||||
string name,
|
name.c_str(), mute, deaf, suppress, self_mute, self_deaf);
|
||||||
string hash,
|
}
|
||||||
string reason,
|
|
||||||
string start,
|
|
||||||
int32_t duration) { }
|
|
||||||
|
|
||||||
void mumlib::BasicCallback::textmessage_callback(
|
void BasicCallback::banList(const uint8_t *ip_data, uint32_t ip_data_size, uint32_t mask, string name, string hash,
|
||||||
|
string reason, string start, int32_t duration) {
|
||||||
|
impl->logger.debug("banList: %s, hash: %s, reason: %s", name.c_str(), hash.c_str(), reason.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasicCallback::textMessage(
|
||||||
uint32_t actor,
|
uint32_t actor,
|
||||||
uint32_t n_session,
|
std::vector<uint32_t> session,
|
||||||
uint32_t *session,
|
std::vector<uint32_t> channel_id,
|
||||||
uint32_t n_channel_id,
|
std::vector<uint32_t> tree_id,
|
||||||
uint32_t *channel_id,
|
string message) {
|
||||||
uint32_t n_tree_id,
|
impl->logger.debug("textMessage: %d: %s", actor, message.c_str());
|
||||||
uint32_t *tree_id,
|
}
|
||||||
string message) { }
|
|
||||||
|
|
||||||
void mumlib::BasicCallback::permissiondenied_callback(
|
void BasicCallback::permissionDenied(int32_t permission, int32_t channel_id, int32_t session, string reason,
|
||||||
int32_t permission,
|
int32_t deny_type, string name) {
|
||||||
int32_t channel_id,
|
impl->logger.debug("permissionDenied: %s %s", name.c_str(), reason.c_str());
|
||||||
int32_t session,
|
}
|
||||||
string reason,
|
|
||||||
int32_t deny_type,
|
|
||||||
string name) { }
|
|
||||||
|
|
||||||
void mumlib::BasicCallback::acl_callback() { }
|
void BasicCallback::queryUsers(uint32_t n_ids, uint32_t *ids, uint32_t n_names, string *names) {
|
||||||
|
impl->logger.debug("queryUsers: %d users", n_names); //todo make it more high-level
|
||||||
|
}
|
||||||
|
|
||||||
void mumlib::BasicCallback::queryusers_callback(
|
void BasicCallback::contextActionModify(string action, string text, uint32_t m_context, uint32_t operation) {
|
||||||
uint32_t n_ids,
|
impl->logger.debug("contextActionModify: ");
|
||||||
uint32_t *ids,
|
}
|
||||||
uint32_t n_names,
|
|
||||||
string *names) { }
|
|
||||||
|
|
||||||
void mumlib::BasicCallback::cryptsetup_callback(
|
void BasicCallback::contextAction(int32_t session, int32_t channel_id, string action) {
|
||||||
uint32_t key_size,
|
impl->logger.debug("contextAction.");
|
||||||
uint8_t *key,
|
}
|
||||||
uint32_t client_nonce_size,
|
|
||||||
uint8_t *client_nonce,
|
|
||||||
uint32_t server_nonce_size,
|
|
||||||
uint8_t *server_nonce) { }
|
|
||||||
|
|
||||||
void mumlib::BasicCallback::contextactionmodify_callback(
|
void BasicCallback::userList(uint32_t user_id, string name, string last_seen, int32_t last_channel) {
|
||||||
string action,
|
impl->logger.debug("userList.");
|
||||||
string text,
|
}
|
||||||
uint32_t m_context,
|
|
||||||
uint32_t operation) { }
|
|
||||||
|
|
||||||
void mumlib::BasicCallback::contextaction_callback(
|
void BasicCallback::permissionQuery(int32_t channel_id, uint32_t permissions, int32_t flush) {
|
||||||
int32_t session,
|
impl->logger.debug("permissionQuery.");
|
||||||
int32_t channel_id,
|
}
|
||||||
string action) { }
|
|
||||||
|
|
||||||
void mumlib::BasicCallback::userlist_callback(
|
void BasicCallback::codecVersion(int32_t alpha, int32_t beta, uint32_t prefer_alpha, int32_t opus) {
|
||||||
uint32_t user_id,
|
impl->logger.debug("codecVersion.");
|
||||||
string name,
|
}
|
||||||
string last_seen,
|
|
||||||
int32_t last_channel) { }
|
|
||||||
|
|
||||||
void mumlib::BasicCallback::voicetarget_callback() { }
|
void BasicCallback::serverConfig(uint32_t max_bandwidth, string welcome_text, uint32_t allow_html,
|
||||||
|
uint32_t message_length, uint32_t image_message_length) {
|
||||||
|
impl->logger.debug("serverConfig: %s", welcome_text.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
void mumlib::BasicCallback::permissionquery_callback(
|
void BasicCallback::suggestConfig(uint32_t version, uint32_t positional, uint32_t push_to_talk) {
|
||||||
int32_t channel_id,
|
impl->logger.debug("suggestConfig.");
|
||||||
uint32_t permissions,
|
}
|
||||||
int32_t flush) { }
|
|
||||||
|
|
||||||
void mumlib::BasicCallback::codecversion_callback(
|
|
||||||
int32_t alpha,
|
|
||||||
int32_t beta,
|
|
||||||
uint32_t prefer_alpha,
|
|
||||||
int32_t opus) { }
|
|
||||||
|
|
||||||
void mumlib::BasicCallback::userstats_callback() { }
|
|
||||||
|
|
||||||
void mumlib::BasicCallback::requestblob_callback() { }
|
|
||||||
|
|
||||||
void mumlib::BasicCallback::serverconfig_callback(
|
|
||||||
uint32_t max_bandwidth,
|
|
||||||
string welcome_text,
|
|
||||||
uint32_t allow_html,
|
|
||||||
uint32_t message_length,
|
|
||||||
uint32_t image_message_length) { }
|
|
||||||
|
|
||||||
void mumlib::BasicCallback::suggestconfig_callback(
|
|
||||||
uint32_t version,
|
|
||||||
uint32_t positional,
|
|
||||||
uint32_t push_to_talk) { }
|
|
||||||
|
@ -30,7 +30,7 @@ mumlib::Transport::Transport(
|
|||||||
mumlib::ProcessControlMessageFunction processMessageFunc,
|
mumlib::ProcessControlMessageFunction processMessageFunc,
|
||||||
ProcessEncodedAudioPacketFunction processEncodedAudioPacketFunction,
|
ProcessEncodedAudioPacketFunction processEncodedAudioPacketFunction,
|
||||||
bool noUdp) :
|
bool noUdp) :
|
||||||
logger(log4cpp::Category::getInstance("Mumlib.Transport")),
|
logger(log4cpp::Category::getInstance("mumlib.Transport")),
|
||||||
ioService(ioService),
|
ioService(ioService),
|
||||||
processMessageFunction(processMessageFunc),
|
processMessageFunction(processMessageFunc),
|
||||||
processEncodedAudioPacketFunction(processEncodedAudioPacketFunction),
|
processEncodedAudioPacketFunction(processEncodedAudioPacketFunction),
|
||||||
@ -154,7 +154,7 @@ void mumlib::Transport::doReceiveUdp() {
|
|||||||
|
|
||||||
if (udpActive == false) {
|
if (udpActive == false) {
|
||||||
udpActive = true;
|
udpActive = true;
|
||||||
logger.info("UDP is up.");
|
logger.notice("UDP is up.");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t plainBuffer[1024];
|
uint8_t plainBuffer[1024];
|
||||||
@ -376,12 +376,6 @@ void mumlib::Transport::processMessageInternal(MessageType messageType, uint8_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MessageType::VOICETARGET: {
|
|
||||||
MumbleProto::VoiceTarget voiceTarget;
|
|
||||||
voiceTarget.ParseFromArray(buffer, length);
|
|
||||||
logger.warn("VoiceTarget Message: I don't think the server ever sends this structure....");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default: {
|
default: {
|
||||||
logger.debug("Calling external ProcessControlMessageFunction.");
|
logger.debug("Calling external ProcessControlMessageFunction.");
|
||||||
processMessageFunction(messageType, buffer, length);
|
processMessageFunction(messageType, buffer, length);
|
||||||
|
172
src/mumlib.cpp
172
src/mumlib.cpp
@ -1,11 +1,11 @@
|
|||||||
#include "mumlib.hpp"
|
|
||||||
|
|
||||||
#include "mumlib/CryptState.hpp"
|
#include "mumlib/CryptState.hpp"
|
||||||
#include "mumlib/VarInt.hpp"
|
#include "mumlib/VarInt.hpp"
|
||||||
#include "mumlib/enums.hpp"
|
#include "mumlib/enums.hpp"
|
||||||
#include "mumlib/Transport.hpp"
|
#include "mumlib/Transport.hpp"
|
||||||
#include "mumlib/Audio.hpp"
|
#include "mumlib/Audio.hpp"
|
||||||
|
|
||||||
|
#include "mumlib.hpp"
|
||||||
|
|
||||||
#include <boost/asio/ssl.hpp>
|
#include <boost/asio/ssl.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <log4cpp/Category.hh>
|
#include <log4cpp/Category.hh>
|
||||||
@ -35,7 +35,7 @@ namespace mumlib {
|
|||||||
case MessageType::VERSION: {
|
case MessageType::VERSION: {
|
||||||
MumbleProto::Version version;
|
MumbleProto::Version version;
|
||||||
version.ParseFromArray(buffer, length);
|
version.ParseFromArray(buffer, length);
|
||||||
callback->version_callback(
|
callback->version(
|
||||||
version.version() >> 16,
|
version.version() >> 16,
|
||||||
version.version() >> 8 & 0xff,
|
version.version() >> 8 & 0xff,
|
||||||
version.version() & 0xff,
|
version.version() & 0xff,
|
||||||
@ -47,7 +47,7 @@ namespace mumlib {
|
|||||||
case MessageType::SERVERSYNC: {
|
case MessageType::SERVERSYNC: {
|
||||||
MumbleProto::ServerSync serverSync;
|
MumbleProto::ServerSync serverSync;
|
||||||
serverSync.ParseFromArray(buffer, length);
|
serverSync.ParseFromArray(buffer, length);
|
||||||
callback->serversync_callback(
|
callback->serverSync(
|
||||||
serverSync.welcome_text(),
|
serverSync.welcome_text(),
|
||||||
serverSync.session(),
|
serverSync.session(),
|
||||||
serverSync.max_bandwidth(),
|
serverSync.max_bandwidth(),
|
||||||
@ -58,7 +58,7 @@ namespace mumlib {
|
|||||||
case MessageType::CHANNELREMOVE: {
|
case MessageType::CHANNELREMOVE: {
|
||||||
MumbleProto::ChannelRemove channelRemove;
|
MumbleProto::ChannelRemove channelRemove;
|
||||||
channelRemove.ParseFromArray(buffer, length);
|
channelRemove.ParseFromArray(buffer, length);
|
||||||
callback->channelremove_callback(channelRemove.channel_id());
|
callback->channelRemove(channelRemove.channel_id());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MessageType::CHANNELSTATE: {
|
case MessageType::CHANNELSTATE: {
|
||||||
@ -83,7 +83,7 @@ namespace mumlib {
|
|||||||
std::copy(channelState.links_remove().begin(), channelState.links_remove().end(),
|
std::copy(channelState.links_remove().begin(), channelState.links_remove().end(),
|
||||||
links_remove.begin());
|
links_remove.begin());
|
||||||
|
|
||||||
callback->channelstate_callback(
|
callback->channelState(
|
||||||
channelState.name(),
|
channelState.name(),
|
||||||
channel_id,
|
channel_id,
|
||||||
parent,
|
parent,
|
||||||
@ -104,7 +104,7 @@ namespace mumlib {
|
|||||||
bool ban = user_remove.has_ban() ? user_remove.ban()
|
bool ban = user_remove.has_ban() ? user_remove.ban()
|
||||||
: false; //todo make sure it's correct to assume it's false
|
: false; //todo make sure it's correct to assume it's false
|
||||||
|
|
||||||
callback->userremove_callback(
|
callback->userRemove(
|
||||||
user_remove.session(),
|
user_remove.session(),
|
||||||
actor,
|
actor,
|
||||||
user_remove.reason(),
|
user_remove.reason(),
|
||||||
@ -112,64 +112,150 @@ namespace mumlib {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MessageType::USERSTATE: // 9
|
case MessageType::USERSTATE: {
|
||||||
// return MessageType::private_process_userstate(context, message, message_size);
|
MumbleProto::UserState userState;
|
||||||
|
userState.ParseFromArray(buffer, length);
|
||||||
|
|
||||||
|
// There are far too many things in this structure. Culling to the ones that are probably important
|
||||||
|
int32_t session = userState.has_session() ? userState.session() : -1;
|
||||||
|
int32_t actor = userState.has_actor() ? userState.actor() : -1;
|
||||||
|
int32_t user_id = userState.has_user_id() ? userState.user_id() : -1;
|
||||||
|
int32_t channel_id = userState.has_channel_id() ? userState.channel_id() : -1;
|
||||||
|
int32_t mute = userState.has_mute() ? userState.mute() : -1;
|
||||||
|
int32_t deaf = userState.has_deaf() ? userState.deaf() : -1;
|
||||||
|
int32_t suppress = userState.has_suppress() ? userState.suppress() : -1;
|
||||||
|
int32_t self_mute = userState.has_self_mute() ? userState.self_mute() : -1;
|
||||||
|
int32_t self_deaf = userState.has_self_deaf() ? userState.self_deaf() : -1;
|
||||||
|
int32_t priority_speaker = userState.has_priority_speaker() ? userState.priority_speaker() : -1;
|
||||||
|
int32_t recording = userState.has_recording() ? userState.recording() : -1;
|
||||||
|
|
||||||
|
callback->userState(session,
|
||||||
|
actor,
|
||||||
|
userState.name(),
|
||||||
|
user_id,
|
||||||
|
channel_id,
|
||||||
|
mute,
|
||||||
|
deaf,
|
||||||
|
suppress,
|
||||||
|
self_mute,
|
||||||
|
self_deaf,
|
||||||
|
userState.comment(),
|
||||||
|
priority_speaker,
|
||||||
|
recording);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MessageType::BANLIST: // 10
|
case MessageType::BANLIST: {
|
||||||
// return MessageType::private_process_banlist(context, message, message_size);
|
MumbleProto::BanList ban_list;
|
||||||
|
ban_list.ParseFromArray(buffer, length);
|
||||||
|
for (int i = 0; i < ban_list.bans_size(); i++) {
|
||||||
|
auto ban = ban_list.bans(i);
|
||||||
|
|
||||||
|
const uint8_t *ip_data = reinterpret_cast<const uint8_t *>(ban.address().c_str());
|
||||||
|
uint32_t ip_data_size = ban.address().size();
|
||||||
|
int32_t duration = ban.has_duration() ? ban.duration() : -1;
|
||||||
|
|
||||||
|
callback->banList(
|
||||||
|
ip_data,
|
||||||
|
ip_data_size,
|
||||||
|
ban.mask(),
|
||||||
|
ban.name(),
|
||||||
|
ban.hash(),
|
||||||
|
ban.reason(),
|
||||||
|
ban.start(),
|
||||||
|
duration);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MessageType::TEXTMESSAGE: // 11
|
case MessageType::TEXTMESSAGE: {
|
||||||
// return MessageType::private_process_textmessage(context, message, message_size);
|
MumbleProto::TextMessage text_message;
|
||||||
|
text_message.ParseFromArray(buffer, length);
|
||||||
|
|
||||||
|
int32_t actor = text_message.has_actor() ? text_message.actor() : -1;
|
||||||
|
|
||||||
|
vector<uint32_t> sessions;
|
||||||
|
for (int i = 0; i < text_message.session_size(); ++i) {
|
||||||
|
sessions.push_back(text_message.session(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<uint32_t> channel_ids;
|
||||||
|
for (int i = 0; i < text_message.channel_id_size(); ++i) {
|
||||||
|
channel_ids.push_back(text_message.channel_id(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<uint32_t> tree_ids;
|
||||||
|
for (int i = 0; i < text_message.tree_id_size(); ++i) {
|
||||||
|
tree_ids.push_back(text_message.tree_id(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
callback->textMessage(actor, sessions, channel_ids, tree_ids, text_message.message());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MessageType::PERMISSIONDENIED: // 12
|
case MessageType::PERMISSIONDENIED: // 12
|
||||||
// return MessageType::private_process_permissiondenied(context, message, message_size);
|
logger->warn("PermissionDenied Message: support not implemented yet");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MessageType::ACL: // 13
|
case MessageType::ACL: // 13
|
||||||
// return MessageType::private_process_acl(context, message, message_size);
|
logger->warn("ACL Message: support not implemented yet.");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MessageType::QUERYUSERS: // 14
|
case MessageType::QUERYUSERS: // 14
|
||||||
// return MessageType::private_process_queryusers(context, message, message_size);
|
logger->warn("QueryUsers Message: support not implemented yet");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MessageType::CONTEXTACTIONMODIFY: // 16
|
case MessageType::CONTEXTACTIONMODIFY: // 16
|
||||||
// return MessageType::private_process_contextactionmodify(context, message, message_size);
|
logger->warn("ContextActionModify Message: support not implemented yet");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MessageType::CONTEXTACTION: // 17
|
case MessageType::CONTEXTACTION: // 17
|
||||||
// return MessageType::private_process_contextaction(context, message, message_size);
|
logger->warn("ContextAction Message: support not implemented yet");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MessageType::USERLIST: // 18
|
case MessageType::USERLIST: // 18
|
||||||
// return MessageType::private_process_userlist(context, message, message_size);
|
logger->warn("UserList Message: support not implemented yet");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MessageType::PERMISSIONQUERY: // 20
|
case MessageType::VOICETARGET:
|
||||||
// return MessageType::private_process_permission_query(context, message, message_size);
|
logger->warn("VoiceTarget Message: I don't think the server ever sends this structure.");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MessageType::CODECVERSION: // 21
|
case MessageType::PERMISSIONQUERY: {
|
||||||
// return MessageType::private_process_codecversion(context, message, message_size);
|
MumbleProto::PermissionQuery permissionQuery;
|
||||||
|
permissionQuery.ParseFromArray(buffer, length);
|
||||||
|
|
||||||
|
int32_t channel_id = permissionQuery.has_channel_id() ? permissionQuery.channel_id() : -1;
|
||||||
|
uint32_t permissions = permissionQuery.has_permissions() ? permissionQuery.permissions() : 0;
|
||||||
|
uint32_t flush = permissionQuery.has_flush() ? permissionQuery.flush() : -1;
|
||||||
|
|
||||||
|
callback->permissionQuery(channel_id, permissions, flush);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MessageType::USERSTATS: // 22
|
case MessageType::CODECVERSION: {
|
||||||
// return MessageType::private_process_userstats(context, message, message_size);
|
MumbleProto::CodecVersion codecVersion;
|
||||||
|
codecVersion.ParseFromArray(buffer, length);
|
||||||
|
|
||||||
|
int32_t alpha = codecVersion.alpha();
|
||||||
|
int32_t beta = codecVersion.beta();
|
||||||
|
uint32_t prefer_alpha = codecVersion.prefer_alpha();
|
||||||
|
int32_t opus = codecVersion.has_opus() ? codecVersion.opus() : 0;
|
||||||
|
|
||||||
|
callback->codecVersion(alpha, beta, prefer_alpha, opus);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MessageType::USERSTATS:
|
||||||
|
logger->warn("UserStats Message: support not implemented yet");
|
||||||
break;
|
break;
|
||||||
case MessageType::REQUESTBLOB: // 23
|
case MessageType::REQUESTBLOB: // 23
|
||||||
// return MessageType::private_process_requestblob(context, message, message_size);
|
logger->warn("RequestBlob Message: I don't think this is sent by the server.");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MessageType::SERVERCONFIG: // 24
|
case MessageType::SERVERCONFIG: {
|
||||||
// return MessageType::private_process_serverconfig(context, message, message_size);
|
MumbleProto::ServerConfig serverConfig;
|
||||||
|
serverConfig.ParseFromArray(buffer, length);
|
||||||
|
|
||||||
|
uint32_t max_bandwidth = serverConfig.has_max_bandwidth() ? serverConfig.max_bandwidth() : 0;
|
||||||
|
uint32_t allow_html = serverConfig.has_allow_html() ? serverConfig.allow_html() : 0;
|
||||||
|
uint32_t message_length = serverConfig.has_message_length() ? serverConfig.message_length() : 0;
|
||||||
|
uint32_t image_message_length = serverConfig.has_image_message_length()
|
||||||
|
? serverConfig.image_message_length() : 0;
|
||||||
|
|
||||||
|
callback->serverConfig(max_bandwidth, serverConfig.welcome_text(), allow_html, message_length,
|
||||||
|
image_message_length);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MessageType::SUGGESTCONFIG: // 25
|
case MessageType::SUGGESTCONFIG: // 25
|
||||||
// return MessageType::private_process_suggestconfig(context, message, message_size);
|
logger->warn("SuggestConfig Message: support not implemented yet");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw MumlibException("unknown message type: " + to_string(static_cast<int>(messageType)));
|
throw MumlibException("unknown message type: " + to_string(static_cast<int>(messageType)));
|
||||||
@ -179,8 +265,14 @@ namespace mumlib {
|
|||||||
|
|
||||||
bool processAudioPacket(AudioPacketType type, uint8_t *buffer, int length) {
|
bool processAudioPacket(AudioPacketType type, uint8_t *buffer, int length) {
|
||||||
logger->info("Got %d B of encoded audio data.", length);
|
logger->info("Got %d B of encoded audio data.", length);
|
||||||
int16_t pcmData[5000];
|
try {
|
||||||
audio->decodeAudioPacket(type, buffer, length, pcmData, 5000);
|
int16_t pcmData[5000];
|
||||||
|
int pcmDataLength = audio->decodeAudioPacket(type, buffer, length, pcmData, 5000);
|
||||||
|
callback->audio(pcmData, pcmDataLength);
|
||||||
|
} catch (mumlib::AudioException &exp) {
|
||||||
|
logger->warn("Audio decode error: %s, calling unsupportedAudio callback.", exp.what());
|
||||||
|
callback->unsupportedAudio(buffer, length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -192,7 +284,7 @@ namespace mumlib {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mumlib::Mumlib::Mumlib() : impl(new _Mumlib_Private) {
|
mumlib::Mumlib::Mumlib() : impl(new _Mumlib_Private) {
|
||||||
impl->logger = &(log4cpp::Category::getInstance("Mumlib.Mumlib"));
|
impl->logger = &(log4cpp::Category::getInstance("mumlib.Mumlib"));
|
||||||
impl->externalIoService = false;
|
impl->externalIoService = false;
|
||||||
impl->ioService = new io_service();
|
impl->ioService = new io_service();
|
||||||
impl->audio = new Audio();
|
impl->audio = new Audio();
|
||||||
|
Loading…
Reference in New Issue
Block a user