summaryrefslogtreecommitdiff
path: root/gst/gstmessage.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst/gstmessage.c')
-rw-r--r--gst/gstmessage.c213
1 files changed, 213 insertions, 0 deletions
diff --git a/gst/gstmessage.c b/gst/gstmessage.c
index c30f738d32..3376d9a7fa 100644
--- a/gst/gstmessage.c
+++ b/gst/gstmessage.c
@@ -111,6 +111,7 @@ static GstMessageQuarks message_quarks[] = {
{GST_MESSAGE_ASYNC_DONE, "async-done", 0},
{GST_MESSAGE_REQUEST_STATE, "request-state", 0},
{GST_MESSAGE_STEP_START, "step-start", 0},
+ {GST_MESSAGE_QOS, "qos", 0},
{0, NULL, 0}
};
@@ -1793,3 +1794,215 @@ gst_message_parse_step_start (GstMessage * message, gboolean * active,
GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
}
+
+/**
+ * gst_message_new_qos:
+ * @src: The object originating the message.
+ * @live: if the message was generated by a live element
+ * @running_time: the running time of the buffer that generated the message
+ * @stream_time: the stream time of the buffer that generated the message
+ * @timestamp: the timestamps of the buffer that generated the message
+ * @duration: the duration of the buffer that generated the message
+ *
+ * A QOS message is posted on the bus whenever an element decides to:
+ *
+ * - drop a buffer because of QoS reasons
+ * - change its processing strategy because of QoS reasons (quality)
+ *
+ * This message can be posted by an element that performs synchronisation against the
+ * clock (live) or it could be dropped by an element that performs QoS because of QOS
+ * events received from a downstream element (!live).
+ *
+ * @running_time, @stream_time, @timestamp, @duration should be set to the
+ * respective running-time, stream-time, timestamp and duration of the (dropped)
+ * buffer that generated the QoS event. Values can be left to
+ * GST_CLOCK_TIME_NONE when unknown.
+ *
+ * Returns: The new qos message.
+ *
+ * MT safe.
+ *
+ * Since: 0.10.29
+ */
+GstMessage *
+gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
+ guint64 stream_time, guint64 timestamp, guint64 duration)
+{
+ GstMessage *message;
+ GstStructure *structure;
+
+ structure = gst_structure_id_new (GST_QUARK (MESSAGE_QOS),
+ GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
+ GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
+ GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
+ GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
+ GST_QUARK (DURATION), G_TYPE_UINT64, duration,
+ GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
+ GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
+ GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
+ GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
+ GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
+ GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
+ message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
+
+ return message;
+}
+
+/**
+ * gst_message_set_qos_values:
+ * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
+ * @jitter: The difference of the running-time against the deadline.
+ * @proportion: Long term prediction of the ideal rate relative to normal rate
+ * to get optimal quality.
+ * @quality: An element dependent integer value that specifies the current
+ * quality level of the element. The default maximum quality is 1000000.
+ *
+ * Set the QoS values that have been calculated/analysed from the QoS data
+ *
+ * MT safe.
+ *
+ * Since: 0.10.29
+ */
+void
+gst_message_set_qos_values (GstMessage * message, gint64 jitter,
+ gdouble proportion, gint quality)
+{
+ g_return_if_fail (GST_IS_MESSAGE (message));
+ g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
+
+ gst_structure_id_set (message->structure,
+ GST_QUARK (JITTER), G_TYPE_INT64, jitter,
+ GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
+ GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
+}
+
+/**
+ * gst_message_set_qos_stats:
+ * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
+ * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
+ * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
+ * will likely use GST_FORMAT_DEFAULT (samples).
+ * @processed: Total number of units correctly processed since the last state
+ * change to READY or a flushing operation.
+ * @dropped: Total number of units dropped since the last state change to READY
+ * or a flushing operation.
+ *
+ * Set the QoS stats representing the history of the current continuous pipeline
+ * playback period.
+ *
+ * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
+ * invalid. Values of -1 for either @processed or @dropped mean unknown values.
+ *
+ * MT safe.
+ *
+ * Since: 0.10.29
+ */
+void
+gst_message_set_qos_stats (GstMessage * message, GstFormat format,
+ guint64 processed, guint64 dropped)
+{
+ g_return_if_fail (GST_IS_MESSAGE (message));
+ g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
+
+ gst_structure_id_set (message->structure,
+ GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
+ GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
+ GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
+}
+
+/**
+ * gst_message_parse_qos:
+ * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
+ * @live: if the message was generated by a live element
+ * @running_time: the running time of the buffer that generated the message
+ * @stream_time: the stream time of the buffer that generated the message
+ * @timestamp: the timestamps of the buffer that generated the message
+ * @duration: the duration of the buffer that generated the message
+ *
+ * Extract the timestamps and live status from the QoS message.
+ *
+ * The returned values give the running_time, stream_time, timestamp and
+ * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
+ * values.
+ *
+ * MT safe.
+ *
+ * Since: 0.10.29
+ */
+void
+gst_message_parse_qos (GstMessage * message, gboolean * live,
+ guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
+ guint64 * duration)
+{
+ g_return_if_fail (GST_IS_MESSAGE (message));
+ g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
+
+ gst_structure_id_get (message->structure,
+ GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
+ GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
+ GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
+ GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
+ GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
+}
+
+/**
+ * gst_message_parse_qos_values:
+ * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
+ * @jitter: The difference of the running-time against the deadline.
+ * @proportion: Long term prediction of the ideal rate relative to normal rate
+ * to get optimal quality.
+ * @quality: An element dependent integer value that specifies the current
+ * quality level of the element. The default maximum quality is 1000000.
+ *
+ * Extract the QoS values that have been calculated/analysed from the QoS data
+ *
+ * MT safe.
+ *
+ * Since: 0.10.29
+ */
+void
+gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
+ gdouble * proportion, gint * quality)
+{
+ g_return_if_fail (GST_IS_MESSAGE (message));
+ g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
+
+ gst_structure_id_get (message->structure,
+ GST_QUARK (JITTER), G_TYPE_INT64, jitter,
+ GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
+ GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
+}
+
+/**
+ * gst_message_parse_qos_stats:
+ * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
+ * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
+ * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
+ * will likely use GST_FORMAT_DEFAULT (samples).
+ * @processed: Total number of units correctly processed since the last state
+ * change to READY or a flushing operation.
+ * @dropped: Total number of units dropped since the last state change to READY
+ * or a flushing operation.
+ *
+ * Extract the QoS stats representing the history of the current continuous
+ * pipeline playback period.
+ *
+ * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
+ * invalid. Values of -1 for either @processed or @dropped mean unknown values.
+ *
+ * MT safe.
+ *
+ * Since: 0.10.29
+ */
+void
+gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
+ guint64 * processed, guint64 * dropped)
+{
+ g_return_if_fail (GST_IS_MESSAGE (message));
+ g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
+
+ gst_structure_id_get (message->structure,
+ GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
+ GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
+ GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
+}