glupload: provide the sink template caps that could be used

https://bugzilla.gnome.org/show_bug.cgi?id=746399
This commit is contained in:
Matthew Waters 2015-04-28 20:11:07 +10:00 committed by Tim-Philipp Müller
parent 403ee23de1
commit c902a6f525
7 changed files with 60 additions and 28 deletions

View file

@ -61,17 +61,12 @@ static GstStaticPadTemplate _src_pad_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw(ANY)"));
static GstStaticPadTemplate _sink_pad_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw(ANY)"));
static void
gst_gl_filter_bin_class_init (GstGLFilterBinClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstCaps *upload_caps;
element_class->change_state = gst_gl_filter_bin_change_state;
@ -80,8 +75,11 @@ gst_gl_filter_bin_class_init (GstGLFilterBinClass * klass)
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&_src_pad_template));
upload_caps = gst_gl_upload_get_input_template_caps ();
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&_sink_pad_template));
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, upload_caps));
gst_caps_unref (upload_caps);
g_object_class_install_property (gobject_class, PROP_FILTER,
g_param_spec_object ("filter",

View file

@ -110,12 +110,6 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("video/x-raw(ANY)")
);
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("video/x-raw(ANY)")
);
static void gst_gl_mixer_bin_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_gl_mixer_bin_get_property (GObject * object, guint prop_id,
@ -133,6 +127,7 @@ gst_gl_mixer_bin_class_init (GstGLMixerBinClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstCaps *upload_caps;
g_type_class_add_private (klass, sizeof (GstGLMixerBinPrivate));
@ -178,8 +173,12 @@ gst_gl_mixer_bin_class_init (GstGLMixerBinClass * klass)
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_factory));
upload_caps = gst_gl_upload_get_input_template_caps ();
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_factory));
gst_pad_template_new ("sink_%u", GST_PAD_SINK, GST_PAD_REQUEST,
upload_caps));
gst_caps_unref (upload_caps);
}
static void

View file

@ -43,12 +43,6 @@ static void gst_gl_sink_bin_video_overlay_init (gpointer g_iface,
static void gst_gl_sink_bin_navigation_interface_init (gpointer g_iface,
gpointer g_iface_data);
static GstStaticPadTemplate gst_gl_sink_bin_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw(ANY)"));
enum
{
PROP_0,
@ -79,6 +73,7 @@ gst_gl_sink_bin_class_init (GstGLSinkBinClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *element_class;
GstCaps *upload_caps;
gobject_class = (GObjectClass *) klass;
element_class = GST_ELEMENT_CLASS (klass);
@ -119,8 +114,10 @@ gst_gl_sink_bin_class_init (GstGLSinkBinClass * klass)
"Infrastructure to process GL textures",
"Matthew Waters <matthew@centricular.com>");
upload_caps = gst_gl_upload_get_input_template_caps ();
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_gl_sink_bin_template));
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, upload_caps));
gst_caps_unref (upload_caps);
}
static void

View file

@ -72,17 +72,12 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw(ANY)"));
static GstStaticPadTemplate gst_gl_upload_element_sink_pad_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw(ANY)"));
static void
gst_gl_upload_element_class_init (GstGLUploadElementClass * klass)
{
GstBaseTransformClass *bt_class = GST_BASE_TRANSFORM_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstCaps *upload_caps;
bt_class->query = gst_gl_upload_element_query;
bt_class->transform_caps = _gst_gl_upload_element_transform_caps;
@ -98,8 +93,11 @@ gst_gl_upload_element_class_init (GstGLUploadElementClass * klass)
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_gl_upload_element_src_pad_template));
upload_caps = gst_gl_upload_get_input_template_caps ();
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_gl_upload_element_sink_pad_template));
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, upload_caps));
gst_caps_unref (upload_caps);
gst_element_class_set_metadata (element_class,
"OpenGL uploader", "Filter/Video",

View file

@ -109,6 +109,10 @@ struct _GstGLMemory
};
#define GST_CAPS_FEATURE_MEMORY_GL_MEMORY "memory:GLMemory"
#define GST_GL_MEMORY_VIDEO_FORMATS_STR \
"{ RGBA, BGRA, RGBx, BGRx, ARGB, ABGR, xRGB, xBGR, RGB, BGR, RGB16, BGR16, " \
"AYUV, I420, YV12, NV12, NV21, YUY2, UYVY, Y41B, Y42B, Y444, " \
"GRAY8, GRAY16_LE, GRAY16_BE }"
/**
* GST_GL_MEMORY_ALLOCATOR:

View file

@ -97,6 +97,8 @@ struct _UploadMethod
const gchar *name;
GstGLUploadMethodFlags flags;
GstStaticCaps input_template_caps;
gpointer (*new) (GstGLUpload * upload);
GstCaps *(*transform_caps) (GstGLContext * context,
GstPadDirection direction, GstCaps * caps);
@ -277,6 +279,8 @@ _gl_memory_upload_free (gpointer impl)
static const UploadMethod _gl_memory_upload = {
"GLMemory",
METHOD_FLAG_CAN_SHARE_CONTEXT,
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
(GST_CAPS_FEATURE_MEMORY_GL_MEMORY, GST_GL_MEMORY_VIDEO_FORMATS_STR)),
&_gl_memory_upload_new,
&_gl_memory_upload_transform_caps,
&_gl_memory_upload_accept,
@ -445,6 +449,8 @@ _egl_image_upload_free (gpointer impl)
static const UploadMethod _egl_image_upload = {
"EGLImage",
0,
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
(GST_CAPS_FEATURE_MEMORY_EGL_IMAGE, "RGBA")),
&_egl_image_upload_new,
&_egl_image_upload_transform_caps,
&_egl_image_upload_accept,
@ -651,6 +657,8 @@ _upload_meta_upload_free (gpointer impl)
static const UploadMethod _upload_meta_upload = {
"UploadMeta",
METHOD_FLAG_CAN_SHARE_CONTEXT,
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
(GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, "RGBA")),
&_upload_meta_upload_new,
&_upload_meta_upload_transform_caps,
&_upload_meta_upload_accept,
@ -780,6 +788,7 @@ _raw_data_upload_free (gpointer impl)
static const UploadMethod _raw_data_upload = {
"Raw Data",
0,
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_GL_MEMORY_VIDEO_FORMATS_STR)),
&_raw_data_upload_new,
&_raw_data_upload_transform_caps,
&_raw_data_upload_accept,
@ -796,6 +805,31 @@ static const UploadMethod *upload_methods[] = { &_gl_memory_upload,
&_upload_meta_upload, &_raw_data_upload
};
static GMutex upload_global_lock;
GstCaps *
gst_gl_upload_get_input_template_caps (void)
{
GstCaps *ret = NULL;
gint i;
g_mutex_lock (&upload_global_lock);
/* FIXME: cache this and invalidate on changes to upload_methods */
for (i = 0; i < G_N_ELEMENTS (upload_methods); i++) {
GstCaps *template =
gst_static_caps_get ((GstStaticCaps *) &
upload_methods[i]->input_template_caps);
ret = ret == NULL ? template : gst_caps_merge (ret, template);
}
ret = gst_caps_simplify (ret);
g_mutex_unlock (&upload_global_lock);
return ret;
}
#define DEBUG_INIT \
GST_DEBUG_CATEGORY_INIT (gst_gl_upload_debug, "glupload", 0, "upload");

View file

@ -78,6 +78,8 @@ struct _GstGLUploadClass
GstObjectClass object_class;
};
GstCaps * gst_gl_upload_get_input_template_caps (void);
GstGLUpload * gst_gl_upload_new (GstGLContext * context);
GstCaps * gst_gl_upload_transform_caps (GstGLContext * context,