You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: basic_pipeline/03_Source.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ Let's start with specifying that our module will implement the `Membrane.Source`
20
20
21
21
**_`lib/elements/Source.ex`_**
22
22
23
-
```Elixir
23
+
```elixir
24
24
defmoduleBasic.Elements.Sourcedo
25
25
useMembrane.Source
26
26
aliasMembrane.Buffer
@@ -35,7 +35,7 @@ Later on, we will make use of [macros](https://elixir-lang.org/getting-started/m
35
35
36
36
**_`lib/elements/Source.ex`_**
37
37
38
-
```Elixir
38
+
```elixir
39
39
defmoduleBasic.Elements.Sourcedo
40
40
...
41
41
def_options location: [type::string, description:"Path to the file"]
@@ -47,7 +47,7 @@ end
47
47
The first macro, `def_options` allows us to define the parameters which are expected to be passed while instantiating the element. The parameters will be passed as an automatically generated structure `%Basic.Elements.Source{}`. In our case, we will have a `:location` field inside of that structure. This parameter is about to be a path to the files which will contain input [packets](../glossary/glossary.md#packet).
48
48
Later on, while instantiating the Source element, we will be able to write:
49
49
50
-
```Elixir
50
+
```elixir
51
51
%Basic.Elements.Source{location:"input.A.txt"}
52
52
```
53
53
@@ -63,7 +63,7 @@ Let's define our first callback! Why not start with [`handle_init/1`](https://he
63
63
64
64
**_`lib/elements/Source.ex`_**
65
65
66
-
```Elixir
66
+
```elixir
67
67
defmoduleBasic.Elements.Sourcedo
68
68
...
69
69
@impltrue
@@ -94,7 +94,7 @@ The callbacks we are about to implement will be called once the transition betwe
94
94
95
95
**_`lib/elements/Source.ex`_**
96
96
97
-
```Elixir
97
+
```elixir
98
98
defmoduleBasic.Elements.Sourcedo
99
99
...
100
100
@impltrue
@@ -126,7 +126,7 @@ Once the succeeding element requests for the data, the `handle_demand/4` callbac
@@ -42,7 +42,7 @@ Module name defines the type of the caps, however it is possible to pass some ot
42
42
43
43
2. We specify the pad of the element with the format we have just defined, using the `:caps` option. For the purpose of an example, let it be the `:input` pad:
44
44
45
-
```Elixir
45
+
```elixir
46
46
def_input_pad(:input,
47
47
demand_unit::buffers,
48
48
caps: [
@@ -81,7 +81,7 @@ Imagine a pipeline, which starts with the source producing a video, which is the
81
81
For the source element, we should have the `:output` pads caps which would allow us to send video in the higher and in the lower quality. The same caps should be specified on the input of the filter element. However, the caps on the output of the filter should accept only video in the lower quality.
82
82
Here is the definition of the source element:
83
83
84
-
```Elixir
84
+
```elixir
85
85
# Source element
86
86
87
87
defmoduleSourcedo
@@ -105,7 +105,7 @@ In fact, they will. The format matches (both in the caps being sent and in the c
105
105
It means that the caps can be sent through the `:output` pad.
106
106
Below there is the draft of the filter implementation:
Copy file name to clipboardExpand all lines: basic_pipeline/07_Redemands.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ In the [source elements](../glossary/glossary.md#source), there is a "side-chann
14
14
The whole logic of fetching the data can be put inside the `handle_demand/5` callback - once we are asked to provide the [buffers](../glossary/glossary.md#buffer), the `handle_demand/5` callback gets called and we can provide the desired number of buffers from the "side-channel", inside the body of that callback. No processing occurs here - we get asked for the buffer and we provide the buffer, simple as that.
15
15
The redemand mechanism here lets you focus on providing a single buffer in the `handle_demand/5` body - later on, you can simply return the `:redemand` action and that action will invoke the `handle_demand/5` once again, with the updated number of buffers which are expected to be provided. Let's see it in an example - we could have such a `handle_demand/5` definition (and it wouldn't be a mistake!):
16
16
17
-
```Elixir
17
+
```elixir
18
18
@impltrue
19
19
defhandle_demand(:output, size, _unit, _context, state) do
20
20
actions =for x <-1..size do
@@ -30,7 +30,7 @@ You would need to take under the consideration all these situations and your cod
30
30
31
31
Wouldn't it be better to focus on a single buffer in each `handle_demand/5` call - and let the Membrane Framework automatically update the demand's size? This can be done in the following way:
32
32
33
-
```Elixir
33
+
```elixir
34
34
@impltrue
35
35
defhandle_demand(:output, _size, unit, context, state) do
36
36
payload =Input.get_next() #Input.get_next() is an exemplary function which could be providing data
0 commit comments