]> git.sesse.net Git - kdenlive/blobdiff - src/docclipbase.cpp
Fix crash on clip deletion, fix issues with placeholder clips
[kdenlive] / src / docclipbase.cpp
index 8fd36e282f68176aa2e03129f06cfd5373cdf2aa..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");
@@ -510,6 +508,7 @@ Mlt::Producer *DocClipBase::audioProducer(int track)
         Mlt::Producer *base = producer();
         m_audioTrackProducers[track] = new Mlt::Producer(*(base->profile()), base->get("resource"));
         if (m_properties.contains("force_aspect_ratio")) m_audioTrackProducers.at(track)->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble());
+        if (m_properties.contains("force_fps")) m_audioTrackProducers.at(track)->set("force_fps", m_properties.value("force_fps").toDouble());
         if (m_properties.contains("force_progressive")) m_audioTrackProducers.at(track)->set("force_progressive", m_properties.value("force_progressive").toInt());
         if (m_properties.contains("threads")) m_audioTrackProducers.at(track)->set("threads", m_properties.value("threads").toInt());
         m_audioTrackProducers.at(track)->set("video_index", -1);
@@ -530,6 +529,7 @@ Mlt::Producer *DocClipBase::videoProducer()
         if (i >= m_baseTrackProducers.count()) return NULL;
         m_videoOnlyProducer = new Mlt::Producer(*m_baseTrackProducers.at(i)->profile(), m_baseTrackProducers.at(i)->get("resource"));
         if (m_properties.contains("force_aspect_ratio")) m_videoOnlyProducer->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble());
+        if (m_properties.contains("force_fps")) m_videoOnlyProducer->set("force_fps", m_properties.value("force_fps").toDouble());
         if (m_properties.contains("force_progressive")) m_videoOnlyProducer->set("force_progressive", m_properties.value("force_progressive").toInt());
         if (m_properties.contains("threads")) m_videoOnlyProducer->set("threads", m_properties.value("threads").toInt());
         m_videoOnlyProducer->set("audio_index", -1);
@@ -574,6 +574,7 @@ Mlt::Producer *DocClipBase::producer(int track)
         }
 
         if (m_properties.contains("force_aspect_ratio")) m_baseTrackProducers[track]->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble());
+        if (m_properties.contains("force_fps")) m_baseTrackProducers[track]->set("force_fps", m_properties.value("force_fps").toDouble());
         if (m_properties.contains("force_progressive")) m_baseTrackProducers[track]->set("force_progressive", m_properties.value("force_progressive").toInt());
         if (m_properties.contains("threads")) m_baseTrackProducers[track]->set("threads", m_properties.value("threads").toInt());
         if (m_properties.contains("video_index")) m_baseTrackProducers[track]->set("video_index", m_properties.value("video_index").toInt());
@@ -821,6 +822,11 @@ void DocClipBase::setProperty(const QString &key, const QString &value)
             m_properties.remove("force_aspect_ratio");
             resetProducerProperty("force_aspect_ratio");
         } else setProducerProperty("force_aspect_ratio", value.toDouble());
+    } else if (key == "force_fps") {
+        if (value.isEmpty()) {
+            m_properties.remove("force_fps");
+            resetProducerProperty("force_fps");
+        } else setProducerProperty("force_fps", value.toDouble());
     } else if (key == "force_progressive") {
         if (value.isEmpty()) {
             m_properties.remove("force_progressive");
@@ -921,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;
+}
+