]> git.sesse.net Git - kdenlive/blobdiff - src/docclipbase.cpp
Prepare for clip extra data (reusable analysis data)
[kdenlive] / src / docclipbase.cpp
index 40ff96f4c261c29db57c383ef07e60fdfdb8be6c..693e4ecca2f2829fc62d73add95782907d46fb70 100644 (file)
@@ -44,8 +44,8 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QStrin
         m_audioFrameCache(),
         m_refcount(0),
         m_baseTrackProducers(),
-        m_audioTrackProducers(),
         m_videoTrackProducers(),
+        m_audioTrackProducers(),
         m_snapMarkers(QList < CommentedTime >()),
         m_duration(),
         m_thumbProd(NULL),
@@ -290,22 +290,21 @@ QList < CommentedTime > DocClipBase::commentedSnapMarkers() const
 }
 
 
-void DocClipBase::addSnapMarker(const GenTime & time, QString comment)
+void DocClipBase::addSnapMarker(const CommentedTime marker)
 {
     QList < CommentedTime >::Iterator it = m_snapMarkers.begin();
     for (it = m_snapMarkers.begin(); it != m_snapMarkers.end(); ++it) {
-        if ((*it).time() >= time)
+        if ((*it).time() >= marker.time())
             break;
     }
 
-    if ((it != m_snapMarkers.end()) && ((*it).time() == time)) {
-        (*it).setComment(comment);
+    if ((it != m_snapMarkers.end()) && ((*it).time() == marker.time())) {
+        (*it).setComment(marker.comment());
+       (*it).setMarkerType(marker.markerType());
         //kError() << "trying to add Snap Marker that already exists, this will cause inconsistancies with undo/redo";
     } else {
-        CommentedTime t(time, comment);
-        m_snapMarkers.insert(it, t);
+        m_snapMarkers.insert(it, marker);
     }
-
 }
 
 void DocClipBase::editSnapMarker(const GenTime & time, QString comment)
@@ -378,10 +377,9 @@ GenTime DocClipBase::findNextSnapMarker(const GenTime & currTime)
     return duration();
 }
 
-QString DocClipBase::markerComment(GenTime t)
+QString DocClipBase::markerComment(GenTime t) const
 {
-    QList < CommentedTime >::Iterator itt = m_snapMarkers.begin();
-
+    QList < CommentedTime >::ConstIterator itt = m_snapMarkers.begin();
     while (itt != m_snapMarkers.end()) {
         if ((*itt).time() == t)
             return (*itt).comment();
@@ -390,6 +388,17 @@ QString DocClipBase::markerComment(GenTime t)
     return QString();
 }
 
+CommentedTime DocClipBase::markerAt(GenTime t) const
+{
+    QList < CommentedTime >::ConstIterator itt = m_snapMarkers.begin();
+    while (itt != m_snapMarkers.end()) {
+        if ((*itt).time() == t)
+            return (*itt);
+        ++itt;
+    }
+    return CommentedTime();
+}
+
 void DocClipBase::clearThumbProducer()
 {
     if (m_thumbProd) m_thumbProd->clearProducer();
@@ -503,7 +512,9 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset, bool readProp
             else delete producer;
             return;
         } else if (id.endsWith("video")) {
-           int pos = id.section('_', 0, 0).toInt();
+           int pos = 0;
+           // Keep compatibility with older projects where video only producers were not track specific
+           if (id.contains('_')) pos = id.section('_', 0, 0).toInt();
             if (pos >= m_videoTrackProducers.count()) {
                 while (m_videoTrackProducers.count() - 1 < pos) {
                     m_videoTrackProducers.append(NULL);
@@ -670,6 +681,9 @@ Mlt::Producer *DocClipBase::getCloneProducer()
             if (m_properties.contains("duration")) prod->set("length", m_properties.value("duration").toInt());
             if (m_properties.contains("out"))prod->set("out", m_properties.value("out").toInt());
         }
+        if (m_clipType == AUDIO) {
+           prod->set("_audioclip", 1);
+       }
     }
     return prod;
 }
@@ -1245,4 +1259,14 @@ QImage DocClipBase::extractImage(int frame, int width, int height)
     return m_thumbProd->extractImage(frame, width, height);
 }
 
+void DocClipBase::setAnalysisData(const QString &name, const QString &data)
+{
+    if (data.isEmpty()) m_analysisdata.remove(name);
+    else m_analysisdata.insert(name, data);
+}
+
+QMap <QString, QString> DocClipBase::analysisData() const
+{
+    return m_analysisdata;
+}