MumbleCommunicator.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef MUMSI_MUMBLECOMMUNICATOR_HPP
  2. #define MUMSI_MUMBLECOMMUNICATOR_HPP
  3. #include "AbstractCommunicator.hpp"
  4. extern "C" {
  5. #include "libmumble.h"
  6. }
  7. #include <string>
  8. #include <stdexcept>
  9. #include <opus.h>
  10. #include <log4cpp/Category.hh>
  11. namespace mumble {
  12. constexpr unsigned int SAMPLE_RATE = 48000;
  13. class Exception : public std::runtime_error {
  14. public:
  15. Exception(const char *message) : std::runtime_error(message) { }
  16. };
  17. class MumbleCommunicator : public AbstractCommunicator {
  18. public:
  19. MumbleCommunicator(
  20. SoundSampleQueue<SOUND_SAMPLE_TYPE> &inputQueue,
  21. SoundSampleQueue<SOUND_SAMPLE_TYPE> &outputQueue,
  22. std::string user,
  23. std::string password,
  24. std::string host,
  25. int port = 0);
  26. ~MumbleCommunicator();
  27. void loop();
  28. void receiveAudioFrameCallback(uint8_t *audio_data, uint32_t audio_data_size);
  29. private:
  30. log4cpp::Category &logger;
  31. mumble_struct *mumble;
  32. OpusDecoder *opusDecoder;
  33. OpusEncoder *opusEncoder;
  34. int outgoingAudioSequenceNumber;
  35. };
  36. }
  37. #endif //MUMSI_MUMBLECOMMUNICATOR_HPP