vaapidecodebin: Misc enhancements.

- Use GST_WARNING rather than g_critical

- Replace gst_ghost_pad_new_from_template() with
  gst_ghost_pad_new() to avoid using the template.

- Declare extern variable

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1405>
This commit is contained in:
Víctor Manuel Jáquez Leal 2021-12-01 15:36:44 +01:00
parent 90df5b5ab8
commit d10ad61891

View file

@ -118,6 +118,8 @@ GST_STATIC_PAD_TEMPLATE ("src",
G_DEFINE_TYPE (GstVaapiDecodeBin, gst_vaapi_decode_bin, GST_TYPE_BIN);
extern gboolean _gst_vaapi_has_video_processing;
static gboolean gst_vaapi_decode_bin_configure (GstVaapiDecodeBin * self);
static void
@ -409,30 +411,30 @@ gst_vaapi_decode_bin_init (GstVaapiDecodeBin * vaapidecbin)
g_assert (vaapidecbin->decoder);
/* create the queue */
vaapidecbin->queue = gst_element_factory_make ("queue", "vaapi-queue");
if (!vaapidecbin->queue) {
gst_clear_object (&vaapidecbin->decoder);
post_missing_element_message (vaapidecbin, "queue");
return;
}
vaapidecbin->queue = gst_element_factory_make ("queue", NULL);
g_assert (vaapidecbin->queue);
gst_bin_add_many (GST_BIN (vaapidecbin), vaapidecbin->decoder,
vaapidecbin->queue, NULL);
if (!gst_element_link (vaapidecbin->decoder, vaapidecbin->queue)) {
gst_clear_object (&vaapidecbin->decoder);
gst_clear_object (&vaapidecbin->queue);
g_critical ("failed to link decoder and queue");
GST_WARNING_OBJECT (vaapidecbin, "Failed to link decoder and queue");
return;
}
/* create ghost pad sink */
pad = gst_element_get_static_pad (vaapidecbin->decoder, "sink");
ghostpad = gst_ghost_pad_new_from_template ("sink", pad,
GST_PAD_PAD_TEMPLATE (pad));
if (!pad) {
GST_WARNING_OBJECT (vaapidecbin, "Failed to get decoder sink pad");
return;
}
ghostpad = gst_ghost_pad_new ("sink", pad);
gst_object_unref (pad);
if (!gst_element_add_pad (GST_ELEMENT (vaapidecbin), ghostpad))
g_critical ("failed to add decoder sink pad to bin");
if (!gst_element_add_pad (GST_ELEMENT (vaapidecbin), ghostpad)) {
GST_WARNING_OBJECT (vaapidecbin, "Failed to add decoder sink pad to bin");
return;
}
/* create ghost pad src */
pad = gst_element_get_static_pad (GST_ELEMENT (vaapidecbin->queue), "src");
@ -440,5 +442,5 @@ gst_vaapi_decode_bin_init (GstVaapiDecodeBin * vaapidecbin)
GST_PAD_PAD_TEMPLATE (pad));
gst_object_unref (pad);
if (!gst_element_add_pad (GST_ELEMENT (vaapidecbin), ghostpad))
g_critical ("failed to add queue source pad to bin");
GST_WARNING_OBJECT (vaapidecbin, "Failed to add queue source pad to bin");
}