MythTV  master
thumbfinder.h
Go to the documentation of this file.
1 #ifndef THUMBFINDER_H_
2 #define THUMBFINDER_H_
3 
4 // qt
5 #include <QString>
6 #include <QStringList>
7 #include <QScopedPointer>
8 
9 // mythtv
10 #include <mythscreentype.h>
11 extern "C" {
12 #include <libavcodec/avcodec.h>
13 #include <libavformat/avformat.h>
14 }
15 #include "programtypes.h"
16 
17 // mytharchive
18 #include "archiveutil.h"
19 #include "remoteavformatcontext.h"
20 #include "mythavutil.h"
21 
22 struct SeekAmount
23 {
24  QString name;
25  int amount;
26 };
27 
28 extern struct SeekAmount SeekAmounts[];
29 extern int SeekAmountsCount;
30 
31 class MythUIButton;
32 class MythUItext;
33 class MythUIImage;
34 class MythUIButtonList;
36 class MythImage;
37 
39 {
40 
41  Q_OBJECT
42 
43  public:
44 
45  ThumbFinder(MythScreenStack *parent, ArchiveItem *archiveItem,
46  const QString &menuTheme);
47  ~ThumbFinder() override;
48 
49  bool Create(void) override; // MythScreenType
50  bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
51 
52 
53  private slots:
55  void ShowMenu(void) override; // MythScreenType
56  void cancelPressed(void);
57  void savePressed(void);
58  void updateThumb(void);
59 
60  private:
61  void Init(void) override; // MythScreenType
62  bool getThumbImages(void);
63  static int getChapterCount(const QString &menuTheme);
64  void changeSeekAmount(bool up);
65  void updateCurrentPos(void);
66  bool seekToFrame(int frame, bool checkPos = true);
67  static QString createThumbDir(void);
68  QString frameToTime(int64_t frame, bool addFrame = false) const;
69 
70  // avcodec stuff
71  bool initAVCodec(const QString &inFile);
72  void closeAVCodec();
73  bool seekForward();
74  bool seekBackward();
75  bool getFrameImage(bool needKeyFrame = true, int64_t requiredPTS = -1);
76  int checkFramePosition(int frameNumber);
77  void loadCutList(void);
78  void updatePositionBar(int64_t frame);
79  int calcFinalDuration(void);
80 
82  AVCodecContext *m_codecCtx {nullptr};
84  AVCodec *m_codec {nullptr};
87  QScopedPointer<MythPictureDeinterlacer> m_deinterlacer;
88 
89  float m_fps {0.0F};
90  unsigned char *m_outputbuf {nullptr};
91  QString m_frameFile;
92  int m_frameWidth { 0};
93  int m_frameHeight { 0};
94  int m_videostream { 0};
95  int m_currentSeek { 0};
96  int64_t m_startTime {-1}; // in time_base units
97  int64_t m_startPTS {-1}; // in time_base units
98  int64_t m_currentPTS {-1}; // in time_base units
99  int64_t m_firstIFramePTS {-1};
100  int m_frameTime { 0}; // in time_base units
101  bool m_updateFrame {false};
103  int m_finalDuration { 0};
104  int m_offset { 0};
105 
108  QList<ThumbImage *> m_thumbList;
109  QString m_thumbDir;
110 
111  // GUI stuff
120 };
121 
122 #endif
void updateCurrentPos(void)
MythAVCopy m_copy
Definition: thumbfinder.h:86
int m_videostream
Definition: thumbfinder.h:94
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool getThumbImages(void)
void cancelPressed(void)
int64_t m_currentPTS
Definition: thumbfinder.h:98
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
AVCodecContext * m_codecCtx
Definition: thumbfinder.h:82
QString m_frameFile
Definition: thumbfinder.h:91
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
unsigned int slots[4]
Definition: element.cpp:38
MythAVCopy Copy AVFrame<->frame, performing the required conversion if any.
Definition: mythavutil.h:107
int m_frameWidth
Definition: thumbfinder.h:92
ArchiveItem * m_archiveItem
Definition: thumbfinder.h:106
bool Create(void) override
int SeekAmountsCount
Definition: thumbfinder.cpp:84
int64_t m_startTime
Definition: thumbfinder.h:96
QString name
Definition: thumbfinder.h:24
void changeSeekAmount(bool up)
frm_dir_map_t m_deleteMap
Definition: thumbfinder.h:102
MythAVFrame m_frame
Definition: thumbfinder.h:85
int64_t m_firstIFramePTS
Definition: thumbfinder.h:99
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
MythUIButton * m_frameButton
Definition: thumbfinder.h:112
int m_currentSeek
Definition: thumbfinder.h:95
int checkFramePosition(int frameNumber)
MythUIButtonList * m_imageGrid
Definition: thumbfinder.h:117
int calcFinalDuration(void)
bool initAVCodec(const QString &inFile)
MythUIButton * m_saveButton
Definition: thumbfinder.h:113
bool getFrameImage(bool needKeyFrame=true, int64_t requiredPTS=-1)
RemoteAVFormatContext m_inputFC
Definition: thumbfinder.h:81
void gridItemChanged(MythUIButtonListItem *item)
bool seekToFrame(int frame, bool checkPos=true)
bool m_updateFrame
Definition: thumbfinder.h:101
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
QString frameToTime(int64_t frame, bool addFrame=false) const
QScopedPointer< MythPictureDeinterlacer > m_deinterlacer
Definition: thumbfinder.h:87
QString m_thumbDir
Definition: thumbfinder.h:109
ThumbFinder(MythScreenStack *parent, ArchiveItem *archiveItem, const QString &menuTheme)
Definition: thumbfinder.cpp:86
A single button widget.
Definition: mythuibutton.h:21
void ShowMenu(void) override
void savePressed(void)
struct SeekAmount SeekAmounts[]
Definition: thumbfinder.cpp:71
void loadCutList(void)
MythUIImage * m_positionImage
Definition: thumbfinder.h:116
float m_fps
Definition: thumbfinder.h:89
void closeAVCodec()
MythUIButton * m_cancelButton
Definition: thumbfinder.h:114
MythUIText * m_currentPosText
Definition: thumbfinder.h:119
void updateThumb(void)
static QString createThumbDir(void)
~ThumbFinder() override
MythCodecMap m_codecMap
Definition: thumbfinder.h:83
static int getChapterCount(const QString &menuTheme)
QList< ThumbImage * > m_thumbList
Definition: thumbfinder.h:108
MythUIImage * m_frameImage
Definition: thumbfinder.h:115
MythCodecMap Utility class that keeps pointers to an AVStream and its AVCodecContext.
Definition: mythavutil.h:86
MythAVFrame little utility class that act as a safe way to allocate an AVFrame which can then be allo...
Definition: mythavutil.h:43
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:81
int m_thumbCount
Definition: thumbfinder.h:107
unsigned char * m_outputbuf
Definition: thumbfinder.h:90
Screen in which all other widgets are contained and rendered.
int m_frameHeight
Definition: thumbfinder.h:93
AVCodec * m_codec
Definition: thumbfinder.h:84
int64_t m_startPTS
Definition: thumbfinder.h:97
bool seekForward()
bool seekBackward()
void updatePositionBar(int64_t frame)
MythUIText * m_seekAmountText
Definition: thumbfinder.h:118
int m_finalDuration
Definition: thumbfinder.h:103