]> git.sesse.net Git - kdenlive/blobdiff - src/docclipbase.cpp
Fix crash on clip deletion, fix issues with placeholder clips
[kdenlive] / src / docclipbase.cpp
index 7b7574c6404ab171e1763970fccb401d2dcb99d5..7b55fa5f3beba4fd871deb908d158fa4cebbd29f 100644 (file)
@@ -34,6 +34,8 @@
 
 #include <QCryptographicHash>
 
+#include <cstdio>
+
 DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id) :
         QObject(),
         m_audioFrameCache(),
@@ -41,7 +43,7 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QStrin
         m_baseTrackProducers(),
         m_audioTrackProducers(),
         m_videoOnlyProducer(NULL),
-        m_snapMarkers(),
+        m_snapMarkers(QList < CommentedTime >()),
         m_duration(),
         m_audioTimer(NULL),
         m_thumbProd(NULL),
@@ -323,10 +325,6 @@ QList < CommentedTime > DocClipBase::commentedSnapMarkers() const
     return m_snapMarkers;
 }
 
-void DocClipBase::setSnapMarkers(QList < CommentedTime > markers)
-{
-    m_snapMarkers = markers;
-}
 
 void DocClipBase::addSnapMarker(const GenTime & time, QString comment)
 {
@@ -460,7 +458,7 @@ void DocClipBase::deleteProducers()
 
 void DocClipBase::setProducer(Mlt::Producer *producer, bool reset)
 {
-    if (producer == NULL) return;
+    if (producer == NULL || m_placeHolder) return;
     if (reset) {
         // Clear all previous producers
         kDebug() << "/+++++++++++++++   DELETE ALL PRODS " << producer->get("id");
@@ -929,3 +927,38 @@ QList <CutZoneInfo> DocClipBase::cutZones() const
     return m_cutZones;
 }
 
+bool DocClipBase::hasVideoCodec(const QString &codec) const
+{
+    Mlt::Producer *prod = NULL;
+    if (m_baseTrackProducers.count() == 0) return false;
+    for (int i = 0; i < m_baseTrackProducers.count(); i++) {
+        if (m_baseTrackProducers.at(i) != NULL) {
+            prod = m_baseTrackProducers.at(i);
+            break;
+        }
+    }
+
+    if (!prod) return false;
+    int default_video = prod->get_int("video_index");
+    char property[200];
+    snprintf(property, sizeof(property), "meta.media.%d.codec.name", default_video);
+    return prod->get(property) == codec;
+}
+
+bool DocClipBase::hasAudioCodec(const QString &codec) const
+{
+    Mlt::Producer *prod = NULL;
+    if (m_baseTrackProducers.count() == 0) return false;
+    for (int i = 0; i < m_baseTrackProducers.count(); i++) {
+        if (m_baseTrackProducers.at(i) != NULL) {
+            prod = m_baseTrackProducers.at(i);
+            break;
+        }
+    }
+    if (!prod) return false;
+    int default_video = prod->get_int("audio_index");
+    char property[200];
+    snprintf(property, sizeof(property), "meta.media.%d.codec.name", default_video);
+    return prod->get(property) == codec;
+}
+