+void Render::getFileProperties(const QDomElement &xml, int clipId) {
+ int height = 50;
+ int width = (int)(height * m_mltProfile->dar());
+ QMap < QString, QString > filePropertyMap;
+ QMap < QString, QString > metadataPropertyMap;
+
+ KUrl url = KUrl(xml.attribute("resource", QString::null));
+ Mlt::Producer *producer;
+ if (xml.attribute("type").toInt() == COLOR) {
+ char *tmp = decodedString("colour:" + xml.attribute("colour"));
+ producer = new Mlt::Producer(*m_mltProfile, "fezzik", tmp);
+ delete[] tmp;
+ } else if (url.isEmpty()) {
+ QDomDocument doc;
+ QDomElement westley = doc.createElement("westley");
+ QDomElement play = doc.createElement("playlist");
+ doc.appendChild(westley);
+ westley.appendChild(play);
+ play.appendChild(doc.importNode(xml, true));
+ kDebug() << "/ / / / /CLIP XML: " << doc.toString();
+ char *tmp = decodedString(doc.toString());
+ producer = new Mlt::Producer(*m_mltProfile, "westley-xml", tmp);
+ delete[] tmp;
+ } else {
+ char *tmp = decodedString(url.path());
+ producer = new Mlt::Producer(*m_mltProfile, tmp);
+ delete[] tmp;
+ }
+ if (xml.hasAttribute("out")) producer->set_in_and_out(xml.attribute("in").toInt(), xml.attribute("out").toInt());
+
+ if (producer->is_blank()) {
+ kDebug() << " / / / / / / / /ERRROR / / / / // CANNOT LOAD PRODUCER: ";
+ return;
+ }
+ producer->set("id", clipId);
+ int frameNumber = xml.attribute("thumbnail", "0").toInt();
+ if (frameNumber != 0) producer->seek(frameNumber);
+ mlt_properties properties = MLT_PRODUCER_PROPERTIES(producer->get_producer());
+
+ filePropertyMap["filename"] = url.path();
+ filePropertyMap["duration"] = QString::number(producer->get_playtime());
+ //kDebug() << "/////// PRODUCER: " << url.path() << " IS: " << producer.get_playtime();
+
+ Mlt::Frame * frame = producer->get_frame();
+
+ if (xml.attribute("type").toInt() == SLIDESHOW) {
+ if (xml.hasAttribute("ttl")) producer->set("ttl", xml.attribute("ttl").toInt());
+ if (xml.attribute("fade") == "1") {
+ // user wants a fade effect to slideshow
+ Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, "luma");
+ if (xml.hasAttribute("ttl")) filter->set("period", xml.attribute("ttl").toInt() - 1);
+ if (xml.hasAttribute("luma_duration") && !xml.attribute("luma_duration").isEmpty()) filter->set("luma.out", xml.attribute("luma_duration").toInt());
+ if (xml.hasAttribute("luma_file") && !xml.attribute("luma_file").isEmpty()) {
+ char *tmp = decodedString(xml.attribute("luma_file"));
+ filter->set("luma.resource", tmp);
+ delete[] tmp;
+ if (xml.hasAttribute("softness")) {
+ int soft = xml.attribute("softness").toInt();
+ filter->set("luma.softness", (double) soft / 100.0);
+ }
+ }
+ Mlt::Service clipService(producer->get_service());
+ clipService.attach(*filter);
+ }
+ }
+
+
+ filePropertyMap["fps"] = producer->get("source_fps");
+
+ if (frame && frame->is_valid()) {
+ filePropertyMap["frame_size"] = QString::number(frame->get_int("width")) + "x" + QString::number(frame->get_int("height"));
+ filePropertyMap["frequency"] = QString::number(frame->get_int("frequency"));
+ filePropertyMap["channels"] = QString::number(frame->get_int("channels"));
+ filePropertyMap["aspect_ratio"] = frame->get("aspect_ratio");
+
+ if (frame->get_int("test_image") == 0) {
+ if (url.path().endsWith(".westley") || url.path().endsWith(".kdenlive")) {
+ filePropertyMap["type"] = "playlist";
+ metadataPropertyMap["comment"] = QString::fromUtf8(mlt_properties_get(MLT_SERVICE_PROPERTIES(producer->get_service()), "title"));
+ } else if (frame->get_int("test_audio") == 0)
+ filePropertyMap["type"] = "av";
+ else
+ filePropertyMap["type"] = "video";
+
+ mlt_image_format format = mlt_image_yuv422;
+ int frame_width = 0;
+ int frame_height = 0;
+ //frame->set("rescale.interp", "hyper");
+ frame->set("normalised_height", height);
+ frame->set("normalised_width", width);
+ QPixmap pix(width, height);
+
+ uint8_t *data = frame->get_image(format, frame_width, frame_height, 0);
+ uint8_t *new_image = (uint8_t *)mlt_pool_alloc(frame_width * (frame_height + 1) * 4);
+ mlt_convert_yuv422_to_rgb24a((uint8_t *)data, new_image, frame_width * frame_height);
+ QImage image((uchar *)new_image, frame_width, frame_height, QImage::Format_ARGB32);
+
+ if (!image.isNull()) {
+ pix = pix.fromImage(image.rgbSwapped());
+ } else
+ pix.fill(Qt::black);
+
+ mlt_pool_release(new_image);
+ emit replyGetImage(clipId, 0, pix, width, height);
+
+ } else if (frame->get_int("test_audio") == 0) {
+ QPixmap pixmap = KIcon("audio-x-generic").pixmap(QSize(width, height));
+ emit replyGetImage(clipId, 0, pixmap, width, height);
+ filePropertyMap["type"] = "audio";
+ }
+ }
+
+ // Retrieve audio / video codec name
+
+ // Fetch the video_context
+#if 1
+
+ AVFormatContext *context = (AVFormatContext *) mlt_properties_get_data(properties, "video_context", NULL);
+ if (context != NULL) {
+ // Get the video_index
+ int index = mlt_properties_get_int(properties, "video_index");
+
+#if ENABLE_FFMPEG_CODEC_DESCRIPTION
+ if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->long_name) {
+ filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->long_name;
+ } else
+#endif
+ if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name) {
+ filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->name;
+ }
+ } else kDebug() << " / / / / /WARNING, VIDEO CONTEXT IS NULL!!!!!!!!!!!!!!";
+ context = (AVFormatContext *) mlt_properties_get_data(properties, "audio_context", NULL);
+ if (context != NULL) {
+ // Get the audio_index
+ int index = mlt_properties_get_int(properties, "audio_index");
+
+#if ENABLE_FFMPEG_CODEC_DESCRIPTION
+ if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->long_name)
+ filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->long_name;
+ else
+#endif
+ if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name)
+ filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->name;
+ }
+#endif
+ // metadata
+
+ mlt_properties metadata = mlt_properties_new();
+ mlt_properties_pass(metadata, properties, "meta.attr.");
+ int count = mlt_properties_count(metadata);
+ for (int i = 0; i < count; i ++) {
+ QString name = mlt_properties_get_name(metadata, i);
+ QString value = QString::fromUtf8(mlt_properties_get_value(metadata, i));
+ if (name.endsWith("markup") && !value.isEmpty())
+ metadataPropertyMap[ name.section(".", 0, -2)] = value;
+ }
+
+ emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap);
+ kDebug() << "REquested fuile info for: " << url.path();
+ if (frame) delete frame;
+ //if (producer) delete producer;