Functions ========= .. currentmodule:: gi.repository.GstCheck .. function:: buffer_straw_get_buffer(bin: ~gi.repository.Gst.Element, pad: ~gi.repository.Gst.Pad) -> ~gi.repository.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 :func:`~gi.repository.GstCheck.buffer_straw_start_pipeline` on ``pipeline`` and ``pad``\. :param bin: the pipeline previously started via :func:`~gi.repository.GstCheck.buffer_straw_start_pipeline` :param pad: the pad previously passed to :func:`~gi.repository.GstCheck.buffer_straw_start_pipeline` :return: the captured :obj:`~gi.repository.Gst.Buffer`\. .. function:: buffer_straw_start_pipeline(bin: ~gi.repository.Gst.Element, pad: ~gi.repository.Gst.Pad) -> None Sets up a pipeline for buffer sucking. This will allow you to call :func:`~gi.repository.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 :func:`~gi.repository.Gst.parse_launch`, pull out the pad you want to monitor, then call :func:`~gi.repository.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 :func:`~gi.repository.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. :param bin: the pipeline to run :param pad: a pad on an element in ``bin`` .. function:: buffer_straw_stop_pipeline(bin: ~gi.repository.Gst.Element, pad: ~gi.repository.Gst.Pad) -> None Set ``bin`` to ``GST_STATE_NULL`` and release resource allocated in :func:`~gi.repository.GstCheck.buffer_straw_start_pipeline`. You must have previously called :func:`~gi.repository.GstCheck.buffer_straw_start_pipeline` on ``pipeline`` and ``pad``\. :param bin: the pipeline previously started via :func:`~gi.repository.GstCheck.buffer_straw_start_pipeline` :param pad: the pad previously passed to :func:`~gi.repository.GstCheck.buffer_straw_start_pipeline` .. function:: check_abi_list(list: ~gi.repository.GstCheck.CheckABIStruct, have_abi_sizes: bool) -> None Verifies that reference values and current values are equals in ``list``\. :param list: A list of GstCheckABIStruct to be verified :param have_abi_sizes: Whether there is a reference ABI size already specified, if it is :const:`False` and the ``GST_ABI`` environment variable is set, usable code for ``list`` will be printed. .. function:: check_buffer_data(buffer: ~gi.repository.Gst.Buffer, data: ~typing.Any, size: int) -> None Compare the buffer contents with ``data`` and ``size``\. :param buffer: buffer to compare :param data: data to compare to :param size: size of data to compare .. function:: check_caps_equal(caps1: ~gi.repository.Gst.Caps, caps2: ~gi.repository.Gst.Caps) -> None Compare two caps with gst_caps_is_equal and fail unless they are equal. :param caps1: first caps to compare :param caps2: second caps to compare .. function:: check_chain_func(pad: ~gi.repository.Gst.Pad, parent: ~gi.repository.Gst.Object, buffer: ~gi.repository.Gst.Buffer) -> ~gi.repository.Gst.FlowReturn A fake chain function that appends the buffer to the internal list of buffers. :param pad: :param parent: :param buffer: .. function:: check_clear_log_filter() -> None Clear all filters added by ``gst_check_add_log_filter``\. MT safe. .. versionadded:: 1.12 .. function:: check_drop_buffers() -> None Unref and remove all buffers that are in the global ``buffers`` GList, emptying the list. .. function:: check_element_push_buffer(element_name: str, buffer_in: ~gi.repository.Gst.Buffer, caps_in: ~gi.repository.Gst.Caps, buffer_out: ~gi.repository.Gst.Buffer, caps_out: ~gi.repository.Gst.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. :param element_name: name of the element that needs to be created :param buffer_in: push this buffer to the element :param caps_in: the :obj:`~gi.repository.Gst.Caps` expected of the sinkpad of the element :param buffer_out: compare the result with this buffer :param caps_out: the :obj:`~gi.repository.Gst.Caps` expected of the srcpad of the element .. function:: check_element_push_buffer_list(element_name: str, buffer_in: list[~gi.repository.Gst.Buffer], caps_in: ~gi.repository.Gst.Caps, buffer_out: list[~gi.repository.Gst.Buffer], caps_out: ~gi.repository.Gst.Caps, last_flow_return: ~gi.repository.Gst.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. :param element_name: name of the element that needs to be created :param buffer_in: a list of buffers that needs to be pushed to the element :param caps_in: the :obj:`~gi.repository.Gst.Caps` expected of the sinkpad of the element :param buffer_out: a list of buffers that we expect from the element :param caps_out: the :obj:`~gi.repository.Gst.Caps` expected of the srcpad of the element :param last_flow_return: the last buffer push needs to give this GstFlowReturn .. function:: check_init(argc: int, argv: str) -> None :param argc: :param argv: .. function:: check_message_error(message: ~gi.repository.Gst.Message, type: ~gi.repository.Gst.MessageType, domain: int, code: int) -> None :param message: :param type: :param domain: :param code: .. function:: check_remove_log_filter(filter: ~gi.repository.GstCheck.CheckLogFilter) -> None Remove a filter that has been added by ``gst_check_add_log_filter``\. MT safe. .. versionadded:: 1.12 :param filter: Filter returned by ``gst_check_add_log_filter`` .. function:: check_setup_element(factory: str) -> ~gi.repository.Gst.Element setup an element for a filter test with mysrcpad and mysinkpad :param factory: factory :return: a new element .. function:: check_setup_events(srcpad: ~gi.repository.Gst.Pad, element: ~gi.repository.Gst.Element, caps: ~gi.repository.Gst.Caps | None, format: ~gi.repository.Gst.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 :func:`~gi.repository.GstCheck.check_setup_events_with_stream_id` instead. :param srcpad: The src :obj:`~gi.repository.Gst.Pad` to push on :param element: The :obj:`~gi.repository.Gst.Element` use to create the stream id :param caps: :obj:`~gi.repository.Gst.Caps` in case caps event must be sent :param format: The :obj:`~gi.repository.Gst.Format` of the default segment to send .. function:: check_setup_events_with_stream_id(srcpad: ~gi.repository.Gst.Pad, element: ~gi.repository.Gst.Element, caps: ~gi.repository.Gst.Caps | None, format: ~gi.repository.Gst.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. :param srcpad: The src :obj:`~gi.repository.Gst.Pad` to push on :param element: The :obj:`~gi.repository.Gst.Element` use to create the stream id :param caps: :obj:`~gi.repository.Gst.Caps` in case caps event must be sent :param format: The :obj:`~gi.repository.Gst.Format` of the default segment to send :param stream_id: A unique identifier for the stream .. function:: check_setup_sink_pad(element: ~gi.repository.Gst.Element, tmpl: ~gi.repository.Gst.StaticPadTemplate) -> ~gi.repository.Gst.Pad Does the same as ``gst_check_setup_sink_pad_by_name`` with the name parameter equal to "src". :param element: element to setup pad on :param tmpl: pad template :return: a new pad that can be used to check the output of ``element`` .. function:: check_setup_sink_pad_by_name(element: ~gi.repository.Gst.Element, tmpl: ~gi.repository.Gst.StaticPadTemplate, name: str) -> ~gi.repository.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``\. :param element: element to setup pad on :param tmpl: pad template :param name: Name of the ``element`` src pad that will be linked to the sink pad that will be setup :return: a new pad that can be used to check the output of ``element`` .. function:: check_setup_sink_pad_by_name_from_template(element: ~gi.repository.Gst.Element, tmpl: ~gi.repository.Gst.PadTemplate, name: str) -> ~gi.repository.Gst.Pad .. versionadded:: 1.4 :param element: element to setup pad on :param tmpl: pad template :param name: name :return: a new pad .. function:: check_setup_sink_pad_from_template(element: ~gi.repository.Gst.Element, tmpl: ~gi.repository.Gst.PadTemplate) -> ~gi.repository.Gst.Pad .. versionadded:: 1.4 :param element: element to setup pad on :param tmpl: pad template :return: a new pad .. function:: check_setup_src_pad(element: ~gi.repository.Gst.Element, tmpl: ~gi.repository.Gst.StaticPadTemplate) -> ~gi.repository.Gst.Pad Does the same as ``gst_check_setup_src_pad_by_name`` with the name parameter equal to "sink". :param element: element to setup pad on :param tmpl: pad template :return: A new pad that can be used to inject data on ``element`` .. function:: check_setup_src_pad_by_name(element: ~gi.repository.Gst.Element, tmpl: ~gi.repository.Gst.StaticPadTemplate, name: str) -> ~gi.repository.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 ``gst_check_setup_events`` on the created src pad. Example of how to push a buffer on ``element``\: .. code-block:: C :dedent: 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``. :param element: element to setup src pad on :param tmpl: pad template :param name: Name of the ``element`` sink pad that will be linked to the src pad that will be setup :return: A new pad that can be used to inject data on ``element`` .. function:: check_setup_src_pad_by_name_from_template(element: ~gi.repository.Gst.Element, tmpl: ~gi.repository.Gst.PadTemplate, name: str) -> ~gi.repository.Gst.Pad .. versionadded:: 1.4 :param element: element to setup pad on :param tmpl: pad template :param name: name :return: a new pad .. function:: check_setup_src_pad_from_template(element: ~gi.repository.Gst.Element, tmpl: ~gi.repository.Gst.PadTemplate) -> ~gi.repository.Gst.Pad .. versionadded:: 1.4 :param element: element to setup pad on :param tmpl: pad template :return: a new pad .. function:: check_teardown_element(element: ~gi.repository.Gst.Element) -> None :param element: .. function:: check_teardown_pad_by_name(element: ~gi.repository.Gst.Element, name: str) -> None :param element: :param name: .. function:: check_teardown_sink_pad(element: ~gi.repository.Gst.Element) -> None :param element: .. function:: check_teardown_src_pad(element: ~gi.repository.Gst.Element) -> None :param element: .. function:: consistency_checker_add_pad(consist: ~gi.repository.GstCheck.StreamConsistency, pad: ~gi.repository.Gst.Pad) -> bool Sets up a data probe on the given pad which will raise assertions if the data flow is inconsistent. :param consist: The :obj:`~gi.repository.GstCheck.StreamConsistency` handle :param pad: The :obj:`~gi.repository.Gst.Pad` on which the dataflow will be checked. :return: :const:`True` if the pad was added .. function:: consistency_checker_free(consist: ~gi.repository.GstCheck.StreamConsistency) -> None Frees the allocated data and probes associated with ``consist``\. :param consist: The :obj:`~gi.repository.GstCheck.StreamConsistency` to free. .. function:: consistency_checker_reset(consist: ~gi.repository.GstCheck.StreamConsistency) -> None Reset the stream checker's internal variables. :param consist: The :obj:`~gi.repository.GstCheck.StreamConsistency` to reset. .. function:: harness_stress_thread_stop(t: ~gi.repository.GstCheck.HarnessThread) -> int :param t: