gstcheck

package
v0.0.0-...-ccbbe8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2023 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GTypeTestClock = coreglib.Type(C.gst_test_clock_get_type())
)

GType values.

Functions

func BufferStrawGetBuffer

func BufferStrawGetBuffer(bin gst.Elementer, pad *gst.Pad) *gst.Buffer

BufferStrawGetBuffer: 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 gst_buffer_straw_start_pipeline() on pipeline and pad.

The function takes the following parameters:

  • bin: pipeline previously started via gst_buffer_straw_start_pipeline().
  • pad previously passed to gst_buffer_straw_start_pipeline().

The function returns the following values:

  • buffer: captured Buffer.

func BufferStrawStartPipeline

func BufferStrawStartPipeline(bin gst.Elementer, pad *gst.Pad)

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

The function takes the following parameters:

  • bin: pipeline to run.
  • pad on an element in bin.

func BufferStrawStopPipeline

func BufferStrawStopPipeline(bin gst.Elementer, pad *gst.Pad)

BufferStrawStopPipeline: set bin to T_STATE_NULL and release resource allocated in gst_buffer_straw_start_pipeline().

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

The function takes the following parameters:

  • bin: pipeline previously started via gst_buffer_straw_start_pipeline().
  • pad previously passed to gst_buffer_straw_start_pipeline().

func CheckAbiList

func CheckAbiList(list *CheckABIStruct, haveAbiSizes bool)

CheckAbiList verifies that reference values and current values are equals in list.

The function takes the following parameters:

  • list of GstCheckABIStruct to be verified.
  • haveAbiSizes: whether there is a reference ABI size already specified, if it is FALSE and the GST_ABI environment variable is set, usable code for list will be printed.

func CheckBufferData

func CheckBufferData(buffer *gst.Buffer, data unsafe.Pointer, size uint)

CheckBufferData: compare the buffer contents with data and size.

The function takes the following parameters:

  • buffer to compare.
  • data (optional) to compare to.
  • size of data to compare.

func CheckCapsEqual

func CheckCapsEqual(caps1, caps2 *gst.Caps)

CheckCapsEqual: compare two caps with gst_caps_is_equal and fail unless they are equal.

The function takes the following parameters:

  • caps1: first caps to compare.
  • caps2: second caps to compare.

func CheckChainFunc

func CheckChainFunc(pad *gst.Pad, parent gst.GstObjector, buffer *gst.Buffer) gst.FlowReturn

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

The function takes the following parameters:

  • pad
  • parent
  • buffer

The function returns the following values:

func CheckClearLogFilter

func CheckClearLogFilter()

CheckClearLogFilter: clear all filters added by gst_check_add_log_filter.

MT safe.

func CheckDropBuffers

func CheckDropBuffers()

CheckDropBuffers: unref and remove all buffers that are in the global buffers GList, emptying the list.

func CheckElementPushBuffer

func CheckElementPushBuffer(elementName string, bufferIn *gst.Buffer, capsIn *gst.Caps, bufferOut *gst.Buffer, capsOut *gst.Caps)

CheckElementPushBuffer: 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.

The function takes the following parameters:

  • elementName: name of the element that needs to be created.
  • bufferIn: push this buffer to the element.
  • capsIn expected of the sinkpad of the element.
  • bufferOut: compare the result with this buffer.
  • capsOut expected of the srcpad of the element.

func CheckElementPushBufferList

func CheckElementPushBufferList(elementName string, bufferIn []*gst.Buffer, capsIn *gst.Caps, bufferOut []*gst.Buffer, capsOut *gst.Caps, lastFlowReturn gst.FlowReturn)

CheckElementPushBufferList: 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.

The function takes the following parameters:

  • elementName: name of the element that needs to be created.
  • bufferIn: list of buffers that needs to be pushed to the element.
  • capsIn expected of the sinkpad of the element.
  • bufferOut: list of buffers that we expect from the element.
  • capsOut expected of the srcpad of the element.
  • lastFlowReturn: last buffer push needs to give this GstFlowReturn.

func CheckMessageError

func CheckMessageError(message *gst.Message, typ gst.MessageType, domain glib.Quark, code int)

The function takes the following parameters:

  • message
  • typ
  • domain
  • code

func CheckSetupElement

func CheckSetupElement(factory string) gst.Elementer

CheckSetupElement: setup an element for a filter test with mysrcpad and mysinkpad.

The function takes the following parameters:

  • factory: factory.

The function returns the following values:

  • element: new element.

func CheckSetupEvents

func CheckSetupEvents(srcpad *gst.Pad, element gst.Elementer, caps *gst.Caps, format gst.Format)

CheckSetupEvents: 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 gst_check_setup_events_with_stream_id() instead.

The function takes the following parameters:

  • srcpad: src Pad to push on.
  • element use to create the stream id.
  • caps (optional) in case caps event must be sent.
  • format of the default segment to send.

func CheckSetupEventsWithStreamID

func CheckSetupEventsWithStreamID(srcpad *gst.Pad, element gst.Elementer, caps *gst.Caps, format gst.Format, streamId string)

CheckSetupEventsWithStreamID: 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.

The function takes the following parameters:

  • srcpad: src Pad to push on.
  • element use to create the stream id.
  • caps (optional) in case caps event must be sent.
  • format of the default segment to send.
  • streamId: unique identifier for the stream.

func CheckSetupSinkPad

func CheckSetupSinkPad(element gst.Elementer, tmpl *gst.StaticPadTemplate) *gst.Pad

CheckSetupSinkPad does the same as #gst_check_setup_sink_pad_by_name with the <emphasis> name </emphasis> parameter equal to "src".

The function takes the following parameters:

  • element to setup pad on.
  • tmpl: pad template.

The function returns the following values:

  • pad: new pad that can be used to check the output of element.

func CheckSetupSinkPadByName

func CheckSetupSinkPadByName(element gst.Elementer, tmpl *gst.StaticPadTemplate, name string) *gst.Pad

CheckSetupSinkPadByName 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.

The function takes the following parameters:

  • element to setup pad on.
  • tmpl: pad template.
  • name: name of the element src pad that will be linked to the sink pad that will be setup.

The function returns the following values:

  • pad: new pad that can be used to check the output of element.

func CheckSetupSinkPadByNameFromTemplate

func CheckSetupSinkPadByNameFromTemplate(element gst.Elementer, tmpl *gst.PadTemplate, name string) *gst.Pad

The function takes the following parameters:

  • element to setup pad on.
  • tmpl: pad template.
  • name: name.

The function returns the following values:

  • pad: new pad.

func CheckSetupSinkPadFromTemplate

func CheckSetupSinkPadFromTemplate(element gst.Elementer, tmpl *gst.PadTemplate) *gst.Pad

The function takes the following parameters:

  • element to setup pad on.
  • tmpl: pad template.

The function returns the following values:

  • pad: new pad.

func CheckSetupSrcPad

func CheckSetupSrcPad(element gst.Elementer, tmpl *gst.StaticPadTemplate) *gst.Pad

CheckSetupSrcPad does the same as #gst_check_setup_src_pad_by_name with the <emphasis> name </emphasis> parameter equal to "sink".

The function takes the following parameters:

  • element to setup pad on.
  • tmpl: pad template.

The function returns the following values:

  • pad: new pad that can be used to inject data on element.

func CheckSetupSrcPadByName

func CheckSetupSrcPadByName(element gst.Elementer, tmpl *gst.StaticPadTemplate, name string) *gst.Pad

CheckSetupSrcPadByName creates a new src pad (based on the given tmpl) and links it to the given element sink pad (the pad that matches the given name). Before using the src pad to push data on element you need to call #gst_check_setup_events on the created src pad.

Example of how to push a buffer on element:

static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (YOUR_CAPS_TEMPLATE_STRING)
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (YOUR_CAPS_TEMPLATE_STRING)
);

GstElement * element = gst_check_setup_element ("element");
GstPad * mysrcpad = gst_check_setup_src_pad (element, &srctemplate);
GstPad * mysinkpad = gst_check_setup_sink_pad (element, &sinktemplate);

gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
fail_unless (gst_element_set_state (element, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, "could not set to playing");

GstCaps * caps = gst_caps_from_string (YOUR_DESIRED_SINK_CAPS);
gst_check_setup_events (mysrcpad, element, caps, GST_FORMAT_TIME);
gst_caps_unref (caps);

fail_unless (gst_pad_push (mysrcpad, gst_buffer_new_and_alloc(2)) == GST_FLOW_OK);

For very simple input/output test scenarios checkout #gst_check_element_push_buffer_list and #gst_check_element_push_buffer.

The function takes the following parameters:

  • element to setup src pad on.
  • tmpl: pad template.
  • name: name of the element sink pad that will be linked to the src pad that will be setup.

The function returns the following values:

  • pad: new pad that can be used to inject data on element.

func CheckSetupSrcPadByNameFromTemplate

func CheckSetupSrcPadByNameFromTemplate(element gst.Elementer, tmpl *gst.PadTemplate, name string) *gst.Pad

The function takes the following parameters:

  • element to setup pad on.
  • tmpl: pad template.
  • name: name.

The function returns the following values:

  • pad: new pad.

func CheckSetupSrcPadFromTemplate

func CheckSetupSrcPadFromTemplate(element gst.Elementer, tmpl *gst.PadTemplate) *gst.Pad

The function takes the following parameters:

  • element to setup pad on.
  • tmpl: pad template.

The function returns the following values:

  • pad: new pad.

func CheckTeardownElement

func CheckTeardownElement(element gst.Elementer)

The function takes the following parameters:

func CheckTeardownPadByName

func CheckTeardownPadByName(element gst.Elementer, name string)

The function takes the following parameters:

  • element
  • name

func CheckTeardownSinkPad

func CheckTeardownSinkPad(element gst.Elementer)

The function takes the following parameters:

func CheckTeardownSrcPad

func CheckTeardownSrcPad(element gst.Elementer)

The function takes the following parameters:

func TestClockIDListGetLatestTime

func TestClockIDListGetLatestTime(pendingList []gst.ClockID) gst.ClockTime

TestClockIDListGetLatestTime finds the latest time inside the list.

MT safe.

The function takes the following parameters:

  • pendingList (optional): list of of pending ClockIDs.

The function returns the following values:

Types

type CheckABIStruct

type CheckABIStruct struct {
	// contains filtered or unexported fields
}

CheckABIStruct: instance of this type is always passed by reference.

func (*CheckABIStruct) AbiSize

func (c *CheckABIStruct) AbiSize() int

AbiSize: reference size of the structure.

func (*CheckABIStruct) Name

func (c *CheckABIStruct) Name() string

Name: name of the structure.

func (*CheckABIStruct) SetAbiSize

func (c *CheckABIStruct) SetAbiSize(abiSize int)

AbiSize: reference size of the structure.

func (*CheckABIStruct) SetSize

func (c *CheckABIStruct) SetSize(size int)

Size: current size of a structure.

func (*CheckABIStruct) Size

func (c *CheckABIStruct) Size() int

Size: current size of a structure.

type CheckLogFilterFunc

type CheckLogFilterFunc func(logDomain string, logLevel glib.LogLevelFlags, message string) (ok bool)

CheckLogFilterFunc: function that is called for messages matching the filter added by gst_check_add_log_filter.

type Harness

type Harness struct {
	// contains filtered or unexported fields
}

Harness is meant to make writing unit test for GStreamer much easier. It can be thought of as a way of treating a Element as a black box, deterministically feeding it data, and controlling what data it outputs.

The basic structure of Harness is two "floating" Pads that connect to the harnessed Element src and sink Pads like so:

          __________________________
 _____   |  _____            _____  |   _____
|     |  | |     |          |     | |  |     |
| src |--+-| sink|  Element | src |-+--| sink|
|_____|  | |_____|          |_____| |  |_____|
         |__________________________|

With this, you can now simulate any environment the Element might find itself in. By specifying the Caps of the harness Pads, using functions like gst_harness_set_src_caps() or gst_harness_set_sink_caps_str(), you can test how the Element interacts with different caps sets.

Your harnessed Element can of course also be a bin, and using gst_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 Buffers and Events on to the srcpad, using functions like gst_harness_push() and gst_harness_push_event(), and then pull them out to examine them with gst_harness_pull() and gst_harness_pull_event().

A simple buffer-in buffer-out example

gst_harness_push_from_src (h);

An instance of this type is always passed by reference.

func (*Harness) AddElementSinkPad

func (h *Harness) AddElementSinkPad(sinkpad *gst.Pad)

AddElementSinkPad links the specified Pad the GstHarness srcpad.

MT safe.

The function takes the following parameters:

  • sinkpad to link to the harness srcpad.

func (*Harness) AddElementSrcPad

func (h *Harness) AddElementSrcPad(srcpad *gst.Pad)

AddElementSrcPad links the specified 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.

The function takes the following parameters:

  • srcpad to link to the harness sinkpad.

func (*Harness) AddProbe

func (h *Harness) AddProbe(elementName string, padName string, mask gst.PadProbeType, callback gst.PadProbeCallback)

AddProbe: convenience function to allows you to call gst_pad_add_probe on a Pad of a Element that are residing inside the Harness, by using normal gst_pad_add_probe syntax

MT safe.

The function takes the following parameters:

  • elementName with a ElementFactory name.
  • padName with the name of the pad to attach the probe to.
  • mask (see gst_pad_add_probe).
  • callback (see gst_pad_add_probe).

func (*Harness) AddProposeAllocationMeta

func (h *Harness) AddProposeAllocationMeta(api coreglib.Type, params *gst.Structure)

AddProposeAllocationMeta: add api with params as one of the supported metadata API to propose when receiving an allocation query.

MT safe.

The function takes the following parameters:

  • api: metadata API.
  • params (optional): API specific parameters.

func (*Harness) AddSink

func (h *Harness) AddSink(sinkElementName string)

AddSink: 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.

The function takes the following parameters:

  • sinkElementName with the name of a Element.

func (*Harness) AddSinkHarness

func (h *Harness) AddSinkHarness(sinkHarness *Harness)

AddSinkHarness: similar to gst_harness_add_src, this allows you to send the data coming out of your harnessed 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.

The function takes the following parameters:

  • sinkHarness to be added as a sink-harness.

func (*Harness) AddSinkParse

func (h *Harness) AddSinkParse(launchline string)

AddSinkParse: 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.

The function takes the following parameters:

  • launchline with the name of a Element.

func (*Harness) AddSrc

func (h *Harness) AddSrc(srcElementName string, hasClockWait bool)

AddSrc: 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.

The function takes the following parameters:

  • srcElementName with the name of a Element.
  • hasClockWait specifying if the Element uses gst_clock_wait_id internally.

func (*Harness) AddSrcHarness

func (h *Harness) AddSrcHarness(srcHarness *Harness, hasClockWait bool)

AddSrcHarness src-harness is a great way of providing the Harness with data. By adding a src-type 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.

The function takes the following parameters:

  • srcHarness to be added as a src-harness.
  • hasClockWait specifying if the Element uses gst_clock_wait_id internally.

func (*Harness) AddSrcParse

func (h *Harness) AddSrcParse(launchline string, hasClockWait bool)

AddSrcParse: similar to gst_harness_add_src, this allows you to specify a launch-line, which can be useful for both having more then one 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.

The function takes the following parameters:

  • launchline describing a gst-launch type line.
  • hasClockWait specifying if the Element uses gst_clock_wait_id internally.

func (*Harness) Allocator

func (h *Harness) Allocator() (gst.Allocatorrer, *gst.AllocationParams)

Allocator gets the allocator and its params that has been decided to use after an allocation query.

MT safe.

The function returns the following values:

  • allocator (optional): Allocator used.
  • params (optional) of allocator.

func (*Harness) BuffersInQueue

func (h *Harness) BuffersInQueue() uint

BuffersInQueue: number of Buffers currently in the Harness sinkpad Queue

MT safe.

The function returns the following values:

  • guint number of buffers in the queue.

func (*Harness) BuffersReceived

func (h *Harness) BuffersReceived() uint

BuffersReceived: total number of Buffers that has arrived on the Harness sinkpad. This number includes buffers that have been dropped as well as buffers that have already been pulled out.

MT safe.

The function returns the following values:

  • guint number of buffers received.

func (*Harness) CrankMultipleClockWaits

func (h *Harness) CrankMultipleClockWaits(waits uint) bool

CrankMultipleClockWaits: similar to gst_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 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.

The function takes the following parameters:

  • waits describing the number of ClockIDs to crank.

The function returns the following values:

  • ok: gboolean TRUE if the "crank" was successful, FALSE if not.

func (*Harness) CrankSingleClockWait

func (h *Harness) CrankSingleClockWait() bool

CrankSingleClockWait: "crank" consists of three steps: 1: Wait for a ClockID to be registered with the TestClock. 2: Advance the TestClock to the time the ClockID is waiting for. 3: Release the 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.

The function returns the following values:

  • ok: gboolean TRUE if the "crank" was successful, FALSE if not.

func (*Harness) CreateBuffer

func (h *Harness) CreateBuffer(size uint) *gst.Buffer

CreateBuffer allocates a buffer using a BufferPool if present, or else using the configured Allocator and AllocationParams

MT safe.

The function takes the following parameters:

  • size specifying the size of the buffer.

The function returns the following values:

  • buffer of size size.

func (*Harness) DumpToFile

func (h *Harness) DumpToFile(filename string)

DumpToFile allows you to dump the Buffers the Harness sinkpad Queue to a file.

MT safe.

The function takes the following parameters:

  • filename with a the name of a file.

func (*Harness) Element

func (h *Harness) Element() gst.Elementer

Element: element inside the harness.

func (*Harness) EventsInQueue

func (h *Harness) EventsInQueue() uint

EventsInQueue: number of Events currently in the Harness sinkpad Queue

MT safe.

The function returns the following values:

  • guint number of events in the queue.

func (*Harness) EventsReceived

func (h *Harness) EventsReceived() uint

EventsReceived: total number of Events that has arrived on the Harness sinkpad This number includes events handled by the harness as well as events that have already been pulled out.

MT safe.

The function returns the following values:

  • guint number of events received.

func (*Harness) FindElement

func (h *Harness) FindElement(elementName string) gst.Elementer

FindElement: most useful in conjunction with gst_harness_new_parse, this will scan the Elements 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.

The function takes the following parameters:

  • elementName with a ElementFactory name.

The function returns the following values:

  • element (optional) or NULL if not found.

func (*Harness) LastPushedTimestamp

func (h *Harness) LastPushedTimestamp() gst.ClockTime

LastPushedTimestamp: get the timestamp of the last Buffer pushed on the Harness srcpad, typically with gst_harness_push or gst_harness_push_from_src.

MT safe.

The function returns the following values:

  • clockTime with the timestamp or GST_CLOCK_TIME_NONE if no Buffer has been pushed on the Harness srcpad.

func (*Harness) Play

func (h *Harness) Play()

Play: this will set the harnessed Element to GST_STATE_PLAYING. Elements without a sink-Pad and with the GST_ELEMENT_FLAG_SOURCE flag set is considered a src Element Non-src Elements (like sinks and filters) are automatically set to playing by the Harness, but src Elements are not to avoid them starting to produce buffers. Hence, for src Element you must call gst_harness_play() explicitly.

MT safe.

func (*Harness) Pull

func (h *Harness) Pull() *gst.Buffer

Pull pulls a Buffer from the Queue on the Harness sinkpad. The pull will timeout in 60 seconds. This is the standard way of getting a buffer from a harnessed Element.

MT safe.

The function returns the following values:

  • buffer or NULL if timed out.

func (*Harness) PullEvent

func (h *Harness) PullEvent() *gst.Event

PullEvent pulls an Event from the Queue on the Harness sinkpad. Timeouts after 60 seconds similar to gst_harness_pull.

MT safe.

The function returns the following values:

  • event or NULL if timed out.

func (*Harness) PullUntilEos

func (h *Harness) PullUntilEos() (*gst.Buffer, bool)

PullUntilEos pulls a Buffer from the Queue on the Harness sinkpad. The pull will block until an EOS event is received, or timeout in 60 seconds. MT safe.

The function returns the following values:

  • buf or NULL if EOS or timeout occures first.
  • ok: TRUE on success, FALSE on timeout.

func (*Harness) PullUpstreamEvent

func (h *Harness) PullUpstreamEvent() *gst.Event

PullUpstreamEvent pulls an Event from the Queue on the Harness srcpad. Timeouts after 60 seconds similar to gst_harness_pull.

MT safe.

The function returns the following values:

  • event or NULL if timed out.

func (*Harness) Push

func (h *Harness) Push(buffer *gst.Buffer) gst.FlowReturn

Push pushes a Buffer on the Harness srcpad. The standard way of interacting with an harnessed element.

MT safe.

The function takes the following parameters:

  • buffer to push.

The function returns the following values:

  • flowReturn with the result from the push.

func (*Harness) PushAndPull

func (h *Harness) PushAndPull(buffer *gst.Buffer) *gst.Buffer

PushAndPull: 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.

The function takes the following parameters:

  • buffer to push.

The function returns the following values:

  • ret or NULL if timed out.

func (*Harness) PushEvent

func (h *Harness) PushEvent(event *gst.Event) bool

PushEvent pushes an Event on the Harness srcpad.

MT safe.

The function takes the following parameters:

  • event to push.

The function returns the following values:

  • ok with the result from the push.

func (*Harness) PushFromSrc

func (h *Harness) PushFromSrc() gst.FlowReturn

PushFromSrc: 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 Buffer from the src-Harness (see: gst_harness_pull) 4: Push the same Buffer into the main-Harness (see: gst_harness_push)

MT safe.

The function returns the following values:

  • flowReturn with the result of the push.

func (*Harness) PushToSink

func (h *Harness) PushToSink() gst.FlowReturn

PushToSink: transfer one Buffer from the main-Harness to the sink-Harness. See gst_harness_push_from_src for details.

MT safe.

The function returns the following values:

  • flowReturn with the result of the push.

func (*Harness) PushUpstreamEvent

func (h *Harness) PushUpstreamEvent(event *gst.Event) bool

PushUpstreamEvent pushes an Event on the Harness sinkpad.

MT safe.

The function takes the following parameters:

  • event to push.

The function returns the following values:

  • ok with the result from the push.

func (*Harness) QueryLatency

func (h *Harness) QueryLatency() gst.ClockTime

QueryLatency: get the min latency reported by any harnessed Element.

MT safe.

The function returns the following values:

  • clockTime with min latency.

func (*Harness) SetBlockingPushMode

func (h *Harness) SetBlockingPushMode()

SetBlockingPushMode: setting this will make the harness block in the chain-function, and then release when gst_harness_pull() or gst_harness_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.

func (*Harness) SetCaps

func (h *Harness) SetCaps(in *gst.Caps, out *gst.Caps)

SetCaps sets the GstHarness srcpad and sinkpad caps.

MT safe.

The function takes the following parameters:

  • in to set on the harness srcpad.
  • out to set on the harness sinkpad.

func (*Harness) SetCapsStr

func (h *Harness) SetCapsStr(in string, out string)

SetCapsStr sets the GstHarness srcpad and sinkpad caps using strings.

MT safe.

The function takes the following parameters:

  • in: gchar describing a Caps to set on the harness srcpad.
  • out: gchar describing a Caps to set on the harness sinkpad.

func (*Harness) SetDropBuffers

func (h *Harness) SetDropBuffers(dropBuffers bool)

SetDropBuffers: when set to TRUE, instead of placing the buffers arriving from the harnessed Element inside the sinkpads Queue, they are instead unreffed.

MT safe.

The function takes the following parameters:

  • dropBuffers specifying to drop outgoing buffers or not.

func (*Harness) SetForwarding

func (h *Harness) SetForwarding(forwarding bool)

SetForwarding 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 gst_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.

The function takes the following parameters:

  • forwarding to enable/disable forwarding.

func (*Harness) SetLive

func (h *Harness) SetLive(isLive bool)

SetLive sets the liveness reported by Harness when receiving a latency-query. The default is TRUE.

The function takes the following parameters:

  • isLive: TRUE for live, FALSE for non-live.

func (*Harness) SetProposeAllocator

func (h *Harness) SetProposeAllocator(allocator gst.Allocatorrer, params *gst.AllocationParams)

SetProposeAllocator sets the allocator and params to propose when receiving an allocation query.

MT safe.

The function takes the following parameters:

  • allocator (optional): Allocator.
  • params (optional): AllocationParams.

func (*Harness) SetSinkCaps

func (h *Harness) SetSinkCaps(caps *gst.Caps)

SetSinkCaps sets the GstHarness sinkpad caps.

MT safe.

The function takes the following parameters:

  • caps to set on the harness sinkpad.

func (*Harness) SetSinkCapsStr

func (h *Harness) SetSinkCapsStr(str string)

SetSinkCapsStr sets the GstHarness sinkpad caps using a string.

MT safe.

The function takes the following parameters:

  • str: gchar describing a Caps to set on the harness sinkpad.

func (*Harness) SetSrcCaps

func (h *Harness) SetSrcCaps(caps *gst.Caps)

SetSrcCaps sets the GstHarness srcpad caps. This must be done before any buffers can legally be pushed from the harness to the element.

MT safe.

The function takes the following parameters:

  • caps to set on the harness srcpad.

func (*Harness) SetSrcCapsStr

func (h *Harness) SetSrcCapsStr(str string)

SetSrcCapsStr 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.

The function takes the following parameters:

  • str: gchar describing a Caps to set on the harness srcpad.

func (*Harness) SetTime

func (h *Harness) SetTime(time gst.ClockTime) bool

SetTime: advance the TestClock to a specific time.

MT safe.

The function takes the following parameters:

  • time to advance the clock to.

The function returns the following values:

  • ok: gboolean TRUE if the time could be set. FALSE if not.

func (*Harness) SetUpstreamLatency

func (h *Harness) SetUpstreamLatency(latency gst.ClockTime)

SetUpstreamLatency sets the min latency reported by Harness when receiving a latency-query.

The function takes the following parameters:

  • latency specifying the latency.

func (*Harness) SinkHarness

func (h *Harness) SinkHarness() *Harness

SinkHarness: sink (output) harness (if any).

func (*Harness) SinkPushMany

func (h *Harness) SinkPushMany(pushes int) gst.FlowReturn

SinkPushMany: convenience that calls gst_harness_push_to_sink pushes number of times. Will abort the pushing if any one push fails.

MT safe.

The function takes the following parameters:

  • pushes with the number of calls to gst_harness_push_to_sink.

The function returns the following values:

  • flowReturn with the result of the push.

func (*Harness) Sinkpad

func (h *Harness) Sinkpad() *gst.Pad

Sinkpad: internal harness sink pad.

func (*Harness) SrcCrankAndPushMany

func (h *Harness) SrcCrankAndPushMany(cranks int, pushes int) gst.FlowReturn

SrcCrankAndPushMany: 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.

The function takes the following parameters:

  • cranks with the number of calls to gst_harness_crank_single_clock_wait.
  • pushes with the number of calls to gst_harness_push.

The function returns the following values:

  • flowReturn with the result of the push.

func (*Harness) SrcHarness

func (h *Harness) SrcHarness() *Harness

SrcHarness: source (input) harness (if any).

func (*Harness) SrcPushEvent

func (h *Harness) SrcPushEvent() bool

SrcPushEvent: similar to what gst_harness_src_push does with Buffers, this transfers a Event from the src-Harness to the main-Harness. Note that some Events are being transferred automagically. Look at sink_forward_pad for details.

MT safe.

The function returns the following values:

  • ok with the result of the push.

func (*Harness) Srcpad

func (h *Harness) Srcpad() *gst.Pad

Srcpad: internal harness source pad.

func (*Harness) TakeAllData

func (h *Harness) TakeAllData() *glib.Bytes

TakeAllData pulls all pending data from the harness and returns it as a single #GBytes.

The function returns the following values:

  • bytes: pointer to the data, newly allocated. Free with g_free() when no longer needed.

func (*Harness) TakeAllDataAsBuffer

func (h *Harness) TakeAllDataAsBuffer() *gst.Buffer

TakeAllDataAsBuffer pulls all pending data from the harness and returns it as a single buffer.

The function returns the following values:

  • buffer: data as a buffer. Unref with gst_buffer_unref() when no longer needed.

func (*Harness) Teardown

func (h *Harness) Teardown()

Teardown tears down a GstHarness, freeing all resources allocated using it.

MT safe.

func (*Harness) Testclock

func (h *Harness) Testclock() *TestClock

Testclock: get the TestClock. Useful if specific operations on the testclock is needed.

MT safe.

The function returns the following values:

  • testClock or NULL if the testclock is not present.

func (*Harness) TryPull

func (h *Harness) TryPull() *gst.Buffer

TryPull pulls a Buffer from the Queue on the Harness sinkpad. Unlike gst_harness_pull this will not wait for any buffers if not any are present, and return NULL straight away.

MT safe.

The function returns the following values:

  • buffer or NULL if no buffers are present in the Queue.

func (*Harness) TryPullEvent

func (h *Harness) TryPullEvent() *gst.Event

TryPullEvent pulls an Event from the Queue on the Harness sinkpad. See gst_harness_try_pull for details.

MT safe.

The function returns the following values:

  • event or NULL if no buffers are present in the Queue.

func (*Harness) TryPullUpstreamEvent

func (h *Harness) TryPullUpstreamEvent() *gst.Event

TryPullUpstreamEvent pulls an Event from the Queue on the Harness srcpad. See gst_harness_try_pull for details.

MT safe.

The function returns the following values:

  • event or NULL if no buffers are present in the Queue.

func (*Harness) UpstreamEventsInQueue

func (h *Harness) UpstreamEventsInQueue() uint

UpstreamEventsInQueue: number of Events currently in the Harness srcpad Queue

MT safe.

The function returns the following values:

  • guint number of events in the queue.

func (*Harness) UpstreamEventsReceived

func (h *Harness) UpstreamEventsReceived() uint

UpstreamEventsReceived: total number of Events that has arrived on the Harness srcpad This number includes events handled by the harness as well as events that have already been pulled out.

MT safe.

The function returns the following values:

  • guint number of events received.

func (*Harness) UseSystemclock

func (h *Harness) UseSystemclock()

UseSystemclock sets the system Clock on the GstHarness Element

MT safe.

func (*Harness) UseTestclock

func (h *Harness) UseTestclock()

UseTestclock sets the TestClock on the Harness Element

MT safe.

func (*Harness) WaitForClockIDWaits

func (h *Harness) WaitForClockIDWaits(waits uint, timeout uint) bool

WaitForClockIDWaits waits for timeout seconds until waits number of ClockID 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.

The function takes the following parameters:

  • waits describing the numbers of ClockID registered with the TestClock.
  • timeout describing how many seconds to wait for waits to be true.

The function returns the following values:

  • ok: 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).

type TestClock

type TestClock struct {
	gst.Clock
	// contains filtered or unexported fields
}

TestClock is an implementation of Clock which has different behaviour compared to SystemClock. Time for SystemClock advances according to the system time, while time for TestClock changes only when gst_test_clock_set_time() or gst_test_clock_advance_time() are called. TestClock provides unit tests with the possibility to precisely advance the time in a deterministic manner, independent of the system time or any other external factors.

Advancing the time of a TestClock

#include <gst/gst.h>
#include <gst/check/gstcheck.h>
#include <gst/check/gsttestclock.h>

GstClockTime latency;
GstElement *element;
GstPad *srcpad;
GstClock *clock;
GstTestClock *test_clock;
GstBuffer buf;
GstClockID pending_id;
GstClockID processed_id;

latency = 42 * GST_MSECOND;
element = create_element (latency, ...);
srcpad = get_source_pad (element);

clock = gst_test_clock_new ();
test_clock = GST_TEST_CLOCK (clock);
gst_element_set_clock (element, clock);

GST_INFO ("Set time, create and push the first buffer\n");
gst_test_clock_set_time (test_clock, 0);
buf = create_test_buffer (gst_clock_get_time (clock), ...);
gst_assert_cmpint (gst_pad_push (srcpad, buf), ==, GST_FLOW_OK);

GST_INFO ("Block until element is waiting for a clock notification\n");
gst_test_clock_wait_for_next_pending_id (test_clock, &pending_id);
GST_INFO ("Advance to the requested time of the clock notification\n");
gst_test_clock_advance_time (test_clock, latency);
GST_INFO ("Release the next blocking wait and make sure it is the one from element\n");
processed_id = gst_test_clock_process_next_clock_id (test_clock);
g_assert (processed_id == pending_id);
g_assert_cmpint (GST_CLOCK_ENTRY_STATUS (processed_id), ==, GST_CLOCK_OK);
gst_clock_id_unref (pending_id);
gst_clock_id_unref (processed_id);

GST_INFO ("Validate that element produced an output buffer and check its timestamp\n");
g_assert_cmpint (get_number_of_output_buffer (...), ==, 1);
buf = get_buffer_pushed_by_element (element, ...);
g_assert_cmpint (GST_BUFFER_TIMESTAMP (buf), ==, latency);
gst_buffer_unref (buf);
GST_INFO ("Check that element does not wait for any clock notification\n");
g_assert (!gst_test_clock_peek_next_pending_id (test_clock, NULL));

GST_INFO ("Set time, create and push the second buffer\n");
gst_test_clock_advance_time (test_clock, 10 * GST_SECOND);
buf = create_test_buffer (gst_clock_get_time (clock), ...);
gst_assert_cmpint (gst_pad_push (srcpad, buf), ==, GST_FLOW_OK);

GST_INFO ("Block until element is waiting for a new clock notification\n");
(gst_test_clock_wait_for_next_pending_id (test_clock, &pending_id);
GST_INFO ("Advance past 7ms beyond the requested time of the clock notification\n");
gst_test_clock_advance_time (test_clock, latency + 7 * GST_MSECOND);
GST_INFO ("Release the next blocking wait and make sure it is the one from element\n");
processed_id = gst_test_clock_process_next_clock_id (test_clock);
g_assert (processed_id == pending_id);
g_assert_cmpint (GST_CLOCK_ENTRY_STATUS (processed_id), ==, GST_CLOCK_OK);
gst_clock_id_unref (pending_id);
gst_clock_id_unref (processed_id);

GST_INFO ("Validate that element produced an output buffer and check its timestamp\n");
g_assert_cmpint (get_number_of_output_buffer (...), ==, 1);
buf = get_buffer_pushed_by_element (element, ...);
g_assert_cmpint (GST_BUFFER_TIMESTAMP (buf), ==,
    10 * GST_SECOND + latency + 7 * GST_MSECOND);
gst_buffer_unref (buf);
GST_INFO ("Check that element does not wait for any clock notification\n");
g_assert (!gst_test_clock_peek_next_pending_id (test_clock, NULL));
...

Since TestClock is only supposed to be used in unit tests it calls g_assert(), g_assert_cmpint() or g_assert_cmpuint() to validate all function arguments. This will highlight any issues with the unit test code itself.

func NewTestClock

func NewTestClock() *TestClock

NewTestClock creates a new test clock with its time set to zero.

MT safe.

The function returns the following values:

  • testClock cast to Clock.

func NewTestClockWithStartTime

func NewTestClockWithStartTime(startTime gst.ClockTime) *TestClock

NewTestClockWithStartTime creates a new test clock with its time set to the specified time.

MT safe.

The function takes the following parameters:

  • startTime set to the desired start time of the clock.

The function returns the following values:

  • testClock cast to Clock.

func (*TestClock) AdvanceTime

func (testClock *TestClock) AdvanceTime(delta gst.ClockTimeDiff)

AdvanceTime advances the time of the test_clock by the amount given by delta. The time of test_clock is monotonically increasing, therefore providing a delta which is negative or zero is a programming error.

MT safe.

The function takes the following parameters:

  • delta: positive ClockTimeDiff to be added to the time of the clock.

func (*TestClock) Crank

func (testClock *TestClock) Crank() bool

Crank: "crank" consists of three steps: 1: Wait for a ClockID to be registered with the TestClock. 2: Advance the TestClock to the time the ClockID is waiting, unless the clock time is already passed the clock id (Since: 1.18). 3: Release the ClockID wait. A "crank" can be though of as the notion of manually driving the clock forward to its next logical step.

The function returns the following values:

  • ok: TRUE if the crank was successful, FALSE otherwise.

    MT safe.

func (*TestClock) HasID

func (testClock *TestClock) HasID(id gst.ClockID) bool

HasID checks whether test_clock was requested to provide the clock notification given by id.

MT safe.

The function takes the following parameters:

  • id clock notification.

The function returns the following values:

  • ok: TRUE if the clock has been asked to provide the given clock notification, FALSE otherwise.

func (*TestClock) NextEntryTime

func (testClock *TestClock) NextEntryTime() gst.ClockTime

NextEntryTime: retrieve the requested time for the next pending clock notification.

MT safe.

The function returns the following values:

  • clockTime set to the time of the next pending clock notification. If no clock notifications have been requested GST_CLOCK_TIME_NONE will be returned.

func (*TestClock) PeekIDCount

func (testClock *TestClock) PeekIDCount() uint

PeekIDCount: determine the number of pending clock notifications that have been requested from the test_clock.

MT safe.

The function returns the following values:

  • guint: number of pending clock notifications.

func (*TestClock) PeekNextPendingID

func (testClock *TestClock) PeekNextPendingID() (gst.ClockID, bool)

PeekNextPendingID determines if the pending_id is the next clock notification scheduled to be triggered given the current time of the test_clock.

MT safe.

The function returns the following values:

  • pendingId (optional) clock notification to look for.
  • ok: TRUE if pending_id is the next clock notification to be triggered, FALSE otherwise.

func (*TestClock) ProcessID

func (testClock *TestClock) ProcessID(pendingId gst.ClockID) bool

ProcessID processes and releases the pending ID.

MT safe.

The function takes the following parameters:

  • pendingId: ClockID.

The function returns the following values:

func (*TestClock) ProcessIDList

func (testClock *TestClock) ProcessIDList(pendingList []gst.ClockID) uint

ProcessIDList processes and releases the pending IDs in the list.

MT safe.

The function takes the following parameters:

  • pendingList (optional): list of pending ClockIDs.

The function returns the following values:

func (*TestClock) ProcessNextClockID

func (testClock *TestClock) ProcessNextClockID() gst.ClockID

ProcessNextClockID: MT safe.

The function returns the following values:

  • clockID (optional) containing the next pending clock notification.

func (*TestClock) SetTime

func (testClock *TestClock) SetTime(newTime gst.ClockTime)

SetTime sets the time of test_clock to the time given by new_time. The time of test_clock is monotonically increasing, therefore providing a new_time which is earlier or equal to the time of the clock as given by gst_clock_get_time() is a programming error.

MT safe.

The function takes the following parameters:

  • newTime later than that returned by gst_clock_get_time().

func (*TestClock) TimedWaitForMultiplePendingIDs

func (testClock *TestClock) TimedWaitForMultiplePendingIDs(count, timeoutMs uint) ([]gst.ClockID, bool)

TimedWaitForMultiplePendingIDs blocks until at least count clock notifications have been requested from test_clock, or the timeout expires.

MT safe.

The function takes the following parameters:

  • count: number of pending clock notifications to wait for.
  • timeoutMs: timeout in milliseconds.

The function returns the following values:

  • pendingList (optional): address of a #GList pointer variable to store the list of pending ClockIDs that expired, or NULL.
  • ok: 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).

func (*TestClock) WaitForMultiplePendingIDs

func (testClock *TestClock) WaitForMultiplePendingIDs(count uint) []gst.ClockID

WaitForMultiplePendingIDs blocks until at least count clock notifications have been requested from test_clock. There is no timeout for this wait, see the main description of TestClock.

MT safe.

The function takes the following parameters:

  • count: number of pending clock notifications to wait for.

The function returns the following values:

  • pendingList (optional): address of a #GList pointer variable to store the list of pending ClockIDs that expired, or NULL.

func (*TestClock) WaitForNextPendingID

func (testClock *TestClock) WaitForNextPendingID() gst.ClockID

WaitForNextPendingID waits until a clock notification is requested from test_clock. There is no timeout for this wait, see the main description of TestClock. A reference to the pending clock notification is stored in pending_id.

MT safe.

The function returns the following values:

  • pendingId (optional) information about the pending clock notification.

func (*TestClock) WaitForPendingIDCount deprecated

func (testClock *TestClock) WaitForPendingIDCount(count uint)

WaitForPendingIDCount blocks until at least count clock notifications have been requested from test_clock. There is no timeout for this wait, see the main description of TestClock.

Deprecated: use gst_test_clock_wait_for_multiple_pending_ids() instead.

The function takes the following parameters:

  • count: number of pending clock notifications to wait for.

type TestClockClass

type TestClockClass struct {
	// contains filtered or unexported fields
}

TestClockClass class of a TestClock, which has no virtual methods to override.

An instance of this type is always passed by reference.

func (*TestClockClass) ParentClass

func (t *TestClockClass) ParentClass() *gst.ClockClass

ParentClass: parent class structure.

type TestClockOverrides

type TestClockOverrides struct {
}

TestClockOverrides contains methods that are overridable.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL