Struct gstreamer_check::harness::RefMut
source · pub struct RefMut<'a>(/* private fields */);
Methods from Deref<Target = Harness>§
sourcepub 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>,
)
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>, )
Adds a gst::Element
to an empty Harness
MT safe.
§element
a gst::Element
to add to the harness (transfer none)
§hsrc
a 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 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
.
sourcepub fn add_element_sink_pad<P: IsA<Pad>>(&mut self, sinkpad: &P)
pub fn add_element_sink_pad<P: IsA<Pad>>(&mut self, sinkpad: &P)
sourcepub fn add_element_src_pad<P: IsA<Pad>>(&mut self, srcpad: &P)
pub fn add_element_src_pad<P: IsA<Pad>>(&mut self, srcpad: &P)
sourcepub fn add_probe<F>(
&mut self,
element_name: &str,
pad_name: &str,
mask: PadProbeType,
func: F,
)
pub fn add_probe<F>( &mut self, element_name: &str, pad_name: &str, mask: PadProbeType, func: F, )
A convenience function to allows you to call gst_pad_add_probe on a
gst::Pad
of a gst::Element
that are residing inside the Harness
,
by using normal gst_pad_add_probe syntax
MT safe.
§element_name
a gchar
with a gst::ElementFactory
name
§pad_name
a gchar
with the name of the pad to attach the probe to
§mask
a gst::PadProbeType
(see gst_pad_add_probe)
§callback
a GstPadProbeCallback
(see gst_pad_add_probe)
§destroy_data
a GDestroyNotify
(see gst_pad_add_probe)
sourcepub fn add_propose_allocation_meta(
&mut self,
api: Type,
params: Option<&StructureRef>,
)
pub fn add_propose_allocation_meta( &mut self, api: Type, params: Option<&StructureRef>, )
sourcepub fn add_sink(&mut self, sink_element_name: &str)
pub fn add_sink(&mut self, sink_element_name: &str)
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 gst::Element
sourcepub fn add_sink_harness(&mut self, sink_harness: Harness)
pub fn add_sink_harness(&mut self, sink_harness: Harness)
Similar to gst_harness_add_src, this allows you to send the data coming out
of your harnessed 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 Harness
to be added as a sink-harness.
sourcepub fn add_sink_parse(&mut self, launchline: &str)
pub fn add_sink_parse(&mut self, launchline: &str)
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 gst::Element
sourcepub fn add_src(&mut self, src_element_name: &str, has_clock_wait: bool)
pub fn add_src(&mut self, src_element_name: &str, has_clock_wait: bool)
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 gst::Element
§has_clock_wait
a gboolean
specifying if the gst::Element
uses
gst_clock_wait_id internally.
sourcepub fn add_src_harness(&mut self, src_harness: Harness, has_clock_wait: bool)
pub fn add_src_harness(&mut self, src_harness: Harness, has_clock_wait: bool)
A src-harness is a great way of providing the Harness
with data.
By adding a src-type 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 Harness
to be added as a src-harness.
§has_clock_wait
a gboolean
specifying if the gst::Element
uses
gst_clock_wait_id internally.
sourcepub fn add_src_parse(&mut self, launchline: &str, has_clock_wait: bool)
pub fn add_src_parse(&mut self, launchline: &str, has_clock_wait: bool)
Similar to gst_harness_add_src, this allows you to specify a launch-line,
which can be useful for both having more then one 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 gst::Element
uses
gst_clock_wait_id internally.
sourcepub fn buffers_in_queue(&self) -> u32
pub fn buffers_in_queue(&self) -> u32
sourcepub fn buffers_received(&self) -> u32
pub fn buffers_received(&self) -> u32
sourcepub fn crank_multiple_clock_waits(
&mut self,
waits: u32,
) -> Result<(), BoolError>
pub fn crank_multiple_clock_waits( &mut self, waits: u32, ) -> Result<(), BoolError>
Similar to 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 GstClockID
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.
sourcepub fn crank_single_clock_wait(&mut self) -> Result<(), BoolError>
pub fn crank_single_clock_wait(&mut self) -> Result<(), BoolError>
A “crank” consists of three steps:
1: Wait for a GstClockID
to be registered with the TestClock
.
2: Advance the TestClock
to the time the GstClockID
is waiting for.
3: Release the GstClockID
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.
sourcepub fn create_buffer(&mut self, size: usize) -> Result<Buffer, BoolError>
pub fn create_buffer(&mut self, size: usize) -> Result<Buffer, BoolError>
Allocates a buffer using a gst::BufferPool
if present, or else using the
configured gst::Allocator
and gst::AllocationParams
MT safe.
§size
a gsize
specifying the size of the buffer
§Returns
a gst::Buffer
of size size
sourcepub fn dump_to_file(&mut self, filename: impl AsRef<Path>)
pub fn dump_to_file(&mut self, filename: impl AsRef<Path>)
sourcepub fn events_in_queue(&self) -> u32
pub fn events_in_queue(&self) -> u32
sourcepub fn events_received(&self) -> u32
pub fn events_received(&self) -> u32
sourcepub fn find_element(&mut self, element_name: &str) -> Option<Element>
pub fn find_element(&mut self, element_name: &str) -> Option<Element>
Most useful in conjunction with gst_harness_new_parse, this will scan the
GstElements
inside the 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 gst::ElementFactory
name
§Returns
a gst::Element
or None
if not found
sourcepub fn last_pushed_timestamp(&self) -> Option<ClockTime>
pub fn last_pushed_timestamp(&self) -> Option<ClockTime>
Get the timestamp of the last gst::Buffer
pushed on the Harness
srcpad,
typically with gst_harness_push or gst_harness_push_from_src.
MT safe.
§Returns
a GstClockTime
with the timestamp or GST_CLOCK_TIME_NONE
if no
gst::Buffer
has been pushed on the Harness
srcpad
sourcepub fn play(&mut self)
pub fn play(&mut self)
This will set the harnessed gst::Element
to gst::State::Playing
.
GstElements
without a sink-gst::Pad
and with the gst::ElementFlags::SOURCE
flag set is considered a src gst::Element
Non-src GstElements
(like sinks and filters) are automatically set to
playing by the Harness
, but src GstElements
are not to avoid them
starting to produce buffers.
Hence, for src gst::Element
you must call play()
explicitly.
MT safe.
sourcepub fn pull(&mut self) -> Result<Buffer, BoolError>
pub fn pull(&mut self) -> Result<Buffer, BoolError>
Pulls a gst::Buffer
from the GAsyncQueue
on the Harness
sinkpad. The pull
will timeout in 60 seconds. This is the standard way of getting a buffer
from a harnessed gst::Element
.
MT safe.
§Returns
a gst::Buffer
or None
if timed out.
sourcepub fn pull_until_eos(&mut self) -> Result<Option<Buffer>, BoolError>
pub fn pull_until_eos(&mut self) -> Result<Option<Buffer>, BoolError>
Pulls a gst::Buffer
from the GAsyncQueue
on the Harness
sinkpad. The pull
will block until an EOS event is received, or timeout in 60 seconds.
MT safe.
§Returns
true
on success, false
on timeout.
§buf
A gst::Buffer
, or None
if EOS or timeout occures
first.
sourcepub fn pull_event(&mut self) -> Result<Event, BoolError>
pub fn pull_event(&mut self) -> Result<Event, BoolError>
Pulls an gst::Event
from the GAsyncQueue
on the Harness
sinkpad.
Timeouts after 60 seconds similar to gst_harness_pull.
MT safe.
§Returns
a gst::Event
or None
if timed out.
sourcepub fn pull_upstream_event(&mut self) -> Result<Event, BoolError>
pub fn pull_upstream_event(&mut self) -> Result<Event, BoolError>
Pulls an gst::Event
from the GAsyncQueue
on the Harness
srcpad.
Timeouts after 60 seconds similar to gst_harness_pull.
MT safe.
§Returns
a gst::Event
or None
if timed out.
sourcepub fn push(&mut self, buffer: Buffer) -> Result<FlowSuccess, FlowError>
pub fn push(&mut self, buffer: Buffer) -> Result<FlowSuccess, FlowError>
Pushes a gst::Buffer
on the Harness
srcpad. The standard way of
interacting with an harnessed element.
MT safe.
§buffer
a gst::Buffer
to push
§Returns
a gst::FlowReturn
with the result from the push
sourcepub fn push_and_pull(&mut self, buffer: Buffer) -> Result<Buffer, BoolError>
pub fn push_and_pull(&mut self, buffer: Buffer) -> Result<Buffer, BoolError>
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 gst::Buffer
to push
§Returns
a gst::Buffer
or None
if timed out.
sourcepub fn push_event(&mut self, event: Event) -> bool
pub fn push_event(&mut self, event: Event) -> bool
Pushes an gst::Event
on the Harness
srcpad.
MT safe.
§event
a gst::Event
to push
§Returns
a gboolean
with the result from the push
sourcepub fn push_from_src(&mut self) -> Result<FlowSuccess, FlowError>
pub fn push_from_src(&mut self) -> Result<FlowSuccess, FlowError>
Transfer data from the src-Harness
to the main-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 gst::Buffer
from the src-Harness
(see: gst_harness_pull)
4: Push the same gst::Buffer
into the main-Harness
(see: gst_harness_push)
MT safe.
§Returns
a gst::FlowReturn
with the result of the push
sourcepub fn push_to_sink(&mut self) -> Result<FlowSuccess, FlowError>
pub fn push_to_sink(&mut self) -> Result<FlowSuccess, FlowError>
Transfer one gst::Buffer
from the main-Harness
to the sink-Harness
.
See gst_harness_push_from_src for details.
MT safe.
§Returns
a gst::FlowReturn
with the result of the push
sourcepub fn push_upstream_event(&mut self, event: Event) -> bool
pub fn push_upstream_event(&mut self, event: Event) -> bool
Pushes an gst::Event
on the Harness
sinkpad.
MT safe.
§event
a gst::Event
to push
§Returns
a gboolean
with the result from the push
sourcepub fn query_latency(&self) -> Option<ClockTime>
pub fn query_latency(&self) -> Option<ClockTime>
Get the min latency reported by any harnessed gst::Element
.
MT safe.
§Returns
a GstClockTime
with min latency
sourcepub fn set_blocking_push_mode(&mut self)
pub fn set_blocking_push_mode(&mut self)
Setting this will make the harness block in the chain-function, and
then release when pull()
or try_pull()
is called.
Can be useful when wanting to control a src-element that is not implementing
gst_clock_id_wait()
so it can’t be controlled by the TestClock
, since
it otherwise would produce buffers as fast as possible.
MT safe.
sourcepub fn set_caps_str(&mut self, in_: &str, out: &str)
pub fn set_caps_str(&mut self, in_: &str, out: &str)
sourcepub fn set_drop_buffers(&mut self, drop_buffers: bool)
pub fn set_drop_buffers(&mut self, drop_buffers: bool)
When set to true
, instead of placing the buffers arriving from the harnessed
gst::Element
inside the sinkpads GAsyncQueue
, they are instead unreffed.
MT safe.
§drop_buffers
a gboolean
specifying to drop outgoing buffers or not
sourcepub fn set_forwarding(&mut self, forwarding: bool)
pub fn set_forwarding(&mut self, forwarding: bool)
As a convenience, a src-harness will forward gst::EventType::StreamStart
,
gst::EventType::Caps
and 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 GST_QUERY_ALLOCATION
.
If forwarding is disabled, the user will have to either manually push
these events from the src-harness using 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
sourcepub fn set_sink_caps(&mut self, caps: Caps)
pub fn set_sink_caps(&mut self, caps: Caps)
sourcepub fn set_sink_caps_str(&mut self, str: &str)
pub fn set_sink_caps_str(&mut self, str: &str)
sourcepub fn set_src_caps(&mut self, caps: Caps)
pub fn set_src_caps(&mut self, caps: Caps)
sourcepub fn set_src_caps_str(&mut self, str: &str)
pub fn set_src_caps_str(&mut self, str: &str)
sourcepub fn set_upstream_latency(&mut self, latency: ClockTime)
pub fn set_upstream_latency(&mut self, latency: ClockTime)
sourcepub fn sink_push_many(&mut self, pushes: u32) -> Result<FlowSuccess, FlowError>
pub fn sink_push_many(&mut self, pushes: u32) -> Result<FlowSuccess, FlowError>
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 gst::FlowReturn
with the result of the push
sourcepub fn src_crank_and_push_many(
&mut self,
cranks: u32,
pushes: u32,
) -> Result<FlowSuccess, FlowError>
pub fn src_crank_and_push_many( &mut self, cranks: u32, pushes: u32, ) -> Result<FlowSuccess, FlowError>
Transfer data from the src-Harness
to the main-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 gst::FlowReturn
with the result of the push
sourcepub fn src_push_event(&mut self) -> bool
pub fn src_push_event(&mut self) -> bool
Similar to what gst_harness_src_push does with GstBuffers
, this transfers
a gst::Event
from the src-Harness
to the main-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
sourcepub fn take_all_data_as_buffer(&mut self) -> Result<Buffer, BoolError>
pub fn take_all_data_as_buffer(&mut self) -> Result<Buffer, BoolError>
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.
sourcepub fn take_all_data_as_bytes(&mut self) -> Result<Bytes, BoolError>
pub fn take_all_data_as_bytes(&mut self) -> Result<Bytes, BoolError>
Pulls all pending data from the harness and returns it as a single glib::Bytes
.
§Returns
a pointer to the data, newly allocated. Free
with g_free()
when no longer needed.
sourcepub fn try_pull(&mut self) -> Option<Buffer>
pub fn try_pull(&mut self) -> Option<Buffer>
Pulls a gst::Buffer
from the GAsyncQueue
on the 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 gst::Buffer
or None
if no buffers are present in the GAsyncQueue
sourcepub fn try_pull_event(&mut self) -> Option<Event>
pub fn try_pull_event(&mut self) -> Option<Event>
Pulls an gst::Event
from the GAsyncQueue
on the Harness
sinkpad.
See gst_harness_try_pull for details.
MT safe.
§Returns
a gst::Event
or None
if no buffers are present in the GAsyncQueue
sourcepub fn try_pull_upstream_event(&mut self) -> Option<Event>
pub fn try_pull_upstream_event(&mut self) -> Option<Event>
Pulls an gst::Event
from the GAsyncQueue
on the Harness
srcpad.
See gst_harness_try_pull for details.
MT safe.
§Returns
a gst::Event
or None
if no buffers are present in the GAsyncQueue
sourcepub fn upstream_events_in_queue(&self) -> u32
pub fn upstream_events_in_queue(&self) -> u32
sourcepub fn upstream_events_received(&self) -> u32
pub fn upstream_events_received(&self) -> u32
sourcepub fn use_systemclock(&mut self)
pub fn use_systemclock(&mut self)
Sets the system gst::Clock
on the Harness
gst::Element
MT safe.
sourcepub fn use_testclock(&mut self)
pub fn use_testclock(&mut self)
Sets the TestClock
on the Harness
gst::Element
MT safe.
sourcepub fn wait_for_clock_id_waits(
&mut self,
waits: u32,
timeout: u32,
) -> Result<(), BoolError>
pub fn wait_for_clock_id_waits( &mut self, waits: u32, timeout: u32, ) -> Result<(), BoolError>
Waits for timeout
seconds until waits
number of GstClockID
waits is
registered with the 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 GstClockID
registered with
the 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 element(&self) -> Option<Element>
pub fn sinkpad(&self) -> Option<Pad>
pub fn srcpad(&self) -> Option<Pad>
pub fn sink_harness(&self) -> Option<Ref<'_>>
pub fn src_harness(&self) -> Option<Ref<'_>>
pub fn sink_harness_mut(&mut self) -> Option<RefMut<'_>>
pub fn src_harness_mut(&mut self) -> Option<RefMut<'_>>
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for RefMut<'a>
impl<'a> RefUnwindSafe for RefMut<'a>
impl<'a> Send for RefMut<'a>
impl<'a> Sync for RefMut<'a>
impl<'a> Unpin for RefMut<'a>
impl<'a> !UnwindSafe for RefMut<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more