2 ******************************************************************************
4 * @file pipelineevent.h
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
7 * @see The GNU Public License (GPL) Version 3
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #ifndef PIPELINEEVENT_H_
28 #define PIPELINEEVENT_H_
36 class PipelineEvent
: public QEvent
{
39 static const QEvent::Type PrepareWindowId
;
40 static const QEvent::Type StateChange
;
41 static const QEvent::Type StreamStatus
;
42 static const QEvent::Type NewClock
;
43 static const QEvent::Type ClockProvide
;
44 static const QEvent::Type ClockLost
;
45 static const QEvent::Type Progress
;
46 static const QEvent::Type Latency
;
47 static const QEvent::Type Qos
;
48 static const QEvent::Type Eos
;
49 static const QEvent::Type Error
;
50 static const QEvent::Type Warning
;
51 static const QEvent::Type Info
;
53 PipelineEvent(QEvent::Type type
, QString src
) :
54 QEvent(type
), src(src
)
56 virtual ~PipelineEvent()
62 const QEvent::Type
PipelineEvent::PrepareWindowId
= static_cast<QEvent::Type
>(QEvent::registerEventType());
63 const QEvent::Type
PipelineEvent::StateChange
= static_cast<QEvent::Type
>(QEvent::registerEventType());
64 const QEvent::Type
PipelineEvent::StreamStatus
= static_cast<QEvent::Type
>(QEvent::registerEventType());
65 const QEvent::Type
PipelineEvent::NewClock
= static_cast<QEvent::Type
>(QEvent::registerEventType());
66 const QEvent::Type
PipelineEvent::ClockProvide
= static_cast<QEvent::Type
>(QEvent::registerEventType());
67 const QEvent::Type
PipelineEvent::ClockLost
= static_cast<QEvent::Type
>(QEvent::registerEventType());
68 const QEvent::Type
PipelineEvent::Progress
= static_cast<QEvent::Type
>(QEvent::registerEventType());
69 const QEvent::Type
PipelineEvent::Latency
= static_cast<QEvent::Type
>(QEvent::registerEventType());
70 const QEvent::Type
PipelineEvent::Qos
= static_cast<QEvent::Type
>(QEvent::registerEventType());
71 const QEvent::Type
PipelineEvent::Eos
= static_cast<QEvent::Type
>(QEvent::registerEventType());
72 const QEvent::Type
PipelineEvent::Error
= static_cast<QEvent::Type
>(QEvent::registerEventType());
73 const QEvent::Type
PipelineEvent::Warning
= static_cast<QEvent::Type
>(QEvent::registerEventType());
74 const QEvent::Type
PipelineEvent::Info
= static_cast<QEvent::Type
>(QEvent::registerEventType());
76 class PrepareWindowIdEvent
: public PipelineEvent
{
78 PrepareWindowIdEvent(QString src
, Overlay
*overlay
) :
79 PipelineEvent(PrepareWindowId
, src
), overlay(overlay
)
85 static QEvent::Type
type()
87 return PrepareWindowId
;
93 class StateChangedEvent
: public PipelineEvent
{
95 StateChangedEvent(QString src
, Pipeline::State oldState
, Pipeline::State newState
, Pipeline::State pendingState
) :
96 PipelineEvent(StateChange
, src
), oldState(oldState
), newState(newState
), pendingState(pendingState
)
98 static QEvent::Type
type()
102 Pipeline::State
getOldState()
106 Pipeline::State
getNewState()
110 Pipeline::State
getPendingState()
114 static const char *stateName(Pipeline::State state
)
117 case Pipeline::VoidPending
:
118 return "VoidPending";
123 case Pipeline::Ready
:
126 case Pipeline::Paused
:
129 case Pipeline::Playing
:
135 Pipeline::State oldState
;
136 Pipeline::State newState
;
137 Pipeline::State pendingState
;
140 class StreamStatusEvent
: public PipelineEvent
{
142 enum StreamStatusType
{
143 Create
, Enter
, Leave
, Destroy
, Start
, Pause
, Stop
, Null
145 StreamStatusEvent(QString src
, StreamStatusType status
, QString owner
) :
146 PipelineEvent(StreamStatus
, src
), status(status
), owner(owner
)
148 static QEvent::Type
type()
152 StreamStatusType
getStatus()
156 const char *getStatusName()
158 return statusName(status
);
160 static const char *statusName(StreamStatusType status
)
163 case StreamStatusEvent::Create
:
166 case StreamStatusEvent::Enter
:
169 case StreamStatusEvent::Leave
:
172 case StreamStatusEvent::Destroy
:
175 case StreamStatusEvent::Start
:
178 case StreamStatusEvent::Pause
:
181 case StreamStatusEvent::Stop
:
184 case StreamStatusEvent::Null
:
194 StreamStatusType status
;
198 class ClockEvent
: public PipelineEvent
{
200 ClockEvent(QEvent::Type type
, QString src
, QString name
) : PipelineEvent(type
, src
), name(name
)
210 class NewClockEvent
: public ClockEvent
{
212 NewClockEvent(QString src
, QString name
) : ClockEvent(NewClock
, src
, name
)
214 static QEvent::Type
type()
220 class ClockProvideEvent
: public ClockEvent
{
222 ClockProvideEvent(QString src
, QString name
, bool ready
) : ClockEvent(ClockProvide
, src
, name
), ready(ready
)
224 static QEvent::Type
type()
237 class ClockLostEvent
: public ClockEvent
{
239 ClockLostEvent(QString src
, QString name
) : ClockEvent(ClockLost
, src
, name
)
241 static QEvent::Type
type()
247 class ProgressEvent
: public PipelineEvent
{
250 Start
, Continue
, Complete
, Cancelled
, Error
253 ProgressEvent(QString src
, ProgressType progressType
, QString code
, QString text
) :
254 PipelineEvent(Progress
, src
), progressType(progressType
), code(code
), text(text
)
256 static QEvent::Type
type()
260 ProgressType
getProgressType()
273 ProgressType progressType
;
278 class LatencyEvent
: public PipelineEvent
{
280 LatencyEvent(QString src
) :
281 PipelineEvent(Latency
, src
)
283 static QEvent::Type
type()
291 // timestamps and live status
292 // If the message was generated by a live element
294 // running_time, stream_time, timestamp and duration of the dropped buffer.
295 // Values of GST_CLOCK_TIME_NONE mean unknown values.
296 quint64 running_time
;
302 // The difference of the running-time against the deadline.
304 // Long term prediction of the ideal rate relative to normal rate to get optimal quality.
305 qreal proportion
; // won't work on ARM?
306 // An element dependent integer value that specifies the current quality level of the element.
307 // The default maximum quality is 1000000.
311 // QoS stats representing the history of the current continuous pipeline playback period.
312 // When format is GST_FORMAT_UNDEFINED both dropped and processed are invalid.
313 // Values of -1 for either processed or dropped mean unknown values.
315 // Units of the 'processed' and 'dropped' fields.
316 // Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
317 // Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT (samples)
319 // Total number of units correctly processed since the last state change to READY or a flushing operation.
321 // Total number of units dropped since the last state change to READY or a flushing operation.
326 return QString("live: %0; running time: %1; stream time: %2; timestamp: %3; duration: %4").arg(live
).arg(
327 running_time
).arg(stream_time
).arg(timestamp
).arg(duration
);
331 return QString("jitter: %0; proportion: %1; quality: %2;").arg(jitter
).arg(proportion
).arg(quality
);
335 return QString("format: %0; processed: %1; dropped: %2;").arg("").arg(processed
).arg(dropped
);
339 class QosEvent
: public PipelineEvent
{
341 QosEvent(QString src
, QosData data
) : PipelineEvent(Qos
, src
), data(data
)
343 static QEvent::Type
type()
355 class EosEvent
: public PipelineEvent
{
357 EosEvent(QString src
) : PipelineEvent(Eos
, src
)
359 static QEvent::Type
type()
365 class MessageEvent
: public PipelineEvent
{
367 MessageEvent(QEvent::Type type
, QString src
, QString message
, QString debug
) :
368 PipelineEvent(type
, src
), message(message
), debug(debug
)
383 class ErrorEvent
: public MessageEvent
{
385 ErrorEvent(QString src
, QString message
, QString debug
) : MessageEvent(Error
, src
, message
, debug
)
387 static QEvent::Type
type()
393 class WarningEvent
: public MessageEvent
{
395 WarningEvent(QString src
, QString message
, QString debug
) : MessageEvent(Warning
, src
, message
, debug
)
397 static QEvent::Type
type()
403 class InfoEvent
: public MessageEvent
{
405 InfoEvent(QString src
, QString message
, QString debug
) : MessageEvent(Info
, src
, message
, debug
)
407 static QEvent::Type
type()
413 #endif /* PIPELINEEVENT_H_ */