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. Thanks
4 Replies
Sameer
SameerOPโ€ข3w ago
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
get_child(:filter 3)
|> via_out(:control)
|> via_in(:control)
|> get_child(:filter 1),
get_child(:filter 3)
|> via_out(:control)
|> via_in(:control)
|> get_child(:filter 1),
Feliks
Feliksโ€ข3w ago
@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
Sameer
SameerOPโ€ข3w ago
Thanks a lot @Feliks Thats even cleaner !! It also resolved the other problem I introduced ๐Ÿคญ

Did you find this page helpful?