QtGStreamer  0.10.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
message.h
1 /*
2  Copyright (C) 2009-2010 George Kiagiadakis <kiagiadakis.george@gmail.com>
3 
4  This library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as published
6  by the Free Software Foundation; either version 2.1 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 #ifndef QGST_MESSAGE_H
18 #define QGST_MESSAGE_H
19 
20 #include "miniobject.h"
21 #include "structure.h"
22 #include "taglist.h"
23 
24 namespace QGst {
25 
47 class QTGSTREAMER_EXPORT Message : public MiniObject
48 {
49  QGST_WRAPPER(Message)
50 public:
51  ObjectPtr source() const;
52  quint64 timestamp() const;
53  QString typeName() const;
54  MessageType type() const;
55 
56  StructurePtr internalStructure();
57 
58  quint32 sequenceNumber() const;
59  void setSequenceNumber(quint32 num);
60 };
61 
65 class QTGSTREAMER_EXPORT EosMessage : public Message
66 {
67  QGST_WRAPPER_FAKE_SUBCLASS(Eos, Message)
68 public:
69  static EosMessagePtr create(const ObjectPtr & source);
70 };
71 
75 class QTGSTREAMER_EXPORT ErrorMessage : public Message
76 {
77  QGST_WRAPPER_FAKE_SUBCLASS(Error, Message)
78 public:
79  static ErrorMessagePtr create(const ObjectPtr & source,
80  const QGlib::Error & error, const char *debug);
81 
82  QGlib::Error error() const;
83  QString debugMessage() const;
84 };
85 
89 class QTGSTREAMER_EXPORT WarningMessage : public Message
90 {
91  QGST_WRAPPER_FAKE_SUBCLASS(Warning, Message)
92 public:
93  static WarningMessagePtr create(const ObjectPtr & source,
94  const QGlib::Error & error, const char *debug);
95 
96  QGlib::Error error() const;
97  QString debugMessage() const;
98 };
99 
103 class QTGSTREAMER_EXPORT InfoMessage : public Message
104 {
105  QGST_WRAPPER_FAKE_SUBCLASS(Info, Message)
106 public:
107  static InfoMessagePtr create(const ObjectPtr & source,
108  const QGlib::Error & error, const char *debug);
109 
110  QGlib::Error error() const;
111  QString debugMessage() const;
112 };
113 
117 class QTGSTREAMER_EXPORT TagMessage : public Message
118 {
119  QGST_WRAPPER_FAKE_SUBCLASS(Tag, Message)
120 public:
121  static TagMessagePtr create(const ObjectPtr & source, const TagList & taglist);
122 
123  TagList taglist() const;
124 };
125 
129 class QTGSTREAMER_EXPORT BufferingMessage : public Message
130 {
131  QGST_WRAPPER_FAKE_SUBCLASS(Buffering, Message)
132 public:
133  static BufferingMessagePtr create(const ObjectPtr & source, int percent);
134 
135  int percent() const;
136  BufferingMode mode() const;
137  int averageInputRate() const;
138  int averageOutputRate() const;
139  qint64 bufferingTimeLeft() const;
140 
141  void setStats(BufferingMode mode, int avgIn, int avgOut, qint64 bufferingLeft);
142 };
143 
147 class QTGSTREAMER_EXPORT StateChangedMessage : public Message
148 {
149  QGST_WRAPPER_FAKE_SUBCLASS(StateChanged, Message)
150 public:
151  static StateChangedMessagePtr create(const ObjectPtr & source,
152  State oldState, State newState, State pending);
153 
154  State oldState() const;
155  State newState() const;
156  State pendingState() const;
157 };
158 
159 //won't do: STATE_DIRTY (deprecated)
160 
164 class QTGSTREAMER_EXPORT StepDoneMessage : public Message
165 {
166  QGST_WRAPPER_FAKE_SUBCLASS(StepDone, Message)
167 public:
168  static StepDoneMessagePtr create(const ObjectPtr & source, Format format, quint64 amount,
169  double rate, bool flush, bool intermediate, quint64 duration, bool eos);
170 
171  Format format() const;
172  quint64 amount() const;
173  double rate() const;
174  bool isFlushingStep() const;
175  bool isIntermediateStep() const;
176  quint64 duration() const;
177  bool causedEos() const;
178 };
179 
180 //TODO CLOCK_PROVIDE, CLOCK_LOST, NEW_CLOCK
181 //maybe do: STRUCTURE_CHANGE (internal)
182 
186 class QTGSTREAMER_EXPORT StreamStatusMessage : public Message
187 {
188  QGST_WRAPPER_FAKE_SUBCLASS(StreamStatus, Message)
189 public:
190  static StreamStatusMessagePtr create(const ObjectPtr & source,
191  StreamStatusType type, const ElementPtr & owner);
192 
193  StreamStatusType statusType() const;
194  ElementPtr owner() const;
195  QGlib::Value streamStatusObject() const;
196  void setStreamStatusObject(const QGlib::Value & object);
197 };
198 
202 class QTGSTREAMER_EXPORT ApplicationMessage : public Message
203 {
204  QGST_WRAPPER_FAKE_SUBCLASS(Application, Message)
205 public:
206  static ApplicationMessagePtr create(const ObjectPtr & source,
207  const Structure & structure = Structure());
208 };
209 
213 class QTGSTREAMER_EXPORT ElementMessage : public Message
214 {
215  QGST_WRAPPER_FAKE_SUBCLASS(Element, Message)
216 public:
217  static ElementMessagePtr create(const ObjectPtr & source,
218  const Structure & structure = Structure());
219 };
220 
221 //maybe do: SEGMENT_START (internal)
222 
226 class QTGSTREAMER_EXPORT SegmentDoneMessage : public Message
227 {
228  QGST_WRAPPER_FAKE_SUBCLASS(SegmentDone, Message)
229 public:
230  static SegmentDoneMessagePtr create(const ObjectPtr & source, Format format, qint64 position);
231 
232  Format format() const;
233  qint64 position() const;
234 };
235 
239 class QTGSTREAMER_EXPORT DurationMessage : public Message
240 {
241  QGST_WRAPPER_FAKE_SUBCLASS(Duration, Message)
242 public:
243  static DurationMessagePtr create(const ObjectPtr & source, Format format, qint64 duration);
244 
245  Format format() const;
246  qint64 duration() const;
247 };
248 
252 class QTGSTREAMER_EXPORT LatencyMessage : public Message
253 {
254  QGST_WRAPPER_FAKE_SUBCLASS(Latency, Message)
255 public:
256  static LatencyMessagePtr create(const ObjectPtr & source);
257 };
258 
259 //maybe do: ASYNC_START (internal)
260 
264 class QTGSTREAMER_EXPORT AsyncDoneMessage : public Message
265 {
266  QGST_WRAPPER_FAKE_SUBCLASS(AsyncDone, Message)
267 public:
268  static AsyncDoneMessagePtr create(const ObjectPtr & source);
269 };
270 
274 class QTGSTREAMER_EXPORT RequestStateMessage : public Message
275 {
276  QGST_WRAPPER_FAKE_SUBCLASS(RequestState, Message)
277 public:
278  static RequestStateMessagePtr create(const ObjectPtr & source, State state);
279 
280  State state() const;
281 };
282 
286 class QTGSTREAMER_EXPORT StepStartMessage : public Message
287 {
288  QGST_WRAPPER_FAKE_SUBCLASS(StepStart, Message)
289 public:
290  static StepStartMessagePtr create(const ObjectPtr & source, bool active, Format format,
291  quint64 amount, double rate, bool flush, bool intermediate);
292  bool isActive() const;
293  Format format() const;
294  quint64 amount() const;
295  double rate() const;
296  bool isFlushingStep() const;
297  bool isIntermediateStep() const;
298 };
299 
303 class QTGSTREAMER_EXPORT QosMessage : public Message
304 {
305  QGST_WRAPPER_FAKE_SUBCLASS(Qos, Message)
306 public:
307  static QosMessagePtr create(const ObjectPtr & source, bool live, quint64 runningTime,
308  quint64 streamTime, quint64 timestamp, quint64 duration);
309 
310  bool live() const;
311  quint64 runningTime() const;
312  quint64 streamTime() const;
313  quint64 timestamp() const;
314  quint64 duration() const;
315 
316  qint64 jitter() const;
317  double proportion() const;
318  int quality() const;
319  void setValues(qint64 jitter, double proportion, int quality);
320 
321  Format format() const;
322  quint64 processed() const;
323  quint64 dropped() const;
324  void setStats(Format format, quint64 processed, quint64 dropped);
325 };
326 
327 } //namespace QGst
328 
329 QGST_REGISTER_TYPE(QGst::Message)
330 QGST_REGISTER_SUBCLASS(Message, Eos)
331 QGST_REGISTER_SUBCLASS(Message, Error)
332 QGST_REGISTER_SUBCLASS(Message, Warning)
333 QGST_REGISTER_SUBCLASS(Message, Info)
334 QGST_REGISTER_SUBCLASS(Message, Tag)
335 QGST_REGISTER_SUBCLASS(Message, Buffering)
336 QGST_REGISTER_SUBCLASS(Message, StateChanged)
337 QGST_REGISTER_SUBCLASS(Message, StepDone)
338 QGST_REGISTER_SUBCLASS(Message, StreamStatus)
339 QGST_REGISTER_SUBCLASS(Message, Application)
340 QGST_REGISTER_SUBCLASS(Message, Element)
341 QGST_REGISTER_SUBCLASS(Message, SegmentDone)
342 QGST_REGISTER_SUBCLASS(Message, Duration)
343 QGST_REGISTER_SUBCLASS(Message, Latency)
344 QGST_REGISTER_SUBCLASS(Message, AsyncDone)
345 QGST_REGISTER_SUBCLASS(Message, RequestState)
346 QGST_REGISTER_SUBCLASS(Message, StepStart)
347 QGST_REGISTER_SUBCLASS(Message, Qos)
348 
349 #endif