From 32a1e057950b447e33e460e17511ab2bbf14aaa6 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Fri, 21 Oct 2011 13:18:26 +0300 Subject: [PATCH 1/7] vc1parser: fix parsing of RANGEREDFRM --- gst-libs/gst/codecparsers/gstvc1parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gst-libs/gst/codecparsers/gstvc1parser.c b/gst-libs/gst/codecparsers/gstvc1parser.c index 3dde8d6d64..9c720911a2 100644 --- a/gst-libs/gst/codecparsers/gstvc1parser.c +++ b/gst-libs/gst/codecparsers/gstvc1parser.c @@ -1397,7 +1397,7 @@ parse_frame_header (GstBitReader * br, GstVC1FrameHdr * framehdr, pic->rangeredfrm = 0; if (structc->rangered) { - READ_UINT8 (br, pic->rangeredfrm, 2); + READ_UINT8 (br, pic->rangeredfrm, 1); } /* Figuring out the picture type */ From ca2f96caac718c4d466e0e619f2e48471d7dbb24 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Wed, 26 Oct 2011 16:29:35 +0100 Subject: [PATCH 2/7] vc1parser: do not overwrite buffer I do not know the bitstream format, but this seems likely to be what was intended. Also add a check on the number of items to read. https://bugzilla.gnome.org/show_bug.cgi?id=662776 --- gst-libs/gst/codecparsers/gstvc1parser.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/codecparsers/gstvc1parser.c b/gst-libs/gst/codecparsers/gstvc1parser.c index 9c720911a2..7407b5585b 100644 --- a/gst-libs/gst/codecparsers/gstvc1parser.c +++ b/gst-libs/gst/codecparsers/gstvc1parser.c @@ -1985,8 +1985,16 @@ gst_vc1_parse_entry_point_header (const guint8 * data, gsize size, entrypoint->quantizer = gst_bit_reader_get_bits_uint8_unchecked (&br, 2); if (advanced->hrd_param_flag) { + if (seqhdr->advanced.hrd_param.hrd_num_leaky_buckets > + MAX_HRD_NUM_LEAKY_BUCKETS) { + GST_WARNING + ("hrd_num_leaky_buckets (%d) > MAX_HRD_NUM_LEAKY_BUCKETS (%d)", + seqhdr->advanced.hrd_param.hrd_num_leaky_buckets, + MAX_HRD_NUM_LEAKY_BUCKETS); + goto failed; + } for (i = 0; i < seqhdr->advanced.hrd_param.hrd_num_leaky_buckets; i++) - READ_UINT8 (&br, entrypoint->hrd_full[MAX_HRD_NUM_LEAKY_BUCKETS], 8); + READ_UINT8 (&br, entrypoint->hrd_full[i], 8); } READ_UINT8 (&br, entrypoint->coded_size_flag, 1); From 0a170110ea18c112ebe18fcd0589f4ccf93def70 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Wed, 26 Oct 2011 16:31:39 +0100 Subject: [PATCH 3/7] tests: make const data const https://bugzilla.gnome.org/show_bug.cgi?id=662776 --- tests/check/libs/vc1parser.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/check/libs/vc1parser.c b/tests/check/libs/vc1parser.c index 1136fac3c3..6782289314 100644 --- a/tests/check/libs/vc1parser.c +++ b/tests/check/libs/vc1parser.c @@ -21,7 +21,7 @@ #include #include -static guint8 sequence_fullframe[] = { +static const guint8 sequence_fullframe[] = { 0x00, 0x00, 0x01, 0x0f, 0xca, 0x86, 0x13, 0xf0, 0xef, 0x88, 0x80, 0x00, 0x00, 0x01, 0x0e, 0x48, 0x3f, 0x4f, 0xc3, 0xbc, 0x3f, 0x2b, 0x3f, 0x3c, 0x3f, 0x00, 0x00, 0x01, 0x0d, 0x3f, @@ -44,11 +44,11 @@ static guint8 sequence_fullframe[] = { 0x00, 0x00, 0x01, 0x05, 0x3f }; -static guint8 pframe_header_main[] = { +static const guint8 pframe_header_main[] = { 0x4e, 0x29, 0x1a, 0x11 }; -static guint8 pframe_main[] = { +static const guint8 pframe_main[] = { 0x6a, 0x88, 0xbc, 0x1d, 0x40, 0x16, 0x96, 0x90, 0x05, 0x82, 0xac, 0x22, 0x88, 0xe0, 0x5d, 0x52, 0xca, 0x85, 0x4c, 0x47, 0x9d, 0xc9, 0x25, 0x45, 0x56, 0x99, 0x44, 0x15, 0xa5, 0xc5, @@ -59,11 +59,11 @@ static guint8 pframe_main[] = { 0x15, 0xbf, 0x54, 0x61, 0xf2, 0x25, 0x25, 0xa0, 0x83, 0xa0, }; -static guint8 bframe_header_main[] = { +static const guint8 bframe_header_main[] = { 0x4e, 0x39, 0x1a, 0x11 }; -static guint8 bframe_main[] = { +static const guint8 bframe_main[] = { 0x80, 0xae, 0x01, 0x43, 0x47, 0x6a, 0x9f, 0x53, 0x04, 0x55, 0x2a, 0x8b, 0x42, 0x75, 0x8b, 0x35, 0x50, 0xf5, 0x95, 0x56, 0xf2, 0x00, 0xe0, 0xa0, 0x60, 0x2c, 0xe8, 0x6b, 0x60, 0x0b, 0x20, 0x00, 0x11, @@ -80,11 +80,11 @@ static guint8 bframe_main[] = { 0x54, 0xcd, 0xd2, 0xaf, 0x1f, 0x2b, 0xba, 0xf3, 0xd9, 0x4c, 0x71 }; -static guint8 i_bi_frame_header[] = { +static const guint8 i_bi_frame_header[] = { 0x4e, 0x79, 0x1a, 0x11 }; -static guint8 biframe_main[] = { +static const guint8 biframe_main[] = { 0x0f, 0xe0, 0x4c, 0x56, 0x19, 0xdb, 0x40, 0x68, 0xd9, 0x14, 0x2c, 0x92, 0x55, 0x1f, 0x59, 0xd5, 0x5b, 0xd8, 0x55, 0x13, 0x19, 0x64, 0x40, 0x2c, 0x27, 0x38, 0x71, 0x9d, 0x05, 0x52, 0x02, 0x18, 0x7b, 0x9d, 0x22, 0x88, @@ -105,7 +105,7 @@ static guint8 biframe_main[] = { 0x54, 0x45, 0x62, 0x2d, 0x00, 0x0a, 0x0e, 0x06, 0xf0, 0x04, 0x06, 0x5a }; -static guint8 iframe_main[] = { +static const guint8 iframe_main[] = { 0x10, 0x04, 0x88, 0x18, 0x1f, 0xdf, 0xe1, 0xe1, 0xde, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, @@ -122,16 +122,16 @@ static guint8 iframe_main[] = { 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78 }; -static guint8 iframe_adv_hdr[] = { +static const guint8 iframe_adv_hdr[] = { 0xdb, 0xfe, 0x3b, 0xf2, 0x1b, 0xca, 0x3b, 0xf8, 0x86, 0xf1, 0x80, 0xca, 0x02, 0x02, 0x03, 0x09, 0xa5, 0xb8, 0xd7, 0x07, 0xfc }; -static guint8 entrypoint[] = { +static const guint8 entrypoint[] = { 0x5a, 0xc7, 0xfc, 0xef, 0xc8, 0x6c, 0x40 }; -static guint8 iframe_adv[] = { +static const guint8 iframe_adv[] = { 0x69, 0x1c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x16, 0x0c, 0x0f, 0x13, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, @@ -154,7 +154,7 @@ static guint8 iframe_adv[] = { 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f }; -static guint8 bframe_adv[] = { +static const guint8 bframe_adv[] = { 0x46, 0x03, 0x1f, 0xf0, 0x8d, 0xd8, 0xbf, 0xc0, 0xcc, 0x14, 0x24, 0xdc, 0x60, 0xe2, 0xa8, 0x5e, 0x0d, 0xff, 0xfc, 0x3b, 0x12, 0xfd, 0xe1, 0x2e, 0xd1, 0x84, 0xb0, 0xc2, 0xc4, 0xc1, @@ -397,7 +397,7 @@ static guint8 bframe_adv[] = { 0xa0, 0x84, 0x85, 0x81, 0x94, 0x23, 0x06, 0x2f, 0x22, 0xb2, }; -static guint8 bframe2_adv[] = { +static const guint8 bframe2_adv[] = { 0x46, 0x88, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf8, 0xa1, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, @@ -480,7 +480,7 @@ static guint8 bframe2_adv[] = { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, }; -static guint8 pframe_adv[] = { +static const guint8 pframe_adv[] = { 0x24, 0x20, 0x04, 0xbf, 0x85, 0x88, 0x65, 0xc1, 0x00, 0xdc, 0x4c, 0x06, 0xce, 0x05, 0x01, 0x01, 0x41, 0x0c, 0x60, 0x42, 0x67, 0xff, 0xfb, 0x85, 0x0b, 0x9c, 0x56, 0x0d, 0x0b, 0x1b, @@ -583,7 +583,7 @@ static guint8 pframe_adv[] = { 0x02, 0x84, 0x8f, 0x85, 0xb5, 0xb3, 0x5a, 0x81, 0x23, 0xa8, }; -static guint8 pframe2_adv[] = { +static const guint8 pframe2_adv[] = { 0x1c, 0x22, 0x1f, 0xdc, 0x9d, 0x3b, 0x81, 0x61, 0x85, 0x2, 0x57, 0xa0, 0x50, 0xac, 0x03, 0x81, 0x0c, 0x39, 0x4f, 0xff, 0xc2, 0x20, 0x9f, 0xf4, 0x86, 0x16, 0x8e, 0xe1, 0xda, 0x0c, From 2808290592814c83c68913771646f5961596104a Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Fri, 7 Oct 2011 19:05:30 -0400 Subject: [PATCH 4/7] video: Abstract surface API for HW accelerated codecs --- docs/libs/gst-plugins-bad-libs-docs.sgml | 3 + docs/libs/gst-plugins-bad-libs-sections.txt | 19 +++++ gst-libs/gst/video/Makefile.am | 10 ++- gst-libs/gst/video/gstsurfacebuffer.c | 88 +++++++++++++++++++ gst-libs/gst/video/gstsurfacebuffer.h | 94 +++++++++++++++++++++ gst-libs/gst/video/gstsurfaceconverter.c | 80 ++++++++++++++++++ gst-libs/gst/video/gstsurfaceconverter.h | 66 +++++++++++++++ 7 files changed, 358 insertions(+), 2 deletions(-) create mode 100644 gst-libs/gst/video/gstsurfacebuffer.c create mode 100644 gst-libs/gst/video/gstsurfacebuffer.h create mode 100644 gst-libs/gst/video/gstsurfaceconverter.c create mode 100644 gst-libs/gst/video/gstsurfaceconverter.h diff --git a/docs/libs/gst-plugins-bad-libs-docs.sgml b/docs/libs/gst-plugins-bad-libs-docs.sgml index bc648842e5..0c9994160e 100644 --- a/docs/libs/gst-plugins-bad-libs-docs.sgml +++ b/docs/libs/gst-plugins-bad-libs-docs.sgml @@ -39,6 +39,9 @@ + + + diff --git a/docs/libs/gst-plugins-bad-libs-sections.txt b/docs/libs/gst-plugins-bad-libs-sections.txt index 7976c25777..9e0d034e02 100644 --- a/docs/libs/gst-plugins-bad-libs-sections.txt +++ b/docs/libs/gst-plugins-bad-libs-sections.txt @@ -404,3 +404,22 @@ gst_base_video_rawvideo_convert gst_base_video_encoded_video_convert gst_video_state_get_timestamp + +
+gstsurfacebuffer +GstSurfaceBuffer +GST_VIDEO_CAPS_SURFACE +GstSurfaceBuffer +GstSurfaceBufferClass +gst_surface_buffer_get_type +gst_surface_buffer_create_converter +
+ +
+gstsurfaceconverter +GstSurfaceConverter +GstSurfaceConverter +GstSurfaceConverterInterface +gst_surface_converter_get_type +gst_surface_converter_upload +
diff --git a/gst-libs/gst/video/Makefile.am b/gst-libs/gst/video/Makefile.am index cca3fefcf9..7ce58a3c76 100644 --- a/gst-libs/gst/video/Makefile.am +++ b/gst-libs/gst/video/Makefile.am @@ -7,14 +7,20 @@ libgstbasevideo_@GST_MAJORMINOR@_la_SOURCES = \ gstbasevideocodec.c \ gstbasevideoutils.c \ gstbasevideodecoder.c \ - gstbasevideoencoder.c + gstbasevideoencoder.c \ + gstsurfacebuffer.c \ + gstsurfaceconverter.c \ + videocontext.c libgstbasevideo_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/video libgstbasevideo_@GST_MAJORMINOR@include_HEADERS = \ gstbasevideocodec.h \ gstbasevideoutils.h \ gstbasevideodecoder.h \ - gstbasevideoencoder.h + gstbasevideoencoder.h \ + gstsurfacebuffer.h \ + gstsurfaceconverter.h \ + videocontext.h libgstbasevideo_@GST_MAJORMINOR@_la_CFLAGS = \ $(GST_PLUGINS_BAD_CFLAGS) \ diff --git a/gst-libs/gst/video/gstsurfacebuffer.c b/gst-libs/gst/video/gstsurfacebuffer.c new file mode 100644 index 0000000000..61bf4eebac --- /dev/null +++ b/gst-libs/gst/video/gstsurfacebuffer.c @@ -0,0 +1,88 @@ +/* GStreamer + * Copyright (C) 2011 Collabora Ltd. + * Copyright (C) 2011 Intel + * + * Author: Nicolas Dufresne + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "gstsurfacebuffer.h" + +/** + * SECTION:gstsurfacebuffer + * @short_description: Accelerated surface base class + * + * This base class is used to abstract hardware accelerated buffers and enable + * generic convertion to standard type such as GL textures. The media type for + * those buffers is defined by #GST_VIDEO_CAPS_SURFACE. An implementation + * specific type must be set using the "type" key (e.g. type="vaapi"). + * Available convertion type are speficied using seperate boolean + * arguement (e.g. opengl=true). Having this information in the capabilities + * allow easy negotiating of such feature with other elements (e.g. a + * ClutterGstVideoSink can claim accpeting caps "video/x-surface,opengl=true"). + * + * The GstVideoContext interface is unstable API and may change in future. + * One can define GST_USE_UNSTABLE_API to acknowledge and avoid this warning. + * + */ + +G_DEFINE_TYPE (GstSurfaceBuffer, gst_surface_buffer, GST_TYPE_BUFFER); + +static GstSurfaceConverter * +gst_surface_buffer_default_create_converter (GstSurfaceBuffer * surface, + const gchar * type, GValue * dest) +{ + return NULL; +} + +static void +gst_surface_buffer_class_init (GstSurfaceBufferClass * klass) +{ + klass->create_converter = gst_surface_buffer_default_create_converter; +} + +static void +gst_surface_buffer_init (GstSurfaceBuffer * surface) +{ + /* Nothing to do */ +} + +/** + * gst_surface_buffer_create_converter: + * @buffer: a #GstSurfaceBuffer + * @type: the type to convert to + * @dest: a #GValue containing the destination to upload + * + * This method is used to create a type specific converter. The converter will + * serve as context to accelerate the data convertion. This converter object + * shall be discarded when the pipeline state changes to NULL and renewed when + * caps are changed. + * + * Returns: newly allocated #GstSurfaceConverter + */ +GstSurfaceConverter * +gst_surface_buffer_create_converter (GstSurfaceBuffer * buffer, + const gchar * type, GValue * dest) +{ + g_return_val_if_fail (GST_IS_SURFACE_BUFFER (buffer), FALSE); + return GST_SURFACE_BUFFER_GET_CLASS (buffer)->create_converter (buffer, + type, dest); +} diff --git a/gst-libs/gst/video/gstsurfacebuffer.h b/gst-libs/gst/video/gstsurfacebuffer.h new file mode 100644 index 0000000000..1b9bc2544e --- /dev/null +++ b/gst-libs/gst/video/gstsurfacebuffer.h @@ -0,0 +1,94 @@ +/* GStreamer + * Copyright (C) 2011 Collabora Ltd. + * Copyright (C) 2011 Intel + * + * Author: Nicolas Dufresne + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _GST_SURFACE_BUFFER_H_ +#define _GST_SURFACE_BUFFER_H_ + +#ifndef GST_USE_UNSTABLE_API +#warning "GstSurfaceBuffer is unstable API and may change in future." +#warning "You can define GST_USE_UNSTABLE_API to avoid this warning." +#endif + +#include +#include + +G_BEGIN_DECLS + +#define GST_TYPE_SURFACE_BUFFER (gst_surface_buffer_get_type()) +#define GST_SURFACE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SURFACE_BUFFER,GstSurfaceBuffer)) +#define GST_SURFACE_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SURFACE_BUFFER,GstSurfaceBufferClass)) +#define GST_SURFACE_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_SURFACE_BUFFER,GstSurfaceBufferClass)) +#define GST_IS_SURFACE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SURFACE_BUFFER)) +#define GST_IS_SURFACE_BUFFER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SURFACE_BUFFER)) + +/** + * GST_VIDEO_CAPS_SURFACE: + * + * Base caps for GstSurfaceBuffer. Implementation specific type must be marked + * using the type attribute (e.g. type=vaapi). Available convertion shall be + * specified using boolean attributes (e.g. opengl=true). + */ +#define GST_VIDEO_CAPS_SURFACE "video/x-surface" + +typedef struct _GstSurfaceBuffer GstSurfaceBuffer; +typedef struct _GstSurfaceBufferClass GstSurfaceBufferClass; + +/** + * GstSurfaceBuffer: + * @parent: parent object + */ +struct _GstSurfaceBuffer +{ + GstBuffer parent; + + /*< private >*/ + void *padding[GST_PADDING]; +}; + +/** + * GstSurfaceBufferClass: + * @parent_class: parent class type. + * @create_converter: vmethod to create a converter. + * + * #GstVideoContextInterface interface. + */ +struct _GstSurfaceBufferClass +{ + GstBufferClass parent_class; + + GstSurfaceConverter * (*create_converter) (GstSurfaceBuffer *buffer, + const gchar *type, + GValue *dest); + + /*< private >*/ + void *padding[GST_PADDING]; +}; + +GType gst_surface_buffer_get_type (void); + +GstSurfaceConverter *gst_surface_buffer_create_converter (GstSurfaceBuffer *buffer, + const gchar *type, + GValue *dest); + +G_END_DECLS + +#endif diff --git a/gst-libs/gst/video/gstsurfaceconverter.c b/gst-libs/gst/video/gstsurfaceconverter.c new file mode 100644 index 0000000000..c482ff12e8 --- /dev/null +++ b/gst-libs/gst/video/gstsurfaceconverter.c @@ -0,0 +1,80 @@ +/* GStreamer + * Copyright (C) 2011 Collabora Ltd. + * Copyright (C) 2011 Intel + * + * Author: Nicolas Dufresne + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "gstsurfaceconverter.h" +#include "gstsurfacebuffer.h" + +/** + * SECTION:gstsurfaceconverter + * @short_description: Interface for #GstSurfaceBuffer convertion + * + * Objects implementing this interface are used as a convertion context. This + * allow element optimizing the upload by keeping required resources between + * uploads. The context must be discarded when the pipeline goes to + * #GST_STATE_NULL or renewed whenever the caps are changed. + * + * The GstVideoContext interface is unstable API and may change in future. + * One can define GST_USE_UNSTABLE_API to acknowledge and avoid this warning. + * + * + * + * Example uploading to GL texture + * |[ + * if (G_UNLIKELY (priv->converter == NULL)) + * priv->converter = gst_surface_buffer_create_converter (surface, "opengl", &value); + * + * gst_surface_converter_uplaod (priv->converter, surface); + * ]| + * + */ + +G_DEFINE_INTERFACE (GstSurfaceConverter, gst_surface_converter, G_TYPE_INVALID); + +static void +gst_surface_converter_default_init (GstSurfaceConverterInterface * iface) +{ + /* default virtual functions */ + iface->upload = NULL; +} + +/** + * gst_surface_converter_upload: + * @converter: a #GstSurfaceConverter + * @buffer: the #GstSurfaceBuffer to upload + * + * Convert and uploads the #GstSurfaceBuffer to the converter destination. + * + * Returns: #TRUE on success, #FALSE otherwise + */ +gboolean +gst_surface_converter_upload (GstSurfaceConverter * converter, + GstSurfaceBuffer * buffer) +{ + g_return_val_if_fail (GST_IS_SURFACE_CONVERTER (converter), FALSE); + g_return_val_if_fail (GST_IS_SURFACE_BUFFER (buffer), FALSE); + return GST_SURFACE_CONVERTER_GET_IFACE (converter)->upload (converter, + buffer); +} diff --git a/gst-libs/gst/video/gstsurfaceconverter.h b/gst-libs/gst/video/gstsurfaceconverter.h new file mode 100644 index 0000000000..2a87557b81 --- /dev/null +++ b/gst-libs/gst/video/gstsurfaceconverter.h @@ -0,0 +1,66 @@ +/* GStreamer + * Copyright (C) 2011 Collabora Ltd. + * Copyright (C) 2011 Intel + * + * Author: Nicolas Dufresne + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _GST_SURFACE_CONVERTER_H_ +#define _GST_SURFACE_CONVERTER_H_ + +#ifndef GST_USE_UNSTABLE_API +#warning "GstSurfaceConverter is unstable API and may change in future." +#warning "You can define GST_USE_UNSTABLE_API to avoid this warning." +#endif + +#include + +G_BEGIN_DECLS + +#define GST_TYPE_SURFACE_CONVERTER (gst_surface_converter_get_type ()) +#define GST_SURFACE_CONVERTER(obj) (GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SURFACE_CONVERTER, GstSurfaceConverter)) +#define GST_IS_SURFACE_CONVERTER(obj) (GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SURFACE_CONVERTER)) +#define GST_SURFACE_CONVERTER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_SURFACE_CONVERTER, GstSurfaceConverterInterface)) + +typedef struct _GstSurfaceBuffer GstSurfaceBuffer; +typedef struct _GstSurfaceConverter GstSurfaceConverter; +typedef struct _GstSurfaceConverterInterface GstSurfaceConverterInterface; + +/** + * GstSurfaceConverterInterface: + * @parent: parent interface type. + * @upload: vmethod to upload #GstSurfaceBuffer. + * + * #GstSurfaceConverterInterface interface. + */ +struct _GstSurfaceConverterInterface +{ + GTypeInterface parent; + + gboolean (*upload) (GstSurfaceConverter *converter, + GstSurfaceBuffer *buffer); +}; + +GType gst_surface_converter_get_type (void); + +gboolean gst_surface_converter_upload (GstSurfaceConverter *converter, + GstSurfaceBuffer *buffer); + +G_END_DECLS + +#endif From 149c058209dbf14afe6844ce47d6bb7f57e29ea5 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 19 Oct 2011 16:19:51 -0400 Subject: [PATCH 5/7] video: Add GstVideoContext interface This interface will be used to implement video context sharing. Those context could be X11 Display, VaDisplay, etc. --- docs/libs/gst-plugins-bad-libs-sections.txt | 23 + gst-libs/gst/video/videocontext.c | 539 ++++++++++++++++++++ gst-libs/gst/video/videocontext.h | 117 +++++ 3 files changed, 679 insertions(+) create mode 100644 gst-libs/gst/video/videocontext.c create mode 100644 gst-libs/gst/video/videocontext.h diff --git a/docs/libs/gst-plugins-bad-libs-sections.txt b/docs/libs/gst-plugins-bad-libs-sections.txt index 9e0d034e02..09a395dab4 100644 --- a/docs/libs/gst-plugins-bad-libs-sections.txt +++ b/docs/libs/gst-plugins-bad-libs-sections.txt @@ -405,6 +405,29 @@ gst_base_video_encoded_video_convert gst_video_state_get_timestamp +
+gstvideocontext +GstVideoContextInterface +GST_IS_VIDEO_CONTEXT +GstVideoContext +GstVideoContextInterface +gst_video_context_iface_get_type +gst_video_context_set_context +gst_video_context_set_context_string +gst_video_context_set_context_pointer +gst_video_context_set_context_object +gst_video_context_prepare +gst_video_context_message_parse_prepare +gst_video_context_query_new +gst_video_context_run_query +gst_video_context_query_get_supported_types +gst_video_context_query_parse_value +gst_video_context_query_set_value +gst_video_context_query_set_string +gst_video_context_query_set_pointer +gst_video_context_query_set_object +
+
gstsurfacebuffer GstSurfaceBuffer diff --git a/gst-libs/gst/video/videocontext.c b/gst-libs/gst/video/videocontext.c new file mode 100644 index 0000000000..a5458a2e26 --- /dev/null +++ b/gst-libs/gst/video/videocontext.c @@ -0,0 +1,539 @@ +/* GStreamer + * + * Copyright (C) 2011 Intel + * Copyright (C) 2011 Collabora Ltd. + * Author: Nicolas Dufresne + * + * video-context.c: Video Context interface and helpers + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "videocontext.h" + +/** + * SECTION:gstvideocontext + * @short_description: Interface to handle video library context + * + * The Video Context interface enable sharing video context (such as display + * name, X11 Display, VA-API Display, etc) between neighboor elements and the + * application. + * + * The GstVideoContext interface is unstable API and may change in future. + * One can define GST_USE_UNSTABLE_API to acknowledge and avoid this warning. + * + * + * + * For Element + * + * This interface shall be implement by group of elements that need to share + * a specific video context (like VDPAU, LibVA, OpenGL elements) or by video + * sink in order to let the application select appropriate display information + * (like the X11 display name) when those sink are auto-plugged. + * + * + * Along with implementing the interface, elements will need to query + * neighboor elements or send message to the application when preparing + * the context (see gst_video_context_prepare()). They also need to reply + * to the neighboors element queries, so the context can be shared without + * the application help. + * + * + * Elements that are guarantied to have both upstream and downstream + * neighboors element implementing the #GstVideoContext (like the gloverlay + * element in gst-plugins-opengl) is not required to also implement the + * interface. Relying on neighboors query shall be sufficient (see + * gst_video_context_run_query()). + * + * + * The query is an application query with a structure name set to + * "prepare-video-context" and an array of supported video context types set + * in the field named "types". This query shall be send downstream and + * upstream, iterating the pads in order to find neighboors regardless of a + * static (sink to src) or a dynamic (src to sink) activation. Element should + * used the helpers method gst_video_context_prepare() (or + * gst_video_context_run_query() if no GstVideoContext interface) to + * correctly execute the query . The result is set using the query helper + * functions, the structures fields name being "video-context-type" as + * string and "video-context" as a #GValue. + * + * + * If the query is not handled by any neighboor, the element should ask the + * application using the "prepare-video-context" message. The application + * may then use the interface to set the video context information. If no + * context was set, the element shall create one using default configuration. + * Elements with multiple src or sink pad shall implement proper locking to + * prevent the race of parallel queries being replied. + * + * + * Well known video-context are: "x11-display-name" a string representing the + * X11 display to use, "x11-display" the X11 Display structure, "va-display", + * the VADisplay structure and more. + * + * + * + * + * For Application + * + * In the case there is no neighboor element with video context to share, + * the element will first turn toward the application, by sending a + * "prepare-video-context" message. This message is sent along with a list + * of supported display types. The application can optionally reply to this + * message by calling appropriate setter through the #GstVideoContext + * interface. If the application supports more then one video context type, + * it should choose the first one to occure in the supported list. It's + * important to remember that the message is delivered from the streaming + * thread, and appropriate locking should be considered. If the application + * does not have a video context to share, the element will simply allocate + * one base on default settings. Usually, only applications using OpenGL + * base sink, or running on special X11 display need to share a video context. + * + * Applications sharing X11 Display structure should always initialize the + * X11 threading support using XInitThreads() as GStreamer will need to + * manipulate the display from a separeate threads. + * + * + * + * Example using ClutterVideoGstVideoSink + * + * This example is for user of ClutterGstVideoSink element, the + * ClutterGstPlayer object transparently handle this. + * + * |[ + * #if CLUTTER_WINDOWING_X11 + * static GstBusSyncReply + * on_sync_message (GstBus * bus, GstMessage * message, gpointer user_data) + * { + * Display *display = user_data; + * GstVideoContext *context; + * const gchar **types; + * + * if (gst_video_context_message_parse_prepare (message, &types, &context)) { + * gint i; + * + * for (i = 0; types[i]; i++) { + * + * if (!strcmp(types[i], "x11-display")) { + * gst_video_context_set_context_pointer (context, "x11-display", display); + * } + * else if (!strcmp(types[i], "x11-display-name")) { + * gst_video_context_set_context_string (context, "x11-display-name", + * DisplayString (display)); + * } else { + * continue; + * } + * + * gst_message_unref (message); + * return GST_BUS_DROP; + * } + * } + * + * return GST_BUS_PASS; + * } + * #endif + * + * gint + * main (gint argc, gchar **argv) + * { + * GstBin *pipeline; + * GstBus *bus; + * + * ... + * + * bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); + * + * #if CLUTTER_WINDOWING_X11 + * gst_bus_set_sync_handler (priv->bus, on_sync_message, + * clutter_x11_get_default_display ()); + * #endif + * + * gst_object_unref (GST_OBJECT (priv->bus)); + * + * ... + * } + * ]| + * + * + */ + +G_DEFINE_INTERFACE (GstVideoContext, gst_video_context_iface, G_TYPE_INVALID); + +static inline GstStructure * +gst_video_context_new_structure (const gchar ** types) +{ + return gst_structure_new ("prepare-video-context", + "types", G_TYPE_STRV, types, NULL); +} + +static gboolean +gst_video_context_pad_query (gpointer item, GValue * value, gpointer user_data) +{ + GstPad *pad = GST_PAD (item); + GstQuery *query = user_data; + gboolean res; + + res = gst_pad_peer_query (pad, query); + gst_object_unref (pad); + + if (res) { + g_value_set_boolean (value, TRUE); + return FALSE; + } + + return TRUE; +} + +static void +gst_video_context_iface_default_init (GstVideoContextInterface * iface) +{ + /* default virtual functions */ + iface->set_context = NULL; +} + +/** + * gst_video_context_set_context: + * @context: an element implementing #GstVideoContext + * @type: the type of display being set + * @value: a #GValue containing the context + * + * This is a wrapper for the set_context() virtual method. It is suggested to + * use one of the helpers to avoid having to manipulate #GValue + */ +void +gst_video_context_set_context (GstVideoContext * context, const gchar * type, + const GValue * value) +{ + g_return_if_fail (GST_IS_VIDEO_CONTEXT (context)); + g_return_if_fail (GST_VIDEO_CONTEXT_GET_IFACE (context)->set_context); + + GST_VIDEO_CONTEXT_GET_IFACE (context)->set_context (context, type, value); +} + +/** + * gst_video_context_set_context_string: + * @context: an element implementing #GstVideoContext + * @type: the type of display being set + * @string: a string representing the video context + * + * This helper is commonly used for setting video context represented by a + * string like the X11 display name ("x11-display-name")/ + */ +void +gst_video_context_set_context_string (GstVideoContext * context, + const gchar * type, const gchar * string) +{ + GValue value = { 0 }; + g_value_init (&value, G_TYPE_STRING); + g_value_set_string (&value, string); + gst_video_context_set_context (context, type, &value); + g_value_unset (&value); +} + +/** + * gst_video_context_set_context_pointer: + * @context: an element implementing #GstVideoContext + * @type: the type of display being set + * @pointer: a pointer to the video context + * + * This helper is used for setting video context using a pointer, typically to + * a structure like the X11 Display ("x11-display") or the VADisplay + * ("vaapi-display"). + * + * Users of X11 Display should ensure that XInitThreads() was called before + * opening the display. + * + */ +void +gst_video_context_set_context_pointer (GstVideoContext * context, + const gchar * type, gpointer pointer) +{ + GValue value = { 0 }; + g_value_init (&value, G_TYPE_POINTER); + g_value_set_pointer (&value, pointer); + gst_video_context_set_context (context, type, &value); + g_value_unset (&value); +} + +/** + * gst_video_context_set_context_object: + * @context: an element implementing #GstVideoContext + * @type: the type of display being set + * @object: a #GObject resenting the display + * + * This is for video context that are #GObject, this helper allow taking + * benifit of the #GObject refcounting. It is particularly handy for element + * to have refcounting as the order in which element will stop using the + * display is not defined. + */ +void +gst_video_context_set_context_object (GstVideoContext * context, + const gchar * type, GObject * object) +{ + GValue value = { 0 }; + g_return_if_fail (G_IS_OBJECT (object)); + g_value_init (&value, G_TYPE_OBJECT); + g_value_set_object (&value, object); + gst_video_context_set_context (context, type, &value); + g_value_unset (&value); +} + +/** + * gst_video_context_prepare: + * @context: an element implementing #GstVideoContext interface + * @types: an array of supported types, prefered first + * + * This method run "prepare-video-context" custom query dowstream, and + * upstream. If * the query has a reply, it sets the context value using + * gst_video_context_set_context(). Otherwise, it sends a + * "prepare-video-context" message to the application. The element can then + * continue video context initialization. + */ +void +gst_video_context_prepare (GstVideoContext * context, const gchar ** types) +{ + GstQuery *query = gst_video_context_query_new (types); + + /* Check neighborhood, if found call GstVideoContext */ + if (gst_video_context_run_query (GST_ELEMENT (context), query)) { + const gchar *type = NULL; + const GValue *value; + gst_video_context_query_parse_value (query, &type, &value); + gst_video_context_set_context (context, type, value); + } else { + /* If no neighbor replyed, query the application */ + GstMessage *message; + GstStructure *structure; + + structure = gst_video_context_new_structure (types); + message = gst_message_new_element (GST_OBJECT (context), structure); + gst_element_post_message (GST_ELEMENT (context), message); + } + + gst_query_unref (query); +} + +/** + * gst_video_context_message_parse_prepare: + * @message: a #GstMessage + * @types: return value for supported types + * @context: return value for the element the implements #GstVideoContext + * + * This helper shall be used by application to simply handling of the + * "prepare-video-context" message. + * + * Rerturns: #FALSE is the message was not valid "prepare-video-context" + * element message, otherwise #TRUE with @types and @context set. + */ +gboolean +gst_video_context_message_parse_prepare (GstMessage * message, + const gchar *** types, GstVideoContext ** context) +{ + GstObject *src = GST_MESSAGE_SRC (message); + const GstStructure *structure; + const GValue *value; + + if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) + return FALSE; + + if (!gst_structure_has_name (message->structure, "prepare-video-context")) + return FALSE; + + if (!GST_IS_VIDEO_CONTEXT (src)) + return FALSE; + + structure = gst_message_get_structure (message); + value = gst_structure_get_value (structure, "types"); + + if (!G_VALUE_HOLDS (value, G_TYPE_STRV)) + return FALSE; + + if (types) + *types = g_value_get_boxed (value); + + if (context) + *context = GST_VIDEO_CONTEXT (src); + + return TRUE; +} + +/** + * gst_video_context_query_new: + * @types: a string array of video context types + * + * Create a new custom #GstQuery with structure name "prepare-video-context". + */ +GstQuery * +gst_video_context_query_new (const gchar ** types) +{ + GstStructure *structure = gst_video_context_new_structure (types); + return gst_query_new_application (GST_QUERY_CUSTOM, structure); +} + +/** + * gst_video_context_run_query: + * @element: a #GstElement + * @query: a #GstQuery + * + * This helper runs the query on each downstream, then upstream pads in an + * element. This is called by gst_video_context_prepare(). This method is only + * used directly within elements that are required to have two neighboors + * elements with appropriate video context. This would be the case of + * specialized filters that only manipulate non-raw buffers (e.g. + * gldeinterlace). Those elements do not have to implement #GstVideoContext + * interface. + */ +gboolean +gst_video_context_run_query (GstElement * element, GstQuery * query) +{ + GstIterator *it; + GstIteratorFoldFunction func = gst_video_context_pad_query; + GValue res = { 0 }; + + g_value_init (&res, G_TYPE_BOOLEAN); + g_value_set_boolean (&res, FALSE); + + /* Ask downstream neighbor (mainly static pipeline case) */ + it = gst_element_iterate_src_pads (element); + + while (gst_iterator_fold (it, func, &res, query) == GST_ITERATOR_RESYNC) + gst_iterator_resync (it); + + gst_iterator_free (it); + + /* If none, ask upstream neighbor (auto-plugged case) */ + if (!g_value_get_boolean (&res)) { + it = gst_element_iterate_sink_pads (element); + + while (gst_iterator_fold (it, func, &res, query) == GST_ITERATOR_RESYNC) + gst_iterator_resync (it); + + gst_iterator_free (it); + } + + return g_value_get_boolean (&res); +} + +/** + * gst_video_context_query_get_supported_types: + * @query: a #GstQuery + * + * Returns: An array of supported video context types + */ +const gchar ** +gst_video_context_query_get_supported_types (GstQuery * query) +{ + GstStructure *structure = gst_query_get_structure (query); + const GValue *value = gst_structure_get_value (structure, "types"); + + if (G_VALUE_HOLDS (value, G_TYPE_STRV)) + return g_value_get_boxed (value); + + return NULL; +} + +/** + * gst_video_context_query_parse_value: + * @query: a #GstQuery + * @type: return video context type + * @value: return video context #GValue + * + * Helper to extract the video context type and value from a #GstQuery. + */ +void +gst_video_context_query_parse_value (GstQuery * query, const gchar ** type, + const GValue ** value) +{ + GstStructure *structure = gst_query_get_structure (query); + + if (type) + *type = gst_structure_get_string (structure, "video-context-type"); + + if (value) + *value = gst_structure_get_value (structure, "video-context"); +} + +/** + * gst_video_context_query_set_value: + * @query: a #GstQuery + * @type: the video context type + * @value: a #GValue set with video context + * + * Helper to set the video context as a #GValue inside the #GstQuery. + */ +void +gst_video_context_query_set_value (GstQuery * query, const gchar * type, + GValue * value) +{ + GstStructure *structure = gst_query_get_structure (query); + gst_structure_set (structure, "video-context-type", G_TYPE_STRING, type, + "video-context", G_TYPE_VALUE, value, NULL); +} + +/** + * gst_video_context_query_set_string: + * @query: a #GstQuery + * @type: the video context type + * @value: a string representing the video context + * + * Helper to set the video context as a string inside the #GstQuery. + */ +void +gst_video_context_query_set_string (GstQuery * query, const gchar * type, + const gchar * value) +{ + GstStructure *structure = gst_query_get_structure (query); + gst_structure_set (structure, "video-context-type", G_TYPE_STRING, type, + "video-context", G_TYPE_STRING, value, NULL); +} + +/** + * gst_video_context_query_set_pointer: + * @query: a #GstQuery + * @type: the video context type + * @value: a #gpointer representing the video context + * + * Helper to set the video context as a #gpointer inside the #GstQuery. + */ +void +gst_video_context_query_set_pointer (GstQuery * query, const gchar * type, + gpointer value) +{ + GstStructure *structure = gst_query_get_structure (query); + gst_structure_set (structure, "video-context-type", G_TYPE_STRING, type, + "video-context", G_TYPE_POINTER, value, NULL); +} + +/** + * gst_video_context_query_set_object: + * @query: a #GstQuery + * @type: the video context type + * @value: a #GObject representing the video context + * + * Helper to set the video context as a #GObject inside the #GstQuery. + */ +void +gst_video_context_query_set_object (GstQuery * query, const gchar * type, + GObject * value) +{ + GstStructure *structure = gst_query_get_structure (query); + gst_structure_set (structure, "video-context-type", G_TYPE_STRING, type, + "video-context", G_TYPE_OBJECT, value, NULL); +} diff --git a/gst-libs/gst/video/videocontext.h b/gst-libs/gst/video/videocontext.h new file mode 100644 index 0000000000..5becb56163 --- /dev/null +++ b/gst-libs/gst/video/videocontext.h @@ -0,0 +1,117 @@ +/* GStreamer + * + * Copyright (C) 2011 Intel + * Copyright (C) 2011 Collabora Ltd. + * Author: Nicolas Dufresne + * + * video-context.h: Video Context interface and helpers + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GST_VIDEO_CONTEXT_H__ +#define __GST_VIDEO_CONTEXT_H__ + +#ifndef GST_USE_UNSTABLE_API +#warning "The GstVideoContext interface is unstable API and may change in future." +#warning "You can define GST_USE_UNSTABLE_API to avoid this warning." +#endif + +#include + +G_BEGIN_DECLS + +#define GST_TYPE_VIDEO_CONTEXT (gst_video_context_iface_get_type ()) +#define GST_VIDEO_CONTEXT(obj) (GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VIDEO_CONTEXT, GstVideoContext)) +#define GST_IS_VIDEO_CONTEXT(obj) (GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VIDEO_CONTEXT)) +#define GST_VIDEO_CONTEXT_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_VIDEO_CONTEXT, GstVideoContextInterface)) + +/** + * GstVideoContext: + * + * Opaque #GstVideoContext data structure. + */ +typedef struct _GstVideoContext GstVideoContext; +typedef struct _GstVideoContextInterface GstVideoContextInterface; + +/** + * GstVideoContextInterface: + * @parent: parent interface type. + * @set_context: vmethod to set video context. + * + * #GstVideoContextInterface interface. + */ +struct _GstVideoContextInterface +{ + GTypeInterface parent; + + /* virtual functions */ + void (*set_context) (GstVideoContext * context, + const gchar * type, + const GValue * value); + +}; + +GType gst_video_context_iface_get_type (void); + +/* virtual class method and associated helpers */ +void gst_video_context_set_context (GstVideoContext * context, + const gchar * type, + const GValue * value); +void gst_video_context_set_context_string (GstVideoContext * context, + const gchar * type, + const gchar * value); +void gst_video_context_set_context_pointer (GstVideoContext * context, + const gchar * type, + gpointer value); +void gst_video_context_set_context_object (GstVideoContext * context, + const gchar * type, + GObject * value); + + +/* message helpers */ +void gst_video_context_prepare (GstVideoContext *context, + const gchar ** types); + +gboolean gst_video_context_message_parse_prepare (GstMessage * message, + const gchar *** types, + GstVideoContext ** ctx); + +/* query helpers */ +GstQuery * gst_video_context_query_new (const gchar ** types); +gboolean gst_video_context_run_query (GstElement *element, + GstQuery *query); +const gchar ** gst_video_context_query_get_supported_types (GstQuery * query); +void gst_video_context_query_parse_value (GstQuery * query, + const gchar ** type, + const GValue ** value); +void gst_video_context_query_set_value (GstQuery * query, + const gchar * type, + GValue * value); +void gst_video_context_query_set_string (GstQuery * query, + const gchar * type, + const gchar * value); +void gst_video_context_query_set_pointer (GstQuery * query, + const gchar * type, + gpointer value); +void gst_video_context_query_set_object (GstQuery * query, + const gchar * type, + GObject * value); + +G_END_DECLS + +#endif /* __GST_VIDEO_CONTEXT_H__ */ From fa21ce91bfd88cc08ed38b94c67ed1b64c1b8fe6 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 28 Sep 2011 19:29:07 -0400 Subject: [PATCH 6/7] video: Add libgstbasevideo PC file --- configure.ac | 2 ++ pkgconfig/Makefile.am | 9 ++++++--- pkgconfig/gstreamer-basevideo-uninstalled.pc.in | 12 ++++++++++++ pkgconfig/gstreamer-basevideo.pc.in | 12 ++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 pkgconfig/gstreamer-basevideo-uninstalled.pc.in create mode 100644 pkgconfig/gstreamer-basevideo.pc.in diff --git a/configure.ac b/configure.ac index bd83784892..7561c00379 100644 --- a/configure.ac +++ b/configure.ac @@ -2067,6 +2067,8 @@ pkgconfig/gstreamer-plugins-bad.pc pkgconfig/gstreamer-plugins-bad-uninstalled.pc pkgconfig/gstreamer-codecparsers.pc pkgconfig/gstreamer-codecparsers-uninstalled.pc +pkgconfig/gstreamer-basevideo.pc +pkgconfig/gstreamer-basevideo-uninstalled.pc tools/Makefile m4/Makefile win32/common/config.h diff --git a/pkgconfig/Makefile.am b/pkgconfig/Makefile.am index 99e1f1c1d8..4058adc2fc 100644 --- a/pkgconfig/Makefile.am +++ b/pkgconfig/Makefile.am @@ -1,11 +1,13 @@ ### all of the standard pc files we need to generate pcverfiles = \ gstreamer-plugins-bad-@GST_MAJORMINOR@.pc \ - gstreamer-codecparsers-@GST_MAJORMINOR@.pc + gstreamer-codecparsers-@GST_MAJORMINOR@.pc \ + gstreamer-basevideo-@GST_MAJORMINOR@.pc pcverfiles_uninstalled = \ gstreamer-plugins-bad-@GST_MAJORMINOR@-uninstalled.pc \ - gstreamer-codecparsers-@GST_MAJORMINOR@-uninstalled.pc + gstreamer-codecparsers-@GST_MAJORMINOR@-uninstalled.pc \ + gstreamer-basevideo-@GST_MAJORMINOR@-uninstalled.pc all-local: $(pcverfiles) $(pcverfiles_uninstalled) @@ -25,7 +27,8 @@ pkgconfig_DATA = $(pcverfiles) CLEANFILES = $(pcverfiles) $(pcverfiles_uninstalled) pcinfiles = \ gstreamer-plugins-bad.pc.in gstreamer-plugins-bad-uninstalled.pc.in \ - gstreamer-codecparsers.pc.in gstreamer-codecparsers-uninstalled.pc.in + gstreamer-codecparsers.pc.in gstreamer-codecparsers-uninstalled.pc.in \ + gstreamer-basevideo.pc.in gstreamer-basevideo-uninstalled.pc.in DISTCLEANFILES = $(pcinfiles:.in=) EXTRA_DIST = $(pcinfiles) diff --git a/pkgconfig/gstreamer-basevideo-uninstalled.pc.in b/pkgconfig/gstreamer-basevideo-uninstalled.pc.in new file mode 100644 index 0000000000..50a64c439f --- /dev/null +++ b/pkgconfig/gstreamer-basevideo-uninstalled.pc.in @@ -0,0 +1,12 @@ +prefix= +exec_prefix= +libdir=${pcfiledir}/../gst-libs/gst/basevideo +includedir=${pcfiledir}/../gst-libs + +Name: GStreamer base video, Uninstalled +Description: Base class, interface and utilities for video elements, Uninstalled +Requires: gstreamer-@GST_MAJORMINOR@ gstreamer-base-@GST_MAJORMINOR@ +Version: @VERSION@ +Libs: -L${libdir} ${libdir}/libgstbasevideo-@GST_MAJORMINOR@.la +Cflags: -I${includedir} + diff --git a/pkgconfig/gstreamer-basevideo.pc.in b/pkgconfig/gstreamer-basevideo.pc.in new file mode 100644 index 0000000000..d892fac2da --- /dev/null +++ b/pkgconfig/gstreamer-basevideo.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@/gstreamer-@GST_MAJORMINOR@ + +Name: GStreamer base video +Description: Base class, interface and utilities for video elements +Requires: gstreamer-@GST_MAJORMINOR@ gstreamer-base-@GST_MAJORMINOR@ +Version: @VERSION@ +Libs: -L${libdir} -lgstbasevideo-@GST_MAJORMINOR@ +Cflags: -I${includedir} + From 9f76573bda8013e7fa912a4f45f13a03e061bd66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Thu, 3 Nov 2011 17:17:10 -0400 Subject: [PATCH 7/7] surfaceconverter: Remove duplicated forward declaration It seems that some compilers don't like duplicated typedefs. --- gst-libs/gst/video/gstsurfacebuffer.h | 1 - gst-libs/gst/video/gstsurfaceconverter.h | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/video/gstsurfacebuffer.h b/gst-libs/gst/video/gstsurfacebuffer.h index 1b9bc2544e..6ce6605721 100644 --- a/gst-libs/gst/video/gstsurfacebuffer.h +++ b/gst-libs/gst/video/gstsurfacebuffer.h @@ -49,7 +49,6 @@ G_BEGIN_DECLS */ #define GST_VIDEO_CAPS_SURFACE "video/x-surface" -typedef struct _GstSurfaceBuffer GstSurfaceBuffer; typedef struct _GstSurfaceBufferClass GstSurfaceBufferClass; /** diff --git a/gst-libs/gst/video/gstsurfaceconverter.h b/gst-libs/gst/video/gstsurfaceconverter.h index 2a87557b81..c8fdcc804f 100644 --- a/gst-libs/gst/video/gstsurfaceconverter.h +++ b/gst-libs/gst/video/gstsurfaceconverter.h @@ -32,12 +32,14 @@ G_BEGIN_DECLS +/* Forward declaration from gstsurfacebuffer.h */ +typedef struct _GstSurfaceBuffer GstSurfaceBuffer; + #define GST_TYPE_SURFACE_CONVERTER (gst_surface_converter_get_type ()) #define GST_SURFACE_CONVERTER(obj) (GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SURFACE_CONVERTER, GstSurfaceConverter)) #define GST_IS_SURFACE_CONVERTER(obj) (GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SURFACE_CONVERTER)) #define GST_SURFACE_CONVERTER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_SURFACE_CONVERTER, GstSurfaceConverterInterface)) -typedef struct _GstSurfaceBuffer GstSurfaceBuffer; typedef struct _GstSurfaceConverter GstSurfaceConverter; typedef struct _GstSurfaceConverterInterface GstSurfaceConverterInterface;