Functions

buffer_straw_get_buffer(bin: Element, pad: Pad) 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 buffer_straw_start_pipeline() on pipeline and pad.

Parameters:
Returns:

the captured Buffer.

buffer_straw_start_pipeline(bin: Element, pad: Pad) None

Sets up a pipeline for buffer sucking. This will allow you to call 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 parse_launch(), pull out the pad you want to monitor, then call 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 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.

Parameters:
  • bin – the pipeline to run

  • pad – a pad on an element in bin

buffer_straw_stop_pipeline(bin: Element, pad: Pad) None

Set bin to GST_STATE_NULL and release resource allocated in buffer_straw_start_pipeline().

You must have previously called buffer_straw_start_pipeline() on pipeline and pad.

Parameters:
check_abi_list(list: CheckABIStruct, have_abi_sizes: bool) None

Verifies that reference values and current values are equals in list.

Parameters:
  • list – A list of GstCheckABIStruct to be verified

  • have_abi_sizes – Whether there is a reference ABI size already specified, if it is False and the GST_ABI environment variable is set, usable code for list will be printed.

check_buffer_data(buffer: Buffer, data: None, size: int) None

Compare the buffer contents with data and size.

Parameters:
  • buffer – buffer to compare

  • data – data to compare to

  • size – size of data to compare

check_caps_equal(caps1: Caps, caps2: Caps) None

Compare two caps with gst_caps_is_equal and fail unless they are equal.

Parameters:
  • caps1 – first caps to compare

  • caps2 – second caps to compare

check_chain_func(pad: Pad, parent: Object, buffer: Buffer) FlowReturn

A fake chain function that appends the buffer to the internal list of buffers.

Parameters:
  • pad

  • parent

  • buffer

check_clear_log_filter() None

Clear all filters added by gst_check_add_log_filter.

MT safe.

Added in version 1.12.

check_drop_buffers() None

Unref and remove all buffers that are in the global buffers GList, emptying the list.

check_element_push_buffer(element_name: str, buffer_in: Buffer, caps_in: Caps, buffer_out: Buffer, caps_out: Caps) None

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.

Parameters:
  • element_name – name of the element that needs to be created

  • buffer_in – push this buffer to the element

  • caps_in – the Caps expected of the sinkpad of the element

  • buffer_out – compare the result with this buffer

  • caps_out – the Caps expected of the srcpad of the element

check_element_push_buffer_list(element_name: str, buffer_in: list[Buffer], caps_in: Caps, buffer_out: list[Buffer], caps_out: Caps, last_flow_return: FlowReturn) None

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.

Parameters:
  • element_name – name of the element that needs to be created

  • buffer_in – a list of buffers that needs to be pushed to the element

  • caps_in – the Caps expected of the sinkpad of the element

  • buffer_out – a list of buffers that we expect from the element

  • caps_out – the Caps expected of the srcpad of the element

  • last_flow_return – the last buffer push needs to give this GstFlowReturn

check_init(argc: int, argv: str) None
Parameters:
  • argc

  • argv

check_message_error(message: Message, type: MessageType, domain: int, code: int) None
Parameters:
  • message

  • type

  • domain

  • code

check_remove_log_filter(filter: CheckLogFilter) None

Remove a filter that has been added by gst_check_add_log_filter.

MT safe.

Added in version 1.12.

Parameters:

filter – Filter returned by gst_check_add_log_filter

check_setup_element(factory: str) Element

setup an element for a filter test with mysrcpad and mysinkpad

Parameters:

factory – factory

Returns:

a new element

check_setup_events(srcpad: Pad, element: Element, caps: Caps | None, format: Format) None

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 check_setup_events_with_stream_id() instead.

Parameters:
  • srcpad – The src Pad to push on

  • element – The Element use to create the stream id

  • capsCaps in case caps event must be sent

  • format – The Format of the default segment to send

check_setup_events_with_stream_id(srcpad: Pad, element: Element, caps: Caps | None, format: Format, stream_id: str) None

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.

Parameters:
  • srcpad – The src Pad to push on

  • element – The Element use to create the stream id

  • capsCaps in case caps event must be sent

  • format – The Format of the default segment to send

  • stream_id – A unique identifier for the stream

check_setup_sink_pad(element: Element, tmpl: StaticPadTemplate) Pad

Does the same as gst_check_setup_sink_pad_by_name with the <emphasis> name </emphasis> parameter equal to “src”.

Parameters:
  • element – element to setup pad on

  • tmpl – pad template

Returns:

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

check_setup_sink_pad_by_name(element: Element, tmpl: StaticPadTemplate, name: str) 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.

Parameters:
  • element – element to setup pad on

  • tmpl – pad template

  • name – 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

check_setup_sink_pad_by_name_from_template(element: Element, tmpl: PadTemplate, name: str) Pad

Added in version 1.4.

Parameters:
  • element – element to setup pad on

  • tmpl – pad template

  • name – name

Returns:

a new pad

check_setup_sink_pad_from_template(element: Element, tmpl: PadTemplate) Pad

Added in version 1.4.

Parameters:
  • element – element to setup pad on

  • tmpl – pad template

Returns:

a new pad

check_setup_src_pad(element: Element, tmpl: StaticPadTemplate) Pad

Does the same as gst_check_setup_src_pad_by_name with the <emphasis> name </emphasis> parameter equal to “sink”.

Parameters:
  • element – element to setup pad on

  • tmpl – pad template

Returns:

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

check_setup_src_pad_by_name(element: Element, tmpl: StaticPadTemplate, name: str) 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 gst_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 gst_check_element_push_buffer_list and gst_check_element_push_buffer.

Parameters:
  • element – element to setup src pad on

  • tmpl – pad template

  • name – 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

check_setup_src_pad_by_name_from_template(element: Element, tmpl: PadTemplate, name: str) Pad

Added in version 1.4.

Parameters:
  • element – element to setup pad on

  • tmpl – pad template

  • name – name

Returns:

a new pad

check_setup_src_pad_from_template(element: Element, tmpl: PadTemplate) Pad

Added in version 1.4.

Parameters:
  • element – element to setup pad on

  • tmpl – pad template

Returns:

a new pad

check_teardown_element(element: Element) None
Parameters:

element

check_teardown_pad_by_name(element: Element, name: str) None
Parameters:
  • element

  • name

check_teardown_sink_pad(element: Element) None
Parameters:

element

check_teardown_src_pad(element: Element) None
Parameters:

element

consistency_checker_add_pad(consist: StreamConsistency, pad: Pad) bool

Sets up a data probe on the given pad which will raise assertions if the data flow is inconsistent.

Parameters:
Returns:

True if the pad was added

consistency_checker_free(consist: StreamConsistency) None

Frees the allocated data and probes associated with consist.

Parameters:

consist – The StreamConsistency to free.

consistency_checker_reset(consist: StreamConsistency) None

Reset the stream checker’s internal variables.

Parameters:

consist – The StreamConsistency to reset.

harness_stress_thread_stop(t: HarnessThread) int
Parameters:

t