Creates a new src pad (based on the given tmpl
) and links it to the given element
sink pad (the pad that
matches the given name
).
Before using the src pad to push data on element
you need to call
setup_events on the created src pad.
Example of how to push a buffer on element
:
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (YOUR_CAPS_TEMPLATE_STRING)
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (YOUR_CAPS_TEMPLATE_STRING)
);
GstElement * element = gst_check_setup_element ("element");
GstPad * mysrcpad = gst_check_setup_src_pad (element, &srctemplate);
GstPad * mysinkpad = gst_check_setup_sink_pad (element, &sinktemplate);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
fail_unless (gst_element_set_state (element, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, "could not set to playing");
GstCaps * caps = gst_caps_from_string (YOUR_DESIRED_SINK_CAPS);
gst_check_setup_events (mysrcpad, element, caps, GST_FORMAT_TIME);
gst_caps_unref (caps);
fail_unless (gst_pad_push (mysrcpad, gst_buffer_new_and_alloc(2)) == GST_FLOW_OK);
For very simple input/output test scenarios checkout element_push_buffer_list and element_push_buffer.
element |
element to setup src pad on |
tmpl |
pad template |
name |
Name of the |
A new pad that can be used to inject data on |