How to send control events upstream/downstream ?
Hi ๐
I am new to elixir and even newer to Membrane ๐
I am trying to determine how to send events elements in the pipeline, which one or more other elements (upstream or downstream) could handle.
I came across https://hexdocs.pm/membrane_core/Membrane.Event.html , which links to https://hexdocs.pm/membrane_core/Membrane.Element.Action.html#t:event/0. Am I correct in understanding that control events also should be sent via pads (maybe creating custom pads that are not
input
output
but something like signal
or control
?
If there is a sample/demo that showcases what the correct arch approach is, I'd love to be pointed in the right direction.
Thanks4 Replies
Looks like events can be sent on the same pads as other input/output: https://github.com/membraneframework/membrane_realtimer_plugin/pull/25/files#diff-235f12e11e35e76672c0f8d2e30d6dcf24f92ef815cf43ad18d9f01e7d13c510R51
Thanks @samrat
Can you point me to how an element can send the event to an upstream element ?
In the case
Source A
-> Filter 1
-> Filter 2
-> Filter 3
-> Sink X
, how to define Filter 3
sending an event to Filter 1
?
Figured it out after your help and doing some more reading - https://hexdocs.pm/membrane_core/Membrane.ChildrenSpec.html#t:t/0
In case someone else needs to figure this out too, it involves creating a separate link in the pipeline spec with
@Sameer there is no need to create a new link from
:filter_3
to :filter_1
. All you have to do is to return action [event: {:input, %My.Event{}}]
in :filter_3
so it will be sent to the :filter_2
. IDK what is the implementation of :filter_2
, but if it doesn't do anything with events explicitly, %My.Event{}
by default will be forwarded to :filter_1
. Then, you will be able to handle it there in handle_event(:output, %My.Event{}, ctx, state)
callback