Functions¶
Details¶
- GstCheck.buffer_straw_get_buffer(bin, pad)[source]¶
- Parameters:
bin (
Gst.Element
) – the pipeline previously started viaGstCheck.buffer_straw_start_pipeline
()pad (
Gst.Pad
) – the pad previously passed toGstCheck.buffer_straw_start_pipeline
()
- Returns:
the captured
Gst.Buffer
.- Return type:
Get one buffer from pad. Implemented via buffer probes. This function will block until the pipeline passes a buffer over pad, so for robust behavior in unit tests, you need to use check’s timeout to fail out in the case that a buffer never arrives.
You must have previously called
GstCheck.buffer_straw_start_pipeline
() on pipeline and pad.
- GstCheck.buffer_straw_start_pipeline(bin, pad)[source]¶
- Parameters:
bin (
Gst.Element
) – the pipeline to runpad (
Gst.Pad
) – a pad on an element in bin
Sets up a pipeline for buffer sucking. This will allow you to call
GstCheck.buffer_straw_get_buffer
() to access buffers as they pass over pad.This function is normally used in unit tests that want to verify that a particular element is outputting correct buffers. For example, you would make a pipeline via
Gst.parse_launch
(), pull out the pad you want to monitor, then callGstCheck.buffer_straw_get_buffer
() to get the buffers that pass through pad. The pipeline will block until you have sucked off the buffers.This function will set the state of bin to PLAYING; to clean up, be sure to call
GstCheck.buffer_straw_stop_pipeline
().Note that you may not start two buffer straws at the same time. This function is intended for unit tests, not general API use. In fact it calls fail_if from libcheck, so you cannot use it outside unit tests.
- GstCheck.buffer_straw_stop_pipeline(bin, pad)[source]¶
- Parameters:
bin (
Gst.Element
) – the pipeline previously started viaGstCheck.buffer_straw_start_pipeline
()pad (
Gst.Pad
) – the pad previously passed toGstCheck.buffer_straw_start_pipeline
()
Set bin to
Gst.State.NULL
and release resource allocated inGstCheck.buffer_straw_start_pipeline
().You must have previously called
GstCheck.buffer_straw_start_pipeline
() on pipeline and pad.
- GstCheck.check_abi_list(list, have_abi_sizes)[source]¶
- Parameters:
list (
GstCheck.CheckABIStruct
) – A list ofGstCheck.CheckABIStruct
to be verifiedhave_abi_sizes (
bool
) – Whether there is a reference ABI size already specified, if it isFalse
and theGST_ABI
environment variable is set, usable code for list will be printed.
Verifies that reference values and current values are equals in list.
- GstCheck.check_buffer_data(buffer, data, size)[source]¶
- Parameters:
buffer (
Gst.Buffer
) – buffer to comparesize (
int
) – size of data to compare
Compare the buffer contents with data and size.
- GstCheck.check_caps_equal(caps1, caps2)[source]¶
-
Compare two caps with
Gst.Caps.is_equal
and fail unless they are equal.
- GstCheck.check_chain_func(pad, parent, buffer)[source]¶
- Parameters:
pad (
Gst.Pad
) –parent (
Gst.Object
) –buffer (
Gst.Buffer
) –
- Return type:
A fake chain function that appends the buffer to the internal list of buffers.
- GstCheck.check_clear_log_filter()[source]¶
Clear all filters added by gst_check_add_log_filter.
MT safe.
New in version 1.12.
- GstCheck.check_drop_buffers()[source]¶
Unref and remove all buffers that are in the global buffers
GLib.List
, emptying the list.
- GstCheck.check_element_push_buffer(element_name, buffer_in, caps_in, buffer_out, caps_out)[source]¶
- Parameters:
element_name (
str
) – name of the element that needs to be createdbuffer_in (
Gst.Buffer
) – push this buffer to the elementcaps_in (
Gst.Caps
) – theGst.Caps
expected of the sinkpad of the elementbuffer_out (
Gst.Buffer
) – compare the result with this buffercaps_out (
Gst.Caps
) – theGst.Caps
expected of the srcpad of the element
Create an element using the factory providing the element_name and push the buffer_in to this element. The element should create one buffer and this will be compared with buffer_out. We only check the caps and the data of the buffers. This function unrefs the buffers.
- GstCheck.check_element_push_buffer_list(element_name, buffer_in, caps_in, buffer_out, caps_out, last_flow_return)[source]¶
- Parameters:
element_name (
str
) – name of the element that needs to be createdbuffer_in ([
Gst.Buffer
]) – a list of buffers that needs to be pushed to the elementcaps_in (
Gst.Caps
) – theGst.Caps
expected of the sinkpad of the elementbuffer_out ([
Gst.Buffer
]) – a list of buffers that we expect from the elementcaps_out (
Gst.Caps
) – theGst.Caps
expected of the srcpad of the elementlast_flow_return (
Gst.FlowReturn
) – the last buffer push needs to give thisGst.FlowReturn
Create an element using the factory providing the element_name and push the buffers in buffer_in to this element. The element should create the buffers equal to the buffers in buffer_out. We only check the size and the data of the buffers. This function unrefs the buffers in the two lists. The last_flow_return parameter indicates the expected flow return value from pushing the final buffer in the list. This can be used to set up a test which pushes some buffers and then an invalid buffer, when the final buffer is expected to fail, for example.
- GstCheck.check_message_error(message, type, domain, code)[source]¶
- Parameters:
message (
Gst.Message
) –type (
Gst.MessageType
) –domain (
int
) –code (
int
) –
- GstCheck.check_object_destroyed_on_unref(object_to_unref)[source]¶
- Parameters:
object_to_unref (
object
orNone
) – TheGObject.Object
to unref
Unrefs object_to_unref and checks that is has properly been destroyed.
New in version 1.6.
- GstCheck.check_remove_log_filter(filter)[source]¶
- Parameters:
filter (
GstCheck.CheckLogFilter
) – Filter returned by gst_check_add_log_filter
Remove a filter that has been added by gst_check_add_log_filter.
MT safe.
New in version 1.12.
- GstCheck.check_setup_element(factory)[source]¶
- Parameters:
factory (
str
) – factory- Returns:
a new element
- Return type:
setup an element for a filter test with mysrcpad and mysinkpad
- GstCheck.check_setup_events(srcpad, element, caps, format)[source]¶
- Parameters:
element (
Gst.Element
) – TheGst.Element
use to create the stream idcaps (
Gst.Caps
orNone
) –Gst.Caps
in case caps event must be sentformat (
Gst.Format
) – TheGst.Format
of the default segment to send
Push stream-start, caps and segment event, which consist of the minimum required events to allow streaming. Caps is optional to allow raw src testing. If element has more than one src or sink pad, use
GstCheck.check_setup_events_with_stream_id
() instead.
- GstCheck.check_setup_events_with_stream_id(srcpad, element, caps, format, stream_id)[source]¶
- Parameters:
element (
Gst.Element
) – TheGst.Element
use to create the stream idcaps (
Gst.Caps
orNone
) –Gst.Caps
in case caps event must be sentformat (
Gst.Format
) – TheGst.Format
of the default segment to sendstream_id (
str
) – A unique identifier for the stream
Push stream-start, caps and segment event, which consist of the minimum required events to allow streaming. Caps is optional to allow raw src testing.
- GstCheck.check_setup_sink_pad(element, tmpl)[source]¶
- Parameters:
element (
Gst.Element
) – element to setup pad ontmpl (
Gst.StaticPadTemplate
) – pad template
- Returns:
a new pad that can be used to check the output of element
- Return type:
Does the same as
GstCheck.check_setup_sink_pad_by_name
with the name parameter equal to “src”.
- GstCheck.check_setup_sink_pad_by_name(element, tmpl, name)[source]¶
- Parameters:
element (
Gst.Element
) – element to setup pad ontmpl (
Gst.StaticPadTemplate
) – pad templatename (
str
) – Name of the element src pad that will be linked to the sink pad that will be setup
- Returns:
a new pad that can be used to check the output of element
- Return type:
Creates a new sink pad (based on the given tmpl) and links it to the given element src pad (the pad that matches the given name). You can set event/chain/query functions on this pad to check the output of the element.
- GstCheck.check_setup_sink_pad_by_name_from_template(element, tmpl, name)[source]¶
- Parameters:
element (
Gst.Element
) – element to setup pad ontmpl (
Gst.PadTemplate
) – pad templatename (
str
) – name
- Returns:
a new pad
- Return type:
New in version 1.4.
- GstCheck.check_setup_sink_pad_from_template(element, tmpl)[source]¶
- Parameters:
element (
Gst.Element
) – element to setup pad ontmpl (
Gst.PadTemplate
) – pad template
- Returns:
a new pad
- Return type:
New in version 1.4.
- GstCheck.check_setup_src_pad(element, tmpl)[source]¶
- Parameters:
element (
Gst.Element
) – element to setup pad ontmpl (
Gst.StaticPadTemplate
) – pad template
- Returns:
A new pad that can be used to inject data on element
- Return type:
Does the same as
GstCheck.check_setup_src_pad_by_name
with the name parameter equal to “sink”.
- GstCheck.check_setup_src_pad_by_name(element, tmpl, name)[source]¶
- Parameters:
element (
Gst.Element
) – element to setup src pad ontmpl (
Gst.StaticPadTemplate
) – pad templatename (
str
) – Name of the element sink pad that will be linked to the src pad that will be setup
- Returns:
A new pad that can be used to inject data on element
- Return type:
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
GstCheck.check_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
GstCheck.check_element_push_buffer_list
andGstCheck.check_element_push_buffer
.
- GstCheck.check_setup_src_pad_by_name_from_template(element, tmpl, name)[source]¶
- Parameters:
element (
Gst.Element
) – element to setup pad ontmpl (
Gst.PadTemplate
) – pad templatename (
str
) – name
- Returns:
a new pad
- Return type:
New in version 1.4.
- GstCheck.check_setup_src_pad_from_template(element, tmpl)[source]¶
- Parameters:
element (
Gst.Element
) – element to setup pad ontmpl (
Gst.PadTemplate
) – pad template
- Returns:
a new pad
- Return type:
New in version 1.4.
- GstCheck.check_teardown_element(element)[source]¶
- Parameters:
element (
Gst.Element
) –
- GstCheck.check_teardown_pad_by_name(element, name)[source]¶
- Parameters:
element (
Gst.Element
) –name (
str
) –
- GstCheck.check_teardown_sink_pad(element)[source]¶
- Parameters:
element (
Gst.Element
) –
- GstCheck.check_teardown_src_pad(element)[source]¶
- Parameters:
element (
Gst.Element
) –
- GstCheck.consistency_checker_add_pad(consist, pad)[source]¶
- Parameters:
consist (
GstCheck.StreamConsistency
) – TheGstCheck.StreamConsistency
handlepad (
Gst.Pad
) – TheGst.Pad
on which the dataflow will be checked.
- Returns:
True
if the pad was added- Return type:
Sets up a data probe on the given pad which will raise assertions if the data flow is inconsistent.
- GstCheck.consistency_checker_free(consist)[source]¶
- Parameters:
consist (
GstCheck.StreamConsistency
) – TheGstCheck.StreamConsistency
to free.
Frees the allocated data and probes associated with consist.
- GstCheck.consistency_checker_reset(consist)[source]¶
- Parameters:
consist (
GstCheck.StreamConsistency
) – TheGstCheck.StreamConsistency
to reset.
Reset the stream checker’s internal variables.
- GstCheck.harness_stress_thread_stop(t)[source]¶
- Parameters:
- Return type:
Stop the running
GstCheck.HarnessThread
MT safe.
New in version 1.6.