OpenShot Library | libopenshot  0.3.1
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;
43  };
44 
52  class EffectBase : public ClipBase
53  {
54  private:
55  int order;
56 
57  protected:
59 
60  public:
61 
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 
109  Json::Value JsonInfo() const;
110 
112  int Order() const { return order; }
113 
115  void Order(int new_order) { order = new_order; }
116 
117  virtual ~EffectBase() = default;
118  };
119 
120 }
121 
122 #endif
Header file for ClipBase class.
Header file for JSON class.
Header file for the TrackedObjectBase class.
This abstract class is the base class, used by all clips in libopenshot.
Definition: ClipBase.h:33
This abstract class is the base class, used by all effects in libopenshot.
Definition: EffectBase.h:53
virtual void SetJson(const std::string value)
Load JSON string into this object.
Definition: EffectBase.cpp:95
EffectBase * parentEffect
Parent effect (which properties will set this effect properties)
Definition: EffectBase.h:63
virtual std::string Json(int64_t requested_frame) const
Definition: EffectBase.h:102
Json::Value JsonInfo() const
Generate JSON object of meta data / info.
Definition: EffectBase.cpp:158
virtual void SetJson(int64_t requested_frame, const std::string value)
Definition: EffectBase.h:105
std::string ParentClipId() const
Return the ID of this effect's parent clip.
Definition: EffectBase.cpp:208
void SetParentEffect(std::string parentEffect_id)
Set the parent effect from which this properties will be set to.
Definition: EffectBase.cpp:183
virtual Json::Value JsonValue() const
Generate Json::Value for this object.
Definition: EffectBase.cpp:77
virtual ~EffectBase()=default
openshot::ClipBase * ParentClip()
Parent clip object of this effect (which can be unparented and NULL)
Definition: EffectBase.cpp:173
int constrain(int color_value)
Constrain a color value from 0 to 255.
Definition: EffectBase.cpp:58
virtual std::string Json() const
Generate JSON string of this object.
Definition: EffectBase.cpp:70
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
virtual void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Definition: EffectBase.cpp:112
int Order() const
Get the order that this effect should be executed.
Definition: EffectBase.h:112
void Order(int new_order)
Set the order that this effect should be executed.
Definition: EffectBase.h:115
openshot::ClipBase * clip
Pointer to the parent clip instance (if any)
Definition: EffectBase.h:58
EffectInfoStruct info
Information about the current effect.
Definition: EffectBase.h:69
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
void DisplayInfo(std::ostream *out=&std::cout)
Display effect information in the standard output stream (stdout)
Definition: EffectBase.cpp:45
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:29
This struct contains info about an effect, such as the name, video or audio effect,...
Definition: EffectBase.h:35
bool has_video
Determines if this effect manipulates the image of a frame.
Definition: EffectBase.h:40
std::string parent_effect_id
Id of the parent effect (if there is one)
Definition: EffectBase.h:39
bool has_audio
Determines if this effect manipulates the audio of a frame.
Definition: EffectBase.h:41
std::string class_name
The class name of the effect.
Definition: EffectBase.h:36
std::string name
The name of the effect.
Definition: EffectBase.h:37
std::string description
The description of this effect and what it does.
Definition: EffectBase.h:38
bool has_tracked_object
Determines if this effect track objects through the clip.
Definition: EffectBase.h:42