summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2020-01-14 18:25:11 +0100
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2020-01-14 19:52:18 +0100
commit81f3a7f02bc4e4d6b38214d2816e65c63a2e3435 (patch)
tree05243378190115c406b5f86795d89c588305190c /gst
parentf97d858237e8ed830ab7515cef8fa103f9ecf107 (diff)
libs: blend: simplify generator API
Instead of using a parent structure that has to be derived by API consumers, this change propse a simplification by using the common pattern of GTK of passing a function pointer and user data which will be passed as its parameter. That user data contains the state and the function will be called to update that state.
Diffstat (limited to 'gst')
-rw-r--r--gst/vaapi/gstvaapioverlay.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/gst/vaapi/gstvaapioverlay.c b/gst/vaapi/gstvaapioverlay.c
index 59b1a289..37155ee4 100644
--- a/gst/vaapi/gstvaapioverlay.c
+++ b/gst/vaapi/gstvaapioverlay.c
@@ -69,7 +69,6 @@ G_DEFINE_TYPE (GstVaapiOverlaySinkPad, gst_vaapi_overlay_sink_pad,
typedef struct _GstVaapiOverlaySurfaceGenerator GstVaapiOverlaySurfaceGenerator;
struct _GstVaapiOverlaySurfaceGenerator
{
- GstVaapiBlendSurfaceGenerator parent;
GstVaapiOverlay *overlay;
GList *current;
GstVaapiBlendSurface blend_surface;
@@ -340,9 +339,9 @@ gst_vaapi_overlay_decide_allocation (GstAggregator * agg, GstQuery * query)
}
static GstVaapiBlendSurface *
-gst_vaapi_overlay_surface_next (GstVaapiBlendSurfaceGenerator * generator)
+gst_vaapi_overlay_surface_next (gpointer data)
{
- GstVaapiOverlaySurfaceGenerator *ogenerator;
+ GstVaapiOverlaySurfaceGenerator *generator;
GstVideoAggregatorPad *vagg_pad;
GstVaapiOverlaySinkPad *pad;
GstVideoFrame *inframe;
@@ -351,20 +350,20 @@ gst_vaapi_overlay_surface_next (GstVaapiBlendSurfaceGenerator * generator)
GstVaapiVideoMeta *inbuf_meta;
GstVaapiBlendSurface *blend_surface;
- ogenerator = (GstVaapiOverlaySurfaceGenerator *) generator;
+ generator = (GstVaapiOverlaySurfaceGenerator *) data;
/* at the end of the generator? */
- if (!ogenerator->current)
+ if (!generator->current)
return NULL;
/* get the current video aggregator sinkpad */
- vagg_pad = GST_VIDEO_AGGREGATOR_PAD (ogenerator->current->data);
+ vagg_pad = GST_VIDEO_AGGREGATOR_PAD (generator->current->data);
/* increment list pointer */
- ogenerator->current = ogenerator->current->next;
+ generator->current = generator->current->next;
/* recycle the blend surface from the overlay surface generator */
- blend_surface = &ogenerator->blend_surface;
+ blend_surface = &generator->blend_surface;
blend_surface->surface = NULL;
inframe = gst_video_aggregator_pad_get_prepared_frame (vagg_pad);
@@ -372,12 +371,12 @@ gst_vaapi_overlay_surface_next (GstVaapiBlendSurfaceGenerator * generator)
pad = GST_VAAPI_OVERLAY_SINK_PAD (vagg_pad);
if (gst_vaapi_plugin_base_pad_get_input_buffer (GST_VAAPI_PLUGIN_BASE
- (ogenerator->overlay), GST_PAD (pad), buf, &inbuf) != GST_FLOW_OK)
+ (generator->overlay), GST_PAD (pad), buf, &inbuf) != GST_FLOW_OK)
return blend_surface;
/* Current sinkpad may have reached EOS */
if (!inframe || !inbuf)
- return generator->next (generator);
+ return gst_vaapi_overlay_surface_next (generator);
inbuf_meta = gst_buffer_get_vaapi_video_meta (inbuf);
@@ -436,12 +435,11 @@ gst_vaapi_overlay_aggregate_frames (GstVideoAggregator * vagg,
outbuf_surface = gst_vaapi_video_meta_get_surface (outbuf_meta);
/* initialize the surface generator */
- generator.parent.next = gst_vaapi_overlay_surface_next;
generator.overlay = overlay;
generator.current = GST_ELEMENT (overlay)->sinkpads;
if (!gst_vaapi_blend_process (overlay->blend, outbuf_surface,
- (GstVaapiBlendSurfaceGenerator *) & generator))
+ gst_vaapi_overlay_surface_next, &generator))
return GST_FLOW_ERROR;
return GST_FLOW_OK;