#include <mlt++/Mlt.h>
#include "clipitem.h"
+#include "customtrackview.h"
#include "renderer.h"
#include "events.h"
#include "kdenlivesettings.h"
else if (m_clipType == IMAGE) {
m_startPix = KThumb::getImage(KUrl(m_xml.attribute("resource")), 50 * KdenliveSettings::project_display_ratio(), 50);
}
+ else if (m_clipType == AUDIO) {
+ connect(clip, SIGNAL (gotAudioData()), this, SLOT (slotGotAudioData()));
+ }
}
QDomDocument doc;
doc.setContent(effects, true);
QDomElement e = doc.documentElement();
- if (QApplication::activeWindow())
- QApplication::postEvent(QApplication::activeWindow(), new EffectEvent(GenTime(m_startPos, 25), m_track, e, (QEvent::Type)10010));
+ CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
+ if (view) view->slotAddEffect(e, GenTime(m_startPos, 25), m_track);
}
//virtual
void ClipItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
- kDebug()<<"DRAG EVNET, FORMAT: "<<event->mimeData()->formats();
event->setAccepted(event->mimeData()->hasFormat("kdenlive/effectslist"));
}
#include "addclipcommand.h"
#include "kdenlivesettings.h"
#include "clipmanager.h"
-
+#include "docclipbase.h"
ClipManager::ClipManager(KdenliveDoc *doc):m_doc(doc)
{
{
}
+void ClipManager::setThumbsProgress(KUrl url, int progress)
+{
+ m_doc->setThumbsProgress(url, progress);
+}
+
+
void ClipManager::addClip(DocClipBase *clip)
{
m_clipList.append(clip);
#include "gentime.h"
#include "definitions.h"
-#include "docclipbase.h"
-class KdenliveDoc;
+class KdenliveDoc;
+class DocClipBase;
class ClipManager:public QObject {
Q_OBJECT public:
void slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group);
DocClipBase *getClipById(int clipId);
void slotDeleteClip(uint clipId);
+ void setThumbsProgress(KUrl url, int progress);
private: // Private attributes
/** the list of clips in the document */
#include "kdenlivesettings.h"
#include "docclipbase.h"
-DocClipBase::DocClipBase(QDomElement xml, uint id):
+DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, uint id):
m_xml(xml), m_id(id), m_description(""), m_refcount(0), m_projectThumbFrame(0), m_audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL)
{
int type = xml.attribute("type").toInt();
if (out != 0) setDuration(GenTime(out, 25));
if (m_name.isEmpty()) m_name = url.fileName();
if (!url.isEmpty()){
- m_thumbProd = new KThumb(url, KdenliveSettings::track_height() * KdenliveSettings::project_display_ratio(), KdenliveSettings::track_height());
+ m_thumbProd = new KThumb(clipManager, url, KdenliveSettings::track_height() * KdenliveSettings::project_display_ratio(), KdenliveSettings::track_height());
connect (m_thumbProd, SIGNAL (audioThumbReady(QMap <int, QMap <int, QByteArray> >)), this , SLOT(updateAudioThumbnail(QMap <int, QMap <int, QByteArray> > )));
connect (this, SIGNAL (getAudioThumbs()), this , SLOT( slotGetAudioThumbs() ) );
if (m_clipType == AV || m_clipType==AUDIO || m_clipType==UNKNOWN){
m_audioTimer = new QTimer( this );
connect(m_audioTimer, SIGNAL(timeout()), this, SLOT(slotGetAudioThumbs()));
- //TODO disabled until the crash cause is found
- emit getAudioThumbs();
}
}
+
+
DocClipBase::DocClipBase(const DocClipBase& clip)
{
m_xml = clip.toXML();
//if (m_thumbProd) delete m_thumbProd;
}
+void DocClipBase::slotRequestAudioThumbs()
+{
+ emit getAudioThumbs();
+}
+
KThumb *DocClipBase::thumbProducer()
{
return m_thumbProd;
void DocClipBase::updateAudioThumbnail(QMap<int,QMap<int,QByteArray> > data)
{
+ kDebug()<<"CLIPBASE RECIEDVED AUDIO DATA*********************************************";
audioFrameChache = data;
m_audioThumbCreated = true;
emit gotAudioData();
}
}
+
+
#include <klocale.h>
#include "gentime.h"
+#include "clipmanager.h"
#include "definitions.h"
#include "kthumb.h"
* done here. If a new clip type is added then it should be possible to combine it with both audio
* and video. */
- DocClipBase(QDomElement xml, uint id);
+ DocClipBase(ClipManager *clipManager, QDomElement xml, uint id);
DocClipBase(const DocClipBase& clip);
DocClipBase & operator=(const DocClipBase & clip);
virtual ~ DocClipBase();
/** return english name for clip type */
static QString getTypeName(CLIPTYPE type);
+ /** Clip is ready to get thumbs */
+ void slotRequestAudioThumbs();
+
+
private: // Private attributes
/** The name of this clip */
QString m_name;
QString markerComment(GenTime t);
void setProjectThumbFrame( const uint &ix);
uint getProjectThumbFrame() const;
- signals:
- void getAudioThumbs();
+
+ signals:
+ void getAudioThumbs();
void gotAudioData();
};
};
-class EffectEvent : public QEvent {
-public:
- EffectEvent( GenTime pos, int track, QDomElement xml, QEvent::Type eventType )
- : QEvent( eventType ), m_pos( pos ), m_track(track), m_xml(xml) {
- if (xml.isNull()) kDebug()<<"--- ERROR, TRYING TO APPEND NULL EFFECT EVENT";
- if (m_xml.isNull()) kDebug()<<"--- ERROR, TRYING TO APPEND NULL EFFECT EVENT 2";
- };
- GenTime pos() const { return m_pos; };
- int track() const { return m_track; };
- QDomElement xml() const { return m_xml; };
-private:
- GenTime m_pos;
- int m_track;
- QDomElement m_xml;
-
-};
-
#endif
#include "kdenlivedoc.h"
+#include "docclipbase.h"
KdenliveDoc::KdenliveDoc(const KUrl &url, double fps, int width, int height, QWidget *parent):QObject(parent), m_render(NULL), m_url(url), m_fps(fps), m_width(width), m_height(height), m_projectName(NULL), m_commandStack(new KUndoStack())
{
return m_clipManager;
}
+void KdenliveDoc::setThumbsProgress(KUrl url, int progress)
+{
+ emit thumbsProgress(url, progress);
+}
+
KUndoStack *KdenliveDoc::commandStack()
{
return m_commandStack;
void KdenliveDoc::addClip(const QDomElement &elem, const int clipId)
{
kDebug()<<"///////// DOCUM, CREATING NEW CLIP, ID:"<<clipId;
- DocClipBase *clip = new DocClipBase(elem, clipId);
+ DocClipBase *clip = new DocClipBase(m_clipManager, elem, clipId);
m_clipManager->addClip(clip);
emit addProjectClip(clip);
}
DocClipBase *getBaseClip(int clipId);
void updateClip(int id);
void deleteProjectClip(const uint clipId);
+ /** Inform application of the audio thumbnails generation progress */
+ void setThumbsProgress(KUrl url, int progress);
private:
KUrl m_url;
void signalDeleteProjectClip(int);
void updateClipDisplay(int);
void deletTimelineClip(int);
+ void thumbsProgress(KUrl, int);
};
#endif
#include <QApplication>
#include <QCryptographicHash>
-
+#include "clipmanager.h"
#include "renderer.h"
#include "kthumb.h"
#include "kdenlivesettings.h"
#include "events.h"
-void MyThread::init(KUrl url, QString target, double frame, double frameLength, int frequency, int channels, int arrayWidth)
+
+void MyThread::init(QObject *parent, KUrl url, QString target, double frame, double frameLength, int frequency, int channels, int arrayWidth)
{
stop_me = false;
+ m_parent = parent;
m_isWorking = false;
f.setFileName(target);
m_url = url;
m_frequency = frequency;
m_channels = channels;
m_arrayWidth = arrayWidth;
-
}
bool MyThread::isWorking()
return;
}
m_isWorking = true;
- Mlt::Profile prof((char*) KdenliveSettings::current_profile().data());
- Mlt::Producer m_producer(prof, m_url.path().toAscii().data());
+ Mlt::Profile prof((char*) qstrdup(KdenliveSettings::current_profile().toUtf8()));
+ Mlt::Producer m_producer(prof, m_url.path().toUtf8().data());
/*TODO if (KdenliveSettings::normaliseaudiothumbs()) {
m_producer.attach(m_convert);
}*/
- if (QApplication::activeWindow())
- QApplication::postEvent(QApplication::activeWindow(), new ProgressEvent(-1, (QEvent::Type)10005));
+ //QApplication::postEvent(m_parent, new ProgressEvent(-1, (QEvent::Type)10005));
int last_val = 0;
int val = 0;
if (stop_me) break;
val=(int)((z-m_frame)/(m_frame+m_frameLength)*100.0);
if (last_val!=val & val > 1){
- QApplication::postEvent(QApplication::activeWindow(), new ProgressEvent(val, (QEvent::Type)10005));
+ QApplication::postEvent(m_parent, new ProgressEvent(val, (QEvent::Type)10005));
last_val=val;
}
m_producer.seek( z );
Mlt::Frame *mlt_frame = m_producer.get_frame();
- if ( mlt_frame->is_valid() )
+ if ( mlt_frame && mlt_frame->is_valid() )
{
double m_framesPerSecond = mlt_producer_get_fps( m_producer.get_producer() ); //mlt_frame->get_double( "fps" );
int m_samples = mlt_sample_calculator( m_framesPerSecond, m_frequency, mlt_frame_get_position(mlt_frame->get_frame()) );
m_isWorking = false;
if (stop_me) {
f.remove();
- QApplication::postEvent(QApplication::activeWindow(), new ProgressEvent(-1, (QEvent::Type)10005));
+ QApplication::postEvent(m_parent, new ProgressEvent(-1, (QEvent::Type)10005));
}
- QApplication::postEvent(QApplication::activeWindow(), new ProgressEvent(0, (QEvent::Type)10005));
+ QApplication::postEvent(m_parent, new ProgressEvent(0, (QEvent::Type)10005));
}
#define _G(y,u,v) (0x2568*(y) - 0x0c92*(v) - 0x1a1e*(u)) /0x2000
#define _B(y,u,v) (0x2568*(y) + 0x40cf*(v)) /0x2000
-KThumb::KThumb(KUrl url, int width, int height, QObject * parent, const char *name):QObject(parent), m_url(url), m_width(width), m_height(height)
+KThumb::KThumb(ClipManager *clipManager, KUrl url, int width, int height, QObject * parent, const char *name):QObject(parent), m_clipManager(clipManager), m_url(url), m_width(width), m_height(height)
{
- kDebug()<<"+++++++++++ CREATING THMB PROD FOR: "<<url;
- m_profile = new Mlt::Profile((char*) qstrdup(KdenliveSettings::current_profile().toUtf8()));
+
+ m_profile = new Mlt::Profile((char*) KdenliveSettings::current_profile().data());
QCryptographicHash context(QCryptographicHash::Sha1);
context.addData((KFileItem(m_url,"text/plain", S_IFREG).timeString() + m_url.fileName()).toAscii().data());
m_thumbFile = KdenliveSettings::currenttmpfolder() + context.result().toHex() + ".thumb";
void KThumb::getAudioThumbs(int channel, double frame, double frameLength, int arrayWidth){
- if ((thumbProducer.isRunning () && thumbProducer.isWorking()) || channel == 0) {
+ if ((thumbProducer.isRunning() && thumbProducer.isWorking()) || channel == 0) {
return;
}
}
else {
if (thumbProducer.isRunning()) return;
- thumbProducer.init(m_url, m_thumbFile, frame, frameLength, m_frequency, m_channels, arrayWidth);
+ thumbProducer.init(this, m_url, m_thumbFile, frame, frameLength, m_frequency, m_channels, arrayWidth);
thumbProducer.start(QThread::LowestPriority );
+ kDebug() << "STARTING GENERATE THMB FOR: "<<m_url<<" ................................";
}
}
+void KThumb::customEvent ( QEvent * event ){
+ if (event->type()==10005){
+ ProgressEvent* p=(ProgressEvent*) event;
+ m_clipManager->setThumbsProgress(m_url, p->value());
+ }
+}
+
+
+#include "kthumb.moc"
#include <mlt++/Mlt.h>
+
/**KRender encapsulates the client side of the interface to a renderer.
From Kdenlive's point of view, you treat the KRender object as the
renderer, and simply use it as if it was local. Calls are asyncrhonous -
class Profile;
};
+class ClipManager;
class MyThread : public QThread {
public:
virtual void run();
- void init(KUrl url, QString target, double frame, double frameLength, int frequency, int channels, int arrayWidth);
+ void init(QObject *parent, KUrl url, QString target, double frame, double frameLength, int frequency, int channels, int arrayWidth);
bool isWorking();
bool stop_me;
int m_channels;
int m_arrayWidth;
bool m_isWorking;
+ QObject *m_parent;
};
Q_OBJECT public:
- KThumb(KUrl url, int width, int height, QObject * parent = 0, const char *name = 0);
+ KThumb(ClipManager *clipManager, KUrl url, int width, int height, QObject * parent = 0, const char *name = 0);
~KThumb();
public slots:
void removeAudioThumb();
void getAudioThumbs(int channel, double frame, double frameLength, int arrayWidth);
+protected:
+ virtual void customEvent ( QEvent * event );
+
private:
MyThread thumbProducer;
KUrl m_url;
int m_width;
int m_height;
Mlt::Profile *m_profile;
+ ClipManager *m_clipManager;
signals:
void thumbReady(int frame, QPixmap pm);
connect(doc, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
connect(doc, SIGNAL(deletTimelineClip(int)), trackView, SLOT(slotDeleteClip(int)));
+ connect(doc, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int)));
+
connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
//connect( dialog, SIGNAL(settingsChanged()), this, SLOT(updateConfiguration()) );
dialog->show();
}
-void MainWindow::customEvent ( QEvent * event ){
- if (event->type()==10005){
- ProgressEvent* p=(ProgressEvent*) event;
- statusProgressBar->setValue(p->value());
- if (p->value()>0) {
- statusLabel->setText(tr("Creating Audio Thumbs"));
- statusProgressBar->setVisible(true);
- }
- else {
- statusLabel->setText("");
- statusProgressBar->setVisible(false);
- }
- }
- if (event->type()==10010){
- EffectEvent* p=(EffectEvent*) event;
- slotAddEffect(p->xml(), p->pos(), p->track());
- }
+void MainWindow::slotGotProgressInfo( KUrl url, int progress) {
+ statusProgressBar->setValue(progress);
+ if (progress>0) {
+ statusLabel->setText(tr("Creating Audio Thumbs"));
+ statusProgressBar->setVisible(true);
+ }
+ else {
+ statusLabel->setText("");
+ statusProgressBar->setVisible(false);
+ }
}
+
#include "mainwindow.moc"
MainWindow(QWidget *parent=0);
void parseProfiles();
- void customEvent ( QEvent * event );
+
protected:
virtual bool queryClose();
void slotEditProfiles();
void slotEditProjectSettings();
void slotDisplayActionMessage( QAction *a);
+ void slotGotProgressInfo( KUrl url, int progress);
};
#endif
}
m_clip->setClipType(m_clipType);
}
- slotSetToolTip();
+ slotSetToolTip();
+ if (m_element.isNull()) {
+ QDomDocument doc;
+ m_element = doc.createElement("producer");
+ }
+ if (m_element.attribute("duration") == QString::null) m_element.setAttribute("duration", attributes["duration"].toInt());
+ m_element.setAttribute("resource", attributes["filename"]);
+ m_element.setAttribute("type", (int) m_clipType);
- if (m_element.isNull()) {
- QDomDocument doc;
- m_element = doc.createElement("producer");
- }
- if (m_element.attribute("duration") == QString::null) m_element.setAttribute("duration", attributes["duration"].toInt());
- m_element.setAttribute("resource", attributes["filename"]);
- m_element.setAttribute("type", (int) m_clipType);
+ m_clip->slotRequestAudioThumbs();
/*
if (attributes.contains("height")) {
m_height = attributes["height"].toInt();