Functions

  buffer_straw_get_buffer (bin, pad)
  buffer_straw_start_pipeline (bin, pad)
  buffer_straw_stop_pipeline (bin, pad)
  check_abi_list (list, have_abi_sizes)
  check_buffer_data (buffer, data, size)
  check_caps_equal (caps1, caps2)
  check_chain_func (pad, parent, buffer)
  check_clear_log_filter ()
  check_drop_buffers ()
  check_element_push_buffer (element_name, buffer_in, caps_in, buffer_out, caps_out)
  check_element_push_buffer_list (element_name, buffer_in, caps_in, buffer_out, caps_out, last_flow_return)
  check_init (argc, argv)
  check_message_error (message, type, domain, code)
  check_object_destroyed_on_unref (object_to_unref)
  check_remove_log_filter (filter)
  check_setup_element (factory)
  check_setup_events (srcpad, element, caps, format)
  check_setup_events_with_stream_id (srcpad, element, caps, format, stream_id)
  check_setup_sink_pad (element, tmpl)
  check_setup_sink_pad_by_name (element, tmpl, name)
  check_setup_sink_pad_by_name_from_template (element, tmpl, name)
  check_setup_sink_pad_from_template (element, tmpl)
  check_setup_src_pad (element, tmpl)
  check_setup_src_pad_by_name (element, tmpl, name)
  check_setup_src_pad_by_name_from_template (element, tmpl, name)
  check_setup_src_pad_from_template (element, tmpl)
  check_teardown_element (element)
  check_teardown_pad_by_name (element, name)
  check_teardown_sink_pad (element)
  check_teardown_src_pad (element)
  consistency_checker_add_pad (consist, pad)
  consistency_checker_free (consist)
  consistency_checker_reset (consist)
  harness_stress_thread_stop (t)

Details

GstCheck.buffer_straw_get_buffer(bin, pad)[source]
Parameters:
Returns:

the captured Gst.Buffer.

Return type:

Gst.Buffer

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:

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 call GstCheck.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:

Set bin to Gst.State.NULL and release resource allocated in GstCheck.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:
GstCheck.check_buffer_data(buffer, data, size)[source]
Parameters:
  • buffer (Gst.Buffer) – buffer to compare
  • data (object or None) – data to compare to
  • size (int) – size of data to compare

Compare the buffer contents with data and size.

GstCheck.check_caps_equal(caps1, caps2)[source]
Parameters:
  • caps1 (Gst.Caps) – first caps to compare
  • caps2 (Gst.Caps) – second caps to compare

Compare two caps with Gst.Caps.is_equal and fail unless they are equal.

GstCheck.check_chain_func(pad, parent, buffer)[source]
Parameters:
Return type:

Gst.FlowReturn

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 created
  • buffer_in (Gst.Buffer) – push this buffer to the element
  • caps_in (Gst.Caps) – the Gst.Caps expected of the sinkpad of the element
  • buffer_out (Gst.Buffer) – compare the result with this buffer
  • caps_out (Gst.Caps) – the Gst.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 created
  • buffer_in ([Gst.Buffer]) – a list of buffers that needs to be pushed to the element
  • caps_in (Gst.Caps) – the Gst.Caps expected of the sinkpad of the element
  • buffer_out ([Gst.Buffer]) – a list of buffers that we expect from the element
  • caps_out (Gst.Caps) – the Gst.Caps expected of the srcpad of the element
  • last_flow_return (Gst.FlowReturn) – the last buffer push needs to give this Gst.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_init(argc, argv)[source]
Parameters:
  • argc (int) –
  • argv (str) –
GstCheck.check_message_error(message, type, domain, code)[source]
Parameters:
GstCheck.check_object_destroyed_on_unref(object_to_unref)[source]
Parameters:object_to_unref (object or None) – The GObject.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:Gst.Element

setup an element for a filter test with mysrcpad and mysinkpad

GstCheck.check_setup_events(srcpad, element, caps, format)[source]
Parameters:

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:

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:
Returns:

a new pad that can be used to check the output of element

Return type:

Gst.Pad

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 on
  • tmpl (Gst.StaticPadTemplate) – pad template
  • name (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:

Gst.Pad

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:
Returns:

a new pad

Return type:

Gst.Pad

New in version 1.4.

GstCheck.check_setup_sink_pad_from_template(element, tmpl)[source]
Parameters:
Returns:

a new pad

Return type:

Gst.Pad

New in version 1.4.

GstCheck.check_setup_src_pad(element, tmpl)[source]
Parameters:
Returns:

A new pad that can be used to inject data on element

Return type:

Gst.Pad

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 on
  • tmpl (Gst.StaticPadTemplate) – pad template
  • name (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:

Gst.Pad

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 and GstCheck.check_element_push_buffer.

GstCheck.check_setup_src_pad_by_name_from_template(element, tmpl, name)[source]
Parameters:
Returns:

a new pad

Return type:

Gst.Pad

New in version 1.4.

GstCheck.check_setup_src_pad_from_template(element, tmpl)[source]
Parameters:
Returns:

a new pad

Return type:

Gst.Pad

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:
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:
Returns:

True if the pad was added

Return type:

bool

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) – The GstCheck.StreamConsistency to free.

Frees the allocated data and probes associated with consist.

GstCheck.consistency_checker_reset(consist)[source]
Parameters:consist (GstCheck.StreamConsistency) – The GstCheck.StreamConsistency to reset.

Reset the stream checker’s internal variables.

GstCheck.harness_stress_thread_stop(t)[source]
Parameters:t (GstCheck.HarnessThread) – a GstCheck.HarnessThread
Return type:int

Stop the running GstCheck.HarnessThread

MT safe.

New in version 1.6.