13#ifndef OPENSHOT_TIMELINE_H
14#define OPENSHOT_TIMELINE_H
20#include <QtGui/QImage>
21#include <QtGui/QPainter>
22#include <QtCore/QRegularExpression>
152 std::list<openshot::Clip*> clips;
153 std::list<openshot::Clip*> closing_clips;
154 std::map<openshot::Clip*, openshot::Clip*> open_clips;
155 std::set<openshot::Clip*> allocated_clips;
156 std::list<openshot::EffectBase*> effects;
157 std::set<openshot::EffectBase*> allocated_effects;
159 std::set<openshot::FrameMapper*> allocated_frame_mappers;
162 int max_concurrent_frames;
165 std::map<std::string, std::shared_ptr<openshot::TrackedObjectBase>> tracked_objects;
168 void add_layer(std::shared_ptr<openshot::Frame> new_frame,
openshot::Clip* source_clip, int64_t clip_frame_number,
bool is_top_clip,
float max_volume);
174 void apply_json_to_clips(Json::Value change);
175 void apply_json_to_effects(Json::Value change);
177 void apply_json_to_timeline(Json::Value change);
180 void calculate_max_duration();
191 std::vector<openshot::Clip*> find_intersecting_clips(int64_t requested_frame,
int number_of_frames,
bool include);
197 bool isEqual(
double a,
double b);
230 Timeline(
const std::string& projectPath,
bool convert_absolute_paths);
235 void AddTrackedObject(std::shared_ptr<openshot::TrackedObjectBase> trackedObject);
237 std::shared_ptr<openshot::TrackedObjectBase>
GetTrackedObject(std::string
id)
const;
254 std::shared_ptr<openshot::Frame>
apply_effects(std::shared_ptr<openshot::Frame> frame, int64_t timeline_frame_number,
int layer,
TimelineInfoStruct* options);
273 std::list<openshot::Clip*>
Clips()
override {
return clips; };
290 void Close()
override;
293 std::list<openshot::EffectBase*>
Effects() {
return effects; };
296 std::list<openshot::EffectBase*>
ClipEffects()
const;
309 std::shared_ptr<openshot::Frame>
GetFrame(int64_t requested_frame)
override;
320 bool IsOpen()
override {
return is_open; };
323 std::string
Name()
override {
return "Timeline"; };
326 std::string
Json()
const override;
327 void SetJson(
const std::string value)
override;
342 void Open()
override;
Header file for Clip class.
Header file for Color class.
Header file for EffectBase class.
Header file for Fraction class.
Header file for Frame class.
Header file for the Keyframe class.
Header file for ReaderBase class.
Header file for Timeline class.
Header file for the TrackedObjectBBox class.
Header file for the TrackedObjectBase class.
All cache managers in libopenshot are based on this CacheBase class.
float Duration() const
Get the length of this clip (in seconds)
int Layer() const
Get layer of clip on timeline (lower number is covered by higher numbers)
float Position() const
Get position on timeline (in seconds)
This class represents a clip (used to arrange readers on the timeline)
This class represents a color (used on the timeline and clips)
This abstract class is the base class, used by all effects in libopenshot.
int Order() const
Get the order that this effect should be executed.
This class represents a fraction.
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
This abstract class is the base class, used by all readers in libopenshot.
openshot::ReaderInfo info
Information about the current media file.
openshot::ClipBase * clip
Pointer to the parent clip instance (if any)
This class represents a timeline (used for building generic timeline implementations)
This class represents a timeline.
void AddTrackedObject(std::shared_ptr< openshot::TrackedObjectBase > trackedObject)
Add to the tracked_objects map a pointer to a tracked object (TrackedObjectBBox)
Json::Value JsonValue() const override
Generate Json::Value for this object.
std::string Name() override
Return the type name of the class.
openshot::Keyframe viewport_scale
Curve representing the scale of the viewport (0 to 100)
void ApplyJsonDiff(std::string value)
Apply a special formatted JSON object, which represents a change to the timeline (add,...
openshot::EffectBase * GetClipEffect(const std::string &id)
Look up a clip effect by ID.
void AddClip(openshot::Clip *clip)
Add an openshot::Clip to the timeline.
std::list< openshot::EffectBase * > ClipEffects() const
Return the list of effects on all clips.
void AutoMapClips(bool auto_map)
Automatically map all clips to the timeline's framerate and samplerate.
std::list< std::string > GetTrackedObjectsIds() const
Return the ID's of the tracked objects as a list of strings.
std::string Json() const override
Generate JSON string of this object.
std::list< openshot::EffectBase * > Effects()
Return the list of effects on the timeline.
int64_t GetMaxFrame()
Look up the end frame number of the latest element on the timeline.
std::shared_ptr< openshot::Frame > GetFrame(int64_t requested_frame) override
bool AutoMapClips()
Determine if clips are automatically mapped to the timeline's framerate and samplerate.
void ApplyMapperToClips()
Apply the timeline's framerate and samplerate to all clips.
void SortTimeline()
Sort all clips and effects on timeline - which affects the internal order of clips and effects arrays...
openshot::Color color
Background color of timeline canvas.
std::string GetTrackedObjectValues(std::string id, int64_t frame_number) const
Return the trackedObject's properties as a JSON string.
std::shared_ptr< openshot::TrackedObjectBase > GetTrackedObject(std::string id) const
Return tracked object pointer by it's id.
openshot::EffectBase * GetEffect(const std::string &id)
Look up a timeline effect by ID.
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
openshot::Clip * GetClip(const std::string &id)
Look up a single clip by ID.
void ClearAllCache(bool deep=false)
void AddEffect(openshot::EffectBase *effect)
Add an effect to the timeline.
std::list< openshot::Clip * > Clips() override
Return a list of clips on the timeline.
void SetCache(openshot::CacheBase *new_cache)
bool IsOpen() override
Determine if reader is open or closed.
openshot::CacheBase * GetCache() override
Get the cache object used by this reader.
void Clear()
Clear all clips, effects, and frame mappers from timeline (and free memory)
openshot::Keyframe viewport_x
Curve representing the x coordinate for the viewport.
void RemoveClip(openshot::Clip *clip)
Remove an openshot::Clip from the timeline.
void SetMaxSize(int width, int height)
double GetMaxTime()
Look up the end time of the latest timeline element.
void RemoveEffect(openshot::EffectBase *effect)
Remove an effect from the timeline.
std::shared_ptr< openshot::Frame > apply_effects(std::shared_ptr< openshot::Frame > frame, int64_t timeline_frame_number, int layer, TimelineInfoStruct *options)
Apply global/timeline effects to the source frame (if any)
void Open() override
Open the reader (and start consuming resources)
void SetJson(const std::string value) override
Load JSON string into this object.
openshot::Keyframe viewport_y
Curve representing the y coordinate for the viewport.
void Close() override
Close the timeline reader (and any resources it was consuming)
This namespace is the default namespace for all code in the openshot library.
ChannelLayout
This enumeration determines the audio channel layout (such as stereo, mono, 5 point surround,...
bool operator()(const openshot::Clip *lhs, const openshot::Clip *rhs)
bool operator()(openshot::Clip *lhs, openshot::Clip *rhs)
Like CompareClipEndFrames, but for effects.
bool operator()(const openshot::EffectBase *lhs, const openshot::EffectBase *rhs)
bool operator()(openshot::EffectBase *lhs, openshot::EffectBase *rhs)
This struct contains info about a media file, such as height, width, frames per second,...
This struct contains info about the current Timeline clip instance.