]> git.sesse.net Git - kdenlive/blob - src/docclipbase.cpp
Clear monitor when the clip was removed from project, should fix:
[kdenlive] / src / docclipbase.cpp
1 /**************************1*************************************************
2                           DocClipBase.cpp  -  description
3                              -------------------
4     begin                : Fri Apr 12 2002
5     copyright            : (C) 2002 by Jason Wood
6     email                : jasonwood@blueyonder.co.uk
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #include <QCryptographicHash>
19
20 #include <KDebug>
21
22 #include "kdenlivesettings.h"
23 #include "docclipbase.h"
24 #include "kthumb.h"
25 #include "clipmanager.h"
26
27 DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id):
28         m_id(id), m_description(QString()), 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 > ())  {
29     int type = xml.attribute("type").toInt();
30     m_clipType = (CLIPTYPE) type;
31     m_name = xml.attribute("name");
32
33     QDomNamedNodeMap attributes = xml.attributes();
34     for (unsigned int i = 0; i < attributes.count(); i++) {
35         m_properties.insert(attributes.item(i).nodeName(), attributes.item(i).nodeValue());
36     }
37
38     KUrl url = KUrl(xml.attribute("resource"));
39     if (!m_properties.contains("file_hash") && !url.isEmpty()) getFileHash(url.path());
40     int out = xml.attribute("out").toInt();
41     if (out != 0) {
42         setDuration(GenTime(out, KdenliveSettings::project_fps()));
43     } else {
44         out = xml.attribute("duration").toInt();
45         if (out != 0) setDuration(GenTime(out, KdenliveSettings::project_fps()));
46     }
47     if (m_name.isEmpty()) m_name = url.fileName();
48
49     //if (!url.isEmpty() && QFile::exists(url.path()))
50     {
51         m_thumbProd = new KThumb(clipManager, url, m_id, m_properties.value("file_hash"));
52         if (m_clipType == AV || m_clipType == AUDIO) slotCreateAudioTimer();
53     }
54     //kDebug() << "type is video" << (m_clipType == AV) << " " << m_clipType;
55 }
56
57 /*DocClipBase & DocClipBase::operator=(const DocClipBase & clip) {
58     DocClipBase::operator=(clip);
59     m_id = clip.getId();
60     m_clipType = clip.clipType();
61     m_name = clip.name();
62     m_duration = clip.duration();
63     m_audioThumbCreated = clip.audioThumbCreated();
64     m_properties = clip.properties();
65     return *this;
66 }*/
67
68 DocClipBase::~DocClipBase() {
69     if (m_thumbProd) {
70         delete m_thumbProd;
71     }
72     qDeleteAll(m_baseTrackProducers);
73     m_baseTrackProducers.clear();
74 }
75
76 void DocClipBase::slotCreateAudioTimer() {
77     connect(m_thumbProd, SIGNAL(audioThumbReady(QMap <int, QMap <int, QByteArray> >)), this , SLOT(updateAudioThumbnail(QMap <int, QMap <int, QByteArray> >)));
78     connect(this, SIGNAL(getAudioThumbs()), this , SLOT(slotGetAudioThumbs()));
79     m_audioTimer = new QTimer(this);
80     connect(m_audioTimer, SIGNAL(timeout()), this, SLOT(slotGetAudioThumbs()));
81 }
82
83 void DocClipBase::askForAudioThumbs() {
84     if (m_thumbProd) m_thumbProd->askForAudioThumbs(getId());
85 }
86
87 void DocClipBase::slotClearAudioCache() {
88     if (m_thumbProd) m_thumbProd->stopAudioThumbs();
89     if (m_audioTimer != NULL) m_audioTimer->stop();
90     audioFrameChache.clear();
91     m_audioThumbCreated = false;
92 }
93
94 /*void DocClipBase::getClipMainThumb() {
95     if (m_thumbProd) m_thumbProd->getMainThumb(m_properties.value("thumbnail").toInt());
96 }*/
97
98 KThumb *DocClipBase::thumbProducer() {
99     return m_thumbProd;
100 }
101
102 bool DocClipBase::audioThumbCreated() const {
103     return m_audioThumbCreated;
104 }
105
106 void DocClipBase::setName(const QString name) {
107     m_name = name;
108 }
109
110 const QString & DocClipBase::name() const {
111
112     return m_name;
113 }
114
115 const QString &DocClipBase::getId() const {
116     return m_id;
117 }
118
119 void DocClipBase::setId(const QString &newId) {
120     m_id = newId;
121 }
122
123 const CLIPTYPE & DocClipBase::clipType() const {
124     return m_clipType;
125 }
126
127 void DocClipBase::setClipType(CLIPTYPE type) {
128     m_clipType = type;
129
130     m_properties.insert("type", QString::number((int) type));
131     if (m_thumbProd && m_audioTimer == NULL && (m_clipType == AV || m_clipType == AUDIO))
132         slotCreateAudioTimer();
133 }
134
135 KUrl DocClipBase::fileURL() const {
136     QString res = m_properties.value("resource");
137     if (m_clipType != COLOR && !res.isEmpty()) return KUrl(res);
138     return KUrl();
139 }
140
141 void DocClipBase::setClipThumbFrame(const uint &ix) {
142     m_properties.insert("thumbnail", QString::number((int) ix));
143 }
144
145 uint DocClipBase::getClipThumbFrame() const {
146     return (uint) m_properties.value("thumbnail").toInt();
147 }
148
149 const QString DocClipBase::description() const {
150     return m_properties.value("description");
151 }
152
153 bool DocClipBase::isTransparent() const {
154     return (m_properties.value("transparency") == "1");
155 }
156
157 const QString DocClipBase::getProperty(const QString prop) const {
158     return m_properties.value(prop);
159 }
160
161 void DocClipBase::setDuration(GenTime dur) {
162     m_duration = dur;
163     m_properties.insert("duration", QString::number((int) dur.frames(KdenliveSettings::project_fps())));
164 }
165
166 const GenTime &DocClipBase::duration() const {
167     return m_duration;
168 }
169
170 const GenTime &DocClipBase::maxDuration() const {
171     if (m_clipType == COLOR || m_clipType == IMAGE || m_clipType == TEXT || (m_clipType == SLIDESHOW &&  m_properties.value("loop") == "1")) {
172         const GenTime dur(15000, KdenliveSettings::project_fps());
173         return dur;
174     }
175     return m_duration;
176 }
177
178 bool DocClipBase::hasFileSize() const {
179     return true;
180 }
181
182
183 // virtual
184 QDomElement DocClipBase::toXML() const {
185     QDomDocument doc;
186
187     QDomElement clip = doc.createElement("producer");
188
189     QMapIterator<QString, QString> i(m_properties);
190     while (i.hasNext()) {
191         i.next();
192         if (!i.value().isEmpty()) clip.setAttribute(i.key(), i.value());
193     }
194     //doc.appendChild(clip);
195     //kDebug()<<"/// CLIP XML: "<<doc.toString();
196     return clip;
197 }
198
199 DocClipBase *DocClipBase::
200 createClip(KdenliveDoc *doc, const QDomElement & element) {
201     DocClipBase *clip = 0;
202     QString description;
203     QDomNode node = element;
204     node.normalize();
205     if (element.tagName() != "kdenliveclip") {
206         kWarning() <<
207         "DocClipBase::createClip() element has unknown tagName : " << element.tagName();
208         return 0;
209     }
210
211     QDomNode n = element.firstChild();
212
213     while (!n.isNull()) {
214         QDomElement e = n.toElement();
215         if (!e.isNull()) {
216             QString tagName = e.tagName();
217             if (e.tagName() == "avfile") {
218                 // clip = DocClipAVFile::createClip(e);
219             } else if (e.tagName() == "DocTrackBaseList") {
220                 // clip = DocClipProject::createClip(doc, e);
221             }
222         } else {
223             QDomText text = n.toText();
224             if (!text.isNull()) {
225                 description = text.nodeValue();
226             }
227         }
228
229         n = n.nextSibling();
230     }
231     if (clip == 0) {
232         kWarning() << "DocClipBase::createClip() unable to create clip";
233     } else {
234         // setup DocClipBase specifics of the clip.
235         QMap <QString, QString> props;
236         props.insert("description", description);
237         clip->setProperties(props);
238         clip->setAudioThumbCreated(false);
239     }
240     return clip;
241 }
242
243 void DocClipBase::setAudioThumbCreated(bool isDone) {
244     m_audioThumbCreated = isDone;
245 }
246
247
248 void DocClipBase::setThumbnail(const QPixmap & pixmap) {
249     m_thumbnail = pixmap;
250 }
251
252 const QPixmap & DocClipBase::thumbnail() const {
253     return m_thumbnail;
254 }
255
256 void DocClipBase::updateAudioThumbnail(QMap<int, QMap<int, QByteArray> > data) {
257     //kDebug() << "CLIPBASE RECIEDVED AUDIO DATA*********************************************";
258     audioFrameChache = data;
259     m_audioThumbCreated = true;
260     emit gotAudioData();
261 }
262
263 QList < GenTime > DocClipBase::snapMarkers() const {
264     QList < GenTime > markers;
265
266     for (uint count = 0; count < m_snapMarkers.count(); ++count) {
267         markers.append(m_snapMarkers[count].time());
268     }
269
270     return markers;
271 }
272
273 QList < CommentedTime > DocClipBase::commentedSnapMarkers() const {
274     return m_snapMarkers;
275 }
276
277 void DocClipBase::setSnapMarkers(QList < CommentedTime > markers) {
278     m_snapMarkers = markers;
279 }
280
281 void DocClipBase::addSnapMarker(const GenTime & time, QString comment) {
282     QList < CommentedTime >::Iterator it = m_snapMarkers.begin();
283     for (it = m_snapMarkers.begin(); it != m_snapMarkers.end(); ++it) {
284         if ((*it).time() >= time)
285             break;
286     }
287
288     if ((it != m_snapMarkers.end()) && ((*it).time() == time)) {
289         (*it).setComment(comment);
290         //kError() << "trying to add Snap Marker that already exists, this will cause inconsistancies with undo/redo";
291     } else {
292         CommentedTime t(time, comment);
293         m_snapMarkers.insert(it, t);
294     }
295
296 }
297
298 void DocClipBase::editSnapMarker(const GenTime & time, QString comment) {
299     QList < CommentedTime >::Iterator it;
300     for (it = m_snapMarkers.begin(); it != m_snapMarkers.end(); ++it) {
301         if ((*it).time() == time)
302             break;
303     }
304     if (it != m_snapMarkers.end()) {
305         (*it).setComment(comment);
306     } else {
307         kError() << "trying to edit Snap Marker that does not already exists";
308     }
309 }
310
311 QString DocClipBase::deleteSnapMarker(const GenTime & time) {
312     QString result = i18n("Marker");
313     QList < CommentedTime >::Iterator itt = m_snapMarkers.begin();
314
315     while (itt != m_snapMarkers.end()) {
316         if ((*itt).time() == time)
317             break;
318         ++itt;
319     }
320
321     if ((itt != m_snapMarkers.end()) && ((*itt).time() == time)) {
322         result = (*itt).comment();
323         m_snapMarkers.erase(itt);
324     }
325     return result;
326 }
327
328
329 GenTime DocClipBase::hasSnapMarkers(const GenTime & time) {
330     QList < CommentedTime >::Iterator itt = m_snapMarkers.begin();
331
332     while (itt != m_snapMarkers.end()) {
333         if ((*itt).time() == time)
334             return time;
335         ++itt;
336     }
337
338     return GenTime(0.0);
339 }
340
341 GenTime DocClipBase::findPreviousSnapMarker(const GenTime & currTime) {
342     int it;
343     for (it = 0; it < m_snapMarkers.count(); it++) {
344         if (m_snapMarkers[it].time() >= currTime)
345             break;
346     }
347     if (it == 0) return GenTime();
348     else if (it == m_snapMarkers.count() - 1 && m_snapMarkers[it].time() < currTime)
349         return m_snapMarkers[it].time();
350     else return m_snapMarkers[it-1].time();
351 }
352
353 GenTime DocClipBase::findNextSnapMarker(const GenTime & currTime) {
354     int it;
355     for (it = 0; it < m_snapMarkers.count(); it++) {
356         if (m_snapMarkers[it].time() > currTime)
357             break;
358     }
359     if (it < m_snapMarkers.count() && m_snapMarkers[it].time() > currTime) return m_snapMarkers[it].time();
360     return duration();
361 }
362
363 QString DocClipBase::markerComment(GenTime t) {
364     QList < CommentedTime >::Iterator itt = m_snapMarkers.begin();
365
366     while (itt != m_snapMarkers.end()) {
367         if ((*itt).time() == t)
368             return (*itt).comment();
369         ++itt;
370     }
371     return QString::null;
372 }
373
374 void DocClipBase::deleteProducers() {
375     qDeleteAll(m_baseTrackProducers);
376     m_baseTrackProducers.clear();
377     if (m_thumbProd) m_thumbProd->clearProducer();
378 }
379
380 void DocClipBase::setProducer(Mlt::Producer *producer) {
381     if (producer == NULL) return;
382     QString id = producer->get("id");
383     if (id.contains('_')) {
384         // this is a subtrack producer, insert it at correct place
385         int pos = id.section('_', 1, 1).toInt();
386         if (pos >= m_baseTrackProducers.count()) {
387             while (m_baseTrackProducers.count() - 1 < pos) {
388                 m_baseTrackProducers.append(NULL);
389             }
390         }
391         if (m_baseTrackProducers.at(pos) == NULL) m_baseTrackProducers[pos] = producer;
392     } else {
393         if (m_baseTrackProducers.isEmpty()) m_baseTrackProducers.append(producer);
394         else if (m_baseTrackProducers.at(0) == NULL) m_baseTrackProducers[0] = producer;
395     }
396     //m_clipProducer = producer;
397     //m_clipProducer->set("transparency", m_properties.value("transparency").toInt());
398     if (m_thumbProd && !m_thumbProd->hasProducer()) m_thumbProd->setProducer(producer);
399 }
400
401 Mlt::Producer *DocClipBase::producer(int track) {
402     /*for (int i = 0; i < m_baseTrackProducers.count(); i++) {
403         if (m_baseTrackProducers.at(i)) kDebug() << "// PROD: " << i << ", ID: " << m_baseTrackProducers.at(i)->get("id");
404     }*/
405     if (track == -1 || (m_clipType != AUDIO && m_clipType != AV)) {
406         if (m_baseTrackProducers.count() == 0) return NULL;
407         int i;
408         for (int i = 0; i < m_baseTrackProducers.count(); i++)
409             if (m_baseTrackProducers.at(i) != NULL) return m_baseTrackProducers.at(i);
410         return NULL;
411     }
412     if (track >= m_baseTrackProducers.count()) {
413         while (m_baseTrackProducers.count() - 1 < track) {
414             m_baseTrackProducers.append(NULL);
415         }
416     }
417     if (m_baseTrackProducers.at(track) == NULL) {
418         int i;
419         for (i = 0; i < m_baseTrackProducers.count(); i++)
420             if (m_baseTrackProducers.at(i) != NULL) break;
421         if (i >= m_baseTrackProducers.count()) return NULL;
422         m_baseTrackProducers[track] = new Mlt::Producer(*m_baseTrackProducers.at(i)->profile(), m_baseTrackProducers.at(i)->get("resource"));
423         if (m_properties.contains("force_aspect_ratio")) m_baseTrackProducers[track]->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble());
424         if (m_properties.contains("threads")) m_baseTrackProducers[track]->set("threads", m_properties.value("threads").toInt());
425         if (m_properties.contains("video_index")) m_baseTrackProducers[track]->set("video_index", m_properties.value("video_index").toInt());
426         if (m_properties.contains("audio_index")) m_baseTrackProducers[track]->set("audio_index", m_properties.value("audio_index").toInt());
427         char *tmp = (char *) qstrdup(QString(getId() + '_' + QString::number(track)).toUtf8().data());
428         m_baseTrackProducers[track]->set("id", tmp);
429         delete[] tmp;
430         if (KdenliveSettings::dropbframes() && m_baseTrackProducers.at(i)->get("skip_loop_filter") && strcmp(m_baseTrackProducers.at(i)->get("skip_loop_filter"), "all") == 0) {
431             m_baseTrackProducers[track]->set("skip_loop_filter", "all");
432             m_baseTrackProducers[track]->set("skip_frame", "bidir");
433         }
434     }
435     return m_baseTrackProducers.at(track);
436 }
437
438 void DocClipBase::setProducerProperty(const char *name, int data) {
439     for (int i = 0; i < m_baseTrackProducers.count(); i++) {
440         if (m_baseTrackProducers.at(i) != NULL)
441             m_baseTrackProducers[i]->set(name, data);
442     }
443 }
444
445 void DocClipBase::setProducerProperty(const char *name, const char *data) {
446     for (int i = 0; i < m_baseTrackProducers.count(); i++) {
447         if (m_baseTrackProducers.at(i) != NULL)
448             m_baseTrackProducers[i]->set(name, data);
449     }
450 }
451
452 const char *DocClipBase::producerProperty(const char *name) const {
453     for (int i = 0; i < m_baseTrackProducers.count(); i++) {
454         if (m_baseTrackProducers.at(i) != NULL) {
455             return m_baseTrackProducers.at(i)->get(name);
456         }
457     }
458     return NULL;
459 }
460
461
462 void DocClipBase::slotRefreshProducer() {
463     if (m_baseTrackProducers.count() == 0) return;
464     kDebug() << "////////////   REFRESH CLIP !!!!!!!!!!!!!!!!";
465     if (m_clipType == SLIDESHOW) {
466         /*char *tmp = (char *) qstrdup(getProperty("resource").toUtf8().data());
467                Mlt::Producer producer(*(m_clipProducer->profile()), tmp);
468                delete[] tmp;
469         delete m_clipProducer;
470         m_clipProducer = new Mlt::Producer(producer.get_producer());
471         if (!getProperty("out").isEmpty()) m_clipProducer->set_in_and_out(getProperty("in").toInt(), getProperty("out").toInt());*/
472         setProducerProperty("ttl", getProperty("ttl").toInt());
473         //m_clipProducer->set("id", getProperty("id"));
474         if (getProperty("fade") == "1") {
475             // we want a fade filter effect
476             kDebug() << "////////////   FADE WANTED";
477             Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
478             int ct = 0;
479             Mlt::Filter *filter = clipService.filter(ct);
480             while (filter) {
481                 if (filter->get("mlt_service") == "luma") {
482                     break;
483                 }
484                 ct++;
485                 filter = clipService.filter(ct);
486             }
487
488             if (filter && filter->get("mlt_service") == "luma") {
489                 filter->set("period", getProperty("ttl").toInt() - 1);
490                 filter->set("luma.out", getProperty("luma_duration").toInt());
491                 QString resource = getProperty("luma_file");
492                 char *tmp = (char *) qstrdup(resource.toUtf8().data());
493                 filter->set("luma.resource", tmp);
494                 delete[] tmp;
495                 if (getProperty("softness") != QString()) {
496                     int soft = getProperty("softness").toInt();
497                     filter->set("luma.softness", (double) soft / 100.0);
498                 }
499             } else {
500                 // filter does not exist, create it...
501                 Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "luma");
502                 filter->set("period", getProperty("ttl").toInt() - 1);
503                 filter->set("luma.out", getProperty("luma_duration").toInt());
504                 QString resource = getProperty("luma_file");
505                 char *tmp = (char *) qstrdup(resource.toUtf8().data());
506                 filter->set("luma.resource", tmp);
507                 delete[] tmp;
508                 if (getProperty("softness") != QString()) {
509                     int soft = getProperty("softness").toInt();
510                     filter->set("luma.softness", (double) soft / 100.0);
511                 }
512                 clipService.attach(*filter);
513             }
514         } else {
515             kDebug() << "////////////   FADE NOT WANTED!!!";
516             Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
517             int ct = 0;
518             Mlt::Filter *filter = clipService.filter(0);
519             while (filter) {
520                 if (filter->get("mlt_service") == "luma") {
521                     clipService.detach(*filter);
522                 } else ct++;
523                 filter = clipService.filter(ct);
524             }
525         }
526     }
527 }
528
529 void DocClipBase::setProperties(QMap <QString, QString> properties) {
530     // changing clip type is not allowed
531     properties.remove("type");
532     QMapIterator<QString, QString> i(properties);
533     bool refreshProducer = false;
534     QStringList keys;
535     keys << "luma_duration" << "luma_file" << "fade" << "ttl" << "softness";
536     while (i.hasNext()) {
537         i.next();
538         setProperty(i.key(), i.value());
539         if (m_clipType == SLIDESHOW && keys.contains(i.key())) refreshProducer = true;
540     }
541     if (refreshProducer) slotRefreshProducer();
542 }
543
544 void DocClipBase::setMetadata(QMap <QString, QString> properties) {
545     m_metadata = properties;
546 }
547
548 QMap <QString, QString> DocClipBase::metadata() const {
549     return m_metadata;
550 }
551
552 void DocClipBase::clearProperty(const QString &key) {
553     m_properties.remove(key);
554 }
555
556 void DocClipBase::getFileHash(const QString &url) {
557     if (m_clipType == SLIDESHOW) return;
558     QFile file(url);
559     if (file.open(QIODevice::ReadOnly)) { // write size and hash only if resource points to a file
560         QByteArray fileData;
561         QByteArray fileHash;
562         //kDebug() << "SETTING HASH of" << value;
563         m_properties.insert("file_size", QString::number(file.size()));
564         /*
565                * 1 MB = 1 second per 450 files (or faster)
566                * 10 MB = 9 seconds per 450 files (or faster)
567                */
568         if (file.size() > 1000000*2) {
569             fileData = file.read(1000000);
570             if (file.seek(file.size() - 1000000))
571                 fileData.append(file.readAll());
572         } else
573             fileData = file.readAll();
574         file.close();
575         fileHash = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
576         m_properties.insert("file_hash", QString(fileHash.toHex()));
577         //kDebug() << file.fileName() << file.size() << fileHash.toHex();
578     }
579 }
580
581 QString DocClipBase::getClipHash() const {
582     QString hash;
583     if (m_clipType == SLIDESHOW) hash = QCryptographicHash::hash(m_properties.value("resource").toAscii().data(), QCryptographicHash::Md5).toHex();
584     else if (m_clipType == COLOR) hash = QCryptographicHash::hash(m_properties.value("colour").toAscii().data(), QCryptographicHash::Md5).toHex();
585     else hash = m_properties.value("file_hash");
586     return hash;
587 }
588
589 void DocClipBase::refreshThumbUrl() {
590     if (m_thumbProd) m_thumbProd->updateThumbUrl(m_properties.value("file_hash"));
591 }
592
593 void DocClipBase::setProperty(const QString &key, const QString &value) {
594     m_properties.insert(key, value);
595     if (key == "resource") {
596         getFileHash(value);
597         if (m_thumbProd) m_thumbProd->updateClipUrl(KUrl(value), m_properties.value("file_hash"));
598     } else if (key == "out") setDuration(GenTime(value.toInt(), KdenliveSettings::project_fps()));
599     //else if (key == "transparency") m_clipProducer->set("transparency", value.toInt());
600     else if (key == "colour") {
601         char *tmp = (char *) qstrdup(value.toUtf8().data());
602         setProducerProperty("colour", tmp);
603         delete[] tmp;
604     } else if (key == "xmldata") {
605         setProducerProperty("force_reload", 1);
606     } else if (key == "force_aspect_ratio") {
607         if (value.isEmpty()) {
608             m_properties.remove("force_aspect_ratio");
609             setProducerProperty("force_aspect_ratio", 0);
610         } else setProducerProperty("force_aspect_ratio", value.toDouble());
611     } else if (key == "threads") {
612         if (value.isEmpty()) {
613             m_properties.remove("threads");
614             setProducerProperty("threads", 1);
615         } else setProducerProperty("threads", value.toInt());
616     } else if (key == "video_index") {
617         if (value.isEmpty()) {
618             m_properties.remove("video_index");
619             setProducerProperty("video_index", m_properties.value("default_video").toInt());
620         } else setProducerProperty("video_index", value.toInt());
621     } else if (key == "audio_index") {
622         if (value.isEmpty()) {
623             m_properties.remove("audio_index");
624             setProducerProperty("audio_index", m_properties.value("default_audio").toInt());
625         } else setProducerProperty("audio_index", value.toInt());
626     }
627 }
628
629 QMap <QString, QString> DocClipBase::properties() const {
630     return m_properties;
631 }
632
633 bool DocClipBase::slotGetAudioThumbs() {
634     if (m_thumbProd == NULL) return false;
635     if (!KdenliveSettings::audiothumbnails()) {
636         if (m_audioTimer != NULL) m_audioTimer->stop();
637         return false;
638     }
639     if (m_audioThumbCreated) {
640         if (m_audioTimer != NULL) m_audioTimer->stop();
641         return false;
642     }
643     if (m_audioTimer != NULL)
644         m_audioTimer->start(1500);
645     double lengthInFrames = duration().frames(KdenliveSettings::project_fps());
646     m_thumbProd->getAudioThumbs(2, 0, lengthInFrames /*must be number of frames*/, 20);
647     return true;
648 }
649
650
651