X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fdocclipbase.cpp;h=87194e0f33ce4cc904329b78a17e44e50bfc5fac;hb=e3b4bf11679a3a195be8896f465b1616581f1fb3;hp=181a4d913f65966413f1fe7f53d78535a2ddd2e6;hpb=a5ddf353ef63b4b8fbf171f27c1c6e7c768bd156;p=kdenlive diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index 181a4d91..87194e0f 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -28,33 +28,48 @@ #include "kdenlivesettings.h" #include "kthumb.h" #include "clipmanager.h" +#include "slideshowclip.h" +#include #include #include -DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id, bool placeHolder) : +#include + +DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id) : QObject(), m_audioFrameCache(), m_refcount(0), m_baseTrackProducers(), m_audioTrackProducers(), m_videoOnlyProducer(NULL), - m_snapMarkers(), + m_snapMarkers(QList < CommentedTime >()), m_duration(), m_audioTimer(NULL), m_thumbProd(NULL), m_audioThumbCreated(false), m_id(id), - m_placeHolder(placeHolder), + m_placeHolder(xml.hasAttribute("placeholder")), m_properties() { int type = xml.attribute("type").toInt(); m_clipType = (CLIPTYPE) type; - + if (m_placeHolder) xml.removeAttribute("placeholder"); QDomNamedNodeMap attributes = xml.attributes(); for (int i = 0; i < attributes.count(); i++) { - m_properties.insert(attributes.item(i).nodeName(), attributes.item(i).nodeValue()); + QString name = attributes.item(i).nodeName(); + if (name.startsWith("meta.attr.")) { + m_metadata.insert(name.section('.', 2, 3), attributes.item(i).nodeValue()); + } else m_properties.insert(name, attributes.item(i).nodeValue()); + } + + if (xml.hasAttribute("cutzones")) { + QStringList cuts = xml.attribute("cutzones").split(";", QString::SkipEmptyParts); + for (int i = 0; i < cuts.count(); i++) { + QString z = cuts.at(i); + addCutZone(z.section('-', 0, 0).toInt(), z.section('-', 1, 1).toInt(), z.section('-', 2, 2)); + } } KUrl url = KUrl(xml.attribute("resource")); @@ -73,7 +88,7 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QStrin //if (!url.isEmpty() && QFile::exists(url.path())) { m_thumbProd = new KThumb(clipManager, url, m_id, m_properties.value("file_hash")); - if (m_clipType == AV || m_clipType == AUDIO) slotCreateAudioTimer(); + if (m_clipType == AV || m_clipType == AUDIO || m_clipType == PLAYLIST) slotCreateAudioTimer(); } //kDebug() << "type is video" << (m_clipType == AV) << " " << m_clipType; } @@ -91,11 +106,14 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QStrin DocClipBase::~DocClipBase() { + kDebug() << "CLIP " << m_id << " DELETED******************************"; delete m_thumbProd; if (m_audioTimer) { m_audioTimer->stop(); delete m_audioTimer; } + /*kDebug() <<" * * *CNT "< 0) kDebug()<<"YOYO: "<get_out()<<", CUT: "<is_cut();*/ qDeleteAll(m_baseTrackProducers); m_baseTrackProducers.clear(); qDeleteAll(m_audioTrackProducers); @@ -112,23 +130,20 @@ void DocClipBase::setZone(QPoint zone) QPoint DocClipBase::zone() const { - QPoint zone; - zone.setX(m_properties.value("zone_in").toInt()); - zone.setY(m_properties.value("zone_out", "50").toInt()); + QPoint zone(m_properties.value("zone_in", "0").toInt(), m_properties.value("zone_out", "50").toInt()); return zone; } void DocClipBase::slotCreateAudioTimer() { connect(m_thumbProd, SIGNAL(audioThumbReady(QMap >)), this , SLOT(updateAudioThumbnail(QMap >))); - connect(this, SIGNAL(getAudioThumbs()), this , SLOT(slotGetAudioThumbs())); m_audioTimer = new QTimer(this); connect(m_audioTimer, SIGNAL(timeout()), this, SLOT(slotGetAudioThumbs())); } void DocClipBase::askForAudioThumbs() { - if (m_thumbProd) m_thumbProd->askForAudioThumbs(getId()); + if (m_thumbProd && m_audioTimer) m_thumbProd->askForAudioThumbs(getId()); } void DocClipBase::slotClearAudioCache() @@ -179,7 +194,7 @@ 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)) + if (m_thumbProd && m_audioTimer == NULL && (m_clipType == AV || m_clipType == AUDIO || m_clipType == PLAYLIST)) slotCreateAudioTimer(); } @@ -229,8 +244,9 @@ 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")) { - const GenTime dur(15000, KdenliveSettings::project_fps()); - return dur; + /*const GenTime dur(15000, KdenliveSettings::project_fps()); + return dur;*/ + return GenTime(); } return m_duration; } @@ -240,6 +256,10 @@ bool DocClipBase::hasFileSize() const return true; } +qulonglong DocClipBase::fileSize() const +{ + return m_properties.value("file_size").toULongLong(); +} // virtual QDomElement DocClipBase::toXML() const @@ -253,7 +273,15 @@ QDomElement DocClipBase::toXML() const if (!i.value().isEmpty()) clip.setAttribute(i.key(), i.value()); } doc.appendChild(clip); - //kDebug()<<"/// CLIP XML: "< > data) { - //kDebug() << "CLIPBASE RECIEDVED AUDIO DATA*********************************************"; + //kDebug() << "CLIPBASE RECIEDVED AUDIO DATA*********************************************"; m_audioFrameCache = data; m_audioThumbCreated = true; emit gotAudioData(); @@ -287,7 +315,7 @@ QList < GenTime > DocClipBase::snapMarkers() const QList < GenTime > markers; for (int count = 0; count < m_snapMarkers.count(); ++count) { - markers.append(m_snapMarkers[count].time()); + markers.append(m_snapMarkers.at(count).time()); } return markers; @@ -298,10 +326,6 @@ QList < CommentedTime > DocClipBase::commentedSnapMarkers() const return m_snapMarkers; } -void DocClipBase::setSnapMarkers(QList < CommentedTime > markers) -{ - m_snapMarkers = markers; -} void DocClipBase::addSnapMarker(const GenTime & time, QString comment) { @@ -371,23 +395,23 @@ GenTime DocClipBase::findPreviousSnapMarker(const GenTime & currTime) { int it; for (it = 0; it < m_snapMarkers.count(); it++) { - if (m_snapMarkers[it].time() >= currTime) + if (m_snapMarkers.at(it).time() >= currTime) break; } if (it == 0) return GenTime(); - else if (it == m_snapMarkers.count() - 1 && m_snapMarkers[it].time() < currTime) - return m_snapMarkers[it].time(); - else return m_snapMarkers[it-1].time(); + else if (it == m_snapMarkers.count() - 1 && m_snapMarkers.at(it).time() < currTime) + return m_snapMarkers.at(it).time(); + else return m_snapMarkers.at(it - 1).time(); } GenTime DocClipBase::findNextSnapMarker(const GenTime & currTime) { int it; for (it = 0; it < m_snapMarkers.count(); it++) { - if (m_snapMarkers[it].time() > currTime) + if (m_snapMarkers.at(it).time() > currTime) break; } - if (it < m_snapMarkers.count() && m_snapMarkers[it].time() > currTime) return m_snapMarkers[it].time(); + if (it < m_snapMarkers.count() && m_snapMarkers.at(it).time() > currTime) return m_snapMarkers.at(it).time(); return duration(); } @@ -403,20 +427,50 @@ QString DocClipBase::markerComment(GenTime t) return QString(); } -void DocClipBase::deleteProducers() +void DocClipBase::clearProducers() { + m_baseTrackProducers.clear(); +} + +void DocClipBase::deleteProducers(bool clearThumbCreator) +{ + kDebug() << "// CLIP KILL PRODS ct: " << m_baseTrackProducers.count(); + if (clearThumbCreator && m_thumbProd) m_thumbProd->clearProducer(); + /*kDebug()<<"// CLIP KILL PRODS ct: "<clearProducer(); qDeleteAll(m_audioTrackProducers); m_audioTrackProducers.clear(); - delete m_videoOnlyProducer; - m_videoOnlyProducer = NULL; } -void DocClipBase::setProducer(Mlt::Producer *producer) +void DocClipBase::setValid() +{ + m_placeHolder = false; +} + +void DocClipBase::setProducer(Mlt::Producer *producer, bool reset) { - if (producer == NULL) return; + if (producer == NULL || (m_placeHolder && !reset)) return; + if (m_thumbProd && (reset || !m_thumbProd->hasProducer())) m_thumbProd->setProducer(producer); + if (reset) { + // Clear all previous producers + kDebug() << "/+++++++++++++++ DELETE ALL PRODS " << producer->get("id"); + deleteProducers(false); + } QString id = producer->get("id"); if (id.contains('_')) { // this is a subtrack producer, insert it at correct place @@ -430,8 +484,7 @@ void DocClipBase::setProducer(Mlt::Producer *producer) } if (m_audioTrackProducers.at(pos) == NULL) m_audioTrackProducers[pos] = producer; return; - } - if (id.endsWith("video")) { + } else if (id.endsWith("video")) { m_videoOnlyProducer = producer; return; } @@ -448,7 +501,6 @@ void DocClipBase::setProducer(Mlt::Producer *producer) } //m_clipProducer = producer; //m_clipProducer->set("transparency", m_properties.value("transparency").toInt()); - if (m_thumbProd && !m_thumbProd->hasProducer()) m_thumbProd->setProducer(producer); } Mlt::Producer *DocClipBase::audioProducer(int track) @@ -462,6 +514,8 @@ Mlt::Producer *DocClipBase::audioProducer(int track) Mlt::Producer *base = producer(); m_audioTrackProducers[track] = new Mlt::Producer(*(base->profile()), base->get("resource")); if (m_properties.contains("force_aspect_ratio")) m_audioTrackProducers.at(track)->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble()); + if (m_properties.contains("force_fps")) m_audioTrackProducers.at(track)->set("force_fps", m_properties.value("force_fps").toDouble()); + if (m_properties.contains("force_progressive")) m_audioTrackProducers.at(track)->set("force_progressive", m_properties.value("force_progressive").toInt()); if (m_properties.contains("threads")) m_audioTrackProducers.at(track)->set("threads", m_properties.value("threads").toInt()); m_audioTrackProducers.at(track)->set("video_index", -1); if (m_properties.contains("audio_index")) m_audioTrackProducers.at(track)->set("audio_index", m_properties.value("audio_index").toInt()); @@ -481,6 +535,8 @@ Mlt::Producer *DocClipBase::videoProducer() if (i >= m_baseTrackProducers.count()) return NULL; m_videoOnlyProducer = new Mlt::Producer(*m_baseTrackProducers.at(i)->profile(), m_baseTrackProducers.at(i)->get("resource")); if (m_properties.contains("force_aspect_ratio")) m_videoOnlyProducer->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble()); + if (m_properties.contains("force_fps")) m_videoOnlyProducer->set("force_fps", m_properties.value("force_fps").toDouble()); + if (m_properties.contains("force_progressive")) m_videoOnlyProducer->set("force_progressive", m_properties.value("force_progressive").toInt()); if (m_properties.contains("threads")) m_videoOnlyProducer->set("threads", m_properties.value("threads").toInt()); m_videoOnlyProducer->set("audio_index", -1); if (m_properties.contains("video_index")) m_videoOnlyProducer->set("video_index", m_properties.value("video_index").toInt()); @@ -515,12 +571,16 @@ Mlt::Producer *DocClipBase::producer(int track) if (m_baseTrackProducers.at(i) != NULL) break; if (i >= m_baseTrackProducers.count()) return NULL; - m_baseTrackProducers[track] = new Mlt::Producer(*m_baseTrackProducers.at(i)->profile(), m_baseTrackProducers.at(i)->get("resource")); - - // special case for placeholder clips - if (m_baseTrackProducers[track] == NULL) return NULL; + if (KIO::NetAccess::exists(KUrl(m_baseTrackProducers.at(i)->get("resource")), KIO::NetAccess::SourceSide, 0)) + m_baseTrackProducers[track] = new Mlt::Producer(*m_baseTrackProducers.at(i)->profile(), m_baseTrackProducers.at(i)->get("resource")); + else { // special case for placeholder clips + m_baseTrackProducers[track] = NULL; + return NULL; + } if (m_properties.contains("force_aspect_ratio")) m_baseTrackProducers[track]->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble()); + if (m_properties.contains("force_fps")) m_baseTrackProducers[track]->set("force_fps", m_properties.value("force_fps").toDouble()); + if (m_properties.contains("force_progressive")) m_baseTrackProducers[track]->set("force_progressive", m_properties.value("force_progressive").toInt()); if (m_properties.contains("threads")) m_baseTrackProducers[track]->set("threads", m_properties.value("threads").toInt()); if (m_properties.contains("video_index")) m_baseTrackProducers[track]->set("video_index", m_properties.value("video_index").toInt()); if (m_properties.contains("audio_index")) m_baseTrackProducers[track]->set("audio_index", m_properties.value("audio_index").toInt()); @@ -543,6 +603,14 @@ void DocClipBase::setProducerProperty(const char *name, int data) } } +void DocClipBase::setProducerProperty(const char *name, double data) +{ + for (int i = 0; i < m_baseTrackProducers.count(); i++) { + if (m_baseTrackProducers.at(i) != NULL) + m_baseTrackProducers[i]->set(name, data); + } +} + void DocClipBase::setProducerProperty(const char *name, const char *data) { for (int i = 0; i < m_baseTrackProducers.count(); i++) { @@ -551,6 +619,14 @@ void DocClipBase::setProducerProperty(const char *name, const char *data) } } +void DocClipBase::resetProducerProperty(const char *name) +{ + for (int i = 0; i < m_baseTrackProducers.count(); i++) { + if (m_baseTrackProducers.at(i) != NULL) + m_baseTrackProducers[i]->set(name, (const char*) NULL); + } +} + const char *DocClipBase::producerProperty(const char *name) const { for (int i = 0; i < m_baseTrackProducers.count(); i++) { @@ -575,6 +651,49 @@ void DocClipBase::slotRefreshProducer() if (!getProperty("out").isEmpty()) m_clipProducer->set_in_and_out(getProperty("in").toInt(), getProperty("out").toInt());*/ setProducerProperty("ttl", getProperty("ttl").toInt()); //m_clipProducer->set("id", getProperty("id")); + if (!getProperty("animation").isEmpty()) { + Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service()); + int ct = 0; + Mlt::Filter *filter = clipService.filter(ct); + while (filter) { + if (strcmp(filter->get("mlt_service"), "affine") == 0) { + break; + } + else if (strcmp(filter->get("mlt_service"), "boxblur") == 0) { + clipService.detach(*filter); + } else ct++; + filter = clipService.filter(ct); + } + + if (!filter || strcmp(filter->get("mlt_service"), "affine")) { + // filter does not exist, create it. + Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "affine"); + if (filter && filter->is_valid()) { + int cycle = getProperty("ttl").toInt(); + QString geometry = SlideshowClip::animationToGeometry(getProperty("animation"), cycle); + if (!geometry.isEmpty()) { + if (getProperty("animation").contains("low-pass")) { + Mlt::Filter *blur = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "boxblur"); + if (blur && blur->is_valid()) + clipService.attach(*blur); + } + filter->set("transition.geometry", geometry.toUtf8().data()); + filter->set("transition.cycle", cycle); + clipService.attach(*filter); + } + } + } + } else { + Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service()); + int ct = 0; + Mlt::Filter *filter = clipService.filter(0); + while (filter) { + if (strcmp(filter->get("mlt_service"), "affine") == 0 || strcmp(filter->get("mlt_service"), "boxblur") == 0) { + clipService.detach(*filter); + } else ct++; + filter = clipService.filter(ct); + } + } if (getProperty("fade") == "1") { // we want a fade filter effect kDebug() << "//////////// FADE WANTED"; @@ -590,8 +709,8 @@ void DocClipBase::slotRefreshProducer() } if (filter && strcmp(filter->get("mlt_service"), "luma") == 0) { - filter->set("period", getProperty("ttl").toInt() - 1); - filter->set("luma.out", getProperty("luma_duration").toInt()); + filter->set("cycle", getProperty("ttl").toInt()); + filter->set("duration", getProperty("luma_duration").toInt()); QString resource = getProperty("luma_file"); char *tmp = (char *) qstrdup(resource.toUtf8().data()); filter->set("luma.resource", tmp); @@ -603,8 +722,8 @@ void DocClipBase::slotRefreshProducer() } else { // filter does not exist, create it... Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "luma"); - filter->set("period", getProperty("ttl").toInt() - 1); - filter->set("luma.out", getProperty("luma_duration").toInt()); + filter->set("cycle", getProperty("ttl").toInt()); + filter->set("duration", getProperty("luma_duration").toInt()); QString resource = getProperty("luma_file"); char *tmp = (char *) qstrdup(resource.toUtf8().data()); filter->set("luma.resource", tmp); @@ -627,6 +746,36 @@ void DocClipBase::slotRefreshProducer() filter = clipService.filter(ct); } } + if (getProperty("crop") == "1") { + // we want a center crop filter effect + Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service()); + int ct = 0; + Mlt::Filter *filter = clipService.filter(ct); + while (filter) { + if (strcmp(filter->get("mlt_service"), "crop") == 0) { + break; + } + ct++; + filter = clipService.filter(ct); + } + + if (!filter || strcmp(filter->get("mlt_service"), "crop")) { + // filter does not exist, create it... + Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "crop"); + filter->set("center", 1); + clipService.attach(*filter); + } + } else { + Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service()); + int ct = 0; + Mlt::Filter *filter = clipService.filter(0); + while (filter) { + if (strcmp(filter->get("mlt_service"), "crop") == 0) { + clipService.detach(*filter); + } else ct++; + filter = clipService.filter(ct); + } + } } } @@ -648,7 +797,15 @@ void DocClipBase::setProperties(QMap properties) void DocClipBase::setMetadata(QMap properties) { - m_metadata = properties; + QMapIterator i(properties); + while (i.hasNext()) { + i.next(); + if (i.value().isEmpty() && m_metadata.contains(i.key())) { + m_metadata.remove(i.key()); + } else { + m_metadata.insert(i.key(), i.value()); + } + } } QMap DocClipBase::metadata() const @@ -683,19 +840,54 @@ void DocClipBase::getFileHash(const QString url) file.close(); fileHash = QCryptographicHash::hash(fileData, QCryptographicHash::Md5); m_properties.insert("file_hash", QString(fileHash.toHex())); - //kDebug() << file.fileName() << file.size() << fileHash.toHex(); } } +bool DocClipBase::checkHash() const +{ + KUrl url = fileURL(); + if (!url.isEmpty() && getClipHash() != getHash(url.path())) return false; + return true; +} + QString DocClipBase::getClipHash() const { QString hash; if (m_clipType == SLIDESHOW) hash = QCryptographicHash::hash(m_properties.value("resource").toAscii().data(), QCryptographicHash::Md5).toHex(); else if (m_clipType == COLOR) hash = QCryptographicHash::hash(m_properties.value("colour").toAscii().data(), QCryptographicHash::Md5).toHex(); + else if (m_clipType == TEXT) hash = QCryptographicHash::hash(QString("title" + getId() + m_properties.value("xmldata")).toUtf8().data(), QCryptographicHash::Md5).toHex(); else hash = m_properties.value("file_hash"); return hash; } +void DocClipBase::setPlaceHolder(bool place) +{ + m_placeHolder = place; +} + +// static +QString DocClipBase::getHash(const QString &path) +{ + QFile file(path); + if (file.open(QIODevice::ReadOnly)) { // write size and hash only if resource points to a file + QByteArray fileData; + QByteArray fileHash; + /* + * 1 MB = 1 second per 450 files (or faster) + * 10 MB = 9 seconds per 450 files (or faster) + */ + if (file.size() > 1000000*2) { + fileData = file.read(1000000); + if (file.seek(file.size() - 1000000)) + fileData.append(file.readAll()); + } else + fileData = file.readAll(); + file.close(); + return QCryptographicHash::hash(fileData, QCryptographicHash::Md5).toHex(); + } + return QString(); +} + void DocClipBase::refreshThumbUrl() { if (m_thumbProd) m_thumbProd->updateThumbUrl(m_properties.value("file_hash")); @@ -713,13 +905,31 @@ void DocClipBase::setProperty(const QString &key, const QString &value) char *tmp = (char *) qstrdup(value.toUtf8().data()); setProducerProperty("colour", tmp); delete[] tmp; + } else if (key == "templatetext") { + char *tmp = (char *) qstrdup(value.toUtf8().data()); + setProducerProperty("templatetext", tmp); + delete[] tmp; + setProducerProperty("force_reload", 1); } else if (key == "xmldata") { + char *tmp = (char *) qstrdup(value.toUtf8().data()); + setProducerProperty("xmldata", tmp); + delete[] tmp; setProducerProperty("force_reload", 1); } else if (key == "force_aspect_ratio") { if (value.isEmpty()) { m_properties.remove("force_aspect_ratio"); - setProducerProperty("force_aspect_ratio", 0); + resetProducerProperty("force_aspect_ratio"); } else setProducerProperty("force_aspect_ratio", value.toDouble()); + } else if (key == "force_fps") { + if (value.isEmpty()) { + m_properties.remove("force_fps"); + resetProducerProperty("force_fps"); + } else setProducerProperty("force_fps", value.toDouble()); + } else if (key == "force_progressive") { + if (value.isEmpty()) { + m_properties.remove("force_progressive"); + resetProducerProperty("force_progressive"); + } else setProducerProperty("force_progressive", value.toInt()); } else if (key == "threads") { if (value.isEmpty()) { m_properties.remove("threads"); @@ -745,17 +955,16 @@ QMap DocClipBase::properties() const bool DocClipBase::slotGetAudioThumbs() { - if (m_thumbProd == NULL) return false; - if (!KdenliveSettings::audiothumbnails()) { + if (m_thumbProd == NULL || isPlaceHolder()) return false; + if (!KdenliveSettings::audiothumbnails() || m_audioTimer == NULL) { if (m_audioTimer != NULL) m_audioTimer->stop(); return false; } if (m_audioThumbCreated) { - if (m_audioTimer != NULL) m_audioTimer->stop(); + m_audioTimer->stop(); return false; } - if (m_audioTimer != NULL) - m_audioTimer->start(1500); + m_audioTimer->start(1500); double lengthInFrames = duration().frames(KdenliveSettings::project_fps()); m_thumbProd->getAudioThumbs(2, 0, lengthInFrames /*must be number of frames*/, 20); return true; @@ -766,3 +975,88 @@ bool DocClipBase::isPlaceHolder() const return m_placeHolder; } +void DocClipBase::addCutZone(int in, int out, QString desc) +{ + CutZoneInfo info; + info.zone = QPoint(in, out); + info.description = desc; + for (int i = 0; i < m_cutZones.count(); i++) + if (m_cutZones.at(i).zone == info.zone) { + return; + } + m_cutZones.append(info); +} + +bool DocClipBase::hasCutZone(QPoint p) const +{ + for (int i = 0; i < m_cutZones.count(); i++) + if (m_cutZones.at(i).zone == p) return true; + return false; +} + + +void DocClipBase::removeCutZone(int in, int out) +{ + QPoint p(in, out); + for (int i = 0; i < m_cutZones.count(); i++) { + if (m_cutZones.at(i).zone == p) { + m_cutZones.removeAt(i); + i--; + } + } +} + +void DocClipBase::updateCutZone(int oldin, int oldout, int in, int out, QString desc) +{ + QPoint old(oldin, oldout); + for (int i = 0; i < m_cutZones.size(); ++i) { + if (m_cutZones.at(i).zone == old) { + CutZoneInfo info; + info.zone = QPoint(in, out); + info.description = desc; + m_cutZones.replace(i, info); + break; + } + } +} + +QList DocClipBase::cutZones() const +{ + return m_cutZones; +} + +bool DocClipBase::hasVideoCodec(const QString &codec) const +{ + Mlt::Producer *prod = NULL; + if (m_baseTrackProducers.count() == 0) return false; + for (int i = 0; i < m_baseTrackProducers.count(); i++) { + if (m_baseTrackProducers.at(i) != NULL) { + prod = m_baseTrackProducers.at(i); + break; + } + } + + if (!prod) return false; + int default_video = prod->get_int("video_index"); + char property[200]; + snprintf(property, sizeof(property), "meta.media.%d.codec.name", default_video); + return prod->get(property) == codec; +} + +bool DocClipBase::hasAudioCodec(const QString &codec) const +{ + Mlt::Producer *prod = NULL; + if (m_baseTrackProducers.count() == 0) return false; + for (int i = 0; i < m_baseTrackProducers.count(); i++) { + if (m_baseTrackProducers.at(i) != NULL) { + prod = m_baseTrackProducers.at(i); + break; + } + } + if (!prod) return false; + int default_video = prod->get_int("audio_index"); + char property[200]; + snprintf(property, sizeof(property), "meta.media.%d.codec.name", default_video); + return prod->get(property) == codec; +} +