/* 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 #include #include #include #include #include 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); public slots: void rebuild(); private: QHash, QString> *mFrameCache; QQueue > *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 > *data, QHash, QString> *cache); const QString cacheFile() const { return mCacheFile; } const QString cacheDir() const { return mCacheDir; } void readConfig(); public slots: void run(); private: bool grabFrame(const QString &sourceFile, QString when); QSemaphore *mSemFree; QSemaphore *mSemUsed; QMutex *mCacheMx; QQueue > *mDataQueue; QHash, QString> *mFrameCache; QString mCacheDir; QString mCacheFile; QString mFfMpegPath; const QString mCacheSubDir; const QString mCacheFileName; }; #endif // FRAMECACHE_H