Add autodeaf so users in other groups see status
This causes the user to be self_mute and self_deaf when there is no SIP call active. Users in other Mumble groups can then see whether the user is active without moving to same group. Note: this needs the updated mumlib with the self_mute and self_deaf methods
This commit is contained in:
parent
c04ead2ff5
commit
f112cca475
@ -51,6 +51,8 @@ void mumble::MumbleCommunicator::connect(MumbleCommunicatorConfig &config) {
|
|||||||
|
|
||||||
callback.reset(new MumlibCallback());
|
callback.reset(new MumlibCallback());
|
||||||
|
|
||||||
|
mumbleConf = config;
|
||||||
|
|
||||||
mumConfig = mumlib::MumlibConfiguration();
|
mumConfig = mumlib::MumlibConfiguration();
|
||||||
mumConfig.opusEncoderBitrate = config.opusEncoderBitrate;
|
mumConfig.opusEncoderBitrate = config.opusEncoderBitrate;
|
||||||
|
|
||||||
@ -59,6 +61,7 @@ void mumble::MumbleCommunicator::connect(MumbleCommunicatorConfig &config) {
|
|||||||
callback->mum = mum;
|
callback->mum = mum;
|
||||||
|
|
||||||
mum->connect(config.host, config.port, config.user, config.password);
|
mum->connect(config.host, config.port, config.user, config.password);
|
||||||
|
mum->self_deaf(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mumble::MumbleCommunicator::sendPcmSamples(int16_t *samples, unsigned int length) {
|
void mumble::MumbleCommunicator::sendPcmSamples(int16_t *samples, unsigned int length) {
|
||||||
@ -75,4 +78,15 @@ void mumble::MumbleCommunicator::sendTextMessage(std::string message) {
|
|||||||
|
|
||||||
void mumble::MumbleCommunicator::joinChannel(int channel_id) {
|
void mumble::MumbleCommunicator::joinChannel(int channel_id) {
|
||||||
mum->joinChannel(channel_id);
|
mum->joinChannel(channel_id);
|
||||||
|
if ( mumbleConf.autodeaf ) {
|
||||||
|
mum->self_mute(1);
|
||||||
|
mum->self_deaf(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mumble::MumbleCommunicator::mutedeaf(int status) {
|
||||||
|
if ( mumbleConf.autodeaf ) {
|
||||||
|
mum->self_mute(status);
|
||||||
|
mum->self_deaf(status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
|
||||||
namespace mumble {
|
namespace mumble {
|
||||||
|
|
||||||
|
|
||||||
class Exception : public std::runtime_error {
|
class Exception : public std::runtime_error {
|
||||||
public:
|
public:
|
||||||
Exception(const char *message) : std::runtime_error(message) { }
|
Exception(const char *message) : std::runtime_error(message) { }
|
||||||
@ -23,6 +25,7 @@ namespace mumble {
|
|||||||
std::string host;
|
std::string host;
|
||||||
int opusEncoderBitrate;
|
int opusEncoderBitrate;
|
||||||
int port = 0;
|
int port = 0;
|
||||||
|
bool autodeaf;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MumbleCommunicator : boost::noncopyable {
|
class MumbleCommunicator : boost::noncopyable {
|
||||||
@ -54,11 +57,15 @@ namespace mumble {
|
|||||||
|
|
||||||
void joinChannel(int channel_id);
|
void joinChannel(int channel_id);
|
||||||
|
|
||||||
|
void mutedeaf(int status);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::asio::io_service &ioService;
|
boost::asio::io_service &ioService;
|
||||||
|
|
||||||
log4cpp::Category &logger;
|
log4cpp::Category &logger;
|
||||||
|
|
||||||
|
MumbleCommunicatorConfig mumbleConf;
|
||||||
|
|
||||||
mumlib::MumlibConfiguration mumConfig;
|
mumlib::MumlibConfiguration mumConfig;
|
||||||
|
|
||||||
std::shared_ptr<mumlib::Mumlib> mum;
|
std::shared_ptr<mumlib::Mumlib> mum;
|
||||||
@ -66,5 +73,6 @@ namespace mumble {
|
|||||||
std::unique_ptr<MumlibCallback> callback;
|
std::unique_ptr<MumlibCallback> callback;
|
||||||
|
|
||||||
friend class MumlibCallback;
|
friend class MumlibCallback;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,7 @@ namespace sip {
|
|||||||
|
|
||||||
communicator.logger.notice(msgText);
|
communicator.logger.notice(msgText);
|
||||||
communicator.onStateChange(msgText);
|
communicator.onStateChange(msgText);
|
||||||
|
communicator.onMuteDeafChange(0);
|
||||||
} else if (ci.state == PJSIP_INV_STATE_DISCONNECTED) {
|
} else if (ci.state == PJSIP_INV_STATE_DISCONNECTED) {
|
||||||
auto &acc = dynamic_cast<_Account &>(account);
|
auto &acc = dynamic_cast<_Account &>(account);
|
||||||
|
|
||||||
@ -154,6 +155,7 @@ namespace sip {
|
|||||||
|
|
||||||
communicator.logger.notice(msgText);
|
communicator.logger.notice(msgText);
|
||||||
communicator.onStateChange(msgText);
|
communicator.onStateChange(msgText);
|
||||||
|
communicator.onMuteDeafChange(1);
|
||||||
|
|
||||||
acc.available = true;
|
acc.available = true;
|
||||||
}
|
}
|
||||||
@ -320,4 +322,4 @@ void sip::PjsuaCommunicator::registerAccount(string host, string user, string pa
|
|||||||
logger.info("Registering account for URI: %s.", uri.c_str());
|
logger.info("Registering account for URI: %s.", uri.c_str());
|
||||||
account.reset(new _Account(*this));
|
account.reset(new _Account(*this));
|
||||||
account->create(accountConfig);
|
account->create(accountConfig);
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,8 @@ namespace sip {
|
|||||||
|
|
||||||
std::function<void(std::string)> onStateChange;
|
std::function<void(std::string)> onStateChange;
|
||||||
|
|
||||||
|
std::function<void(int)> onMuteDeafChange;
|
||||||
|
|
||||||
pj_status_t mediaPortGetFrame(pjmedia_port *port, pjmedia_frame *frame);
|
pj_status_t mediaPortGetFrame(pjmedia_port *port, pjmedia_frame *frame);
|
||||||
|
|
||||||
pj_status_t mediaPortPutFrame(pjmedia_port *port, pjmedia_frame *frame);
|
pj_status_t mediaPortPutFrame(pjmedia_port *port, pjmedia_frame *frame);
|
||||||
|
@ -23,6 +23,11 @@ user = mumsi
|
|||||||
password = foobar
|
password = foobar
|
||||||
channelNameExpression =
|
channelNameExpression =
|
||||||
|
|
||||||
|
# When here is no SIP connection, the mumble state is set to self_mute/self_deaf
|
||||||
|
# so the other users can easily see whether the SIP is connected even when not
|
||||||
|
# in the same group
|
||||||
|
autodeaf = 0
|
||||||
|
|
||||||
# Bitrate of Opus encoder in B/s
|
# Bitrate of Opus encoder in B/s
|
||||||
# Adjust it if you need to meet the specific bandwidth requirements of Murmur server
|
# Adjust it if you need to meet the specific bandwidth requirements of Murmur server
|
||||||
opusEncoderBitrate = 16000
|
opusEncoderBitrate = 16000
|
||||||
|
10
main.cpp
10
main.cpp
@ -64,6 +64,10 @@ int main(int argc, char *argv[]) {
|
|||||||
&mumble::MumbleCommunicator::sendTextMessage,
|
&mumble::MumbleCommunicator::sendTextMessage,
|
||||||
&mumbleCommunicator, _1);
|
&mumbleCommunicator, _1);
|
||||||
|
|
||||||
|
pjsuaCommunicator.onMuteDeafChange = std::bind(
|
||||||
|
&mumble::MumbleCommunicator::mutedeaf,
|
||||||
|
&mumbleCommunicator, _1);
|
||||||
|
|
||||||
mumbleCommunicator.onIncomingPcmSamples = std::bind(
|
mumbleCommunicator.onIncomingPcmSamples = std::bind(
|
||||||
&sip::PjsuaCommunicator::sendPcmSamples,
|
&sip::PjsuaCommunicator::sendPcmSamples,
|
||||||
&pjsuaCommunicator,
|
&pjsuaCommunicator,
|
||||||
@ -85,6 +89,12 @@ int main(int argc, char *argv[]) {
|
|||||||
mumbleConf.user = conf.getString("mumble.user");
|
mumbleConf.user = conf.getString("mumble.user");
|
||||||
mumbleConf.password = conf.getString("mumble.password");
|
mumbleConf.password = conf.getString("mumble.password");
|
||||||
mumbleConf.opusEncoderBitrate = conf.getInt("mumble.opusEncoderBitrate");
|
mumbleConf.opusEncoderBitrate = conf.getInt("mumble.opusEncoderBitrate");
|
||||||
|
/* default to 'false' if not found */
|
||||||
|
try {
|
||||||
|
mumbleConf.autodeaf = conf.getBool("mumble.autodeaf");
|
||||||
|
} catch (...) {
|
||||||
|
mumbleConf.autodeaf = false;
|
||||||
|
}
|
||||||
|
|
||||||
mumbleCommunicator.connect(mumbleConf);
|
mumbleCommunicator.connect(mumbleConf);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user