MumbleCommunicator.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef MUMSI_MUMBLECOMMUNICATOR_HPP
  2. #define MUMSI_MUMBLECOMMUNICATOR_HPP
  3. #include "ISamplesBuffer.hpp"
  4. #include <mumlib.hpp>
  5. #include <string>
  6. #include <stdexcept>
  7. #include <log4cpp/Category.hh>
  8. #include <sndfile.hh>
  9. #include <thread>
  10. namespace mumble {
  11. class Exception : public std::runtime_error {
  12. public:
  13. Exception(const char *message) : std::runtime_error(message) { }
  14. };
  15. class MumlibCallback;
  16. class MumbleCommunicator {
  17. public:
  18. MumbleCommunicator(
  19. boost::asio::io_service &ioService,
  20. ISamplesBuffer &samplesBuffer,
  21. std::string user,
  22. std::string password,
  23. std::string host,
  24. int port = 0);
  25. ~MumbleCommunicator();
  26. // void senderThreadFunction();
  27. //void receiveAudioFrameCallback(uint8_t *audio_data, uint32_t audio_data_size);
  28. void sendAudioFrame(int16_t *samples, int length);
  29. public:
  30. boost::asio::io_service &ioService;
  31. log4cpp::Category &logger;
  32. ISamplesBuffer &samplesBuffer;
  33. std::shared_ptr<mumlib::Mumlib> mum;
  34. std::unique_ptr<std::thread> senderThread;
  35. SndfileHandle fileHandle;
  36. std::unique_ptr<MumlibCallback> callback;
  37. bool quit;
  38. friend class MumlibCallback;
  39. };
  40. }
  41. #endif //MUMSI_MUMBLECOMMUNICATOR_HPP