How to parse current capabilities of a pad in a plugin?
ssshukla26
ssshukla26 at gmail.com
Thu Jan 28 01:52:10 PST 2016
Hi,
I want to get capabilities set on my sink pad in a pipe !
Let suppose my pipe is as follows
gst-launch-1.0 -e filesrc location=rawvideo_yuv420.yuv blocksize=460800 !
*video/x-raw,format=I420,width=640,height=480,framerate=30/1* !
myh264encoder silent=true ! decodebin ! autovideosink
My gstreamer plugin is *myh264encoder*.
Now how can I get width as 640 and height as 480 and framerate as 30 from
the caps "*video/x-raw,format=I420,width=640,height=480,framerate=30/1*"
inside my gstreamer plugin's init function ?
I tried the following but it didn't worked
1) This give me width=[ 16, 2147483647 ]
GstPad *pad = gst_pad_new_from_static_template (&sink_factory,"sink");
*GstCaps *caps = gst_pad_get_pad_template_caps (pad);*
GstStructure *structure = gst_caps_get_structure (caps, 0);
gchar *str = gst_value_serialize
(gst_structure_get_value(structure,"width"));
g_print("width = %s\n",str);
g_free(str);
2) This give me width=(null)
GstPad *pad = gst_pad_new_from_static_template (&sink_factory,"sink");
*GstCaps *caps = gst_pad_get_current_caps (pad);*
GstStructure *structure = gst_caps_get_structure (caps, 0);
gchar *str = gst_value_serialize
(gst_structure_get_value(structure,"width"));
g_print("width = %s\n",str);
g_free(str);
3) I used *gst_pad_set_event_function* technique, but am not sure that am
implementing it correctly
- /*Under init function of my plugin I do as below*/
filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
gst_pad_set_event_function
(filter->sinkpad,GST_DEBUG_FUNCPTR(g*st_myencoder_sink_event*));
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
- /*Implementing the sink event function as below*/
static gboolean *gst_myencoder_sink_event* (GstPad * pad, GstObject *
parent, GstEvent * event)
{
gboolean ret;
GstMyEncoder *filter = GST_MYENCODER (parent);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CAPS:
{
GstCaps * caps;
gst_event_parse_caps (event, &caps);
/* do something with the caps */
GstStructure *structure = gst_caps_get_structure (caps, 0);
gchar *str = gst_value_serialize
(gst_structure_get_value(structure,"width"));
g_print("width = %s\n",str);
g_free(str);
/* and forward */
ret = gst_pad_event_default (pad, parent, event);
break;
}
default:
ret = gst_pad_event_default (pad, parent, event);
break;
}
return ret;
}
Please let me know, as my requirement is to parse the caps and initialize
the encoder resply to the caps.
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-to-parse-current-capabilities-of-a-pad-in-a-plugin-tp4675536.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
More information about the gstreamer-devel
mailing list