1 /**
2  * @file
3  * @brief Source file for EffectInfo class
4  * @author Jonathan Thomas <jonathan@openshot.org>
5  *
6  * @ref License
7  */
8 
9 /* LICENSE
10  *
11  * Copyright (c) 2008-2019 OpenShot Studios, LLC
12  * <http://www.openshotstudios.com/>. This file is part of
13  * OpenShot Library (libopenshot), an open-source project dedicated to
14  * delivering high quality video editing and animation solutions to the
15  * world. For more information visit <http://www.openshot.org/>.
16  *
17  * OpenShot Library (libopenshot) is free software: you can redistribute it
18  * and/or modify it under the terms of the GNU Lesser General Public License
19  * as published by the Free Software Foundation, either version 3 of the
20  * License, or (at your option) any later version.
21  *
22  * OpenShot Library (libopenshot) is distributed in the hope that it will be
23  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU Lesser General Public License for more details.
26  *
27  * You should have received a copy of the GNU Lesser General Public License
28  * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
29  */
30 
31 #include "EffectInfo.h"
32 
33 using namespace openshot;
34 
35 
36 // Generate JSON string of this object
Json()37 std::string EffectInfo::Json() {
38 
39 	// Return formatted string
40 	return JsonValue().toStyledString();
41 }
42 
43 // Create a new effect instance
CreateEffect(std::string effect_type)44 EffectBase* EffectInfo::CreateEffect(std::string effect_type) {
45 	// Init the matching effect object
46 	if (effect_type == "Bars")
47 		return new Bars();
48 
49 	if (effect_type == "Blur")
50 		return new Blur();
51 
52 	else if (effect_type == "Brightness")
53 		return new Brightness();
54 
55 	else if (effect_type == "Caption")
56 		return new Caption();
57 
58 	else if (effect_type == "ChromaKey")
59 		return new ChromaKey();
60 
61 	else if (effect_type == "ColorShift")
62 		return new ColorShift();
63 
64 	else if (effect_type == "Crop")
65 		return new Crop();
66 
67 	else if (effect_type == "Deinterlace")
68 		return new Deinterlace();
69 
70 	else if (effect_type == "Hue")
71 		return new Hue();
72 
73 	else if (effect_type == "Mask")
74 		return new Mask();
75 
76 	else if (effect_type == "Negate")
77 		return new Negate();
78 
79 	else if (effect_type == "Pixelate")
80 		return new Pixelate();
81 
82 	else if (effect_type == "Saturation")
83 		return new Saturation();
84 
85 	else if (effect_type == "Shift")
86 		return new Shift();
87 
88 	else if (effect_type == "Wave")
89 		return new Wave();
90 
91 	else if(effect_type == "Noise")
92 		return new Noise();
93 
94 	else if(effect_type == "Delay")
95 		return new Delay();
96 
97 	else if(effect_type == "Echo")
98 		return new Echo();
99 
100 	else if(effect_type == "Distortion")
101 		return new Distortion();
102 
103 	else if(effect_type == "ParametricEQ")
104 		return new ParametricEQ();
105 
106 	else if(effect_type == "Compressor")
107 		return new Compressor();
108 
109 	else if(effect_type == "Expander")
110 		return new Expander();
111 
112 	else if(effect_type == "Robotization")
113 		return new Robotization();
114 
115 	else if(effect_type == "Whisperization")
116 		return new Whisperization();
117 
118 	#ifdef USE_OPENCV
119 	else if(effect_type == "Stabilizer")
120 		return new Stabilizer();
121 
122 	else if(effect_type == "Tracker")
123 		return new Tracker();
124 
125 	else if(effect_type == "Object Detector")
126 		return new ObjectDetection();
127 	#endif
128 
129 	return NULL;
130 }
131 
132 // Generate Json::Value for this object
JsonValue()133 Json::Value EffectInfo::JsonValue() {
134 
135 	// Create root json object
136 	Json::Value root;
137 
138 	// Append info JSON from each supported effect
139 	root.append(Bars().JsonInfo());
140 	root.append(Blur().JsonInfo());
141 	root.append(Brightness().JsonInfo());
142 	root.append(Caption().JsonInfo());
143 	root.append(ChromaKey().JsonInfo());
144 	root.append(ColorShift().JsonInfo());
145 	root.append(Crop().JsonInfo());
146 	root.append(Deinterlace().JsonInfo());
147 	root.append(Hue().JsonInfo());
148 	root.append(Mask().JsonInfo());
149 	root.append(Negate().JsonInfo());
150 	root.append(Pixelate().JsonInfo());
151 	root.append(Saturation().JsonInfo());
152 	root.append(Shift().JsonInfo());
153 	root.append(Wave().JsonInfo());
154 	/* Audio */
155 	root.append(Noise().JsonInfo());
156 	root.append(Delay().JsonInfo());
157 	root.append(Echo().JsonInfo());
158 	root.append(Distortion().JsonInfo());
159 	root.append(ParametricEQ().JsonInfo());
160 	root.append(Compressor().JsonInfo());
161 	root.append(Expander().JsonInfo());
162 	root.append(Robotization().JsonInfo());
163 	root.append(Whisperization().JsonInfo());
164 
165 	#ifdef USE_OPENCV
166 	root.append(Stabilizer().JsonInfo());
167 	root.append(Tracker().JsonInfo());
168 	root.append(ObjectDetection().JsonInfo());
169 	#endif
170 
171 	// return JsonValue
172 	return root;
173 
174 }
175