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

Method SetJsonValue

src/Timeline.cpp:1265–1364  ·  view source on GitHub ↗

Load Json::Value into this object

Source from the content-addressed store, hash-verified

1263
1264// Load Json::Value into this object
1265void Timeline::SetJsonValue(const Json::Value root) {
1266
1267 // Get lock (prevent getting frames while this happens)
1268 const std::lock_guard<std::recursive_mutex> lock(getFrameMutex);
1269
1270 // Close timeline before we do anything (this closes all clips)
1271 bool was_open = is_open;
1272 Close();
1273
1274 // Set parent data
1275 ReaderBase::SetJsonValue(root);
1276
1277 // Set data from Json (if key is found)
1278 if (!root["path"].isNull())
1279 path = root["path"].asString();
1280
1281 if (!root["clips"].isNull()) {
1282 // Clear existing clips
1283 clips.clear();
1284
1285 // loop through clips
1286 for (const Json::Value existing_clip : root["clips"]) {
1287 // Skip NULL nodes
1288 if (existing_clip.isNull()) {
1289 continue;
1290 }
1291
1292 // Create Clip
1293 Clip *c = new Clip();
1294
1295 // Keep track of allocated clip objects
1296 allocated_clips.insert(c);
1297
1298 // When a clip is attached to an object, it searches for the object
1299 // on it's parent timeline. Setting the parent timeline of the clip here
1300 // allows attaching it to an object when exporting the project (because)
1301 // the exporter script initializes the clip and it's effects
1302 // before setting its parent timeline.
1303 c->ParentTimeline(this);
1304
1305 // Load Json into Clip
1306 c->SetJsonValue(existing_clip);
1307
1308 // Add Clip to Timeline
1309 AddClip(c);
1310 }
1311 }
1312
1313 if (!root["effects"].isNull()) {
1314 // Clear existing effects
1315 effects.clear();
1316
1317 // loop through effects
1318 for (const Json::Value existing_effect :root["effects"]) {
1319 // Skip NULL nodes
1320 if (existing_effect.isNull()) {
1321 continue;
1322 }

Callers 3

apply_json_to_clipsMethod · 0.45
apply_json_to_effectsMethod · 0.45

Calls 5

CreateEffectMethod · 0.80
ToFloatMethod · 0.80
EffectInfoClass · 0.70
clearMethod · 0.45
ParentTimelineMethod · 0.45

Tested by

no test coverage detected