Thumbnailer.hpp
1 #pragma once
2 
3 #include <Media/Libav.hpp>
4 #if SCORE_HAS_LIBAV
5 #include <Video/VideoInterface.hpp>
6 
7 #include <score_plugin_media_export.h>
8 
9 extern "C" {
10 #include <libavformat/avformat.h>
11 #include <libswscale/swscale.h>
12 }
13 
14 #include <QImage>
15 #include <QObject>
16 
17 #include <cinttypes>
18 #include <verdigris>
19 
20 namespace Video
21 {
22 class SCORE_PLUGIN_MEDIA_EXPORT VideoThumbnailer
23  : public QObject
24  , public VideoMetadata
25 {
26  W_OBJECT(VideoThumbnailer)
27 public:
28  explicit VideoThumbnailer(QString filePath);
30 
31  void requestThumbnails(int64_t req, QVector<int64_t> flicks)
32  E_SIGNAL(SCORE_PLUGIN_MEDIA_EXPORT, requestThumbnails, req, flicks)
33 
34  void thumbnailReady(int64_t req, int64_t flicks, QImage thumb)
35  E_SIGNAL(SCORE_PLUGIN_MEDIA_EXPORT, thumbnailReady, req, flicks, thumb)
36 
37  QImage process(int64_t flicks);
38 
39  int smallWidth{};
40  int smallHeight{};
41 
42 private:
43  void onRequest(int64_t req, QVector<int64_t> flicks);
44  void processNext();
45 
46  QVector<int64_t> m_requests;
47  int64_t m_requestIndex{};
48  int m_currentIndex{};
49 
50  AVFormatContext* m_formatContext{};
51  AVCodecContext* m_codecContext{};
52  SwsContext* m_rescale{};
53  const AVCodec* m_codec{};
54  AVFrame* m_rgb{};
55  int64_t m_last_dts = 0;
56 
57  int m_stream{-1};
58  double m_aspect{1.};
59 };
60 }
61 
62 W_REGISTER_ARGTYPE(QVector<int64_t>)
63 #endif
Definition: Thumbnailer.hpp:25
Definition: VideoInterface.hpp:23