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