Struct gstreamer_check::harness::Harness [−][src]
pub struct Harness(_);
crate::Harness
is meant to make writing unit test for GStreamer much easier.
It can be thought of as a way of treating a crate::gst::Element
as a black box,
deterministically feeding it data, and controlling what data it outputs.
The basic structure of crate::Harness
is two “floating” GstPads
that connect
to the harnessed crate::gst::Element
src and sink GstPads
like so:
#include <gst/gst.h>
#include <gst/check/gstharness.h>
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 #GstHarness is its integration with the
#GstTestClock. Operating the #GstTestClock can be very challenging, but
#GstHarness simplifies some of the most desired actions a lot, like wanting
to manually advance the clock while at the same time releasing a #GstClockID
that is waiting, with functions like gst_harness_crank_single_clock_wait().
#GstHarness also supports sub-harnesses, as a way of generating and
validating data. A sub-harness is another #GstHarness 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 gst_harness_add_src() or
gst_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:
|[<!-- language="C" -->
GstHarness * h = gst_harness_new (h, "vp8dec");
gst_harness_add_src_parse (h, "videotestsrc is-live=1 ! vp8enc", TRUE);
and then feeding it data with:
gst_harness_push_from_src (h);
Implementations
impl Harness
[src]
impl Harness
[src]pub fn add_element_full<P: IsA<Element>>(
&mut self,
element: &P,
hsrc: Option<&StaticPadTemplate>,
element_sinkpad_name: Option<&str>,
hsink: Option<&StaticPadTemplate>,
element_srcpad_name: Option<&str>
)
[src]
pub fn add_element_full<P: IsA<Element>>(
&mut self,
element: &P,
hsrc: Option<&StaticPadTemplate>,
element_sinkpad_name: Option<&str>,
hsink: Option<&StaticPadTemplate>,
element_srcpad_name: Option<&str>
)
[src]Adds a crate::gst::Element
to an empty crate::Harness
MT safe.
element
a crate::gst::Element
to add to the harness (transfer none)
hsrc
a crate::gst::StaticPadTemplate
describing the harness srcpad.
None
will not create a harness srcpad.
element_sinkpad_name
a gchar
with the name of the element
sinkpad that is then linked to the harness srcpad. Can be a static or request
or a sometimes pad that has been added. None
will not get/request a sinkpad
from the element. (Like if the element is a src.)
hsink
a crate::gst::StaticPadTemplate
describing the harness sinkpad.
None
will not create a harness sinkpad.
element_srcpad_name
a gchar
with the name of the element
srcpad that is then linked to the harness sinkpad, similar to the
element_sinkpad_name
.
pub fn add_element_sink_pad<P: IsA<Pad>>(&mut self, sinkpad: &P)
[src]
pub fn add_element_sink_pad<P: IsA<Pad>>(&mut self, sinkpad: &P)
[src]Links the specified crate::gst::Pad
the crate::Harness
(XXX: @-reference does not belong to Harness!) srcpad.
MT safe.
sinkpad
a crate::gst::Pad
to link to the harness srcpad
pub fn add_element_src_pad<P: IsA<Pad>>(&mut self, srcpad: &P)
[src]
pub fn add_element_src_pad<P: IsA<Pad>>(&mut self, srcpad: &P)
[src]Links the specified crate::gst::Pad
the crate::Harness
(XXX: @-reference does not belong to Harness!) 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.
srcpad
a crate::gst::Pad
to link to the harness sinkpad
pub fn add_parse(&mut self, launchline: &str)
[src]
pub fn add_parse(&mut self, launchline: &str)
[src]Parses the launchline
and puts that in a crate::gst::Bin
,
and then attches the supplied crate::Harness
to the bin.
MT safe.
launchline
a gchar
describing a gst-launch type line
pub fn add_probe<F>(
&mut self,
element_name: &str,
pad_name: &str,
mask: PadProbeType,
func: F
) where
F: Fn(&Pad, &mut PadProbeInfo<'_>) -> PadProbeReturn + Send + Sync + 'static,
[src]
pub fn add_probe<F>(
&mut self,
element_name: &str,
pad_name: &str,
mask: PadProbeType,
func: F
) where
F: Fn(&Pad, &mut PadProbeInfo<'_>) -> PadProbeReturn + Send + Sync + 'static,
[src]A convenience function to allows you to call gst_pad_add_probe on a
crate::gst::Pad
of a crate::gst::Element
that are residing inside the crate::Harness
,
by using normal gst_pad_add_probe syntax
MT safe.
element_name
a gchar
with a crate::gst::ElementFactory
name
pad_name
a gchar
with the name of the pad to attach the probe to
mask
a crate::gst::PadProbeType
(see gst_pad_add_probe)
callback
a GstPadProbeCallback
(see gst_pad_add_probe)
user_data
a gpointer
(see gst_pad_add_probe)
destroy_data
a GDestroyNotify
(see gst_pad_add_probe)
pub fn add_propose_allocation_meta(
&mut self,
api: Type,
params: Option<&StructureRef>
)
[src]
This is supported on crate feature v1_16
only.
pub fn add_propose_allocation_meta(
&mut self,
api: Type,
params: Option<&StructureRef>
)
[src]v1_16
only.pub fn add_sink(&mut self, sink_element_name: &str)
[src]
pub fn add_sink(&mut self, sink_element_name: &str)
[src]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.
sink_element_name
a gchar
with the name of a crate::gst::Element
pub fn add_sink_harness(&mut self, sink_harness: Harness)
[src]
pub fn add_sink_harness(&mut self, sink_harness: Harness)
[src]Similar to gst_harness_add_src, this allows you to send the data coming out
of your harnessed crate::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.
sink_harness
a crate::Harness
to be added as a sink-harness.
pub fn add_sink_parse(&mut self, launchline: &str)
[src]
pub fn add_sink_parse(&mut self, launchline: &str)
[src]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.
launchline
a gchar
with the name of a crate::gst::Element
pub fn add_src(&mut self, src_element_name: &str, has_clock_wait: bool)
[src]
pub fn add_src(&mut self, src_element_name: &str, has_clock_wait: bool)
[src]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.
src_element_name
a gchar
with the name of a crate::gst::Element
has_clock_wait
a gboolean
specifying if the crate::gst::Element
uses
gst_clock_wait_id internally.
pub fn add_src_harness(&mut self, src_harness: Harness, has_clock_wait: bool)
[src]
pub fn add_src_harness(&mut self, src_harness: Harness, has_clock_wait: bool)
[src]A src-harness is a great way of providing the crate::Harness
with data.
By adding a src-type crate::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.
src_harness
a crate::Harness
to be added as a src-harness.
has_clock_wait
a gboolean
specifying if the crate::gst::Element
uses
gst_clock_wait_id internally.
pub fn add_src_parse(&mut self, launchline: &str, has_clock_wait: bool)
[src]
pub fn add_src_parse(&mut self, launchline: &str, has_clock_wait: bool)
[src]Similar to gst_harness_add_src, this allows you to specify a launch-line,
which can be useful for both having more then one crate::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.
launchline
a gchar
describing a gst-launch type line
has_clock_wait
a gboolean
specifying if the crate::gst::Element
uses
gst_clock_wait_id internally.
pub fn buffers_in_queue(&self) -> u32
[src]
pub fn buffers_in_queue(&self) -> u32
[src]The number of GstBuffers
currently in the crate::Harness
sinkpad [crate::glib::AsyncQueue
]
MT safe.
Returns
a guint
number of buffers in the queue
pub fn buffers_received(&self) -> u32
[src]
pub fn buffers_received(&self) -> u32
[src]The total number of GstBuffers
that has arrived on the crate::Harness
sinkpad.
This number includes buffers that have been dropped as well as buffers
that have already been pulled out.
MT safe.
Returns
a guint
number of buffers received
pub fn crank_multiple_clock_waits(
&mut self,
waits: u32
) -> Result<(), BoolError>
[src]
pub fn crank_multiple_clock_waits(
&mut self,
waits: u32
) -> Result<(), BoolError>
[src]Similar to Self::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 [crate::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.
waits
a guint
describing the number of GstClockIDs
to crank
Returns
a gboolean
true
if the “crank” was successful, false
if not.
pub fn crank_single_clock_wait(&mut self) -> Result<(), BoolError>
[src]
pub fn crank_single_clock_wait(&mut self) -> Result<(), BoolError>
[src]A “crank” consists of three steps:
1: Wait for a [crate::gst::ClockID
] to be registered with the crate::TestClock
.
2: Advance the crate::TestClock
to the time the [crate::gst::ClockID
] is waiting for.
3: Release the [crate::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.
Returns
a gboolean
true
if the “crank” was successful, false
if not.
pub fn create_buffer(&mut self, size: usize) -> Result<Buffer, BoolError>
[src]
pub fn create_buffer(&mut self, size: usize) -> Result<Buffer, BoolError>
[src]Allocates a buffer using a crate::gst::BufferPool
if present, or else using the
configured crate::gst::Allocator
and crate::gst::AllocationParams
MT safe.
size
a gsize
specifying the size of the buffer
Returns
a crate::gst::Buffer
of size size
pub fn dump_to_file<P: AsRef<Path>>(&mut self, filename: P)
[src]
pub fn dump_to_file<P: AsRef<Path>>(&mut self, filename: P)
[src]Allows you to dump the GstBuffers
the crate::Harness
sinkpad [crate::glib::AsyncQueue
]
to a file.
MT safe.
filename
a gchar
with a the name of a file
pub fn events_in_queue(&self) -> u32
[src]
pub fn events_in_queue(&self) -> u32
[src]The number of GstEvents
currently in the crate::Harness
sinkpad [crate::glib::AsyncQueue
]
MT safe.
Returns
a guint
number of events in the queue
pub fn events_received(&self) -> u32
[src]
pub fn events_received(&self) -> u32
[src]The total number of GstEvents
that has arrived on the crate::Harness
sinkpad
This number includes events handled by the harness as well as events
that have already been pulled out.
MT safe.
Returns
a guint
number of events received
pub fn find_element(&mut self, element_name: &str) -> Option<Element>
[src]
pub fn find_element(&mut self, element_name: &str) -> Option<Element>
[src]Most useful in conjunction with gst_harness_new_parse, this will scan the
GstElements
inside the crate::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.
element_name
a gchar
with a crate::gst::ElementFactory
name
Returns
a crate::gst::Element
or None
if not found
pub fn last_pushed_timestamp(&self) -> ClockTime
[src]
pub fn testclock(&self) -> Option<TestClock>
[src]
pub fn play(&mut self)
[src]
pub fn play(&mut self)
[src]This will set the harnessed crate::gst::Element
to crate::gst::State::Playing
.
GstElements
without a sink-crate::gst::Pad
and with the [crate::gst::ElementFlags::Source
]
flag set is considered a src crate::gst::Element
Non-src GstElements
(like sinks and filters) are automatically set to
playing by the crate::Harness
, but src GstElements
are not to avoid them
starting to produce buffers.
Hence, for src crate::gst::Element
you must call Self::play()
explicitly.
MT safe.
pub fn pull(&mut self) -> Result<Buffer, BoolError>
[src]
pub fn pull(&mut self) -> Result<Buffer, BoolError>
[src]Pulls a crate::gst::Buffer
from the [crate::glib::AsyncQueue
] on the crate::Harness
sinkpad. The pull
will timeout in 60 seconds. This is the standard way of getting a buffer
from a harnessed crate::gst::Element
.
MT safe.
Returns
a crate::gst::Buffer
or None
if timed out.
pub fn pull_until_eos(&mut self) -> Result<Option<Buffer>, BoolError>
[src]
This is supported on crate feature v1_18
only.
pub fn pull_until_eos(&mut self) -> Result<Option<Buffer>, BoolError>
[src]v1_18
only.Pulls a crate::gst::Buffer
from the [crate::glib::AsyncQueue
] on the crate::Harness
sinkpad. The pull
will block until an EOS event is received, or timeout in 60 seconds.
MT safe.
buf
A crate::gst::Buffer
, or None
if EOS or timeout occures
first.
Returns
pub fn pull_event(&mut self) -> Result<Event, BoolError>
[src]
pub fn pull_event(&mut self) -> Result<Event, BoolError>
[src]Pulls an crate::gst::Event
from the [crate::glib::AsyncQueue
] on the crate::Harness
sinkpad.
Timeouts after 60 seconds similar to gst_harness_pull.
MT safe.
Returns
a crate::gst::Event
or None
if timed out.
pub fn pull_upstream_event(&mut self) -> Result<Event, BoolError>
[src]
pub fn pull_upstream_event(&mut self) -> Result<Event, BoolError>
[src]Pulls an crate::gst::Event
from the [crate::glib::AsyncQueue
] on the crate::Harness
srcpad.
Timeouts after 60 seconds similar to gst_harness_pull.
MT safe.
Returns
a crate::gst::Event
or None
if timed out.
pub fn push(&mut self, buffer: Buffer) -> Result<FlowSuccess, FlowError>
[src]
pub fn push(&mut self, buffer: Buffer) -> Result<FlowSuccess, FlowError>
[src]Pushes a crate::gst::Buffer
on the crate::Harness
srcpad. The standard way of
interacting with an harnessed element.
MT safe.
buffer
a crate::gst::Buffer
to push
Returns
a crate::gst::FlowReturn
with the result from the push
pub fn push_and_pull(&mut self, buffer: Buffer) -> Result<Buffer, BoolError>
[src]
pub fn push_and_pull(&mut self, buffer: Buffer) -> Result<Buffer, BoolError>
[src]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.
buffer
a crate::gst::Buffer
to push
Returns
a crate::gst::Buffer
or None
if timed out.
pub fn push_event(&mut self, event: Event) -> bool
[src]
pub fn push_event(&mut self, event: Event) -> bool
[src]Pushes an crate::gst::Event
on the crate::Harness
srcpad.
MT safe.
event
a crate::gst::Event
to push
Returns
a gboolean
with the result from the push
pub fn push_from_src(&mut self) -> Result<FlowSuccess, FlowError>
[src]
pub fn push_from_src(&mut self) -> Result<FlowSuccess, FlowError>
[src]Transfer data from the src-crate::Harness
to the main-crate::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 crate::gst::Buffer
from the src-crate::Harness
(see: gst_harness_pull)
4: Push the same crate::gst::Buffer
into the main-crate::Harness
(see: gst_harness_push)
MT safe.
Returns
a crate::gst::FlowReturn
with the result of the push
pub fn push_to_sink(&mut self) -> Result<FlowSuccess, FlowError>
[src]
pub fn push_to_sink(&mut self) -> Result<FlowSuccess, FlowError>
[src]Transfer one crate::gst::Buffer
from the main-crate::Harness
to the sink-crate::Harness
.
See gst_harness_push_from_src for details.
MT safe.
Returns
a crate::gst::FlowReturn
with the result of the push
pub fn push_upstream_event(&mut self, event: Event) -> bool
[src]
pub fn push_upstream_event(&mut self, event: Event) -> bool
[src]Pushes an crate::gst::Event
on the crate::Harness
sinkpad.
MT safe.
event
a crate::gst::Event
to push
Returns
a gboolean
with the result from the push
pub fn query_latency(&self) -> ClockTime
[src]
pub fn query_latency(&self) -> ClockTime
[src]Get the min latency reported by any harnessed crate::gst::Element
.
MT safe.
Returns
a crate::gst::ClockTime
with min latency
pub fn set_blocking_push_mode(&mut self)
[src]
pub fn set_blocking_push_mode(&mut self)
[src]Setting this will make the harness block in the chain-function, and
then release when Self::pull()
or Self::try_pull()
is called.
Can be useful when wanting to control a src-element that is not implementing
[crate::gst::Clock::id_wait()
] so it can’t be controlled by the crate::TestClock
, since
it otherwise would produce buffers as fast as possible.
MT safe.
pub fn set_caps(&mut self, in_: Caps, out: Caps)
[src]
pub fn set_caps(&mut self, in_: Caps, out: Caps)
[src]Sets the crate::Harness
(XXX: @-reference does not belong to Harness!) srcpad and sinkpad caps.
MT safe.
in_
a crate::gst::Caps
to set on the harness srcpad
out
a crate::gst::Caps
to set on the harness sinkpad
pub fn set_caps_str(&mut self, in_: &str, out: &str)
[src]
pub fn set_caps_str(&mut self, in_: &str, out: &str)
[src]Sets the crate::Harness
(XXX: @-reference does not belong to Harness!) srcpad and sinkpad caps using strings.
MT safe.
in_
a gchar
describing a crate::gst::Caps
to set on the harness srcpad
out
a gchar
describing a crate::gst::Caps
to set on the harness sinkpad
pub fn set_drop_buffers(&mut self, drop_buffers: bool)
[src]
pub fn set_drop_buffers(&mut self, drop_buffers: bool)
[src]When set to true
, instead of placing the buffers arriving from the harnessed
crate::gst::Element
inside the sinkpads [crate::glib::AsyncQueue
], they are instead unreffed.
MT safe.
drop_buffers
a gboolean
specifying to drop outgoing buffers or not
pub fn set_forwarding(&mut self, forwarding: bool)
[src]
pub fn set_forwarding(&mut self, forwarding: bool)
[src]As a convenience, a src-harness will forward crate::gst::EventType::StreamStart
,
crate::gst::EventType::Caps
and crate::gst::EventType::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 [crate::gst::QueryType::Allocation
].
If forwarding is disabled, the user will have to either manually push
these events from the src-harness using Self::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.
forwarding
a gboolean
to enable/disable forwarding
pub fn set_sink_caps(&mut self, caps: Caps)
[src]
pub fn set_sink_caps(&mut self, caps: Caps)
[src]Sets the crate::Harness
(XXX: @-reference does not belong to Harness!) sinkpad caps.
MT safe.
caps
a crate::gst::Caps
to set on the harness sinkpad
pub fn set_sink_caps_str(&mut self, str: &str)
[src]
pub fn set_sink_caps_str(&mut self, str: &str)
[src]Sets the crate::Harness
(XXX: @-reference does not belong to Harness!) sinkpad caps using a string.
MT safe.
str
a gchar
describing a crate::gst::Caps
to set on the harness sinkpad
pub fn set_src_caps(&mut self, caps: Caps)
[src]
pub fn set_src_caps(&mut self, caps: Caps)
[src]Sets the crate::Harness
(XXX: @-reference does not belong to Harness!) srcpad caps. This must be done before any buffers
can legally be pushed from the harness to the element.
MT safe.
caps
a crate::gst::Caps
to set on the harness srcpad
pub fn set_src_caps_str(&mut self, str: &str)
[src]
pub fn set_src_caps_str(&mut self, str: &str)
[src]Sets the crate::Harness
(XXX: @-reference does not belong to Harness!) srcpad caps using a string. This must be done before
any buffers can legally be pushed from the harness to the element.
MT safe.
str
a gchar
describing a crate::gst::Caps
to set on the harness srcpad
pub fn set_time(&mut self, time: ClockTime) -> Result<(), BoolError>
[src]
pub fn set_time(&mut self, time: ClockTime) -> Result<(), BoolError>
[src]Advance the crate::TestClock
to a specific time.
MT safe.
time
a crate::gst::ClockTime
to advance the clock to
Returns
pub fn set_upstream_latency(&mut self, latency: ClockTime)
[src]
pub fn set_upstream_latency(&mut self, latency: ClockTime)
[src]Sets the min latency reported by crate::Harness
when receiving a latency-query
latency
a crate::gst::ClockTime
specifying the latency
pub fn sink_push_many(&mut self, pushes: u32) -> Result<FlowSuccess, FlowError>
[src]
pub fn sink_push_many(&mut self, pushes: u32) -> Result<FlowSuccess, FlowError>
[src]Convenience that calls gst_harness_push_to_sink pushes
number of times.
Will abort the pushing if any one push fails.
MT safe.
pushes
a gint
with the number of calls to gst_harness_push_to_sink
Returns
a crate::gst::FlowReturn
with the result of the push
pub fn src_crank_and_push_many(
&mut self,
cranks: u32,
pushes: u32
) -> Result<FlowSuccess, FlowError>
[src]
pub fn src_crank_and_push_many(
&mut self,
cranks: u32,
pushes: u32
) -> Result<FlowSuccess, FlowError>
[src]Transfer data from the src-crate::Harness
to the main-crate::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.
cranks
a gint
with the number of calls to gst_harness_crank_single_clock_wait
pushes
a gint
with the number of calls to gst_harness_push
Returns
a crate::gst::FlowReturn
with the result of the push
pub fn src_push_event(&mut self) -> bool
[src]
pub fn src_push_event(&mut self) -> bool
[src]Similar to what gst_harness_src_push does with GstBuffers
, this transfers
a crate::gst::Event
from the src-crate::Harness
to the main-crate::Harness
. Note that
some GstEvents
are being transferred automagically. Look at sink_forward_pad
for details.
MT safe.
Returns
a gboolean
with the result of the push
pub fn take_all_data_as_buffer(&mut self) -> Result<Buffer, BoolError>
[src]
This is supported on crate feature v1_14
only.
pub fn take_all_data_as_buffer(&mut self) -> Result<Buffer, BoolError>
[src]v1_14
only.Pulls all pending data from the harness and returns it as a single buffer.
Returns
the data as a buffer. Unref with gst_buffer_unref()
when no longer needed.
pub fn take_all_data_as_bytes(&mut self) -> Result<Bytes, BoolError>
[src]
This is supported on crate feature v1_14
only.
pub fn take_all_data_as_bytes(&mut self) -> Result<Bytes, BoolError>
[src]v1_14
only.Pulls all pending data from the harness and returns it as a single crate::glib::Bytes
.
Returns
a pointer to the data, newly allocated. Free
with g_free()
when no longer needed.
pub fn try_pull(&mut self) -> Option<Buffer>
[src]
pub fn try_pull(&mut self) -> Option<Buffer>
[src]Pulls a crate::gst::Buffer
from the [crate::glib::AsyncQueue
] on the crate::Harness
sinkpad. Unlike
gst_harness_pull this will not wait for any buffers if not any are present,
and return None
straight away.
MT safe.
Returns
a crate::gst::Buffer
or None
if no buffers are present in the [crate::glib::AsyncQueue
]
pub fn try_pull_event(&mut self) -> Option<Event>
[src]
pub fn try_pull_event(&mut self) -> Option<Event>
[src]Pulls an crate::gst::Event
from the [crate::glib::AsyncQueue
] on the crate::Harness
sinkpad.
See gst_harness_try_pull for details.
MT safe.
Returns
a crate::gst::Event
or None
if no buffers are present in the [crate::glib::AsyncQueue
]
pub fn try_pull_upstream_event(&mut self) -> Option<Event>
[src]
pub fn try_pull_upstream_event(&mut self) -> Option<Event>
[src]Pulls an crate::gst::Event
from the [crate::glib::AsyncQueue
] on the crate::Harness
srcpad.
See gst_harness_try_pull for details.
MT safe.
Returns
a crate::gst::Event
or None
if no buffers are present in the [crate::glib::AsyncQueue
]
pub fn upstream_events_in_queue(&self) -> u32
[src]
pub fn upstream_events_in_queue(&self) -> u32
[src]The number of GstEvents
currently in the crate::Harness
srcpad [crate::glib::AsyncQueue
]
MT safe.
Returns
a guint
number of events in the queue
pub fn upstream_events_received(&self) -> u32
[src]
pub fn upstream_events_received(&self) -> u32
[src]The total number of GstEvents
that has arrived on the crate::Harness
srcpad
This number includes events handled by the harness as well as events
that have already been pulled out.
MT safe.
Returns
a guint
number of events received
pub fn use_systemclock(&mut self)
[src]
pub fn use_systemclock(&mut self)
[src]Sets the system crate::gst::Clock
on the crate::Harness
(XXX: @-reference does not belong to Harness!) crate::gst::Element
MT safe.
pub fn use_testclock(&mut self)
[src]
pub fn use_testclock(&mut self)
[src]Sets the crate::TestClock
on the crate::Harness
crate::gst::Element
MT safe.
pub fn wait_for_clock_id_waits(
&mut self,
waits: u32,
timeout: u32
) -> Result<(), BoolError>
[src]
pub fn wait_for_clock_id_waits(
&mut self,
waits: u32,
timeout: u32
) -> Result<(), BoolError>
[src]Waits for timeout
seconds until waits
number of [crate::gst::ClockID
] waits is
registered with the crate::TestClock
. Useful for writing deterministic tests,
where you want to make sure that an expected number of waits have been
reached.
MT safe.
waits
a guint
describing the numbers of [crate::gst::ClockID
] registered with
the crate::TestClock
timeout
a guint
describing how many seconds to wait for waits
to be true
Returns
a gboolean
true
if the waits have been registered, false
if not.
(Could be that it timed out waiting or that more waits than waits was found)
pub fn new(element_name: &str) -> Harness
[src]
pub fn new(element_name: &str) -> Harness
[src]Creates a new harness. Works like [Self::new_with_padnames()
], except it
assumes the crate::gst::Element
sinkpad is named “sink” and srcpad is named “src”
MT safe.
element_name
a gchar
describing the crate::gst::Element
name
Returns
a crate::Harness
, or None
if the harness could
not be created
pub fn new_empty() -> Harness
[src]
pub fn new_empty() -> Harness
[src]Creates a new empty harness. Use Self::add_element_full()
to add
an crate::gst::Element
to it.
MT safe.
Returns
a crate::Harness
, or None
if the harness could
not be created
pub fn new_full<P: IsA<Element>>(
element: &P,
hsrc: Option<&StaticPadTemplate>,
element_sinkpad_name: Option<&str>,
hsink: Option<&StaticPadTemplate>,
element_srcpad_name: Option<&str>
) -> Harness
[src]
pub fn new_full<P: IsA<Element>>(
element: &P,
hsrc: Option<&StaticPadTemplate>,
element_sinkpad_name: Option<&str>,
hsink: Option<&StaticPadTemplate>,
element_srcpad_name: Option<&str>
) -> Harness
[src]Creates a new harness.
MT safe.
element
a crate::gst::Element
to attach the harness to (transfer none)
hsrc
a crate::gst::StaticPadTemplate
describing the harness srcpad.
None
will not create a harness srcpad.
element_sinkpad_name
a gchar
with the name of the element
sinkpad that is then linked to the harness srcpad. Can be a static or request
or a sometimes pad that has been added. None
will not get/request a sinkpad
from the element. (Like if the element is a src.)
hsink
a crate::gst::StaticPadTemplate
describing the harness sinkpad.
None
will not create a harness sinkpad.
element_srcpad_name
a gchar
with the name of the element
srcpad that is then linked to the harness sinkpad, similar to the
element_sinkpad_name
.
Returns
a crate::Harness
, or None
if the harness could
not be created
pub fn new_parse(launchline: &str) -> Harness
[src]
pub fn new_parse(launchline: &str) -> Harness
[src]Creates a new harness, parsing the launchline
and putting that in a crate::gst::Bin
,
and then attches the harness to the bin.
MT safe.
launchline
a gchar
describing a gst-launch type line
Returns
a crate::Harness
, or None
if the harness could
not be created
pub fn with_element<P: IsA<Element>>(
element: &P,
element_sinkpad_name: Option<&str>,
element_srcpad_name: Option<&str>
) -> Harness
[src]
element: &P,
element_sinkpad_name: Option<&str>,
element_srcpad_name: Option<&str>
) -> Harness
pub fn with_padnames(
element_name: &str,
element_sinkpad_name: Option<&str>,
element_srcpad_name: Option<&str>
) -> Harness
[src]
element_name: &str,
element_sinkpad_name: Option<&str>,
element_srcpad_name: Option<&str>
) -> Harness
pub fn with_templates(
element_name: &str,
hsrc: Option<&StaticPadTemplate>,
hsink: Option<&StaticPadTemplate>
) -> Harness
[src]
element_name: &str,
hsrc: Option<&StaticPadTemplate>,
hsink: Option<&StaticPadTemplate>
) -> Harness