summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/gst/gstreamer-sections.txt5
-rw-r--r--gst/gst.c2
-rw-r--r--gst/gstevent.c78
-rw-r--r--gst/gstevent.h32
-rw-r--r--tests/check/gst/gstevent.c20
-rw-r--r--win32/common/libgstreamer.def3
6 files changed, 131 insertions, 9 deletions
diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt
index 5c731dc96a..139504861b 100644
--- a/docs/gst/gstreamer-sections.txt
+++ b/docs/gst/gstreamer-sections.txt
@@ -798,4 +798,7 @@ gst_event_parse_buffer_size
+GstQOSType
gst_event_new_qos
+gst_event_new_qos_full
gst_event_parse_qos
+gst_event_parse_qos_full
@@ -828,2 +831,3 @@ GST_TYPE_SEEK_TYPE
GST_TYPE_SEEK_FLAGS
+GST_TYPE_QOS_TYPE
GST_TYPE_EVENT_TYPE_FLAGS
@@ -836,2 +840,3 @@ gst_seek_type_get_type
gst_seek_flags_get_type
+gst_qos_type_get_type
gst_event_type_flags_get_type
diff --git a/gst/gst.c b/gst/gst.c
index 3bde138aa8..50de2c0efc 100644
--- a/gst/gst.c
+++ b/gst/gst.c
@@ -707,2 +707,3 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
g_type_class_ref (gst_seek_flags_get_type ());
+ g_type_class_ref (gst_qos_type_get_type ());
g_type_class_ref (gst_format_get_type ());
@@ -1073,2 +1074,3 @@ gst_deinit (void)
g_type_class_unref (g_type_class_peek (gst_seek_flags_get_type ()));
+ g_type_class_unref (g_type_class_peek (gst_qos_type_get_type ()));
g_type_class_unref (g_type_class_peek (gst_format_get_type ()));
diff --git a/gst/gstevent.c b/gst/gstevent.c
index c407fedb17..07414c7fa4 100644
--- a/gst/gstevent.c
+++ b/gst/gstevent.c
@@ -801,2 +801,30 @@ gst_event_parse_buffer_size (GstEvent * event, GstFormat * format,
*
+ * Allocate a new qos event with the given values. This function calls
+ * gst_event_new_qos_full() with the type set to #GST_QOS_TYPE_OVERFLOW
+ * when diff is negative (buffers are in time) and #GST_QOS_TYPE_UNDERFLOW
+ * when @diff is positive (buffers are late).
+ *
+ * Returns: (transfer full): a new QOS event.
+ */
+GstEvent *
+gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff,
+ GstClockTime timestamp)
+{
+ GstQOSType type;
+
+ if (diff <= 0)
+ type = GST_QOS_TYPE_OVERFLOW;
+ else
+ type = GST_QOS_TYPE_UNDERFLOW;
+
+ return gst_event_new_qos_full (type, proportion, diff, timestamp);
+}
+
+/**
+ * gst_event_new_qos_full:
+ * @type: the QoS type
+ * @proportion: the proportion of the qos message
+ * @diff: The time difference of the last Clock sync
+ * @timestamp: The timestamp of the buffer
+ *
* Allocate a new qos event with the given values.
@@ -804,4 +832,12 @@ gst_event_parse_buffer_size (GstEvent * event, GstFormat * format,
* element to either reduce or increase its rate because of
- * high/low CPU load or other resource usage such as network performance.
- * Typically sinks generate these events for each buffer they receive.
+ * high/low CPU load or other resource usage such as network performance or
+ * throttling. Typically sinks generate these events for each buffer
+ * they receive.
+ *
+ * @type indicates the reason for the QoS event. #GST_QOS_TYPE_OVERFLOW is
+ * used when a buffer arrived in time or when the sink cannot keep up with
+ * the upstream datarate. #GST_QOS_TYPE_UNDERFLOW is when the sink is not
+ * receiving buffers fast enough and thus has to drop late buffers.
+ * #GST_QOS_TYPE_THROTTLE is used when the datarate is artificially limited
+ * by the application, for example to reduce power consumption.
*
@@ -820,3 +856,4 @@ gst_event_parse_buffer_size (GstEvent * event, GstFormat * format,
* means that the buffer with @timestamp arrived in time. A positive value
- * indicates how late the buffer with @timestamp was.
+ * indicates how late the buffer with @timestamp was. When throttling is
+ * enabled, @diff will be set to the requested throttling interval.
*
@@ -836,6 +873,8 @@ gst_event_parse_buffer_size (GstEvent * event, GstFormat * format,
* Returns: (transfer full): a new QOS event.
+ *
+ * Since: 0.10.33
*/
GstEvent *
-gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff,
- GstClockTime timestamp)
+gst_event_new_qos_full (GstQOSType type, gdouble proportion,
+ GstClockTimeDiff diff, GstClockTime timestamp)
{
@@ -848,4 +887,4 @@ gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff,
GST_CAT_INFO (GST_CAT_EVENT,
- "creating qos proportion %lf, diff %" G_GINT64_FORMAT
- ", timestamp %" GST_TIME_FORMAT, proportion,
+ "creating qos type %d, proportion %lf, diff %" G_GINT64_FORMAT
+ ", timestamp %" GST_TIME_FORMAT, type, proportion,
diff, GST_TIME_ARGS (timestamp));
@@ -853,2 +892,3 @@ gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff,
structure = gst_structure_id_new (GST_QUARK (EVENT_QOS),
+ GST_QUARK (TYPE), GST_TYPE_QOS_TYPE, type,
GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
@@ -875,2 +915,22 @@ gst_event_parse_qos (GstEvent * event, gdouble * proportion,
{
+ gst_event_parse_qos_full (event, NULL, proportion, diff, timestamp);
+}
+
+/**
+ * gst_event_parse_qos_full:
+ * @event: The event to query
+ * @type: (out): A pointer to store the QoS type in
+ * @proportion: (out): A pointer to store the proportion in
+ * @diff: (out): A pointer to store the diff in
+ * @timestamp: (out): A pointer to store the timestamp in
+ *
+ * Get the type, proportion, diff and timestamp in the qos event. See
+ * gst_event_new_qos_full() for more information about the different QoS values.
+ *
+ * Since: 0.10.33
+ */
+void
+gst_event_parse_qos_full (GstEvent * event, GstQOSType * type,
+ gdouble * proportion, GstClockTimeDiff * diff, GstClockTime * timestamp)
+{
const GstStructure *structure;
@@ -881,2 +941,6 @@ gst_event_parse_qos (GstEvent * event, gdouble * proportion,
structure = event->structure;
+ if (type)
+ *type =
+ g_value_get_enum (gst_structure_id_get_value (structure,
+ GST_QUARK (TYPE)));
if (proportion)
diff --git a/gst/gstevent.h b/gst/gstevent.h
index 9568514866..34983b679b 100644
--- a/gst/gstevent.h
+++ b/gst/gstevent.h
@@ -96,4 +96,4 @@ typedef enum {
* @GST_EVENT_QOS: A quality message. Used to indicate to upstream elements
- * that the downstream elements are being starved of or
- * flooded with data.
+ * that the downstream elements should adjust their processing
+ * rate.
* @GST_EVENT_SEEK: A request for a new playback position and rate.
@@ -311,2 +311,25 @@ typedef enum {
/**
+ * GstQOSType:
+ * @GST_QOS_TYPE_OVERFLOW: The QoS event type that is produced when downstream
+ * elements are producing data too quickly and the element can't keep up
+ * processing the data. Upstream should reduce their processing rate. This
+ * type is also used when buffers arrive early or in time.
+ * @GST_QOS_TYPE_UNDERFLOW: The QoS event type that is produced when downstream
+ * elements are producing data too slowly and need to speed up their processing
+ * rate.
+ * @GST_QOS_TYPE_THROTTLE: The QoS event type that is produced when the
+ * application enabled throttling to limit the datarate.
+ *
+ * The different types of QoS events that can be given to the
+ * gst_event_new_qos_full() method.
+ *
+ * Since: 0.10.33
+ */
+typedef enum {
+ GST_QOS_TYPE_OVERFLOW = 0,
+ GST_QOS_TYPE_UNDERFLOW = 1,
+ GST_QOS_TYPE_THROTTLE = 2
+} GstQOSType;
+
+/**
* GstEvent:
@@ -463,4 +486,9 @@ GstEvent* gst_event_new_qos (gdouble proportion, GstClockTim
GstClockTime timestamp);
+GstEvent* gst_event_new_qos_full (GstQOSType type, gdouble proportion,
+ GstClockTimeDiff diff, GstClockTime timestamp);
void gst_event_parse_qos (GstEvent *event, gdouble *proportion, GstClockTimeDiff *diff,
GstClockTime *timestamp);
+void gst_event_parse_qos_full (GstEvent *event, GstQOSType *type,
+ gdouble *proportion, GstClockTimeDiff *diff,
+ GstClockTime *timestamp);
/* seek event */
diff --git a/tests/check/gst/gstevent.c b/tests/check/gst/gstevent.c
index 5a2ec2325c..8c0829aab4 100644
--- a/tests/check/gst/gstevent.c
+++ b/tests/check/gst/gstevent.c
@@ -140,2 +140,3 @@ GST_START_TEST (create_events)
{
+ GstQOSType t1 = GST_QOS_TYPE_THROTTLE, t2;
gdouble p1 = 1.0, p2;
@@ -155,2 +156,21 @@ GST_START_TEST (create_events)
fail_unless (ct1 == ct2);
+ gst_event_parse_qos_full (event, &t2, &p2, &ctd2, &ct2);
+ fail_unless (t2 == GST_QOS_TYPE_UNDERFLOW);
+ fail_unless (p1 == p2);
+ fail_unless (ctd1 == ctd2);
+ fail_unless (ct1 == ct2);
+ gst_event_unref (event);
+
+ ctd1 = G_GINT64_CONSTANT (-10);
+ event = gst_event_new_qos (p1, ctd1, ct1);
+ gst_event_parse_qos_full (event, &t2, &p2, &ctd2, &ct2);
+ fail_unless (t2 == GST_QOS_TYPE_OVERFLOW);
+ gst_event_unref (event);
+
+ event = gst_event_new_qos_full (t1, p1, ctd1, ct1);
+ gst_event_parse_qos_full (event, &t2, &p2, &ctd2, &ct2);
+ fail_unless (t2 == GST_QOS_TYPE_THROTTLE);
+ fail_unless (p1 == p2);
+ fail_unless (ctd1 == ctd2);
+ fail_unless (ct1 == ct2);
gst_event_unref (event);
diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def
index eef40ded4e..dd505908bf 100644
--- a/win32/common/libgstreamer.def
+++ b/win32/common/libgstreamer.def
@@ -394,2 +394,3 @@ EXPORTS
gst_event_new_qos
+ gst_event_new_qos_full
gst_event_new_seek
@@ -403,2 +404,3 @@ EXPORTS
gst_event_parse_qos
+ gst_event_parse_qos_full
gst_event_parse_seek
@@ -814,2 +816,3 @@ EXPORTS
gst_proxy_pad_get_type
+ gst_qos_type_get_type
gst_query_add_buffering_range