mumlib/include/mumlib.hpp

77 lines
1.9 KiB
C++
Raw Normal View History

2015-10-25 14:40:16 +01:00
#pragma once
#include "mumlib/Callback.hpp"
#include <boost/asio.hpp>
#include <boost/noncopyable.hpp>
#include <string>
#include <mumlib/enums.hpp>
namespace mumlib {
constexpr int DEFAULT_OPUS_ENCODER_BITRATE = 16000;
2018-03-28 05:37:59 +02:00
constexpr int DEFAULT_OPUS_SAMPLE_RATE = 48000;
constexpr int DEFAULT_OPUS_NUM_CHANNELS = 1;
2015-10-25 14:40:16 +01:00
using namespace std;
using namespace boost::asio;
class MumlibException : public runtime_error {
public:
MumlibException(string message) : runtime_error(message) { }
};
struct MumlibConfiguration {
int opusEncoderBitrate = DEFAULT_OPUS_ENCODER_BITRATE;
2018-03-28 05:37:59 +02:00
int opusSampleRate = DEFAULT_OPUS_SAMPLE_RATE;
int opusChannels = DEFAULT_OPUS_NUM_CHANNELS;
// additional fields will be added in the future
};
2015-10-25 14:40:16 +01:00
struct _Mumlib_Private;
class Mumlib : boost::noncopyable {
public:
2018-03-28 05:37:59 +02:00
explicit Mumlib(Callback &callback);
2015-10-25 14:40:16 +01:00
2015-10-27 23:31:45 +01:00
Mumlib(Callback &callback, io_service &ioService);
2015-10-25 14:40:16 +01:00
Mumlib(Callback &callback, MumlibConfiguration &configuration);
Mumlib(Callback &callback, io_service &ioService, MumlibConfiguration &configuration);
virtual ~Mumlib();
2015-10-25 14:40:16 +01:00
void connect(string host, int port, string user, string password);
void disconnect();
2018-03-28 05:37:59 +02:00
void reconnect();
2015-10-25 14:40:16 +01:00
void run();
ConnectionState getConnectionState();
2018-03-28 05:37:59 +02:00
int getChannelId();
2015-10-25 14:40:16 +01:00
void sendAudioData(int16_t *pcmData, int pcmLength);
void sendAudioDataTarget(int targetId, int16_t *pcmData, int pcmLength);
2015-10-30 02:15:02 +01:00
void sendTextMessage(std::string message);
void joinChannel(int channelId);
void sendVoiceTarget(int targetId, int channelId);
void sendUserState(mumlib::UserState state, bool val);
void sendUserState(mumlib::UserState state, std::string value);
2015-10-25 14:40:16 +01:00
private:
_Mumlib_Private *impl;
};
}