Loading...
Searching...
No Matches
ClipBase.h
Go to the documentation of this file.
// Copyright (c) 2008-2019 OpenShot Studios, LLC
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#ifndef OPENSHOT_CLIPBASE_H
#define OPENSHOT_CLIPBASE_H
#include <memory>
#include "CacheMemory.h"
#include "Frame.h"
#include "KeyFrame.h"
#include "IdGenerator.h"
#include "Json.h"
#include "TimelineBase.h"
namespace openshot {
class ClipBase {
protected:
std::string id;
float position;
int layer;
float start;
float end;
std::string previous_properties;
openshot::TimelineBase* timeline;
Json::Value add_property_json(std::string name, float value, std::string type, std::string memo, const Keyframe* keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame) const;
Json::Value add_property_choice_json(std::string name, int value, int selected_value) const;
public:
ClipBase() :
id(IdGenerator::Generate()),
position(0.0),
layer(0),
start(0.0),
end(0.0),
previous_properties(""),
timeline(nullptr) {}
// Compare a clip using the Position() property
bool operator< ( ClipBase& a) { return (Position() < a.Position()); }
bool operator<= ( ClipBase& a) { return (Position() <= a.Position()); }
bool operator> ( ClipBase& a) { return (Position() > a.Position()); }
bool operator>= ( ClipBase& a) { return (Position() >= a.Position()); }
virtual std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number) = 0;
virtual std::shared_ptr<openshot::Frame> GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number) = 0;
// Get basic properties
std::string Id() const { return id; }
float Position() const { return position; }
int Layer() const { return layer; }
float Start() const { return start; }
virtual float End() const { return end; }
float Duration() const { return end - start; }
virtual openshot::TimelineBase* ParentTimeline() { return timeline; }
// Set basic properties
void Id(std::string value) { id = value; }
void Position(float value);
void Layer(int value);
void Start(float value);
virtual void End(float value);
virtual void ParentTimeline(openshot::TimelineBase* new_timeline) { timeline = new_timeline; }
// Get and Set JSON methods
virtual std::string Json() const = 0;
virtual void SetJson(const std::string value) = 0;
virtual Json::Value JsonValue() const = 0;
virtual void SetJsonValue(const Json::Value root) = 0;
virtual std::string PropertiesJSON(int64_t requested_frame) const = 0;
virtual ~ClipBase() = default;
};
}
#endif
CacheMemory.h
Header file for CacheMemory class.
Frame.h
Header file for Frame class.
IdGenerator.h
Json.h
Header file for JSON class.
KeyFrame.h
Header file for the Keyframe class.
TimelineBase.h
Header file for Timeline class.
openshot::ClipBase::Start
float Start() const
Get start position (in seconds) of clip (trim start of video).
Definition ClipBase.h:88
openshot::ClipBase::start
float start
The position in seconds to start playing (used to trim the beginning of a clip).
Definition ClipBase.h:37
openshot::ClipBase::Duration
float Duration() const
Get the length of this clip (in seconds).
Definition ClipBase.h:90
openshot::ClipBase::GetFrame
virtual std::shared_ptr< openshot::Frame > GetFrame(int64_t frame_number)=0
This method is required for all derived classes of ClipBase, and returns a new openshot::Frame object...
openshot::ClipBase::End
virtual float End() const
Get end position (in seconds) of clip (trim end of video).
Definition ClipBase.h:89
openshot::ClipBase::Json
virtual std::string Json() const =0
Generate JSON string of this object.
openshot::ClipBase::PropertiesJSON
virtual std::string PropertiesJSON(int64_t requested_frame) const =0
openshot::ClipBase::operator>=
bool operator>=(ClipBase &a)
Definition ClipBase.h:63
openshot::ClipBase::Id
std::string Id() const
Get the Id of this clip object.
Definition ClipBase.h:85
openshot::ClipBase::JsonValue
virtual Json::Value JsonValue() const =0
Generate Json::Value for this object.
Definition ClipBase.cpp:64
openshot::ClipBase::add_property_choice_json
Json::Value add_property_choice_json(std::string name, int value, int selected_value) const
Generate JSON choice for a property (dropdown properties).
Definition ClipBase.cpp:132
openshot::ClipBase::Id
void Id(std::string value)
Definition ClipBase.h:94
openshot::ClipBase::GetFrame
virtual std::shared_ptr< openshot::Frame > GetFrame(std::shared_ptr< openshot::Frame > frame, int64_t frame_number)=0
This method is required for all derived classes of ClipBase, and returns a modified openshot::Frame o...
openshot::ClipBase::operator<=
bool operator<=(ClipBase &a)
Definition ClipBase.h:61
openshot::ClipBase::Layer
int Layer() const
Get layer of clip on timeline (lower number is covered by higher numbers).
Definition ClipBase.h:87
openshot::ClipBase::ClipBase
ClipBase()
Constructor for the base clip.
Definition ClipBase.h:50
openshot::ClipBase::SetJsonValue
virtual void SetJsonValue(const Json::Value root)=0
Load Json::Value into this object.
Definition ClipBase.cpp:80
openshot::ClipBase::timeline
openshot::TimelineBase * timeline
Pointer to the parent timeline instance (if any).
Definition ClipBase.h:40
openshot::ClipBase::layer
int layer
The layer this clip is on. Lower clips are covered up by higher clips.
Definition ClipBase.h:36
openshot::ClipBase::Position
float Position() const
Get position on timeline (in seconds).
Definition ClipBase.h:86
openshot::ClipBase::ParentTimeline
virtual openshot::TimelineBase * ParentTimeline()
Get the associated Timeline pointer (if any).
Definition ClipBase.h:91
openshot::ClipBase::operator>
bool operator>(ClipBase &a)
Definition ClipBase.h:62
openshot::ClipBase::id
std::string id
ID Property for all derived Clip and Effect classes.
Definition ClipBase.h:34
openshot::ClipBase::ParentTimeline
virtual void ParentTimeline(openshot::TimelineBase *new_timeline)
Set associated Timeline pointer.
Definition ClipBase.h:99
openshot::ClipBase::position
float position
The position on the timeline where this clip should start playing.
Definition ClipBase.h:35
openshot::ClipBase::SetJson
virtual void SetJson(const std::string value)=0
Load JSON string into this object.
openshot::ClipBase::end
float end
The position in seconds to end playing (used to trim the ending of a clip).
Definition ClipBase.h:38
openshot::ClipBase::operator<
bool operator<(ClipBase &a)
Definition ClipBase.h:60
openshot::ClipBase::~ClipBase
virtual ~ClipBase()=default
openshot::ClipBase::previous_properties
std::string previous_properties
This string contains the previous JSON properties.
Definition ClipBase.h:39
openshot::ClipBase::add_property_json
Json::Value add_property_json(std::string name, float value, std::string type, std::string memo, const Keyframe *keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame) const
Generate JSON for a property.
Definition ClipBase.cpp:96
openshot::IdGenerator
Definition IdGenerator.h:18
openshot::Keyframe
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition KeyFrame.h:53
openshot::TimelineBase
This class represents a timeline (used for building generic timeline implementations).
Definition TimelineBase.h:41
openshot
This namespace is the default namespace for all code in the openshot library.
Definition Compressor.h:29