mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 00:01:23 +00:00
video-overlay-composition: Allow empty overlay compositions
Allowing to pass NULL to the constructor removes the need to special-case the first rectangle in calling code and generally simplifies application code. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1256>
This commit is contained in:
parent
535c02c73b
commit
a14f4f48c4
1 changed files with 9 additions and 12 deletions
|
@ -327,12 +327,14 @@ gst_video_overlay_composition_free (GstMiniObject * mini_obj)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_video_overlay_composition_new:
|
* gst_video_overlay_composition_new:
|
||||||
* @rectangle: (transfer none): a #GstVideoOverlayRectangle to add to the
|
* @rectangle: (transfer none) (nullable): a #GstVideoOverlayRectangle to add to the
|
||||||
* composition
|
* composition
|
||||||
*
|
*
|
||||||
* Creates a new video overlay composition object to hold one or more
|
* Creates a new video overlay composition object to hold one or more
|
||||||
* overlay rectangles.
|
* overlay rectangles.
|
||||||
*
|
*
|
||||||
|
* Note that since 1.20 this allows to pass %NULL for @rectangle.
|
||||||
|
*
|
||||||
* Returns: (transfer full): a new #GstVideoOverlayComposition. Unref with
|
* Returns: (transfer full): a new #GstVideoOverlayComposition. Unref with
|
||||||
* gst_video_overlay_composition_unref() when no longer needed.
|
* gst_video_overlay_composition_unref() when no longer needed.
|
||||||
*/
|
*/
|
||||||
|
@ -341,11 +343,8 @@ gst_video_overlay_composition_new (GstVideoOverlayRectangle * rectangle)
|
||||||
{
|
{
|
||||||
GstVideoOverlayComposition *comp;
|
GstVideoOverlayComposition *comp;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_VIDEO_OVERLAY_RECTANGLE (rectangle)
|
||||||
/* FIXME: should we allow empty compositions? Could also be expressed as
|
|| NULL, NULL);
|
||||||
* buffer without a composition on it. Maybe there are cases where doing
|
|
||||||
* an empty new + _add() in a loop is easier? */
|
|
||||||
g_return_val_if_fail (GST_IS_VIDEO_OVERLAY_RECTANGLE (rectangle), NULL);
|
|
||||||
|
|
||||||
comp = g_slice_new0 (GstVideoOverlayComposition);
|
comp = g_slice_new0 (GstVideoOverlayComposition);
|
||||||
|
|
||||||
|
@ -355,18 +354,16 @@ gst_video_overlay_composition_new (GstVideoOverlayRectangle * rectangle)
|
||||||
NULL, (GstMiniObjectFreeFunction) gst_video_overlay_composition_free);
|
NULL, (GstMiniObjectFreeFunction) gst_video_overlay_composition_free);
|
||||||
|
|
||||||
comp->rectangles = g_new0 (GstVideoOverlayRectangle *, RECTANGLE_ARRAY_STEP);
|
comp->rectangles = g_new0 (GstVideoOverlayRectangle *, RECTANGLE_ARRAY_STEP);
|
||||||
comp->rectangles[0] = gst_video_overlay_rectangle_ref (rectangle);
|
|
||||||
gst_mini_object_add_parent (GST_MINI_OBJECT_CAST (rectangle),
|
|
||||||
GST_MINI_OBJECT_CAST (comp));
|
|
||||||
comp->num_rectangles = 1;
|
|
||||||
|
|
||||||
comp->seq_num = gst_video_overlay_get_seqnum ();
|
comp->seq_num = gst_video_overlay_get_seqnum ();
|
||||||
|
|
||||||
/* since the rectangle was created earlier, its seqnum is smaller than ours */
|
/* since the rectangle was created earlier, its seqnum is smaller than ours */
|
||||||
comp->min_seq_num_used = rectangle->seq_num;
|
comp->min_seq_num_used = rectangle->seq_num;
|
||||||
|
|
||||||
GST_LOG ("new composition %p: seq_num %u with rectangle %p", comp,
|
GST_LOG ("new composition %p: seq_num %u", comp, comp->seq_num);
|
||||||
comp->seq_num, rectangle);
|
|
||||||
|
if (rectangle)
|
||||||
|
gst_video_overlay_composition_add_rectangle (comp, rectangle);
|
||||||
|
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue