score-plugin-gfx/Gfx/Video/Process.hpp
1 #pragma once
2 #include <Process/Drop/ProcessDropHandler.hpp>
3 #include <Process/GenericProcessFactory.hpp>
4 #include <Process/Process.hpp>
5 
6 #include <Gfx/CommandFactory.hpp>
7 #include <Gfx/Graph/Scale.hpp>
8 #include <Gfx/Video/Metadata.hpp>
9 #include <Library/LibraryInterface.hpp>
10 #include <Video/VideoDecoder.hpp>
11 
12 #include <score/command/PropertyCommand.hpp>
13 namespace Gfx::Video
14 {
15 using video_decoder = ::Video::VideoDecoder;
16 class Model final : public Process::ProcessModel
17 {
18  SCORE_SERIALIZE_FRIENDS
19  PROCESS_METADATA_IMPL(Gfx::Video::Model)
20  W_OBJECT(Model)
21 
22 public:
23  Model(
24  const TimeVal& duration, const QString& path, const Id<Process::ProcessModel>& id,
25  QObject* parent);
26 
27  template <typename Impl>
28  Model(Impl& vis, QObject* parent)
29  : Process::ProcessModel{vis, parent}
30  {
31  vis.writeTo(*this);
32  }
33 
34  ~Model() override;
35 
36  std::shared_ptr<video_decoder> makeDecoder() const noexcept;
37 
38  QString absolutePath() const noexcept;
39  QString path() const noexcept { return m_path; }
40  void setPath(const QString& f);
41  void pathChanged(const QString& f) W_SIGNAL(pathChanged, f);
42 
43  double nativeTempo() const noexcept;
44  void setNativeTempo(double);
45  void nativeTempoChanged(double t) W_SIGNAL(nativeTempoChanged, t);
46 
47  score::gfx::ScaleMode scaleMode() const noexcept;
48  void setScaleMode(score::gfx::ScaleMode);
49  void scaleModeChanged(score::gfx::ScaleMode t) W_SIGNAL(scaleModeChanged, t);
50 
51  bool ignoreTempo() const noexcept;
52  void setIgnoreTempo(bool);
53  void ignoreTempoChanged(bool t) W_SIGNAL(ignoreTempoChanged, t);
54 
55  PROPERTY(
57  scaleMode READ scaleMode WRITE setScaleMode NOTIFY scaleModeChanged)
58 
59  PROPERTY(QString, path READ path WRITE setPath NOTIFY pathChanged)
60  PROPERTY(
61  double,
62  nativeTempo READ nativeTempo WRITE setNativeTempo NOTIFY nativeTempoChanged,
63  W_Final)
64  PROPERTY(
65  bool, ignoreTempo READ ignoreTempo WRITE setIgnoreTempo NOTIFY ignoreTempoChanged,
66  W_Final)
67 
68 private:
69  QString m_path;
70  score::gfx::ScaleMode m_scaleMode{};
71  double m_nativeTempo{};
72  bool m_ignoreTempo{};
73 };
74 
76 
78 {
79  SCORE_CONCRETE("be66d573-571f-4c33-9f60-0791f53c7266")
80 
81  QSet<QString> acceptedFiles() const noexcept override;
82 };
83 
85 {
86  SCORE_CONCRETE("12d1ed39-0fac-43da-8520-b7e32f9fad7d")
87 
88 public:
89  QSet<QString> mimeTypes() const noexcept override;
90  QSet<QString> fileExtensions() const noexcept override;
91  void dropPath(
92  std::vector<ProcessDrop>& vec, const score::FilePath& filename,
93  const score::DocumentContext& ctx) const noexcept override;
94 };
95 
96 }
97 
98 PROPERTY_COMMAND_T(Gfx, ChangeVideo, Video::Model::p_path, "Change video")
99 SCORE_COMMAND_DECL_T(Gfx::ChangeVideo)
100 PROPERTY_COMMAND_T(Gfx, ChangeTempo, Video::Model::p_nativeTempo, "Change video tempo")
101 SCORE_COMMAND_DECL_T(Gfx::ChangeTempo)
102 PROPERTY_COMMAND_T(
103  Gfx, ChangeIgnoreTempo, Video::Model::p_ignoreTempo, "Ignore video tempo")
104 SCORE_COMMAND_DECL_T(Gfx::ChangeIgnoreTempo)
105 PROPERTY_COMMAND_T(
106  Gfx, ChangeVideoScaleMode, Video::Model::p_scaleMode, "Video scale mode")
107 SCORE_COMMAND_DECL_T(Gfx::ChangeVideoScaleMode)
108 
109 W_REGISTER_ARGTYPE(score::gfx::ScaleMode)
Definition: score-plugin-gfx/Gfx/Video/Process.hpp:85
Definition: score-plugin-gfx/Gfx/Video/Process.hpp:78
Definition: score-plugin-gfx/Gfx/Video/Process.hpp:17
Definition: LibraryInterface.hpp:22
Definition: ProcessDropHandler.hpp:25
Definition: GenericProcessFactory.hpp:15
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
Definition: VideoDecoder.hpp:28
The id_base_t class.
Definition: Identifier.hpp:57
Binds the rendering pipeline to ossia processes.
Definition: CameraDevice.cpp:28
ScaleMode
How to resize a texture to adapt it to a viewport.
Definition: Scale.hpp:10
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: TimeValue.hpp:21
Definition: DocumentContext.hpp:18
Definition: FilePath.hpp:25