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
|
|
|
|
|
|
|
signals:
|
|
|
|
void error(const AudioMsgId &audio);
|
|
|
|
void needToCheck();
|
|
|
|
|
2019-02-28 21:03:25 +00:00
|
|
|
public 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:
|
2017-04-06 16:49:42 +00:00
|
|
|
void videoSoundAdded();
|
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
|
|
|
|
|
|
|
void emitError(AudioMsgId::Type type);
|
|
|
|
AudioMsgId clear(AudioMsgId::Type type);
|
2017-01-24 21:24:39 +00:00
|
|
|
void setStoppedState(Mixer::Track *m, State state = State::Stopped);
|
2016-07-05 17:44:02 +00:00
|
|
|
|
|
|
|
enum SetupError {
|
|
|
|
SetupErrorAtStart = 0,
|
|
|
|
SetupErrorNotPlaying = 1,
|
|
|
|
SetupErrorLoadedFull = 2,
|
|
|
|
SetupNoErrorStarted = 3,
|
|
|
|
};
|
2019-02-21 13:40:09 +00:00
|
|
|
void loadData(AudioMsgId audio, crl::time positionMs = 0);
|
2017-12-10 08:52:38 +00:00
|
|
|
AudioPlayerLoader *setupLoader(
|
|
|
|
const AudioMsgId &audio,
|
|
|
|
SetupError &err,
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time positionMs);
|
2017-01-24 21:24:39 +00:00
|
|
|
Mixer::Track *checkLoader(AudioMsgId::Type type);
|
2016-07-05 17:44:02 +00:00
|
|
|
|
|
|
|
};
|
2017-01-19 08:24:43 +00:00
|
|
|
|
|
|
|
} // namespace Player
|
|
|
|
} // namespace Media
|