// // libtgvoip is free and unencumbered public domain software. // For more information, see http://unlicense.org or the UNLICENSE file // you should have received with this source code distribution. // #ifndef LIBTGVOIP_AUDIO_IO_CALLBACK #define LIBTGVOIP_AUDIO_IO_CALLBACK #include #include #include #include "AudioIO.h" #include "../tools/threading.h" namespace tgvoip { namespace audio { class AudioInputCallback : public AudioInput { public: AudioInputCallback(); virtual ~AudioInputCallback(); virtual void Start() override; virtual void Stop() override; void SetDataCallback(std::function c); private: void RunThread(); std::atomic running{false}; bool recording = false; Thread *thread; std::function dataCallback; }; class AudioOutputCallback : public AudioOutput { public: AudioOutputCallback(); virtual ~AudioOutputCallback(); virtual void Start() override; virtual void Stop() override; virtual bool IsPlaying() override; void SetDataCallback(std::function c); private: void RunThread(); std::atomic running{false}; bool playing = false; Thread *thread; std::function dataCallback; }; class AudioIOCallback : public AudioIO { public: AudioIOCallback(); virtual ~AudioIOCallback(); virtual std::shared_ptr GetInput() override; virtual std::shared_ptr GetOutput() override; private: std::shared_ptr input; std::shared_ptr output; }; } // namespace audio } // namespace tgvoip #endif /* LIBTGVOIP_AUDIO_IO_CALLBACK */