tdesktop/Telegram/SourceFiles/media/audio/media_audio_capture.h

64 lines
1.1 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include <QtCore/QTimer>
struct AVFrame;
namespace Media {
namespace Capture {
2020-10-01 07:47:03 +00:00
struct Update {
int samples = 0;
ushort level = 0;
};
struct Result {
QByteArray bytes;
VoiceWaveform waveform;
int samples = 0;
};
void Start();
void Finish();
2020-10-01 07:47:03 +00:00
class Instance final : public QObject {
public:
Instance();
2020-10-01 07:47:03 +00:00
~Instance();
void check();
2020-10-01 07:47:03 +00:00
[[nodiscard]] bool available() const {
return _available;
}
2020-10-01 07:47:03 +00:00
[[nodiscard]] rpl::producer<Update, rpl::empty_error> updated() const {
return _updates.events();
}
void start();
2020-10-01 07:47:03 +00:00
void stop(Fn<void(Result&&)> callback = nullptr);
private:
class Inner;
friend class Inner;
bool _available = false;
2020-10-01 07:47:03 +00:00
rpl::event_stream<Update, rpl::empty_error> _updates;
QThread _thread;
2020-10-01 07:47:03 +00:00
std::unique_ptr<Inner> _inner;
};
2020-10-01 07:47:03 +00:00
[[nodiscard]] Instance *instance();
} // namespace Capture
} // namespace Media