OpenShot Library | libopenshot  0.3.3
EffectBase.h
Go to the documentation of this file.
1 
9 // Copyright (c) 2008-2019 OpenShot Studios, LLC
10 //
11 // SPDX-License-Identifier: LGPL-3.0-or-later
12 
13 #ifndef OPENSHOT_EFFECT_BASE_H
14 #define OPENSHOT_EFFECT_BASE_H
15 
16 #include "ClipBase.h"
17 
18 #include "Json.h"
19 #include "TrackedObjectBase.h"
20 
21 #include <memory>
22 #include <map>
23 #include <string>
24 
25 namespace openshot
26 {
35  {
36  std::string class_name;
37  std::string name;
38  std::string description;
39  std::string parent_effect_id;
40  bool has_video;
41  bool has_audio;
44  };
45 
53  class EffectBase : public ClipBase
54  {
55  private:
56  int order;
57 
58  protected:
60 
61  public:
64 
66  std::map<int, std::shared_ptr<openshot::TrackedObjectBase> > trackedObjects;
67 
70 
72  void DisplayInfo(std::ostream* out=&std::cout);
73 
75  int constrain(int color_value);
76 
79  void InitEffectInfo();
80 
83 
85  void ParentClip(openshot::ClipBase* new_clip);
86 
88  void SetParentEffect(std::string parentEffect_id);
89 
91  std::string ParentClipId() const;
92 
94  virtual std::string GetVisibleObjects(int64_t frame_number) const {return {}; };
95 
96  // Get and Set JSON methods
97  virtual std::string Json() const;
98  virtual void SetJson(const std::string value);
99  virtual Json::Value JsonValue() const;
100  virtual void SetJsonValue(const Json::Value root);
101 
102  virtual std::string Json(int64_t requested_frame) const{
103  return "";
104  };
105  virtual void SetJson(int64_t requested_frame, const std::string value) {
106  return;
107  };
108 
110  Json::Value JsonInfo() const;
111 
113  Json::Value BasePropertiesJSON(int64_t requested_frame) const;
114 
116  int Order() const { return order; }
117 
119  void Order(int new_order) { order = new_order; }
120 
121  virtual ~EffectBase() = default;
122  };
123 
124 }
125 
126 #endif
openshot::EffectBase
This abstract class is the base class, used by all effects in libopenshot.
Definition: EffectBase.h:53
openshot::EffectBase::info
EffectInfoStruct info
Information about the current effect.
Definition: EffectBase.h:69
openshot::EffectBase::JsonInfo
Json::Value JsonInfo() const
Generate JSON object of meta data / info.
Definition: EffectBase.cpp:164
openshot::EffectInfoStruct::apply_before_clip
bool apply_before_clip
Apply effect before we evaluate the clip's keyframes.
Definition: EffectBase.h:43
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::EffectBase::ParentClip
openshot::ClipBase * ParentClip()
Parent clip object of this effect (which can be unparented and NULL)
Definition: EffectBase.cpp:201
openshot::EffectBase::JsonValue
virtual Json::Value JsonValue() const
Generate Json::Value for this object.
Definition: EffectBase.cpp:79
openshot::EffectInfoStruct
This struct contains info about an effect, such as the name, video or audio effect,...
Definition: EffectBase.h:34
openshot::EffectBase::DisplayInfo
void DisplayInfo(std::ostream *out=&std::cout)
Display effect information in the standard output stream (stdout)
Definition: EffectBase.cpp:45
openshot::EffectBase::trackedObjects
std::map< int, std::shared_ptr< openshot::TrackedObjectBase > > trackedObjects
Map of Tracked Object's by their indices (used by Effects that track objects on clips)
Definition: EffectBase.h:66
openshot::EffectBase::Json
virtual std::string Json() const
Generate JSON string of this object.
Definition: EffectBase.cpp:72
openshot::EffectBase::SetParentEffect
void SetParentEffect(std::string parentEffect_id)
Set the parent effect from which this properties will be set to.
Definition: EffectBase.cpp:211
openshot::EffectBase::~EffectBase
virtual ~EffectBase()=default
openshot::EffectBase::BasePropertiesJSON
Json::Value BasePropertiesJSON(int64_t requested_frame) const
Generate JSON object of base properties (recommended to be used by all effects)
Definition: EffectBase.cpp:179
openshot::EffectBase::Json
virtual std::string Json(int64_t requested_frame) const
Definition: EffectBase.h:102
openshot::EffectBase::parentEffect
EffectBase * parentEffect
Parent effect (which properties will set this effect properties)
Definition: EffectBase.h:63
openshot::EffectBase::Order
void Order(int new_order)
Set the order that this effect should be executed.
Definition: EffectBase.h:119
openshot::EffectBase::InitEffectInfo
void InitEffectInfo()
Definition: EffectBase.cpp:24
openshot::EffectInfoStruct::has_audio
bool has_audio
Determines if this effect manipulates the audio of a frame.
Definition: EffectBase.h:41
openshot::EffectInfoStruct::has_tracked_object
bool has_tracked_object
Determines if this effect track objects through the clip.
Definition: EffectBase.h:42
openshot::EffectBase::ParentClipId
std::string ParentClipId() const
Return the ID of this effect's parent clip.
Definition: EffectBase.cpp:236
openshot::EffectBase::Order
int Order() const
Get the order that this effect should be executed.
Definition: EffectBase.h:116
openshot::EffectInfoStruct::class_name
std::string class_name
The class name of the effect.
Definition: EffectBase.h:36
openshot::EffectInfoStruct::description
std::string description
The description of this effect and what it does.
Definition: EffectBase.h:38
openshot::EffectInfoStruct::has_video
bool has_video
Determines if this effect manipulates the image of a frame.
Definition: EffectBase.h:40
openshot::EffectBase::constrain
int constrain(int color_value)
Constrain a color value from 0 to 255.
Definition: EffectBase.cpp:60
openshot::EffectInfoStruct::parent_effect_id
std::string parent_effect_id
Id of the parent effect (if there is one)
Definition: EffectBase.h:39
openshot::EffectInfoStruct::name
std::string name
The name of the effect.
Definition: EffectBase.h:37
openshot::EffectBase::SetJson
virtual void SetJson(int64_t requested_frame, const std::string value)
Definition: EffectBase.h:105
Json.h
Header file for JSON class.
openshot::ClipBase
This abstract class is the base class, used by all clips in libopenshot.
Definition: ClipBase.h:33
openshot::EffectBase::SetJson
virtual void SetJson(const std::string value)
Load JSON string into this object.
Definition: EffectBase.cpp:98
TrackedObjectBase.h
Header file for the TrackedObjectBase class.
ClipBase.h
Header file for ClipBase class.
openshot::EffectBase::GetVisibleObjects
virtual std::string GetVisibleObjects(int64_t frame_number) const
Get the indexes and IDs of all visible objects in the given frame.
Definition: EffectBase.h:94
openshot::EffectBase::SetJsonValue
virtual void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Definition: EffectBase.cpp:115
openshot::EffectBase::clip
openshot::ClipBase * clip
Pointer to the parent clip instance (if any)
Definition: EffectBase.h:59