MythTV  master
videovisual.h
Go to the documentation of this file.
1 #ifndef VIDEOVISUAL_H
2 #define VIDEOVISUAL_H
3 
4 #include <cstdint>
5 
6 #include <QRect>
7 #include <QList>
8 #include <QDateTime>
9 
10 #include "mythtvexp.h"
11 #include "mythlogging.h"
12 #include "visual.h"
13 #include "mythrender_base.h"
14 #include "mythpainter.h"
15 #include "videovisualdefs.h"
16 
17 using namespace std::chrono_literals;
18 
19 #define DESC QString("Visualiser: ")
20 
21 class MythRender;
22 class AudioPlayer;
23 
25 {
26  public:
27  VisualNode(short *l, short *r, unsigned long n, std::chrono::milliseconds timecode)
28  : m_left(l), m_right(r), m_length(n), m_offset(timecode) { }
29 
31  {
32  delete [] m_left;
33  delete [] m_right;
34  }
35 
36  short *m_left {nullptr};
37  short *m_right {nullptr};
38  long m_length;
39  std::chrono::milliseconds m_offset;
40 };
41 
43 {
44  public:
45  static VideoVisual* Create(const QString &name,
46  AudioPlayer *audio, MythRender *render);
47  static QStringList GetVisualiserList(RenderType type);
48 
49  VideoVisual(AudioPlayer *audio, MythRender *render);
50  ~VideoVisual() override;
51 
52  bool NeedsPrepare() const { return m_needsPrepare; }
53  virtual void Prepare(const QRect /*Area*/) { }
54  virtual void Draw(QRect area, MythPainter *painter,
55  QPaintDevice* device) = 0;
56  virtual QString Name(void) = 0;
57 
58  void add(const void *b, unsigned long b_len,
59  std::chrono::milliseconds timecode,
60  int c, int p) override; // Visual
61  void prepare() override; // Visual
62 
63  protected:
64  VisualNode* GetNode(void);
65  void DeleteNodes(void);
66  std::chrono::milliseconds SetLastUpdate(void);
67 
68  AudioPlayer *m_audio { nullptr };
69  bool m_needsPrepare { false };
70  bool m_disabled { false };
71  QRect m_area;
72  MythRender *m_render { nullptr };
73  QList<VisualNode*> m_nodes;
74  QDateTime m_lastUpdate;
75 };
76 
78 {
79  public:
81  {
82  m_nextVideoVisualFactory = g_videoVisualFactory;
83  g_videoVisualFactory = this;
84  }
85  virtual ~VideoVisualFactory() = default;
86  virtual const QString &name(void) const = 0;
87  virtual VideoVisual* Create(AudioPlayer *audio,
88  MythRender *render) const = 0;
90  {
91  return g_videoVisualFactory;
92  }
94  {
95  return m_nextVideoVisualFactory;
96  }
97  virtual bool SupportedRenderer(RenderType type) = 0;
98 
99  protected:
101  VideoVisualFactory* m_nextVideoVisualFactory {nullptr};
102 };
103 #endif // VIDEOVISUAL_H
VisualNode::~VisualNode
~VisualNode()
Definition: videovisual.h:30
VideoVisualFactory::VideoVisualFactories
static VideoVisualFactory * VideoVisualFactories()
Definition: videovisual.h:89
VideoVisualFactory::g_videoVisualFactory
static VideoVisualFactory * g_videoVisualFactory
Definition: videovisual.h:100
VideoVisual::m_lastUpdate
QDateTime m_lastUpdate
Definition: videovisual.h:74
AudioPlayer
Definition: audioplayer.h:28
VisualNode
Definition: videovisual.h:24
VisualNode::VisualNode
VisualNode(short *l, short *r, unsigned long n, std::chrono::milliseconds timecode)
Definition: videovisual.h:27
VideoVisual::NeedsPrepare
bool NeedsPrepare() const
Definition: videovisual.h:52
mythtvexp.h
VideoVisual::m_nodes
QList< VisualNode * > m_nodes
Definition: videovisual.h:73
MythTV::Visual
Definition: visual.h:16
VisualNode::m_offset
std::chrono::milliseconds m_offset
Definition: videovisual.h:39
mythrender_base.h
mythlogging.h
hardwareprofile.config.p
p
Definition: config.py:33
VideoVisualFactory::VideoVisualFactory
VideoVisualFactory()
Definition: videovisual.h:80
VideoVisualFactory
Definition: videovisual.h:77
VideoVisualFactory::next
VideoVisualFactory * next() const
Definition: videovisual.h:93
RenderType
RenderType
Definition: mythrender_base.h:15
mythpainter.h
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
VisualNode::m_length
long m_length
Definition: videovisual.h:38
MythRender
Definition: mythrender_base.h:23
MythPainter
Definition: mythpainter.h:32
Name
Definition: channelsettings.cpp:46
VideoVisual
Definition: videovisual.h:42
VideoVisual::m_area
QRect m_area
Definition: videovisual.h:71
VideoVisual::Prepare
virtual void Prepare(const QRect)
Definition: videovisual.h:53
videovisualdefs.h
visual.h