info = m_dropItem->info();
info.track = m_tracksList.count() - m_dropItem->track();
// kDebug()<<"IIIIIIIIIIIIIIIIIIIIIIII TRAX CNT: "<<m_tracksList.count()<<", DROP: "<<m_dropItem->track();
- m_document->renderer()->mltInsertClip(info, m_dropItem->xml());
+ m_document->renderer()->mltInsertClip(info, m_dropItem->xml(), m_dropItem->baseClip()->producer());
m_document->setModified(true);
} else QGraphicsView::dropEvent(event);
m_dropItem = NULL;
new AddTimelineClipCommand(this, clip->xml(), clip->clipProducer(), item->info(), false, false, moveClips);
ItemInfo info = item->info();
info.track = m_tracksList.count() - item->track();
- m_document->renderer()->mltInsertClip(info, clip->xml());
+ m_document->renderer()->mltInsertClip(info, clip->xml(), clip->baseClip()->producer());
} else {
Transition *tr = static_cast <Transition*>(item);
ItemInfo transitionInfo = tr->info();
baseclip->addReference();
m_document->updateClip(baseclip->getId());
info.track = m_tracksList.count() - info.track;
- m_document->renderer()->mltInsertClip(info, xml);
+ m_document->renderer()->mltInsertClip(info, xml, baseclip->producer());
m_document->renderer()->doRefresh();
}
clip->refreshClip();
ItemInfo info = clip->info();
info.track = m_tracksList.count() - clip->track();
- m_document->renderer()->mltUpdateClip(info, clip->xml());
+ m_document->renderer()->mltUpdateClip(info, clip->xml(), clip->baseClip()->producer());
}
}
}
#include "clipmanager.h"
DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, uint id):
- m_id(id), m_description(QString()), m_refcount(0), m_audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL) {
+ m_id(id), m_description(QString()), m_refcount(0), m_audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL), m_clipProducer(NULL) {
int type = xml.attribute("type").toInt();
m_clipType = (CLIPTYPE) type;
m_name = xml.attribute("name");
//kDebug() << "type is video" << (m_clipType == AV) << " " << m_clipType;
}
-
-
-DocClipBase::DocClipBase(const DocClipBase& clip) {
- m_id = clip.getId();
- m_clipType = clip.clipType();
- m_name = clip.name();
- m_duration = clip.duration();
- m_audioThumbCreated = clip.audioThumbCreated();
- m_properties = clip.properties();
-}
-
-DocClipBase & DocClipBase::operator=(const DocClipBase & clip) {
+/*DocClipBase & DocClipBase::operator=(const DocClipBase & clip) {
DocClipBase::operator=(clip);
m_id = clip.getId();
m_clipType = clip.clipType();
m_audioThumbCreated = clip.audioThumbCreated();
m_properties = clip.properties();
return *this;
-}
+}*/
DocClipBase::~DocClipBase() {
if (m_thumbProd) delete m_thumbProd;
+ if (m_clipProducer) delete m_clipProducer;
}
void DocClipBase::slotCreateAudioTimer() {
return QString::null;
}
+void DocClipBase::setProducer(Mlt::Producer *producer) {
+ m_clipProducer = producer;
+ if (m_thumbProd) m_thumbProd->setProducer(producer);
+}
+
+Mlt::Producer *DocClipBase::producer() {
+ return m_clipProducer;
+}
+
void DocClipBase::setProperties(QMap <QString, QString> properties) {
// changing clip type is not allowed
properties.remove("type");
class KThumb;
class ClipManager;
-
+namespace Mlt {
+class Producer;
+};
class DocClipBase: public QObject {
* and video. */
DocClipBase(ClipManager *clipManager, QDomElement xml, uint id);
- DocClipBase(const DocClipBase& clip);
- DocClipBase & operator=(const DocClipBase & clip);
+// DocClipBase & operator=(const DocClipBase & clip);
virtual ~ DocClipBase();
/** sets the name of this clip. */
return false;
}
+ void setProducer(Mlt::Producer *producer);
+ Mlt::Producer *producer();
+
/*virtual DocClipAVFile *toDocClipAVFile() {
return 0;
}
/** The number of times this clip is used in the project - the number of references to this clip
* that exist. */
uint m_refcount;
-
+ Mlt::Producer *m_clipProducer;
CLIPTYPE m_clipType;
/** A list of snap markers; these markers are added to a clips snap-to points, and are displayed as necessary. */
#define _G(y,u,v) (0x2568*(y) - 0x0c92*(v) - 0x1a1e*(u)) /0x2000
#define _B(y,u,v) (0x2568*(y) + 0x40cf*(v)) /0x2000
-KThumb::KThumb(ClipManager *clipManager, KUrl url, QObject * parent, const char *name): QObject(parent), m_clipManager(clipManager), m_url(url) {
+KThumb::KThumb(ClipManager *clipManager, KUrl url, QObject * parent, const char *name): QObject(parent), m_clipManager(clipManager), m_url(url), m_producer(NULL) {
m_profile = new Mlt::Profile((char*) KdenliveSettings::current_profile().data());
QCryptographicHash context(QCryptographicHash::Sha1);
if (thumbProducer.isRunning()) thumbProducer.exit();
}
+void KThumb::setProducer(Mlt::Producer *producer) {
+ m_producer = producer;
+}
+
void KThumb::updateClipUrl(KUrl url) {
m_url = url;
}
void KThumb::extractImage(int frame, int frame2) {
if (m_url.isEmpty()) return;
- char *tmp = Render::decodedString("<westley><playlist><producer resource=\"" + m_url.path() + "\" /></playlist></westley>");
+ if (m_producer == NULL) return;
+ /*char *tmp = Render::decodedString("<westley><playlist><producer resource=\"" + m_url.path() + "\" /></playlist></westley>");
Mlt::Producer producer(*m_profile, "westley-xml", tmp);
- delete[] tmp;
+ delete[] tmp;*/
int twidth = (int)(KdenliveSettings::trackheight() * m_profile->dar());
- if (producer.is_blank()) {
+ if (m_producer->is_blank()) {
QPixmap pix(twidth, KdenliveSettings::trackheight());
pix.fill(Qt::black);
emit thumbReady(frame, pix);
return;
}
if (frame != -1) {
- QPixmap pix = getFrame(producer, frame, twidth, KdenliveSettings::trackheight());
+ QPixmap pix = getFrame(*m_producer, frame, twidth, KdenliveSettings::trackheight());
emit thumbReady(frame, pix);
}
if (frame2 != -1) {
- QPixmap pix = getFrame(producer, frame2, twidth , KdenliveSettings::trackheight());
+ QPixmap pix = getFrame(*m_producer, frame2, twidth , KdenliveSettings::trackheight());
emit thumbReady(frame2, pix);
}
}
KThumb(ClipManager *clipManager, KUrl url, QObject * parent = 0, const char *name = 0);
~KThumb();
+ void setProducer(Mlt::Producer *producer);
public slots:
void extractImage(int frame, int frame2);
KUrl m_url;
QString m_thumbFile;
Mlt::Profile *m_profile;
+ Mlt::Producer *m_producer;
ClipManager *m_clipManager;
signals:
#define ID_TIMELINE_POS 6
#define ID_TIMELINE_FORMAT 7
+namespace Mlt {
+class Producer;
+};
+
EffectsList MainWindow::videoEffects;
EffectsList MainWindow::audioEffects;
EffectsList MainWindow::customEffects;
connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
- connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)));
+ connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(int, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(int, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)));
connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
}
if (!clip) return;
if (clip != m_currentClip) {
m_currentClip = clip;
- QDomDocument doc;
- QDomElement westley = doc.createElement("westley");
- doc.appendChild(westley);
- westley.appendChild(doc.importNode(m_currentClip->toXML(), true));
- render->setSceneList(doc, 0);
+ render->setProducer(clip->producer(), 0);
m_ruler->slotNewValue(0);
m_timePos->setText("00:00:00:00");
m_position = 0;
}
}
-void ProjectList::slotReplyGetFileProperties(int clipId, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata) {
+void ProjectList::slotReplyGetFileProperties(int clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata) {
ProjectItem *item = getItemById(clipId);
if (item) {
item->setProperties(properties, metadata);
+ item->referencedClip()->setProducer(producer);
listView->setCurrentItem(item);
emit receivedClipDuration(clipId, item->clipMaxDuration());
- }
+ } else kDebug() << "//////// COULD NOT FIND CLIP TO UPDATE PRPS...";
}
void ProjectList::slotReplyGetImage(int clipId, int pos, const QPixmap &pix, int w, int h) {
#include "definitions.h"
#include "timecode.h"
+namespace Mlt {
+class Producer;
+};
+
class ProjectItem;
class ProjectListView;
class Render;
public slots:
void setDocument(KdenliveDoc *doc);
void slotReplyGetImage(int clipId, int pos, const QPixmap &pix, int w, int h);
- void slotReplyGetFileProperties(int clipId, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata);
+ void slotReplyGetFileProperties(int clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata);
void slotAddClip(DocClipBase *clip);
void slotDeleteClip(int clipId);
void slotUpdateClip(int id);
}
}
-Render::Render(const QString & rendererName, int winid, int extid, QWidget *parent): QObject(parent), m_name(rendererName), m_mltConsumer(NULL), m_mltProducer(NULL), m_mltTextProducer(NULL), m_winid(-1), m_framePosition(0), m_generateScenelist(false), m_isBlocked(true) {
+Render::Render(const QString & rendererName, int winid, int extid, QWidget *parent): QObject(parent), m_name(rendererName), m_mltConsumer(NULL), m_mltProducer(NULL), m_mltTextProducer(NULL), m_winid(-1), m_framePosition(0), m_generateScenelist(false), m_isBlocked(true), m_blackClip(NULL) {
kDebug() << "////////// USING PROFILE: " << (char *)KdenliveSettings::current_profile().toUtf8().data();
m_mltProfile = new Mlt::Profile((char*) KdenliveSettings::current_profile().data());
refreshTimer = new QTimer(this);
m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "westley-xml", "<westley><playlist><producer mlt_service=\"colour\" colour=\"blue\" in=\"0\" out=\"25\" /></playlist></westley>");
m_mltProducer = producer;
+ if (m_blackClip) delete m_blackClip;
+ m_blackClip = new Mlt::Producer(*m_mltProfile , "colour", "black");
m_mltConsumer->connect(*m_mltProducer);
m_mltProducer->set_speed(0.0);
delete m_mltConsumer;
if (m_mltProducer)
delete m_mltProducer;
- while (! m_producersList.isEmpty()) delete m_producersList.takeFirst();
+ if (m_blackClip) delete m_blackClip;
//delete m_osdInfo;
}
Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "westley-xml", tmp);
delete[] tmp;
m_mltProducer = producer;
+ if (m_blackClip) delete m_blackClip;
+ m_blackClip = new Mlt::Producer(*m_mltProfile , "colour", "black");
m_mltProducer->optimise();
m_mltProducer->set_speed(0);
connectPlaylist();
QMap < QString, QString > metadataPropertyMap;
KUrl url = KUrl(xml.attribute("resource", QString::null));
- bool newProducer = false;
-
- Mlt::Producer *producer = getProducerById(QString::number(clipId));
- if (producer == NULL) {
- if (true /*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));
- 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 (producer->is_blank()) {
- kDebug() << " / / / / / / / /ERRROR / / / / // CANNOT LOAD PRODUCER: ";
- return;
- }
- m_producersList.append(producer);
- newProducer = true;
+ Mlt::Producer *producer;
+ if (xml.attribute("type").toInt() == COLOR) {
+ char *tmp = decodedString("colour:" + xml.attribute("colour"));
+ producer = new Mlt::Producer(*m_mltProfile, "fezzik", tmp);
+ producer->set_in_and_out(xml.attribute("in").toInt(), xml.attribute("out").toInt());
+ 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);
+ if (!xml.attribute("out").isEmpty()) producer->set_in_and_out(xml.attribute("in").toInt(), xml.attribute("out").toInt());
+ delete[] tmp;
}
-
-
-
+ 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());
metadataPropertyMap[ name.section(".", 0, -2)] = value;
}
- emit replyGetFileProperties(clipId, filePropertyMap, metadataPropertyMap);
+ emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap);
kDebug() << "REquested fuile info for: " << url.path();
if (frame) delete frame;
- if (!newProducer && producer) delete producer;
+ //if (producer) delete producer;
}
/** Create the producer from the Westley QDomDocument */
setSceneList(doc, 0);
}
#endif
+
+
+
+/** Create the producer from the Westley QDomDocument */
+void Render::setProducer(Mlt::Producer *producer, int position) {
+ if (m_winid == -1) return;
+ m_generateScenelist = true;
+
+ if (m_mltConsumer) {
+ m_mltConsumer->stop();
+ } else return;
+
+ if (m_mltProducer) {
+ m_mltProducer->set_speed(0);
+ delete m_mltProducer;
+ m_mltProducer = NULL;
+ emit stopped();
+ }
+ if (producer) m_mltProducer = new Mlt::Producer(producer->get_producer());
+ else m_mltProducer = new Mlt::Producer();
+ if (!m_mltProducer || !m_mltProducer->is_valid()) kDebug() << " WARNING - - - - -INVALID PLAYLIST: ";
+ m_mltProducer->optimise();
+
+ m_fps = m_mltProducer->get_fps();
+ connectPlaylist();
+ if (position != 0) {
+ m_mltProducer->seek(position);
+ emit rendererPosition(position);
+ }
+ m_generateScenelist = false;
+}
+
+
+
/** Create the producer from the Westley QDomDocument */
void Render::setSceneList(QDomDocument list, int position) {
setSceneList(list.toString(), position);
char *tmp = decodedString(playlist);
m_mltProducer = new Mlt::Producer(*m_mltProfile, "westley-xml", tmp);
delete[] tmp;
+ if (m_blackClip) delete m_blackClip;
+ m_blackClip = new Mlt::Producer(*m_mltProfile , "colour", "black");
if (!m_mltProducer || !m_mltProducer->is_valid()) kDebug() << " WARNING - - - - -INVALID PLAYLIST: " << tmp;
m_mltProducer->optimise();
m_mltConsumer->connect(*m_mltProducer);
m_mltProducer->set_speed(0);
m_mltConsumer->start();
- parsePlaylistForClips();
emit durationChanged(m_mltProducer->get_playtime());
//refresh();
/*
while (dur > 14000) {
info.startPos = GenTime(i * 14000, m_fps);
info.endPos = info.startPos + GenTime(13999, m_fps);
- mltInsertClip(info, black);
+ mltInsertClip(info, black, m_blackClip);
dur = dur - 14000;
i++;
}
if (dur > 0) {
info.startPos = GenTime(i * 14000, m_fps);
info.endPos = info.startPos + GenTime(dur, m_fps);
- mltInsertClip(info, black);
+ mltInsertClip(info, black, m_blackClip);
}
m_mltProducer->set("out", duration);
emit durationChanged((int)duration);
}
}
-void Render::mltInsertClip(ItemInfo info, QDomElement element) {
+void Render::mltInsertClip(ItemInfo info, QDomElement element, Mlt::Producer *prod) {
if (!m_mltProducer) {
kDebug() << "PLAYLIST NOT INITIALISED //////";
return;
Mlt::Producer trackProducer(tractor.track(info.track));
Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
- Mlt::Producer *prod = getProducerById(element.attribute("id"));
- if (prod == NULL) {
+ /*if (prod == NULL) {
// clip was never used yet
QDomDocument doc;
doc.appendChild(doc.importNode(element, true));
char *tmp = decodedString(resource);
prod = new Mlt::Producer(*m_mltProfile, "westley-xml", tmp);
delete[] tmp;
- m_producersList.append(prod);
- }
+ }*/
Mlt::Producer *clip = prod->cut(info.cropStart.frames(m_fps), (info.endPos - info.startPos).frames(m_fps));
trackPlaylist.insert_at((int) info.startPos.frames(m_fps), *clip, 1);
//tractor.refresh();
}
-Mlt::Producer *Render::getProducerById(const QString &id) {
- for (int i = 0; i < m_producersList.count(); i++) {
- if (m_producersList.at(i)->get("id") == id) return m_producersList.at(i);
- }
- return NULL;
-}
-
-void Render::parsePlaylistForClips() {
- // clear current producers list
- while (! m_producersList.isEmpty()) delete m_producersList.takeFirst();
-
- //parse entire playlists to find all the different clips
- Mlt::Producer parentProd(m_mltProducer->parent());
- if (parentProd.get_producer() == NULL) {
- kDebug() << "PLAYLIST BROKEN, CANNOT INSERT CLIP //////";
- return;
- }
- Mlt::Service service(parentProd.get_service());
- if (service.type() != tractor_type) return;
- Mlt::Tractor tractor(service);
- mlt_service_lock(service.get_service());
- for (int i = 0; i < tractor.count(); i++) {
- Mlt::Producer trackProducer(tractor.track(i));
- Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
- for (int j = 0; j < trackPlaylist.count(); j++) {
- if (!trackPlaylist.is_blank(j)) {
- Mlt::Producer *clip = trackPlaylist.get_clip(j);
- if (clip) {
- if (getProducerById(clip->get("id")) == NULL)
- m_producersList.append(new Mlt::Producer(clip->get_parent()));
- }
- }
- }
- }
-}
void Render::mltCutClip(int track, GenTime position) {
m_isBlocked = true;
m_isBlocked = false;
}
-void Render::mltUpdateClip(ItemInfo info, QDomElement element) {
+void Render::mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *prod) {
// TODO: optimize
mltRemoveClip(info.track, info.startPos);
- mltInsertClip(info, element);
+ mltInsertClip(info, element, prod);
}
be list. */
void setSceneList(QDomDocument list, int position = 0);
void setSceneList(QString playlist, int position = 0);
+ void setProducer(Mlt::Producer *producer, int position);
QString sceneList();
void saveSceneList(QString path, QDomElement kdenliveData = QDomElement());
const double dar() const;
/** Playlist manipulation */
- void mltInsertClip(ItemInfo info, QDomElement element);
- void mltUpdateClip(ItemInfo info, QDomElement element);
+ void mltInsertClip(ItemInfo info, QDomElement element, Mlt::Producer *prod);
+ void mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *prod);
void mltCutClip(int track, GenTime position);
void mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out);
void mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out);
uint m_monitorId;
bool m_generateScenelist;
- QList <Mlt::Producer *> m_producersList;
- Mlt::Producer *getProducerById(const QString &id);
- void parsePlaylistForClips();
+ Mlt::Producer *m_blackClip;
/** Holds the path to on screen display profile */
QString m_osdProfile;
signals: // Signals
/** emitted when the renderer recieves a reply to a getFileProperties request. */
- void replyGetFileProperties(int clipId, const QMap < QString, QString > &, const QMap < QString, QString > &);
+ void replyGetFileProperties(int clipId, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &);
/** emitted when the renderer recieves a reply to a getImage request. */
void replyGetImage(int , int, const QPixmap &, int, int);