X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fdocclipbase.cpp;h=3c6620ccd721f0a1c2814ce276e3a1773d14ae9e;hb=7fff167fb95bb6b13b138b8d3f7b68da8a030473;hp=15b4d92b170b1758f18cfd1256b30eadb0341bb3;hpb=0dc5db505f705ff5e9b8aacce87a3e7e1b3b05dc;p=kdenlive diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index 15b4d92b..3c6620cc 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -22,12 +22,11 @@ #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++) { @@ -38,7 +37,9 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, uint id): 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(); @@ -49,18 +50,7 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, uint id): //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(); @@ -69,10 +59,11 @@ DocClipBase & DocClipBase::operator=(const DocClipBase & clip) { 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() { @@ -110,11 +101,11 @@ const QString & DocClipBase::name() const { 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; } @@ -135,24 +126,29 @@ KUrl DocClipBase::fileURL() const { 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 { @@ -161,7 +157,7 @@ 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; @@ -237,9 +233,6 @@ void DocClipBase::setAudioThumbCreated(bool isDone) { } -QDomDocument DocClipBase::generateSceneList(bool, bool) const { -} - void DocClipBase::setThumbnail(const QPixmap & pixmap) { m_thumbnail = pixmap; } @@ -366,22 +359,106 @@ QString DocClipBase::markerComment(GenTime t) { 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 properties) { // changing clip type is not allowed properties.remove("type"); QMapIterator 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 DocClipBase::properties() const {