+void DocClipBase::slotRefreshProducer() {
+ if (m_baseTrackProducers.count() == 0) return;
+ kDebug() << "//////////// REFRESH CLIP !!!!!!!!!!!!!!!!";
+ if (m_clipType == SLIDESHOW) {
+ /*char *tmp = (char *) qstrdup(getProperty("resource").toUtf8().data());
+ Mlt::Producer producer(*(m_clipProducer->profile()), tmp);
+ delete[] tmp;
+ delete m_clipProducer;
+ m_clipProducer = new Mlt::Producer(producer.get_producer());
+ if (!getProperty("out").isEmpty()) m_clipProducer->set_in_and_out(getProperty("in").toInt(), getProperty("out").toInt());*/
+ setProducerProperty("ttl", getProperty("ttl").toInt());
+ //m_clipProducer->set("id", getProperty("id"));
+ if (getProperty("fade") == "1") {
+ // we want a fade filter effect
+ kDebug() << "//////////// FADE WANTED";
+ Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
+ int ct = 0;
+ Mlt::Filter *filter = clipService.filter(ct);
+ while (filter) {
+ if (filter->get("mlt_service") == "luma") {
+ break;
+ }
+ ct++;
+ filter = clipService.filter(ct);
+ }
+
+ if (filter && filter->get("mlt_service") == "luma") {
+ filter->set("period", getProperty("ttl").toInt() - 1);
+ filter->set("luma.out", getProperty("luma_duration").toInt());
+ QString resource = getProperty("luma_file");
+ char *tmp = (char *) qstrdup(resource.toUtf8().data());
+ filter->set("luma.resource", tmp);
+ delete[] tmp;
+ if (getProperty("softness") != QString()) {
+ int soft = getProperty("softness").toInt();
+ filter->set("luma.softness", (double) soft / 100.0);
+ }
+ } else {
+ // filter does not exist, create it...
+ Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "luma");
+ filter->set("period", getProperty("ttl").toInt() - 1);
+ filter->set("luma.out", getProperty("luma_duration").toInt());
+ QString resource = getProperty("luma_file");
+ char *tmp = (char *) qstrdup(resource.toUtf8().data());
+ filter->set("luma.resource", tmp);
+ delete[] tmp;
+ if (getProperty("softness") != QString()) {
+ int soft = getProperty("softness").toInt();
+ filter->set("luma.softness", (double) soft / 100.0);
+ }
+ clipService.attach(*filter);
+ }
+ } else {
+ kDebug() << "//////////// FADE NOT WANTED!!!";
+ Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
+ int ct = 0;
+ Mlt::Filter *filter = clipService.filter(0);
+ while (filter) {
+ if (filter->get("mlt_service") == "luma") {
+ clipService.detach(*filter);
+ } else ct++;
+ filter = clipService.filter(ct);
+ }
+ }
+ }
+}
+
+void DocClipBase::setProperties(QMap <QString, QString> properties) {
+ // changing clip type is not allowed
+ properties.remove("type");
+ QMapIterator<QString, QString> i(properties);
+ bool refreshProducer = false;
+ QStringList keys;
+ keys << "luma_duration" << "luma_file" << "fade" << "ttl" << "softness";
+ while (i.hasNext()) {
+ i.next();
+ setProperty(i.key(), i.value());
+ if (m_clipType == SLIDESHOW && keys.contains(i.key())) refreshProducer = true;
+ }
+ if (refreshProducer) slotRefreshProducer();
+}
+
+void DocClipBase::clearProperty(const QString &key) {
+ m_properties.remove(key);
+}
+
+void DocClipBase::setProperty(const QString &key, const QString &value) {
+ m_properties.insert(key, value);
+ if (key == "resource") m_thumbProd->updateClipUrl(KUrl(value));
+ else if (key == "out") setDuration(GenTime(value.toInt(), KdenliveSettings::project_fps()));
+ //else if (key == "transparency") m_clipProducer->set("transparency", value.toInt());
+ else if (key == "colour") {
+ char *tmp = (char *) qstrdup(value.toUtf8().data());
+ setProducerProperty("colour", tmp);
+ delete[] tmp;
+ } else if (key == "xmldata") {
+ setProducerProperty("force_reload", 1);
+ } else if (key == "force_aspect_ratio") {
+ if (value.isEmpty()) {
+ m_properties.remove("force_aspect_ratio");
+ setProducerProperty("force_aspect_ratio", 0);
+ } else setProducerProperty("force_aspect_ratio", value.toDouble());
+ } else if (key == "threads") {
+ if (value.isEmpty()) {
+ m_properties.remove("threads");
+ setProducerProperty("threads", 1);
+ } else setProducerProperty("threads", value.toInt());
+ } else if (key == "video_index") {
+ if (value.isEmpty()) {
+ m_properties.remove("video_index");
+ setProducerProperty("video_index", m_properties.value("default_video").toInt());
+ } else setProducerProperty("video_index", value.toInt());
+ } else if (key == "audio_index") {
+ if (value.isEmpty()) {
+ m_properties.remove("audio_index");
+ setProducerProperty("audio_index", m_properties.value("default_audio").toInt());
+ } else setProducerProperty("audio_index", value.toInt());
+ }
+}
+
+QMap <QString, QString> DocClipBase::properties() const {
+ return m_properties;
+}
+
+bool DocClipBase::slotGetAudioThumbs() {
+ if (m_thumbProd == NULL) return false;
+ if (m_audioThumbCreated) {
+ if (m_audioTimer != NULL) m_audioTimer->stop();
+ return false;
+ }
+ if (m_audioTimer != NULL)
+ m_audioTimer->start(1500);
+ double lengthInFrames = duration().frames(KdenliveSettings::project_fps());
+ m_thumbProd->getAudioThumbs(2, 0, lengthInFrames /*must be number of frames*/, 20);
+ return true;
+}
+
+
+