mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
plugins: rework set_context() vmethod definition
In bug 757598 was added the set_context() vmethod chain up in GstVaapiPluginBase. But it is buggy, since the parent_class address is assigned to the last element which called gst_vaapi_plugin_base_class_init(). No error has shown up since none of the element's base classes redefined set_context() vmethod from GstElement, so always the correct function was called. Still this code is wrong and this patch make it right. Since set_context() is the same code, a macro is used to implement that code in all the gst-vaapi elements. https://bugzilla.gnome.org/show_bug.cgi?id=765368
This commit is contained in:
parent
e519f2ea79
commit
bccdda84b7
6 changed files with 40 additions and 15 deletions
|
@ -160,6 +160,7 @@ static const GstVaapiDecoderMap vaapi_decode_map[] = {
|
|||
};
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
GST_VAAPI_PLUGIN_BASE_DEFINE_SET_CONTEXT (parent_class);
|
||||
|
||||
static gboolean gst_vaapidecode_update_sink_caps (GstVaapiDecode * decode,
|
||||
GstCaps * caps);
|
||||
|
@ -1263,6 +1264,7 @@ gst_vaapidecode_class_init (GstVaapiDecodeClass * klass)
|
|||
longname = g_strdup ("VA-API decoder");
|
||||
}
|
||||
|
||||
element_class->set_context = gst_vaapi_base_set_context;
|
||||
gst_element_class_set_static_metadata (element_class, longname,
|
||||
"Codec/Decoder/Video", GST_PLUGIN_DESC,
|
||||
"Gwenole Beauchesne <gwenole.beauchesne@intel.com>, "
|
||||
|
|
|
@ -44,6 +44,8 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstVaapiEncode,
|
|||
gst_vaapiencode, GST_TYPE_VIDEO_ENCODER,
|
||||
GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES);
|
||||
|
||||
GST_VAAPI_PLUGIN_BASE_DEFINE_SET_CONTEXT (gst_vaapiencode_parent_class);
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
@ -629,6 +631,7 @@ gst_vaapiencode_class_init (GstVaapiEncodeClass * klass)
|
|||
|
||||
object_class->finalize = gst_vaapiencode_finalize;
|
||||
|
||||
element_class->set_context = gst_vaapi_base_set_context;
|
||||
element_class->change_state =
|
||||
GST_DEBUG_FUNCPTR (gst_vaapiencode_change_state);
|
||||
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
/* Default debug category is from the subclass */
|
||||
#define GST_CAT_DEFAULT (plugin->debug_category)
|
||||
|
||||
static gpointer plugin_parent_class = NULL;
|
||||
|
||||
/* GstVideoContext interface */
|
||||
static void
|
||||
plugin_set_display (GstVaapiPluginBase * plugin, GstVaapiDisplay * display)
|
||||
|
@ -57,18 +55,25 @@ plugin_set_display (GstVaapiPluginBase * plugin, GstVaapiDisplay * display)
|
|||
gst_vaapi_display_unref (display);
|
||||
}
|
||||
|
||||
static void
|
||||
plugin_set_context (GstElement * element, GstContext * context)
|
||||
/**
|
||||
* gst_vaapi_plugin_base_set_context:
|
||||
* @plugin: a #GstVaapiPluginBase instance
|
||||
* @context: a #GstContext to set
|
||||
*
|
||||
* This is a common set_context() element's vmethod for all the
|
||||
* GStreamer VA-API elements.
|
||||
*
|
||||
* It normally should be used through the macro
|
||||
* #GST_VAAPI_PLUGIN_BASE_DEFINE_SET_CONTEXT()
|
||||
**/
|
||||
void
|
||||
gst_vaapi_plugin_base_set_context (GstVaapiPluginBase * plugin,
|
||||
GstContext * context)
|
||||
{
|
||||
GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (element);
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (plugin_parent_class);
|
||||
GstVaapiDisplay *display = NULL;
|
||||
|
||||
if (gst_vaapi_video_context_get_display (context, &display))
|
||||
plugin_set_display (plugin, display);
|
||||
|
||||
if (element_class->set_context)
|
||||
element_class->set_context (element, context);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -180,14 +185,8 @@ error_create_proxy:
|
|||
void
|
||||
gst_vaapi_plugin_base_class_init (GstVaapiPluginBaseClass * klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
klass->has_interface = default_has_interface;
|
||||
klass->display_changed = default_display_changed;
|
||||
|
||||
plugin_parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
element_class->set_context = GST_DEBUG_FUNCPTR (plugin_set_context);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -102,6 +102,16 @@ typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
|
|||
(gst_vaapi_display_replace(&GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin), \
|
||||
(new_display)))
|
||||
|
||||
#define GST_VAAPI_PLUGIN_BASE_DEFINE_SET_CONTEXT(parent_class) \
|
||||
static void \
|
||||
gst_vaapi_base_set_context (GstElement * element, GstContext * context) \
|
||||
{ \
|
||||
GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (element); \
|
||||
\
|
||||
gst_vaapi_plugin_base_set_context (plugin, context); \
|
||||
GST_ELEMENT_CLASS (parent_class)->set_context (element, context); \
|
||||
}
|
||||
|
||||
struct _GstVaapiPluginBase
|
||||
{
|
||||
/*< private >*/
|
||||
|
@ -220,6 +230,11 @@ GstFlowReturn
|
|||
gst_vaapi_plugin_base_get_input_buffer (GstVaapiPluginBase * plugin,
|
||||
GstBuffer * inbuf, GstBuffer ** outbuf_ptr);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gst_vaapi_plugin_base_set_context (GstVaapiPluginBase * plugin,
|
||||
GstContext * context);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
|
||||
|
|
|
@ -96,6 +96,8 @@ G_DEFINE_TYPE_WITH_CODE (GstVaapiPostproc, gst_vaapipostproc,
|
|||
G_IMPLEMENT_INTERFACE (GST_TYPE_COLOR_BALANCE,
|
||||
gst_vaapipostproc_colorbalance_init));
|
||||
|
||||
GST_VAAPI_PLUGIN_BASE_DEFINE_SET_CONTEXT (gst_vaapipostproc_parent_class);
|
||||
|
||||
static GstVideoFormat native_formats[] =
|
||||
{ GST_VIDEO_FORMAT_NV12, GST_VIDEO_FORMAT_YV12, GST_VIDEO_FORMAT_I420 };
|
||||
|
||||
|
@ -1522,6 +1524,7 @@ gst_vaapipostproc_class_init (GstVaapiPostprocClass * klass)
|
|||
|
||||
trans_class->prepare_output_buffer = gst_vaapipostproc_prepare_output_buffer;
|
||||
|
||||
element_class->set_context = gst_vaapi_base_set_context;
|
||||
gst_element_class_set_static_metadata (element_class,
|
||||
"VA-API video postprocessing",
|
||||
"Filter/Converter/Video;Filter/Converter/Video/Scaler;"
|
||||
|
|
|
@ -107,6 +107,8 @@ G_DEFINE_TYPE_WITH_CODE (GstVaapiSink,
|
|||
G_IMPLEMENT_INTERFACE (GST_TYPE_NAVIGATION,
|
||||
gst_vaapisink_navigation_iface_init));
|
||||
|
||||
GST_VAAPI_PLUGIN_BASE_DEFINE_SET_CONTEXT (gst_vaapisink_parent_class);
|
||||
|
||||
enum
|
||||
{
|
||||
HANDOFF_SIGNAL,
|
||||
|
@ -1663,6 +1665,7 @@ gst_vaapisink_class_init (GstVaapiSinkClass * klass)
|
|||
|
||||
videosink_class->show_frame = GST_DEBUG_FUNCPTR (gst_vaapisink_show_frame);
|
||||
|
||||
element_class->set_context = gst_vaapi_base_set_context;
|
||||
element_class->set_bus = gst_vaapisink_set_bus;
|
||||
gst_element_class_set_static_metadata (element_class,
|
||||
"VA-API sink", "Sink/Video", GST_PLUGIN_DESC,
|
||||
|
|
Loading…
Reference in a new issue