m_videoOnlyProducer = NULL;
}
-void DocClipBase::setProducer(Mlt::Producer *producer)
+void DocClipBase::setProducer(Mlt::Producer *producer, bool reset)
{
if (producer == NULL) return;
+ if (reset) {
+ // Clear all previous producers
+ deleteProducers();
+ }
QString id = producer->get("id");
if (id.contains('_')) {
// this is a subtrack producer, insert it at correct place
}
//m_clipProducer = producer;
//m_clipProducer->set("transparency", m_properties.value("transparency").toInt());
- if (m_thumbProd && !m_thumbProd->hasProducer()) m_thumbProd->setProducer(producer);
+ if (m_thumbProd && (reset || !m_thumbProd->hasProducer())) m_thumbProd->setProducer(producer);
}
Mlt::Producer *DocClipBase::audioProducer(int track)
file.close();
fileHash = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
m_properties.insert("file_hash", QString(fileHash.toHex()));
- //kDebug() << file.fileName() << file.size() << fileHash.toHex();
}
}
return hash;
}
+// static
+QString DocClipBase::getHash(const QString &path)
+{
+ QFile file(path);
+ if (file.open(QIODevice::ReadOnly)) { // write size and hash only if resource points to a file
+ QByteArray fileData;
+ QByteArray fileHash;
+ /*
+ * 1 MB = 1 second per 450 files (or faster)
+ * 10 MB = 9 seconds per 450 files (or faster)
+ */
+ if (file.size() > 1000000*2) {
+ fileData = file.read(1000000);
+ if (file.seek(file.size() - 1000000))
+ fileData.append(file.readAll());
+ } else
+ fileData = file.readAll();
+ file.close();
+ return QCryptographicHash::hash(fileData, QCryptographicHash::Md5).toHex();
+ }
+ return QString();
+}
+
void DocClipBase::refreshThumbUrl()
{
if (m_thumbProd) m_thumbProd->updateThumbUrl(m_properties.value("file_hash"));