]> git.sesse.net Git - kdenlive/blob - src/docclipbase.cpp
[PATCH by Ray Lehtiniem] Delete some unused variables
[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         for (int i = 0; i < m_baseTrackProducers.count(); i++) {
420             if (m_baseTrackProducers.at(i) != NULL)
421                 return m_baseTrackProducers.at(i);
422         }
423         return NULL;
424     }
425     if (track >= m_baseTrackProducers.count()) {
426         while (m_baseTrackProducers.count() - 1 < track) {
427             m_baseTrackProducers.append(NULL);
428         }
429     }
430     if (m_baseTrackProducers.at(track) == NULL) {
431         int i;
432         for (i = 0; i < m_baseTrackProducers.count(); i++)
433             if (m_baseTrackProducers.at(i) != NULL) break;
434         if (i >= m_baseTrackProducers.count()) return NULL;
435         m_baseTrackProducers[track] = new Mlt::Producer(*m_baseTrackProducers.at(i)->profile(), m_baseTrackProducers.at(i)->get("resource"));
436         if (m_properties.contains("force_aspect_ratio")) m_baseTrackProducers[track]->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble());
437         if (m_properties.contains("threads")) m_baseTrackProducers[track]->set("threads", m_properties.value("threads").toInt());
438         if (m_properties.contains("video_index")) m_baseTrackProducers[track]->set("video_index", m_properties.value("video_index").toInt());
439         if (m_properties.contains("audio_index")) m_baseTrackProducers[track]->set("audio_index", m_properties.value("audio_index").toInt());
440         char *tmp = (char *) qstrdup(QString(getId() + '_' + QString::number(track)).toUtf8().data());
441         m_baseTrackProducers[track]->set("id", tmp);
442         delete[] tmp;
443         if (KdenliveSettings::dropbframes() && m_baseTrackProducers.at(i)->get("skip_loop_filter") && strcmp(m_baseTrackProducers.at(i)->get("skip_loop_filter"), "all") == 0) {
444             m_baseTrackProducers[track]->set("skip_loop_filter", "all");
445             m_baseTrackProducers[track]->set("skip_frame", "bidir");
446         }
447     }
448     return m_baseTrackProducers.at(track);
449 }
450
451 void DocClipBase::setProducerProperty(const char *name, int data) {
452     for (int i = 0; i < m_baseTrackProducers.count(); i++) {
453         if (m_baseTrackProducers.at(i) != NULL)
454             m_baseTrackProducers[i]->set(name, data);
455     }
456 }
457
458 void DocClipBase::setProducerProperty(const char *name, const char *data) {
459     for (int i = 0; i < m_baseTrackProducers.count(); i++) {
460         if (m_baseTrackProducers.at(i) != NULL)
461             m_baseTrackProducers[i]->set(name, data);
462     }
463 }
464
465 const char *DocClipBase::producerProperty(const char *name) const {
466     for (int i = 0; i < m_baseTrackProducers.count(); i++) {
467         if (m_baseTrackProducers.at(i) != NULL) {
468             return m_baseTrackProducers.at(i)->get(name);
469         }
470     }
471     return NULL;
472 }
473
474
475 void DocClipBase::slotRefreshProducer() {
476     if (m_baseTrackProducers.count() == 0) return;
477     kDebug() << "////////////   REFRESH CLIP !!!!!!!!!!!!!!!!";
478     if (m_clipType == SLIDESHOW) {
479         /*char *tmp = (char *) qstrdup(getProperty("resource").toUtf8().data());
480                Mlt::Producer producer(*(m_clipProducer->profile()), tmp);
481                delete[] tmp;
482         delete m_clipProducer;
483         m_clipProducer = new Mlt::Producer(producer.get_producer());
484         if (!getProperty("out").isEmpty()) m_clipProducer->set_in_and_out(getProperty("in").toInt(), getProperty("out").toInt());*/
485         setProducerProperty("ttl", getProperty("ttl").toInt());
486         //m_clipProducer->set("id", getProperty("id"));
487         if (getProperty("fade") == "1") {
488             // we want a fade filter effect
489             kDebug() << "////////////   FADE WANTED";
490             Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
491             int ct = 0;
492             Mlt::Filter *filter = clipService.filter(ct);
493             while (filter) {
494                 if (filter->get("mlt_service") == "luma") {
495                     break;
496                 }
497                 ct++;
498                 filter = clipService.filter(ct);
499             }
500
501             if (filter && filter->get("mlt_service") == "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").isEmpty()) {
509                     int soft = getProperty("softness").toInt();
510                     filter->set("luma.softness", (double) soft / 100.0);
511                 }
512             } else {
513                 // filter does not exist, create it...
514                 Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "luma");
515                 filter->set("period", getProperty("ttl").toInt() - 1);
516                 filter->set("luma.out", getProperty("luma_duration").toInt());
517                 QString resource = getProperty("luma_file");
518                 char *tmp = (char *) qstrdup(resource.toUtf8().data());
519                 filter->set("luma.resource", tmp);
520                 delete[] tmp;
521                 if (!getProperty("softness").isEmpty()) {
522                     int soft = getProperty("softness").toInt();
523                     filter->set("luma.softness", (double) soft / 100.0);
524                 }
525                 clipService.attach(*filter);
526             }
527         } else {
528             kDebug() << "////////////   FADE NOT WANTED!!!";
529             Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
530             int ct = 0;
531             Mlt::Filter *filter = clipService.filter(0);
532             while (filter) {
533                 if (filter->get("mlt_service") == "luma") {
534                     clipService.detach(*filter);
535                 } else ct++;
536                 filter = clipService.filter(ct);
537             }
538         }
539     }
540 }
541
542 void DocClipBase::setProperties(QMap <QString, QString> properties) {
543     // changing clip type is not allowed
544     properties.remove("type");
545     QMapIterator<QString, QString> i(properties);
546     bool refreshProducer = false;
547     QStringList keys;
548     keys << "luma_duration" << "luma_file" << "fade" << "ttl" << "softness";
549     while (i.hasNext()) {
550         i.next();
551         setProperty(i.key(), i.value());
552         if (m_clipType == SLIDESHOW && keys.contains(i.key())) refreshProducer = true;
553     }
554     if (refreshProducer) slotRefreshProducer();
555 }
556
557 void DocClipBase::setMetadata(QMap <QString, QString> properties) {
558     m_metadata = properties;
559 }
560
561 QMap <QString, QString> DocClipBase::metadata() const {
562     return m_metadata;
563 }
564
565 void DocClipBase::clearProperty(const QString &key) {
566     m_properties.remove(key);
567 }
568
569 void DocClipBase::getFileHash(const QString &url) {
570     if (m_clipType == SLIDESHOW) return;
571     QFile file(url);
572     if (file.open(QIODevice::ReadOnly)) { // write size and hash only if resource points to a file
573         QByteArray fileData;
574         QByteArray fileHash;
575         //kDebug() << "SETTING HASH of" << value;
576         m_properties.insert("file_size", QString::number(file.size()));
577         /*
578                * 1 MB = 1 second per 450 files (or faster)
579                * 10 MB = 9 seconds per 450 files (or faster)
580                */
581         if (file.size() > 1000000*2) {
582             fileData = file.read(1000000);
583             if (file.seek(file.size() - 1000000))
584                 fileData.append(file.readAll());
585         } else
586             fileData = file.readAll();
587         file.close();
588         fileHash = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
589         m_properties.insert("file_hash", QString(fileHash.toHex()));
590         //kDebug() << file.fileName() << file.size() << fileHash.toHex();
591     }
592 }
593
594 QString DocClipBase::getClipHash() const {
595     QString hash;
596     if (m_clipType == SLIDESHOW) hash = QCryptographicHash::hash(m_properties.value("resource").toAscii().data(), QCryptographicHash::Md5).toHex();
597     else if (m_clipType == COLOR) hash = QCryptographicHash::hash(m_properties.value("colour").toAscii().data(), QCryptographicHash::Md5).toHex();
598     else hash = m_properties.value("file_hash");
599     return hash;
600 }
601
602 void DocClipBase::refreshThumbUrl() {
603     if (m_thumbProd) m_thumbProd->updateThumbUrl(m_properties.value("file_hash"));
604 }
605
606 void DocClipBase::setProperty(const QString &key, const QString &value) {
607     m_properties.insert(key, value);
608     if (key == "resource") {
609         getFileHash(value);
610         if (m_thumbProd) m_thumbProd->updateClipUrl(KUrl(value), m_properties.value("file_hash"));
611     } else if (key == "out") setDuration(GenTime(value.toInt(), KdenliveSettings::project_fps()));
612     //else if (key == "transparency") m_clipProducer->set("transparency", value.toInt());
613     else if (key == "colour") {
614         char *tmp = (char *) qstrdup(value.toUtf8().data());
615         setProducerProperty("colour", tmp);
616         delete[] tmp;
617     } else if (key == "xmldata") {
618         setProducerProperty("force_reload", 1);
619     } else if (key == "force_aspect_ratio") {
620         if (value.isEmpty()) {
621             m_properties.remove("force_aspect_ratio");
622             setProducerProperty("force_aspect_ratio", 0);
623         } else setProducerProperty("force_aspect_ratio", value.toDouble());
624     } else if (key == "threads") {
625         if (value.isEmpty()) {
626             m_properties.remove("threads");
627             setProducerProperty("threads", 1);
628         } else setProducerProperty("threads", value.toInt());
629     } else if (key == "video_index") {
630         if (value.isEmpty()) {
631             m_properties.remove("video_index");
632             setProducerProperty("video_index", m_properties.value("default_video").toInt());
633         } else setProducerProperty("video_index", value.toInt());
634     } else if (key == "audio_index") {
635         if (value.isEmpty()) {
636             m_properties.remove("audio_index");
637             setProducerProperty("audio_index", m_properties.value("default_audio").toInt());
638         } else setProducerProperty("audio_index", value.toInt());
639     }
640 }
641
642 QMap <QString, QString> DocClipBase::properties() const {
643     return m_properties;
644 }
645
646 bool DocClipBase::slotGetAudioThumbs() {
647     if (m_thumbProd == NULL) return false;
648     if (!KdenliveSettings::audiothumbnails()) {
649         if (m_audioTimer != NULL) m_audioTimer->stop();
650         return false;
651     }
652     if (m_audioThumbCreated) {
653         if (m_audioTimer != NULL) m_audioTimer->stop();
654         return false;
655     }
656     if (m_audioTimer != NULL)
657         m_audioTimer->start(1500);
658     double lengthInFrames = duration().frames(KdenliveSettings::project_fps());
659     m_thumbProd->getAudioThumbs(2, 0, lengthInFrames /*must be number of frames*/, 20);
660     return true;
661 }
662
663
664