2017-01-19 08:24:43 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-01-19 08:24:43 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-01-19 08:24:43 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2019-09-13 06:06:02 +00:00
|
|
|
#include <QtCore/QTimer>
|
|
|
|
|
2017-01-19 08:24:43 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2017-05-03 11:36:39 +00:00
|
|
|
void Start();
|
|
|
|
void Finish();
|
2017-01-19 08:24:43 +00:00
|
|
|
|
2020-10-01 07:47:03 +00:00
|
|
|
class Instance final : public QObject {
|
2017-01-19 08:24:43 +00:00
|
|
|
public:
|
|
|
|
Instance();
|
2020-10-01 07:47:03 +00:00
|
|
|
~Instance();
|
2017-01-19 08:24:43 +00:00
|
|
|
|
|
|
|
void check();
|
2020-10-01 07:47:03 +00:00
|
|
|
[[nodiscard]] bool available() const {
|
2017-01-19 08:24:43 +00:00
|
|
|
return _available;
|
|
|
|
}
|
|
|
|
|
2020-10-01 07:47:03 +00:00
|
|
|
[[nodiscard]] rpl::producer<Update, rpl::empty_error> updated() const {
|
|
|
|
return _updates.events();
|
|
|
|
}
|
2017-01-19 08:24:43 +00:00
|
|
|
|
2020-10-12 19:30:14 +00:00
|
|
|
[[nodiscard]] rpl::producer<bool> startedChanges() const {
|
|
|
|
return _started.changes();
|
|
|
|
}
|
|
|
|
|
2017-01-19 08:24:43 +00:00
|
|
|
void start();
|
2020-10-01 07:47:03 +00:00
|
|
|
void stop(Fn<void(Result&&)> callback = nullptr);
|
2017-01-19 08:24:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
class Inner;
|
|
|
|
friend class Inner;
|
|
|
|
|
|
|
|
bool _available = false;
|
2020-10-12 19:30:14 +00:00
|
|
|
rpl::variable<bool> _started = false;;
|
2020-10-01 07:47:03 +00:00
|
|
|
rpl::event_stream<Update, rpl::empty_error> _updates;
|
2017-01-19 08:24:43 +00:00
|
|
|
QThread _thread;
|
2020-10-01 07:47:03 +00:00
|
|
|
std::unique_ptr<Inner> _inner;
|
2017-01-19 08:24:43 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-10-01 07:47:03 +00:00
|
|
|
[[nodiscard]] Instance *instance();
|
2017-01-19 08:24:43 +00:00
|
|
|
|
|
|
|
} // namespace Capture
|
|
|
|
} // namespace Media
|
|
|
|
|