From 5037b39883ca615ba7b68f378f8836af85cb60d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 7 Dec 2011 17:57:08 +0000 Subject: [PATCH] video: add seqnum getters for overlay compositions and rectangles API: gst_video_overlay_composition_get_seqnum() API: gst_video_overlay_rectangle_get_seqnum() --- gst-libs/gst/video/video-overlay-composition.c | 42 ++++++++++++++++++++++++++ gst-libs/gst/video/video-overlay-composition.h | 4 +++ tests/check/libs/video.c | 9 ++++++ win32/common/libgstvideo.def | 2 ++ 4 files changed, 57 insertions(+) diff --git a/gst-libs/gst/video/video-overlay-composition.c b/gst-libs/gst/video/video-overlay-composition.c index d5ed836..3cc289c 100644 --- a/gst-libs/gst/video/video-overlay-composition.c +++ b/gst-libs/gst/video/video-overlay-composition.c @@ -602,6 +602,27 @@ copy: return writable_comp; } +/** + * gst_video_overlay_composition_get_seqnum: + * @comp: a #GstVideoOverlayComposition + * + * Returns the sequence number of this composition. Sequence numbers are + * monotonically increasing and unique for overlay compositions and rectangles + * (meaning there will never be a rectangle with the same sequence number as + * a composition). + * + * Returns: the sequence number of @comp + * + * Since: 0.10.36 + */ +guint +gst_video_overlay_composition_get_seqnum (GstVideoOverlayComposition * comp) +{ + g_return_val_if_fail (GST_IS_VIDEO_OVERLAY_COMPOSITION (comp), 0); + + return comp->seq_num; +} + /* ------------------------------ rectangles ------------------------------ -*/ static void gst_video_overlay_rectangle_instance_init (GstMiniObject * miniobj); @@ -958,3 +979,24 @@ gst_video_overlay_rectangle_copy (GstVideoOverlayRectangle * rectangle) return copy; } + +/** + * gst_video_overlay_rectangle_get_seqnum: + * @rectangle: a #GstVideoOverlayRectangle + * + * Returns the sequence number of this rectangle. Sequence numbers are + * monotonically increasing and unique for overlay compositions and rectangles + * (meaning there will never be a rectangle with the same sequence number as + * a composition). + * + * Returns: the sequence number of @rectangle + * + * Since: 0.10.36 + */ +guint +gst_video_overlay_rectangle_get_seqnum (GstVideoOverlayRectangle * rectangle) +{ + g_return_val_if_fail (GST_IS_VIDEO_OVERLAY_RECTANGLE (rectangle), 0); + + return rectangle->seq_num; +} diff --git a/gst-libs/gst/video/video-overlay-composition.h b/gst-libs/gst/video/video-overlay-composition.h index 9b6c3ca..8e35efa 100644 --- a/gst-libs/gst/video/video-overlay-composition.h +++ b/gst-libs/gst/video/video-overlay-composition.h @@ -114,6 +114,8 @@ GstVideoOverlayRectangle * gst_video_overlay_rectangle_new_argb (GstBuffer * p GstVideoOverlayRectangle * gst_video_overlay_rectangle_copy (GstVideoOverlayRectangle * rectangle); +guint gst_video_overlay_rectangle_get_seqnum (GstVideoOverlayRectangle * rectangle); + void gst_video_overlay_rectangle_set_render_rectangle (GstVideoOverlayRectangle * rectangle, gint render_x, gint render_y, @@ -214,6 +216,8 @@ guint gst_video_overlay_composition_n_rectangles (GstVid GstVideoOverlayRectangle * gst_video_overlay_composition_get_rectangle (GstVideoOverlayComposition * comp, guint n); +guint gst_video_overlay_composition_get_seqnum (GstVideoOverlayComposition * comp); + /* blend composition onto raw video buffer */ void gst_video_overlay_composition_blend (GstVideoOverlayComposition * comp, diff --git a/tests/check/libs/video.c b/tests/check/libs/video.c index 18a6417..fd3178d 100644 --- a/tests/check/libs/video.c +++ b/tests/check/libs/video.c @@ -783,6 +783,7 @@ GST_START_TEST (test_overlay_composition) GstVideoOverlayComposition *comp1, *comp2; GstVideoOverlayRectangle *rect1, *rect2; GstBuffer *pix1, *pix2, *buf; + guint seq1, seq2; guint w, h, stride; gint x, y; @@ -800,6 +801,11 @@ GST_START_TEST (test_overlay_composition) fail_unless (gst_video_overlay_composition_get_rectangle (comp1, 0) == rect1); fail_unless (gst_video_overlay_composition_get_rectangle (comp1, 1) == NULL); + /* rectangle was created first, sequence number should be smaller */ + seq1 = gst_video_overlay_rectangle_get_seqnum (rect1); + seq2 = gst_video_overlay_composition_get_seqnum (comp1); + fail_unless (seq1 < seq2); + /* composition took own ref, so refcount is 2 now, so this should fail */ ASSERT_CRITICAL (gst_video_overlay_rectangle_set_render_rectangle (rect1, 50, 600, 300, 50)); @@ -813,6 +819,9 @@ GST_START_TEST (test_overlay_composition) fail_unless (gst_video_overlay_composition_get_rectangle (comp2, 0) == rect1); fail_unless (gst_video_overlay_composition_get_rectangle (comp2, 1) == NULL); + fail_unless (seq1 < gst_video_overlay_composition_get_seqnum (comp2)); + fail_unless (seq2 < gst_video_overlay_composition_get_seqnum (comp2)); + /* now refcount is 2 again because comp2 has also taken a ref, so must fail */ ASSERT_CRITICAL (gst_video_overlay_rectangle_set_render_rectangle (rect1, 0, 0, 1, 1)); diff --git a/win32/common/libgstvideo.def b/win32/common/libgstvideo.def index fee972a..dd6e2b0 100644 --- a/win32/common/libgstvideo.def +++ b/win32/common/libgstvideo.def @@ -39,6 +39,7 @@ EXPORTS gst_video_overlay_composition_blend gst_video_overlay_composition_copy gst_video_overlay_composition_get_rectangle + gst_video_overlay_composition_get_seqnum gst_video_overlay_composition_get_type gst_video_overlay_composition_make_writable gst_video_overlay_composition_n_rectangles @@ -47,6 +48,7 @@ EXPORTS gst_video_overlay_rectangle_get_pixels_argb gst_video_overlay_rectangle_get_pixels_unscaled_argb gst_video_overlay_rectangle_get_render_rectangle + gst_video_overlay_rectangle_get_seqnum gst_video_overlay_rectangle_get_type gst_video_overlay_rectangle_new_argb gst_video_overlay_rectangle_set_render_rectangle -- 2.7.4