Commit dc892a51 authored by Nicolas Carion's avatar Nicolas Carion

fix clip disabling

parent 0b413c8b
...@@ -427,6 +427,14 @@ void ProjectClip::createVideoMasterProducer() ...@@ -427,6 +427,14 @@ void ProjectClip::createVideoMasterProducer()
m_videoProducer->set("set.test_image", 0); m_videoProducer->set("set.test_image", 0);
} }
} }
void ProjectClip::createDisabledMasterProducer()
{
if (!m_disabledProducer) {
m_disabledProducer = cloneProducer(&pCore->getCurrentProfile()->profile());
m_disabledProducer->set("set.test_audio", 1);
m_disabledProducer->set("set.test_image", 1);
}
}
std::shared_ptr<Mlt::Producer> ProjectClip::getTimelineProducer(int clipId, PlaylistState::ClipState state, double speed) std::shared_ptr<Mlt::Producer> ProjectClip::getTimelineProducer(int clipId, PlaylistState::ClipState state, double speed)
{ {
if (qFuzzyCompare(speed, 1.0)) { if (qFuzzyCompare(speed, 1.0)) {
...@@ -442,10 +450,15 @@ std::shared_ptr<Mlt::Producer> ProjectClip::getTimelineProducer(int clipId, Play ...@@ -442,10 +450,15 @@ std::shared_ptr<Mlt::Producer> ProjectClip::getTimelineProducer(int clipId, Play
} }
return std::shared_ptr<Mlt::Producer>(m_audioProducers[clipId]->cut()); return std::shared_ptr<Mlt::Producer>(m_audioProducers[clipId]->cut());
} }
// we return the video producer
m_audioProducers.erase(clipId); m_audioProducers.erase(clipId);
createVideoMasterProducer(); if (state == PlaylistState::VideoOnly) {
return std::shared_ptr<Mlt::Producer>(m_videoProducer->cut()); // we return the video producer
createVideoMasterProducer();
return std::shared_ptr<Mlt::Producer>(m_videoProducer->cut());
}
Q_ASSERT(state == PlaylistState::Disabled);
createDisabledMasterProducer();
return std::shared_ptr<Mlt::Producer>(m_disabledProducer->cut());
} }
// in that case, we need to create a warp producer, if we don't have one // in that case, we need to create a warp producer, if we don't have one
...@@ -497,15 +510,24 @@ std::pair<std::shared_ptr<Mlt::Producer>, bool> ProjectClip::giveMasterAndGetTim ...@@ -497,15 +510,24 @@ std::pair<std::shared_ptr<Mlt::Producer>, bool> ProjectClip::giveMasterAndGetTim
return {getTimelineProducer(clipId, state, speed), false}; return {getTimelineProducer(clipId, state, speed), false};
} }
// if it's a video or disabled clip, we must make sure that its master clip matches our video master // if it's a video or disabled clip, we must make sure that its master clip matches our video master
if (!m_videoProducer) { if (state == PlaylistState::VideoOnly && !m_videoProducer) {
qDebug() << "Warning: weird, we found a video clip whose master is already loaded but we don't have any yet"; qDebug() << "Warning: weird, we found a video clip whose master is already loaded but we don't have any yet";
createVideoMasterProducer(); createVideoMasterProducer();
return {std::shared_ptr<Mlt::Producer>(m_videoProducer->cut(in, out)), false}; return {std::shared_ptr<Mlt::Producer>(m_videoProducer->cut(in, out)), false};
} }
if (QString::fromUtf8(m_videoProducer->get("id")) != QString::fromUtf8(master->parent().get("id"))) { if (state == PlaylistState::Disabled && !m_disabledProducer) {
qDebug() << "Warning: weird, we found a disabled clip whose master is already loaded but we don't have any yet";
createDisabledMasterProducer();
return {std::shared_ptr<Mlt::Producer>(m_disabledProducer->cut(in, out)), false};
}
if (state == PlaylistState::VideoOnly && QString::fromUtf8(m_videoProducer->get("id")) != QString::fromUtf8(master->parent().get("id"))) {
qDebug() << "Warning: weird, we found a video clip whose master is already loaded but doesn't match ours"; qDebug() << "Warning: weird, we found a video clip whose master is already loaded but doesn't match ours";
return {std::shared_ptr<Mlt::Producer>(m_videoProducer->cut(in, out)), false}; return {std::shared_ptr<Mlt::Producer>(m_videoProducer->cut(in, out)), false};
} }
if (state == PlaylistState::Disabled && QString::fromUtf8(m_disabledProducer->get("id")) != QString::fromUtf8(master->parent().get("id"))) {
qDebug() << "Warning: weird, we found a disabled clip whose master is already loaded but doesn't match ours";
return {std::shared_ptr<Mlt::Producer>(m_disabledProducer->cut(in, out)), false};
}
// We have a good id, this clip can be used // We have a good id, this clip can be used
return {master, true}; return {master, true};
} else { } else {
...@@ -518,12 +540,17 @@ std::pair<std::shared_ptr<Mlt::Producer>, bool> ProjectClip::giveMasterAndGetTim ...@@ -518,12 +540,17 @@ std::pair<std::shared_ptr<Mlt::Producer>, bool> ProjectClip::giveMasterAndGetTim
m_timewarpProducers[clipId] = std::shared_ptr<Mlt::Producer>(&master->parent()); m_timewarpProducers[clipId] = std::shared_ptr<Mlt::Producer>(&master->parent());
return {master, true}; return {master, true};
} }
if (!m_videoProducer) { if (state == PlaylistState::VideoOnly && !m_videoProducer) {
// good, we found a master video producer, and we didn't have any // good, we found a master video producer, and we didn't have any
m_videoProducer.reset(&master->parent()); m_videoProducer.reset(&master->parent());
return {master, true}; return {master, true};
} }
qDebug() << "Warning: weird, we found a video clip whose master is not loaded but we already have a master"; if (state == PlaylistState::Disabled && !m_disabledProducer) {
// good, we found a master disabled producer, and we didn't have any
m_disabledProducer.reset(&master->parent());
return {master, true};
}
qDebug() << "Warning: weird, we found a clip whose master is not loaded but we already have a master";
return {std::shared_ptr<Mlt::Producer>(m_videoProducer->cut(in, out)), false}; return {std::shared_ptr<Mlt::Producer>(m_videoProducer->cut(in, out)), false};
} }
} else if (master->is_valid()) { } else if (master->is_valid()) {
......
...@@ -257,13 +257,16 @@ private: ...@@ -257,13 +257,16 @@ private:
// This is a helper function that creates the video producer. This is a clone of the original one, with audio disabled // This is a helper function that creates the video producer. This is a clone of the original one, with audio disabled
void createVideoMasterProducer(); void createVideoMasterProducer();
// This is a helper function that creates the disabled producer. This is a clone of the original one, with audio and video disabled
void createDisabledMasterProducer();
std::map<int, std::weak_ptr<TimelineModel>> m_registeredClips; std::map<int, std::weak_ptr<TimelineModel>> m_registeredClips;
// the following holds a producer for each audio clip in the timeline // the following holds a producer for each audio clip in the timeline
// keys are the id of the clips in the timeline, values are their values // keys are the id of the clips in the timeline, values are their values
std::unordered_map<int, std::shared_ptr<Mlt::Producer>> m_audioProducers; std::unordered_map<int, std::shared_ptr<Mlt::Producer>> m_audioProducers;
std::unordered_map<int, std::shared_ptr<Mlt::Producer>> m_timewarpProducers; std::unordered_map<int, std::shared_ptr<Mlt::Producer>> m_timewarpProducers;
std::shared_ptr<Mlt::Producer> m_videoProducer; std::shared_ptr<Mlt::Producer> m_videoProducer, m_disabledProducer;
signals: signals:
void producerChanged(const QString &, const std::shared_ptr<Mlt::Producer> &); void producerChanged(const QString &, const std::shared_ptr<Mlt::Producer> &);
......
...@@ -81,7 +81,7 @@ OLD.Menu { ...@@ -81,7 +81,7 @@ OLD.Menu {
onTriggered: timeline.triggerAction('cut_timeline_clip') onTriggered: timeline.triggerAction('cut_timeline_clip')
} }
OLD.Menu { OLD.Menu {
title: i18n('Clip Tape...') title: i18n('Clip Type...')
OLD.ExclusiveGroup { OLD.ExclusiveGroup {
id: radioInputGroup id: radioInputGroup
} }
......
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