Hi experts: I’m adding a video conversion element (vaSurface based), caps negotiation goes ok on its sinkpad. But when I try to add caps negotiation on its src pad to support downlink capsfilter, setcaps isn’t invoked at all, though getacps is called: Is there anything I missed to support src pad caps negotiation? I noticed that most audio/video conversion element uses GstBaseTransformClass as parent_class, while I’m using GstElementClass. Do I have to use GstbaseTransformClass instead? thanks source code reference is here: diff --git a/gst/vaapi/gstvaapipostproc.c b/gst/vaapi/gstvaapipostproc.c index 67a82ee..6b4aa00 100755 --- a/gst/vaapi/gstvaapipostproc.c +++ b/gst/vaapi/gstvaapipostproc.c @@ -41,6 +41,9 @@ #define GST_PLUGIN_NAME "vaapipostproc" #define GST_PLUGIN_DESC "A video postprocessing filter" +#define PRINT_MARK_ printf(" %s, %s, %d ", __FILE__, __FUNCTION__, __LINE__) +#define PRINT_MARK printf(" %s, %s, %d \n", __FILE__, __FUNCTION__, __LINE__) +#define PRINTF printf GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapipostproc); #define GST_CAT_DEFAULT gst_debug_vaapipostproc @@ -263,6 +266,7 @@ static gboolean gst_vaapipostproc_context_deinit(GstVaapiPostproc *postproc) } free (vpp); + postproc->vpp = NULL; return TRUE; } @@ -771,8 +775,8 @@ gst_vaapipostproc_ensure_allowed_caps(GstVaapiPostproc *postproc) } static GstCaps * -gst_vaapipostproc_get_caps(GstPad *pad) -{ +gst_vaapipostproc_sinkpad_get_caps(GstPad *pad) +{ PRINT_MARK; GstVaapiPostproc * const postproc = get_vaapipostproc_from_pad(pad); GstCaps *out_caps; @@ -785,17 +789,50 @@ gst_vaapipostproc_get_caps(GstPad *pad) return out_caps; } +static GstCaps * +gst_vaapipostproc_srcpad_get_caps(GstPad *pad) +{ PRINT_MARK; + GstVaapiPostproc * const postproc = get_vaapipostproc_from_pad(pad); + GstCaps *out_caps; + + if (gst_vaapipostproc_ensure_allowed_caps(postproc)) + out_caps = gst_caps_ref(postproc->allowed_caps); + else + out_caps = gst_caps_new_empty(); + + gst_object_unref(postproc); + PRINT_MARK_; PRINTF("out_caps: %s\n", gst_caps_to_string(out_caps)); + return out_caps; +} static gboolean -gst_vaapipostproc_set_caps(GstPad *pad, GstCaps *caps) -{ +gst_vaapipostproc_sinkpad_set_caps(GstPad *pad, GstCaps *caps) +{ PRINT_MARK; GstVaapiPostproc * const postproc = get_vaapipostproc_from_pad(pad); gboolean success = FALSE; g_return_val_if_fail(pad == postproc->sinkpad, FALSE); + PRINTF("%s, caps: %s\n", __FUNCTION__, gst_caps_to_string(caps)); do { if (!gst_vaapipostproc_update_sink_caps(postproc, caps)) break; + success = TRUE; + } while (0); + gst_object_unref(postproc); + return success; +} + +// todo gst_vaapipostproc_reset should be done in both srcpad_set_caps and sinkpad_set_caps +static gboolean +gst_vaapipostproc_srcpad_set_caps(GstPad *pad, GstCaps *caps) +{ PRINT_MARK; + GstVaapiPostproc * const postproc = get_vaapipostproc_from_pad(pad); + gboolean success = FALSE; + + g_return_val_if_fail(pad == postproc->srcpad, FALSE); + + PRINTF("%s, caps: %s\n", __FUNCTION__, gst_caps_to_string(caps)); + do { if (!gst_vaapipostproc_update_src_caps(postproc, caps)) break; if (!gst_vaapipostproc_reset(postproc, postproc->sinkpad_caps)) @@ -1201,8 +1238,8 @@ gst_vaapipostproc_init(GstVaapiPostproc *postproc) ); postproc->sinkpad_caps = NULL; - gst_pad_set_getcaps_function(postproc->sinkpad, gst_vaapipostproc_get_caps); - gst_pad_set_setcaps_function(postproc->sinkpad, gst_vaapipostproc_set_caps); + gst_pad_set_getcaps_function(postproc->sinkpad, gst_vaapipostproc_sinkpad_get_caps); + gst_pad_set_setcaps_function(postproc->sinkpad, gst_vaapipostproc_sinkpad_set_caps); gst_pad_set_chain_function(postproc->sinkpad, gst_vaapipostproc_chain); gst_pad_set_event_function(postproc->sinkpad, gst_vaapipostproc_sink_event); gst_pad_set_query_function(postproc->sinkpad, gst_vaapipostproc_query); @@ -1215,6 +1252,9 @@ gst_vaapipostproc_init(GstVaapiPostproc *postproc) ); postproc->srcpad_caps = NULL; + gst_pad_set_getcaps_function(postproc->srcpad, gst_vaapipostproc_srcpad_get_caps); + gst_pad_set_setcaps_function(postproc->srcpad, gst_vaapipostproc_srcpad_set_caps); + // gst_pad_set_chain_function(postproc->srcpad, gst_vaapipostproc_chain); gst_pad_set_event_function(postproc->srcpad, gst_vaapipostproc_src_event); gst_pad_set_query_function(postproc->srcpad, gst_vaapipostproc_query); gst_element_add_pad(GST_ELEMENT(postproc), postproc->srcpad); _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |