if (mlt_properties_get_double( MLT_FRAME_PROPERTIES( frame_ptr ), "_speed" ) == 0.0) {
self->emitConsumerStopped();
}
- else {
+ else
+ {
self->emitFrameNumber(mlt_frame_get_position(frame_ptr));
}
}
-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_sceneList(QDomDocument()), m_winid(-1), m_framePosition(0), m_generateScenelist(false), 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_sceneList(QDomDocument()), m_winid(-1), m_framePosition(0), m_generateScenelist(false), m_isBlocked(true)
{
kDebug()<<"////////// USING PROFILE: "<<qstrdup(KdenliveSettings::current_profile().toUtf8());
m_mltProfile = new Mlt::Profile((char*) qstrdup(KdenliveSettings::current_profile().toUtf8()));
//delete m_osdInfo;
}
-
-
-
-
-/** Wraps the VEML command of the same name; requests that the renderer
-should create a video window. If show is true, then the window should be
-displayed, otherwise it should be hidden. Render will emit the signal
-replyCreateVideoXWindow() once the renderer has replied. */
-
-void Render::createVideoXWindow(WId winid, WId externalMonitor)
-{
- return;
- if (m_mltConsumer) {
- delete m_mltConsumer;
- }
-
- kDebug()<<"///////// INIT MONITOR WID";
- //Mlt::Profile profile("dv_pal");//hdv_1080_50i");
- //m_profile = profile;
- //Mlt::Producer *producer = new Mlt::Producer( profile, "/home/one/Video002.mp4" );
- Mlt::Consumer *consumer = new Mlt::Consumer( *m_mltProfile , "sdl_preview");
- //m_mltProducer = producer;
- m_mltConsumer = consumer;
- //consumer->set( "rescale", "none" );
- m_mltConsumer->set("resize", 1);
- m_mltConsumer->set("window_id", (int) winid);
- m_mltConsumer->set("terminate_on_pause", 1);
- m_externalwinid = (int) externalMonitor;
- m_winid = (int) winid;
- m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
- //m_mltProducer->set_speed(0.0);
- //m_mltConsumer->connect( *m_mltProducer );
- //m_mltConsumer->start( );
-/*
- m_mltConsumer = new Mlt::Consumer(m_profile, "sdl_preview");
- if (!m_mltConsumer || !m_mltConsumer->is_valid()) {
- KMessageBox::error(qApp->activeWindow(), i18n("Could not create the video preview window.\nThere is something wrong with your Kdenlive install.\n Exiting now..."));
- kError()<<"Sorry, cannot create MLT consumer, check your MLT install you miss SDL libraries support in MLT";
- exit(1);
- }
-
- m_externalwinid = (int) externalMonitor;
- m_winid = (int) winid;
-
- m_mltConsumer->set("window_id", m_winid);
- m_mltConsumer->set("resize", 1);
-
- m_mltConsumer->set("terminate_on_pause", 1);
- m_mltConsumer->set("progressive", 1);
- m_mltConsumer->set("audio_buffer", 1024);
- m_mltConsumer->set("frequency", 48000);
-
- m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
-*/
- /*QString aDevice = KdenliveSettings::audiodevice();
- if (!KdenliveSettings::videodriver().isEmpty()) m_mltConsumer->set("video_driver", KdenliveSettings::videodriver().ascii());
- if (!KdenliveSettings::audiodriver().isEmpty()) m_mltConsumer->set("audio_driver", KdenliveSettings::audiodriver().ascii());
- m_mltConsumer->set("audio_device", aDevice.section(";", 1).ascii());*/
-
- initSceneList();
-
- //QTimer::singleShot(500, this, SLOT(initSceneList()));
- //initSceneList();
-// m_mltConsumer->listen("consumer-stopped", this, (mlt_listener) consumer_stopped);
-// m_mltConsumer->set("buffer", 25);
-}
int Render::resetRendererProfile(char * profile)
return 1;
}
-void Render::restartConsumer()
-{
- if (m_winid != -1) createVideoXWindow( m_winid, m_externalwinid);
-}
-
/** Wraps the VEML command of the same name; Seeks the renderer clip to the given time. */
void Render::seek(GenTime time)
{
producer.attach(m_convert);
Mlt::Frame * frame = producer.get_frame();
- if (frame->is_valid()) {
- filePropertyMap["fps"] =
- QString::number(mlt_producer_get_fps( producer.get_producer() ));
+ filePropertyMap["fps"] =
+ QString::number(mlt_producer_get_fps( producer.get_producer() ));
+
+ if (frame && frame->is_valid()) {
filePropertyMap["width"] =
QString::number(frame->get_int("width"));
filePropertyMap["height"] =
filePropertyMap["channels"] =
QString::number(frame->get_int("channels"));
+ if (frame->get_int("test_image") == 0) {
+ if (url.path().endsWith(".westley") || url.path().endsWith(".kdenlive")) {
+ filePropertyMap["type"] = "playlist";
+ metadataPropertyMap["comment"] = QString::fromUtf8(mlt_properties_get( MLT_SERVICE_PROPERTIES( producer.get_service() ), "title"));
+ }
+ else if (frame->get_int("test_audio") == 0)
+ filePropertyMap["type"] = "av";
+ else
+ filePropertyMap["type"] = "video";
+
+ // Generate thumbnail for this frame
+ QPixmap pixmap = frameThumbnail(frame, width, height, true);
+
+ emit replyGetImage(clipId, 0, pixmap, width, height);
+
+ } else if (frame->get_int("test_audio") == 0) {
+ QPixmap pixmap(KStandardDirs::locate("appdata", "graphics/music.png"));
+ emit replyGetImage(clipId, 0, pixmap, width, height);
+ filePropertyMap["type"] = "audio";
+ }
+ }
+
// Retrieve audio / video codec name
// Fetch the video_context
+#if 0 //until the reason for the chrashs is found
AVFormatContext *context = (AVFormatContext *) mlt_properties_get_data( properties, "video_context", NULL );
if (context != NULL) {
// Get the video_index
int index = mlt_properties_get_int( properties, "video_index" );
- filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->name;
+ if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name )
+ filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->name;
}
context = (AVFormatContext *) mlt_properties_get_data( properties, "audio_context", NULL );
if (context != NULL) {
// Get the video_index
int index = mlt_properties_get_int( properties, "audio_index" );
- filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->name;
+ if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name )
+ filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->name;
}
-
+#endif
// metadata
metadataPropertyMap[ name.section(".", 0, -2) ] = value;
}
- if (frame->get_int("test_image") == 0) {
- if (url.path().endsWith(".westley") || url.path().endsWith(".kdenlive")) {
- filePropertyMap["type"] = "playlist";
- metadataPropertyMap["comment"] = QString::fromUtf8(mlt_properties_get( MLT_SERVICE_PROPERTIES( producer.get_service() ), "title"));
- }
- else if (frame->get_int("test_audio") == 0)
- filePropertyMap["type"] = "av";
- else
- filePropertyMap["type"] = "video";
-
- // Generate thumbnail for this frame
- QPixmap pixmap = frameThumbnail(frame, width, height, true);
-
- emit replyGetImage(clipId, 0, pixmap, width, height);
-
- } else if (frame->get_int("test_audio") == 0) {
- QPixmap pixmap(KStandardDirs::locate("appdata", "graphics/music.png"));
- emit replyGetImage(clipId, 0, pixmap, width, height);
- filePropertyMap["type"] = "audio";
- }
- }
emit replyGetFileProperties(clipId, filePropertyMap, metadataPropertyMap);
kDebug()<<"REquested fuile info for: "<<url.path();
- delete frame;
+ if (frame) delete frame;
}
QDomDocument Render::sceneList() const
}*/
m_fps = m_mltProducer->get_fps();
- if (!m_mltConsumer) {
- restartConsumer();
- }
- emit playListDuration(m_mltProducer->get_playtime());
+
+ emit durationChanged(m_mltProducer->get_playtime());
//m_connectTimer->start( 500 );
connectPlaylist();
m_generateScenelist = false;
void Render::start()
{
kDebug()<<"----- STARTING MONITOR: "<<m_name;
- if (!m_mltConsumer || m_winid == -1) {
+ if (m_winid == -1) {
kDebug()<<"----- BROKEN MONITOR: "<<m_name<<", RESTART";
- restartConsumer();
return;
}
refresh();
}
}
- isBlocked = false;
+ m_isBlocked = false;
}
void Render::clear()
m_mltConsumer->stop();
}
kDebug()<<"///////////// RENDER STOP2-------";
- isBlocked = true;
+ m_isBlocked = true;
if (m_mltProducer) {
m_mltProducer->set_speed(0.0);
refreshTimer->start( 200 );
}
+void Render::doRefresh()
+{
+ // Use a Timer so that we don't refresh too much
+ refresh();
+}
+
void Render::refresh()
{
- if (!m_mltProducer)
+ if (!m_mltProducer || m_isBlocked)
return;
refreshTimer->stop();
if (m_mltConsumer) {
Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
duration = Mlt::Producer(trackPlaylist.get_producer()).get_playtime() - 1;
m_mltProducer->set("out", duration);
- emit durationChanged();
+ emit durationChanged(duration);
return;
}
while (trackNb > 1) {
blackTrackPlaylist.remove_region( 0, blackDuration );
int i = 0;
int dur = duration;
-
+ QDomDocument doc;
+ QDomElement black = doc.createElement("producer");
+ black.setAttribute("mlt_service", "colour");
+ black.setAttribute("colour", "black");
+ black.setAttribute("in", "0");
+ black.setAttribute("out", "13999");
while (dur > 14000) { // <producer mlt_service=\"colour\" colour=\"black\" in=\"0\" out=\"13999\" />
- mltInsertClip(0, GenTime(i * 14000, m_fps), QString("<westley><producer mlt_service=\"colour\" colour=\"black\" in=\"0\" out=\"13999\" /></westley>"));
+ mltInsertClip(0, GenTime(i * 14000, m_fps), black);
dur = dur - 14000;
i++;
}
-
- mltInsertClip(0, GenTime(), QString("<westley><producer mlt_service=\"colour\" colour=\"black\" in=\"0\" out=\"" + QString::number(dur) + "\" /></westley>"));
+ black.setAttribute("out", QString::number(dur));
+ mltInsertClip(0, GenTime(), black);
m_mltProducer->set("out", duration);
- emit durationChanged();
+ emit durationChanged(duration);
}
}
-void Render::mltInsertClip(int track, GenTime position, QString resource)
+void Render::mltInsertClip(int track, GenTime position, QDomElement element)
{
if (!m_mltProducer) {
kDebug()<<"PLAYLIST NOT INITIALISED //////";
kDebug()<<"PLAYLIST BROKEN, CANNOT INSERT CLIP //////";
return;
}
+ m_isBlocked = true;
Mlt::Service service(parentProd.get_service());
Mlt::Tractor tractor(service);
+ QDomDocument doc;
+ doc.appendChild(doc.importNode(element, true));
+ QString resource = doc.toString();
+ kDebug()<<"/////// ADDING CLIP TMLNE: "<<resource<<" ON TRACK: "<<track;
Mlt::Producer trackProducer(tractor.track(track));
Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
char *tmp = decodedString(resource);
tractor.multitrack()->refresh();
tractor.refresh();
if (track != 0) mltCheckLength();
- double duration = Mlt::Producer(trackPlaylist.get_producer()).get_playtime();
- kDebug()<<"// + +INSERTING CLIP: "<<resource<<" AT: "<<position.frames(m_fps)<<" on track: "<<track<<", DURATION: "<<duration;
-
-
+ m_isBlocked = false;
}
void Render::mltCutClip(int track, GenTime position)
{
+ m_isBlocked = true;
Mlt::Service service(m_mltProducer->parent().get_service());
- if (service.type() == playlist_type) kDebug()<<"// PLAYLIST TYPE";
- if (service.type() == tractor_type) kDebug()<<"// TRACOT TYPE";
- if (service.type() == multitrack_type) kDebug()<<"// MULTITRACK TYPE";
- if (service.type() == producer_type) kDebug()<<"// PROD TYPE";
-
Mlt::Tractor tractor(service);
Mlt::Producer trackProducer(tractor.track(track));
Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
trackPlaylist.split_at(position.frames(m_fps));
trackPlaylist.consolidate_blanks(0);
kDebug()<<"/ / / /CUTTING CLIP AT: "<<position.frames(m_fps);
+ m_isBlocked = false;
}
void Render::mltRemoveClip(int track, GenTime position)
{
+ m_isBlocked = true;
Mlt::Service service(m_mltProducer->parent().get_service());
- if (service.type() == playlist_type) kDebug()<<"// PLAYLIST TYPE";
- if (service.type() == tractor_type) kDebug()<<"// TRACOT TYPE";
- if (service.type() == multitrack_type) kDebug()<<"// MULTITRACK TYPE";
- if (service.type() == producer_type) kDebug()<<"// PROD TYPE";
-
Mlt::Tractor tractor(service);
Mlt::Producer trackProducer(tractor.track(track));
Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
trackPlaylist.consolidate_blanks(0);
if (track != 0) mltCheckLength();
//emit durationChanged();
+ m_isBlocked = false;
}
-void Render::mltRemoveEffect(int track, GenTime position, QString id, QString tag, int index)
+void Render::mltRemoveEffect(int track, GenTime position, QString index, bool doRefresh)
{
+
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Tractor tractor(service);
kDebug()<<" / / / CANNOT FIND CLIP TO REMOVE EFFECT";
return;
}
+ m_isBlocked = true;
Mlt::Service clipService(clip->get_service());
- if (tag.startsWith("ladspa")) tag = "ladspa";
+// if (tag.startsWith("ladspa")) tag = "ladspa";
- if (index == -1) {
- int ct = 0;
+ int ct = 0;
Mlt::Filter *filter = clipService.filter( ct );
while (filter) {
- if (filter->get("mlt_service") == tag && filter->get("kdenlive_id") == id) {
+ if (index == "-1" || filter->get("kdenlive_ix") == index) {// && filter->get("kdenlive_id") == id) {
clipService.detach(*filter);
kDebug()<<" / / / DLEETED EFFECT: "<<ct;
}
else ct++;
filter = clipService.filter( ct );
}
- }
- else {
- Mlt::Filter *filter = clipService.filter( index );
- if (filter && filter->get("mlt_service") == tag && filter->get("kdenlive_id") == id) clipService.detach(*filter);
- else {
- kDebug()<<"WARINIG, FILTER "<<id<<" NOT FOUND!!!!!";
- }
- }
- refresh();
+ m_isBlocked = false;
+ if (doRefresh) refresh();
}
-void Render::mltAddEffect(int track, GenTime position, QString id, QString tag, QMap <QString, QString> args)
+void Render::mltAddEffect(int track, GenTime position, QMap <QString, QString> args, bool doRefresh)
{
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Tractor tractor(service);
return;
}
Mlt::Service clipService(clip->get_service());
-
+ m_isBlocked = true;
// create filter
- kDebug()<<" / / INSERTING EFFECT: "<<id;
+ QString tag = args.value("tag");
+ //kDebug()<<" / / INSERTING EFFECT: "<<id;
if (tag.startsWith("ladspa")) tag = "ladspa";
char *filterId = decodedString(tag);
Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, filterId);
- filter->set("kdenlive_id", filterId);
+ if (filter && filter->is_valid())
+ filter->set("kdenlive_id", filterId);
+ else {
+ kDebug() << "filter is NULL";
+ return;
+ }
QMap<QString, QString>::Iterator it;
QString keyFrameNumber = "#0";
// attach filter to the clip
clipService.attach(*filter);
delete[] filterId;
- refresh();
+ m_isBlocked = false;
+ if (doRefresh) refresh();
}
-void Render::mltEditEffect(int track, GenTime position, int index, QString id, QString tag, QMap <QString, QString> args)
+void Render::mltEditEffect(int track, GenTime position, QMap <QString, QString> args)
{
+ QString index = args.value("kdenlive_ix");
+ QString tag = args.value("tag");
QMap<QString, QString>::Iterator it = args.begin();
if (it.key().startsWith("#") || tag.startsWith("ladspa") || tag == "sox" || tag == "autotrack_rectangle") {
// This is a keyframe effect, to edit it, we remove it and re-add it.
- mltRemoveEffect(track, position, id, tag, -1);
- mltAddEffect(track, position, id, tag, args);
+ mltRemoveEffect(track, position,index);
+ mltAddEffect(track, position, args);
return;
}
-
+ m_isBlocked = true;
// create filter
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
//int clipIndex = trackPlaylist.get_clip_index_at(position.frames(m_fps));
Mlt::Producer *clip = trackPlaylist.get_clip_at(position.frames(m_fps));
+ if (!clip) {
+ kDebug()<<"WARINIG, CANNOT FIND CLIP ON track: "<<track<<", AT POS: "<<position.frames(m_fps);
+ m_isBlocked = false;
+ return;
+ }
+
Mlt::Service clipService(clip->get_service());
- Mlt::Filter *filter = clipService.filter( index );
+// if (tag.startsWith("ladspa")) tag = "ladspa";
- if (!filter || filter->get("mlt_service") != tag) {
- kDebug()<<"WARINIG, FILTER NOT FOUND!!!!!";
- int index = 0;
- filter = clipService.filter( index );
- while (filter) {
- if (filter->get("mlt_service") == tag && filter->get("kdenlive_id") == id) break;
- index++;
- filter = clipService.filter( index );
+ int ct = 0;
+ Mlt::Filter *filter = clipService.filter( ct );
+ while (filter) {
+ if (filter->get("kdenlive_ix") == index) {
+ break;
}
+ ct++;
+ filter = clipService.filter( ct );
}
+
+
if (!filter) {
- kDebug()<<"WARINIG, FILTER "<<id<<" NOT FOUND!!!!!";
+ kDebug()<<"WARINIG, FILTER NOT FOUND!!!!!";
+ m_isBlocked = false;
return;
}
for ( it = args.begin(); it != args.end(); ++it ) {
- kDebug()<<" / / INSERTING EFFECT ARGS: "<<it.key()<<": "<<it.value();
+ kDebug()<<" / / EDITING EFFECT ARGS: "<<it.key()<<": "<<it.value();
char *name = decodedString(it.key());
char *value = decodedString(it.value());
filter->set(name, value);
delete[] name;
delete[] value;
}
+ m_isBlocked = false;
refresh();
}
void Render::mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out)
{
+ m_isBlocked = true;
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Tractor tractor(service);
tractor.multitrack()->refresh();
tractor.refresh();
if (track != 0) mltCheckLength();
-
+ m_isBlocked = false;
}
void Render::mltChangeTrackState(int track, bool mute, bool blind)
void Render::mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out)
{
+ m_isBlocked = true;
Mlt::Service service(m_mltProducer->parent().get_service());
- if (service.type() == playlist_type) kDebug()<<"// PLAYLIST TYPE";
- if (service.type() == tractor_type) kDebug()<<"// TRACOT TYPE";
- if (service.type() == multitrack_type) kDebug()<<"// MULTITRACK TYPE";
- if (service.type() == producer_type) kDebug()<<"// PROD TYPE";
-
int moveFrame = (moveEnd - moveStart).frames(m_fps);
Mlt::Tractor tractor(service);
else trackPlaylist.resize_clip(blankIndex, 0, blankLength + moveFrame -1);
}
trackPlaylist.consolidate_blanks(0);
-
+ m_isBlocked = false;
kDebug()<<"-----------------\n"<<"CLIP 0: "<<trackPlaylist.clip_start(0)<<", LENGT: "<<trackPlaylist.clip_length(0);
kDebug()<<"CLIP 1: "<<trackPlaylist.clip_start(1)<<", LENGT: "<<trackPlaylist.clip_length(1);
kDebug()<<"CLIP 2: "<<trackPlaylist.clip_start(2)<<", LENGT: "<<trackPlaylist.clip_length(2);
void Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEnd)
{
- m_mltConsumer->set("refresh", 0);
+ m_isBlocked = true;
+ //m_mltConsumer->set("refresh", 0);
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Tractor tractor(service);
Mlt::Producer trackProducer(tractor.track(startTrack));
Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
int clipIndex = trackPlaylist.get_clip_index_at(moveStart + 1);
-
-
mlt_field field = mlt_tractor_field(tractor.get_tractor());
-
mlt_multitrack multitrack = mlt_field_multitrack(field); //mlt_tractor_multitrack(tractor.get_tractor());
kDebug()<<" -- CURRENT MULTIOTRACK HAS: "<<mlt_multitrack_count(multitrack)<<" tracks";;
mlt_service multiprod = mlt_multitrack_service( multitrack );
Mlt::Producer clipProducer(trackPlaylist.replace_with_blank(clipIndex));
trackPlaylist.consolidate_blanks(0);
- mlt_events_block( MLT_PRODUCER_PROPERTIES(clipProducer.get_producer()), NULL );
+ mlt_events_block( MLT_PRODUCER_PROPERTIES(trackProducer.get_producer()), NULL );
if (endTrack == startTrack) {
if (!trackPlaylist.is_blank_at(moveEnd)) {
}
mltCheckLength();
- mlt_events_unblock( MLT_PRODUCER_PROPERTIES(clipProducer.get_producer()), NULL );
+ mlt_events_unblock( MLT_PRODUCER_PROPERTIES(trackProducer.get_producer()), NULL );
+ m_isBlocked = false;
+ m_mltConsumer->set("refresh", 1);
}
void Render::mltMoveTransition(QString type, int startTrack, int trackOffset, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut)
{
+ m_isBlocked = true;
m_mltConsumer->set("refresh", 0);
mlt_service serv = m_mltProducer->parent().get_service();
mlt_type = mlt_properties_get( properties, "mlt_type" );
resource = mlt_properties_get( properties, "mlt_service" );
}
+ m_isBlocked = false;
}
void Render::mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QMap <QString, QString> args)
{
+ m_isBlocked = true;
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Tractor tractor(service);
// attach filter to the clip
field->plant_transition(*transition, a_track, b_track);
delete[] transId;
+ m_isBlocked = false;
refresh();
}