2018-10-03 14:34:43 +00:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
2019-02-06 18:22:38 +00:00
|
|
|
#include "AudioIO.h"
|
2018-10-03 14:34:43 +00:00
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
#include "../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<void(int16_t*, size_t)> c);
|
|
|
|
private:
|
2019-02-06 18:22:38 +00:00
|
|
|
void RunThread();
|
2018-10-03 14:34:43 +00:00
|
|
|
bool running=false;
|
|
|
|
bool recording=false;
|
|
|
|
Thread* thread;
|
|
|
|
std::function<void(int16_t*, size_t)> 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<void(int16_t*, size_t)> c);
|
|
|
|
private:
|
2019-02-06 18:22:38 +00:00
|
|
|
void RunThread();
|
2018-10-03 14:34:43 +00:00
|
|
|
bool running=false;
|
|
|
|
bool playing=false;
|
|
|
|
Thread* thread;
|
|
|
|
std::function<void(int16_t*, size_t)> dataCallback;
|
|
|
|
};
|
|
|
|
|
|
|
|
class AudioIOCallback : public AudioIO{
|
|
|
|
public:
|
|
|
|
AudioIOCallback();
|
|
|
|
virtual ~AudioIOCallback();
|
|
|
|
virtual AudioInput* GetInput() override;
|
|
|
|
virtual AudioOutput* GetOutput() override;
|
|
|
|
private:
|
|
|
|
AudioInputCallback* input;
|
|
|
|
AudioOutputCallback* output;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* LIBTGVOIP_AUDIO_IO_CALLBACK */
|