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 
82  openshot::ClipBase* ParentClip();
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.
This abstract class is the base class, used by all effects in libopenshot.
Definition: EffectBase.h:52
virtual std::string Json(int64_t requested_frame) const
Definition: EffectBase.h:102
std::map< int, std::shared_ptr< openshot::TrackedObjectBase > > trackedObjects
Map of Tracked Object&#39;s by their indices (used by Effects that track objects on clips) ...
Definition: EffectBase.h:66
openshot::ClipBase * clip
Pointer to the parent clip instance (if any)
Definition: EffectBase.h:58
EffectBase * parentEffect
Parent effect (which properties will set this effect properties)
Definition: EffectBase.h:63
bool has_audio
Determines if this effect manipulates the audio of a frame.
Definition: EffectBase.h:41
void Order(int new_order)
Set the order that this effect should be executed.
Definition: EffectBase.h:115
Header file for JSON class.
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
This abstract class is the base class, used by all clips in libopenshot.
Definition: ClipBase.h:33
bool has_tracked_object
Determines if this effect track objects through the clip.
Definition: EffectBase.h:42
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
int Order() const
Get the order that this effect should be executed.
Definition: EffectBase.h:112
This struct contains info about an effect, such as the name, video or audio effect, etc...
Definition: EffectBase.h:34
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
std::string description
The description of this effect and what it does.
Definition: EffectBase.h:38
bool has_video
Determines if this effect manipulates the image of a frame.
Definition: EffectBase.h:40
virtual void SetJson(int64_t requested_frame, const std::string value)
Definition: EffectBase.h:105
std::string parent_effect_id
Id of the parent effect (if there is one)
Definition: EffectBase.h:39
Header file for the TrackedObjectBase class.
EffectInfoStruct info
Information about the current effect.
Definition: EffectBase.h:69