mumsi/main.cpp

57 lines
1.5 KiB
C++
Raw Normal View History

2015-09-29 02:26:45 +02:00
#include "log4cpp/Category.hh"
#include "log4cpp/FileAppender.hh"
#include "log4cpp/OstreamAppender.hh"
#include "PjsuaCommunicator.hpp"
#include "MumbleCommunicator.hpp"
2015-07-13 18:14:35 +02:00
2015-10-17 22:27:37 +02:00
#include "Configuration.hpp"
2015-07-13 18:14:35 +02:00
int main(int argc, char *argv[]) {
2015-09-29 02:26:45 +02:00
log4cpp::Appender *appender1 = new log4cpp::OstreamAppender("console", &std::cout);
appender1->setLayout(new log4cpp::BasicLayout());
log4cpp::Category &logger = log4cpp::Category::getRoot();
2015-10-17 22:27:37 +02:00
logger.setPriority(log4cpp::Priority::DEBUG);
2015-09-29 02:26:45 +02:00
logger.addAppender(appender1);
2015-10-17 22:27:37 +02:00
if (argc == 1) {
logger.crit("No configuration file provided. Use %s {config file}", argv[0]);
return 1;
}
config::Configuration conf(argv[1]);
2015-10-16 22:41:37 +02:00
2015-10-30 13:43:06 +01:00
boost::asio::io_service ioService;
2015-11-02 23:41:49 +01:00
sip::PjsuaCommunicator pjsuaCommunicator;
2015-07-13 18:14:35 +02:00
2015-09-29 02:26:45 +02:00
mumble::MumbleCommunicator mumbleCommunicator(
2015-10-30 13:43:06 +01:00
ioService,
2015-10-16 22:41:37 +02:00
pjsuaCommunicator,
2015-10-17 22:27:37 +02:00
conf.getString("mumble.user"),
conf.getString("mumble.password"),
conf.getString("mumble.host"),
conf.getInt("mumble.port"));
2015-11-02 23:41:49 +01:00
using namespace std::placeholders;
pjsuaCommunicator.onIncomingSamples = std::bind(
&mumble::MumbleCommunicator::sendAudioFrame,
&mumbleCommunicator,
_1, _2);
pjsuaCommunicator.connect(
conf.getString("sip.host"),
conf.getString("sip.user"),
conf.getString("sip.password"),
conf.getInt("sip.port"));
2015-09-29 02:26:45 +02:00
logger.info("Application started.");
2015-07-13 18:14:35 +02:00
2015-10-30 13:43:06 +01:00
ioService.run();
2015-10-16 22:41:37 +02:00
return 0;
2015-07-13 18:14:35 +02:00
}