Use original clip properties, not proxy for effects / display

CCBUG: 355825
CCBUG: 356643
parent d797d77b
......@@ -173,7 +173,7 @@ public:
/** @brief Flags this item as being current (or not) and notifies the bin model about it. */
virtual void setCurrent(bool current, bool notify = true) = 0;
virtual QDomElement toXml(QDomDocument &document) = 0;
virtual QDomElement toXml(QDomDocument &document, bool includeMeta = false) = 0;
virtual QString getToolTip() const = 0;
virtual bool rename(const QString &name, int column) = 0;
......
......@@ -1930,7 +1930,7 @@ void Bin::gotProxy(const QString &id)
ProjectClip *clip = m_rootFolder->clip(id);
if (clip) {
QDomDocument doc;
QDomElement xml = clip->toXml(doc);
QDomElement xml = clip->toXml(doc, true);
if (!xml.isNull()) m_doc->renderer()->getFileProperties(xml, id, 150, true);
}
}
......
......@@ -246,10 +246,10 @@ void ProjectClip::setCurrent(bool current, bool notify)
}
}
QDomElement ProjectClip::toXml(QDomDocument& document)
QDomElement ProjectClip::toXml(QDomDocument& document, bool includeMeta)
{
if (m_controller) {
m_controller->getProducerXML(document);
m_controller->getProducerXML(document, includeMeta);
return document.documentElement().firstChildElement("producer");
}
return QDomElement();
......
......@@ -117,7 +117,7 @@ public:
virtual bool rename(const QString &name, int column);
virtual QDomElement toXml(QDomDocument &document);
virtual QDomElement toXml(QDomDocument &document, bool includeMeta = false);
QVariant data(DataType type) const;
......
......@@ -133,7 +133,7 @@ Bin* ProjectFolder::bin()
}
}
QDomElement ProjectFolder::toXml(QDomDocument& document)
QDomElement ProjectFolder::toXml(QDomDocument& document, bool)
{
QDomElement folder = document.createElement("folder");
folder.setAttribute("name", name());
......
......@@ -79,7 +79,7 @@ public:
Bin *bin();
/** @brief Returns an xml description of the folder. */
QDomElement toXml(QDomDocument &document);
QDomElement toXml(QDomDocument &document, bool includeMeta = false);
virtual QString getToolTip() const;
virtual bool rename(const QString &name, int column);
/** @brief Returns a list of all children and sub-children clips. */
......
......@@ -87,7 +87,7 @@ Bin* ProjectFolderUp::bin()
}
}
QDomElement ProjectFolderUp::toXml(QDomDocument& document)
QDomElement ProjectFolderUp::toXml(QDomDocument& document, bool)
{
return document.documentElement();
}
......
......@@ -76,7 +76,7 @@ public:
Bin *bin();
/** @brief Returns an xml description of the folder. */
QDomElement toXml(QDomDocument &document);
QDomElement toXml(QDomDocument &document, bool includeMeta = false);
virtual QString getToolTip() const;
virtual bool rename(const QString &name, int column);
......
......@@ -98,7 +98,7 @@ ProjectClip* ProjectSubClip::clipAt(int ix)
return NULL;
}
QDomElement ProjectSubClip::toXml(QDomDocument& document)
QDomElement ProjectSubClip::toXml(QDomDocument& document, bool)
{
QDomElement sub = document.createElement("subclip");
sub.setAttribute("id", m_masterClip->clipId());
......
......@@ -62,7 +62,7 @@ public:
ProjectClip *clipAt(int ix);
/** @brief Recursively disable/enable bin effects. */
void disableEffects(bool disable);
QDomElement toXml(QDomDocument &document);
QDomElement toXml(QDomDocument &document, bool includeMeta = false);
/** @brief Returns the clip's duration. */
GenTime duration() const;
......
......@@ -396,7 +396,7 @@ QString BinController::xmlFromId(const QString & id)
return str;
}
QString BinController::getProducerXML(Mlt::Producer &producer)
QString BinController::getProducerXML(Mlt::Producer &producer, bool includeMeta)
{
QString filename = "string";
Mlt::Consumer c(*producer.profile(), "xml", filename.toUtf8().constData());
......@@ -407,7 +407,7 @@ QString BinController::getProducerXML(Mlt::Producer &producer)
if (ignore)
s.set("ignore_points", 0);
c.set("time_format", "frames");
c.set("no_meta", 1);
if (!includeMeta) c.set("no_meta", 1);
c.set("store", "kdenlive");
if (filename != "string") {
c.set("no_root", 1);
......
......@@ -118,7 +118,7 @@ public:
/** @brief Returns the clip data as rendered by MLT's XML consumer, used to duplicate a clip
* @param producer The clip's original producer
*/
QString getProducerXML(Mlt::Producer &producer);
QString getProducerXML(Mlt::Producer &producer, bool includeMeta = false);
/** @brief Returns the clip data as rendered by MLT's XML consumer
* @param id The clip's original id
......
......@@ -38,6 +38,7 @@ ClipController::ClipController(BinController *bincontroller, Mlt::Producer& prod
, selectedEffectIndex(1)
, audioThumbCreated(false)
, m_properties(new Mlt::Properties(producer.get_properties()))
, m_usesProxy(false)
, m_audioInfo(NULL)
, m_audioIndex(0)
, m_videoIndex(0)
......@@ -56,6 +57,7 @@ ClipController::ClipController(BinController *bincontroller, Mlt::Producer& prod
if (proxy.length() > 2) {
// This is a proxy producer, read original url from kdenlive property
m_url = QUrl::fromLocalFile(m_properties->get("kdenlive:originalurl"));
m_usesProxy = true;
}
else m_url = QUrl::fromLocalFile(m_properties->get("resource"));
m_service = m_properties->get("mlt_service");
......@@ -104,17 +106,21 @@ void ClipController::addMasterProducer(Mlt::Producer &producer)
if (proxy.length() > 2) {
// This is a proxy producer, read original url from kdenlive property
m_url = QUrl::fromLocalFile(m_properties->get("kdenlive:originalurl"));
m_usesProxy = true;
}
else {
m_url = QUrl::fromLocalFile(m_properties->get("resource"));
m_usesProxy = false;
}
else m_url = QUrl::fromLocalFile(m_properties->get("resource"));
m_service = m_properties->get("mlt_service");
getInfoForProducer();
}
}
void ClipController::getProducerXML(QDomDocument& document)
void ClipController::getProducerXML(QDomDocument& document, bool includeMeta)
{
if (m_masterProducer) {
QString xml = m_binController->getProducerXML(*m_masterProducer);
QString xml = m_binController->getProducerXML(*m_masterProducer, includeMeta);
document.setContent(xml);
}
else qDebug()<<" + + ++ NO MASTER PROD";
......@@ -223,6 +229,12 @@ void ClipController::updateProducer(const QString &id, Mlt::Producer* producer)
delete m_masterProducer;
m_masterProducer = producer;
m_properties = new Mlt::Properties(producer->get_properties());
QString proxy = m_properties->get("kdenlive:proxy");
if (proxy.length() > 2) {
// This is a proxy producer, read original url from kdenlive property
m_usesProxy = true;
}
else m_usesProxy = false;
// Pass properties from previous producer
m_properties->pass_list(passProperties, getPassPropertiesList());
if (!m_masterProducer->is_valid()) qDebug()<<"// WARNING, USING INVALID PRODUCER";
......@@ -276,12 +288,20 @@ GenTime ClipController::getPlaytime() const
QString ClipController::property(const QString &name) const
{
if (!m_properties) return QString();
if (m_usesProxy && name.startsWith("meta.")) {
QString correctedName = QStringLiteral("kdenlive:") + name;
return m_properties->get(correctedName.toUtf8().constData());
}
return QString(m_properties->get(name.toUtf8().constData()));
}
int ClipController::int_property(const QString &name) const
{
if (!m_properties) return 0;
if (m_usesProxy && name.startsWith("meta.")) {
QString correctedName = QStringLiteral("kdenlive:") + name;
return m_properties->get_int(correctedName.toUtf8().constData());
}
return m_properties->get_int(name.toUtf8().constData());
}
......@@ -564,7 +584,7 @@ void ClipController::addEffect(const ProfileInfo &pInfo, QDomElement &effect)
info.cropStart = GenTime();
info.cropDuration = getPlaytime();
EffectsList eff = effectList();
EffectsController::initEffect(info, pInfo, eff, property("proxy"), effect);
EffectsController::initEffect(info, pInfo, eff, property("kdenlive:proxy"), effect);
// Add effect to list and setup a kdenlive_ix value
int kdenlive_ix = 0;
for (int i = 0; i < service.filter_count(); ++i) {
......
......@@ -70,7 +70,7 @@ public:
/** @brief Replaces the master producer and (TODO) the track producers with an updated producer, for example a proxy */
void updateProducer(const QString &id, Mlt::Producer *producer);
void getProducerXML(QDomDocument& document);
void getProducerXML(QDomDocument& document, bool includeMeta = false);
/** @brief Returns a clone of our master producer. Delete after use! */
Mlt::Producer *masterProducer();
......@@ -189,6 +189,7 @@ public:
private:
Mlt::Producer *m_masterProducer;
Mlt::Properties *m_properties;
bool m_usesProxy;
AudioStreamInfo *m_audioInfo;
QString m_service;
QUrl m_url;
......
......@@ -732,6 +732,17 @@ void Render::processFileProperties()
}
// replace clip
m_processingClipId.removeAll(info.clipId);
// Store original properties in a kdenlive: prefixed format
QDomNodeList props = info.xml.elementsByTagName("property");
for (int i = 0; i < props.count(); ++i) {
QDomElement e = props.at(i).toElement();
QString name = e.attribute("name");
if (name.startsWith("meta.")) {
name.prepend("kdenlive:");
producer->set(name.toUtf8().constData(), e.firstChild().nodeValue().toUtf8().constData());
}
}
m_binController->replaceProducer(info.clipId, *producer);
emit gotFileProperties(info, NULL);
continue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment