Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 816d1c34 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

LIB: Add the VideoContext to the VideoSubDocument

parent f4e04ba8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!18Implement the VivyDocument specification
......@@ -7,6 +7,7 @@
#include "../Utils.hh"
#include "../Audio.hh"
#include "../Video.hh"
#include "../Ass/Ass.hh"
namespace Vivy
......@@ -52,17 +53,14 @@ public:
// Audio document
class AudioSubDocument final : public CRTPSubDocument<AudioDocumentType, AudioSubDocument> {
private:
const QStringList &suffixList = Vivy::Utils::audioFileSuffix;
std::unique_ptr<AudioContext> contextPtr{ nullptr };
void initFromPath(const QString &);
explicit AudioSubDocument() = default;
friend CRTPSubDocument<AudioDocumentType, AudioSubDocument>;
private:
std::unique_ptr<AudioContext> contextPtr;
public:
int getDefaultStreamIndex() const noexcept;
AudioContext::StreamPtr getDefaultStream() const noexcept;
......@@ -74,8 +72,8 @@ public:
// Video document
class VideoSubDocument final : public CRTPSubDocument<VideoDocumentType, VideoSubDocument> {
private:
const QStringList &suffixList = Vivy::Utils::videoFileSuffix;
std::unique_ptr<VideoContext> contextPtr{ nullptr };
void initFromPath(const QString &);
......@@ -83,6 +81,10 @@ private:
friend CRTPSubDocument<VideoDocumentType, VideoSubDocument>;
public:
int getDefaultStreamIndex() const noexcept;
VideoContext::StreamPtr getDefaultStream() const noexcept;
VideoContext::StreamPtr getStream(int index) const noexcept;
QString getElementName() const noexcept;
QJsonDocument getProperties() const noexcept;
};
......
......@@ -2,10 +2,49 @@
using namespace Vivy;
// Get the default stream index or -1 if not possible
int
VideoSubDocument::getDefaultStreamIndex() const noexcept
{
if (auto ptr = getDefaultStream()) {
return ptr->getStreamIndex();
} else {
return -1;
}
}
// Get a pointer to the default stream, nullptr if not possible
VideoContext::StreamPtr
VideoSubDocument::getDefaultStream() const noexcept
{
if (auto ptr = contextPtr->getDefaultStream().lock()) {
return ptr;
} else {
qCritical() << "Document deleted!";
return nullptr;
}
}
// Get the stream asked for, nullptr if no stream or if the index is invalid
VideoContext::StreamPtr
VideoSubDocument::getStream(int index) const noexcept
{
if (auto ptr = contextPtr->getStream(index).lock()) {
return ptr;
} else {
return nullptr;
}
}
// Init a video sub-document from a file
void
VideoSubDocument::initFromPath(const QString &)
VideoSubDocument::initFromPath(const QString &path)
{
if (contextPtr)
qDebug() << "Replacing the video contetx by a new one for file" << path;
contextPtr.reset(new VideoContext(path)); // May throw
qDebug() << "Video OK for" << path;
}
QString
......@@ -18,7 +57,10 @@ QJsonDocument
VideoSubDocument::getProperties() const noexcept
{
QJsonDocument ret;
QJsonObject object;
QJsonObject object{
{ "Video context", contextPtr->getProperties().object() },
{ "File", filePath },
};
ret.setObject(object);
return ret;
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter