void Render::closeMlt()
-{
+{
//delete m_osdTimer;
- if (m_mltProducer) {
+ if (m_mltConsumer) delete m_mltConsumer;
+ if (m_mltProducer) delete m_mltProducer;
+ /*if (m_mltProducer) {
Mlt::Service service(m_mltProducer->parent().get_service());
mlt_service_lock(service.get_service());
resource = mlt_properties_get(properties, "mlt_service");
}
- for (int trackNb = tractor.count() - 1; trackNb >= 0; --trackNb) {
- Mlt::Producer trackProducer(tractor.track(trackNb));
- Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
- if (trackPlaylist.type() == playlist_type) trackPlaylist.clear();
- }
delete field;
field = NULL;
}
mlt_service_unlock(service.get_service());
- }
+ }*/
kDebug() << "// // // CLOSE RENDERER " << m_name;
- delete m_mltConsumer;
- delete m_mltProducer;
- delete m_blackClip;
+ if (m_blackClip) delete m_blackClip;
//delete m_osdInfo;
}
void Render::buildConsumer(const QString profileName)
{
- m_activeProfile = profileName;
- char *tmp = qstrdup(m_activeProfile.toUtf8().constData());
delete m_blackClip;
m_blackClip = NULL;
//TODO: uncomment following line when everything is clean
// uncommented Feb 2011 --Granjow
if (m_mltProfile) delete m_mltProfile;
-
+ m_activeProfile = profileName;
+ char *tmp = qstrdup(m_activeProfile.toUtf8().constData());
+ setenv("MLT_PROFILE", tmp, 1);
m_mltProfile = new Mlt::Profile(tmp);
m_mltProfile->set_explicit(true);
delete[] tmp;
Mlt::Producer *Render::invalidProducer(const QString &id)
{
- Mlt::Producer *clip = new Mlt::Producer(*m_mltProfile, "colour", "red");
+ Mlt::Producer *clip;
+ QString txt = "+" + i18n("Missing clip") + ".txt";
+ char *tmp = qstrdup(txt.toUtf8().constData());
+ clip = new Mlt::Producer(*m_mltProfile, tmp);
+ delete[] tmp;
+ if (clip == NULL) clip = new Mlt::Producer(*m_mltProfile, "colour", "red");
+ else {
+ clip->set("bgcolour", "0xff0000ff");
+ clip->set("pad", "10");
+ }
clip->set("id", id.toUtf8().constData());
clip->set("mlt_type", "producer");
return clip;
}
-int Render::resetProfile(const QString profileName)
+int Render::resetProfile(const QString profileName, bool dropSceneList)
{
- QString scene = sceneList();
+ QString scene;
+ if (!dropSceneList) scene = sceneList();
if (m_mltConsumer) {
if (m_externalConsumer == KdenliveSettings::external_display()) {
if (KdenliveSettings::external_display() && m_activeProfile == profileName) return 1;
buildConsumer(profileName);
double new_fps = m_mltProfile->fps();
double new_dar = m_mltProfile->dar();
- if (current_fps != new_fps) {
- // fps changed, we must update the scenelist positions
- scene = updateSceneListFps(current_fps, new_fps, scene);
+
+ if (!dropSceneList) {
+ // We need to recover our playlist
+ if (current_fps != new_fps) {
+ // fps changed, we must update the scenelist positions
+ scene = updateSceneListFps(current_fps, new_fps, scene);
+ }
+ setSceneList(scene, pos);
+ // producers have changed (different profile), so reset them...
+ emit refreshDocumentProducers(new_dar != current_dar, current_fps != new_fps);
}
- //kDebug() << "//RESET WITHSCENE: " << scene;
- setSceneList(scene, pos);
- // producers have changed (different profile), so reset them...
- emit refreshDocumentProducers(new_dar != current_dar, current_fps != new_fps);
- /*Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "xml-string", scene.toUtf8().constData());
- m_mltProducer = producer;
- m_blackClip = new Mlt::Producer(*m_mltProfile , "colour", "black");
- m_mltProducer->optimise();
- m_mltProducer->set_speed(0);
- connectPlaylist();*/
-
- //delete m_mltProfile;
- // mlt_properties properties = MLT_CONSUMER_PROPERTIES(m_mltConsumer->get_consumer());
- //mlt_profile prof = m_mltProfile->get_profile();
- //mlt_properties_set_data(properties, "_profile", prof, 0, (mlt_destructor)mlt_profile_close, NULL);
- //mlt_properties_set(properties, "profile", "hdv_1080_50i");
- //m_mltConsumer->set("profile", (char *) profile.toUtf8().data());
- //m_mltProfile = new Mlt::Profile((char*) profile.toUtf8().data());
-
- //apply_profile_properties( m_mltProfile, m_mltConsumer->get_consumer(), properties );
- //refresh();
return 1;
}
proxyProducer = false;
}
- KUrl url = KUrl(path);
+ KUrl url(path);
Mlt::Producer *producer = NULL;
CLIPTYPE type = (CLIPTYPE)xml.attribute("type").toInt();
//kDebug() << "PROFILE WIDT: "<< xml.attribute("mlt_service") << ": "<< m_mltProfile->width() << "\n...................\n\n";
play.appendChild(doc.importNode(xml, true));
producer = new Mlt::Producer(*m_mltProfile, "xml-string", doc.toString().toUtf8().constData());
} else {
- producer = new Mlt::Producer(*m_mltProfile, url.path().toUtf8().constData());
+ producer = new Mlt::Producer(*m_mltProfile, path.toUtf8().constData());
}
if (producer == NULL || producer->is_blank() || !producer->is_valid()) {
- kDebug() << " / / / / / / / / ERROR / / / / // CANNOT LOAD PRODUCER: ";
+ kDebug() << " / / / / / / / / ERROR / / / / // CANNOT LOAD PRODUCER: "<<path;
if (proxyProducer) {
// Proxy file is corrupted
emit removeInvalidProxy(clipId, false);
if ((!replaceProducer && xml.hasAttribute("file_hash")) || xml.hasAttribute("proxy")) {
// Clip already has all properties
+ if (replaceProducer) emit blockClipMonitor(clipId);
+ // Querying a frame is required by MLT, otherwise the producer is not correctly initialised
+ Mlt::Frame *frame = producer->get_frame();
+ delete frame;
emit replyGetFileProperties(clipId, producer, QMap < QString, QString >(), QMap < QString, QString >(), replaceProducer, selectClip);
return;
}
metadataPropertyMap[ name.section('.', 0, -2)] = value;
}
producer->seek(0);
+ if (replaceProducer) emit blockClipMonitor(clipId);
emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap, replaceProducer, selectClip);
// FIXME: should delete this to avoid a leak...
//delete producer;
int Render::setProducer(Mlt::Producer *producer, int position)
{
+ QMutexLocker locker(&m_mutex);
if (m_winid == -1) return -1;
-
if (m_mltConsumer) {
- m_mltConsumer->stop();
- } else return -1;
+ if (!m_mltConsumer->is_stopped()) {
+ m_mltConsumer->stop();
+ }
+ m_mltConsumer->set("refresh", 0);
+ }
+ else {
+ return -1;
+ }
- m_mltConsumer->purge();
m_isBlocked = true;
if (m_mltProducer) {
m_mltProducer->set_speed(0);
m_mltProducer = NULL;
emit stopped();
}
- if (producer) {
+ blockSignals(true);
+ if (producer && producer->is_valid()) {
m_mltProducer = new Mlt::Producer(producer->get_producer());
} else m_mltProducer = m_blackClip->cut(0, 50);
int volume = KdenliveSettings::volume();
m_mltProducer->set("meta.volume", (double)volume / 100);
m_fps = m_mltProducer->get_fps();
+ blockSignals(false);
int error = connectPlaylist();
if (position != -1) {
m_isBlocked = true;
int error = 0;
- //kDebug() << "////// RENDER, SET SCENE LIST: " << playlist;
+ //kDebug() << "////// RENDER, SET SCENE LIST:\n" << playlist <<"\n..........:::.";
// Remove previous profile info
QDomDocument doc;
m_mltProducer->set_speed(0);
//if (KdenliveSettings::osdtimecode() && m_osdInfo) m_mltProducer->detach(*m_osdInfo);
- Mlt::Service service(m_mltProducer->parent().get_service());
+ /*Mlt::Service service(m_mltProducer->parent().get_service());
mlt_service_lock(service.get_service());
if (service.type() == tractor_type) {
}
delete field;
}
- mlt_service_unlock(service.get_service());
+ mlt_service_unlock(service.get_service());*/
qDeleteAll(m_slowmotionProducers.values());
m_slowmotionProducers.clear();
}
blockSignals(true);
- // TODO: Better way to do this
- if (KdenliveSettings::projectloading_avformatnovalidate())
+ // WARNING: disabled because it caused crashes (see Kdenlive bug #2205 and #2206) - jbm
+ /*if (KdenliveSettings::projectloading_avformatnovalidate())
playlist.replace(">avformat</property>", ">avformat-novalidate</property>");
else
- playlist.replace(">avformat-novalidate</property>", ">avformat</property>");
-
+ playlist.replace(">avformat-novalidate</property>", ">avformat</property>");*/
m_mltProducer = new Mlt::Producer(*m_mltProfile, "xml-string", playlist.toUtf8().constData());
if (!m_mltProducer || !m_mltProducer->is_valid()) {
kDebug() << " WARNING - - - - -INVALID PLAYLIST: " << playlist.toUtf8().constData();
if (!slowprod || slowprod->get_producer() == NULL) {
slowprod = new Mlt::Producer(*m_mltProfile, 0, ("framebuffer:" + url).toUtf8().constData());
if (strobe > 1) slowprod->set("strobe", strobe);
- QString id = prod->get("id");
+ QString id = prod->parent().get("id");
if (id.contains('_')) id = id.section('_', 0, 0);
QString producerid = "slowmotion:" + id + ':' + QString::number(speed);
if (strobe > 1) producerid.append(':' + QString::number(strobe));
return false;
}
params.removeParam("kdenlive_id");
+ if (params.hasParam("_sync_in_out")) {
+ // This effect must sync in / out with parent clip
+ params.removeParam("_sync_in_out");
+ filter->set_in_and_out(service.get_int("in"), service.get_int("out"));
+ }
for (int j = 0; j < params.count(); j++) {
filter->set((prefix + params.at(j).name()).toUtf8().constData(), params.at(j).value().toUtf8().constData());
filter->set("effect", effectArgs.simplified().toUtf8().constData());
}
- if (params.paramValue("id") == "pan_zoom") {
- filter->set_in_and_out(service.get_int("in"), service.get_int("out") + 1);
- }
-
// attach filter to the clip
service.attach(*filter);
}
QString prefix;
QString ser = filter->get("mlt_service");
if (ser == "region") prefix = "filter0.";
+ if (params.hasParam("_sync_in_out")) {
+ // This effect must sync in / out with parent clip
+ params.removeParam("_sync_in_out");
+ filter->set_in_and_out(clip->get_in(), clip->get_out());
+ }
mlt_service_lock(service.get_service());
for (int j = 0; j < params.count(); j++) {
filter->set((prefix + params.at(j).name()).toUtf8().constData(), params.at(j).value().toUtf8().constData());
- }
-
- if (params.paramValue("id") == "pan_zoom")
- filter->set_in_and_out(clip->get_in(), clip->get_out() + 1);
+ }
delete clip;
mlt_service_unlock(service.get_service());
kDebug() << "// Warning, CLIP on track " << track << ", at: " << pos << " is invalid, cannot update it!!!";
return false;
}
- kDebug() << "NEW PROD ID: " << prod->get("id");
m_isBlocked++;
kDebug() << "// TRYING TO UPDATE CLIP at: " << pos << ", TK: " << track;
Mlt::Service service(m_mltProducer->parent().get_service());
int clipNb = trackPlaylist.count();
for (int i = 0; i < clipNb; i++) {
Mlt::Producer *c = trackPlaylist.get_clip(i);
- Mlt::Producer *nprod = new Mlt::Producer(c->get_parent());
- if (nprod) {
- QString prodId = nprod->get("id");
- if (!prodId.startsWith("slowmotion") && !prodId.isEmpty() && !nprod->is_blank() && !ids.contains(prodId)) {
- ids.append(nprod->get("id"));
+ if (c == NULL) continue;
+ QString prodId = c->parent().get("id");
+ if (!c->is_blank() && !ids.contains(prodId) && !prodId.startsWith("slowmotion") && !prodId.isEmpty()) {
+ Mlt::Producer *nprod = new Mlt::Producer(c->get_parent());
+ if (nprod) {
+ ids.append(prodId);
prods.append(nprod);
- } else delete nprod;
+ }
}
delete c;
}
Mlt::Producer *c = trackPlaylist.get_clip(i);
Mlt::Producer *nprod = new Mlt::Producer(c->get_parent());
if (nprod) {
- QString id = nprod->get("id");
+ QString id = nprod->parent().get("id");
if (id.startsWith("slowmotion:") && !nprod->is_blank()) {
// this is a slowmotion producer, add it to the list
QString url = QString::fromUtf8(nprod->get("resource"));