2016-07-05 17:44:02 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2016-07-05 17:44:02 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "media/media_child_ffmpeg_loader.h"
|
|
|
|
#include "media/media_audio.h"
|
2016-07-19 16:02:39 +00:00
|
|
|
#include "media/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);
|
2016-07-05 17:44:02 +00:00
|
|
|
void feedFromVideo(VideoSoundPart &&part);
|
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();
|
|
|
|
|
2017-01-19 08:24:43 +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
|
|
|
void clearFromVideoQueue();
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
QMutex _fromVideoMutex;
|
2017-05-18 20:18:59 +00:00
|
|
|
QMap<AudioMsgId, QQueue<FFMpeg::AVPacketDataWrap>> _fromVideoQueues;
|
2017-04-06 16:49:42 +00:00
|
|
|
SingleQueuedInvokation _fromVideoNotify;
|
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,
|
|
|
|
};
|
2017-12-10 08:52:38 +00:00
|
|
|
void loadData(AudioMsgId audio, TimeMs positionMs);
|
|
|
|
AudioPlayerLoader *setupLoader(
|
|
|
|
const AudioMsgId &audio,
|
|
|
|
SetupError &err,
|
|
|
|
TimeMs 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
|