plugins: factor out GstImplementsInterface.

This commit is contained in:
Gwenole Beauchesne 2013-12-13 13:24:24 +01:00
parent fad3f538bc
commit e5f066b719
8 changed files with 54 additions and 125 deletions

View file

@ -95,24 +95,6 @@ static GstStaticPadTemplate gst_vaapidecode_src_factory =
GST_PAD_ALWAYS,
GST_STATIC_CAPS(gst_vaapidecode_src_caps_str));
/* GstImplementsInterface interface */
#if !GST_CHECK_VERSION(1,0,0)
static gboolean
gst_vaapidecode_implements_interface_supported(
GstImplementsInterface *iface,
GType type
)
{
return (type == GST_TYPE_VIDEO_CONTEXT);
}
static void
gst_vaapidecode_implements_iface_init(GstImplementsInterfaceClass *iface)
{
iface->supported = gst_vaapidecode_implements_interface_supported;
}
#endif
/* GstVideoContext interface */
#if !GST_CHECK_VERSION(1,1,0)
static void
@ -136,10 +118,7 @@ G_DEFINE_TYPE_WITH_CODE(
GstVaapiDecode,
gst_vaapidecode,
GST_TYPE_VIDEO_DECODER,
#if !GST_CHECK_VERSION(1,0,0)
G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
gst_vaapidecode_implements_iface_init);
#endif
GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES
#if !GST_CHECK_VERSION(1,1,0)
G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
gst_video_context_interface_init)

View file

@ -91,22 +91,6 @@ struct _GstVaapiDownloadClass {
GstVaapiPluginBaseClass parent_class;
};
/* GstImplementsInterface interface */
static gboolean
gst_vaapidownload_implements_interface_supported(
GstImplementsInterface *iface,
GType type
)
{
return (type == GST_TYPE_VIDEO_CONTEXT);
}
static void
gst_vaapidownload_implements_iface_init(GstImplementsInterfaceClass *iface)
{
iface->supported = gst_vaapidownload_implements_interface_supported;
}
/* GstVideoContext interface */
static void
gst_vaapidownload_set_video_context(GstVideoContext *context, const gchar *type,
@ -127,8 +111,7 @@ G_DEFINE_TYPE_WITH_CODE(
GstVaapiDownload,
gst_vaapidownload,
GST_TYPE_BASE_TRANSFORM,
G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
gst_vaapidownload_implements_iface_init);
GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES
G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
gst_video_context_interface_init))

View file

@ -42,22 +42,6 @@
GST_DEBUG_CATEGORY_STATIC (gst_vaapiencode_debug);
#define GST_CAT_DEFAULT gst_vaapiencode_debug
/* GstImplementsInterface interface */
#if !GST_CHECK_VERSION(1,0,0)
static gboolean
gst_vaapiencode_implements_interface_supported (GstImplementsInterface * iface,
GType type)
{
return (type == GST_TYPE_VIDEO_CONTEXT);
}
static void
gst_vaapiencode_implements_iface_init (GstImplementsInterfaceClass * iface)
{
iface->supported = gst_vaapiencode_implements_interface_supported;
}
#endif
/* GstContext interface */
#if GST_CHECK_VERSION(1,1,0)
static void
@ -93,10 +77,7 @@ gst_video_context_interface_init (GstVideoContextInterface * iface)
G_DEFINE_TYPE_WITH_CODE (GstVaapiEncode,
gst_vaapiencode, GST_TYPE_VIDEO_ENCODER,
#if !GST_CHECK_VERSION(1,0,0)
G_IMPLEMENT_INTERFACE (GST_TYPE_IMPLEMENTS_INTERFACE,
gst_vaapiencode_implements_iface_init);
#endif
GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES
#if !GST_CHECK_VERSION(1,1,0)
G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_CONTEXT,
gst_video_context_interface_init)

View file

@ -29,6 +29,38 @@
/* Default debug category is from the subclass */
#define GST_CAT_DEFAULT (plugin->debug_category)
/* GstImplementsInterface interface */
#if !GST_CHECK_VERSION(1,0,0)
static gboolean
implements_interface_supported (GstImplementsInterface * iface, GType type)
{
GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (iface);
return GST_VAAPI_PLUGIN_BASE_GET_CLASS (plugin)->has_interface (plugin, type);
}
static void
implements_interface_init (GstImplementsInterfaceClass * iface)
{
iface->supported = implements_interface_supported;
}
#endif
void
gst_vaapi_plugin_base_init_interfaces (GType g_define_type_id)
{
#if !GST_CHECK_VERSION(1,0,0)
G_IMPLEMENT_INTERFACE (GST_TYPE_IMPLEMENTS_INTERFACE,
implements_interface_init);
#endif
}
static gboolean
default_has_interface (GstVaapiPluginBase * plugin, GType type)
{
return FALSE;
}
static void
default_display_changed (GstVaapiPluginBase * plugin)
{
@ -37,6 +69,7 @@ default_display_changed (GstVaapiPluginBase * plugin)
void
gst_vaapi_plugin_base_class_init (GstVaapiPluginBaseClass * klass)
{
klass->has_interface = default_has_interface;
klass->display_changed = default_display_changed;
}
@ -45,7 +78,6 @@ gst_vaapi_plugin_base_init (GstVaapiPluginBase * plugin,
GstDebugCategory * debug_category)
{
plugin->debug_category = debug_category;
plugin->display_type = GST_VAAPI_DISPLAY_TYPE_ANY;
plugin->display_type_req = GST_VAAPI_DISPLAY_TYPE_ANY;
}

View file

@ -68,6 +68,9 @@ typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
#define GST_VAAPI_PLUGIN_BASE_SINK_CLASS(plugin) \
(&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->sink)
#define GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES \
gst_vaapi_plugin_base_init_interfaces(g_define_type_id);
#define GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin) \
(GST_VAAPI_PLUGIN_BASE(plugin)->display)
#define GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(plugin) \
@ -107,9 +110,14 @@ struct _GstVaapiPluginBaseClass
GstVideoSinkClass sink;
} parent_class;
gboolean (*has_interface) (GstVaapiPluginBase * plugin, GType type);
void (*display_changed) (GstVaapiPluginBase * plugin);
};
G_GNUC_INTERNAL
void
gst_vaapi_plugin_base_init_interfaces (GType type);
G_GNUC_INTERNAL
void
gst_vaapi_plugin_base_class_init (GstVaapiPluginBaseClass * klass);

View file

@ -89,24 +89,6 @@ static GstStaticPadTemplate gst_vaapipostproc_src_factory =
GST_PAD_ALWAYS,
GST_STATIC_CAPS(gst_vaapipostproc_src_caps_str));
/* GstImplementsInterface interface */
#if !GST_CHECK_VERSION(1,0,0)
static gboolean
gst_vaapipostproc_implements_interface_supported(
GstImplementsInterface *iface,
GType type
)
{
return (type == GST_TYPE_VIDEO_CONTEXT);
}
static void
gst_vaapipostproc_implements_iface_init(GstImplementsInterfaceClass *iface)
{
iface->supported = gst_vaapipostproc_implements_interface_supported;
}
#endif
/* GstVideoContext interface */
#if !GST_CHECK_VERSION(1,1,0)
static void
@ -137,10 +119,7 @@ G_DEFINE_TYPE_WITH_CODE(
GstVaapiPostproc,
gst_vaapipostproc,
GST_TYPE_BASE_TRANSFORM,
#if !GST_CHECK_VERSION(1,0,0)
G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
gst_vaapipostproc_implements_iface_init);
#endif
GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES
#if !GST_CHECK_VERSION(1,1,0)
G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
gst_video_context_interface_init)

View file

@ -107,25 +107,6 @@ static GstStaticPadTemplate gst_vaapisink_sink_factory =
GST_PAD_ALWAYS,
GST_STATIC_CAPS(gst_vaapisink_sink_caps_str));
/* GstImplementsInterface interface */
#if !GST_CHECK_VERSION(1,0,0)
static gboolean
gst_vaapisink_implements_interface_supported(
GstImplementsInterface *iface,
GType type
)
{
return (type == GST_TYPE_VIDEO_CONTEXT ||
type == GST_TYPE_VIDEO_OVERLAY);
}
static void
gst_vaapisink_implements_iface_init(GstImplementsInterfaceClass *iface)
{
iface->supported = gst_vaapisink_implements_interface_supported;
}
#endif
/* GstVideoContext interface */
#if !GST_CHECK_VERSION(1,1,0)
static void
@ -143,6 +124,12 @@ gst_vaapisink_video_context_iface_init(GstVideoContextInterface *iface)
}
#endif
static gboolean
gst_vaapisink_has_interface(GstVaapiPluginBase *plugin, GType type)
{
return type == GST_TYPE_VIDEO_OVERLAY;
}
static void
gst_vaapisink_video_overlay_iface_init(GstVideoOverlayInterface *iface);
@ -150,10 +137,7 @@ G_DEFINE_TYPE_WITH_CODE(
GstVaapiSink,
gst_vaapisink,
GST_TYPE_VIDEO_SINK,
#if !GST_CHECK_VERSION(1,0,0)
G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
gst_vaapisink_implements_iface_init);
#endif
GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES
#if !GST_CHECK_VERSION(1,1,0)
G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
gst_vaapisink_video_context_iface_init);
@ -1489,6 +1473,7 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
gst_vaapi_plugin_base_class_init(base_plugin_class);
base_plugin_class->has_interface = gst_vaapisink_has_interface;
base_plugin_class->display_changed = gst_vaapisink_display_changed;
object_class->finalize = gst_vaapisink_finalize;

View file

@ -68,23 +68,6 @@ static GstStaticPadTemplate gst_vaapiupload_src_factory =
GST_PAD_ALWAYS,
GST_STATIC_CAPS(gst_vaapiupload_vaapi_caps_str));
/* GstImplementsInterface interface */
static gboolean
gst_vaapiupload_implements_interface_supported(
GstImplementsInterface *iface,
GType type
)
{
return (type == GST_TYPE_VIDEO_CONTEXT);
}
static void
gst_vaapiupload_implements_iface_init(GstImplementsInterfaceClass *iface)
{
iface->supported = gst_vaapiupload_implements_interface_supported;
}
/* GstVideoContext interface */
static void
gst_vaapiupload_set_video_context(GstVideoContext *context, const gchar *type,
@ -110,8 +93,7 @@ G_DEFINE_TYPE_WITH_CODE(
GstVaapiUpload,
gst_vaapiupload,
GST_TYPE_BASE_TRANSFORM,
G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
gst_vaapiupload_implements_iface_init);
GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES
G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
gst_video_context_interface_init))