MythTV  master
output.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 // Copyright (c) 2000-2001 Brad Hughes <bhughes@trolltech.com>
3 //
4 // Use, modification and distribution is allowed without limitation,
5 // warranty, or liability of any kind.
6 //
7 
8 #ifndef __output_h
9 #define __output_h
10 
11 class OutputListeners;
12 class OutputEvent;
13 
14 #include <vector>
15 
16 #include <QMutex>
17 #include <QList>
18 
19 #include "mythobservable.h"
20 #include "mythexp.h"
21 
22 class QObject;
23 class Buffer;
24 
25 namespace MythTV {
26 class Visual;
27 }
28 
30 {
31  public:
32  explicit OutputEvent(Type type) :
33  MythEvent(type) {}
34  OutputEvent(long s, unsigned long w, int b, int f, int p, int c) :
35  MythEvent(Info), m_elasped_seconds(s), m_written_bytes(w),
36  m_brate(b), m_freq(f), m_prec(p), m_chan(c) {}
37  explicit OutputEvent(const QString &e) :
38  MythEvent(Error)
39  {
40  QByteArray tmp = e.toUtf8();
41  m_error_msg = new QString(tmp.constData());
42  }
43 
45  {
46  delete m_error_msg;
47  }
48 
49  const QString *errorMessage() const { return m_error_msg; }
50 
51  const long &elapsedSeconds() const { return m_elasped_seconds; }
52  const unsigned long &writtenBytes() const { return m_written_bytes; }
53  const int &bitrate() const { return m_brate; }
54  const int &frequency() const { return m_freq; }
55  const int &precision() const { return m_prec; }
56  const int &channels() const { return m_chan; }
57 
58  MythEvent *clone(void) const override // MythEvent
59  { return new OutputEvent(*this); }
60 
61  static Type Playing;
62  static Type Buffering;
63  static Type Info;
64  static Type Paused;
65  static Type Stopped;
66  static Type Error;
67 
68  private:
70  m_elasped_seconds(o.m_elasped_seconds),
71  m_written_bytes(o.m_written_bytes),
72  m_brate(o.m_brate), m_freq(o.m_freq),
73  m_prec(o.m_prec), m_chan(o.m_chan)
74  {
75  if (o.m_error_msg)
76  {
77  m_error_msg = new QString(*o.m_error_msg);
78  }
79  }
80  OutputEvent &operator=(const OutputEvent&);
81 
82  private:
83  QString *m_error_msg {nullptr};
84 
85  long m_elasped_seconds {0};
86  unsigned long m_written_bytes {0};
87  int m_brate {0};
88  int m_freq {0};
89  int m_prec {0};
90  int m_chan {0};
91 };
92 
93 typedef std::vector<MythTV::Visual*> Visuals;
94 
96 {
97 public:
98  OutputListeners() = default;
99  virtual ~OutputListeners() = default;
100 
101  bool hasVisual(void) { return m_visuals.size(); }
102  void addVisual(MythTV::Visual *);
103  void removeVisual(MythTV::Visual *);
104 
105  QMutex *mutex() { return &m_mtx; }
106 
107  void setBufferSize(unsigned int sz) { m_bufsize = sz; }
108  unsigned int bufferSize() const { return m_bufsize; }
109 
110 protected:
111  void error(const QString &e);
112  void dispatchVisual(uchar *b, unsigned long b_len,
113  unsigned long written, int chan, int prec);
114  void prepareVisuals();
115 
116 private:
117  Q_DISABLE_COPY(OutputListeners)
118 
119  QMutex m_mtx;
120  Visuals m_visuals;
121 
122  unsigned int m_bufsize {0};
123 };
124 
125 
126 #endif // __output_h
bool hasVisual(void)
Definition: output.h:101
static Type Info
Definition: output.h:63
const unsigned long & writtenBytes() const
Definition: output.h:52
#define MPUBLIC
Definition: mythexp.h:10
static Type Error
Definition: output.h:66
QMutex * mutex()
Definition: output.h:105
static Type Playing
Definition: output.h:61
static void error(const char *str,...)
Definition: vbi.c:42
OutputEvent(const QString &e)
Definition: output.h:37
const int & channels() const
Definition: output.h:56
const int & precision() const
Definition: output.h:55
MythEvent * clone(void) const override
Definition: output.h:58
static guint32 * tmp
Definition: goom_core.c:35
static Type Buffering
Definition: output.h:62
Superclass for making an object have a set of listeners.
unsigned char b
Definition: ParseText.cpp:329
OutputEvent(Type type)
Definition: output.h:32
OutputEvent(long s, unsigned long w, int b, int f, int p, int c)
Definition: output.h:34
void setBufferSize(unsigned int sz)
Definition: output.h:107
This class is used as a container for messages.
Definition: mythevent.h:16
QString * m_error_msg
Definition: output.h:83
unsigned int bufferSize() const
Definition: output.h:108
const int & bitrate() const
Definition: output.h:53
~OutputEvent()
Definition: output.h:44
const QString * errorMessage() const
Definition: output.h:49
OutputEvent(const OutputEvent &o)
Definition: output.h:69
const long & elapsedSeconds() const
Definition: output.h:51
Definition: output.h:25
static Type Paused
Definition: output.h:64
const int & frequency() const
Definition: output.h:54
std::vector< MythTV::Visual * > Visuals
Definition: output.h:93
static Type Stopped
Definition: output.h:65