From 09aae6cd42927b370af1b7bc7a94db03fd6a7cf6 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Tue, 18 Oct 2011 12:47:22 +0000 Subject: [PATCH] Fix some avformat producer concurrency crashes svn path=/trunk/kdenlive/; revision=5967 --- src/clipitem.cpp | 12 +- src/clipmanager.cpp | 2 +- src/customtrackview.cpp | 45 ++- src/docclipbase.cpp | 91 +++-- src/docclipbase.h | 9 +- src/kthumb.cpp | 45 ++- src/kthumb.h | 1 + src/mainwindow.cpp | 1 - src/monitor.cpp | 11 +- src/monitor.h | 2 +- src/projectlist.cpp | 115 +++++-- src/projectlist.h | 4 +- src/renderer.cpp | 738 ++++++++++++++++++++-------------------- src/renderer.h | 32 +- 14 files changed, 616 insertions(+), 492 deletions(-) diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 463f1dbb..5f4cfb02 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -99,9 +99,6 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i connect(&m_startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb())); m_endThumbTimer.setSingleShot(true); connect(&m_endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb())); - - connect(this, SIGNAL(getThumb(int, int)), m_clip, SLOT(slotExtractImage(int, int))); - connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage))); connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData())); if (generateThumbs) QTimer::singleShot(200, this, SLOT(slotFetchThumbs())); @@ -114,7 +111,6 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i } else if (m_clipType == IMAGE || m_clipType == TEXT) { m_baseColor = QColor(141, 166, 215); if (m_clipType == TEXT) { - connect(this, SIGNAL(getThumb(int, int)), m_clip, SLOT(slotExtractImage(int, int))); connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage))); } //m_startPix = KThumb::getImage(KUrl(clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight()); @@ -570,7 +566,7 @@ void ClipItem::slotFetchThumbs() if (m_endPix.isNull() && m_startPix.isNull()) { m_startThumbRequested = true; m_endThumbRequested = true; - emit getThumb((int)m_speedIndependantInfo.cropStart.frames(m_fps), (int)(m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1); + m_clip->slotExtractImage((int)m_speedIndependantInfo.cropStart.frames(m_fps), (int)(m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1); } else { if (m_endPix.isNull()) { slotGetEndThumb(); @@ -584,13 +580,13 @@ void ClipItem::slotFetchThumbs() void ClipItem::slotGetStartThumb() { m_startThumbRequested = true; - emit getThumb((int)m_speedIndependantInfo.cropStart.frames(m_fps), -1); + m_clip->slotExtractImage((int)m_speedIndependantInfo.cropStart.frames(m_fps), -1); } void ClipItem::slotGetEndThumb() { m_endThumbRequested = true; - emit getThumb(-1, (int)(m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1); + m_clip->slotExtractImage(-1, (int)(m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1); } @@ -1780,7 +1776,7 @@ Mlt::Producer *ClipItem::getProducer(int track, bool trackSpecific) else if (isVideoOnly()) return m_clip->videoProducer(); else - return m_clip->producer(trackSpecific ? track : -1); + return m_clip->getProducer(trackSpecific ? track : -1); } QMap ClipItem::adjustEffectsToDuration(int width, int height, ItemInfo oldInfo) diff --git a/src/clipmanager.cpp b/src/clipmanager.cpp index bc07ebac..0710fce5 100644 --- a/src/clipmanager.cpp +++ b/src/clipmanager.cpp @@ -258,7 +258,7 @@ void ClipManager::resetProducersList(const QList prods, bool d { for (int i = 0; i < m_clipList.count(); i++) { if (m_clipList.at(i)->numReferences() > 0 || displayRatioChanged || fpsChanged) { - m_clipList.at(i)->deleteProducers(true); + m_clipList.at(i)->deleteProducers(); } } QString id; diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 188d18e7..ebe5144d 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -1491,7 +1491,7 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint &pos) kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << list.at(0); return false; } - if (clip->producer() == NULL) { + if (clip->getProducer() == NULL) { emit displayMessage(i18n("Clip not ready"), ErrorMessage); return false; } @@ -1546,7 +1546,7 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint &pos) kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << ids.at(i); return false; } - if (clip->producer() == NULL) { + if (clip->getProducer() == NULL) { emit displayMessage(i18n("Clip not ready"), ErrorMessage); return false; } @@ -2420,7 +2420,7 @@ void CustomTrackView::dropEvent(QDropEvent * event) ItemInfo clipInfo = info; clipInfo.track = m_document->tracksCount() - item->track(); - int worked = m_document->renderer()->mltInsertClip(clipInfo, item->xml(), item->baseClip()->producer(item->track()), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT); + int worked = m_document->renderer()->mltInsertClip(clipInfo, item->xml(), item->baseClip()->getProducer(item->track()), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT); if (worked == -1) { emit displayMessage(i18n("Cannot insert clip in timeline"), ErrorMessage); brokenClips.append(item); @@ -2663,6 +2663,7 @@ void CustomTrackView::addTrack(TrackInfo type, int ix) m_selectionGroup->translate(0, m_tracksHeight); // adjust track number + m_document->renderer()->lock(); QList children = m_selectionGroup->childItems(); for (int i = 0; i < children.count(); i++) { if (children.at(i)->type() == GROUPWIDGET) { @@ -2694,6 +2695,7 @@ void CustomTrackView::addTrack(TrackInfo type, int ix) } } resetSelectionGroup(false); + m_document->renderer()->unlock(); } int maxHeight = m_tracksHeight * m_document->tracksCount() * matrix().m22(); @@ -2735,6 +2737,7 @@ void CustomTrackView::removeTrack(int ix) // Move graphic items qreal ydiff = 0 - (int) m_tracksHeight; m_selectionGroup->translate(0, ydiff); + m_document->renderer()->lock(); // adjust track number QList children = m_selectionGroup->childItems(); @@ -2767,6 +2770,7 @@ void CustomTrackView::removeTrack(int ix) } } resetSelectionGroup(false); + m_document->renderer()->unlock(); int maxHeight = m_tracksHeight * m_document->tracksCount() * matrix().m22(); for (int i = 0; i < m_guides.count(); i++) { @@ -4123,18 +4127,18 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i return; } - if (baseclip->producer() == NULL) { + if (baseclip->getProducer() == NULL) { // If the clip has no producer, we must wait until it is created... m_mutex.lock(); emit displayMessage(i18n("Waiting for clip..."), InformationMessage); emit forceClipProcessing(clipId); qApp->processEvents(); for (int i = 0; i < 3; i++) { - if (baseclip->producer() == NULL) { + if (baseclip->getProducer() == NULL) { m_producerNotReady.wait(&m_mutex, 500 + 500 * i); } else break; } - if (baseclip->producer() == NULL) { + if (baseclip->getProducer() == NULL) { emit displayMessage(i18n("Cannot insert clip..."), ErrorMessage); m_mutex.unlock(); return; @@ -4171,18 +4175,24 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i void CustomTrackView::slotUpdateClip(const QString &clipId, bool reload) { + QMutexLocker locker(&m_mutex); QList list = scene()->items(); QList clipList; ClipItem *clip = NULL; + DocClipBase *baseClip = NULL; + m_document->renderer()->lock(); for (int i = 0; i < list.size(); ++i) { if (list.at(i)->type() == AVWIDGET) { clip = static_cast (list.at(i)); if (clip->clipProducer() == clipId) { + if (baseClip == NULL) { + baseClip = clip->baseClip(); + } ItemInfo info = clip->info(); Mlt::Producer *prod = NULL; - if (clip->isAudioOnly()) prod = clip->baseClip()->audioProducer(info.track); - else if (clip->isVideoOnly()) prod = clip->baseClip()->videoProducer(); - else prod = clip->baseClip()->producer(info.track); + if (clip->isAudioOnly()) prod = baseClip->audioProducer(info.track); + else if (clip->isVideoOnly()) prod = baseClip->videoProducer(); + else prod = baseClip->getProducer(info.track); if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), prod)) { emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage); } @@ -4190,8 +4200,12 @@ void CustomTrackView::slotUpdateClip(const QString &clipId, bool reload) } } } + m_document->renderer()->unlock(); for (int i = 0; i < clipList.count(); i++) clipList.at(i)->refreshClip(true, true); + if (baseClip) { + baseClip->cleanupProducers(); + } } ClipItem *CustomTrackView::getClipItemAtEnd(GenTime pos, int track) @@ -5995,6 +6009,7 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, EffectsList ef clip->setSelected(true); ClipItem *audioClip = getClipItemAt(start, info.track); if (audioClip) { + m_document->renderer()->lock(); clip->setVideoOnly(true); if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - track, start, clip->baseClip()->videoProducer()) == false) { emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage); @@ -6002,6 +6017,7 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, EffectsList ef if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - info.track, start, clip->baseClip()->audioProducer(info.track)) == false) { emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, info.track), ErrorMessage); } + m_document->renderer()->unlock(); audioClip->setSelected(true); audioClip->setAudioOnly(true); @@ -6039,10 +6055,11 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, EffectsList ef ItemInfo info = clip->info(); deleteClip(clp->info()); clip->setVideoOnly(false); - - if (!m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - info.track, info.startPos.frames(m_document->fps()), clip->baseClip()->producer(info.track))) { + m_document->renderer()->lock(); + if (!m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - info.track, info.startPos.frames(m_document->fps()), clip->baseClip()->getProducer(info.track))) { emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage); } + m_document->renderer()->unlock(); // re-add audio effects for (int i = 0; i < effects.count(); ++i) { @@ -6146,21 +6163,25 @@ void CustomTrackView::doChangeClipType(const GenTime &pos, int track, bool video int start = pos.frames(m_document->fps()); clip->setVideoOnly(true); clip->setAudioOnly(false); + m_document->renderer()->lock(); if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - track, start, clip->baseClip()->videoProducer()) == false) { emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage); } + m_document->renderer()->unlock(); } else if (audioOnly) { int start = pos.frames(m_document->fps()); clip->setAudioOnly(true); clip->setVideoOnly(false); + m_document->renderer()->lock(); if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - track, start, clip->baseClip()->audioProducer(track)) == false) { emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage); } + m_document->renderer()->unlock(); } else { int start = pos.frames(m_document->fps()); clip->setAudioOnly(false); clip->setVideoOnly(false); - if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - track, start, clip->baseClip()->producer(track)) == false) { + if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - track, start, clip->baseClip()->getProducer(track)) == false) { emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage); } } diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index 70da2394..ef78b242 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -411,19 +411,48 @@ QString DocClipBase::markerComment(GenTime t) return QString(); } -void DocClipBase::deleteProducers(bool clearThumbCreator) +void DocClipBase::clearThumbProducer() { - if (clearThumbCreator && m_thumbProd) m_thumbProd->clearProducer(); + if (m_thumbProd) m_thumbProd->clearProducer(); +} - delete m_videoOnlyProducer; +void DocClipBase::deleteProducers() +{ + m_thumbProd->clearProducer(); + + if (numReferences() > 0) { + // Clip is used in timeline, delay producers deletion + if (m_videoOnlyProducer) m_toDeleteProducers.append(m_videoOnlyProducer); + for (int i = 0; i < m_baseTrackProducers.count(); i++) { + m_toDeleteProducers.append(m_baseTrackProducers.at(i)); + } + for (int i = 0; i < m_audioTrackProducers.count(); i++) { + m_toDeleteProducers.append(m_audioTrackProducers.at(i)); + } + } + else { + delete m_videoOnlyProducer; + qDeleteAll(m_baseTrackProducers); + qDeleteAll(m_audioTrackProducers); + m_replaceMutex.unlock(); + } m_videoOnlyProducer = NULL; - - qDeleteAll(m_baseTrackProducers); m_baseTrackProducers.clear(); - qDeleteAll(m_audioTrackProducers); m_audioTrackProducers.clear(); } +void DocClipBase::cleanupProducers() +{ + qDeleteAll(m_toDeleteProducers); + m_toDeleteProducers.clear(); + m_replaceMutex.unlock(); +} + +bool DocClipBase::isClean() const +{ + return m_toDeleteProducers.isEmpty(); +} + void DocClipBase::setValid() { m_placeHolder = false; @@ -432,7 +461,12 @@ void DocClipBase::setValid() void DocClipBase::setProducer(Mlt::Producer *producer, bool reset, bool readPropertiesFromProducer) { if (producer == NULL) return; - if (reset) QMutexLocker locker(&m_producerMutex); + if (reset) { + QMutexLocker locker(&m_producerMutex); + m_replaceMutex.lock(); + deleteProducers(); + } + QString id = producer->get("id"); if (m_placeHolder || !producer->is_valid()) { char *tmp = qstrdup(i18n("Missing clip").toUtf8().constData()); producer->set("markup", tmp); @@ -440,21 +474,12 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset, bool readProp producer->set("pad", "10"); delete[] tmp; } - QString id = producer->get("id"); - if (m_thumbProd) { - if (reset) m_thumbProd->setProducer(NULL); - if (!m_thumbProd->hasProducer()) { - if (m_clipType != AUDIO) { - if (!id.endsWith("_audio")) - m_thumbProd->setProducer(producer); - } - else m_thumbProd->setProducer(producer); + else if (m_thumbProd && !m_thumbProd->hasProducer()) { + if (m_clipType != AUDIO) { + if (!id.endsWith("_audio")) + m_thumbProd->setProducer(producer); } - } - if (reset) { - // Clear all previous producers - kDebug() << "/+++++++++++++++ DELETE ALL PRODS " << producer->get("id"); - deleteProducers(false); + else m_thumbProd->setProducer(producer); } bool updated = false; if (id.contains('_')) { @@ -530,7 +555,7 @@ Mlt::Producer *DocClipBase::audioProducer(int track) if (i >= m_audioTrackProducers.count()) { // Could not find a valid producer for that clip locker.unlock(); - base = producer(); + base = getProducer(); if (base == NULL) { return NULL; } @@ -556,7 +581,7 @@ void DocClipBase::adjustProducerProperties(Mlt::Producer *prod, const QString &i else if (m_properties.contains("audio_index")) prod->set("audio_index", m_properties.value("audio_index").toInt()); if (blind) prod->set("video_index", -1); else if (m_properties.contains("video_index")) prod->set("video_index", m_properties.value("video_index").toInt()); - prod->set("id", id.toUtf8().data()); + prod->set("id", id.toUtf8().constData()); if (m_properties.contains("force_colorspace")) prod->set("force_colorspace", m_properties.value("force_colorspace").toInt()); if (m_properties.contains("full_luma")) prod->set("set.force_full_luma", m_properties.value("full_luma").toInt()); if (m_properties.contains("proxy_out")) { @@ -581,7 +606,7 @@ Mlt::Producer *DocClipBase::videoProducer() return m_videoOnlyProducer; } -Mlt::Producer *DocClipBase::producer(int track) +Mlt::Producer *DocClipBase::getProducer(int track) { QMutexLocker locker(&m_producerMutex); if (track == -1 || (m_clipType != AUDIO && m_clipType != AV && m_clipType != PLAYLIST)) { @@ -621,9 +646,7 @@ Mlt::Producer *DocClipBase::cloneProducer(Mlt::Producer *source) Mlt::Producer *result = NULL; QString url = QString::fromUtf8(source->get("resource")); if (KIO::NetAccess::exists(KUrl(url), KIO::NetAccess::SourceSide, 0)) { - char *tmp = qstrdup(url.toUtf8().constData()); - result = new Mlt::Producer(*source->profile(), tmp); - delete[] tmp; + result = new Mlt::Producer(*(source->profile()), url.toUtf8().constData()); } if (result == NULL || !result->is_valid()) { // placeholder clip @@ -632,21 +655,22 @@ Mlt::Producer *DocClipBase::cloneProducer(Mlt::Producer *source) result = new Mlt::Producer(*source->profile(), tmp); delete[] tmp; if (result == NULL || !result->is_valid()) - result = new Mlt::Producer(*source->profile(), "colour:red"); + result = new Mlt::Producer(*(source->profile()), "colour:red"); else { result->set("bgcolour", "0xff0000ff"); result->set("pad", "10"); } return result; } + /*Mlt::Properties src_props(source->get_properties()); Mlt::Properties props(result->get_properties()); - Mlt::Properties src_props(source->get_properties()); - props.inherit(src_props); + props.inherit(src_props);*/ return result; } void DocClipBase::setProducerProperty(const char *name, int data) { + QMutexLocker locker(&m_producerMutex); for (int i = 0; i < m_baseTrackProducers.count(); i++) { if (m_baseTrackProducers.at(i) != NULL) m_baseTrackProducers[i]->set(name, data); @@ -655,6 +679,7 @@ void DocClipBase::setProducerProperty(const char *name, int data) void DocClipBase::setProducerProperty(const char *name, double data) { + QMutexLocker locker(&m_producerMutex); for (int i = 0; i < m_baseTrackProducers.count(); i++) { if (m_baseTrackProducers.at(i) != NULL) m_baseTrackProducers[i]->set(name, data); @@ -663,6 +688,7 @@ void DocClipBase::setProducerProperty(const char *name, double data) void DocClipBase::setProducerProperty(const char *name, const char *data) { + QMutexLocker locker(&m_producerMutex); for (int i = 0; i < m_baseTrackProducers.count(); i++) { if (m_baseTrackProducers.at(i) != NULL) m_baseTrackProducers[i]->set(name, data); @@ -671,6 +697,7 @@ void DocClipBase::setProducerProperty(const char *name, const char *data) void DocClipBase::resetProducerProperty(const char *name) { + QMutexLocker locker(&m_producerMutex); for (int i = 0; i < m_baseTrackProducers.count(); i++) { if (m_baseTrackProducers.at(i) != NULL) m_baseTrackProducers[i]->set(name, (const char*) NULL); @@ -692,10 +719,6 @@ void DocClipBase::slotRefreshProducer() { if (m_baseTrackProducers.count() == 0) return; if (m_clipType == SLIDESHOW) { - /*Mlt::Producer producer(*(m_clipProducer->profile()), getProperty("resource").toUtf8().data()); - 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());*/ setProducerProperty("ttl", getProperty("ttl").toInt()); //m_clipProducer->set("id", getProperty("id")); if (!getProperty("animation").isEmpty()) { diff --git a/src/docclipbase.h b/src/docclipbase.h index f44130e1..edccd3c4 100644 --- a/src/docclipbase.h +++ b/src/docclipbase.h @@ -119,7 +119,7 @@ Q_OBJECT public: /** Sets producers for the current clip (one for each track due to a limitation in MLT's track mixing */ void setProducer(Mlt::Producer *producer, bool reset = false, bool readPropertiesFromProducer = false); /** Retrieve a producer for a track */ - Mlt::Producer *producer(int track = -1); + Mlt::Producer *getProducer(int track = -1); /** Retrieve the producer that shows only video */ Mlt::Producer *videoProducer(); /** Retrieve the producer that shows only audio */ @@ -181,7 +181,7 @@ Q_OBJECT public: const char *producerProperty(const char *name) const; void setProducerProperty(const char *name, const char *data); void resetProducerProperty(const char *name); - void deleteProducers(bool clearThumbCreator = true); + void deleteProducers(); /** Set default play zone for clip monitor */ void setZone(QPoint zone); @@ -204,6 +204,9 @@ Q_OBJECT public: bool checkHash() const; void setPlaceHolder(bool place); QPixmap extractImage(int frame, int width, int height); + void clearThumbProducer(); + void cleanupProducers(); + bool isClean() const; private: // Private attributes @@ -212,6 +215,7 @@ private: // Private attributes uint m_refcount; QList m_baseTrackProducers; QList m_audioTrackProducers; + QList m_toDeleteProducers; Mlt::Producer *m_videoOnlyProducer; CLIPTYPE m_clipType; @@ -242,6 +246,7 @@ private: // Private attributes /** Try to make sure we don't delete a producer while using it */ QMutex m_producerMutex; + QMutex m_replaceMutex; /** Create connections for audio thumbnails */ void slotCreateAudioTimer(); diff --git a/src/kthumb.cpp b/src/kthumb.cpp index a7950b2a..ac232e66 100644 --- a/src/kthumb.cpp +++ b/src/kthumb.cpp @@ -70,11 +70,11 @@ KThumb::~KThumb() void KThumb::setProducer(Mlt::Producer *producer) { - m_mutex.lock(); m_requestedThumbs.clear(); m_intraFramesQueue.clear(); m_future.waitForFinished(); m_intra.waitForFinished(); + m_mutex.lock(); m_producer = producer; // FIXME: the profile() call leaks an object, but trying to free // it leads to a double-free in Profile::~Profile() @@ -103,8 +103,6 @@ void KThumb::updateThumbUrl(const QString &hash) void KThumb::updateClipUrl(KUrl url, const QString &hash) { m_url = url; - //if (m_producer) - //m_producer->set("resource", url.path().toUtf8().constData()); m_thumbFile = m_clipManager->projectFolder() + "/thumbs/" + hash + ".thumb"; } @@ -122,9 +120,7 @@ void KThumb::extractImage(int frame, int frame2) if (frame2 != -1 && !m_requestedThumbs.contains(frame2)) m_requestedThumbs.append(frame2); qSort(m_requestedThumbs); if (!m_future.isRunning()) { - m_mutex.lock(); m_future = QtConcurrent::run(this, &KThumb::doGetThumbs); - m_mutex.unlock(); } } @@ -137,16 +133,20 @@ void KThumb::doGetThumbs() while (!m_requestedThumbs.isEmpty()) { int frame = m_requestedThumbs.takeFirst(); if (frame != -1) { - emit thumbReady(frame, getFrame(m_producer, frame, swidth, dwidth, theight)); + QImage img = getProducerFrame(frame, swidth, dwidth, theight); + emit thumbReady(frame, img); } } } QPixmap KThumb::extractImage(int frame, int width, int height) { - m_mutex.lock(); - QImage img = getFrame(m_producer, frame, (int) (height * m_ratio + 0.5), width, height); - m_mutex.unlock(); + if (m_producer == NULL) { + QPixmap p(width, height); + p.fill(Qt::black); + return p; + } + QImage img = getProducerFrame(frame, (int) (height * m_ratio + 0.5), width, height); return QPixmap::fromImage(img); } @@ -166,6 +166,28 @@ QPixmap KThumb::getImage(KUrl url, int frame, int width, int height) return pix; } + +QImage KThumb::getProducerFrame(int framepos, int frameWidth, int displayWidth, int height) +{ + if (m_producer == NULL || !m_producer->is_valid()) { + QImage p(displayWidth, height, QImage::Format_ARGB32_Premultiplied); + p.fill(QColor(Qt::red).rgb()); + return p; + } + if (m_producer->is_blank()) { + QImage p(displayWidth, height, QImage::Format_ARGB32_Premultiplied); + p.fill(QColor(Qt::black).rgb()); + return p; + } + m_mutex.lock(); + m_producer->seek(framepos); + Mlt::Frame *frame = m_producer->get_frame(); + QImage p = getFrame(frame, frameWidth, displayWidth, height); + delete frame; + m_mutex.unlock(); + return p; +} + //static QImage KThumb::getFrame(Mlt::Producer *producer, int framepos, int frameWidth, int displayWidth, int height) { @@ -174,7 +196,6 @@ QImage KThumb::getFrame(Mlt::Producer *producer, int framepos, int frameWidth, i p.fill(QColor(Qt::red).rgb()); return p; } - if (producer->is_blank()) { QImage p(displayWidth, height, QImage::Format_ARGB32_Premultiplied); p.fill(QColor(Qt::black).rgb()); @@ -478,9 +499,7 @@ void KThumb::queryIntraThumbs(QList missingFrames) } qSort(m_intraFramesQueue); if (!m_intra.isRunning()) { - m_mutex.lock(); m_intra = QtConcurrent::run(this, &KThumb::slotGetIntraThumbs); - m_mutex.unlock(); } } @@ -495,7 +514,7 @@ void KThumb::slotGetIntraThumbs() while (!m_intraFramesQueue.isEmpty()) { int pos = m_intraFramesQueue.takeFirst(); if (!m_clipManager->pixmapCache->contains(path + QString::number(pos))) { - if (m_clipManager->pixmapCache->insertImage(path + QString::number(pos), getFrame(m_producer, pos, frameWidth, displayWidth, theight))) { + if (m_clipManager->pixmapCache->insertImage(path + QString::number(pos), getProducerFrame(pos, frameWidth, displayWidth, theight))) { addedThumbs = true; } else kDebug()<<"// INSERT FAILD FOR: "< m_intraFramesQueue; QMutex m_mutex; void doGetThumbs(); + QImage getProducerFrame(int framepos, int frameWidth, int displayWidth, int height); signals: void thumbReady(int, QImage); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ad341f38..30616e1c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -849,7 +849,6 @@ void MainWindow::slotConnectMonitors() connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap)), this, SLOT(slotDeleteProjectClips(QStringList, QMap))); connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *))); connect(m_projectList, SIGNAL(showClipProperties(QList , QMap)), this, SLOT(slotShowClipProperties(QList , QMap))); - connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool))); connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int))); connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &))); connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool, bool))); diff --git a/src/monitor.cpp b/src/monitor.cpp index 20bd0060..8bda5253 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -813,17 +813,16 @@ void Monitor::slotSetXml(DocClipBase *clip, QPoint zone, const int position) render->setProducer(NULL, -1); return; } - if (m_currentClip != NULL || clip != NULL) { - activateMonitor(); - } if (clip != m_currentClip) { m_currentClip = clip; + if (m_currentClip) activateMonitor(); updateMarkers(clip); - if (render->setProducer(clip->producer(), position) == -1) { + if (render->setProducer(clip->getProducer(), position) == -1) { // MLT CONSUMER is broken kDebug(QtWarningMsg) << "ERROR, Cannot start monitor"; } } else { + if (m_currentClip) activateMonitor(); if (position != -1) render->seek(position); } if (!zone.isNull()) { @@ -1040,9 +1039,9 @@ void MonitorRefresh::setRenderer(Render* render) m_renderer = render; } -void MonitorRefresh::paintEvent(QPaintEvent *event) + +void MonitorRefresh::resizeEvent(QResizeEvent *event) { - Q_UNUSED(event) if (m_renderer) m_renderer->doRefresh(); } diff --git a/src/monitor.h b/src/monitor.h index 13f107a2..45f0179a 100644 --- a/src/monitor.h +++ b/src/monitor.h @@ -75,7 +75,7 @@ public: void setRenderer(Render* render); protected: - virtual void paintEvent(QPaintEvent *event); + virtual void resizeEvent(QResizeEvent *event); private: Render *m_renderer; diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 13615f7e..2b099953 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -129,6 +129,10 @@ ProjectList::ProjectList(QWidget *parent) : QHBoxLayout *box = new QHBoxLayout; KTreeWidgetSearchLine *searchView = new KTreeWidgetSearchLine; + m_refreshMonitorTimer.setSingleShot(true); + m_refreshMonitorTimer.setInterval(100); + connect(&m_refreshMonitorTimer, SIGNAL(timeout()), this, SLOT(slotRefreshMonitor())); + box->addWidget(searchView); //int s = style()->pixelMetric(QStyle::PM_SmallIconSize); //m_toolbar->setIconSize(QSize(s, s)); @@ -494,27 +498,35 @@ void ProjectList::slotReloadClip(const QString &id) continue; } item = static_cast (selected.at(i)); - if (item) { + if (item && !item->isProxyRunning()) { + DocClipBase *clip = item->referencedClip(); + if (!clip->isClean()) { + // The clip is currently under processing (replacement in timeline), we cannot reload it now. + continue; + } CLIPTYPE t = item->clipType(); if (t == TEXT) { - if (!item->referencedClip()->getProperty("xmltemplate").isEmpty()) + if (clip && !clip->getProperty("xmltemplate").isEmpty()) regenerateTemplate(item); - } else if (t != COLOR && t != SLIDESHOW && item->referencedClip() && item->referencedClip()->checkHash() == false) { + } else if (t != COLOR && t != SLIDESHOW && clip && clip->checkHash() == false) { item->referencedClip()->setPlaceHolder(true); item->setProperty("file_hash", QString()); } else if (t == IMAGE) { - item->referencedClip()->producer()->set("force_reload", 1); + clip->getProducer()->set("force_reload", 1); } QDomElement e = item->toXml(); // Make sure we get the correct producer length if it was adjusted in timeline if (t == COLOR || t == IMAGE || t == SLIDESHOW || t == TEXT) { - int length = QString(item->referencedClip()->producerProperty("length")).toInt(); + int length = QString(clip->producerProperty("length")).toInt(); if (length > 0 && !e.hasAttribute("length")) { e.setAttribute("length", length); } - } - emit getFileProperties(e, item->clipId(), m_listView->iconSize().height(), true); + } + if (clip) { + clip->clearThumbProducer(); + } + m_render->getFileProperties(e, item->clipId(), m_listView->iconSize().height(), true); } } } @@ -560,9 +572,9 @@ void ProjectList::slotMissingClip(const QString &id) return; } Mlt::Producer *newProd = m_render->invalidProducer(id); - if (item->referencedClip()->producer()) { + if (item->referencedClip()->getProducer()) { Mlt::Properties props(newProd->get_properties()); - Mlt::Properties src_props(item->referencedClip()->producer()->get_properties()); + Mlt::Properties src_props(item->referencedClip()->getProducer()->get_properties()); props.inherit(src_props); } item->referencedClip()->setProducer(newProd, true); @@ -615,28 +627,31 @@ void ProjectList::setRenderer(Render *projectRender) void ProjectList::slotClipSelected() { - if (m_listView->currentItem()) { - if (m_listView->currentItem()->type() == PROJECTFOLDERTYPE) { + m_refreshMonitorTimer.stop(); + QTreeWidgetItem *item = m_listView->currentItem(); + ProjectItem *clip = NULL; + if (item) { + if (item->type() == PROJECTFOLDERTYPE) { emit clipSelected(NULL); - m_editButton->defaultAction()->setEnabled(m_listView->currentItem()->childCount() > 0); + m_editButton->defaultAction()->setEnabled(item->childCount() > 0); m_deleteButton->defaultAction()->setEnabled(true); m_openAction->setEnabled(false); m_reloadAction->setEnabled(false); m_transcodeAction->setEnabled(false); - m_proxyAction->setEnabled(false); } else { - ProjectItem *clip; - if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) { + if (item->type() == PROJECTSUBCLIPTYPE) { // this is a sub item, use base clip m_deleteButton->defaultAction()->setEnabled(true); - clip = static_cast (m_listView->currentItem()->parent()); + clip = static_cast (item->parent()); if (clip == NULL) kDebug() << "-----------ERROR"; - SubProjectItem *sub = static_cast (m_listView->currentItem()); + SubProjectItem *sub = static_cast (item); emit clipSelected(clip->referencedClip(), sub->zone()); m_transcodeAction->setEnabled(false); + m_reloadAction->setEnabled(false); + adjustProxyActions(clip); return; } - clip = static_cast (m_listView->currentItem()); + clip = static_cast (item); if (clip && clip->referencedClip()) emit clipSelected(clip->referencedClip()); m_editButton->defaultAction()->setEnabled(true); @@ -665,6 +680,7 @@ void ProjectList::slotClipSelected() m_reloadAction->setEnabled(false); m_transcodeAction->setEnabled(false); } + adjustProxyActions(clip); } void ProjectList::adjustProxyActions(ProjectItem *clip) const @@ -831,6 +847,7 @@ void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item) if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) { clip = static_cast (item->parent()); m_transcodeAction->setEnabled(false); + adjustProxyActions(clip); } else if (m_listView->currentItem()->type() == PROJECTCLIPTYPE) { clip = static_cast (item); // Display relevant transcoding actions only @@ -917,7 +934,6 @@ void ProjectList::updateButtons() const m_openAction->setEnabled(true); m_reloadAction->setEnabled(true); m_transcodeAction->setEnabled(true); - m_proxyAction->setEnabled(useProxy()); return; } else if (item && item->type() == PROJECTFOLDERTYPE && item->childCount() > 0) { @@ -1071,7 +1087,8 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) m_listView->processLayout(); QDomElement e = clip->toXML().cloneNode().toElement(); e.removeAttribute("file_hash"); - emit getFileProperties(e, clip->getId(), m_listView->iconSize().height(), true); + clip->clearThumbProducer(); + m_render->getFileProperties(e, clip->getId(), m_listView->iconSize().height(), true); } else if (item->hasProxy() && !item->isProxyRunning()) { slotCreateProxy(clip->getId()); @@ -1128,6 +1145,11 @@ void ProjectList::slotGotProxy(ProjectItem *item) { if (item == NULL || !m_refreshed) return; DocClipBase *clip = item->referencedClip(); + if (!clip->isClean()) { + //WARNING: might result in clip said marked as proxy but not using proxy? + // The clip is currently under processing (replacement in timeline), we cannot reload it now. + return; + } // Proxy clip successfully created QDomElement e = clip->toXML().cloneNode().toElement(); @@ -1139,7 +1161,8 @@ void ProjectList::slotGotProxy(ProjectItem *item) e.setAttribute("length", length); } } - emit getFileProperties(e, clip->getId(), m_listView->iconSize().height(), true); + clip->clearThumbProducer(); + m_render->getFileProperties(e, clip->getId(), m_listView->iconSize().height(), true); } void ProjectList::slotResetProjectList() @@ -1213,7 +1236,7 @@ void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged) } else { item = static_cast (*it); clip = item->referencedClip(); - if (item->referencedClip()->producer() == NULL) { + if (item->referencedClip()->getProducer() == NULL) { if (clip->isPlaceHolder() == false) { QDomElement xml = clip->toXML(); if (fpsChanged) { @@ -1221,7 +1244,9 @@ void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged) xml.removeAttribute("file_hash"); xml.removeAttribute("proxy_out"); } - emit getFileProperties(xml, clip->getId(), m_listView->iconSize().height(), xml.attribute("replace") == "1"); + bool replace = xml.attribute("replace") == "1"; + if (replace) clip->clearThumbProducer(); + m_render->getFileProperties(xml, clip->getId(), m_listView->iconSize().height(), replace); } else { item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled); @@ -1243,7 +1268,7 @@ void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged) getCachedThumbnail(item); } if (item->data(0, DurationRole).toString().isEmpty()) { - item->changeDuration(item->referencedClip()->producer()->get_playtime()); + item->changeDuration(item->referencedClip()->getProducer()->get_playtime()); } if (clip->isPlaceHolder()) { QPixmap pixmap = qVariantValue(item->data(0, Qt::DecorationRole)); @@ -1673,9 +1698,10 @@ void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update) if (clip->clipType() == AUDIO) pix = KIcon("audio-x-generic").pixmap(QSize(dwidth, height)); else if (clip->clipType() == IMAGE) - pix = QPixmap::fromImage(KThumb::getFrame(item->referencedClip()->producer(), 0, swidth, dwidth, height)); - else + pix = QPixmap::fromImage(KThumb::getFrame(item->referencedClip()->getProducer(), 0, swidth, dwidth, height)); + else { pix = item->referencedClip()->extractImage(frame, dwidth, height); + } if (!pix.isNull()) { monitorItemEditing(false); @@ -1693,6 +1719,17 @@ void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update) } } +void ProjectList::slotRefreshMonitor() +{ + if (m_listView->selectedItems().count() == 1 && m_render && m_render->processingItems() == 0) { + if (m_listView->currentItem() && m_listView->currentItem()->type() != PROJECTFOLDERTYPE) { + ProjectItem *item = static_cast (m_listView->currentItem()); + DocClipBase *clip = item->referencedClip(); + if (clip && clip->isClean()) emit clipSelected(clip); + } + } +} + void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const stringMap &properties, const stringMap &metadata, bool replace, bool refreshThumbnail) { QString toReload; @@ -1705,7 +1742,6 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce if (item && producer) { monitorItemEditing(false); DocClipBase *clip = item->referencedClip(); - item->setProperties(properties, metadata); if (producer->is_valid()) { if (clip->isPlaceHolder()) { clip->setValid(); @@ -1714,13 +1750,14 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled); } clip->setProducer(producer, replace); + item->setProperties(properties, metadata); clip->askForAudioThumbs(); if (refreshThumbnail) getCachedThumbnail(item); // Proxy stuff QString size = properties.value("frame_size"); if (!useProxy() && clip->getProperty("proxy").isEmpty()) setProxyStatus(item, NOPROXY); if (useProxy() && generateProxy() && clip->getProperty("proxy") == "-") setProxyStatus(item, NOPROXY); - else if (useProxy() && !item->isProxyRunning()) { + else if (useProxy() && !item->hasProxy() && !item->isProxyRunning()) { // proxy video and image clips int maxSize; CLIPTYPE t = item->clipType(); @@ -1762,7 +1799,7 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce updatedProfile = adjustProjectProfileToItem(item); } if (updatedProfile == false) { - emit clipSelected(item->referencedClip()); + //emit clipSelected(item->referencedClip()); } } else { int max = m_doc->clipManager()->clipsCount(); @@ -1770,12 +1807,12 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce } processNextThumbnail(); } - if (item && queue == 0 && replace) { + if (replace && item) { + if (item->numReferences() > 0) toReload = clipId; + else item->referencedClip()->cleanupProducers(); // update clip in clip monitor - if (item->isSelected() && m_listView->selectedItems().count() == 1) - emit clipSelected(item->referencedClip()); - //TODO: Make sure the line below has no side effect - toReload = clipId; + if (queue == 0 && item->isSelected() && m_listView->selectedItems().count() == 1) + m_refreshMonitorTimer.start(); } if (!item) { // no item for producer, delete it @@ -1966,7 +2003,6 @@ void ProjectList::slotSelectClip(const QString &ix) m_deleteButton->defaultAction()->setEnabled(true); m_reloadAction->setEnabled(true); m_transcodeAction->setEnabled(true); - m_proxyAction->setEnabled(useProxy()); if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) { m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp())); m_openAction->setEnabled(true); @@ -2032,7 +2068,7 @@ void ProjectList::regenerateTemplate(const QString &id) void ProjectList::regenerateTemplate(ProjectItem *clip) { //TODO: remove this unused method, only force_reload is necessary - clip->referencedClip()->producer()->set("force_reload", 1); + clip->referencedClip()->getProducer()->set("force_reload", 1); } QDomDocument ProjectList::generateTemplateXml(QString path, const QString &replaceString) @@ -2556,10 +2592,15 @@ void ProjectList::slotProxyCurrentItem(bool doProxy) if (!list.contains(sub)) list.append(sub); } } - if (listItem->type() == PROJECTCLIPTYPE) { + else if (listItem->type() == PROJECTSUBCLIPTYPE) { + QTreeWidgetItem *sub = listItem->parent(); + if (!list.contains(sub)) list.append(sub); + } + else if (listItem->type() == PROJECTCLIPTYPE) { ProjectItem *item = static_cast (listItem); CLIPTYPE t = item->clipType(); if ((t == VIDEO || t == AV || t == UNKNOWN || t == IMAGE || t == PLAYLIST) && item->referencedClip()) { + if ((doProxy && item->hasProxy()) || (!doProxy && !item->hasProxy())) continue; oldProps = item->referencedClip()->properties(); if (doProxy) { newProps.clear(); diff --git a/src/projectlist.h b/src/projectlist.h index 98f9b7d6..1803c362 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -309,6 +309,7 @@ private: QList m_proxyList; QFutureSynchronizer m_proxyThreads; InvalidDialog *m_invalidClipDialog; + QTimer m_refreshMonitorTimer; void requestClipThumbnail(const QString id); @@ -380,10 +381,11 @@ private slots: void slotAbortProxy(const QString id, const QString path); /** @brief Start creation of proxy clip. */ void slotGenerateProxy();//const QString destPath, const QString sourcePath, int clipType, int exif); + /** @brief Timer triggering a refresh of the clip monitor. */ + void slotRefreshMonitor(); signals: void clipSelected(DocClipBase *, QPoint zone = QPoint()); - void getFileProperties(const QDomElement, const QString &, int pixHeight, bool); void receivedClipDuration(const QString &); void showClipProperties(DocClipBase *); void showClipProperties(QList , QMap commonproperties); diff --git a/src/renderer.cpp b/src/renderer.cpp index 2acfe0f6..3e1001c4 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -117,7 +117,7 @@ Render::Render(const QString & rendererName, int winid, QString profile, QWidget { if (profile.isEmpty()) profile = KdenliveSettings::current_profile(); buildConsumer(profile); - m_mltProducer = m_blackClip->cut(0, 50); + m_mltProducer = m_blackClip->cut(0, 1); m_mltConsumer->connect(*m_mltProducer); m_mltProducer->set_speed(0.0); } @@ -138,7 +138,7 @@ void Render::closeMlt() if (m_mltProducer) delete m_mltProducer; /*if (m_mltProducer) { Mlt::Service service(m_mltProducer->parent().get_service()); - mlt_service_lock(service.get_service()); + service.lock(); if (service.type() == tractor_type) { Mlt::Tractor tractor(service); @@ -162,7 +162,7 @@ void Render::closeMlt() delete field; field = NULL; } - mlt_service_unlock(service.get_service()); + service.unlock(); }*/ kDebug() << "// // // CLOSE RENDERER " << m_name; @@ -560,9 +560,11 @@ void Render::getFileProperties(const QDomElement &xml, const QString &clipId, in info.clipId = clipId; info.imageHeight = imageHeight; info.replaceProducer = replaceProducer; + // Make sure we don't request the info for same clip twice + m_requestList.removeAll(info); m_requestList.append(info); if (!m_infoThread.isRunning()) - m_infoThread = QtConcurrent::run(this, &Render::getFileProperties2); + m_infoThread = QtConcurrent::run(this, &Render::processFileProperties); } void Render::forceProcessing(const QString &id) @@ -589,329 +591,319 @@ int Render::processingItems() const return count; } -void Render::getFileProperties2() +void Render::processFileProperties() { - while (!m_requestList.isEmpty()) { - m_infoMutex.lock(); - requestClipInfo info = m_requestList.takeFirst(); - m_infoMutex.unlock(); - - QString path; + requestClipInfo info; QLocale locale; - bool proxyProducer; - if (info.xml.hasAttribute("proxy") && info.xml.attribute("proxy") != "-") { - path = info.xml.attribute("proxy"); - proxyProducer = true; - } - else { - path = info.xml.attribute("resource"); - proxyProducer = false; - } - - KUrl url(path); - Mlt::Producer *producer = NULL; - CLIPTYPE type = (CLIPTYPE)info.xml.attribute("type").toInt(); - //kDebug() << "PROFILE WIDT: "<< info.xml.attribute("mlt_service") << ": "<< m_mltProfile->width() << "\n...................\n\n"; - /*if (info.xml.attribute("type").toInt() == TEXT && !QFile::exists(url.path())) { - emit replyGetFileProperties(clipId, producer, QMap < QString, QString >(), QMap < QString, QString >(), replaceProducer); - return; - }*/ - - if (type == COLOR) { - producer = new Mlt::Producer(*m_mltProfile, 0, ("colour:" + info.xml.attribute("colour")).toUtf8().constData()); - } else if (type == TEXT) { - producer = new Mlt::Producer(*m_mltProfile, 0, ("kdenlivetitle:" + info.xml.attribute("resource")).toUtf8().constData()); - if (producer && producer->is_valid() && info.xml.hasAttribute("xmldata")) - producer->set("xmldata", info.xml.attribute("xmldata").toUtf8().constData()); - } else if (url.isEmpty()) { - QDomDocument doc; - QDomElement mlt = doc.createElement("mlt"); - QDomElement play = doc.createElement("playlist"); - doc.appendChild(mlt); - mlt.appendChild(play); - play.appendChild(doc.importNode(info.xml, true)); - producer = new Mlt::Producer(*m_mltProfile, "xml-string", doc.toString().toUtf8().constData()); - } else { - producer = new Mlt::Producer(*m_mltProfile, path.toUtf8().constData()); - } - - - if (producer == NULL || producer->is_blank() || !producer->is_valid()) { - kDebug() << " / / / / / / / / ERROR / / / / // CANNOT LOAD PRODUCER: "<is_valid() && info.xml.hasAttribute("xmldata")) + producer->set("xmldata", info.xml.attribute("xmldata").toUtf8().constData()); + } else if (url.isEmpty()) { + QDomDocument doc; + QDomElement mlt = doc.createElement("mlt"); + QDomElement play = doc.createElement("playlist"); + doc.appendChild(mlt); + mlt.appendChild(play); + play.appendChild(doc.importNode(info.xml, true)); + producer = new Mlt::Producer(*m_mltProfile, "xml-string", doc.toString().toUtf8().constData()); + } else { + producer = new Mlt::Producer(*m_mltProfile, path.toUtf8().constData()); } - else emit removeInvalidClip(info.clipId, info.replaceProducer); - delete producer; - continue; - } - if (proxyProducer && info.xml.hasAttribute("proxy_out")) { - producer->set("length", info.xml.attribute("proxy_out").toInt() + 1); - producer->set("out", info.xml.attribute("proxy_out").toInt()); - if (producer->get_out() != info.xml.attribute("proxy_out").toInt()) { - // Proxy file length is different than original clip length, this will corrupt project so disable this proxy clip - emit removeInvalidProxy(info.clipId, true); + if (producer == NULL || producer->is_blank() || !producer->is_valid()) { + kDebug() << " / / / / / / / / ERROR / / / / // CANNOT LOAD PRODUCER: "< 0) producer->set("force_aspect_ratio", aspect); - } - - if (info.xml.hasAttribute("force_aspect_num") && info.xml.hasAttribute("force_aspect_den")) { - int width = info.xml.attribute("frame_size").section('x', 0, 0).toInt(); - int height = info.xml.attribute("frame_size").section('x', 1, 1).toInt(); - int aspectNumerator = info.xml.attribute("force_aspect_num").toInt(); - int aspectDenominator = info.xml.attribute("force_aspect_den").toInt(); - if (aspectDenominator != 0 && width != 0) - producer->set("force_aspect_ratio", double(height) * aspectNumerator / aspectDenominator / width); - } - - if (info.xml.hasAttribute("force_fps")) { - double fps = info.xml.attribute("force_fps").toDouble(); - if (fps > 0) producer->set("force_fps", fps); - } - if (info.xml.hasAttribute("force_progressive")) { - bool ok; - int progressive = info.xml.attribute("force_progressive").toInt(&ok); - if (ok) producer->set("force_progressive", progressive); - } - if (info.xml.hasAttribute("force_tff")) { - bool ok; - int fieldOrder = info.xml.attribute("force_tff").toInt(&ok); - if (ok) producer->set("force_tff", fieldOrder); - } - if (info.xml.hasAttribute("threads")) { - int threads = info.xml.attribute("threads").toInt(); - if (threads != 1) producer->set("threads", threads); - } - if (info.xml.hasAttribute("video_index")) { - int vindex = info.xml.attribute("video_index").toInt(); - if (vindex != 0) producer->set("video_index", vindex); - } - if (info.xml.hasAttribute("audio_index")) { - int aindex = info.xml.attribute("audio_index").toInt(); - if (aindex != 0) producer->set("audio_index", aindex); - } - if (info.xml.hasAttribute("force_colorspace")) { - int colorspace = info.xml.attribute("force_colorspace").toInt(); - if (colorspace != 0) producer->set("force_colorspace", colorspace); - } - if (info.xml.hasAttribute("full_luma")) { - int full_luma = info.xml.attribute("full_luma").toInt(); - if (full_luma != 0) producer->set("set.force_full_luma", full_luma); - } - - int clipOut = 0; - int duration = 0; - if (info.xml.hasAttribute("out")) clipOut = info.xml.attribute("out").toInt(); - - // setup length here as otherwise default length (currently 15000 frames in MLT) will be taken even if outpoint is larger - if (type == COLOR || type == TEXT || type == IMAGE || type == SLIDESHOW) { - int length; - if (info.xml.hasAttribute("length")) { - if (clipOut > 0) duration = clipOut + 1; - length = info.xml.attribute("length").toInt(); - clipOut = length - 1; + if (proxyProducer && info.xml.hasAttribute("proxy_out")) { + producer->set("length", info.xml.attribute("proxy_out").toInt() + 1); + producer->set("out", info.xml.attribute("proxy_out").toInt()); + if (producer->get_out() != info.xml.attribute("proxy_out").toInt()) { + // Proxy file length is different than original clip length, this will corrupt project so disable this proxy clip + emit removeInvalidProxy(info.clipId, true); + delete producer; + continue; + } } - else length = info.xml.attribute("out").toInt() - info.xml.attribute("in").toInt(); - producer->set("length", length); - } - if (clipOut > 0) producer->set_in_and_out(info.xml.attribute("in").toInt(), clipOut); + if (info.xml.hasAttribute("force_aspect_ratio")) { + double aspect = info.xml.attribute("force_aspect_ratio").toDouble(); + if (aspect > 0) producer->set("force_aspect_ratio", aspect); + } - producer->set("id", info.clipId.toUtf8().constData()); + if (info.xml.hasAttribute("force_aspect_num") && info.xml.hasAttribute("force_aspect_den")) { + int width = info.xml.attribute("frame_size").section('x', 0, 0).toInt(); + int height = info.xml.attribute("frame_size").section('x', 1, 1).toInt(); + int aspectNumerator = info.xml.attribute("force_aspect_num").toInt(); + int aspectDenominator = info.xml.attribute("force_aspect_den").toInt(); + if (aspectDenominator != 0 && width != 0) + producer->set("force_aspect_ratio", double(height) * aspectNumerator / aspectDenominator / width); + } - if (info.xml.hasAttribute("templatetext")) - producer->set("templatetext", info.xml.attribute("templatetext").toUtf8().constData()); + if (info.xml.hasAttribute("force_fps")) { + double fps = info.xml.attribute("force_fps").toDouble(); + if (fps > 0) producer->set("force_fps", fps); + } - if ((!info.replaceProducer && info.xml.hasAttribute("file_hash")) || info.xml.hasAttribute("proxy")) { - // Clip already has all properties - if (info.replaceProducer) emit blockClipMonitor(info.clipId); - emit replyGetFileProperties(info.clipId, producer, stringMap(), stringMap(), info.replaceProducer, true); - continue; - } + if (info.xml.hasAttribute("force_progressive")) { + bool ok; + int progressive = info.xml.attribute("force_progressive").toInt(&ok); + if (ok) producer->set("force_progressive", progressive); + } + if (info.xml.hasAttribute("force_tff")) { + bool ok; + int fieldOrder = info.xml.attribute("force_tff").toInt(&ok); + if (ok) producer->set("force_tff", fieldOrder); + } + if (info.xml.hasAttribute("threads")) { + int threads = info.xml.attribute("threads").toInt(); + if (threads != 1) producer->set("threads", threads); + } + if (info.xml.hasAttribute("video_index")) { + int vindex = info.xml.attribute("video_index").toInt(); + if (vindex != 0) producer->set("video_index", vindex); + } + if (info.xml.hasAttribute("audio_index")) { + int aindex = info.xml.attribute("audio_index").toInt(); + if (aindex != 0) producer->set("audio_index", aindex); + } + if (info.xml.hasAttribute("force_colorspace")) { + int colorspace = info.xml.attribute("force_colorspace").toInt(); + if (colorspace != 0) producer->set("force_colorspace", colorspace); + } + if (info.xml.hasAttribute("full_luma")) { + int full_luma = info.xml.attribute("full_luma").toInt(); + if (full_luma != 0) producer->set("set.force_full_luma", full_luma); + } - int imageWidth = (int)((double) info.imageHeight * m_mltProfile->width() / m_mltProfile->height() + 0.5); - int fullWidth = (int)((double) info.imageHeight * m_mltProfile->dar() + 0.5); - stringMap filePropertyMap; - stringMap metadataPropertyMap; + int clipOut = 0; + int duration = 0; + if (info.xml.hasAttribute("out")) clipOut = info.xml.attribute("out").toInt(); + + // setup length here as otherwise default length (currently 15000 frames in MLT) will be taken even if outpoint is larger + if (type == COLOR || type == TEXT || type == IMAGE || type == SLIDESHOW) { + int length; + if (info.xml.hasAttribute("length")) { + if (clipOut > 0) duration = clipOut + 1; + length = info.xml.attribute("length").toInt(); + clipOut = length - 1; + } + else length = info.xml.attribute("out").toInt() - info.xml.attribute("in").toInt(); + producer->set("length", length); + } - int frameNumber = info.xml.attribute("thumbnail", "0").toInt(); - if (frameNumber != 0) producer->seek(frameNumber); + if (clipOut > 0) producer->set_in_and_out(info.xml.attribute("in").toInt(), clipOut); - filePropertyMap["duration"] = QString::number(duration > 0 ? duration : producer->get_playtime()); - //kDebug() << "/////// PRODUCER: " << url.path() << " IS: " << producer->get_playtime(); + producer->set("id", info.clipId.toUtf8().constData()); - Mlt::Frame *frame = producer->get_frame(); + if (info.xml.hasAttribute("templatetext")) + producer->set("templatetext", info.xml.attribute("templatetext").toUtf8().constData()); + + if ((!info.replaceProducer && info.xml.hasAttribute("file_hash")) || proxyProducer) { + // Clip already has all properties + emit replyGetFileProperties(info.clipId, producer, stringMap(), stringMap(), info.replaceProducer, true); + continue; + } - if (type == SLIDESHOW) { - int ttl = info.xml.hasAttribute("ttl") ? info.xml.attribute("ttl").toInt() : 0; - if (ttl) producer->set("ttl", ttl); - if (!info.xml.attribute("animation").isEmpty()) { - Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, "affine"); - if (filter && filter->is_valid()) { - int cycle = ttl; - QString geometry = SlideshowClip::animationToGeometry(info.xml.attribute("animation"), cycle); - if (!geometry.isEmpty()) { - if (info.xml.attribute("animation").contains("low-pass")) { - Mlt::Filter *blur = new Mlt::Filter(*m_mltProfile, "boxblur"); - if (blur && blur->is_valid()) - producer->attach(*blur); + int imageWidth = (int)((double) info.imageHeight * m_mltProfile->width() / m_mltProfile->height() + 0.5); + int fullWidth = (int)((double) info.imageHeight * m_mltProfile->dar() + 0.5); + stringMap filePropertyMap; + stringMap metadataPropertyMap; + + int frameNumber = info.xml.attribute("thumbnail", "-1").toInt(); + if (frameNumber > 0) producer->seek(frameNumber); + + duration = duration > 0 ? duration : producer->get_playtime(); + filePropertyMap["duration"] = QString::number(duration); + //kDebug() << "/////// PRODUCER: " << url.path() << " IS: " << producer->get_playtime(); + + if (type == SLIDESHOW) { + int ttl = info.xml.hasAttribute("ttl") ? info.xml.attribute("ttl").toInt() : 0; + if (ttl) producer->set("ttl", ttl); + if (!info.xml.attribute("animation").isEmpty()) { + Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, "affine"); + if (filter && filter->is_valid()) { + int cycle = ttl; + QString geometry = SlideshowClip::animationToGeometry(info.xml.attribute("animation"), cycle); + if (!geometry.isEmpty()) { + if (info.xml.attribute("animation").contains("low-pass")) { + Mlt::Filter *blur = new Mlt::Filter(*m_mltProfile, "boxblur"); + if (blur && blur->is_valid()) + producer->attach(*blur); + } + filter->set("transition.geometry", geometry.toUtf8().data()); + filter->set("transition.cycle", cycle); + producer->attach(*filter); } - filter->set("transition.geometry", geometry.toUtf8().data()); - filter->set("transition.cycle", cycle); - producer->attach(*filter); } } - } - if (info.xml.attribute("fade") == "1") { - // user wants a fade effect to slideshow - Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, "luma"); - if (filter && filter->is_valid()) { - if (ttl) filter->set("cycle", ttl); - if (info.xml.hasAttribute("luma_duration") && !info.xml.attribute("luma_duration").isEmpty()) filter->set("duration", info.xml.attribute("luma_duration").toInt()); - if (info.xml.hasAttribute("luma_file") && !info.xml.attribute("luma_file").isEmpty()) { - filter->set("luma.resource", info.xml.attribute("luma_file").toUtf8().constData()); - if (info.xml.hasAttribute("softness")) { - int soft = info.xml.attribute("softness").toInt(); - filter->set("luma.softness", (double) soft / 100.0); + if (info.xml.attribute("fade") == "1") { + // user wants a fade effect to slideshow + Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, "luma"); + if (filter && filter->is_valid()) { + if (ttl) filter->set("cycle", ttl); + if (info.xml.hasAttribute("luma_duration") && !info.xml.attribute("luma_duration").isEmpty()) filter->set("duration", info.xml.attribute("luma_duration").toInt()); + if (info.xml.hasAttribute("luma_file") && !info.xml.attribute("luma_file").isEmpty()) { + filter->set("luma.resource", info.xml.attribute("luma_file").toUtf8().constData()); + if (info.xml.hasAttribute("softness")) { + int soft = info.xml.attribute("softness").toInt(); + filter->set("luma.softness", (double) soft / 100.0); + } } + producer->attach(*filter); } - producer->attach(*filter); } - } - if (info.xml.attribute("crop") == "1") { - // user wants to center crop the slides - Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, "crop"); - if (filter && filter->is_valid()) { - filter->set("center", 1); - producer->attach(*filter); + if (info.xml.attribute("crop") == "1") { + // user wants to center crop the slides + Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, "crop"); + if (filter && filter->is_valid()) { + filter->set("center", 1); + producer->attach(*filter); + } } } - } - if (producer->get_double("meta.media.frame_rate_den") > 0) { - filePropertyMap["fps"] = locale.toString(producer->get_double("meta.media.frame_rate_num") / producer->get_double("meta.media.frame_rate_den")); - } else filePropertyMap["fps"] = producer->get("source_fps"); - - if (frame && frame->is_valid()) { - filePropertyMap["frame_size"] = QString::number(frame->get_int("width")) + 'x' + QString::number(frame->get_int("height")); - filePropertyMap["frequency"] = QString::number(frame->get_int("frequency")); - filePropertyMap["channels"] = QString::number(frame->get_int("channels")); - filePropertyMap["aspect_ratio"] = frame->get("aspect_ratio"); - - if (frame->get_int("test_image") == 0) { - if (url.path().endsWith(".mlt") || url.path().endsWith(".westley") || url.path().endsWith(".kdenlive")) { - filePropertyMap["type"] = "playlist"; - metadataPropertyMap["comment"] = QString::fromUtf8(producer->get("title")); - } else if (frame->get_int("test_audio") == 0) - filePropertyMap["type"] = "av"; - else - filePropertyMap["type"] = "video"; - - int variance; - QImage img; - do { - variance = 100; - img = KThumb::getFrame(frame, imageWidth, fullWidth, info.imageHeight); - variance = KThumb::imageVariance(img); - if (frameNumber == 0 && variance< 6) { - // Thumbnail is not interesting (for example all black, seek to fetch better thumb - frameNumber = 100; - producer->seek(frameNumber); - delete frame; - frame = producer->get_frame(); - variance = -1; - } - } while (variance == -1); - emit replyGetImage(info.clipId, img); - } else if (frame->get_int("test_audio") == 0) { - emit replyGetImage(info.clipId, "audio-x-generic", fullWidth, info.imageHeight); - filePropertyMap["type"] = "audio"; + if (producer->get_double("meta.media.frame_rate_den") > 0) { + filePropertyMap["fps"] = locale.toString(producer->get_double("meta.media.frame_rate_num") / producer->get_double("meta.media.frame_rate_den")); + } else filePropertyMap["fps"] = producer->get("source_fps"); + + Mlt::Frame *frame = producer->get_frame(); + if (frame && frame->is_valid()) { + filePropertyMap["frame_size"] = QString::number(frame->get_int("width")) + 'x' + QString::number(frame->get_int("height")); + filePropertyMap["frequency"] = QString::number(frame->get_int("frequency")); + filePropertyMap["channels"] = QString::number(frame->get_int("channels")); + filePropertyMap["aspect_ratio"] = frame->get("aspect_ratio"); + + if (frame->get_int("test_image") == 0) { + if (url.path().endsWith(".mlt") || url.path().endsWith(".westley") || url.path().endsWith(".kdenlive")) { + filePropertyMap["type"] = "playlist"; + metadataPropertyMap["comment"] = QString::fromUtf8(producer->get("title")); + } else if (frame->get_int("test_audio") == 0) + filePropertyMap["type"] = "av"; + else + filePropertyMap["type"] = "video"; + + int variance; + QImage img; + do { + variance = 100; + img = KThumb::getFrame(frame, imageWidth, fullWidth, info.imageHeight); + variance = KThumb::imageVariance(img); + if (frameNumber == -1 && variance< 6) { + // Thumbnail is not interesting (for example all black, seek to fetch better thumb + frameNumber = duration > 100 ? 100 : duration / 2 ; + producer->seek(frameNumber); + delete frame; + frame = producer->get_frame(); + variance = -1; + } + } while (variance == -1); + if (frameNumber > -1) filePropertyMap["thumbnail"] = frameNumber; + emit replyGetImage(info.clipId, img); + } else if (frame->get_int("test_audio") == 0) { + emit replyGetImage(info.clipId, "audio-x-generic", fullWidth, info.imageHeight); + filePropertyMap["type"] = "audio"; + } } - } - delete frame; - // Retrieve audio / video codec name - - // If there is a - char property[200]; - if (producer->get_int("video_index") > -1) { - /*if (context->duration == AV_NOPTS_VALUE) { - kDebug() << " / / / / / / / /ERROR / / / CLIP HAS UNKNOWN DURATION"; - emit removeInvalidClip(clipId); + delete frame; + // Retrieve audio / video codec name + + // If there is a + char property[200]; + if (producer->get_int("video_index") > -1) { + /*if (context->duration == AV_NOPTS_VALUE) { + kDebug() << " / / / / / / / /ERROR / / / CLIP HAS UNKNOWN DURATION"; + emit removeInvalidClip(clipId); delete producer; return; - }*/ - // Get the video_index - int default_video = producer->get_int("video_index"); - int video_max = 0; - int default_audio = producer->get_int("audio_index"); - int audio_max = 0; - - // Find maximum stream index values - for (int ix = 0; ix < producer->get_int("meta.media.nb_streams"); ix++) { - snprintf(property, sizeof(property), "meta.media.%d.stream.type", ix); - QString type = producer->get(property); - if (type == "video") - video_max = ix; - else if (type == "audio") - audio_max = ix; - } - filePropertyMap["default_video"] = QString::number(default_video); - filePropertyMap["video_max"] = QString::number(video_max); - filePropertyMap["default_audio"] = QString::number(default_audio); - filePropertyMap["audio_max"] = QString::number(audio_max); - - snprintf(property, sizeof(property), "meta.media.%d.codec.long_name", default_video); - if (producer->get(property)) { - filePropertyMap["videocodec"] = producer->get(property); - } else { - snprintf(property, sizeof(property), "meta.media.%d.codec.name", default_video); - if (producer->get(property)) + }*/ + // Get the video_index + int default_video = producer->get_int("video_index"); + int video_max = 0; + int default_audio = producer->get_int("audio_index"); + int audio_max = 0; + + // Find maximum stream index values + for (int ix = 0; ix < producer->get_int("meta.media.nb_streams"); ix++) { + snprintf(property, sizeof(property), "meta.media.%d.stream.type", ix); + QString type = producer->get(property); + if (type == "video") + video_max = ix; + else if (type == "audio") + audio_max = ix; + } + filePropertyMap["default_video"] = QString::number(default_video); + filePropertyMap["video_max"] = QString::number(video_max); + filePropertyMap["default_audio"] = QString::number(default_audio); + filePropertyMap["audio_max"] = QString::number(audio_max); + + snprintf(property, sizeof(property), "meta.media.%d.codec.long_name", default_video); + if (producer->get(property)) { filePropertyMap["videocodec"] = producer->get(property); - } - QString query; - query = QString("meta.media.%1.codec.pix_fmt").arg(default_video); - filePropertyMap["pix_fmt"] = producer->get(query.toUtf8().constData()); - filePropertyMap["colorspace"] = producer->get("meta.media.colorspace"); - - } else kDebug() << " / / / / /WARNING, VIDEO CONTEXT IS NULL!!!!!!!!!!!!!!"; - if (producer->get_int("audio_index") > -1) { - // Get the audio_index - int index = producer->get_int("audio_index"); - - snprintf(property, sizeof(property), "meta.media.%d.codec.long_name", index); - if (producer->get(property)) { - filePropertyMap["audiocodec"] = producer->get(property); - } else { - snprintf(property, sizeof(property), "meta.media.%d.codec.name", index); - if (producer->get(property)) + } else { + snprintf(property, sizeof(property), "meta.media.%d.codec.name", default_video); + if (producer->get(property)) + filePropertyMap["videocodec"] = producer->get(property); + } + QString query; + query = QString("meta.media.%1.codec.pix_fmt").arg(default_video); + filePropertyMap["pix_fmt"] = producer->get(query.toUtf8().constData()); + filePropertyMap["colorspace"] = producer->get("meta.media.colorspace"); + + } else kDebug() << " / / / / /WARNING, VIDEO CONTEXT IS NULL!!!!!!!!!!!!!!"; + if (producer->get_int("audio_index") > -1) { + // Get the audio_index + int index = producer->get_int("audio_index"); + snprintf(property, sizeof(property), "meta.media.%d.codec.long_name", index); + if (producer->get(property)) { filePropertyMap["audiocodec"] = producer->get(property); + } else { + snprintf(property, sizeof(property), "meta.media.%d.codec.name", index); + if (producer->get(property)) + filePropertyMap["audiocodec"] = producer->get(property); + } } - } - // metadata - Mlt::Properties metadata; - metadata.pass_values(*producer, "meta.attr."); - int count = metadata.count(); - for (int i = 0; i < count; i ++) { - QString name = metadata.get_name(i); - QString value = QString::fromUtf8(metadata.get(i)); - if (name.endsWith("markup") && !value.isEmpty()) - metadataPropertyMap[ name.section('.', 0, -2)] = value; - } - producer->seek(0); - if (info.replaceProducer) emit blockClipMonitor(info.clipId); - emit replyGetFileProperties(info.clipId, producer, filePropertyMap, metadataPropertyMap, info.replaceProducer); - // FIXME: should delete this to avoid a leak... - //delete producer; + // metadata + Mlt::Properties metadata; + metadata.pass_values(*producer, "meta.attr."); + int count = metadata.count(); + for (int i = 0; i < count; i ++) { + QString name = metadata.get_name(i); + QString value = QString::fromUtf8(metadata.get(i)); + if (name.endsWith("markup") && !value.isEmpty()) + metadataPropertyMap[ name.section('.', 0, -2)] = value; + } + producer->seek(0); + emit replyGetFileProperties(info.clipId, producer, filePropertyMap, metadataPropertyMap, info.replaceProducer); } } @@ -956,11 +948,13 @@ void Render::initSceneList() int Render::setProducer(Mlt::Producer *producer, int position) { + kDebug()<<"//////////\n SET CLIP PRODUCER \n//////////"; QMutexLocker locker(&m_mutex); if (m_winid == -1) return -1; if (m_mltConsumer) { if (!m_mltConsumer->is_stopped()) { m_mltConsumer->stop(); + m_mltConsumer->purge(); } m_mltConsumer->set("refresh", 0); } @@ -977,7 +971,7 @@ int Render::setProducer(Mlt::Producer *producer, int position) blockSignals(true); if (producer && producer->is_valid()) { m_mltProducer = new Mlt::Producer(producer->get_producer()); - } else m_mltProducer = m_blackClip->cut(0, 50); + } else m_mltProducer = m_blackClip->cut(0, 1); if (!m_mltProducer || !m_mltProducer->is_valid()) { kDebug() << " WARNING - - - - -INVALID PLAYLIST: "; @@ -988,6 +982,9 @@ int Render::setProducer(Mlt::Producer *producer, int position) m_fps = m_mltProducer->get_fps(); blockSignals(false); int error = connectPlaylist(); + if (producer == NULL) { + return error; + } if (position != -1) { m_mltProducer->seek(position); @@ -1032,7 +1029,7 @@ int Render::setSceneList(QString playlist, int position) //if (KdenliveSettings::osdtimecode() && m_osdInfo) m_mltProducer->detach(*m_osdInfo); /*Mlt::Service service(m_mltProducer->parent().get_service()); - mlt_service_lock(service.get_service()); + service.lock(); if (service.type() == tractor_type) { Mlt::Tractor tractor(service); @@ -1061,7 +1058,7 @@ int Render::setSceneList(QString playlist, int position) } delete field; } - mlt_service_unlock(service.get_service());*/ + service.unlock();*/ qDeleteAll(m_slowmotionProducers.values()); m_slowmotionProducers.clear(); @@ -1077,7 +1074,7 @@ int Render::setSceneList(QString playlist, int position) m_mltProducer = new Mlt::Producer(*m_mltProfile, "xml-string", playlist.toUtf8().constData()); if (!m_mltProducer || !m_mltProducer->is_valid()) { kDebug() << " WARNING - - - - -INVALID PLAYLIST: " << playlist.toUtf8().constData(); - m_mltProducer = m_blackClip->cut(0, 50); + m_mltProducer = m_blackClip->cut(0, 1); error = -1; } checkMaxThreads(); @@ -1521,6 +1518,7 @@ void Render::emitFrameUpdated(Mlt::Frame& frame) void Render::emitFrameNumber(double position) { + kDebug()<<"+++++++++++++++++++++++++++++++++++++++\n "<is_valid()) { - mlt_service_unlock(service.get_service()); + service.unlock(); return -1; } @@ -1750,7 +1748,7 @@ int Render::mltInsertClip(ItemInfo info, QDomElement element, Mlt::Producer *pro mltAddClipTransparency(info, info.track - 1, QString(prod->get("id")).toInt());*/ if (info.track != 0 && (newIndex + 1 == trackPlaylist.count())) mltCheckLength(&tractor); - mlt_service_unlock(service.get_service()); + service.unlock(); /*tractor.multitrack()->refresh(); tractor.refresh();*/ return 0; @@ -1787,10 +1785,10 @@ void Render::mltCutClip(int track, GenTime position) kDebug() << "// WARNING, TRYING TO CUT A BLANK"; return; } - mlt_service_lock(service.get_service()); + service.lock(); int clipStart = trackPlaylist.clip_start(clipIndex); trackPlaylist.split(clipIndex, cutPos - clipStart - 1); - mlt_service_unlock(service.get_service()); + service.unlock(); // duplicate effects Mlt::Producer *original = trackPlaylist.get_clip_at(clipStart); @@ -1835,6 +1833,28 @@ void Render::mltCutClip(int track, GenTime position) } +void Render::lock() +{ + if (!m_mltProducer) return; + Mlt::Service service(m_mltProducer->parent().get_service()); + if (service.type() != tractor_type) { + kWarning() << "// TRACTOR PROBLEM"; + return; + } + service.lock(); +} + +void Render::unlock() +{ + if (!m_mltProducer) return; + Mlt::Service service(m_mltProducer->parent().get_service()); + if (service.type() != tractor_type) { + kWarning() << "// TRACTOR PROBLEM"; + return; + } + service.unlock(); +} + bool Render::mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *prod) { // TODO: optimize @@ -1842,6 +1862,7 @@ bool Render::mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *pr kDebug() << "Cannot update clip with null producer //////"; return false; } + Mlt::Service service(m_mltProducer->parent().get_service()); if (service.type() != tractor_type) { kWarning() << "// TRACTOR PROBLEM"; @@ -1856,11 +1877,11 @@ bool Render::mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *pr kDebug() << "// WARNING, TRYING TO REMOVE A BLANK: " << startPos; return false; } - mlt_service_lock(service.get_service()); Mlt::Producer *clip = trackPlaylist.get_clip(clipIndex); // keep effects QList filtersList; Mlt::Service sourceService(clip->get_service()); + sourceService.lock(); int ct = 0; Mlt::Filter *filter = sourceService.filter(ct); while (filter) { @@ -1873,28 +1894,20 @@ bool Render::mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *pr trackPlaylist.replace_with_blank(clipIndex); delete clip; - //if (!mltRemoveClip(info.track, info.startPos)) return false; prod = checkSlowMotionProducer(prod, element); if (prod == NULL || !prod->is_valid()) { - mlt_service_unlock(service.get_service()); return false; } Mlt::Producer *clip2 = prod->cut(info.cropStart.frames(m_fps), (info.cropDuration + info.cropStart).frames(m_fps) - 1); trackPlaylist.insert_at(info.startPos.frames(m_fps), clip2, 1); + Mlt::Service destService(clip2->get_service()); delete clip2; - - //if (mltInsertClip(info, element, prod) == -1) return false; if (!filtersList.isEmpty()) { - clipIndex = trackPlaylist.get_clip_index_at(startPos); - Mlt::Producer *destclip = trackPlaylist.get_clip(clipIndex); - Mlt::Service destService(destclip->get_service()); - delete destclip; for (int i = 0; i < filtersList.count(); i++) destService.attach(*(filtersList.at(i))); } - mlt_service_unlock(service.get_service()); return true; } @@ -1914,7 +1927,7 @@ bool Render::mltRemoveClip(int track, GenTime position) if (trackPlaylist.is_blank(clipIndex)) { kDebug() << "// WARNING, TRYING TO REMOVE A BLANK: " << position.frames(m_fps); - //mlt_service_unlock(service.get_service()); + //service.unlock(); return false; } Mlt::Producer *clip = trackPlaylist.replace_with_blank(clipIndex); @@ -1998,7 +2011,7 @@ void Render::mltInsertSpace(QMap trackClipStartList, QMap Mlt::Service service(parentProd.get_service()); Mlt::Tractor tractor(service); - mlt_service_lock(service.get_service()); + service.lock(); int diff = duration.frames(m_fps); int offset = timeOffset.frames(m_fps); int insertPos; @@ -2116,7 +2129,7 @@ void Render::mltInsertSpace(QMap trackClipStartList, QMap resource = mlt_properties_get(properties, "mlt_service"); } } - mlt_service_unlock(service.get_service()); + service.unlock(); mltCheckLength(&tractor); m_mltConsumer->set("refresh", 1); } @@ -2178,7 +2191,7 @@ int Render::mltChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, dou if (speed <= 0 && speed > -1) speed = 1.0; //kDebug() << "CLIP SERVICE: " << serv; if ((serv == "avformat" || serv == "avformat-novalidate") && (speed != 1.0 || strobe > 1)) { - mlt_service_lock(service.get_service()); + service.lock(); QString url = QString::fromUtf8(clipparent.get("resource")); url.append('?' + m_locale.toString(speed)); if (strobe > 1) url.append("&strobe=" + QString::number(strobe)); @@ -2227,9 +2240,9 @@ int Render::mltChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, dou delete clip; clipIndex = trackPlaylist.get_clip_index_at(startPos); newLength = trackPlaylist.clip_length(clipIndex); - mlt_service_unlock(service.get_service()); + service.unlock(); } else if (speed == 1.0 && strobe < 2) { - mlt_service_lock(service.get_service()); + service.lock(); Mlt::Producer *clip = trackPlaylist.replace_with_blank(clipIndex); trackPlaylist.consolidate_blanks(0); @@ -2253,10 +2266,10 @@ int Render::mltChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, dou delete clip; clipIndex = trackPlaylist.get_clip_index_at(startPos); newLength = trackPlaylist.clip_length(clipIndex); - mlt_service_unlock(service.get_service()); + service.unlock(); } else if (serv == "framebuffer") { - mlt_service_lock(service.get_service()); + service.lock(); QString url = QString::fromUtf8(clipparent.get("resource")); url = url.section('?', 0, 0); url.append('?' + m_locale.toString(speed)); @@ -2312,7 +2325,7 @@ int Render::mltChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, dou clipIndex = trackPlaylist.get_clip_index_at(startPos); newLength = trackPlaylist.clip_length(clipIndex); - mlt_service_unlock(service.get_service()); + service.unlock(); } delete original; if (clipIndex + 1 == trackPlaylist.count()) mltCheckLength(&tractor); @@ -2328,7 +2341,7 @@ bool Render::mltRemoveTrackEffect(int track, int index, bool updateIndex) Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service()); Mlt::Service clipService(trackPlaylist.get_service()); - mlt_service_lock(service.get_service()); + service.lock(); int ct = 0; Mlt::Filter *filter = clipService.filter(ct); while (filter) { @@ -2341,7 +2354,7 @@ bool Render::mltRemoveTrackEffect(int track, int index, bool updateIndex) } else ct++; filter = clipService.filter(ct); } - mlt_service_unlock(service.get_service()); + service.unlock(); refresh(); return success; } @@ -2374,7 +2387,7 @@ bool Render::mltRemoveEffect(int track, GenTime position, int index, bool update } delete clip; - mlt_service_lock(service.get_service()); + service.lock(); int ct = 0; Mlt::Filter *filter = clipService.filter(ct); while (filter) { @@ -2388,7 +2401,7 @@ bool Render::mltRemoveEffect(int track, GenTime position, int index, bool update } else ct++; filter = clipService.filter(ct); } - mlt_service_unlock(service.get_service()); + service.unlock(); if (doRefresh) refresh(); return success; } @@ -2436,7 +2449,7 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int const int filter_ix = params.paramValue("kdenlive_ix").toInt(); const QString region = params.paramValue("region"); int ct = 0; - mlt_service_lock(service.get_service()); + service.lock(); Mlt::Filter *filter = service.filter(ct); while (filter) { @@ -2460,7 +2473,7 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int ct++; filter = service.filter(ct); } - mlt_service_unlock(service.get_service()); + service.unlock(); if (doRefresh) refresh(); return true; } @@ -2563,7 +2576,7 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int } } else { kDebug() << "filter is NULL"; - mlt_service_unlock(service.get_service()); + service.unlock(); return false; } params.removeParam("kdenlive_id"); @@ -2606,7 +2619,7 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int filter->set("kdenlive_ix", filter->get_int("kdenlive_ix") + 1); service.attach(*filter); } - mlt_service_unlock(service.get_service()); + service.unlock(); if (doRefresh) refresh(); return true; } @@ -2641,11 +2654,11 @@ bool Render::mltEditTrackEffect(int track, EffectsParameterList params) QString prefix; QString ser = filter->get("mlt_service"); if (ser == "region") prefix = "filter0."; - mlt_service_lock(service.get_service()); + service.lock(); for (int j = 0; j < params.count(); j++) { filter->set((prefix + params.at(j).name()).toUtf8().constData(), params.at(j).value().toUtf8().constData()); } - mlt_service_unlock(service.get_service()); + service.unlock(); refresh(); return true; @@ -2716,13 +2729,13 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par params.removeParam("_sync_in_out"); filter->set_in_and_out(clip->get_in(), clip->get_out()); } - mlt_service_lock(service.get_service()); + service.lock(); for (int j = 0; j < params.count(); j++) { filter->set((prefix + params.at(j).name()).toUtf8().constData(), params.at(j).value().toUtf8().constData()); } delete clip; - mlt_service_unlock(service.get_service()); + service.unlock(); if (doRefresh) refresh(); return true; @@ -2923,7 +2936,7 @@ bool Render::mltResizeClipEnd(ItemInfo info, GenTime clipDuration) kDebug() << "//////// ERROR RSIZING BLANK CLIP!!!!!!!!!!!"; return false; } - mlt_service_lock(service.get_service()); + service.lock(); int clipIndex = trackPlaylist.get_clip_index_at((int) info.startPos.frames(m_fps)); //kDebug() << "// SELECTED CLIP START: " << trackPlaylist.clip_start(clipIndex); Mlt::Producer *clip = trackPlaylist.get_clip(clipIndex); @@ -2968,7 +2981,7 @@ bool Render::mltResizeClipEnd(ItemInfo info, GenTime clipDuration) } } else if (clipIndex != trackPlaylist.count()) trackPlaylist.insert_blank(clipIndex, 0 - diff - 1); trackPlaylist.consolidate_blanks(0); - mlt_service_unlock(service.get_service()); + service.unlock(); if (info.track != 0 && clipIndex == trackPlaylist.count()) mltCheckLength(&tractor); /*if (QString(clip->parent().get("transparency")).toInt() == 1) { @@ -3078,19 +3091,19 @@ bool Render::mltResizeClipCrop(ItemInfo info, GenTime diff) kDebug() << "//////// ERROR RSIZING BLANK CLIP!!!!!!!!!!!"; return false; } - mlt_service_lock(service.get_service()); + service.lock(); int clipIndex = trackPlaylist.get_clip_index_at(info.startPos.frames(m_fps)); Mlt::Producer *clip = trackPlaylist.get_clip(clipIndex); if (clip == NULL) { kDebug() << "//////// ERROR RSIZING NULL CLIP!!!!!!!!!!!"; - mlt_service_unlock(service.get_service()); + service.unlock(); return false; } int previousStart = clip->get_in(); int previousOut = clip->get_out(); delete clip; trackPlaylist.resize_clip(clipIndex, previousStart + frameOffset, previousOut + frameOffset); - mlt_service_unlock(service.get_service()); + service.unlock(); m_mltConsumer->set("refresh", 1); return true; } @@ -3107,12 +3120,12 @@ bool Render::mltResizeClipStart(ItemInfo info, GenTime diff) kDebug() << "//////// ERROR RSIZING BLANK CLIP!!!!!!!!!!!"; return false; } - mlt_service_lock(service.get_service()); + service.lock(); int clipIndex = trackPlaylist.get_clip_index_at(info.startPos.frames(m_fps)); Mlt::Producer *clip = trackPlaylist.get_clip(clipIndex); if (clip == NULL || clip->is_blank()) { kDebug() << "//////// ERROR RSIZING NULL CLIP!!!!!!!!!!!"; - mlt_service_unlock(service.get_service()); + service.unlock(); return false; } int previousStart = clip->get_in(); @@ -3162,7 +3175,7 @@ bool Render::mltResizeClipStart(ItemInfo info, GenTime diff) mltAddClipTransparency(transpinfo, info.track - 1, QString(clip->parent().get("id")).toInt()); }*/ //m_mltConsumer->set("refresh", 1); - mlt_service_unlock(service.get_service()); + service.unlock(); m_mltConsumer->set("refresh", 1); return true; } @@ -3185,7 +3198,7 @@ bool Render::mltUpdateClipProducer(int track, int pos, Mlt::Producer *prod) kWarning() << "// TRACTOR PROBLEM"; return false; } - mlt_service_lock(service.get_service()); + service.lock(); Mlt::Tractor tractor(service); Mlt::Producer trackProducer(tractor.track(track)); Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service()); @@ -3194,14 +3207,14 @@ bool Render::mltUpdateClipProducer(int track, int pos, Mlt::Producer *prod) if (clipProducer == NULL || clipProducer->is_blank()) { kDebug() << "// ERROR UPDATING CLIP PROD"; delete clipProducer; - mlt_service_unlock(service.get_service()); + service.unlock(); return false; } Mlt::Producer *clip = prod->cut(clipProducer->get_in(), clipProducer->get_out()); if (!clip || !clip->is_valid()) { if (clip) delete clip; delete clipProducer; - mlt_service_unlock(service.get_service()); + service.unlock(); return false; } // move all effects to the correct producer @@ -3209,7 +3222,7 @@ bool Render::mltUpdateClipProducer(int track, int pos, Mlt::Producer *prod) trackPlaylist.insert_at(pos, clip, 1); delete clip; delete clipProducer; - mlt_service_unlock(service.get_service()); + service.unlock(); return true; } @@ -3222,7 +3235,7 @@ bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn } Mlt::Tractor tractor(service); - mlt_service_lock(service.get_service()); + service.lock(); Mlt::Producer trackProducer(tractor.track(startTrack)); Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service()); int clipIndex = trackPlaylist.get_clip_index_at(moveStart); @@ -3238,7 +3251,7 @@ bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn } //int ix = trackPlaylist.get_clip_index_at(moveEnd); kDebug() << "// ERROR MOVING CLIP TO : " << moveEnd; - mlt_service_unlock(service.get_service()); + service.unlock(); return false; } else { trackPlaylist.consolidate_blanks(0); @@ -3255,13 +3268,13 @@ bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn }*/ if (newIndex + 1 == trackPlaylist.count()) checkLength = true; } - //mlt_service_unlock(service.get_service()); + //service.unlock(); } else { Mlt::Producer destTrackProducer(tractor.track(endTrack)); Mlt::Playlist destTrackPlaylist((mlt_playlist) destTrackProducer.get_service()); if (!overwrite && !destTrackPlaylist.is_blank_at(moveEnd)) { // error, destination is not empty - mlt_service_unlock(service.get_service()); + service.unlock(); return false; } else { Mlt::Producer *clipProducer = trackPlaylist.replace_with_blank(clipIndex); @@ -3270,7 +3283,7 @@ bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn //int ix = trackPlaylist.get_clip_index_at(moveEnd); if (clipProducer) delete clipProducer; kDebug() << "// ERROR MOVING CLIP TO : " << moveEnd; - mlt_service_unlock(service.get_service()); + service.unlock(); return false; } trackPlaylist.consolidate_blanks(0); @@ -3318,7 +3331,7 @@ bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn else if (newIndex + 1 == destTrackPlaylist.count()) checkLength = true; } } - mlt_service_unlock(service.get_service()); + service.unlock(); if (checkLength) mltCheckLength(&tractor); //askForRefresh(); //m_mltConsumer->set("refresh", 1); @@ -3335,7 +3348,7 @@ QList Render::checkTrackSequence(int track) return list; } Mlt::Tractor tractor(service); - mlt_service_lock(service.get_service()); + service.lock(); Mlt::Producer trackProducer(tractor.track(track)); Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service()); int clipNb = trackPlaylist.count(); @@ -3371,7 +3384,7 @@ bool Render::mltMoveTransition(QString type, int startTrack, int newTrack, int n diff = new_out - m_mltProducer->position(); if (diff < 0 || diff > new_out - new_in) doRefresh = false; } - mlt_service_lock(service.get_service()); + service.lock(); mlt_service nextservice = mlt_service_get_producer(service.get_service()); mlt_properties properties = MLT_SERVICE_PROPERTIES(nextservice); @@ -3406,7 +3419,7 @@ bool Render::mltMoveTransition(QString type, int startTrack, int newTrack, int n mlt_type = mlt_properties_get(properties, "mlt_type"); resource = mlt_properties_get(properties, "mlt_service"); } - mlt_service_unlock(service.get_service()); + service.unlock(); if (doRefresh) refresh(); //if (m_isBlocked == 0) m_mltConsumer->set("refresh", 1); return found; @@ -3666,7 +3679,7 @@ void Render::mltResizeTransparency(int oldStart, int newStart, int newEnd, int t Mlt::Service service(m_mltProducer->parent().get_service()); Mlt::Tractor tractor(service); - mlt_service_lock(service.get_service()); + service.lock(); m_mltConsumer->set("refresh", 0); mlt_service serv = m_mltProducer->parent().get_service(); @@ -3693,7 +3706,7 @@ void Render::mltResizeTransparency(int oldStart, int newStart, int newEnd, int t mlt_type = mlt_properties_get(properties, "mlt_type"); resource = mlt_properties_get(properties, "mlt_service"); } - mlt_service_unlock(service.get_service()); + service.unlock(); m_mltConsumer->set("refresh", 1); } @@ -3703,7 +3716,7 @@ void Render::mltMoveTransparency(int startTime, int endTime, int startTrack, int Mlt::Service service(m_mltProducer->parent().get_service()); Mlt::Tractor tractor(service); - mlt_service_lock(service.get_service()); + service.lock(); m_mltConsumer->set("refresh", 0); mlt_service serv = m_mltProducer->parent().get_service(); @@ -3737,7 +3750,7 @@ void Render::mltMoveTransparency(int startTime, int endTime, int startTrack, int mlt_type = mlt_properties_get(properties, "mlt_type"); resource = mlt_properties_get(properties, "mlt_service"); } - mlt_service_unlock(service.get_service()); + service.unlock(); m_mltConsumer->set("refresh", 1); } @@ -3772,10 +3785,10 @@ bool Render::mltAddTransition(QString tag, int a_track, int b_track, GenTime in, //kDebug() << " ------ ADDING TRANS PARAM: " << key << ": " << it.value(); } // attach transition - mlt_service_lock(service.get_service()); + service.lock(); mltPlantTransition(field, *transition, a_track, b_track); // field->plant_transition(*transition, a_track, b_track); - mlt_service_unlock(service.get_service()); + service.unlock(); if (do_refresh) refresh(); return true; } @@ -3865,7 +3878,7 @@ void Render::mltInsertTrack(int ix, bool videoTrack) blockSignals(true); Mlt::Service service(m_mltProducer->parent().get_service()); - mlt_service_lock(service.get_service()); + service.lock(); if (service.type() != tractor_type) { kWarning() << "// TRACTOR PROBLEM"; return; @@ -3897,7 +3910,6 @@ void Render::mltInsertTrack(int ix, bool videoTrack) Mlt::Producer newProd(tractor.track(ix)); if (!videoTrack) newProd.set("hide", 1); } - checkMaxThreads(); // Move transitions @@ -3936,7 +3948,7 @@ void Render::mltInsertTrack(int ix, bool videoTrack) transition->set("combine", 1); field->plant_transition(*transition, 1, ct); //mlt_service_unlock(m_mltConsumer->get_service()); - mlt_service_unlock(service.get_service()); + service.unlock(); //tractor.multitrack()->refresh(); //tractor.refresh(); blockSignals(false); diff --git a/src/renderer.h b/src/renderer.h index 9acd058a..04d8452c 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -66,6 +66,11 @@ struct requestClipInfo { QString clipId; int imageHeight; bool replaceProducer; + +bool operator==(const requestClipInfo &a) +{ + return clipId == a.clipId; +} }; class MltErrorEvent : public QEvent @@ -283,6 +288,18 @@ Q_OBJECT public: /** @brief Force processing of clip with selected id. */ void forceProcessing(const QString &id); + /** @brief Requests the file properties for the specified URL (will be put in a queue list) + @param xml The xml parameters for the clip + @param clipId The clip Id string + @param imageHeight The height (in pixels) of the returned thumbnail (height of a treewidgetitem in projectlist) + @param replaceProducer If true, the MLT producer will be recreated */ + void getFileProperties(const QDomElement &xml, const QString &clipId, int imageHeight, bool replaceProducer = true); + + /** @brief Lock the MLT service */ + void lock(); + /** @brief Unlock the MLT service */ + void unlock(); + private: /** @brief The name of this renderer. @@ -349,7 +366,8 @@ private slots: void refresh(); void slotOsdTimeout(); int connectPlaylist(); - //void initSceneList(); + /** @brief Process the clip info requests (in a separate thread). */ + void processFileProperties(); signals: @@ -404,18 +422,6 @@ public slots: /** @brief Checks if the file is readable by MLT. */ bool isValid(KUrl url); - /** @brief Requests the file properties for the specified URL. - @param xml The xml parameters for the clip - @param clipId The clip Id string - @param imageHeight The height (in pixels) of the returned thumbnail (height of a treewidgetitem in projectlist) - @param replaceProducer If true, the MLT producer will be recreated - @param selectClip If true, clip item will be selected in project view - * Upon return, the result will be emitted via replyGetFileProperties(). - * Wraps the VEML command of the same name. */ - void getFileProperties(const QDomElement &xml, const QString &clipId, int imageHeight, bool replaceProducer = true); - - void getFileProperties2(); - void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime); void mltSavePlaylist(); void slotSplitView(bool doit); -- 2.39.5