]> git.sesse.net Git - kdenlive/commitdiff
got first audio frames, but
authorMarco Gittler <marco@gitma.de>
Sat, 23 Feb 2008 23:06:34 +0000 (23:06 +0000)
committerMarco Gittler <marco@gitma.de>
Sat, 23 Feb 2008 23:06:34 +0000 (23:06 +0000)
m_url=url (Kurl) crashes
notification of progress is not active

svn path=/branches/KDE4/; revision=1915

src/docclipbase.cpp
src/docclipbase.h
src/kthumb.cpp
src/renderer.cpp

index 38562405cff0c50851fe6c22c5ac7a0f3e36baf0..de5cafb188a93daae99f901628c63300923761c5 100644 (file)
@@ -21,7 +21,7 @@
 #include "docclipbase.h"
 
 DocClipBase::DocClipBase(QDomElement xml, uint id):
-m_xml(xml), m_id(id), m_description(""), m_refcount(0), m_projectThumbFrame(0), audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL)
+m_xml(xml), m_id(id), m_description(""), m_refcount(0), m_projectThumbFrame(0), audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL)
 {
   int type = xml.attribute("type").toInt();
   m_clipType = (CLIPTYPE) type;
@@ -40,6 +40,8 @@ m_xml(xml), m_id(id), m_description(""), m_refcount(0), m_projectThumbFrame(0),
        kDebug() << "type is video" << (m_clipType==AV) << " " << m_clipType;
        
        if (m_clipType == AV || m_clipType==AUDIO ||m_clipType==UNKNOWN){
+               m_audioTimer = new QTimer( this );
+               connect(m_audioTimer, SIGNAL(timeout()), this, SLOT(slotGetAudioThumbs()));
                emit getAudioThumbs();
        }
 }
@@ -397,7 +399,15 @@ QString DocClipBase::getTypeName(CLIPTYPE type)
 
 void DocClipBase::slotGetAudioThumbs(){
        kDebug() << "getting audio data";
-       double lengthInFrames=duration().frames(/*framesPerSecond()*/25);
-       m_thumbProd->getAudioThumbs(fileURL(), 1, 0, lengthInFrames, 20);
+       if (audioThumbCreated){
+               if (m_audioTimer!=NULL)
+                       m_audioTimer->stop();
+       }else{
+               if (m_audioTimer!=NULL)
+                       m_audioTimer->start(5);
+               double lengthInFrames=duration().frames(/*framesPerSecond()*/25);
+               m_thumbProd->getAudioThumbs(fileURL(), 1, 0, 10 /*must be number of frames*/, 20);
+               
+       }
 }
 
index b39dc0040c1332f2d93af80522ba055e84571897..e1ec86501b1641bca4b4fe63867cbdb364360f29 100644 (file)
@@ -25,6 +25,7 @@
 #include <qdom.h>
 #include <QPixmap>
 #include <QObject>
+#include <QTimer>
 
 #include <KUrl>
 #include <klocale.h>
@@ -210,7 +211,7 @@ class DocClipBase:public QObject {
        /** A thumbnail for this clip */
     QPixmap m_thumbnail;
     GenTime m_duration;
-
+       QTimer *m_audioTimer;
     KThumb *m_thumbProd;
     
     /** a unique numeric id */
index 27cb36395898da164841cf675f7f68b66416de68..42313c44a1806b6052971e23d934fb949458f571 100644 (file)
@@ -64,6 +64,7 @@ void MyThread::init(KUrl url, QString target, double frame, double frameLength,
 
     void MyThread::run()
     {
+               
                 if (!f.open( QIODevice::WriteOnly )) {
                        kDebug()<<"++++++++  ERROR WRITING TO FILE: "<<f.fileName()<<endl;
                        kDebug()<<"++++++++  DISABLING AUDIO THUMBS"<<endl;
@@ -86,7 +87,10 @@ void MyThread::init(KUrl url, QString target, double frame, double frameLength,
        */
                int last_val = 0;
                int val = 0;
+               kDebug() << "for " << m_frame << " " << m_frameLength << " " << m_producer.is_valid();
                for (int z=(int) m_frame;z<(int) (m_frame+m_frameLength) && m_producer.is_valid();z++){
+                       kDebug() << "starting audithumb for frame " << z;
+                       
                        if (stop_me) break;
                        val=(int)((z-m_frame)/(m_frame+m_frameLength)*100.0);
                        if (last_val!=val & val > 1){
@@ -110,6 +114,7 @@ void MyThread::init(KUrl url, QString target, double frame, double frameLength,
                                                        m_array[i] =  qAbs((*( m_pcm + c + i * m_samples / m_array.size() ))>>8);
                                                }
                                                f.write(m_array);
+                                               
                                        }
                                } else{
                                        f.write(QByteArray(m_arrayWidth,'\x00'));
@@ -320,12 +325,14 @@ void KThumb::getAudioThumbs(KUrl url, int channel, double frame, double frameLen
        if ((thumbProducer.isRunning () && thumbProducer.isWorking()) || channel == 0) {
            return;
        }
-
+       
        QMap <int, QMap <int, QByteArray> > storeIn;
        //FIXME: Hardcoded!!! 
        int m_frequency = 48000;
        int m_channels = channel;
-       /*TODO 
+       
+       m_thumbFile="/tmp/testfile";
+       /*FIXME WHY crash here ??????
        if (m_url != url) {
                m_url = url;
                QCryptographicHash context(QCryptographicHash::Sha1);
@@ -334,7 +341,7 @@ void KThumb::getAudioThumbs(KUrl url, int channel, double frame, double frameLen
                m_thumbFile = KdenliveSettings::currenttmpfolder() + context.result().toHex() + ".thumb";
                
        }*/
-       return;
+       
        QFile f(m_thumbFile);
        if (f.open( QIODevice::ReadOnly )) {
                QByteArray channelarray = f.readAll();
index ee7f7b8377703b815c8af2443db9449b5732bad5..a44f016462ba3b5a9aa22f430375b28cf3dbc2de 100644 (file)
@@ -387,6 +387,7 @@ void Render::getFileProperties(const QDomElement &xml, int clipId)
        // 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
@@ -401,7 +402,7 @@ void Render::getFileProperties(const QDomElement &xml, int clipId)
                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