diff options
author | Arno <am@disconnect.de> | 2013-03-29 12:55:36 +0100 |
---|---|---|
committer | Arno <am@disconnect.de> | 2013-03-29 12:55:36 +0100 |
commit | 1bcbb69e31090cf71e913419299b52dd4d094bef (patch) | |
tree | 07fc7ed7ff38b68ed996ba398e564219e85758f5 /framecache.h | |
parent | 110271a7db1ef05769bcfb5c936caad82bc0e498 (diff) | |
download | SheMov-1bcbb69e31090cf71e913419299b52dd4d094bef.tar.gz SheMov-1bcbb69e31090cf71e913419299b52dd4d094bef.tar.bz2 SheMov-1bcbb69e31090cf71e913419299b52dd4d094bef.zip |
Make FrameCache threaded
create snapshot pics in a separate thread. Also use the first frame
available if the clip isn't long enough for the configured frame.
Diffstat (limited to 'framecache.h')
-rw-r--r-- | framecache.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/framecache.h b/framecache.h new file mode 100644 index 0000000..509fea6 --- /dev/null +++ b/framecache.h @@ -0,0 +1,72 @@ +/* + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version + 2 of the License, or (at your option) any later version. +*/ + +#ifndef FRAMECACHE_H +#define FRAMECACHE_H + +#include <QThread> +#include <QPair> +#include <QHash> +#include <QPair> +#include <QQueue> +#include <QString> + +class QSemaphore; +class QMutex; +class FrameCacheGenerator; + +class FrameCache : public QObject { + Q_OBJECT + public: + explicit FrameCache(QObject *parent = 0); + ~FrameCache(); + const QPixmap entry(const QString &sourcePath, const QString &when = QString()); + const QString entryPath(const QString &sourcePath, const QString &when); + + private: + QHash<QPair<QString, QString>, QString> *mFrameCache; + QQueue<QPair<QString, QString> > *mDataQueue; + QString mCacheFile; + qint32 mMagic; + QSemaphore *mSemFree; + QSemaphore *mSemUsed; + QMutex *mCacheMx; + FrameCacheGenerator *mGenerator; + QString mWhen; +}; + +class FrameCacheGenerator : public QThread { + Q_OBJECT + public: + explicit FrameCacheGenerator(QObject *parent = 0); + void init(QSemaphore *set, QSemaphore *get, QMutex *cachemx, QQueue<QPair<QString, QString> > *data, QHash<QPair<QString, QString>, QString> *cache); + const QString cacheFile() const { return mCacheFile; } + qint32 magic() const { return mMagic; }; + void readConfig(); + void readCache(); + + public slots: + void run(); + + private: + bool grabFrame(const QString &sourceFile, QString when); + QSemaphore *mSemFree; + QSemaphore *mSemUsed; + QMutex *mCacheMx; + QQueue<QPair<QString, QString> > *mDataQueue; + QHash<QPair<QString, QString>, QString> *mFrameCache; + QString mCacheDir; + QString mCacheFile; + //QString mWhen; + QString mFfMpegPath; + const qint32 mMagic; + const QString mCacheSubDir; + const QString mCacheFileName; + +}; + +#endif // FRAMECACHE_H |