2016-07-05 17:44:02 +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.
|
2016-07-05 17:44:02 +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
|
2016-07-05 17:44:02 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2019-02-13 12:36:59 +00:00
|
|
|
#include "media/audio/media_audio.h"
|
|
|
|
#include "media/audio/media_child_ffmpeg_loader.h"
|
2016-07-05 17:44:02 +00:00
|
|
|
|
|
|
|
class AudioPlayerLoader;
|
|
|
|
class ChildFFMpegLoader;
|
2017-01-19 08:24:43 +00:00
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
namespace Player {
|
|
|
|
|
|
|
|
class Loaders : public QObject {
|
2016-07-05 17:44:02 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-01-19 08:24:43 +00:00
|
|
|
Loaders(QThread *thread);
|
2019-02-28 21:03:25 +00:00
|
|
|
void feedFromExternal(ExternalSoundPart &&part);
|
|
|
|
void forceToBufferExternal(const AudioMsgId &audioId);
|
2017-01-19 08:24:43 +00:00
|
|
|
~Loaders();
|
2016-07-05 17:44:02 +00:00
|
|
|
|
2021-03-03 18:22:42 +00:00
|
|
|
Q_SIGNALS:
|
2016-07-05 17:44:02 +00:00
|
|
|
void error(const AudioMsgId &audio);
|
|
|
|
void needToCheck();
|
|
|
|
|
2021-03-03 18:22:42 +00:00
|
|
|
public Q_SLOTS:
|
2016-07-05 17:44:02 +00:00
|
|
|
void onInit();
|
|
|
|
|
2017-12-10 08:52:38 +00:00
|
|
|
void onStart(const AudioMsgId &audio, qint64 positionMs);
|
2016-07-05 17:44:02 +00:00
|
|
|
void onLoad(const AudioMsgId &audio);
|
|
|
|
void onCancel(const AudioMsgId &audio);
|
|
|
|
|
|
|
|
private:
|
2023-03-08 09:31:58 +00:00
|
|
|
struct SetupLoaderResult {
|
|
|
|
AudioPlayerLoader *loader = nullptr;
|
|
|
|
float64 oldSpeed = 0.;
|
|
|
|
float64 newSpeed = 0.;
|
|
|
|
int64 fadeStartPosition = 0;
|
|
|
|
int64 position = 0;
|
|
|
|
int64 normalLength = 0;
|
|
|
|
int frequency = 0;
|
|
|
|
bool errorAtStart = false;
|
|
|
|
bool justStarted = false;
|
|
|
|
};
|
|
|
|
|
2017-04-06 16:49:42 +00:00
|
|
|
void videoSoundAdded();
|
2023-03-08 09:31:58 +00:00
|
|
|
[[nodiscard]] Mixer::Track::WithSpeed rebufferOnSpeedChange(
|
|
|
|
const SetupLoaderResult &setup);
|
|
|
|
|
|
|
|
void emitError(AudioMsgId::Type type);
|
|
|
|
AudioMsgId clear(AudioMsgId::Type type);
|
|
|
|
void setStoppedState(Mixer::Track *m, State state = State::Stopped);
|
|
|
|
|
|
|
|
void loadData(AudioMsgId audio, crl::time positionMs = 0);
|
|
|
|
[[nodiscard]] SetupLoaderResult setupLoader(
|
|
|
|
const AudioMsgId &audio,
|
|
|
|
crl::time positionMs);
|
|
|
|
Mixer::Track *checkLoader(AudioMsgId::Type type);
|
2016-07-05 17:44:02 +00:00
|
|
|
|
|
|
|
AudioMsgId _audio, _song, _video;
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<AudioPlayerLoader> _audioLoader;
|
|
|
|
std::unique_ptr<AudioPlayerLoader> _songLoader;
|
2017-05-18 20:18:59 +00:00
|
|
|
std::unique_ptr<AudioPlayerLoader> _videoLoader;
|
2016-07-05 17:44:02 +00:00
|
|
|
|
2019-02-28 21:03:25 +00:00
|
|
|
QMutex _fromExternalMutex;
|
|
|
|
base::flat_map<
|
|
|
|
AudioMsgId,
|
2019-06-26 15:04:38 +00:00
|
|
|
std::deque<FFmpeg::Packet>> _fromExternalQueues;
|
2019-02-28 21:03:25 +00:00
|
|
|
base::flat_set<AudioMsgId> _fromExternalForceToBuffer;
|
|
|
|
SingleQueuedInvokation _fromExternalNotify;
|
2016-07-05 17:44:02 +00:00
|
|
|
|
|
|
|
};
|
2017-01-19 08:24:43 +00:00
|
|
|
|
|
|
|
} // namespace Player
|
|
|
|
} // namespace Media
|