mumlib.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include "mumlib/Callback.hpp"
  3. #include <boost/asio.hpp>
  4. #include <boost/noncopyable.hpp>
  5. #include <string>
  6. #include <mumlib/enums.hpp>
  7. namespace mumlib {
  8. constexpr int DEFAULT_OPUS_ENCODER_BITRATE = 16000;
  9. using namespace std;
  10. using namespace boost::asio;
  11. class MumlibException : public runtime_error {
  12. public:
  13. MumlibException(string message) : runtime_error(message) { }
  14. };
  15. struct MumlibConfiguration {
  16. int opusEncoderBitrate = DEFAULT_OPUS_ENCODER_BITRATE;
  17. // additional fields will be added in the future
  18. };
  19. struct _Mumlib_Private;
  20. class Mumlib : boost::noncopyable {
  21. public:
  22. Mumlib(Callback &callback);
  23. Mumlib(Callback &callback, io_service &ioService);
  24. Mumlib(Callback &callback, MumlibConfiguration &configuration);
  25. Mumlib(Callback &callback, io_service &ioService, MumlibConfiguration &configuration);
  26. virtual ~Mumlib();
  27. void connect(string host, int port, string user, string password);
  28. void disconnect();
  29. void run();
  30. ConnectionState getConnectionState();
  31. void sendAudioData(int16_t *pcmData, int pcmLength);
  32. void sendTextMessage(std::string message);
  33. void joinChannel(int channelId);
  34. private:
  35. _Mumlib_Private *impl;
  36. };
  37. }