]> git.sesse.net Git - kdenlive/blobdiff - src/docclipbase.cpp
improve document checker
[kdenlive] / src / docclipbase.cpp
index e843889ab0184dd350a706bd093d781f160a1dbc..4c6ccad4eaa3370b2a8aae52294e5d43be37af38 100644 (file)
 #include <QCryptographicHash>
 
 DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id) :
-        m_id(id),
-        m_description(QString()),
+        QObject(),
+        m_audioFrameCache(),
         m_refcount(0),
-        m_audioThumbCreated(false),
-        m_duration(GenTime()),
-        m_thumbProd(NULL),
-        m_audioTimer(NULL),
-        m_properties(QMap <QString, QString> ()),
-        audioFrameChache(QMap<int, QMap<int, QByteArray> > ()),
-        m_baseTrackProducers(QList <Mlt::Producer *>()),
-        m_snapMarkers(QList < CommentedTime > ()),
+        m_baseTrackProducers(),
+        m_audioTrackProducers(),
         m_videoOnlyProducer(NULL),
-        m_audioTrackProducers(QList <Mlt::Producer *>())
+        m_snapMarkers(),
+        m_duration(),
+        m_audioTimer(NULL),
+        m_thumbProd(NULL),
+        m_audioThumbCreated(false),
+        m_id(id),
+        m_placeHolder(xml.hasAttribute("placeholder")),
+        m_properties()
 {
     int type = xml.attribute("type").toInt();
     m_clipType = (CLIPTYPE) type;
-
+    if (m_placeHolder) xml.removeAttribute("placeholder");
     QDomNamedNodeMap attributes = xml.attributes();
-    for (unsigned int i = 0; i < attributes.count(); i++) {
+    for (int i = 0; i < attributes.count(); i++) {
         m_properties.insert(attributes.item(i).nodeName(), attributes.item(i).nodeValue());
     }
 
@@ -90,15 +91,17 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QStrin
 
 DocClipBase::~DocClipBase()
 {
-    if (m_thumbProd) {
-        delete m_thumbProd;
-    }
+    delete m_thumbProd;
     if (m_audioTimer) {
         m_audioTimer->stop();
         delete m_audioTimer;
     }
     qDeleteAll(m_baseTrackProducers);
     m_baseTrackProducers.clear();
+    qDeleteAll(m_audioTrackProducers);
+    m_audioTrackProducers.clear();
+    delete m_videoOnlyProducer;
+    m_videoOnlyProducer = NULL;
 }
 
 void DocClipBase::setZone(QPoint zone)
@@ -132,7 +135,7 @@ void DocClipBase::slotClearAudioCache()
 {
     if (m_thumbProd) m_thumbProd->stopAudioThumbs();
     if (m_audioTimer != NULL) m_audioTimer->stop();
-    audioFrameChache.clear();
+    m_audioFrameCache.clear();
     m_audioThumbCreated = false;
 }
 
@@ -274,7 +277,7 @@ const QPixmap & DocClipBase::thumbnail() const
 void DocClipBase::updateAudioThumbnail(QMap<int, QMap<int, QByteArray> > data)
 {
     //kDebug() << "CLIPBASE RECIEDVED AUDIO DATA*********************************************";
-    audioFrameChache = data;
+    m_audioFrameCache = data;
     m_audioThumbCreated = true;
     emit gotAudioData();
 }
@@ -283,7 +286,7 @@ QList < GenTime > DocClipBase::snapMarkers() const
 {
     QList < GenTime > markers;
 
-    for (uint count = 0; count < m_snapMarkers.count(); ++count) {
+    for (int count = 0; count < m_snapMarkers.count(); ++count) {
         markers.append(m_snapMarkers[count].time());
     }
 
@@ -405,6 +408,10 @@ void DocClipBase::deleteProducers()
     qDeleteAll(m_baseTrackProducers);
     m_baseTrackProducers.clear();
     if (m_thumbProd) m_thumbProd->clearProducer();
+    qDeleteAll(m_audioTrackProducers);
+    m_audioTrackProducers.clear();
+    delete m_videoOnlyProducer;
+    m_videoOnlyProducer = NULL;
 }
 
 void DocClipBase::setProducer(Mlt::Producer *producer)
@@ -506,8 +513,13 @@ Mlt::Producer *DocClipBase::producer(int track)
         int i;
         for (i = 0; i < m_baseTrackProducers.count(); i++)
             if (m_baseTrackProducers.at(i) != NULL) break;
+
         if (i >= m_baseTrackProducers.count()) return NULL;
         m_baseTrackProducers[track] = new Mlt::Producer(*m_baseTrackProducers.at(i)->profile(), m_baseTrackProducers.at(i)->get("resource"));
+
+        // special case for placeholder clips
+        if (m_baseTrackProducers[track] == NULL) return NULL;
+
         if (m_properties.contains("force_aspect_ratio")) m_baseTrackProducers[track]->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble());
         if (m_properties.contains("threads")) m_baseTrackProducers[track]->set("threads", m_properties.value("threads").toInt());
         if (m_properties.contains("video_index")) m_baseTrackProducers[track]->set("video_index", m_properties.value("video_index").toInt());
@@ -570,14 +582,14 @@ void DocClipBase::slotRefreshProducer()
             int ct = 0;
             Mlt::Filter *filter = clipService.filter(ct);
             while (filter) {
-                if (filter->get("mlt_service") == "luma") {
+                if (strcmp(filter->get("mlt_service"), "luma") == 0) {
                     break;
                 }
                 ct++;
                 filter = clipService.filter(ct);
             }
 
-            if (filter && filter->get("mlt_service") == "luma") {
+            if (filter && strcmp(filter->get("mlt_service"), "luma") == 0) {
                 filter->set("period", getProperty("ttl").toInt() - 1);
                 filter->set("luma.out", getProperty("luma_duration").toInt());
                 QString resource = getProperty("luma_file");
@@ -609,7 +621,7 @@ void DocClipBase::slotRefreshProducer()
             int ct = 0;
             Mlt::Filter *filter = clipService.filter(0);
             while (filter) {
-                if (filter->get("mlt_service") == "luma") {
+                if (strcmp(filter->get("mlt_service"), "luma") == 0) {
                     clipService.detach(*filter);
                 } else ct++;
                 filter = clipService.filter(ct);
@@ -749,5 +761,8 @@ bool DocClipBase::slotGetAudioThumbs()
     return true;
 }
 
-
+bool DocClipBase::isPlaceHolder() const
+{
+    return m_placeHolder;
+}