MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / SetJsonValue

Method SetJsonValue

src/EffectBase.cpp:139–218  ·  view source on GitHub ↗

Load Json::Value into this object

Source from the content-addressed store, hash-verified

137
138// Load Json::Value into this object
139void EffectBase::SetJsonValue(const Json::Value root) {
140
141 if (ParentTimeline()){
142 // Get parent timeline
143 Timeline* parentTimeline = static_cast<Timeline *>(ParentTimeline());
144
145 // Get the list of effects on the timeline
146 std::list<EffectBase*> effects = parentTimeline->ClipEffects();
147
148 // TODO: Fix recursive call for Object Detection
149
150 // // Loop through the effects and check if we have a child effect linked to this effect
151 for (auto const& effect : effects){
152 // Set the properties of all effects which parentEffect points to this
153 if ((effect->info.parent_effect_id == this->Id()) && (effect->Id() != this->Id()))
154 effect->SetJsonValue(root);
155 }
156 }
157
158 // Set this effect properties with the parent effect properties (except the id and parent_effect_id)
159 Json::Value my_root;
160 if (parentEffect){
161 my_root = parentEffect->JsonValue();
162 my_root["id"] = this->Id();
163 my_root["parent_effect_id"] = this->info.parent_effect_id;
164 } else {
165 my_root = root;
166 }
167
168 // Legacy compatibility: older shared-mask JSON stored source trim
169 // separately from the effect trim. Canonical trim now uses ClipBase.
170 if (my_root["start"].isNull() && !my_root["mask_start"].isNull())
171 my_root["start"] = my_root["mask_start"];
172 if (my_root["end"].isNull() && !my_root["mask_end"].isNull())
173 my_root["end"] = my_root["mask_end"];
174
175 // Set parent data
176 ClipBase::SetJsonValue(my_root);
177
178 // Set data from Json (if key is found)
179 if (!my_root["order"].isNull())
180 Order(my_root["order"].asInt());
181
182 if (!my_root["apply_before_clip"].isNull())
183 info.apply_before_clip = my_root["apply_before_clip"].asBool();
184
185 if (!my_root["mask_invert"].isNull())
186 mask_invert = my_root["mask_invert"].asBool();
187 if (!my_root["mask_time_mode"].isNull()) {
188 const int time_mode = my_root["mask_time_mode"].asInt();
189 mask_time_mode = (time_mode == MASK_TIME_TIMELINE || time_mode == MASK_TIME_SOURCE_FPS)
190 ? time_mode : MASK_TIME_SOURCE_FPS;
191 }
192 if (!my_root["mask_loop_mode"].isNull()) {
193 const int loop_mode = my_root["mask_loop_mode"].asInt();
194 if (loop_mode >= MASK_LOOP_PLAY_ONCE && loop_mode <= MASK_LOOP_PING_PONG)
195 mask_loop_mode = loop_mode;
196 else

Callers 2

SetParentEffectMethod · 0.95
CreateReaderFromJsonMethod · 0.45

Calls 3

ClipEffectsMethod · 0.80
IdMethod · 0.45
JsonValueMethod · 0.45

Tested by

no test coverage detected