OpenShot Library | libopenshot  0.1.9
EffectBase.h
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Header file for EffectBase class
4  * @author Jonathan Thomas <jonathan@openshot.org>
5  *
6  * @section LICENSE
7  *
8  * Copyright (c) 2008-2014 OpenShot Studios, LLC
9  * <http://www.openshotstudios.com/>. This file is part of
10  * OpenShot Library (libopenshot), an open-source project dedicated to
11  * delivering high quality video editing and animation solutions to the
12  * world. For more information visit <http://www.openshot.org/>.
13  *
14  * OpenShot Library (libopenshot) is free software: you can redistribute it
15  * and/or modify it under the terms of the GNU Lesser General Public License
16  * as published by the Free Software Foundation, either version 3 of the
17  * License, or (at your option) any later version.
18  *
19  * OpenShot Library (libopenshot) is distributed in the hope that it will be
20  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public License
25  * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
26  */
27 
28 #ifndef OPENSHOT_EFFECT_BASE_H
29 #define OPENSHOT_EFFECT_BASE_H
30 
31 #include <iostream>
32 #include <iomanip>
33 #include <memory>
34 #include "ClipBase.h"
35 #include "Frame.h"
36 #include "Json.h"
37 
38 using namespace std;
39 
40 namespace openshot
41 {
42  /**
43  * @brief This struct contains info about an effect, such as the name, video or audio effect, etc...
44  *
45  * Each derived class of EffectBase is responsible for updating this struct to reflect accurate information
46  * about the underlying effect. Derived classes of EffectBase should call the InitEffectInfo() method to initialize the
47  * default values of this struct.
48  */
50  {
51  string class_name; ///< The class name of the effect
52  string short_name; ///< A short name of the effect, commonly used for icon names, etc...
53  string name; ///< The name of the effect
54  string description; ///< The description of this effect and what it does
55  bool has_video; ///< Determines if this effect manipulates the image of a frame
56  bool has_audio; ///< Determines if this effect manipulates the audio of a frame
57  };
58 
59  /**
60  * @brief This abstract class is the base class, used by all effects in libopenshot.
61  *
62  * Effects are types of classes that manipulate the image or audio data of an openshot::Frame object.
63  * The only requirements for an 'effect', is to derive from this base class, implement the Apply()
64  * method, and call the InitEffectInfo() method.
65  */
66  class EffectBase : public ClipBase
67  {
68  private:
69  int order; ///< The order to evaluate this effect. Effects are processed in this order (when more than one overlap).
70  public:
71 
72  /// Information about the current effect
74 
75  /// Display effect information in the standard output stream (stdout)
76  void DisplayInfo();
77 
78  /// @brief This method is required for all derived classes of EffectBase, and returns a
79  /// modified openshot::Frame object
80  ///
81  /// The frame object is passed into this method, and a frame_number is passed in which
82  /// tells the effect which settings to use from it's keyframes (starting at 1).
83  ///
84  /// @returns The modified openshot::Frame object
85  /// @param frame The frame object that needs the effect applied to it
86  /// @param frame_number The frame number (starting at 1) of the effect on the timeline.
87  virtual std::shared_ptr<Frame> GetFrame(std::shared_ptr<Frame> frame, int64_t frame_number) = 0;
88 
89  /// Initialize the values of the EffectInfo struct. It is important for derived classes to call
90  /// this method, or the EffectInfo struct values will not be initialized.
91  void InitEffectInfo();
92 
93  /// Get and Set JSON methods
94  virtual string Json() = 0; ///< Generate JSON string of this object
95  virtual void SetJson(string value) = 0; ///< Load JSON string into this object
96  virtual Json::Value JsonValue() = 0; ///< Generate Json::JsonValue for this object
97  virtual void SetJsonValue(Json::Value root) = 0; ///< Load Json::JsonValue into this object
98  Json::Value JsonInfo(); ///< Generate JSON object of meta data / info
99 
100  /// Get the order that this effect should be executed.
101  int Order() { return order; }
102 
103  /// Set the order that this effect should be executed.
104  void Order(int new_order) { order = new_order; }
105  };
106 
107 }
108 
109 #endif
Header file for ClipBase class.
This abstract class is the base class, used by all effects in libopenshot.
Definition: EffectBase.h:66
string class_name
The class name of the effect.
Definition: EffectBase.h:51
bool has_audio
Determines if this effect manipulates the audio of a frame.
Definition: EffectBase.h:56
Header file for Frame class.
void Order(int new_order)
Set the order that this effect should be executed.
Definition: EffectBase.h:104
Header file for JSON class.
string name
The name of the effect.
Definition: EffectBase.h:53
string description
The description of this effect and what it does.
Definition: EffectBase.h:54
This abstract class is the base class, used by all clips in libopenshot.
Definition: ClipBase.h:53
This struct contains info about an effect, such as the name, video or audio effect, etc...
Definition: EffectBase.h:49
This namespace is the default namespace for all code in the openshot library.
bool has_video
Determines if this effect manipulates the image of a frame.
Definition: EffectBase.h:55
string short_name
A short name of the effect, commonly used for icon names, etc...
Definition: EffectBase.h:52
int Order()
Get the order that this effect should be executed.
Definition: EffectBase.h:101
EffectInfoStruct info
Information about the current effect.
Definition: EffectBase.h:73