]> git.sesse.net Git - kdenlive/commitdiff
More efficient usage of MLT producers
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 19 Jul 2008 10:01:20 +0000 (10:01 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 19 Jul 2008 10:01:20 +0000 (10:01 +0000)
svn path=/branches/KDE4/; revision=2322

src/customtrackview.cpp
src/docclipbase.cpp
src/docclipbase.h
src/kthumb.cpp
src/kthumb.h
src/mainwindow.cpp
src/monitor.cpp
src/projectlist.cpp
src/projectlist.h
src/renderer.cpp
src/renderer.h

index 0e48dfaf014da8e369d60e44e52c956f4c66626d..2e7ba05810403dff7b720278a2de91b9cd1e1d83 100644 (file)
@@ -936,7 +936,7 @@ void CustomTrackView::dropEvent(QDropEvent * event) {
         info = m_dropItem->info();
         info.track = m_tracksList.count() - m_dropItem->track();
         // kDebug()<<"IIIIIIIIIIIIIIIIIIIIIIII TRAX CNT: "<<m_tracksList.count()<<", DROP: "<<m_dropItem->track();
-        m_document->renderer()->mltInsertClip(info, m_dropItem->xml());
+        m_document->renderer()->mltInsertClip(info, m_dropItem->xml(), m_dropItem->baseClip()->producer());
         m_document->setModified(true);
     } else QGraphicsView::dropEvent(event);
     m_dropItem = NULL;
@@ -1130,7 +1130,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) {
                         new AddTimelineClipCommand(this, clip->xml(), clip->clipProducer(), item->info(), false, false, moveClips);
                         ItemInfo info = item->info();
                         info.track = m_tracksList.count() - item->track();
-                        m_document->renderer()->mltInsertClip(info, clip->xml());
+                        m_document->renderer()->mltInsertClip(info, clip->xml(), clip->baseClip()->producer());
                     } else {
                         Transition *tr = static_cast <Transition*>(item);
                         ItemInfo transitionInfo = tr->info();
@@ -1301,7 +1301,7 @@ void CustomTrackView::addClip(QDomElement xml, int clipId, ItemInfo info) {
     baseclip->addReference();
     m_document->updateClip(baseclip->getId());
     info.track = m_tracksList.count() - info.track;
-    m_document->renderer()->mltInsertClip(info, xml);
+    m_document->renderer()->mltInsertClip(info, xml, baseclip->producer());
     m_document->renderer()->doRefresh();
 }
 
@@ -1315,7 +1315,7 @@ void CustomTrackView::slotUpdateClip(int clipId) {
                 clip->refreshClip();
                 ItemInfo info = clip->info();
                 info.track = m_tracksList.count() - clip->track();
-                m_document->renderer()->mltUpdateClip(info, clip->xml());
+                m_document->renderer()->mltUpdateClip(info, clip->xml(), clip->baseClip()->producer());
             }
         }
     }
index a380b8fafa4b1c9e6271bd266091aca65fe59eee..3bb9dab3e365a3f34bf4a0bcd0a2200c8354dcd4 100644 (file)
@@ -23,7 +23,7 @@
 #include "clipmanager.h"
 
 DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, uint id):
-        m_id(id), m_description(QString()), m_refcount(0), m_audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL) {
+        m_id(id), m_description(QString()), m_refcount(0), m_audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL), m_clipProducer(NULL) {
     int type = xml.attribute("type").toInt();
     m_clipType = (CLIPTYPE) type;
     m_name = xml.attribute("name");
@@ -51,18 +51,7 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, uint id):
     //kDebug() << "type is video" << (m_clipType == AV) << " " << m_clipType;
 }
 
-
-
-DocClipBase::DocClipBase(const DocClipBase& clip) {
-    m_id = clip.getId();
-    m_clipType = clip.clipType();
-    m_name = clip.name();
-    m_duration = clip.duration();
-    m_audioThumbCreated = clip.audioThumbCreated();
-    m_properties = clip.properties();
-}
-
-DocClipBase & DocClipBase::operator=(const DocClipBase & clip) {
+/*DocClipBase & DocClipBase::operator=(const DocClipBase & clip) {
     DocClipBase::operator=(clip);
     m_id = clip.getId();
     m_clipType = clip.clipType();
@@ -71,10 +60,11 @@ DocClipBase & DocClipBase::operator=(const DocClipBase & clip) {
     m_audioThumbCreated = clip.audioThumbCreated();
     m_properties = clip.properties();
     return *this;
-}
+}*/
 
 DocClipBase::~DocClipBase() {
     if (m_thumbProd) delete m_thumbProd;
+    if (m_clipProducer) delete m_clipProducer;
 }
 
 void DocClipBase::slotCreateAudioTimer() {
@@ -366,6 +356,15 @@ QString DocClipBase::markerComment(GenTime t) {
     return QString::null;
 }
 
+void DocClipBase::setProducer(Mlt::Producer *producer) {
+    m_clipProducer = producer;
+    if (m_thumbProd) m_thumbProd->setProducer(producer);
+}
+
+Mlt::Producer *DocClipBase::producer() {
+    return m_clipProducer;
+}
+
 void DocClipBase::setProperties(QMap <QString, QString> properties) {
     // changing clip type is not allowed
     properties.remove("type");
index 634a47b40ce02c902f45f4df5b27517ce8eab7a4..51ecdd039e6a103512972c5f60e12e889f7d7d32 100644 (file)
@@ -42,7 +42,9 @@ class KdenliveDoc;
 class KThumb;
 class ClipManager;
 
-
+namespace Mlt {
+class Producer;
+};
 
 
 class DocClipBase: public QObject {
@@ -53,8 +55,7 @@ Q_OBJECT public:
      *   and video. */
 
     DocClipBase(ClipManager *clipManager, QDomElement xml, uint id);
-    DocClipBase(const DocClipBase& clip);
-    DocClipBase & operator=(const DocClipBase & clip);
+//    DocClipBase & operator=(const DocClipBase & clip);
     virtual ~ DocClipBase();
 
     /** sets the name of this clip. */
@@ -105,6 +106,9 @@ Q_OBJECT public:
         return false;
     }
 
+    void setProducer(Mlt::Producer *producer);
+    Mlt::Producer *producer();
+
     /*virtual DocClipAVFile *toDocClipAVFile() {
     return 0;
     }
@@ -190,7 +194,7 @@ private:   // Private attributes
     /** The number of times this clip is used in the project - the number of references to this clip
      * that exist. */
     uint m_refcount;
-
+    Mlt::Producer *m_clipProducer;
     CLIPTYPE m_clipType;
 
     /** A list of snap markers; these markers are added to a clips snap-to points, and are displayed as necessary. */
index accd897f5f61d858f3dda172e7da9260a250145a..a881ec606480b04db78a844032658f8292c40663 100644 (file)
@@ -132,7 +132,7 @@ void MyThread::run() {
 #define _G(y,u,v) (0x2568*(y) - 0x0c92*(v) - 0x1a1e*(u)) /0x2000
 #define _B(y,u,v) (0x2568*(y) + 0x40cf*(v))                                          /0x2000
 
-KThumb::KThumb(ClipManager *clipManager, KUrl url, QObject * parent, const char *name): QObject(parent), m_clipManager(clipManager), m_url(url) {
+KThumb::KThumb(ClipManager *clipManager, KUrl url, QObject * parent, const char *name): QObject(parent), m_clipManager(clipManager), m_url(url), m_producer(NULL) {
 
     m_profile = new Mlt::Profile((char*) KdenliveSettings::current_profile().data());
     QCryptographicHash context(QCryptographicHash::Sha1);
@@ -146,6 +146,10 @@ KThumb::~KThumb() {
     if (thumbProducer.isRunning()) thumbProducer.exit();
 }
 
+void KThumb::setProducer(Mlt::Producer *producer) {
+    m_producer = producer;
+}
+
 void KThumb::updateClipUrl(KUrl url) {
     m_url = url;
 }
@@ -158,23 +162,24 @@ QPixmap KThumb::getImage(KUrl url, int width, int height) {
 
 void KThumb::extractImage(int frame, int frame2) {
     if (m_url.isEmpty()) return;
-    char *tmp = Render::decodedString("<westley><playlist><producer resource=\"" + m_url.path() + "\" /></playlist></westley>");
+    if (m_producer == NULL) return;
+    /*char *tmp = Render::decodedString("<westley><playlist><producer resource=\"" + m_url.path() + "\" /></playlist></westley>");
     Mlt::Producer producer(*m_profile, "westley-xml", tmp);
-    delete[] tmp;
+    delete[] tmp;*/
 
     int twidth = (int)(KdenliveSettings::trackheight() * m_profile->dar());
-    if (producer.is_blank()) {
+    if (m_producer->is_blank()) {
         QPixmap pix(twidth, KdenliveSettings::trackheight());
         pix.fill(Qt::black);
         emit thumbReady(frame, pix);
         return;
     }
     if (frame != -1) {
-        QPixmap pix = getFrame(producer, frame, twidth, KdenliveSettings::trackheight());
+        QPixmap pix = getFrame(*m_producer, frame, twidth, KdenliveSettings::trackheight());
         emit thumbReady(frame, pix);
     }
     if (frame2 != -1) {
-        QPixmap pix = getFrame(producer, frame2, twidth , KdenliveSettings::trackheight());
+        QPixmap pix = getFrame(*m_producer, frame2, twidth , KdenliveSettings::trackheight());
         emit thumbReady(frame2, pix);
     }
 }
index ffbd745d16042ce6c9a9db2f6176af922ab6adf9..65f80efd1d0a58cdd3e2baa0461800d858dc1079 100644 (file)
@@ -74,6 +74,7 @@ Q_OBJECT public:
 
     KThumb(ClipManager *clipManager, KUrl url, QObject * parent = 0, const char *name = 0);
     ~KThumb();
+    void setProducer(Mlt::Producer *producer);
 
 public slots:
     void extractImage(int frame, int frame2);
@@ -96,6 +97,7 @@ private:
     KUrl m_url;
     QString m_thumbFile;
     Mlt::Profile *m_profile;
+    Mlt::Producer *m_producer;
     ClipManager *m_clipManager;
 
 signals:
index 2c9d015b730dade28a8e97a56185b449b088b8e3..fc6955bca9b2b1277bcaeb5869e3a07d38757602 100644 (file)
 #define ID_TIMELINE_POS 6
 #define ID_TIMELINE_FORMAT 7
 
+namespace Mlt {
+class Producer;
+};
+
 EffectsList MainWindow::videoEffects;
 EffectsList MainWindow::audioEffects;
 EffectsList MainWindow::customEffects;
@@ -381,7 +385,7 @@ void MainWindow::slotConnectMonitors() {
     connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
     connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
     connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
-    connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)));
+    connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(int, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(int, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)));
     connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
 }
 
index e03be8a57ea281a1cbdd7aeb7d46720f4f7204f0..ac44012a87e68815e9b45cd3865a0e64230bb6ba 100644 (file)
@@ -301,11 +301,7 @@ void Monitor::slotSetXml(DocClipBase *clip, const int position) {
     if (!clip) return;
     if (clip != m_currentClip) {
         m_currentClip = clip;
-        QDomDocument doc;
-        QDomElement westley = doc.createElement("westley");
-        doc.appendChild(westley);
-        westley.appendChild(doc.importNode(m_currentClip->toXML(), true));
-        render->setSceneList(doc, 0);
+        render->setProducer(clip->producer(), 0);
         m_ruler->slotNewValue(0);
         m_timePos->setText("00:00:00:00");
         m_position = 0;
index 879a7bbc4c248dbf59317a91bb4e48a0b3867064..b9191ced82acdc305cbaaf63b3645f76b8595f38 100644 (file)
@@ -453,13 +453,14 @@ void ProjectList::slotRefreshClipThumbnail(ProjectItem *item) {
     }
 }
 
-void ProjectList::slotReplyGetFileProperties(int clipId, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata) {
+void ProjectList::slotReplyGetFileProperties(int clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata) {
     ProjectItem *item = getItemById(clipId);
     if (item) {
         item->setProperties(properties, metadata);
+        item->referencedClip()->setProducer(producer);
         listView->setCurrentItem(item);
         emit receivedClipDuration(clipId, item->clipMaxDuration());
-    }
+    } else kDebug() << "////////  COULD NOT FIND CLIP TO UPDATE PRPS...";
 }
 
 void ProjectList::slotReplyGetImage(int clipId, int pos, const QPixmap &pix, int w, int h) {
index 99a16114f4cf03939710c61762c8779490626eab..31a16341de17b510b463ebbd2008b38cd67b8575 100644 (file)
 #include "definitions.h"
 #include "timecode.h"
 
+namespace Mlt {
+class Producer;
+};
+
 class ProjectItem;
 class ProjectListView;
 class Render;
@@ -108,7 +112,7 @@ public:
 public slots:
     void setDocument(KdenliveDoc *doc);
     void slotReplyGetImage(int clipId, int pos, const QPixmap &pix, int w, int h);
-    void slotReplyGetFileProperties(int clipId, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata);
+    void slotReplyGetFileProperties(int clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata);
     void slotAddClip(DocClipBase *clip);
     void slotDeleteClip(int clipId);
     void slotUpdateClip(int id);
index 17593582989f38d814b1ab3355585dc9beadfded..cc0b15db4782ed7a5a76e7e83a5afbd7bc290dc8 100644 (file)
@@ -61,7 +61,7 @@ static void consumer_frame_show(mlt_consumer, Render * self, mlt_frame frame_ptr
     }
 }
 
-Render::Render(const QString & rendererName, int winid, int extid, QWidget *parent): QObject(parent), m_name(rendererName), m_mltConsumer(NULL), m_mltProducer(NULL), m_mltTextProducer(NULL), m_winid(-1), m_framePosition(0), m_generateScenelist(false), m_isBlocked(true) {
+Render::Render(const QString & rendererName, int winid, int extid, QWidget *parent): QObject(parent), m_name(rendererName), m_mltConsumer(NULL), m_mltProducer(NULL), m_mltTextProducer(NULL), m_winid(-1), m_framePosition(0), m_generateScenelist(false), m_isBlocked(true), m_blackClip(NULL) {
     kDebug() << "//////////  USING PROFILE: " << (char *)KdenliveSettings::current_profile().toUtf8().data();
     m_mltProfile = new Mlt::Profile((char*) KdenliveSettings::current_profile().data());
     refreshTimer = new QTimer(this);
@@ -89,6 +89,8 @@ Render::Render(const QString & rendererName, int winid, int extid, QWidget *pare
         m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
         Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "westley-xml", "<westley><playlist><producer mlt_service=\"colour\" colour=\"blue\" in=\"0\" out=\"25\" /></playlist></westley>");
         m_mltProducer = producer;
+        if (m_blackClip) delete m_blackClip;
+        m_blackClip = new Mlt::Producer(*m_mltProfile , "colour", "black");
         m_mltConsumer->connect(*m_mltProducer);
         m_mltProducer->set_speed(0.0);
 
@@ -121,7 +123,7 @@ void Render::closeMlt() {
         delete m_mltConsumer;
     if (m_mltProducer)
         delete m_mltProducer;
-    while (! m_producersList.isEmpty()) delete m_producersList.takeFirst();
+    if (m_blackClip) delete m_blackClip;
     //delete m_osdInfo;
 }
 
@@ -162,6 +164,8 @@ int Render::resetProfile(QString profile) {
     Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "westley-xml", tmp);
     delete[] tmp;
     m_mltProducer = producer;
+    if (m_blackClip) delete m_blackClip;
+    m_blackClip = new Mlt::Producer(*m_mltProfile , "colour", "black");
     m_mltProducer->optimise();
     m_mltProducer->set_speed(0);
     connectPlaylist();
@@ -384,36 +388,34 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) {
     QMap < QString, QString > metadataPropertyMap;
 
     KUrl url = KUrl(xml.attribute("resource", QString::null));
-    bool newProducer = false;
-
-    Mlt::Producer *producer = getProducerById(QString::number(clipId));
-    if (producer == NULL) {
-        if (true /*url.isEmpty()*/) {
-            QDomDocument doc;
-            QDomElement westley = doc.createElement("westley");
-            QDomElement play = doc.createElement("playlist");
-            doc.appendChild(westley);
-            westley.appendChild(play);
-            play.appendChild(doc.importNode(xml, true));
-            char *tmp = decodedString(doc.toString());
-            producer = new Mlt::Producer(*m_mltProfile, "westley-xml", tmp);
-            delete[] tmp;
-        } else {
-            char *tmp = decodedString(url.path());
-            producer = new Mlt::Producer(*m_mltProfile, tmp);
-            delete[] tmp;
-        }
-
-        if (producer->is_blank()) {
-            kDebug() << " / / / / / / / /ERRROR / / / / // CANNOT LOAD PRODUCER: ";
-            return;
-        }
-        m_producersList.append(producer);
-        newProducer = true;
+    Mlt::Producer *producer;
+    if (xml.attribute("type").toInt() == COLOR) {
+        char *tmp = decodedString("colour:" + xml.attribute("colour"));
+        producer = new Mlt::Producer(*m_mltProfile, "fezzik", tmp);
+        producer->set_in_and_out(xml.attribute("in").toInt(), xml.attribute("out").toInt());
+        delete[] tmp;
+    } else if (url.isEmpty()) {
+        QDomDocument doc;
+        QDomElement westley = doc.createElement("westley");
+        QDomElement play = doc.createElement("playlist");
+        doc.appendChild(westley);
+        westley.appendChild(play);
+        play.appendChild(doc.importNode(xml, true));
+        kDebug() << "/ / / / /CLIP XML: " << doc.toString();
+        char *tmp = decodedString(doc.toString());
+        producer = new Mlt::Producer(*m_mltProfile, "westley-xml", tmp);
+        delete[] tmp;
+    } else {
+        char *tmp = decodedString(url.path());
+        producer = new Mlt::Producer(*m_mltProfile, tmp);
+        if (!xml.attribute("out").isEmpty()) producer->set_in_and_out(xml.attribute("in").toInt(), xml.attribute("out").toInt());
+        delete[] tmp;
     }
-
-
-
+    if (producer->is_blank()) {
+        kDebug() << " / / / / / / / /ERRROR / / / / // CANNOT LOAD PRODUCER: ";
+        return;
+    }
+    producer->set("id", clipId);
     int frameNumber = xml.attribute("thumbnail", "0").toInt();
     if (frameNumber != 0) producer->seek(frameNumber);
     mlt_properties properties = MLT_PRODUCER_PROPERTIES(producer->get_producer());
@@ -513,10 +515,10 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) {
             metadataPropertyMap[ name.section(".", 0, -2)] = value;
     }
 
-    emit replyGetFileProperties(clipId, filePropertyMap, metadataPropertyMap);
+    emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap);
     kDebug() << "REquested fuile info for: " << url.path();
     if (frame) delete frame;
-    if (!newProducer && producer) delete producer;
+    //if (producer) delete producer;
 }
 
 /** Create the producer from the Westley QDomDocument */
@@ -555,6 +557,40 @@ void Render::initSceneList() {
     setSceneList(doc, 0);
 }
 #endif
+
+
+
+/** Create the producer from the Westley QDomDocument */
+void Render::setProducer(Mlt::Producer *producer, int position) {
+    if (m_winid == -1) return;
+    m_generateScenelist = true;
+
+    if (m_mltConsumer) {
+        m_mltConsumer->stop();
+    } else return;
+
+    if (m_mltProducer) {
+        m_mltProducer->set_speed(0);
+        delete m_mltProducer;
+        m_mltProducer = NULL;
+        emit stopped();
+    }
+    if (producer) m_mltProducer = new Mlt::Producer(producer->get_producer());
+    else m_mltProducer = new Mlt::Producer();
+    if (!m_mltProducer || !m_mltProducer->is_valid()) kDebug() << " WARNING - - - - -INVALID PLAYLIST: ";
+    m_mltProducer->optimise();
+
+    m_fps = m_mltProducer->get_fps();
+    connectPlaylist();
+    if (position != 0) {
+        m_mltProducer->seek(position);
+        emit rendererPosition(position);
+    }
+    m_generateScenelist = false;
+}
+
+
+
 /** Create the producer from the Westley QDomDocument */
 void Render::setSceneList(QDomDocument list, int position) {
     setSceneList(list.toString(), position);
@@ -592,6 +628,8 @@ void Render::setSceneList(QString playlist, int position) {
     char *tmp = decodedString(playlist);
     m_mltProducer = new Mlt::Producer(*m_mltProfile, "westley-xml", tmp);
     delete[] tmp;
+    if (m_blackClip) delete m_blackClip;
+    m_blackClip = new Mlt::Producer(*m_mltProfile , "colour", "black");
     if (!m_mltProducer || !m_mltProducer->is_valid()) kDebug() << " WARNING - - - - -INVALID PLAYLIST: " << tmp;
     m_mltProducer->optimise();
 
@@ -691,7 +729,6 @@ void Render::connectPlaylist() {
     m_mltConsumer->connect(*m_mltProducer);
     m_mltProducer->set_speed(0);
     m_mltConsumer->start();
-    parsePlaylistForClips();
     emit durationChanged(m_mltProducer->get_playtime());
     //refresh();
     /*
@@ -1044,21 +1081,21 @@ void Render::mltCheckLength(bool reload) {
         while (dur > 14000) {
             info.startPos = GenTime(i * 14000, m_fps);
             info.endPos = info.startPos + GenTime(13999, m_fps);
-            mltInsertClip(info, black);
+            mltInsertClip(info, black, m_blackClip);
             dur = dur - 14000;
             i++;
         }
         if (dur > 0) {
             info.startPos = GenTime(i * 14000, m_fps);
             info.endPos = info.startPos + GenTime(dur, m_fps);
-            mltInsertClip(info, black);
+            mltInsertClip(info, black, m_blackClip);
         }
         m_mltProducer->set("out", duration);
         emit durationChanged((int)duration);
     }
 }
 
-void Render::mltInsertClip(ItemInfo info, QDomElement element) {
+void Render::mltInsertClip(ItemInfo info, QDomElement element, Mlt::Producer *prod) {
     if (!m_mltProducer) {
         kDebug() << "PLAYLIST NOT INITIALISED //////";
         return;
@@ -1075,8 +1112,7 @@ void Render::mltInsertClip(ItemInfo info, QDomElement element) {
     Mlt::Producer trackProducer(tractor.track(info.track));
     Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
 
-    Mlt::Producer *prod = getProducerById(element.attribute("id"));
-    if (prod == NULL) {
+    /*if (prod == NULL) {
         // clip was never used yet
         QDomDocument doc;
         doc.appendChild(doc.importNode(element, true));
@@ -1085,8 +1121,7 @@ void Render::mltInsertClip(ItemInfo info, QDomElement element) {
         char *tmp = decodedString(resource);
         prod = new Mlt::Producer(*m_mltProfile, "westley-xml", tmp);
         delete[] tmp;
-        m_producersList.append(prod);
-    }
+    }*/
 
     Mlt::Producer *clip = prod->cut(info.cropStart.frames(m_fps), (info.endPos - info.startPos).frames(m_fps));
     trackPlaylist.insert_at((int) info.startPos.frames(m_fps), *clip, 1);
@@ -1098,41 +1133,6 @@ void Render::mltInsertClip(ItemInfo info, QDomElement element) {
     //tractor.refresh();
 }
 
-Mlt::Producer *Render::getProducerById(const QString &id) {
-    for (int i = 0; i < m_producersList.count(); i++) {
-        if (m_producersList.at(i)->get("id") == id) return m_producersList.at(i);
-    }
-    return NULL;
-}
-
-void Render::parsePlaylistForClips() {
-    // clear current producers list
-    while (! m_producersList.isEmpty()) delete m_producersList.takeFirst();
-
-    //parse entire playlists to find all the different clips
-    Mlt::Producer parentProd(m_mltProducer->parent());
-    if (parentProd.get_producer() == NULL) {
-        kDebug() << "PLAYLIST BROKEN, CANNOT INSERT CLIP //////";
-        return;
-    }
-    Mlt::Service service(parentProd.get_service());
-    if (service.type() != tractor_type) return;
-    Mlt::Tractor tractor(service);
-    mlt_service_lock(service.get_service());
-    for (int i = 0; i < tractor.count(); i++) {
-        Mlt::Producer trackProducer(tractor.track(i));
-        Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
-        for (int j = 0; j < trackPlaylist.count(); j++) {
-            if (!trackPlaylist.is_blank(j)) {
-                Mlt::Producer *clip = trackPlaylist.get_clip(j);
-                if (clip) {
-                    if (getProducerById(clip->get("id")) == NULL)
-                        m_producersList.append(new Mlt::Producer(clip->get_parent()));
-                }
-            }
-        }
-    }
-}
 
 void Render::mltCutClip(int track, GenTime position) {
     m_isBlocked = true;
@@ -1148,10 +1148,10 @@ void Render::mltCutClip(int track, GenTime position) {
     m_isBlocked = false;
 }
 
-void Render::mltUpdateClip(ItemInfo info, QDomElement element) {
+void Render::mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *prod) {
     // TODO: optimize
     mltRemoveClip(info.track, info.startPos);
-    mltInsertClip(info, element);
+    mltInsertClip(info, element, prod);
 }
 
 
index 324a20d28bfb17e19ee7c7671fcf0fd39d3aea00..75a6daed13de236ad11b5fafb46d7a683372ff83 100644 (file)
@@ -91,6 +91,7 @@ Q_OBJECT public:
     be list. */
     void setSceneList(QDomDocument list, int position = 0);
     void setSceneList(QString playlist, int position = 0);
+    void setProducer(Mlt::Producer *producer, int position);
     QString sceneList();
     void saveSceneList(QString path, QDomElement kdenliveData = QDomElement());
 
@@ -147,8 +148,8 @@ Q_OBJECT public:
     const double dar() const;
 
     /** Playlist manipulation */
-    void mltInsertClip(ItemInfo info, QDomElement element);
-    void mltUpdateClip(ItemInfo info, QDomElement element);
+    void mltInsertClip(ItemInfo info, QDomElement element, Mlt::Producer *prod);
+    void mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *prod);
     void mltCutClip(int track, GenTime position);
     void mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out);
     void mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out);
@@ -180,9 +181,7 @@ private:   // Private attributes & methods
     uint m_monitorId;
     bool m_generateScenelist;
 
-    QList <Mlt::Producer *> m_producersList;
-    Mlt::Producer *getProducerById(const QString &id);
-    void parsePlaylistForClips();
+    Mlt::Producer *m_blackClip;
     /** Holds the path to on screen display profile */
     QString m_osdProfile;
 
@@ -213,7 +212,7 @@ private slots:  // Private slots
 
 signals:   // Signals
     /** emitted when the renderer recieves a reply to a getFileProperties request. */
-    void replyGetFileProperties(int clipId, const QMap < QString, QString > &, const QMap < QString, QString > &);
+    void replyGetFileProperties(int clipId, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &);
 
     /** emitted when the renderer recieves a reply to a getImage request. */
     void replyGetImage(int , int, const QPixmap &, int, int);