aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-05-23 15:34:19 +0200
committerJean-Baptiste Mardelle <[email protected]>2015-05-23 15:34:19 +0200
commit165d95603d520ccd092a46e318240b1cb222c979 (patch)
tree6ac3366c9db36b7ad17202efb52bb77abfdeb0fc
parentd027bdc83abe68876230e616fc88ad65617f4774 (diff)
Fix proxy clips
-rw-r--r--src/mltcontroller/bincontroller.cpp3
-rw-r--r--src/mltcontroller/bincontroller.h1
-rw-r--r--src/mltcontroller/clipcontroller.h2
-rw-r--r--src/renderer.cpp6
-rw-r--r--src/renderer.h2
-rw-r--r--src/timeline/customtrackview.cpp10
-rw-r--r--src/timeline/customtrackview.h2
-rw-r--r--src/timeline/timeline.cpp8
-rw-r--r--src/timeline/timeline.h1
-rw-r--r--src/timeline/track.cpp29
-rw-r--r--src/timeline/track.h5
11 files changed, 64 insertions, 5 deletions
diff --git a/src/mltcontroller/bincontroller.cpp b/src/mltcontroller/bincontroller.cpp
index 05419af..a300cfb 100644
--- a/src/mltcontroller/bincontroller.cpp
+++ b/src/mltcontroller/bincontroller.cpp
@@ -222,12 +222,13 @@ void BinController::replaceProducer(const QString &id, Mlt::Producer &producer)
{
ClipController *ctrl = m_clipList.value(id);
if (!ctrl) {
- qDebug()<<" / // errror controller not foound, crashing";
+ qDebug()<<" / // error controller not found, crashing";
return;
}
ctrl->updateProducer(id, &producer);
replaceBinPlaylistClip(id, producer);
producer.set("id", id.toUtf8().constData());
+ emit replaceTimelineProducer(id);
}
void BinController::addClipToBin(const QString &id, ClipController *controller) // Mlt::Producer &producer)
diff --git a/src/mltcontroller/bincontroller.h b/src/mltcontroller/bincontroller.h
index 8d40c44..95a75bf 100644
--- a/src/mltcontroller/bincontroller.h
+++ b/src/mltcontroller/bincontroller.h
@@ -179,6 +179,7 @@ signals:
void reloadTrackProducers(const QString &id);
void requestAudioThumb(const QString&);
void abortAudioThumb(const QString&);
+ void replaceTimelineProducer(const QString &id);
};
#endif
diff --git a/src/mltcontroller/clipcontroller.h b/src/mltcontroller/clipcontroller.h
index 041238c..fab64a7 100644
--- a/src/mltcontroller/clipcontroller.h
+++ b/src/mltcontroller/clipcontroller.h
@@ -70,7 +70,7 @@ public:
/** @brief Append a track producer retrieved from document loading to out list */
void appendTrackProducer(const QString trackName, Mlt::Producer &producer);
- /** @brief Returns a clone of our master producer */
+ /** @brief Returns a clone of our master producer. Delete after use! */
Mlt::Producer *masterProducer();
Mlt::Producer *zoneProducer(int in, int out);
diff --git a/src/renderer.cpp b/src/renderer.cpp
index 46873c1..089ed90 100644
--- a/src/renderer.cpp
+++ b/src/renderer.cpp
@@ -104,6 +104,7 @@ Render::Render(Kdenlive::MonitorId rendererName, BinController *binController, G
connect(this, SIGNAL(checkSeeking()), this, SLOT(slotCheckSeeking()));
if (m_name == Kdenlive::ProjectMonitor) {
connect(m_binController, SIGNAL(reloadTrackProducers(const QString &)), this, SLOT(slotUpdateTrackProducers(const QString &)));
+ connect(m_binController, SIGNAL(replaceTimelineProducer(QString)), this, SIGNAL(replaceTimelineProducer(QString)));
connect(m_binController, SIGNAL(createThumb(QDomElement,QString,int)), this, SLOT(getFileProperties(QDomElement,QString,int)));
}
//connect(this, SIGNAL(mltFrameReceived(Mlt::Frame*)), this, SLOT(showFrame(Mlt::Frame*)), Qt::UniqueConnection);
@@ -599,7 +600,7 @@ void Render::processProducerProperties(Mlt::Producer *prod, QDomElement xml)
{
QString value;
QStringList internalProperties;
- internalProperties << "bypassDuplicate";
+ internalProperties << "bypassDuplicate" << "resource" << "mlt_service";
QDomNodeList props = xml.elementsByTagName("property");
for (int i = 0; i < props.count(); ++i) {
QString propertyName = props.at(i).toElement().attribute("name");
@@ -677,6 +678,7 @@ void Render::processFileProperties()
//path = info.xml.attribute("resource");
proxyProducer = false;
}
+ qDebug()<<" / / /CHECKING PRODUCER PATH: "<<path;
QUrl url = QUrl::fromLocalFile(path);
Mlt::Producer *producer = NULL;
ClipType type = (ClipType)info.xml.attribute("type").toInt();
@@ -984,7 +986,7 @@ void Render::processFileProperties()
Mlt::Producer *tmpProd;
if (KdenliveSettings::gpu_accel()) {
QString service = producer->get("mlt_service");
- tmpProd = new Mlt::Producer(*m_mltProfile, service.toUtf8().constData(), producer->get("resource"));
+ tmpProd = new Mlt::Producer(*m_mltProfile, service.toUtf8().constData(), path.toUtf8().constData());
Mlt::Filter scaler(*m_mltProfile, "swscale");
Mlt::Filter converter(*m_mltProfile, "avcolor_space");
tmpProd->attach(scaler);
diff --git a/src/renderer.h b/src/renderer.h
index 476c85e..c30f230 100644
--- a/src/renderer.h
+++ b/src/renderer.h
@@ -456,6 +456,8 @@ signals:
void requestProxy(QString);
/** @brief A multiple stream clip was found. */
void multiStreamFound(const QString &,QList<int>,QList<int>,stringMap data);
+ /** @brief A clip has changed, we must reload timeline producers. */
+ void replaceTimelineProducer(const QString&);
/** @brief A frame's image has to be shown.
diff --git a/src/timeline/customtrackview.cpp b/src/timeline/customtrackview.cpp
index 632f4ad..af39ebe 100644
--- a/src/timeline/customtrackview.cpp
+++ b/src/timeline/customtrackview.cpp
@@ -163,6 +163,8 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, Timeline *timeline, CustomTra
QIcon razorIcon = QIcon::fromTheme("edit-cut");
m_razorCursor = QCursor(razorIcon.pixmap(32, 32));
m_spacerCursor = QCursor(Qt::SplitHCursor);
+
+ connect(m_document->renderer(), SIGNAL(replaceTimelineProducer(QString)), this, SLOT(slotReplaceTimelineProducer(QString)));
scale(1, 1);
setAlignment(Qt::AlignLeft | Qt::AlignTop);
@@ -7445,3 +7447,11 @@ void CustomTrackView::slotImportClipKeyframes(GraphicsRectItem type)
emit importKeyframes(type, result, ui.limit_keyframes->isChecked() ? ui.max_keyframes->value() : -1);
delete d;
}
+
+void CustomTrackView::slotReplaceTimelineProducer(const QString &id)
+{
+ Mlt::Producer *prod = m_document->renderer()->getBinProducer(id);
+ for (int i = 0; i < m_timeline->tracksCount(); i++) {
+ m_timeline->track(i)->replace(id, prod);
+ }
+}
diff --git a/src/timeline/customtrackview.h b/src/timeline/customtrackview.h
index 7d17773..32c76d5 100644
--- a/src/timeline/customtrackview.h
+++ b/src/timeline/customtrackview.h
@@ -497,6 +497,8 @@ private slots:
void slotRefreshThumbs(const QString &id, bool resetThumbs);
/** @brief A Filter job producer results. */
void slotGotFilterJobResults(const QString &id, int startPos, int track, stringMap filterParams, stringMap extra);
+ /** @brief Replace a producer in all tracks (for example when proxying a clip). */
+ void slotReplaceTimelineProducer(const QString &id);
signals:
diff --git a/src/timeline/timeline.cpp b/src/timeline/timeline.cpp
index 2c40e06..0fb0b82 100644
--- a/src/timeline/timeline.cpp
+++ b/src/timeline/timeline.cpp
@@ -139,10 +139,16 @@ Timeline::~Timeline()
m_tracks.clear();
}
-Track* Timeline::track(int i) {
+Track* Timeline::track(int i)
+{
return m_tracks.at(i);
}
+int Timeline::tracksCount() const
+{
+ return m_tracks.count();
+}
+
//virtual
void Timeline::keyPressEvent(QKeyEvent * event)
{
diff --git a/src/timeline/timeline.h b/src/timeline/timeline.h
index 44156dc..4179c7a 100644
--- a/src/timeline/timeline.h
+++ b/src/timeline/timeline.h
@@ -53,6 +53,7 @@ public:
explicit Timeline(KdenliveDoc *doc, const QList <QAction *>& actions, bool *ok, QWidget *parent = 0);
virtual ~ Timeline();
Track* track(int i);
+ int tracksCount() const;
void setEditMode(const QString & editMode);
const QString & editMode() const;
QGraphicsScene *projectScene();
diff --git a/src/timeline/track.cpp b/src/timeline/track.cpp
index b7f77fd..70939e4 100644
--- a/src/timeline/track.cpp
+++ b/src/timeline/track.cpp
@@ -215,6 +215,35 @@ bool Track::cut(qreal t)
}
+bool Track::replace(const QString &id, Mlt::Producer *original)
+{
+ int startindex = 0;
+ bool found = false;
+ QString idForTrack = original->get("id") + QLatin1Char('_') + m_playlist.get("id");
+ Mlt::Producer *trackProducer = Clip(*original).clone();
+
+ for (int i = 0; i < m_playlist.count(); i++) {
+ if (m_playlist.is_blank(i)) continue;
+ Mlt::Producer *p = m_playlist.get_clip(i);
+ if (idForTrack == p->parent().get("id")) {
+ //Mlt::Producer *orig = m_playlist.replace_with_blank(i);
+ Mlt::Producer *cut = trackProducer->cut(p->get_in(), p->get_out());
+ Clip(*cut).addEffects(*p);
+ m_playlist.remove(i);
+ m_playlist.insert(*cut, i);
+ m_playlist.consolidate_blanks();
+ found = true;
+ delete cut;
+ }
+ delete p;
+ }
+ if (found) {
+ trackProducer->set("id", idForTrack.toUtf8().constData());
+ } else {
+ delete trackProducer;
+ }
+}
+
//TODO: cut: checkSlowMotionProducer
bool Track::replace(qreal t, Mlt::Producer *prod) {
int index = m_playlist.get_clip_index_at(frame(t));
diff --git a/src/timeline/track.h b/src/timeline/track.h
index 3f6f985..686a2ff 100644
--- a/src/timeline/track.h
+++ b/src/timeline/track.h
@@ -93,6 +93,11 @@ public:
* @return true if success */
bool cut(qreal t);
/** @brief replace a clip with another resource
+ * @param id is the clip id
+ * @param prod is the replacement clip
+ * @return true if success */
+ bool replace(const QString &id, Mlt::Producer *prod);
+ /** @brief replace a clip with another resource
* @param t is the clip time in playlist
* @param prod is the replacement clip
* @return true if success */