00001
00002
00003
00004
00005
00006
00007 #ifndef __output_h
00008 #define __output_h
00009
00010 class OutputListeners;
00011 class OutputEvent;
00012
00013 #include <qthread.h>
00014 #include <qevent.h>
00015 #include <qptrlist.h>
00016 #include "mythobservable.h"
00017
00018 class QObject;
00019 class Buffer;
00020
00021 namespace MythTV {
00022 class Visual;
00023 }
00024
00025 class MPUBLIC OutputEvent : public MythEvent
00026 {
00027 public:
00028 enum Type { Playing = (User + 200), Buffering, Info, Paused,
00029 Stopped, Error };
00030
00031 OutputEvent(Type t)
00032 : MythEvent(t), error_msg(0), elasped_seconds(0), written_bytes(0),
00033 brate(0), freq(0), prec(0), chan(0)
00034 { ; }
00035
00036 OutputEvent(long s, unsigned long w, int b, int f, int p, int c)
00037 : MythEvent(Info), error_msg(0), elasped_seconds(s), written_bytes(w),
00038 brate(b), freq(f), prec(p), chan(c)
00039 { ; }
00040
00041 OutputEvent(const QString &e)
00042 : MythEvent(Error), elasped_seconds(0), written_bytes(0),
00043 brate(0), freq(0), prec(0), chan(0)
00044 {
00045 error_msg = new QString(e.utf8());
00046 }
00047
00048
00049 ~OutputEvent()
00050 {
00051 if (error_msg)
00052 delete error_msg;
00053 }
00054
00055 const QString *errorMessage() const { return error_msg; }
00056
00057 const long &elapsedSeconds() const { return elasped_seconds; }
00058 const unsigned long &writtenBytes() const { return written_bytes; }
00059 const int &bitrate() const { return brate; }
00060 const int &frequency() const { return freq; }
00061 const int &precision() const { return prec; }
00062 const int &channels() const { return chan; }
00063
00064 virtual OutputEvent *clone() { return new OutputEvent(*this); };
00065
00066 private:
00067 QString *error_msg;
00068
00069 long elasped_seconds;
00070 unsigned long written_bytes;
00071 int brate, freq, prec, chan;
00072 };
00073
00074
00075 class MPUBLIC OutputListeners : public MythObservable
00076 {
00077 public:
00078 OutputListeners();
00079 virtual ~OutputListeners();
00080
00081 void addVisual(MythTV::Visual *);
00082 void removeVisual(MythTV::Visual *);
00083
00084 QMutex *mutex() { return &mtx; }
00085
00086 void setBufferSize(unsigned int sz) { bufsize = sz; }
00087 unsigned int bufferSize() const { return bufsize; }
00088
00089 protected:
00090 void error(const QString &e);
00091 void dispatchVisual(uchar *b, unsigned long b_len,
00092 unsigned long written, int chan, int prec);
00093 void prepareVisuals();
00094
00095 private:
00096 QMutex mtx;
00097 QPtrList<MythTV::Visual> visuals;
00098
00099 unsigned int bufsize;
00100 };
00101
00102
00103 #endif // __output_h