#include "kthumb.h"
#include "clipmanager.h"
-DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, uint id):
- m_id(id), m_description(QString()), m_refcount(0), m_projectThumbFrame(0), m_audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL) {
+DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id):
+ m_id(id), m_description(QString()), m_refcount(0), m_audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL), m_clipProducer(NULL) {
int type = xml.attribute("type").toInt();
m_clipType = (CLIPTYPE) type;
m_name = xml.attribute("name");
- m_id = id;
QDomNamedNodeMap attributes = xml.attributes();
for (unsigned int i = 0; i < attributes.count(); i++) {
int out = xml.attribute("out").toInt();
if (out != 0) {
setDuration(GenTime(out, KdenliveSettings::project_fps()));
- //m_properties.insert("out", QString::number(out));
+ } else {
+ out = xml.attribute("duration").toInt();
+ if (out != 0) setDuration(GenTime(out, KdenliveSettings::project_fps()));
}
if (m_name.isEmpty()) m_name = url.fileName();
//kDebug() << "type is video" << (m_clipType == AV) << " " << m_clipType;
}
-
-
-DocClipBase::DocClipBase(const DocClipBase& clip) {
- m_id = clip.getId();
- m_clipType = clip.clipType();
- m_name = clip.name();
- m_duration = clip.duration();
- m_audioThumbCreated = clip.audioThumbCreated();
- m_properties = clip.properties();
-}
-
-DocClipBase & DocClipBase::operator=(const DocClipBase & clip) {
+/*DocClipBase & DocClipBase::operator=(const DocClipBase & clip) {
DocClipBase::operator=(clip);
m_id = clip.getId();
m_clipType = clip.clipType();
m_audioThumbCreated = clip.audioThumbCreated();
m_properties = clip.properties();
return *this;
-}
+}*/
DocClipBase::~DocClipBase() {
if (m_thumbProd) delete m_thumbProd;
+ if (m_clipProducer) delete m_clipProducer;
}
void DocClipBase::slotCreateAudioTimer() {
return m_name;
}
-uint DocClipBase::getId() const {
+const QString &DocClipBase::getId() const {
return m_id;
}
-void DocClipBase::setId(const uint &newId) {
+void DocClipBase::setId(const QString &newId) {
m_id = newId;
}
void DocClipBase::setClipType(CLIPTYPE type) {
m_clipType = type;
+ m_properties.insert("type", QString::number((int) type));
if (m_thumbProd && m_audioTimer == NULL && (m_clipType == AV || m_clipType == AUDIO))
slotCreateAudioTimer();
}
return KUrl();
}
-void DocClipBase::setProjectThumbFrame(const uint &ix) {
- m_projectThumbFrame = ix;
+void DocClipBase::setClipThumbFrame(const uint &ix) {
+ m_properties.insert("thumbnail", QString::number((int) ix));
}
-uint DocClipBase::getProjectThumbFrame() const {
- return m_projectThumbFrame;
+uint DocClipBase::getClipThumbFrame() const {
+ return (uint) m_properties.value("thumbnail").toInt();
}
const QString DocClipBase::description() const {
return m_properties.value("description");
}
+bool DocClipBase::isTransparent() const {
+ return (m_properties.value("transparency") == "1");
+}
+
const QString DocClipBase::getProperty(const QString prop) const {
return m_properties.value(prop);
}
void DocClipBase::setDuration(GenTime dur) {
m_duration = dur;
+ m_properties.insert("duration", QString::number((int) dur.frames(KdenliveSettings::project_fps())));
}
const GenTime &DocClipBase::duration() const {
const GenTime &DocClipBase::maxDuration() const {
if (m_clipType == COLOR || m_clipType == IMAGE || m_clipType == TEXT || (m_clipType == SLIDESHOW && m_properties.value("loop") == "1")) {
- GenTime dur(10000, KdenliveSettings::project_fps());
+ const GenTime dur(10000, KdenliveSettings::project_fps());
return dur;
}
return m_duration;
node.normalize();
if (element.tagName() != "kdenliveclip") {
kWarning() <<
- "DocClipBase::createClip() element has unknown tagName : " <<
- element.tagName() << endl;
+ "DocClipBase::createClip() element has unknown tagName : " << element.tagName();
return 0;
}
n = n.nextSibling();
}
if (clip == 0) {
- kWarning() << "DocClipBase::createClip() unable to create clip" <<
- endl;
+ kWarning() << "DocClipBase::createClip() unable to create clip";
} else {
// setup DocClipBase specifics of the clip.
QMap <QString, QString> props;
}
-QDomDocument DocClipBase::generateSceneList(bool, bool) const {
-}
-
void DocClipBase::setThumbnail(const QPixmap & pixmap) {
m_thumbnail = pixmap;
}
}
if ((it != m_snapMarkers.end()) && ((*it).time() == time)) {
- kError() <<
- "trying to add Snap Marker that already exists, this will cause inconsistancies with undo/redo"
- << endl;
+ (*it).setComment(comment);
+ //kError() << "trying to add Snap Marker that already exists, this will cause inconsistancies with undo/redo";
} else {
CommentedTime t(time, comment);
m_snapMarkers.insert(it, t);
if (it != m_snapMarkers.end()) {
(*it).setComment(comment);
} else {
- kError() <<
- "trying to edit Snap Marker that does not already exists" << endl;
+ kError() << "trying to edit Snap Marker that does not already exists";
}
}
return QString::null;
}
+void DocClipBase::setProducer(Mlt::Producer *producer) {
+ m_clipProducer = producer;
+ m_clipProducer->set("transparency", m_properties.value("transparency").toInt());
+ if (m_thumbProd) m_thumbProd->setProducer(producer);
+}
+
+Mlt::Producer *DocClipBase::producer() {
+ return m_clipProducer;
+}
+
+void DocClipBase::slotRefreshProducer() {
+ if (m_clipProducer == NULL) return;
+ kDebug() << "//////////// REFRESH CLIP !!!!!!!!!!!!!!!!";
+ if (m_clipType == SLIDESHOW) {
+ /*char *tmp = (char *) qstrdup(getProperty("resource").toUtf8().data());
+ Mlt::Producer producer(*(m_clipProducer->profile()), tmp);
+ delete[] tmp;
+ delete m_clipProducer;
+ m_clipProducer = new Mlt::Producer(producer.get_producer());
+ if (!getProperty("out").isEmpty()) m_clipProducer->set_in_and_out(getProperty("in").toInt(), getProperty("out").toInt());*/
+ m_clipProducer->set("ttl", getProperty("ttl").toInt());
+ //m_clipProducer->set("id", getProperty("id"));
+ if (getProperty("fade") == "1") {
+ // we want a fade filter effect
+ kDebug() << "//////////// FADE WANTED";
+ Mlt::Service clipService(m_clipProducer->get_service());
+ int ct = 0;
+ Mlt::Filter *filter = clipService.filter(ct);
+ while (filter) {
+ if (filter->get("mlt_service") == "luma") {
+ break;
+ }
+ ct++;
+ filter = clipService.filter(ct);
+ }
+
+ if (filter && filter->get("mlt_service") == "luma") {
+ filter->set("period", getProperty("ttl").toInt() - 1);
+ filter->set("luma.out", getProperty("luma_duration").toInt());
+ QString resource = getProperty("luma_file");
+ char *tmp = (char *) qstrdup(resource.toUtf8().data());
+ filter->set("luma.resource", tmp);
+ delete[] tmp;
+ if (getProperty("softness") != QString()) {
+ int soft = getProperty("softness").toInt();
+ filter->set("luma.softness", (double) soft / 100.0);
+ }
+ } else {
+ // filter does not exist, create it...
+ Mlt::Filter *filter = new Mlt::Filter(*(m_clipProducer->profile()), "luma");
+ filter->set("period", getProperty("ttl").toInt() - 1);
+ filter->set("luma.out", getProperty("luma_duration").toInt());
+ QString resource = getProperty("luma_file");
+ char *tmp = (char *) qstrdup(resource.toUtf8().data());
+ filter->set("luma.resource", tmp);
+ delete[] tmp;
+ if (getProperty("softness") != QString()) {
+ int soft = getProperty("softness").toInt();
+ filter->set("luma.softness", (double) soft / 100.0);
+ }
+ clipService.attach(*filter);
+ }
+ } else {
+ kDebug() << "//////////// FADE NOT WANTED!!!";
+ Mlt::Service clipService(m_clipProducer->get_service());
+ int ct = 0;
+ Mlt::Filter *filter = clipService.filter(0);
+ while (filter) {
+ if (filter->get("mlt_service") == "luma") {
+ clipService.detach(*filter);
+ } else ct++;
+ filter = clipService.filter(ct);
+ }
+ }
+ }
+}
+
void DocClipBase::setProperties(QMap <QString, QString> properties) {
// changing clip type is not allowed
properties.remove("type");
QMapIterator<QString, QString> i(properties);
+ bool refreshProducer = false;
+ QStringList keys;
+ keys << "luma_duration" << "luma_file" << "fade" << "ttl" << "softness";
while (i.hasNext()) {
i.next();
m_properties.insert(i.key(), i.value());
if (i.key() == "resource") m_thumbProd->updateClipUrl(KUrl(i.value()));
else if (i.key() == "out") setDuration(GenTime(i.value().toInt(), KdenliveSettings::project_fps()));
+ else if (m_clipType == SLIDESHOW && keys.contains(i.key())) refreshProducer = true;
+ else if (i.key() == "transparency") m_clipProducer->set("transparency", i.value().toInt());
}
+ if (refreshProducer) slotRefreshProducer();
}
void DocClipBase::setProperty(QString key, QString value) {
m_properties.insert(key, value);
if (key == "resource") m_thumbProd->updateClipUrl(KUrl(value));
else if (key == "out") setDuration(GenTime(value.toInt(), KdenliveSettings::project_fps()));
+ else if (key == "transparency") m_clipProducer->set("transparency", value.toInt());
}
QMap <QString, QString> DocClipBase::properties() const {