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