00001 #ifndef VIDEOVISUAL_H
00002 #define VIDEOVISUAL_H
00003
00004 #include "stdint.h"
00005
00006 #include <QRect>
00007 #include <QList>
00008 #include <QDateTime>
00009
00010 #include "mythlogging.h"
00011 #include "visual.h"
00012 #include "mythrender_base.h"
00013 #include "mythpainter.h"
00014 #include "videovisualdefs.h"
00015
00016 #define DESC QString("Visualiser: ")
00017
00018 class MythRender;
00019 class AudioPlayer;
00020
00021 class VisualNode
00022 {
00023 public:
00024 VisualNode(short *l, short *r, unsigned long n, unsigned long o)
00025 : left(l), right(r), length(n), offset(o) { }
00026
00027 ~VisualNode()
00028 {
00029 delete [] left;
00030 delete [] right;
00031 }
00032
00033 short *left, *right;
00034 long length, offset;
00035 };
00036
00037 class VideoVisual : public MythTV::Visual
00038 {
00039 public:
00040 static bool CanVisualise(AudioPlayer *audio, MythRender *render);
00041 static VideoVisual* Create(const QString &name,
00042 AudioPlayer *audio, MythRender *render);
00043 static QStringList GetVisualiserList(RenderType type);
00044
00045 VideoVisual(AudioPlayer *audio, MythRender *render);
00046 ~VideoVisual();
00047
00048 virtual void Draw(const QRect &area, MythPainter *painter,
00049 QPaintDevice* device) = 0;
00050 virtual QString Name(void) = 0;
00051
00052 virtual void add(uchar *b, unsigned long b_len, unsigned long w, int c, int p);
00053 virtual void prepare();
00054
00055 protected:
00056 VisualNode* GetNode(void);
00057 void DeleteNodes(void);
00058 int64_t SetLastUpdate(void);
00059
00060 AudioPlayer *m_audio;
00061 bool m_disabled;
00062 QRect m_area;
00063 MythRender *m_render;
00064 QList<VisualNode*> m_nodes;
00065 QDateTime m_lastUpdate;
00066 };
00067
00068 class VideoVisualFactory
00069 {
00070 public:
00071 VideoVisualFactory()
00072 {
00073 m_nextVideoVisualFactory = g_videoVisualFactory;
00074 g_videoVisualFactory = this;
00075 }
00076 virtual ~VideoVisualFactory() { }
00077 virtual const QString &name(void) const = 0;
00078 virtual VideoVisual* Create(AudioPlayer *audio,
00079 MythRender *render) const = 0;
00080 static VideoVisualFactory* VideoVisualFactories()
00081 {
00082 return g_videoVisualFactory;
00083 }
00084 VideoVisualFactory* next() const
00085 {
00086 return m_nextVideoVisualFactory;
00087 }
00088 virtual bool SupportedRenderer(RenderType type) = 0;
00089
00090 protected:
00091 static VideoVisualFactory* g_videoVisualFactory;
00092 VideoVisualFactory* m_nextVideoVisualFactory;
00093 };
00094 #endif // VIDEOVISUAL_H