2015-09-28 23:25:12 +02:00
|
|
|
#include <cstring>
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
#include "MumbleCommunicator.hpp"
|
|
|
|
|
2015-10-30 13:43:06 +01:00
|
|
|
namespace mumble {
|
|
|
|
class MumlibCallback : public mumlib::BasicCallback {
|
|
|
|
public:
|
|
|
|
std::shared_ptr<mumlib::Mumlib> mum;
|
|
|
|
MumbleCommunicator *communicator;
|
|
|
|
|
|
|
|
virtual void audio(
|
|
|
|
int16_t *pcm_data,
|
|
|
|
uint32_t pcm_data_size) {
|
|
|
|
communicator->samplesBuffer.pushSamples(pcm_data, pcm_data_size);
|
|
|
|
}
|
|
|
|
};
|
2015-09-29 02:26:45 +02:00
|
|
|
}
|
2015-09-28 23:25:12 +02:00
|
|
|
|
2015-09-29 02:26:45 +02:00
|
|
|
mumble::MumbleCommunicator::MumbleCommunicator(
|
2015-10-30 13:43:06 +01:00
|
|
|
boost::asio::io_service &ioService,
|
2015-10-16 22:41:37 +02:00
|
|
|
ISamplesBuffer &samplesBuffer,
|
2015-09-29 02:26:45 +02:00
|
|
|
std::string user,
|
|
|
|
std::string password,
|
|
|
|
std::string host,
|
2015-10-30 13:43:06 +01:00
|
|
|
int port) : ioService(ioService),
|
|
|
|
samplesBuffer(samplesBuffer),
|
2015-09-29 02:26:45 +02:00
|
|
|
logger(log4cpp::Category::getInstance("MumbleCommunicator")) {
|
2015-09-28 23:25:12 +02:00
|
|
|
|
2015-10-16 22:41:37 +02:00
|
|
|
quit = false;
|
|
|
|
|
2015-10-30 13:43:06 +01:00
|
|
|
callback.reset(new MumlibCallback());
|
2015-09-28 23:25:12 +02:00
|
|
|
|
2015-10-30 13:43:06 +01:00
|
|
|
mum.reset(new mumlib::Mumlib(*callback, ioService));
|
|
|
|
callback->communicator = this;
|
|
|
|
callback->mum = mum;
|
2015-09-28 23:25:12 +02:00
|
|
|
|
2015-10-30 13:43:06 +01:00
|
|
|
mum->connect(host, port, user, password);
|
2015-09-28 23:25:12 +02:00
|
|
|
}
|
|
|
|
|
2015-11-02 23:41:49 +01:00
|
|
|
void mumble::MumbleCommunicator::sendAudioFrame(int16_t *samples, int length) {
|
|
|
|
mum->sendAudioData(samples, length);
|
|
|
|
}
|
|
|
|
|
2015-09-28 23:25:12 +02:00
|
|
|
mumble::MumbleCommunicator::~MumbleCommunicator() {
|
2015-10-30 13:43:06 +01:00
|
|
|
mum->disconnect();
|
|
|
|
}
|