-
Notifications
You must be signed in to change notification settings - Fork 0
/
master.ex
40 lines (32 loc) · 1.07 KB
/
master.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
defmodule Membrane.Element.Tee.Master do
use Membrane.Filter
@moduledoc """
Element for forwarding buffers to at least one output pad
It has one input pad `:input` and 2 output pads:
* `:master` - is a static pad which is always available and works in pull mode
* `:copy` - is a dynamic pad that can be linked to any number of elements (including 0) and works in push mode
The `:master` pad dictates the speed of processing data and any element (or elements) connected to `:copy` pad
will receive the same data as `:master`
"""
def_input_pad :input,
availability: :always,
mode: :pull,
demand_unit: :buffers,
caps: :any
def_output_pad :master,
availability: :always,
mode: :pull,
caps: :any
def_output_pad :copy,
availability: :on_request,
mode: :push,
caps: :any
@impl true
def handle_process(:input, %Membrane.Buffer{} = buffer, _ctx, state) do
{{:ok, forward: buffer}, state}
end
@impl true
def handle_demand(:master, size, :buffers, _ctx, state) do
{{:ok, demand: {:input, size}}, state}
end
end