31 #ifndef OPENSHOT_TIMELINE_H
32 #define OPENSHOT_TIMELINE_H
38 #include <QtGui/QImage>
39 #include <QtGui/QPainter>
40 #include <QtCore/QRegularExpression>
172 std::list<openshot::Clip*> clips;
173 std::list<openshot::Clip*> closing_clips;
174 std::map<openshot::Clip*, openshot::Clip*> open_clips;
175 std::list<openshot::EffectBase*> effects;
177 std::set<openshot::FrameMapper*> allocated_frame_mappers;
180 std::mutex get_frame_mutex;
181 int max_concurrent_frames;
183 std::map<std::string, std::shared_ptr<openshot::TrackedObjectBase>> tracked_objects;
186 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);
192 void apply_json_to_clips(Json::Value change);
193 void apply_json_to_effects(Json::Value change);
195 void apply_json_to_timeline(Json::Value change);
206 std::vector<openshot::Clip*> find_intersecting_clips(int64_t requested_frame,
int number_of_frames,
bool include);
212 bool isEqual(
double a,
double b);
245 Timeline(
const std::string& projectPath,
bool convert_absolute_paths);
250 void AddTrackedObject(std::shared_ptr<openshot::TrackedObjectBase> trackedObject);
252 std::shared_ptr<openshot::TrackedObjectBase>
GetTrackedObject(std::string
id)
const;
269 std::shared_ptr<openshot::Frame>
apply_effects(std::shared_ptr<openshot::Frame> frame, int64_t timeline_frame_number,
int layer);
284 std::list<openshot::Clip*>
Clips() {
return clips; };
301 void Close()
override;
304 std::list<openshot::EffectBase*>
Effects() {
return effects; };
307 std::list<openshot::EffectBase*>
ClipEffects()
const;
320 std::shared_ptr<openshot::Frame>
GetFrame(int64_t requested_frame)
override;
331 bool IsOpen()
override {
return is_open; };
334 std::string
Name()
override {
return "Timeline"; };
337 std::string
Json()
const override;
338 void SetJson(
const std::string value)
override;
353 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.
openshot::CacheBase * GetCache() override
Get the cache object used by this reader.
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.
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
std::list< openshot::EffectBase * > Effects()
Return the list of effects on the timeline.
bool AutoMapClips()
Determine if clips are automatically mapped to the timeline's framerate and samplerate.
void ClearAllCache()
Clear all cache for this timeline instance, and all clips, mappers, and readers under it.
void ApplyMapperToClips()
Apply the timeline's framerate and samplerate to all clips.
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.
Timeline(int width, int height, openshot::Fraction fps, int sample_rate, int channels, openshot::ChannelLayout channel_layout)
Constructor for the timeline (which configures the default frame properties)
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 AddEffect(openshot::EffectBase *effect)
Add an effect to the timeline.
std::shared_ptr< openshot::Frame > apply_effects(std::shared_ptr< openshot::Frame > frame, int64_t timeline_frame_number, int layer)
Apply global/timeline effects to the source frame (if any)
void SetCache(openshot::CacheBase *new_cache)
std::list< openshot::Clip * > Clips()
Return a list of clips on the timeline.
bool IsOpen() override
Determine if reader is open or closed.
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.
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.