diff options
-rw-r--r-- | docs/gst/gstreamer-sections.txt | 5 | ||||
-rw-r--r-- | gst/gst.c | 2 | ||||
-rw-r--r-- | gst/gstevent.c | 78 | ||||
-rw-r--r-- | gst/gstevent.h | 32 | ||||
-rw-r--r-- | tests/check/gst/gstevent.c | 20 | ||||
-rw-r--r-- | win32/common/libgstreamer.def | 3 |
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 | |||
@@ -796,8 +796,11 @@ gst_event_parse_tag | |||
796 | gst_event_new_buffer_size | 796 | gst_event_new_buffer_size |
797 | gst_event_parse_buffer_size | 797 | gst_event_parse_buffer_size |
798 | 798 | ||
799 | GstQOSType | ||
799 | gst_event_new_qos | 800 | gst_event_new_qos |
801 | gst_event_new_qos_full | ||
800 | gst_event_parse_qos | 802 | gst_event_parse_qos |
803 | gst_event_parse_qos_full | ||
801 | 804 | ||
802 | GstSeekType | 805 | GstSeekType |
803 | GstSeekFlags | 806 | GstSeekFlags |
@@ -826,6 +829,7 @@ GST_TYPE_EVENT | |||
826 | GST_TYPE_EVENT_TYPE | 829 | GST_TYPE_EVENT_TYPE |
827 | GST_TYPE_SEEK_TYPE | 830 | GST_TYPE_SEEK_TYPE |
828 | GST_TYPE_SEEK_FLAGS | 831 | GST_TYPE_SEEK_FLAGS |
832 | GST_TYPE_QOS_TYPE | ||
829 | GST_TYPE_EVENT_TYPE_FLAGS | 833 | GST_TYPE_EVENT_TYPE_FLAGS |
830 | <SUBSECTION Private> | 834 | <SUBSECTION Private> |
831 | GST_EVENT_TYPE_SHIFT | 835 | GST_EVENT_TYPE_SHIFT |
@@ -834,6 +838,7 @@ gst_event_get_type | |||
834 | gst_event_type_get_type | 838 | gst_event_type_get_type |
835 | gst_seek_type_get_type | 839 | gst_seek_type_get_type |
836 | gst_seek_flags_get_type | 840 | gst_seek_flags_get_type |
841 | gst_qos_type_get_type | ||
837 | gst_event_type_flags_get_type | 842 | gst_event_type_flags_get_type |
838 | </SECTION> | 843 | </SECTION> |
839 | 844 | ||
@@ -705,6 +705,7 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data, | |||
705 | g_type_class_ref (gst_event_type_get_type ()); | 705 | g_type_class_ref (gst_event_type_get_type ()); |
706 | g_type_class_ref (gst_seek_type_get_type ()); | 706 | g_type_class_ref (gst_seek_type_get_type ()); |
707 | g_type_class_ref (gst_seek_flags_get_type ()); | 707 | g_type_class_ref (gst_seek_flags_get_type ()); |
708 | g_type_class_ref (gst_qos_type_get_type ()); | ||
708 | g_type_class_ref (gst_format_get_type ()); | 709 | g_type_class_ref (gst_format_get_type ()); |
709 | g_type_class_ref (gst_index_certainty_get_type ()); | 710 | g_type_class_ref (gst_index_certainty_get_type ()); |
710 | g_type_class_ref (gst_index_entry_type_get_type ()); | 711 | g_type_class_ref (gst_index_entry_type_get_type ()); |
@@ -1071,6 +1072,7 @@ gst_deinit (void) | |||
1071 | g_type_class_unref (g_type_class_peek (gst_event_type_get_type ())); | 1072 | g_type_class_unref (g_type_class_peek (gst_event_type_get_type ())); |
1072 | g_type_class_unref (g_type_class_peek (gst_seek_type_get_type ())); | 1073 | g_type_class_unref (g_type_class_peek (gst_seek_type_get_type ())); |
1073 | g_type_class_unref (g_type_class_peek (gst_seek_flags_get_type ())); | 1074 | g_type_class_unref (g_type_class_peek (gst_seek_flags_get_type ())); |
1075 | g_type_class_unref (g_type_class_peek (gst_qos_type_get_type ())); | ||
1074 | g_type_class_unref (g_type_class_peek (gst_format_get_type ())); | 1076 | g_type_class_unref (g_type_class_peek (gst_format_get_type ())); |
1075 | g_type_class_unref (g_type_class_peek (gst_index_certainty_get_type ())); | 1077 | g_type_class_unref (g_type_class_peek (gst_index_certainty_get_type ())); |
1076 | g_type_class_unref (g_type_class_peek (gst_index_entry_type_get_type ())); | 1078 | g_type_class_unref (g_type_class_peek (gst_index_entry_type_get_type ())); |
diff --git a/gst/gstevent.c b/gst/gstevent.c index c407fedb17..07414c7fa4 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c | |||
@@ -799,11 +799,47 @@ gst_event_parse_buffer_size (GstEvent * event, GstFormat * format, | |||
799 | * @diff: The time difference of the last Clock sync | 799 | * @diff: The time difference of the last Clock sync |
800 | * @timestamp: The timestamp of the buffer | 800 | * @timestamp: The timestamp of the buffer |
801 | * | 801 | * |
802 | * Allocate a new qos event with the given values. This function calls | ||
803 | * gst_event_new_qos_full() with the type set to #GST_QOS_TYPE_OVERFLOW | ||
804 | * when diff is negative (buffers are in time) and #GST_QOS_TYPE_UNDERFLOW | ||
805 | * when @diff is positive (buffers are late). | ||
806 | * | ||
807 | * Returns: (transfer full): a new QOS event. | ||
808 | */ | ||
809 | GstEvent * | ||
810 | gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff, | ||
811 | GstClockTime timestamp) | ||
812 | { | ||
813 | GstQOSType type; | ||
814 | |||
815 | if (diff <= 0) | ||
816 | type = GST_QOS_TYPE_OVERFLOW; | ||
817 | else | ||
818 | type = GST_QOS_TYPE_UNDERFLOW; | ||
819 | |||
820 | return gst_event_new_qos_full (type, proportion, diff, timestamp); | ||
821 | } | ||
822 | |||
823 | /** | ||
824 | * gst_event_new_qos_full: | ||
825 | * @type: the QoS type | ||
826 | * @proportion: the proportion of the qos message | ||
827 | * @diff: The time difference of the last Clock sync | ||
828 | * @timestamp: The timestamp of the buffer | ||
829 | * | ||
802 | * Allocate a new qos event with the given values. | 830 | * Allocate a new qos event with the given values. |
803 | * The QOS event is generated in an element that wants an upstream | 831 | * The QOS event is generated in an element that wants an upstream |
804 | * element to either reduce or increase its rate because of | 832 | * element to either reduce or increase its rate because of |
805 | * high/low CPU load or other resource usage such as network performance. | 833 | * high/low CPU load or other resource usage such as network performance or |
806 | * Typically sinks generate these events for each buffer they receive. | 834 | * throttling. Typically sinks generate these events for each buffer |
835 | * they receive. | ||
836 | * | ||
837 | * @type indicates the reason for the QoS event. #GST_QOS_TYPE_OVERFLOW is | ||
838 | * used when a buffer arrived in time or when the sink cannot keep up with | ||
839 | * the upstream datarate. #GST_QOS_TYPE_UNDERFLOW is when the sink is not | ||
840 | * receiving buffers fast enough and thus has to drop late buffers. | ||
841 | * #GST_QOS_TYPE_THROTTLE is used when the datarate is artificially limited | ||
842 | * by the application, for example to reduce power consumption. | ||
807 | * | 843 | * |
808 | * @proportion indicates the real-time performance of the streaming in the | 844 | * @proportion indicates the real-time performance of the streaming in the |
809 | * element that generated the QoS event (usually the sink). The value is | 845 | * element that generated the QoS event (usually the sink). The value is |
@@ -818,7 +854,8 @@ gst_event_parse_buffer_size (GstEvent * event, GstFormat * format, | |||
818 | * @diff is the difference against the clock in running time of the last | 854 | * @diff is the difference against the clock in running time of the last |
819 | * buffer that caused the element to generate the QOS event. A negative value | 855 | * buffer that caused the element to generate the QOS event. A negative value |
820 | * means that the buffer with @timestamp arrived in time. A positive value | 856 | * means that the buffer with @timestamp arrived in time. A positive value |
821 | * indicates how late the buffer with @timestamp was. | 857 | * indicates how late the buffer with @timestamp was. When throttling is |
858 | * enabled, @diff will be set to the requested throttling interval. | ||
822 | * | 859 | * |
823 | * @timestamp is the timestamp of the last buffer that cause the element | 860 | * @timestamp is the timestamp of the last buffer that cause the element |
824 | * to generate the QOS event. It is expressed in running time and thus an ever | 861 | * to generate the QOS event. It is expressed in running time and thus an ever |
@@ -834,10 +871,12 @@ gst_event_parse_buffer_size (GstEvent * event, GstFormat * format, | |||
834 | * event and implement custom application specific QoS handling. | 871 | * event and implement custom application specific QoS handling. |
835 | * | 872 | * |
836 | * Returns: (transfer full): a new QOS event. | 873 | * Returns: (transfer full): a new QOS event. |
874 | * | ||
875 | * Since: 0.10.33 | ||
837 | */ | 876 | */ |
838 | GstEvent * | 877 | GstEvent * |
839 | gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff, | 878 | gst_event_new_qos_full (GstQOSType type, gdouble proportion, |
840 | GstClockTime timestamp) | 879 | GstClockTimeDiff diff, GstClockTime timestamp) |
841 | { | 880 | { |
842 | GstEvent *event; | 881 | GstEvent *event; |
843 | GstStructure *structure; | 882 | GstStructure *structure; |
@@ -846,11 +885,12 @@ gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff, | |||
846 | g_return_val_if_fail (diff >= 0 || -diff <= timestamp, NULL); | 885 | g_return_val_if_fail (diff >= 0 || -diff <= timestamp, NULL); |
847 | 886 | ||
848 | GST_CAT_INFO (GST_CAT_EVENT, | 887 | GST_CAT_INFO (GST_CAT_EVENT, |
849 | "creating qos proportion %lf, diff %" G_GINT64_FORMAT | 888 | "creating qos type %d, proportion %lf, diff %" G_GINT64_FORMAT |
850 | ", timestamp %" GST_TIME_FORMAT, proportion, | 889 | ", timestamp %" GST_TIME_FORMAT, type, proportion, |
851 | diff, GST_TIME_ARGS (timestamp)); | 890 | diff, GST_TIME_ARGS (timestamp)); |
852 | 891 | ||
853 | structure = gst_structure_id_new (GST_QUARK (EVENT_QOS), | 892 | structure = gst_structure_id_new (GST_QUARK (EVENT_QOS), |
893 | GST_QUARK (TYPE), GST_TYPE_QOS_TYPE, type, | ||
854 | GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion, | 894 | GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion, |
855 | GST_QUARK (DIFF), G_TYPE_INT64, diff, | 895 | GST_QUARK (DIFF), G_TYPE_INT64, diff, |
856 | GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp, NULL); | 896 | GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp, NULL); |
@@ -873,12 +913,36 @@ void | |||
873 | gst_event_parse_qos (GstEvent * event, gdouble * proportion, | 913 | gst_event_parse_qos (GstEvent * event, gdouble * proportion, |
874 | GstClockTimeDiff * diff, GstClockTime * timestamp) | 914 | GstClockTimeDiff * diff, GstClockTime * timestamp) |
875 | { | 915 | { |
916 | gst_event_parse_qos_full (event, NULL, proportion, diff, timestamp); | ||
917 | } | ||
918 | |||
919 | /** | ||
920 | * gst_event_parse_qos_full: | ||
921 | * @event: The event to query | ||
922 | * @type: (out): A pointer to store the QoS type in | ||
923 | * @proportion: (out): A pointer to store the proportion in | ||
924 | * @diff: (out): A pointer to store the diff in | ||
925 | * @timestamp: (out): A pointer to store the timestamp in | ||
926 | * | ||
927 | * Get the type, proportion, diff and timestamp in the qos event. See | ||
928 | * gst_event_new_qos_full() for more information about the different QoS values. | ||
929 | * | ||
930 | * Since: 0.10.33 | ||
931 | */ | ||
932 | void | ||
933 | gst_event_parse_qos_full (GstEvent * event, GstQOSType * type, | ||
934 | gdouble * proportion, GstClockTimeDiff * diff, GstClockTime * timestamp) | ||
935 | { | ||
876 | const GstStructure *structure; | 936 | const GstStructure *structure; |
877 | 937 | ||
878 | g_return_if_fail (GST_IS_EVENT (event)); | 938 | g_return_if_fail (GST_IS_EVENT (event)); |
879 | g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_QOS); | 939 | g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_QOS); |
880 | 940 | ||
881 | structure = event->structure; | 941 | structure = event->structure; |
942 | if (type) | ||
943 | *type = | ||
944 | g_value_get_enum (gst_structure_id_get_value (structure, | ||
945 | GST_QUARK (TYPE))); | ||
882 | if (proportion) | 946 | if (proportion) |
883 | *proportion = | 947 | *proportion = |
884 | g_value_get_double (gst_structure_id_get_value (structure, | 948 | g_value_get_double (gst_structure_id_get_value (structure, |
diff --git a/gst/gstevent.h b/gst/gstevent.h index 9568514866..34983b679b 100644 --- a/gst/gstevent.h +++ b/gst/gstevent.h | |||
@@ -94,8 +94,8 @@ typedef enum { | |||
94 | * send messages that should be emitted in sync with | 94 | * send messages that should be emitted in sync with |
95 | * rendering. | 95 | * rendering. |
96 | * @GST_EVENT_QOS: A quality message. Used to indicate to upstream elements | 96 | * @GST_EVENT_QOS: A quality message. Used to indicate to upstream elements |
97 | * that the downstream elements are being starved of or | 97 | * that the downstream elements should adjust their processing |
98 | * flooded with data. | 98 | * rate. |
99 | * @GST_EVENT_SEEK: A request for a new playback position and rate. | 99 | * @GST_EVENT_SEEK: A request for a new playback position and rate. |
100 | * @GST_EVENT_NAVIGATION: Navigation events are usually used for communicating | 100 | * @GST_EVENT_NAVIGATION: Navigation events are usually used for communicating |
101 | * user requests, such as mouse or keyboard movements, | 101 | * user requests, such as mouse or keyboard movements, |
@@ -309,6 +309,29 @@ typedef enum { | |||
309 | } GstSeekFlags; | 309 | } GstSeekFlags; |
310 | 310 | ||
311 | /** | 311 | /** |
312 | * GstQOSType: | ||
313 | * @GST_QOS_TYPE_OVERFLOW: The QoS event type that is produced when downstream | ||
314 | * elements are producing data too quickly and the element can't keep up | ||
315 | * processing the data. Upstream should reduce their processing rate. This | ||
316 | * type is also used when buffers arrive early or in time. | ||
317 | * @GST_QOS_TYPE_UNDERFLOW: The QoS event type that is produced when downstream | ||
318 | * elements are producing data too slowly and need to speed up their processing | ||
319 | * rate. | ||
320 | * @GST_QOS_TYPE_THROTTLE: The QoS event type that is produced when the | ||
321 | * application enabled throttling to limit the datarate. | ||
322 | * | ||
323 | * The different types of QoS events that can be given to the | ||
324 | * gst_event_new_qos_full() method. | ||
325 | * | ||
326 | * Since: 0.10.33 | ||
327 | */ | ||
328 | typedef enum { | ||
329 | GST_QOS_TYPE_OVERFLOW = 0, | ||
330 | GST_QOS_TYPE_UNDERFLOW = 1, | ||
331 | GST_QOS_TYPE_THROTTLE = 2 | ||
332 | } GstQOSType; | ||
333 | |||
334 | /** | ||
312 | * GstEvent: | 335 | * GstEvent: |
313 | * @mini_object: the parent structure | 336 | * @mini_object: the parent structure |
314 | * @type: the #GstEventType of the event | 337 | * @type: the #GstEventType of the event |
@@ -461,8 +484,13 @@ void gst_event_parse_buffer_size (GstEvent *event, GstFormat *for | |||
461 | /* QOS events */ | 484 | /* QOS events */ |
462 | GstEvent* gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff, | 485 | GstEvent* gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff, |
463 | GstClockTime timestamp); | 486 | GstClockTime timestamp); |
487 | GstEvent* gst_event_new_qos_full (GstQOSType type, gdouble proportion, | ||
488 | GstClockTimeDiff diff, GstClockTime timestamp); | ||
464 | void gst_event_parse_qos (GstEvent *event, gdouble *proportion, GstClockTimeDiff *diff, | 489 | void gst_event_parse_qos (GstEvent *event, gdouble *proportion, GstClockTimeDiff *diff, |
465 | GstClockTime *timestamp); | 490 | GstClockTime *timestamp); |
491 | void gst_event_parse_qos_full (GstEvent *event, GstQOSType *type, | ||
492 | gdouble *proportion, GstClockTimeDiff *diff, | ||
493 | GstClockTime *timestamp); | ||
466 | /* seek event */ | 494 | /* seek event */ |
467 | GstEvent* gst_event_new_seek (gdouble rate, GstFormat format, GstSeekFlags flags, | 495 | GstEvent* gst_event_new_seek (gdouble rate, GstFormat format, GstSeekFlags flags, |
468 | GstSeekType start_type, gint64 start, | 496 | GstSeekType start_type, gint64 start, |
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 | |||
@@ -138,6 +138,7 @@ GST_START_TEST (create_events) | |||
138 | 138 | ||
139 | /* QOS */ | 139 | /* QOS */ |
140 | { | 140 | { |
141 | GstQOSType t1 = GST_QOS_TYPE_THROTTLE, t2; | ||
141 | gdouble p1 = 1.0, p2; | 142 | gdouble p1 = 1.0, p2; |
142 | GstClockTimeDiff ctd1 = G_GINT64_CONSTANT (10), ctd2; | 143 | GstClockTimeDiff ctd1 = G_GINT64_CONSTANT (10), ctd2; |
143 | GstClockTime ct1 = G_GUINT64_CONSTANT (20), ct2; | 144 | GstClockTime ct1 = G_GUINT64_CONSTANT (20), ct2; |
@@ -153,6 +154,25 @@ GST_START_TEST (create_events) | |||
153 | fail_unless (p1 == p2); | 154 | fail_unless (p1 == p2); |
154 | fail_unless (ctd1 == ctd2); | 155 | fail_unless (ctd1 == ctd2); |
155 | fail_unless (ct1 == ct2); | 156 | fail_unless (ct1 == ct2); |
157 | gst_event_parse_qos_full (event, &t2, &p2, &ctd2, &ct2); | ||
158 | fail_unless (t2 == GST_QOS_TYPE_UNDERFLOW); | ||
159 | fail_unless (p1 == p2); | ||
160 | fail_unless (ctd1 == ctd2); | ||
161 | fail_unless (ct1 == ct2); | ||
162 | gst_event_unref (event); | ||
163 | |||
164 | ctd1 = G_GINT64_CONSTANT (-10); | ||
165 | event = gst_event_new_qos (p1, ctd1, ct1); | ||
166 | gst_event_parse_qos_full (event, &t2, &p2, &ctd2, &ct2); | ||
167 | fail_unless (t2 == GST_QOS_TYPE_OVERFLOW); | ||
168 | gst_event_unref (event); | ||
169 | |||
170 | event = gst_event_new_qos_full (t1, p1, ctd1, ct1); | ||
171 | gst_event_parse_qos_full (event, &t2, &p2, &ctd2, &ct2); | ||
172 | fail_unless (t2 == GST_QOS_TYPE_THROTTLE); | ||
173 | fail_unless (p1 == p2); | ||
174 | fail_unless (ctd1 == ctd2); | ||
175 | fail_unless (ct1 == ct2); | ||
156 | gst_event_unref (event); | 176 | gst_event_unref (event); |
157 | } | 177 | } |
158 | 178 | ||
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 | |||
@@ -392,6 +392,7 @@ EXPORTS | |||
392 | gst_event_new_new_segment | 392 | gst_event_new_new_segment |
393 | gst_event_new_new_segment_full | 393 | gst_event_new_new_segment_full |
394 | gst_event_new_qos | 394 | gst_event_new_qos |
395 | gst_event_new_qos_full | ||
395 | gst_event_new_seek | 396 | gst_event_new_seek |
396 | gst_event_new_sink_message | 397 | gst_event_new_sink_message |
397 | gst_event_new_step | 398 | gst_event_new_step |
@@ -401,6 +402,7 @@ EXPORTS | |||
401 | gst_event_parse_new_segment | 402 | gst_event_parse_new_segment |
402 | gst_event_parse_new_segment_full | 403 | gst_event_parse_new_segment_full |
403 | gst_event_parse_qos | 404 | gst_event_parse_qos |
405 | gst_event_parse_qos_full | ||
404 | gst_event_parse_seek | 406 | gst_event_parse_seek |
405 | gst_event_parse_sink_message | 407 | gst_event_parse_sink_message |
406 | gst_event_parse_step | 408 | gst_event_parse_step |
@@ -812,6 +814,7 @@ EXPORTS | |||
812 | gst_print_element_args | 814 | gst_print_element_args |
813 | gst_print_pad_caps | 815 | gst_print_pad_caps |
814 | gst_proxy_pad_get_type | 816 | gst_proxy_pad_get_type |
817 | gst_qos_type_get_type | ||
815 | gst_query_add_buffering_range | 818 | gst_query_add_buffering_range |
816 | gst_query_get_n_buffering_ranges | 819 | gst_query_get_n_buffering_ranges |
817 | gst_query_get_structure | 820 | gst_query_get_structure |