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