Membrane Core v0.5.0 Membrane.Testing.Source View Source
Testing Element for supplying data based on generator function passed through options.
Example usage
As mentioned earlier you can use this element in one of two ways, providing
either a generator function or an Enumerable.t
.
%Sink{output: [0xA1, 0xB2, 0xC3, 0xD4]}
In order to specify Membrane.Testing.Sink
with generator function you need
to provide initial state and function that matches generator/0
type.
generator_function = fn state, size ->
#generate some buffers
{actions, state + 1}
end
%Sink{output: {1, generator_function}}
Element options
Passed via struct Membrane.Testing.Source.t/0
output
Default value:
{0, &Membrane.Testing.Source.default_buf_gen/2}
If
output
is an enumerable withMembrane.Payload.t()
then buffer containing those payloads will be sent through the:output
pad and followed byMembrane.Event.EndOfStream
.If
output
is a{initial_state, function}
tuple then the the function will be invoked each timehandle_demand
is called. It is an action generator that takes two arguments. The first argument is the state that is initially set toinitial_state
. The second one defines the size of the demand. Such function should return{actions, next_state}
whereactions
is a list of actions that will be returned fromhandle_demand/4
andnext_state
is the value that will be used for the next call.
Pads
:output
Availability | :always |
Bin? | false |
Caps | :any |
Direction | :output |
Mode | :pull |
Name | :output |
Link to this section Summary
Functions
Returns pads descriptions for Membrane.Testing.Source
Returns description of options available for this module
Link to this section Types
generator()
View Sourcegenerator() :: (state :: any(), buffers_cnt :: pos_integer() -> {[Membrane.Element.Action.t()], state :: any()})
Struct containing options for Membrane.Testing.Source
Link to this section Functions
default_buf_gen(generator_state, size)
View Sourcedefault_buf_gen(integer(), integer()) :: {[Membrane.Element.Action.t()], integer()}
membrane_pads()
View Sourcemembrane_pads() :: [{Membrane.Pad.name_t(), Membrane.Pad.description_t()}]
Returns pads descriptions for Membrane.Testing.Source
Returns description of options available for this module