From a656e76ac9b532a8fbd5b1d417f71670cd1283c1 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Sun, 15 Jun 2014 12:24:38 +1000 Subject: [PATCH] glmixer: allow the subclass to choose the sink pad type Allows custom properties to be placed on the sink pads by subclasses --- gst-libs/gst/gl/gstglmixer.c | 36 ++++++++++++++++++++++++++++-------- gst-libs/gst/gl/gstglmixer.h | 8 ++++++++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/gst-libs/gst/gl/gstglmixer.c b/gst-libs/gst/gl/gstglmixer.c index 14c56c2..2d88d8a 100644 --- a/gst-libs/gst/gl/gstglmixer.c +++ b/gst-libs/gst/gl/gstglmixer.c @@ -756,6 +756,7 @@ gst_gl_mixer_init (GstGLMixer * mix) mix->display = NULL; mix->fbo = 0; mix->depthbuffer = 0; + mix->pad_type = GST_TYPE_GL_MIXER_PAD; mix->frames = g_ptr_array_new_full (4, _free_pad_frame_data); mix->array_buffers = g_ptr_array_new_full (4, NULL); @@ -1363,6 +1364,26 @@ done: return ret; } +/** + * gst_gl_mixer_set_pad_type: + * @mix: a #GstGLMixer + * @pad_type: a #GstPad type subclass + * + * Set the pad type that will be created in the request_new_pad vfunc. + * + * Intended only for derived classes of #GstGLMixer. + */ +void +gst_gl_mixer_set_pad_type (GstGLMixer * mix, GType pad_type) +{ + g_return_if_fail (GST_IS_GL_MIXER (mix)); + g_return_if_fail (g_type_is_a (pad_type, GST_TYPE_GL_MIXER_PAD)); + + GST_GL_MIXER_LOCK (mix); + mix->pad_type = pad_type; + GST_GL_MIXER_UNLOCK (mix); +} + static GstPad * gst_gl_mixer_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps) @@ -1392,7 +1413,7 @@ gst_gl_mixer_request_new_pad (GstElement * element, } /* create new pad with the name */ name = g_strdup_printf ("sink_%d", serial); - mixpad = g_object_new (GST_TYPE_GL_MIXER_PAD, "name", name, "direction", + mixpad = g_object_new (mix->pad_type, "name", name, "direction", templ->direction, "template", templ, NULL); g_free (name); @@ -1412,13 +1433,6 @@ gst_gl_mixer_request_new_pad (GstElement * element, mix->sinkpads = g_slist_append (mix->sinkpads, mixpad); mix->numpads++; - GST_DEBUG_OBJECT (element, "Adding pad %s", GST_PAD_NAME (mixpad)); - - /* add the pad to the element */ - gst_element_add_pad (element, GST_PAD (mixpad)); - gst_child_proxy_child_added (GST_CHILD_PROXY (mix), G_OBJECT (mixpad), - GST_OBJECT_NAME (mixpad)); - g_ptr_array_set_size (mix->array_buffers, mix->numpads); g_ptr_array_set_size (mix->frames, mix->numpads); @@ -1426,6 +1440,12 @@ gst_gl_mixer_request_new_pad (GstElement * element, GST_GL_MIXER_UNLOCK (mix); + /* add the pad to the element */ + GST_DEBUG_OBJECT (element, "Adding pad %s", GST_PAD_NAME (mixpad)); + gst_element_add_pad (element, GST_PAD (mixpad)); + gst_child_proxy_child_added (GST_CHILD_PROXY (mix), G_OBJECT (mixpad), + GST_OBJECT_NAME (mixpad)); + return GST_PAD (mixpad); } diff --git a/gst-libs/gst/gl/gstglmixer.h b/gst-libs/gst/gl/gstglmixer.h index 87d2bfa..3716eb1 100644 --- a/gst-libs/gst/gl/gstglmixer.h +++ b/gst-libs/gst/gl/gstglmixer.h @@ -40,6 +40,10 @@ G_BEGIN_DECLS #define GST_GL_MIXER_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_GL_MIXER,GstGLMixerClass)) +#define GST_GL_MIXER_GET_LOCK(mix) (GST_GL_MIXER(mix)->lock) +#define GST_GL_MIXER_LOCK(mix) (g_mutex_lock(&GST_GL_MIXER_GET_LOCK (mix))) +#define GST_GL_MIXER_UNLOCK(mix) (g_mutex_unlock(&GST_GL_MIXER_GET_LOCK (mix))) + typedef struct _GstGLMixer GstGLMixer; typedef struct _GstGLMixerClass GstGLMixerClass; typedef struct _GstGLMixerPrivate GstGLMixerPrivate; @@ -99,6 +103,8 @@ struct _GstGLMixer GstGLContext *context; GLuint fbo; GLuint depthbuffer; + + GType pad_type; }; struct _GstGLMixerClass @@ -121,5 +127,7 @@ GType gst_gl_mixer_get_type(void); gboolean gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf); +void gst_gl_mixer_set_pad_type (GstGLMixer * mix, GType pad_type); + G_END_DECLS #endif /* __GST_GL_MIXER_H__ */ -- 2.7.4