]> git.sesse.net Git - kdenlive/commitdiff
Fix several problems with clip crop start, fix undo transition deletion, set monitor...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 15 Jul 2008 15:28:14 +0000 (15:28 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 15 Jul 2008 15:28:14 +0000 (15:28 +0000)
svn path=/branches/KDE4/; revision=2315

src/abstractclipitem.cpp
src/clipitem.cpp
src/clipitem.h
src/customtrackview.cpp
src/definitions.h
src/monitor.cpp
src/monitormanager.cpp
src/projectlist.cpp
src/renderer.cpp
src/renderer.h
src/trackview.cpp

index 7e48fd2e6122e1f3182161ebddcbebf2617cec96..9606825463a71c1367842f202be084891931faab 100644 (file)
@@ -39,6 +39,7 @@ ItemInfo AbstractClipItem::info() const {
     ItemInfo itemInfo;
     itemInfo.startPos = startPos();
     itemInfo.endPos = endPos();
+    itemInfo.cropStart = cropStart();
     itemInfo.track = track();
     return itemInfo;
 }
index 1db6e65d950655ccb979c170700958baab2e9024..ef46cbaebe92f8c1b9f071abecd134bdf9645d44 100644 (file)
@@ -39,7 +39,7 @@
 #include "kdenlivesettings.h"
 #include "kthumb.h"
 
-ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, GenTime cropStart, double scale, double fps)
+ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double scale, double fps)
         : AbstractClipItem(info, QRectF(), fps), m_clip(clip), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_hasThumbs(false), startThumbTimer(NULL), endThumbTimer(NULL), m_effectsCounter(1), audioThumbWasDrawn(false), m_opacity(1.0), m_timeLine(0), m_thumbsRequested(0), m_startFade(0), m_endFade(0), m_hover(false), m_selectedEffect(-1) {
     QRectF rect((double) info.startPos.frames(fps) * scale, (double)(info.track * KdenliveSettings::trackheight() + 1), (double)(info.endPos - info.startPos).frames(fps) * scale, (double)(KdenliveSettings::trackheight() - 1));
     setRect(rect);
@@ -47,7 +47,7 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, GenTime cropStart, double s
     m_clipName = clip->name();
     m_producer = clip->getId();
     m_clipType = clip->clipType();
-    m_cropStart = cropStart;
+    m_cropStart = info.cropStart;
     m_maxDuration = clip->maxDuration();
     setAcceptDrops(true);
     audioThumbReady = clip->audioThumbCreated();
@@ -98,7 +98,7 @@ ClipItem::~ClipItem() {
 }
 
 ClipItem *ClipItem::clone(double scale) const {
-    ClipItem *duplicate = new ClipItem(m_clip, info(), cropStart(), scale, m_fps);
+    ClipItem *duplicate = new ClipItem(m_clip, info(), scale, m_fps);
     duplicate->setEffectList(m_effectList);
     return duplicate;
 }
index 6e72adb44937b7d492ef8fd38c77ce112fdf9362..a52f7d12078e93fe15dd53769a869e56459af2b9 100644 (file)
@@ -38,7 +38,7 @@ class ClipItem : public AbstractClipItem {
     Q_OBJECT
 
 public:
-    ClipItem(DocClipBase *clip, ItemInfo info, GenTime cropStart, double scale, double fps);
+    ClipItem(DocClipBase *clip, ItemInfo info, double scale, double fps);
     virtual ~ ClipItem();
     virtual void paint(QPainter *painter,
                        const QStyleOptionGraphicsItem *option,
index ad998f1a564c3ece24649ec2921d781b7f81840b..778d80757f7057b78db63974d3dda7c3db9a833b 100644 (file)
@@ -813,9 +813,10 @@ void CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut) {
         ItemInfo newPos;
         newPos.startPos = cutTime;
         newPos.endPos = info.endPos;
+        newPos.cropStart = item->cropStart() + (cutTime - info.startPos);
         newPos.track = info.track;
         item->resizeEnd(cutPos, m_scale);
-        ClipItem *dup = new ClipItem(item->baseClip(), newPos, item->cropStart() + (cutTime - info.startPos), m_scale, m_document->fps());
+        ClipItem *dup = new ClipItem(item->baseClip(), newPos, m_scale, m_document->fps());
         scene()->addItem(dup);
         m_document->renderer()->mltCutClip(m_tracksList.count() - info.track, cutTime);
         item->baseClip()->addReference();
@@ -899,7 +900,7 @@ void CustomTrackView::addItem(DocClipBase *clip, QPoint pos) {
     info.endPos = info.startPos + clip->duration();
     info.track = (int)(pos.y() / m_tracksHeight);
     //kDebug()<<"------------  ADDING CLIP ITEM----: "<<info.startPos.frames(25)<<", "<<info.endPos.frames(25)<<", "<<info.track;
-    m_dropItem = new ClipItem(clip, info, GenTime(), m_scale, m_document->fps());
+    m_dropItem = new ClipItem(clip, info, m_scale, m_document->fps());
     scene()->addItem(m_dropItem);
 }
 
@@ -932,7 +933,7 @@ void CustomTrackView::dropEvent(QDropEvent * event) {
         m_dropItem->baseClip()->addReference();
         m_document->updateClip(m_dropItem->baseClip()->getId());
         // kDebug()<<"IIIIIIIIIIIIIIIIIIIIIIII TRAX CNT: "<<m_tracksList.count()<<", DROP: "<<m_dropItem->track();
-        m_document->renderer()->mltInsertClip(m_tracksList.count() - m_dropItem->track(), m_dropItem->startPos(), m_dropItem->xml());
+        m_document->renderer()->mltInsertClip(m_tracksList.count() - m_dropItem->track(), m_dropItem->startPos(), m_dropItem->cropStart(), m_dropItem->xml());
         m_document->setModified(true);
     } else QGraphicsView::dropEvent(event);
     m_dropItem = NULL;
@@ -1124,7 +1125,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) {
                     if (item->type() == AVWIDGET) {
                         ClipItem *clip = static_cast <ClipItem*>(item);
                         new AddTimelineClipCommand(this, clip->xml(), clip->clipProducer(), item->info(), false, false, moveClips);
-                        m_document->renderer()->mltInsertClip(m_tracksList.count() - item->track(), item->startPos(), clip->xml());
+                        m_document->renderer()->mltInsertClip(m_tracksList.count() - item->track(), item->startPos(), item->cropStart(), clip->xml());
                     } else {
                         Transition *tr = static_cast <Transition*>(item);
                         ItemInfo transitionInfo = tr->info();
@@ -1256,15 +1257,15 @@ void CustomTrackView::deleteSelectedClips() {
     deleteSelected->setText("Delete selected items");
     for (int i = 0; i < itemList.count(); i++) {
         if (itemList.at(i)->type() == AVWIDGET) {
-            ClipItem *item = (ClipItem *) itemList.at(i);
+            ClipItem *item = static_cast <ClipItem *> (itemList.at(i));
             new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), true, true, deleteSelected);
         } else if (itemList.at(i)->type() == TRANSITIONWIDGET) {
-            Transition *item = (Transition *) itemList.at(i);
+            Transition *item = static_cast <Transition *> (itemList.at(i));
             ItemInfo info;
             info.startPos = item->startPos();
             info.endPos = item->endPos();
             info.track = item->track();
-            new AddTransitionCommand(this, info, item->transitionEndTrack(), QDomElement(), true, true, deleteSelected);
+            new AddTransitionCommand(this, info, item->transitionEndTrack(), item->toXML(), true, true, deleteSelected);
         }
     }
     m_commandStack->push(deleteSelected);
@@ -1290,12 +1291,11 @@ void CustomTrackView::cutSelectedClips() {
 
 void CustomTrackView::addClip(QDomElement xml, int clipId, ItemInfo info) {
     DocClipBase *baseclip = m_document->clipManager()->getClipById(clipId);
-    int crop = xml.attribute("in").toInt();
-    ClipItem *item = new ClipItem(baseclip, info, GenTime(crop, m_document->fps()), m_scale, m_document->fps());
+    ClipItem *item = new ClipItem(baseclip, info, m_scale, m_document->fps());
     scene()->addItem(item);
     baseclip->addReference();
     m_document->updateClip(baseclip->getId());
-    m_document->renderer()->mltInsertClip(m_tracksList.count() - info.track, info.startPos, xml);
+    m_document->renderer()->mltInsertClip(m_tracksList.count() - info.track, info.startPos, info.cropStart, xml);
     m_document->renderer()->doRefresh();
 }
 
@@ -1307,7 +1307,7 @@ void CustomTrackView::slotUpdateClip(int clipId) {
             clip = static_cast <ClipItem *>(list.at(i));
             if (clip->clipProducer() == clipId) {
                 clip->refreshClip();
-                m_document->renderer()->mltUpdateClip(m_tracksList.count() - clip->track(), clip->startPos(), clip->xml());
+                m_document->renderer()->mltUpdateClip(m_tracksList.count() - clip->track(), clip->startPos(), clip->cropStart(), clip->xml());
             }
         }
     }
@@ -2029,6 +2029,7 @@ void CustomTrackView::pasteClip() {
             ItemInfo info;
             info.startPos = clip->startPos() + offset;
             info.endPos = clip->endPos() + offset;
+            info.cropStart = clip->cropStart();
             info.track = clip->track() + trackOffset;
             if (canBePastedTo(info, AVWIDGET)) {
                 new AddTimelineClipCommand(this, clip->xml(), clip->clipProducer(), info, true, false, pasteClips);
index d0aa354c51146e24d0fa12e5006dff70fa742574..615186010d69d91f82419dc3f2839045a7b57a0d 100644 (file)
@@ -61,6 +61,7 @@ struct TrackInfo {
 struct ItemInfo {
     GenTime startPos;
     GenTime endPos;
+    GenTime cropStart;
     int track;
 };
 
index 6de66890000fb1f6f1606752c43aef6640023c07..e03be8a57ea281a1cbdd7aeb7d46720f4f7204f0 100644 (file)
@@ -43,7 +43,7 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent)
     QVBoxLayout *layout = new QVBoxLayout;
     layout->addWidget(m_ruler);
     ui.ruler_frame->setLayout(layout);
-
+    setMinimumHeight(200);
     QToolBar *toolbar = new QToolBar(name, this);
     QVBoxLayout *layout2 = new QVBoxLayout;
 
@@ -283,7 +283,7 @@ void Monitor::start() {
 void Monitor::refreshMonitor(bool visible) {
     if (visible && render) {
         if (!m_isActive) m_monitorManager->activateMonitor(m_name);
-        render->askForRefresh();
+        render->doRefresh(); //askForRefresh();
     }
 }
 
index 35c48917c9ac81ba77a94b2f9b889441f1695b9c..a8045c1d0543acbe0b217969b4f20e978923d072 100644 (file)
@@ -112,8 +112,11 @@ void MonitorManager::slotEnd() {
 }
 
 void MonitorManager::resetProfiles(QString prof) {
+    activateMonitor("clip");
     m_clipMonitor->resetProfile(prof);
+    activateMonitor("project");
     m_projectMonitor->resetProfile(prof);
+    //m_projectMonitor->refreshMonitor(true);
 }
 
 #include "monitormanager.moc"
index 8ac3babf0c62b0c6d4a0e09278411dc598df09cd..899b41f3dcae9acf1e15b103b5b1c26493f77784 100644 (file)
@@ -311,7 +311,7 @@ void ProjectList::slotAddClip(QUrl givenUrl, QString group) {
     if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!!  NO CMD STK";
     KUrl::List list;
     if (givenUrl.isEmpty())
-        list = KFileDialog::getOpenUrls(KUrl(), "application/vnd.kde.kdenlive application/vnd.westley.scenelist application/flv application/vnd.rn-realmedia video/x-dv video/x-msvideo video/mpeg video/x-ms-wmv audio/mpeg audio/x-mp3 audio/x-wav application/ogg *.m2t *.dv video/mp4 video/quicktime image/gif image/jpeg image/png image/x-bmp image/svg+xml image/tiff image/x-xcf-gimp image/x-vnd.adobe.photoshop image/x-pcx image/x-exr");
+        list = KFileDialog::getOpenUrls(KUrl(), "application/vnd.kde.kdenlive application/vnd.westley.scenelist application/flv application/vnd.rn-realmedia video/x-dv video/x-msvideo video/mpeg video/x-ms-wmv audio/mpeg audio/x-mp3 audio/x-wav application/ogg *.m2t *.mts *.dv video/mp4 video/quicktime image/gif image/jpeg image/png image/x-bmp image/svg+xml image/tiff image/x-xcf-gimp image/x-vnd.adobe.photoshop image/x-pcx image/x-exr");
     else list.append(givenUrl);
     if (list.isEmpty()) return;
     KUrl::List::Iterator it;
index 31e0e0603a0ea87b7b2df09fb9e01c1a3260fdd6..533b31dd51978a2687879881952ed4c80560ee95 100644 (file)
@@ -9,7 +9,7 @@
   copyright            : (C) Marco Gittler
   email                : g.marco@freenet.de
   copyright            : (C) 2006 Jean-Baptiste Mardelle
-  email                : jb@ader.ch
+  email                : jb@kdenlive.org
 
 ***************************************************************************/
 
@@ -67,9 +67,6 @@ Render::Render(const QString & rendererName, int winid, int extid, QWidget *pare
     refreshTimer = new QTimer(this);
     connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
 
-    m_connectTimer = new QTimer(this);
-    connect(m_connectTimer, SIGNAL(timeout()), this, SLOT(connectPlaylist()));
-
     if (rendererName == "project") m_monitorId = 10000;
     else m_monitorId = 10001;
     osdTimer = new QTimer(this);
@@ -118,7 +115,6 @@ Render::~Render() {
 
 
 void Render::closeMlt() {
-    delete m_connectTimer;
     delete osdTimer;
     delete refreshTimer;
     if (m_mltConsumer)
@@ -131,11 +127,13 @@ void Render::closeMlt() {
 
 
 int Render::resetProfile(QString profile) {
+
+
     if (!m_mltConsumer) return 0;
     if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
-    m_mltConsumer->set("refresh", 0);
     m_mltConsumer->purge();
     delete m_mltConsumer;
+
     m_mltConsumer = NULL;
     QString scene = sceneList();
     if (m_mltProducer) delete m_mltProducer;
@@ -156,12 +154,15 @@ int Render::resetProfile(QString profile) {
     m_mltConsumer->set("audio_buffer", 1024);
     m_mltConsumer->set("frequency", 48000);
 
+    kDebug() << "//RESET WITHSCENE: " << scene;
+    setSceneList(scene);
+
     tmp = decodedString(scene);
     Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "westley-xml", tmp);
     delete[] tmp;
     m_mltProducer = producer;
-    m_mltConsumer->connect(*m_mltProducer);
-    m_mltProducer->set_speed(0.0);
+    m_mltProducer->set_speed(0);
+    connectPlaylist();
 
     //delete m_mltProfile;
     // mlt_properties properties = MLT_CONSUMER_PROPERTIES(m_mltConsumer->get_consumer());
@@ -380,32 +381,41 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) {
     QMap < QString, QString > filePropertyMap;
     QMap < QString, QString > metadataPropertyMap;
 
-    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());
-    Mlt::Producer producer(*m_mltProfile, "westley-xml", tmp);
-    delete[] tmp;
+    KUrl url = KUrl(xml.attribute("resource", QString::null));
+
+    Mlt::Producer *producer;
 
-    if (producer.is_blank()) {
-        kDebug() << " / / / / / / / /ERRROR / / / / // CANNOT LOAD PRODUCER: " << doc.toString();
+    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));
+        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;
     }
 
     int frameNumber = xml.attribute("thumbnail", "0").toInt();
-    if (frameNumber != 0) producer.seek(frameNumber);
-    mlt_properties properties = MLT_PRODUCER_PROPERTIES(producer.get_producer());
+    if (frameNumber != 0) producer->seek(frameNumber);
+    mlt_properties properties = MLT_PRODUCER_PROPERTIES(producer->get_producer());
 
-    KUrl url = xml.attribute("resource", QString::null);
     filePropertyMap["filename"] = url.path();
-    filePropertyMap["duration"] = QString::number(producer.get_playtime());
+    filePropertyMap["duration"] = QString::number(producer->get_playtime());
     //kDebug() << "///////  PRODUCER: " << url.path() << " IS: " << producer.get_playtime();
 
-    Mlt::Frame * frame = producer.get_frame();
-    filePropertyMap["fps"] = producer.get("source_fps");
+    Mlt::Frame * frame = producer->get_frame();
+    filePropertyMap["fps"] = producer->get("source_fps");
 
     if (frame && frame->is_valid()) {
         filePropertyMap["frame_size"] = QString::number(frame->get_int("width")) + "x" + QString::number(frame->get_int("height"));
@@ -416,7 +426,7 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) {
         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"));
+                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
@@ -454,10 +464,12 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) {
 
     // Fetch the video_context
 #if 1
+
     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");
+
 #if ENABLE_FFMPEG_CODEC_DESCRIPTION
         if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->long_name) {
             filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->long_name;
@@ -469,7 +481,7 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) {
     } else kDebug() << " / / / / /WARNING, VIDEO CONTEXT IS NULL!!!!!!!!!!!!!!";
     context = (AVFormatContext *) mlt_properties_get_data(properties, "audio_context", NULL);
     if (context != NULL) {
-        // Get the video_index
+        // Get the audio_index
         int index = mlt_properties_get_int(properties, "audio_index");
 
 #if ENABLE_FFMPEG_CODEC_DESCRIPTION
@@ -496,6 +508,7 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) {
     emit replyGetFileProperties(clipId, filePropertyMap, metadataPropertyMap);
     kDebug() << "REquested fuile info for: " << url.path();
     if (frame) delete frame;
+    if (producer) delete producer;
 }
 
 /** Create the producer from the Westley QDomDocument */
@@ -556,10 +569,11 @@ void Render::setSceneList(QString playlist, int position) {
 
     if (m_mltConsumer) {
         m_mltConsumer->stop();
-        m_mltConsumer->set("refresh", 0);
+        //m_mltConsumer->set("refresh", 0);
     } else return;
+
     if (m_mltProducer) {
-        m_mltProducer->set_speed(0.0);
+        m_mltProducer->set_speed(0);
         //if (KdenliveSettings::osdtimecode() && m_osdInfo) m_mltProducer->detach(*m_osdInfo);
 
         delete m_mltProducer;
@@ -598,8 +612,6 @@ void Render::setSceneList(QString playlist, int position) {
 
     m_fps = m_mltProducer->get_fps();
     kDebug() << "// NEW SCENE LIST DURATION SET TO: " << m_mltProducer->get_playtime();
-    emit durationChanged(m_mltProducer->get_playtime());
-    //m_connectTimer->start( 1000 );
     connectPlaylist();
     if (position != 0) {
         m_mltProducer->seek(position);
@@ -666,12 +678,12 @@ const double Render::fps() const {
 
 void Render::connectPlaylist() {
     if (!m_mltConsumer) return;
-    m_connectTimer->stop();
-    m_mltConsumer->set("refresh", "0");
+    //m_mltConsumer->set("refresh", "0");
     m_mltConsumer->connect(*m_mltProducer);
-    m_mltProducer->set_speed(0.0);
+    m_mltProducer->set_speed(0);
     m_mltConsumer->start();
-    refresh();
+    emit durationChanged(m_mltProducer->get_playtime());
+    //refresh();
     /*
      if (m_mltConsumer->start() == -1) {
           KMessageBox::error(qApp->activeWindow(), i18n("Could not create the video preview window.\nThere is something wrong with your Kdenlive install or your driver settings, please fix it."));
@@ -685,7 +697,7 @@ void Render::connectPlaylist() {
 void Render::refreshDisplay() {
 
     if (!m_mltProducer) return;
-    m_mltConsumer->set("refresh", 0);
+    //m_mltConsumer->set("refresh", 0);
 
     mlt_properties properties = MLT_PRODUCER_PROPERTIES(m_mltProducer->get_producer());
     /*if (KdenliveSettings::osdtimecode()) {
@@ -751,8 +763,9 @@ void Render::start() {
 }
 
 void Render::clear() {
+    kDebug() << " *********  RENDER CLEAR";
     if (m_mltConsumer) {
-        m_mltConsumer->set("refresh", 0);
+        //m_mltConsumer->set("refresh", 0);
         if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
     }
 
@@ -768,7 +781,7 @@ void Render::clear() {
 void Render::stop() {
     if (m_mltConsumer && !m_mltConsumer->is_stopped()) {
         kDebug() << "/////////////   RENDER STOPPED: " << m_name;
-        m_mltConsumer->set("refresh", 0);
+        //m_mltConsumer->set("refresh", 0);
         m_mltConsumer->stop();
     }
     kDebug() << "/////////////   RENDER STOP2-------";
@@ -783,6 +796,7 @@ void Render::stop() {
 }
 
 void Render::stop(const GenTime & startTime) {
+
     kDebug() << "/////////////   RENDER STOP-------2";
     if (m_mltProducer) {
         m_mltProducer->set_speed(0.0);
@@ -794,22 +808,34 @@ void Render::stop(const GenTime & startTime) {
 void Render::switchPlay() {
     if (!m_mltProducer)
         return;
-    if (m_mltProducer->get_speed() == 0.0) m_mltProducer->set_speed(1.0);
-    else {
-        m_isBlocked = true;
+    if (m_mltProducer->get_speed() == 0.0) {
+        m_isBlocked = false;
+        m_mltProducer->set_speed(1.0);
+        m_mltConsumer->set("refresh", 1);
+        kDebug() << " *********  RENDER PLAY: " << m_mltProducer->get_speed();
+    } else {
+        //m_isBlocked = true;
+        m_mltConsumer->set("refresh", 0);
         m_mltProducer->set_speed(0.0);
-        //m_mltConsumer->set("refresh", 0);
+        m_isBlocked = true;
         m_mltProducer->seek((int) m_framePosition);
-        m_isBlocked = false;
+        //kDebug()<<" *********  RENDER PAUSE: "<<m_mltProducer->get_speed();
+        //m_mltConsumer->set("refresh", 0);
+        /*mlt_position position = mlt_producer_position( m_mltProducer->get_producer() );
+        m_mltProducer->set_speed(0);
+        m_mltProducer->seek( position );
+               //m_mltProducer->seek((int) m_framePosition);
+               m_isBlocked = false;*/
     }
     /*if (speed == 0.0) {
     m_mltProducer->seek((int) m_framePosition + 1);
         m_mltConsumer->purge();
     }*/
-    refresh();
+    //refresh();
 }
 
 void Render::play(double speed) {
+    kDebug() << " *********  REDNER PLAY";
     if (!m_mltProducer)
         return;
     // if (speed == 0.0) m_mltProducer->set("out", m_mltProducer->get_length() - 1);
@@ -847,14 +873,17 @@ void Render::play(double speed, const GenTime & startTime,
 
 
 void Render::sendSeekCommand(GenTime time) {
+    //kDebug()<<" *********  RENDER SEND SEEK";
     if (!m_mltProducer)
         return;
     //kDebug()<<"//////////  KDENLIVE SEEK: "<<(int) (time.frames(m_fps));
     m_mltProducer->seek((int)(time.frames(m_fps)));
+    m_mltConsumer->set("refresh", 1);
     refresh();
 }
 
 void Render::seekToFrame(int pos) {
+    //kDebug()<<" *********  RENDER SEEK TO POS";
     if (!m_mltProducer)
         return;
     //kDebug()<<"//////////  KDENLIVE SEEK: "<<(int) (time.frames(m_fps));
@@ -869,7 +898,7 @@ void Render::askForRefresh() {
 
 void Render::doRefresh() {
     // Use a Timer so that we don't refresh too much
-    refresh();
+    m_mltConsumer->set("refresh", 1);
 }
 
 void Render::refresh() {
@@ -1003,20 +1032,20 @@ void Render::mltCheckLength(bool reload) {
         black.setAttribute("in", "0");
         black.setAttribute("out", "13999");
         while (dur > 14000) {
-            mltInsertClip(0, GenTime(i * 14000, m_fps), black);
+            mltInsertClip(0, GenTime(i * 14000, m_fps), GenTime(), black);
             dur = dur - 14000;
             i++;
         }
         if (dur > 0) {
             black.setAttribute("out", QString::number(dur));
-            mltInsertClip(0, GenTime(i * 14000, m_fps), black);
+            mltInsertClip(0, GenTime(i * 14000, m_fps), GenTime(), black);
         }
         m_mltProducer->set("out", duration);
         emit durationChanged((int)duration);
     }
 }
 
-void Render::mltInsertClip(int track, GenTime position, QDomElement element) {
+void Render::mltInsertClip(int track, GenTime position, GenTime crop, QDomElement element) {
     if (!m_mltProducer) {
         kDebug() << "PLAYLIST NOT INITIALISED //////";
         return;
@@ -1038,6 +1067,7 @@ void Render::mltInsertClip(int track, GenTime position, QDomElement element) {
     QString resource = doc.toString();
     char *tmp = decodedString(resource);
     Mlt::Producer clip(*m_mltProfile, "westley-xml", tmp);
+    clip.set("in", crop.frames(m_fps));
     //clip.set_in_and_out(in.frames(m_fps), out.frames(m_fps));
     delete[] tmp;
     trackPlaylist.insert_at((int) position.frames(m_fps), clip, 1);
@@ -1061,10 +1091,10 @@ void Render::mltCutClip(int track, GenTime position) {
     m_isBlocked = false;
 }
 
-void Render::mltUpdateClip(int track, GenTime position, QDomElement element) {
+void Render::mltUpdateClip(int track, GenTime position, GenTime crop, QDomElement element) {
     // TODO: optimize
     mltRemoveClip(track, position);
-    mltInsertClip(track, position, element);
+    mltInsertClip(track, position, crop, element);
 }
 
 
@@ -1555,7 +1585,7 @@ void Render::mltUpdateTransitionParams(QString type, int a_track, int b_track, G
     Mlt::Tractor tractor(service);
     Mlt::Field *field = tractor.field();
 
-    m_mltConsumer->set("refresh", 0);
+    //m_mltConsumer->set("refresh", 0);
     mlt_service serv = m_mltProducer->parent().get_service();
 
     mlt_service nextservice = mlt_service_get_producer(serv);
index b60981ed081a4b7c93567b8d17a432aeb40bf5eb..979ab46a4977a8aef433c8a4b92133690246bad6 100644 (file)
@@ -149,8 +149,8 @@ Q_OBJECT public:
     const double dar() const;
 
     /** Playlist manipulation */
-    void mltInsertClip(int track, GenTime position, QDomElement element);
-    void mltUpdateClip(int track, GenTime position, QDomElement element);
+    void mltInsertClip(int track, GenTime position, GenTime crop, QDomElement element);
+    void mltUpdateClip(int track, GenTime position, GenTime crop, QDomElement element);
     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);
@@ -187,7 +187,6 @@ private:   // Private attributes & methods
 
     QTimer *refreshTimer;
     QTimer *osdTimer;
-    QTimer *m_connectTimer;
     KUrl m_exportedFile;
     int exportDuration, firstExportFrame, lastExportFrame;
 
index 67d5ec089d219fb14ebb0808dfbd767ea80b7e29..32c52b0fb3ef0bd06ba48cb30866c9345f3d1838 100644 (file)
@@ -343,9 +343,10 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool videotrack) {
                 ItemInfo clipinfo;
                 clipinfo.startPos = GenTime(position, m_doc->fps());
                 clipinfo.endPos = clipinfo.startPos + GenTime(out - in, m_doc->fps());
+               clipinfo.cropStart = GenTime(in, m_doc->fps());
                 clipinfo.track = ix;
                 //kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
-                ClipItem *item = new ClipItem(clip, clipinfo, GenTime(in, m_doc->fps()), m_scale, m_doc->fps());
+                ClipItem *item = new ClipItem(clip, clipinfo, m_scale, m_doc->fps());
                 m_scene->addItem(item);
                 clip->addReference();
                 position += (out - in);