00001 #ifndef THUMBFINDER_H_
00002 #define THUMBFINDER_H_
00003
00004 #include <qthread.h>
00005 #include <qstring.h>
00006 #include <qstringlist.h>
00007
00008 using namespace std;
00009 #include <iostream>
00010
00011 #include <mythtv/mythdialogs.h>
00012 #include <mythtv/uitypes.h>
00013 extern "C" {
00014 #include <mythtv/ffmpeg/avcodec.h>
00015 #include <mythtv/ffmpeg/avformat.h>
00016 }
00017
00018 #include "archiveutil.h"
00019
00020 typedef struct SeekAmount
00021 {
00022 QString name;
00023 int amount;
00024 } SeekAmount;
00025
00026 extern struct SeekAmount SeekAmounts[];
00027 extern int SeekAmountsCount;
00028
00029 class ThumbFinder : public MythThemedDialog
00030 {
00031
00032 Q_OBJECT
00033
00034 public:
00035
00036 ThumbFinder(ArchiveItem *archiveItem, const QString &menuTheme,
00037 MythMainWindow *parent, const QString &window_name,
00038 const QString &theme_filename, const char *name = 0);
00039 ~ThumbFinder();
00040
00041
00042 private slots:
00043 void keyPressEvent(QKeyEvent *e);
00044 void wireUpTheme(void);
00045 bool getThumbImages(void);
00046 void cancelPressed(void);
00047 void savePressed(void);
00048 void gridItemChanged(ImageGridItem *item);
00049 void showMenu(void);
00050 void closePopupMenu(void);
00051 void menuSavePressed(void);
00052 void menuCancelPressed(void);
00053
00054 private:
00055 int getChapterCount(const QString &menuTheme);
00056 QPixmap *createScaledPixmap(QString filename, int width, int height,
00057 QImage::ScaleMode mode);
00058 void changeSeekAmount(bool up);
00059 void updateThumb(void);
00060 void updateCurrentPos(void);
00061 bool seekToFrame(int frame, bool checkPos = true);
00062 QString createThumbDir(void);
00063 QString frameToTime(int64_t frame, bool addFrame = false);
00064
00065 ArchiveItem *m_archiveItem;
00066 int m_thumbCount;
00067 QPtrList<ThumbImage> m_thumbList;
00068 QString m_thumbDir;
00069
00070
00071 bool initAVCodec(const QString &inFile);
00072 void closeAVCodec();
00073 bool seekForward();
00074 bool seekBackward();
00075 bool getFrameImage(bool needKeyFrame = true, int64_t requiredPTS = -1);
00076 int checkFramePosition(int frameNumber);
00077 void loadCutList(void);
00078 void updatePositionBar(int64_t frame);
00079 int calcFinalDuration(void);
00080
00081 AVFormatContext *m_inputFC;
00082 AVCodecContext *m_codecCtx;
00083 AVCodec *m_codec;
00084 AVFrame *m_frame;
00085
00086 float m_fps;
00087 unsigned char *m_outputbuf;
00088 QString m_frameFile;
00089 int m_frameWidth;
00090 int m_frameHeight;
00091 int m_videostream;
00092 int m_currentSeek;
00093 int64_t m_startTime;
00094 int64_t m_startPTS;
00095 int64_t m_currentPTS;
00096 int64_t m_firstIFramePTS;
00097 int m_frameTime;
00098 bool m_updateFrame;
00099 QMap<long long, int> m_deleteMap;
00100 int m_finalDuration;
00101 int m_offset;
00102
00103
00104 UITextButtonType *m_frameButton;
00105 UITextButtonType *m_saveButton;
00106 UITextButtonType *m_cancelButton;
00107 UIImageType *m_frameImage;
00108 UIImageType *m_positionImage;
00109 UIImageGridType *m_imageGrid;
00110 UITextType *m_seekAmountText;
00111 UITextType *m_currentPosText;
00112
00113
00114 MythPopupBox *m_popupMenu;
00115 };
00116
00117 #endif