Pads guide - #1031
Conversation
b7223f3 to
756d2e3
Compare
mat-hek
left a comment
There was a problem hiding this comment.
Some examples from element's and bin's perspective (handle_pad_added, handle_pad_removed) would be useful. There's also handle_child_pad_removed. Maybe the flow of sending/receiving stream formats and handle_start_of_stream/handle_end_of_stream would be worth mentioning here too.
I'll add a brief lifecycle section, but I think the more in-depth interactions between callbacks, like the flow of events, stream formats and buffers, shouldn't be duplicated from the guide regarding component's lifecycle |
7548f9e to
b8872bf
Compare
b8872bf to
3262a1e
Compare
FelonEkonom
left a comment
There was a problem hiding this comment.
LGTM in general, however I have added some minor comments in places where I think something might be unclear for somebody who doesn't know much about the framework
| * A pad of one component can only connect to a single pad of other component and | ||
| only once two pads are linked communication through them can happen. | ||
| * One pad needs to be an input pad, and the other an output pad. | ||
| * The accepted stream formats of the pads need to match. |
There was a problem hiding this comment.
Make it more explicit that it doesn't mean that accepted formats must be equal. You don't have to follow the suggestion.
| * The accepted stream formats of the pads need to match. | |
| * The accepted stream formats of the pads cannot be disjoint. |
There was a problem hiding this comment.
I don't think the disjointness is that intuituve, but i wrote it more verbosely and łopatologically
| There are three types of information that can be exchanged between components | ||
| through pads - [stream formats](`t:Membrane.StreamFormat.t/0`), | ||
| [events](`t:Membrane.Event.t/0`) and [buffers](`t:Membrane.Buffer.t/0`) |
There was a problem hiding this comment.
you can also send EoS via pad
| There are three types of information that can be exchanged between components | ||
| through pads - [stream formats](`t:Membrane.StreamFormat.t/0`), | ||
| [events](`t:Membrane.Event.t/0`) and [buffers](`t:Membrane.Buffer.t/0`) | ||
|
|
||
| When looking at the insides of components, the pads are their main way to | ||
| communicate with other components in the pipeline. There are three types | ||
| of informations that can be exchanged between components through pads - | ||
| [stream formats](`t:Membrane.StreamFormat.t/0`), | ||
| [events](`t:Membrane.Event.t/0`) and [buffers](`t:Membrane.Buffer.t/0`). |
There was a problem hiding this comment.
looks like you repeat yourself
|
|
||
| ```elixir | ||
| @impl true | ||
| def some_callback(...) do |
There was a problem hiding this comment.
| def some_callback(...) do | |
| def hanlde_something(..., context, state) do |
| Input pads can only be defined for Sinks, Filters and Endpoints, and output | ||
| pads can only be defined for Sources, Filters and Endpoints. |
| [`:spec`](`t:Membrane.Pipeline.Action.spec/0`) action linking the dynamic pad is | ||
| being executed, then the pad is created dynamically and the component needs to | ||
| handle this, in most cases with | ||
| [`handle_pad_added/3`](`c:Membrane.Element.Base.handle_pad_added/3`). |
There was a problem hiding this comment.
please add an information that this callback is executed only for dynamic pads
| Another thing that's different are the pad references. The pad's name can't just | ||
| be used as the pad's reference, because it wouldn't be unique. Dynamic pads are | ||
| identified by [`Pad.ref/2`](`Membrane.Pad.ref/2`), that takes the pad's | ||
| name and some unique reference as arguments. The result is a unique pad reference | ||
| that is also associated with a given pad's specification through it's name. |
There was a problem hiding this comment.
Maybe you could mention that the reference of the specific pad can be known for the first time from hanlde_pad_added/3?
| Then the child with name `:some_child` would be stopped and removed from the | ||
| pipeline, unlinking all it's pads. If an input pad of this child happened to be | ||
| connected to our demuxer, then the | ||
| [`handle_pad_removed/3`](`c:Membrane.Element.Base.handle_pad_removed/3`) | ||
| would be called with a reference to the pad that was unlinked: | ||
|
|
||
| ```elixir | ||
| @impl true | ||
| def handle_pad_removed(Pad.ref(:output, unlinked_track_id), _context, state) do | ||
| ... | ||
| end | ||
| ``` |
There was a problem hiding this comment.
Please make it more explicit that this callback is executed in demuxer
|
|
||
| ### Removal | ||
|
|
||
| Static pads are removed and unlinked once their component is terminated. |
There was a problem hiding this comment.
| Static pads are removed and unlinked once their component is terminated. | |
| Static pads are removed and unlinked only once their component is terminated. |
| Because of this, each creation can be handled separately in | ||
| [`handle_pad_added/3`](`c:Membrane.Element.Base.handle_pad_added/3`) callback, | ||
| that's being called every time a new dynamic pad is linked, and therefore | ||
| created. |
There was a problem hiding this comment.
Maybe we could explain how linking pads in the same spec as spawning a child affects its init -> setup -> playing flow? And that linking pads in the another spec doesn't affect it at all.
| something that can't be ignored. If you think about elements and bins (from now | ||
| on referred to as components) as some | ||
| sort of containers or boxes in which processing happens, then pads are the parts | ||
| that with these containers are connected with. There are some constraints |
There was a problem hiding this comment.
| that with these containers are connected with. There are some constraints | |
| that these containers are connected with. There are some constraints |
Let's pass this through grammarly/chat to fix typos like this
mat-hek
left a comment
There was a problem hiding this comment.
- It would be nice to describe the lifecycle of bins pads - that they're linked extenrally and internally etc
- A picture or two would be nice to have, for example for the bins part
04135f3 to
487a251
Compare
| sent to whatever component is connected to the bin's newly created pad. | ||
|
|
||
| It's worth noting that pads of bins are only an abstraction. When a component | ||
| links with a bin, it actually links directly to the components inside of it to |
There was a problem hiding this comment.
| links with a bin, it actually links directly to the components inside of it to | |
| links with a bin, it actually links directly to one of the components inside the bin, to |
9841fae to
b4539b0
Compare
No description provided.