2015-09-28 23:25:12 +02:00
|
|
|
#ifndef MUMSI_MUMBLECOMMUNICATOR_HPP
|
|
|
|
#define MUMSI_MUMBLECOMMUNICATOR_HPP
|
|
|
|
|
2015-10-16 22:41:37 +02:00
|
|
|
#include "ISamplesBuffer.hpp"
|
2015-09-29 02:26:45 +02:00
|
|
|
|
2015-09-28 23:25:12 +02:00
|
|
|
extern "C" {
|
|
|
|
#include "libmumble.h"
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <opus.h>
|
2015-09-29 02:26:45 +02:00
|
|
|
#include <log4cpp/Category.hh>
|
2015-10-04 22:30:10 +02:00
|
|
|
#include <sndfile.hh>
|
2015-10-16 22:41:37 +02:00
|
|
|
#include <thread>
|
2015-09-28 23:25:12 +02:00
|
|
|
|
|
|
|
namespace mumble {
|
|
|
|
|
|
|
|
constexpr unsigned int SAMPLE_RATE = 48000;
|
|
|
|
|
|
|
|
class Exception : public std::runtime_error {
|
|
|
|
public:
|
|
|
|
Exception(const char *message) : std::runtime_error(message) { }
|
|
|
|
};
|
|
|
|
|
2015-10-16 22:41:37 +02:00
|
|
|
class MumbleCommunicator {
|
2015-09-28 23:25:12 +02:00
|
|
|
public:
|
2015-09-29 02:26:45 +02:00
|
|
|
MumbleCommunicator(
|
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,
|
|
|
|
int port = 0);
|
2015-09-28 23:25:12 +02:00
|
|
|
|
|
|
|
~MumbleCommunicator();
|
|
|
|
|
|
|
|
void loop();
|
|
|
|
|
2015-10-16 22:41:37 +02:00
|
|
|
void senderThreadFunction();
|
|
|
|
|
2015-09-28 23:25:12 +02:00
|
|
|
void receiveAudioFrameCallback(uint8_t *audio_data, uint32_t audio_data_size);
|
|
|
|
|
|
|
|
private:
|
2015-09-29 02:26:45 +02:00
|
|
|
log4cpp::Category &logger;
|
|
|
|
|
2015-10-16 22:41:37 +02:00
|
|
|
ISamplesBuffer &samplesBuffer;
|
|
|
|
|
|
|
|
std::unique_ptr<std::thread> senderThread;
|
|
|
|
|
2015-09-28 23:25:12 +02:00
|
|
|
mumble_struct *mumble;
|
2015-09-29 02:26:45 +02:00
|
|
|
OpusDecoder *opusDecoder;
|
|
|
|
OpusEncoder *opusEncoder;
|
|
|
|
|
|
|
|
int outgoingAudioSequenceNumber;
|
2015-10-04 22:30:10 +02:00
|
|
|
|
|
|
|
SndfileHandle fileHandle;
|
2015-10-16 22:41:37 +02:00
|
|
|
|
|
|
|
bool quit;
|
2015-09-28 23:25:12 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //MUMSI_MUMBLECOMMUNICATOR_HPP
|