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

Method update_open_clips

src/Timeline.cpp:745–788  ·  view source on GitHub ↗

Update the list of 'opened' clips

Source from the content-addressed store, hash-verified

743
744// Update the list of 'opened' clips
745void Timeline::update_open_clips(Clip *clip, bool does_clip_intersect)
746{
747 // Get lock (prevent getting frames while this happens)
748 const std::lock_guard<std::recursive_mutex> guard(getFrameMutex);
749
750 ZmqLogger::Instance()->AppendDebugMethod(
751 "Timeline::update_open_clips (before)",
752 "does_clip_intersect", does_clip_intersect,
753 "closing_clips.size()", closing_clips.size(),
754 "open_clips.size()", open_clips.size());
755
756 // is clip already in list?
757 bool clip_found = open_clips.count(clip);
758
759 if (clip_found && !does_clip_intersect)
760 {
761 // Remove clip from 'opened' list, because it's closed now
762 open_clips.erase(clip);
763
764 // Close clip
765 clip->Close();
766 }
767 else if (!clip_found && does_clip_intersect)
768 {
769 // Add clip to 'opened' list, because it's missing
770 open_clips[clip] = clip;
771
772 try {
773 // Open the clip
774 clip->Open();
775
776 } catch (const InvalidFile & e) {
777 // ...
778 }
779 }
780
781 // Debug output
782 ZmqLogger::Instance()->AppendDebugMethod(
783 "Timeline::update_open_clips (after)",
784 "does_clip_intersect", does_clip_intersect,
785 "clip_found", clip_found,
786 "closing_clips.size()", closing_clips.size(),
787 "open_clips.size()", open_clips.size());
788}
789
790// Calculate the max and min duration (in seconds) of the timeline, based on all the clips, and cache the value
791void Timeline::calculate_max_duration() {

Callers

nothing calls this directly

Calls 3

AppendDebugMethodMethod · 0.80
CloseMethod · 0.45
OpenMethod · 0.45

Tested by

no test coverage detected