:right-sidebar: True Harness =================================================================== .. currentmodule:: gi.repository.GstCheck .. versionadded:: 1.6 .. class:: Harness(*args, **kwargs) :no-contents-entry: :obj:`~gi.repository.GstCheck.Harness` is meant to make writing unit test for GStreamer much easier. It can be thought of as a way of treating a :obj:`~gi.repository.Gst.Element` as a black box, deterministically feeding it data, and controlling what data it outputs. The basic structure of :obj:`~gi.repository.GstCheck.Harness` is two "floating" :obj:`~gi.repository.Gst.Pad` that connect to the harnessed :obj:`~gi.repository.Gst.Element` src and sink :obj:`~gi.repository.Gst.Pad` like so: .. code-block:: :dedent: __________________________ _____ | _____ _____ | _____ | | | | | | | | | | | src |--+-| sink| Element | src |-+--| sink| |_____| | |_____| |_____| | |_____| |__________________________| With this, you can now simulate any environment the :obj:`~gi.repository.Gst.Element` might find itself in. By specifying the :obj:`~gi.repository.Gst.Caps` of the harness :obj:`~gi.repository.Gst.Pad`\, using functions like :func:`~gi.repository.GstCheck.Harness.set_src_caps` or :func:`~gi.repository.GstCheck.Harness.set_sink_caps_str`, you can test how the :obj:`~gi.repository.Gst.Element` interacts with different caps sets. Your harnessed :obj:`~gi.repository.Gst.Element` can of course also be a bin, and using :func:`~gi.repository.GstCheck.Harness.new_parse` supporting standard gst-launch syntax, you can easily test a whole pipeline instead of just one element. You can then go on to push :obj:`~gi.repository.Gst.Buffer` and :obj:`~gi.repository.Gst.Event` on to the srcpad, using functions like :func:`~gi.repository.GstCheck.Harness.push` and :func:`~gi.repository.GstCheck.Harness.push_event`, and then pull them out to examine them with :func:`~gi.repository.GstCheck.Harness.pull` and :func:`~gi.repository.GstCheck.Harness.pull_event`. A simple buffer-in buffer-out example -------------------------------------------------------------------------------- .. code-block:: C :dedent: #include #include GstHarness *h; GstBuffer *in_buf; GstBuffer *out_buf; // attach the harness to the src and sink pad of GstQueue h = gst_harness_new ("queue"); // we must specify a caps before pushing buffers gst_harness_set_src_caps_str (h, "mycaps"); // create a buffer of size 42 in_buf = gst_harness_create_buffer (h, 42); // push the buffer into the queue gst_harness_push (h, in_buf); // pull the buffer from the queue out_buf = gst_harness_pull (h); // validate the buffer in is the same as buffer out fail_unless (in_buf == out_buf); // cleanup gst_buffer_unref (out_buf); gst_harness_teardown (h); Another main feature of the :obj:`~gi.repository.GstCheck.Harness` is its integration with the :obj:`~gi.repository.GstCheck.TestClock`\. Operating the :obj:`~gi.repository.GstCheck.TestClock` can be very challenging, but :obj:`~gi.repository.GstCheck.Harness` simplifies some of the most desired actions a lot, like wanting to manually advance the clock while at the same time releasing a :obj:`~gi.repository.Gst.ClockID` that is waiting, with functions like :func:`~gi.repository.GstCheck.Harness.crank_single_clock_wait`. :obj:`~gi.repository.GstCheck.Harness` also supports sub-harnesses, as a way of generating and validating data. A sub-harness is another :obj:`~gi.repository.GstCheck.Harness` that is managed by the "parent" harness, and can either be created by using the standard gst_harness_new type functions directly on the (GstHarness \*)->src_harness, or using the much more convenient :func:`~gi.repository.GstCheck.Harness.add_src` or :func:`~gi.repository.GstCheck.Harness.add_sink_parse`. If you have a decoder-element you want to test, (like vp8dec) it can be very useful to add a src-harness with both a src-element (videotestsrc) and an encoder (vp8enc) to feed the decoder data with different configurations, by simply doing: .. code-block:: C :dedent: GstHarness * h = gst_harness_new ("vp8dec"); gst_harness_add_src_parse (h, "videotestsrc is-live=1 ! vp8enc", TRUE); and then feeding it data with: .. code-block:: C :dedent: gst_harness_push_from_src (h); Methods ------- .. rst-class:: interim-class .. class:: Harness :no-index: .. method:: add_element_sink_pad(sinkpad: ~gi.repository.Gst.Pad) -> None Links the specified :obj:`~gi.repository.Gst.Pad` the ``GstHarness`` srcpad. MT safe. .. versionadded:: 1.6 :param sinkpad: a :obj:`~gi.repository.Gst.Pad` to link to the harness srcpad .. method:: add_element_src_pad(srcpad: ~gi.repository.Gst.Pad) -> None Links the specified :obj:`~gi.repository.Gst.Pad` the ``GstHarness`` sinkpad. This can be useful if perhaps the srcpad did not exist at the time of creating the harness, like a demuxer that provides a sometimes-pad after receiving data. MT safe. .. versionadded:: 1.6 :param srcpad: a :obj:`~gi.repository.Gst.Pad` to link to the harness sinkpad .. method:: add_probe(element_name: str, pad_name: str, mask: ~gi.repository.Gst.PadProbeType, callback: ~typing.Callable[[~gi.repository.Gst.Pad, ~gi.repository.Gst.PadProbeInfo, ~typing.Any], ~gi.repository.Gst.PadProbeReturn], user_data: ~typing.Any = None) -> None A convenience function to allows you to call gst_pad_add_probe on a :obj:`~gi.repository.Gst.Pad` of a :obj:`~gi.repository.Gst.Element` that are residing inside the :obj:`~gi.repository.GstCheck.Harness`\, by using normal gst_pad_add_probe syntax MT safe. .. versionadded:: 1.6 :param element_name: a :obj:`~gi.repository.utf8` with a :obj:`~gi.repository.Gst.ElementFactory` name :param pad_name: a :obj:`~gi.repository.utf8` with the name of the pad to attach the probe to :param mask: a :obj:`~gi.repository.Gst.PadProbeType` (see gst_pad_add_probe) :param callback: a :obj:`~gi.repository.Gst.PadProbeCallback` (see gst_pad_add_probe) :param user_data: a :obj:`~gi.repository.gpointer` (see gst_pad_add_probe) .. method:: add_propose_allocation_meta(api: ~gobject.GType, params: ~gi.repository.Gst.Structure | None = None) -> None Add api with params as one of the supported metadata API to propose when receiving an allocation query. MT safe. .. versionadded:: 1.16 :param api: a metadata API :param params: API specific parameters .. method:: add_sink(sink_element_name: str) -> None Similar to gst_harness_add_sink_harness, this is a convenience to directly create a sink-harness using the ``sink_element_name`` name specified. MT safe. .. versionadded:: 1.6 :param sink_element_name: a :obj:`~gi.repository.utf8` with the name of a :obj:`~gi.repository.Gst.Element` .. method:: add_sink_harness(sink_harness: ~gi.repository.GstCheck.Harness) -> None Similar to gst_harness_add_src, this allows you to send the data coming out of your harnessed :obj:`~gi.repository.Gst.Element` to a sink-element, allowing to test different responses the element output might create in sink elements. An example might be an existing sink providing some analytical data on the input it receives that can be useful to your testing. If the goal is to test a sink-element itself, this is better achieved using gst_harness_new directly on the sink. If a sink-harness already exists it will be replaced. MT safe. .. versionadded:: 1.6 :param sink_harness: a :obj:`~gi.repository.GstCheck.Harness` to be added as a sink-harness. .. method:: add_sink_parse(launchline: str) -> None Similar to gst_harness_add_sink, this allows you to specify a launch-line instead of just an element name. See gst_harness_add_src_parse for details. MT safe. .. versionadded:: 1.6 :param launchline: a :obj:`~gi.repository.utf8` with the name of a :obj:`~gi.repository.Gst.Element` .. method:: add_src(src_element_name: str, has_clock_wait: bool) -> None Similar to gst_harness_add_src_harness, this is a convenience to directly create a src-harness using the ``src_element_name`` name specified. MT safe. .. versionadded:: 1.6 :param src_element_name: a :obj:`~gi.repository.utf8` with the name of a :obj:`~gi.repository.Gst.Element` :param has_clock_wait: a :obj:`~gi.repository.gboolean` specifying if the :obj:`~gi.repository.Gst.Element` uses gst_clock_wait_id internally. .. method:: add_src_harness(src_harness: ~gi.repository.GstCheck.Harness, has_clock_wait: bool) -> None A src-harness is a great way of providing the :obj:`~gi.repository.GstCheck.Harness` with data. By adding a src-type :obj:`~gi.repository.Gst.Element`\, it is then easy to use functions like gst_harness_push_from_src or gst_harness_src_crank_and_push_many to provide your harnessed element with input. The ``has_clock_wait`` variable is a great way to control you src-element with, in that you can have it produce a buffer for you by simply cranking the clock, and not have it spin out of control producing buffers as fast as possible. If a src-harness already exists it will be replaced. MT safe. .. versionadded:: 1.6 :param src_harness: a :obj:`~gi.repository.GstCheck.Harness` to be added as a src-harness. :param has_clock_wait: a :obj:`~gi.repository.gboolean` specifying if the :obj:`~gi.repository.Gst.Element` uses gst_clock_wait_id internally. .. method:: add_src_parse(launchline: str, has_clock_wait: bool) -> None Similar to gst_harness_add_src, this allows you to specify a launch-line, which can be useful for both having more then one :obj:`~gi.repository.Gst.Element` acting as your src (Like a src producing raw buffers, and then an encoder, providing encoded data), but also by allowing you to set properties like "is-live" directly on the elements. MT safe. .. versionadded:: 1.6 :param launchline: a :obj:`~gi.repository.utf8` describing a gst-launch type line :param has_clock_wait: a :obj:`~gi.repository.gboolean` specifying if the :obj:`~gi.repository.Gst.Element` uses gst_clock_wait_id internally. .. method:: buffers_in_queue() -> int The number of :obj:`~gi.repository.Gst.Buffer` currently in the :obj:`~gi.repository.GstCheck.Harness` sinkpad :obj:`~gi.repository.GLib.AsyncQueue` MT safe. .. versionadded:: 1.6 .. method:: buffers_received() -> int The total number of :obj:`~gi.repository.Gst.Buffer` that has arrived on the :obj:`~gi.repository.GstCheck.Harness` sinkpad. This number includes buffers that have been dropped as well as buffers that have already been pulled out. MT safe. .. versionadded:: 1.6 .. method:: crank_multiple_clock_waits(waits: int) -> bool Similar to :func:`~gi.repository.GstCheck.Harness.crank_single_clock_wait`, this is the function to use if your harnessed element(s) are using more then one gst_clock_id_wait. Failing to do so can (and will) make it racy which :obj:`~gi.repository.Gst.ClockID` you actually are releasing, where as this function will process all the waits at the same time, ensuring that one thread can't register another wait before both are released. MT safe. .. versionadded:: 1.6 :param waits: a :obj:`int` describing the number of :obj:`~gi.repository.Gst.ClockID` to crank .. method:: crank_single_clock_wait() -> bool A "crank" consists of three steps: 1: Wait for a :obj:`~gi.repository.Gst.ClockID` to be registered with the :obj:`~gi.repository.GstCheck.TestClock`\. 2: Advance the :obj:`~gi.repository.GstCheck.TestClock` to the time the :obj:`~gi.repository.Gst.ClockID` is waiting for. 3: Release the :obj:`~gi.repository.Gst.ClockID` wait. Together, this provides an easy way to not have to think about the details around clocks and time, but still being able to write deterministic tests that are dependent on this. A "crank" can be though of as the notion of manually driving the clock forward to its next logical step. MT safe. .. versionadded:: 1.6 .. method:: create_buffer(size: int) -> ~gi.repository.Gst.Buffer Allocates a buffer using a :obj:`~gi.repository.Gst.BufferPool` if present, or else using the configured :obj:`~gi.repository.Gst.Allocator` and :obj:`~gi.repository.Gst.AllocationParams` MT safe. .. versionadded:: 1.6 :param size: a :obj:`~gi.repository.gsize` specifying the size of the buffer .. method:: dump_to_file(filename: str) -> None Allows you to dump the :obj:`~gi.repository.Gst.Buffer` the :obj:`~gi.repository.GstCheck.Harness` sinkpad :obj:`~gi.repository.GLib.AsyncQueue` to a file. MT safe. .. versionadded:: 1.6 :param filename: a :obj:`~gi.repository.utf8` with a the name of a file .. method:: events_in_queue() -> int The number of :obj:`~gi.repository.Gst.Event` currently in the :obj:`~gi.repository.GstCheck.Harness` sinkpad :obj:`~gi.repository.GLib.AsyncQueue` MT safe. .. versionadded:: 1.6 .. method:: events_received() -> int The total number of :obj:`~gi.repository.Gst.Event` that has arrived on the :obj:`~gi.repository.GstCheck.Harness` sinkpad This number includes events handled by the harness as well as events that have already been pulled out. MT safe. .. versionadded:: 1.6 .. method:: find_element(element_name: str) -> ~gi.repository.Gst.Element | None Most useful in conjunction with gst_harness_new_parse, this will scan the :obj:`~gi.repository.Gst.Element` inside the :obj:`~gi.repository.GstCheck.Harness`\, and check if any of them matches ``element_name``\. Typical usecase being that you need to access one of the harnessed elements for properties and/or signals. MT safe. .. versionadded:: 1.6 :param element_name: a :obj:`~gi.repository.utf8` with a :obj:`~gi.repository.Gst.ElementFactory` name .. method:: get_allocator() -> ~typing.Tuple[~gi.repository.Gst.Allocator | None, ~gi.repository.Gst.AllocationParams] Gets the ``allocator`` and its ``params`` that has been decided to use after an allocation query. MT safe. .. versionadded:: 1.6 .. method:: get_last_pushed_timestamp() -> int Get the timestamp of the last :obj:`~gi.repository.Gst.Buffer` pushed on the :obj:`~gi.repository.GstCheck.Harness` srcpad, typically with gst_harness_push or gst_harness_push_from_src. MT safe. .. versionadded:: 1.6 .. method:: get_testclock() -> ~gi.repository.GstCheck.TestClock | None Get the :obj:`~gi.repository.GstCheck.TestClock`\. Useful if specific operations on the testclock is needed. MT safe. .. versionadded:: 1.6 .. method:: play() -> None This will set the harnessed :obj:`~gi.repository.Gst.Element` to %GST_STATE_PLAYING. :obj:`~gi.repository.Gst.Element` without a sink-:obj:`~gi.repository.Gst.Pad` and with the %GST_ELEMENT_FLAG_SOURCE flag set is considered a src :obj:`~gi.repository.Gst.Element` Non-src :obj:`~gi.repository.Gst.Element` (like sinks and filters) are automatically set to playing by the :obj:`~gi.repository.GstCheck.Harness`\, but src :obj:`~gi.repository.Gst.Element` are not to avoid them starting to produce buffers. Hence, for src :obj:`~gi.repository.Gst.Element` you must call :func:`~gi.repository.GstCheck.Harness.play` explicitly. MT safe. .. versionadded:: 1.6 .. method:: pull() -> ~gi.repository.Gst.Buffer | None Pulls a :obj:`~gi.repository.Gst.Buffer` from the :obj:`~gi.repository.GLib.AsyncQueue` on the :obj:`~gi.repository.GstCheck.Harness` sinkpad. The pull will timeout in 60 seconds. This is the standard way of getting a buffer from a harnessed :obj:`~gi.repository.Gst.Element`\. MT safe. .. versionadded:: 1.6 .. method:: pull_event() -> ~gi.repository.Gst.Event | None Pulls an :obj:`~gi.repository.Gst.Event` from the :obj:`~gi.repository.GLib.AsyncQueue` on the :obj:`~gi.repository.GstCheck.Harness` sinkpad. Timeouts after 60 seconds similar to gst_harness_pull. MT safe. .. versionadded:: 1.6 .. method:: pull_until_eos() -> ~typing.Tuple[bool, ~gi.repository.Gst.Buffer | None] Pulls a :obj:`~gi.repository.Gst.Buffer` from the :obj:`~gi.repository.GLib.AsyncQueue` on the :obj:`~gi.repository.GstCheck.Harness` sinkpad. The pull will block until an EOS event is received, or timeout in 60 seconds. MT safe. .. versionadded:: 1.18 .. method:: pull_upstream_event() -> ~gi.repository.Gst.Event | None Pulls an :obj:`~gi.repository.Gst.Event` from the :obj:`~gi.repository.GLib.AsyncQueue` on the :obj:`~gi.repository.GstCheck.Harness` srcpad. Timeouts after 60 seconds similar to gst_harness_pull. MT safe. .. versionadded:: 1.6 .. method:: push(buffer: ~gi.repository.Gst.Buffer) -> ~gi.repository.Gst.FlowReturn Pushes a :obj:`~gi.repository.Gst.Buffer` on the :obj:`~gi.repository.GstCheck.Harness` srcpad. The standard way of interacting with an harnessed element. MT safe. .. versionadded:: 1.6 :param buffer: a :obj:`~gi.repository.Gst.Buffer` to push .. method:: push_and_pull(buffer: ~gi.repository.Gst.Buffer) -> ~gi.repository.Gst.Buffer | None Basically a gst_harness_push and a gst_harness_pull in one line. Reflects the fact that you often want to do exactly this in your test: Push one buffer in, and inspect the outcome. MT safe. .. versionadded:: 1.6 :param buffer: a :obj:`~gi.repository.Gst.Buffer` to push .. method:: push_event(event: ~gi.repository.Gst.Event) -> bool Pushes an :obj:`~gi.repository.Gst.Event` on the :obj:`~gi.repository.GstCheck.Harness` srcpad. MT safe. .. versionadded:: 1.6 :param event: a :obj:`~gi.repository.Gst.Event` to push .. method:: push_from_src() -> ~gi.repository.Gst.FlowReturn Transfer data from the src-:obj:`~gi.repository.GstCheck.Harness` to the main-:obj:`~gi.repository.GstCheck.Harness`\. It consists of 4 steps: 1: Make sure the src is started. (see: gst_harness_play) 2: Crank the clock (see: gst_harness_crank_single_clock_wait) 3: Pull a :obj:`~gi.repository.Gst.Buffer` from the src-:obj:`~gi.repository.GstCheck.Harness` (see: gst_harness_pull) 4: Push the same :obj:`~gi.repository.Gst.Buffer` into the main-:obj:`~gi.repository.GstCheck.Harness` (see: gst_harness_push) MT safe. .. versionadded:: 1.6 .. method:: push_to_sink() -> ~gi.repository.Gst.FlowReturn Transfer one :obj:`~gi.repository.Gst.Buffer` from the main-:obj:`~gi.repository.GstCheck.Harness` to the sink-:obj:`~gi.repository.GstCheck.Harness`\. See gst_harness_push_from_src for details. MT safe. .. versionadded:: 1.6 .. method:: push_upstream_event(event: ~gi.repository.Gst.Event) -> bool Pushes an :obj:`~gi.repository.Gst.Event` on the :obj:`~gi.repository.GstCheck.Harness` sinkpad. MT safe. .. versionadded:: 1.6 :param event: a :obj:`~gi.repository.Gst.Event` to push .. method:: query_latency() -> int Get the min latency reported by any harnessed :obj:`~gi.repository.Gst.Element`\. MT safe. .. versionadded:: 1.6 .. method:: set_blocking_push_mode() -> None Setting this will make the harness block in the chain-function, and then release when :func:`~gi.repository.GstCheck.Harness.pull` or :func:`~gi.repository.GstCheck.Harness.try_pull` is called. Can be useful when wanting to control a src-element that is not implementing :func:`~gi.repository.Gst.Gst.Clock.id_wait` so it can't be controlled by the :obj:`~gi.repository.GstCheck.TestClock`\, since it otherwise would produce buffers as fast as possible. MT safe. .. versionadded:: 1.6 .. method:: set_caps(in_: ~gi.repository.Gst.Caps, out: ~gi.repository.Gst.Caps) -> None Sets the ``GstHarness`` srcpad and sinkpad caps. MT safe. .. versionadded:: 1.6 :param in_: :param out: a :obj:`~gi.repository.Gst.Caps` to set on the harness sinkpad .. method:: set_caps_str(in_: str, out: str) -> None Sets the ``GstHarness`` srcpad and sinkpad caps using strings. MT safe. .. versionadded:: 1.6 :param in_: :param out: a ``gchar`` describing a :obj:`~gi.repository.Gst.Caps` to set on the harness sinkpad .. method:: set_drop_buffers(drop_buffers: bool) -> None When set to :const:`True`, instead of placing the buffers arriving from the harnessed :obj:`~gi.repository.Gst.Element` inside the sinkpads :obj:`~gi.repository.GLib.AsyncQueue`\, they are instead unreffed. MT safe. .. versionadded:: 1.6 :param drop_buffers: a :obj:`~gi.repository.gboolean` specifying to drop outgoing buffers or not .. method:: set_forwarding(forwarding: bool) -> None As a convenience, a src-harness will forward %GST_EVENT_STREAM_START, %GST_EVENT_CAPS and %GST_EVENT_SEGMENT to the main-harness if forwarding is enabled, and forward any sticky-events from the main-harness to the sink-harness. It will also forward the %GST_QUERY_ALLOCATION. If forwarding is disabled, the user will have to either manually push these events from the src-harness using :func:`~gi.repository.GstCheck.Harness.src_push_event`, or create and push them manually. While this will allow full control and inspection of these events, for the most cases having forwarding enabled will be sufficient when writing a test where the src-harness' main function is providing data for the main-harness. Forwarding is enabled by default. MT safe. .. versionadded:: 1.6 :param forwarding: a :obj:`~gi.repository.gboolean` to enable/disable forwarding .. method:: set_live(is_live: bool) -> None Sets the liveness reported by :obj:`~gi.repository.GstCheck.Harness` when receiving a latency-query. The default is :const:`True`. .. versionadded:: 1.20 :param is_live: :const:`True` for live, :const:`False` for non-live .. method:: set_propose_allocator(allocator: ~gi.repository.Gst.Allocator | None = None, params: ~gi.repository.Gst.AllocationParams | None = None) -> None Sets the ``allocator`` and ``params`` to propose when receiving an allocation query. MT safe. .. versionadded:: 1.6 :param allocator: a :obj:`~gi.repository.Gst.Allocator` :param params: a :obj:`~gi.repository.Gst.AllocationParams` .. method:: set_sink_caps(caps: ~gi.repository.Gst.Caps) -> None Sets the ``GstHarness`` sinkpad caps. MT safe. .. versionadded:: 1.6 :param caps: a :obj:`~gi.repository.Gst.Caps` to set on the harness sinkpad .. method:: set_sink_caps_str(str: str) -> None Sets the ``GstHarness`` sinkpad caps using a string. MT safe. .. versionadded:: 1.6 :param str: a ``gchar`` describing a :obj:`~gi.repository.Gst.Caps` to set on the harness sinkpad .. method:: set_src_caps(caps: ~gi.repository.Gst.Caps) -> None Sets the ``GstHarness`` srcpad caps. This must be done before any buffers can legally be pushed from the harness to the element. MT safe. .. versionadded:: 1.6 :param caps: a :obj:`~gi.repository.Gst.Caps` to set on the harness srcpad .. method:: set_src_caps_str(str: str) -> None Sets the ``GstHarness`` srcpad caps using a string. This must be done before any buffers can legally be pushed from the harness to the element. MT safe. .. versionadded:: 1.6 :param str: a ``gchar`` describing a :obj:`~gi.repository.Gst.Caps` to set on the harness srcpad .. method:: set_time(time: int) -> bool Advance the :obj:`~gi.repository.GstCheck.TestClock` to a specific time. MT safe. .. versionadded:: 1.6 :param time: a :obj:`~gi.repository.Gst.ClockTime` to advance the clock to .. method:: set_upstream_latency(latency: int) -> None Sets the min latency reported by :obj:`~gi.repository.GstCheck.Harness` when receiving a latency-query .. versionadded:: 1.6 :param latency: a :obj:`~gi.repository.Gst.ClockTime` specifying the latency .. method:: sink_push_many(pushes: int) -> ~gi.repository.Gst.FlowReturn Convenience that calls gst_harness_push_to_sink ``pushes`` number of times. Will abort the pushing if any one push fails. MT safe. .. versionadded:: 1.6 :param pushes: a :obj:`int` with the number of calls to gst_harness_push_to_sink .. method:: src_crank_and_push_many(cranks: int, pushes: int) -> ~gi.repository.Gst.FlowReturn Transfer data from the src-:obj:`~gi.repository.GstCheck.Harness` to the main-:obj:`~gi.repository.GstCheck.Harness`\. Similar to gst_harness_push_from_src, this variant allows you to specify how many cranks and how many pushes to perform. This can be useful for both moving a lot of data at the same time, as well as cases when one crank does not equal one buffer to push and v.v. MT safe. .. versionadded:: 1.6 :param cranks: a :obj:`int` with the number of calls to gst_harness_crank_single_clock_wait :param pushes: a :obj:`int` with the number of calls to gst_harness_push .. method:: src_push_event() -> bool Similar to what gst_harness_src_push does with :obj:`~gi.repository.Gst.Buffer`\, this transfers a :obj:`~gi.repository.Gst.Event` from the src-:obj:`~gi.repository.GstCheck.Harness` to the main-:obj:`~gi.repository.GstCheck.Harness`\. Note that some :obj:`~gi.repository.Gst.Event` are being transferred automagically. Look at sink_forward_pad for details. MT safe. .. versionadded:: 1.6 .. classmethod:: stress_thread_stop() -> int Stop the running :obj:`~gi.repository.GstCheck.HarnessThread` MT safe. .. versionadded:: 1.6 .. method:: take_all_data() -> ~gi.repository.GLib.Bytes Pulls all pending data from the harness and returns it as a single data slice. .. versionadded:: 1.14 .. method:: take_all_data_as_buffer() -> ~gi.repository.Gst.Buffer Pulls all pending data from the harness and returns it as a single buffer. .. versionadded:: 1.14 .. method:: teardown() -> None Tears down a ``GstHarness``\, freeing all resources allocated using it. MT safe. .. versionadded:: 1.6 .. method:: try_pull() -> ~gi.repository.Gst.Buffer | None Pulls a :obj:`~gi.repository.Gst.Buffer` from the :obj:`~gi.repository.GLib.AsyncQueue` on the :obj:`~gi.repository.GstCheck.Harness` sinkpad. Unlike gst_harness_pull this will not wait for any buffers if not any are present, and return :const:`None` straight away. MT safe. .. versionadded:: 1.6 .. method:: try_pull_event() -> ~gi.repository.Gst.Event | None Pulls an :obj:`~gi.repository.Gst.Event` from the :obj:`~gi.repository.GLib.AsyncQueue` on the :obj:`~gi.repository.GstCheck.Harness` sinkpad. See gst_harness_try_pull for details. MT safe. .. versionadded:: 1.6 .. method:: try_pull_upstream_event() -> ~gi.repository.Gst.Event | None Pulls an :obj:`~gi.repository.Gst.Event` from the :obj:`~gi.repository.GLib.AsyncQueue` on the :obj:`~gi.repository.GstCheck.Harness` srcpad. See gst_harness_try_pull for details. MT safe. .. versionadded:: 1.6 .. method:: upstream_events_in_queue() -> int The number of :obj:`~gi.repository.Gst.Event` currently in the :obj:`~gi.repository.GstCheck.Harness` srcpad :obj:`~gi.repository.GLib.AsyncQueue` MT safe. .. versionadded:: 1.6 .. method:: upstream_events_received() -> int The total number of :obj:`~gi.repository.Gst.Event` that has arrived on the :obj:`~gi.repository.GstCheck.Harness` srcpad This number includes events handled by the harness as well as events that have already been pulled out. MT safe. .. versionadded:: 1.6 .. method:: use_systemclock() -> None Sets the system :obj:`~gi.repository.Gst.Clock` on the ``GstHarness`` :obj:`~gi.repository.Gst.Element` MT safe. .. versionadded:: 1.6 .. method:: use_testclock() -> None Sets the :obj:`~gi.repository.GstCheck.TestClock` on the :obj:`~gi.repository.GstCheck.Harness` :obj:`~gi.repository.Gst.Element` MT safe. .. versionadded:: 1.6 .. method:: wait_for_clock_id_waits(waits: int, timeout: int) -> bool Waits for ``timeout`` seconds until ``waits`` number of :obj:`~gi.repository.Gst.ClockID` waits is registered with the :obj:`~gi.repository.GstCheck.TestClock`\. Useful for writing deterministic tests, where you want to make sure that an expected number of waits have been reached. MT safe. .. versionadded:: 1.6 :param waits: a :obj:`int` describing the numbers of :obj:`~gi.repository.Gst.ClockID` registered with the :obj:`~gi.repository.GstCheck.TestClock` :param timeout: a :obj:`int` describing how many seconds to wait for ``waits`` to be true Fields ------ .. rst-class:: interim-class .. class:: Harness :no-index: .. attribute:: element The element inside the harness .. attribute:: priv .. attribute:: sink_harness The sink (output) harness (if any) .. attribute:: sinkpad The internal harness sink pad .. attribute:: src_harness The source (input) harness (if any) .. attribute:: srcpad The internal harness source pad