From bd3f62c04402eb8a3766e6d34c0269c2a6369be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20S=C5=82omkowski?= Date: Mon, 18 Apr 2016 01:22:36 +0200 Subject: [PATCH] Add option to configure Opus encoder bitrate. #14 --- MumbleCommunicator.cpp | 13 ++++++------- MumbleCommunicator.hpp | 18 ++++++++++++------ config.ini.example | 1 + main.cpp | 12 +++++++----- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/MumbleCommunicator.cpp b/MumbleCommunicator.cpp index 55009a5..9a5c719 100644 --- a/MumbleCommunicator.cpp +++ b/MumbleCommunicator.cpp @@ -47,19 +47,18 @@ mumble::MumbleCommunicator::MumbleCommunicator(boost::asio::io_service &ioServic logger(log4cpp::Category::getInstance("MumbleCommunicator")) { } -void mumble::MumbleCommunicator::connect( - std::string user, - std::string password, - std::string host, - int port) { +void mumble::MumbleCommunicator::connect(MumbleCommunicatorConfig &config) { callback.reset(new MumlibCallback()); - mum.reset(new mumlib::Mumlib(*callback, ioService)); + mumConfig = mumlib::MumlibConfiguration(); + mumConfig.opusEncoderBitrate = config.opusEncoderBitrate; + + mum.reset(new mumlib::Mumlib(*callback, ioService, mumConfig)); callback->communicator = this; callback->mum = mum; - mum->connect(host, port, user, password); + mum->connect(config.host, config.port, config.user, config.password); } void mumble::MumbleCommunicator::sendPcmSamples(int16_t *samples, unsigned int length) { diff --git a/MumbleCommunicator.hpp b/MumbleCommunicator.hpp index 0b6be5b..be04a4b 100644 --- a/MumbleCommunicator.hpp +++ b/MumbleCommunicator.hpp @@ -17,16 +17,20 @@ namespace mumble { class MumlibCallback; + struct MumbleCommunicatorConfig { + std::string user; + std::string password; + std::string host; + int opusEncoderBitrate; + int port = 0; + }; + class MumbleCommunicator : boost::noncopyable { public: MumbleCommunicator( boost::asio::io_service &ioService); - void connect( - std::string user, - std::string password, - std::string host, - int port = 0); + void connect(MumbleCommunicatorConfig &config); virtual ~MumbleCommunicator(); @@ -50,11 +54,13 @@ namespace mumble { void joinChannel(int channel_id); - public: + private: boost::asio::io_service &ioService; log4cpp::Category &logger; + mumlib::MumlibConfiguration mumConfig; + std::shared_ptr mum; std::unique_ptr callback; diff --git a/config.ini.example b/config.ini.example index 34630ab..39b8f95 100644 --- a/config.ini.example +++ b/config.ini.example @@ -14,3 +14,4 @@ port = 64738 user = mumsi password = foobar channelNameExpression = +opusEncoderBitrate = 16000 \ No newline at end of file diff --git a/main.cpp b/main.cpp index f65e795..4624069 100644 --- a/main.cpp +++ b/main.cpp @@ -77,12 +77,14 @@ int main(int argc, char *argv[]) { &mumbleChannelJoiner, &mumbleCommunicator); + mumble::MumbleCommunicatorConfig mumbleConf; + mumbleConf.host = conf.getString("mumble.host"); + mumbleConf.port = conf.getInt("mumble.port"); + mumbleConf.user = conf.getString("mumble.user"); + mumbleConf.password = conf.getString("mumble.password"); + mumbleConf.opusEncoderBitrate = conf.getInt("mumble.opusEncoderBitrate"); - mumbleCommunicator.connect( - conf.getString("mumble.user"), - conf.getString("mumble.password"), - conf.getString("mumble.host"), - conf.getInt("mumble.port")); + mumbleCommunicator.connect(mumbleConf); pjsuaCommunicator.connect( conf.getString("sip.host"),