@@ -8,19 +8,18 @@ that with these containers are connected with. There are some constraints
88regarding pads:
99
1010* A pad of one component can only connect to a single pad of other component and
11- only once two pads are linked communication through them can happen.
11+ only once two pads are linked communication through them can happen.
1212* One pad needs to be an input pad, and the other an output pad.
13- * The accepted stream formats of the pads need to match.
14-
15- There are three types of information that can be exchanged between components
16- through pads - [ stream formats] ( `t:Membrane.StreamFormat.t/0` ) ,
17- [ events] ( `t:Membrane.Event.t/0` ) and [ buffers] ( `t:Membrane.Buffer.t/0` )
13+ * The accepted formats of the pads need to match - stream formats passing
14+ between elements through these pads need to match accepted formats of both.
1815
1916When looking at the insides of components, the pads are their main way to
20- communicate with other components in the pipeline. There are three types
17+ communicate with other components in the pipeline. There are four types
2118of informations that can be exchanged between components through pads -
2219[ stream formats] ( `t:Membrane.StreamFormat.t/0` ) ,
23- [ events] ( `t:Membrane.Event.t/0` ) and [ buffers] ( `t:Membrane.Buffer.t/0` ) .
20+ [ events] ( `t:Membrane.Event.t/0` ) , [ buffers] ( `t:Membrane.Buffer.t/0` ) and
21+ ` :end_of_stream ` s.
22+
2423When an component receives one of these informations from another one, it receives
2524it on a pad. The reference to this pad is then also available as an argument
2625of the callback that handles the received information. For example an invocation
@@ -43,7 +42,7 @@ from a callback would mean that a buffer `buffer` will be sent on a pad `some_pa
4342
4443``` elixir
4544@impl true
46- def some_callback (.. .) do
45+ def handle_something (.. ., _context , state ) do
4746 .. .
4847 {[buffer: {some_pad, buffer}], state}
4948end ^^^^^^ ^^
@@ -54,8 +53,8 @@ end ^^^^^^^^
5453To define what pads an component will have and how they'll behave we use
5554[ ` def_input_pad/2 ` ] ( `Membrane.Element.WithInputPads.def_input_pad/2` )
5655and [ ` def_output_pad/2 ` ] ( `Membrane.Element.WithOutputPads.def_output_pad/2` ) macros.
57- Input pads can only be defined for Sinks, Filters and Endpoints, and output
58- pads can only be defined for Sources, Filters and Endpoints.
56+ Input pads can only be defined for Bins, Sinks, Filters and Endpoints, and output
57+ pads can only be defined for Bins, Sources, Filters and Endpoints.
5958The first argument for these macros is a name, which then will be used to
6059identify the pads. The second argument is a [ pad spec] ( `t:Membrane.Pad.element_spec/0` )
6160keyword list, which is used to define how this pad will work. An option we'll
@@ -120,13 +119,17 @@ The creation of these pads is controlled by the parent of the component - if a
120119[ ` :spec ` ] ( `t:Membrane.Pipeline.Action.spec/0` ) action linking the dynamic pad is
121120being executed, then the pad is created dynamically and the component needs to
122121handle this, in most cases with
123- [ ` handle_pad_added/3 ` ] ( `c:Membrane.Element.Base.handle_pad_added/3` ) .
122+ [ ` handle_pad_added/3 ` ] ( `c:Membrane.Element.Base.handle_pad_added/3` ) . This
123+ callback is called only for dynamic pads.
124124
125125Another thing that's different are the pad references. The pad's name can't just
126126be used as the pad's reference, because it wouldn't be unique. Dynamic pads are
127127identified by [ ` Pad.ref/2 ` ] ( `Membrane.Pad.ref/2` ) , that takes the pad's
128128name and some unique reference as arguments. The result is a unique pad reference
129- that is also associated with a given pad's specification through it's name.
129+ that is also associated with a given pad's specification through it's name. When
130+ a new pad is linked, it's reference is made known to the element through the
131+ first argument of
132+ [ ` handle_pad_added/3 ` ] ( `c:Membrane.Element.Base.handle_pad_added/3` ) .
130133
131134#### MP4 Demuxer Example
132135
@@ -203,7 +206,7 @@ is unlinking them. If the parent removed a child that with
203206
204207``` elixir
205208@impl true
206- def some_callback (.. .) do
209+ def handle_something (.. ., _context , state ) do
207210 .. .
208211 {[remove_children: :some_child ], state}
209212end
@@ -213,7 +216,7 @@ Then the child with name `:some_child` would be stopped and removed from the
213216pipeline, unlinking all it's pads. If an input pad of this child happened to be
214217connected to our demuxer, then the
215218[ ` handle_pad_removed/3 ` ] ( `c:Membrane.Element.Base.handle_pad_removed/3` )
216- would be called with a reference to the pad that was unlinked:
219+ would be called in the demuxer with a reference to the pad that was unlinked:
217220
218221``` elixir
219222@impl true
@@ -262,7 +265,7 @@ send on and receive information from it's pads.
262265
263266### Removal
264267
265- Static pads are removed and unlinked once their component is terminated.
268+ Static pads are removed and unlinked only once their component is terminated.
266269
267270Dynamic pads can be removed during the lifespan of their component. For each removal
268271a [ ` handle_pad_removed/3 ` ] ( `c:Membrane.Element.Base.handle_pad_removed/3` )
0 commit comments