MumbleCommunicator.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include <sndfile.hh>
  12. namespace mumble {
  13. constexpr unsigned int SAMPLE_RATE = 48000;
  14. class Exception : public std::runtime_error {
  15. public:
  16. Exception(const char *message) : std::runtime_error(message) { }
  17. };
  18. class MumbleCommunicator : public AbstractCommunicator {
  19. public:
  20. MumbleCommunicator(
  21. SoundSampleQueue<SOUND_SAMPLE_TYPE> &inputQueue,
  22. SoundSampleQueue<SOUND_SAMPLE_TYPE> &outputQueue,
  23. std::string user,
  24. std::string password,
  25. std::string host,
  26. int port = 0);
  27. ~MumbleCommunicator();
  28. void loop();
  29. void receiveAudioFrameCallback(uint8_t *audio_data, uint32_t audio_data_size);
  30. private:
  31. log4cpp::Category &logger;
  32. mumble_struct *mumble;
  33. OpusDecoder *opusDecoder;
  34. OpusEncoder *opusEncoder;
  35. int outgoingAudioSequenceNumber;
  36. SndfileHandle fileHandle;
  37. };
  38. }
  39. #endif //MUMSI_MUMBLECOMMUNICATOR_HPP