OpenShot Library | libopenshot 0.4.0
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
25namespace 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
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:54
virtual void SetJson(const std::string value)
Load JSON string into this object.
Definition: EffectBase.cpp:98
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:164
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:236
void SetParentEffect(std::string parentEffect_id)
Set the parent effect from which this properties will be set to.
Definition: EffectBase.cpp:211
virtual Json::Value JsonValue() const
Generate Json::Value for this object.
Definition: EffectBase.cpp:79
virtual ~EffectBase()=default
openshot::ClipBase * ParentClip()
Parent clip object of this effect (which can be unparented and NULL)
Definition: EffectBase.cpp:201
int constrain(int color_value)
Constrain a color value from 0 to 255.
Definition: EffectBase.cpp:60
virtual std::string Json() const
Generate JSON string of this object.
Definition: EffectBase.cpp:72
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
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:115
int Order() const
Get the order that this effect should be executed.
Definition: EffectBase.h:116
void Order(int new_order)
Set the order that this effect should be executed.
Definition: EffectBase.h:119
openshot::ClipBase * clip
Pointer to the parent clip instance (if any)
Definition: EffectBase.h:59
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
bool apply_before_clip
Apply effect before we evaluate the clip's keyframes.
Definition: EffectBase.h:43
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