-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathbin.ex
More file actions
154 lines (129 loc) · 4.67 KB
/
Copy pathbin.ex
File metadata and controls
154 lines (129 loc) · 4.67 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
defmodule Membrane.TemplateBin do
@moduledoc """
This is a generated template for a Membrane.Bin. Uncomment the snippets as necessary.
"""
use Membrane.Bin
require Membrane.Logger
# def_input_pad :input,
# accepted_format: _any
# availability: :on_request | :always, # default - :always
# max_instances: pos_integer() | :infinity, # relevant only for pads with `availability: :on_request`, default - :infinity
# options: [
# Same structure as in def_options/1
# ]
# def_output_pad :output,
# accepted_format: _any
# availability: :on_request | :always, # default - :always
# max_instances: pos_integer() | :infinity, # relevant only for pads with `availability: :on_request`, default - :infinity
# options: [
# Same structure as in def_options/1
# ]
# This macro also defines a struct of this module, which is then used for providing options
# when instantiating this component.
# def_options some_option: [
# spec: typespec of the option.
# default: default value - if not set, providing this option will be mandatory.
# inspector: function converting fields' value to a string for documentation purposes. If not set, &inspect/1 will be used.
# description: """
# Desription of the option.
# """
# ]
defmodule State do
# Using this struct is not strictly necessary, but it's considered a good practice
# and is strongly encouraged. Having a state with static fields with defined
# typespecs adds robustness to the codebase and can prevent many bugs.
@moduledoc false
# When you add new fields to the struct remember to add them to this spec too.
@type t :: %__MODULE__{}
defstruct []
end
# -----------------
# --- CALLBACKS ---
# -----------------
# These callbacks have been ordered as they are usually being executed in the lifecycle
# of a typical Membrane component - see https://hexdocs.pm/membrane_core/components_lifecycle.html.
# Most of them are optional and have default implementations, which are present here as commented out code.
# Any exceptions to this rule are mentioned above the relevant callbacks.
# By default this callback will return with state set to an empty map %{},
# however we recommend using a dedicated State struct.
@impl true
def handle_init(_ctx, _opts) do
{[], %State{}}
end
# This callback will be executed only for pads with `availability: :on_request`.
# @impl true
# def handle_pad_added(_pad, _context, state) do
# {[], state}
# end
# This callback will be executed only for pads with `availability: :on_request`.
# @impl true
# def handle_pad_removed(_pad, _context, state) do
# {[], state}
# end
# @impl true
# def handle_setup(_context, state) do
# {[], state}
# end
# @impl true
# def handle_playing(_context, state) do
# {[], state}
# end
# @impl true
# def handle_info(message, _context, state) do
# Membrane.Logger.warning("""
# Received message but no handle_info callback has been specified. Ignoring.
# Message: #{inspect(message)}\
# """)
#
# {[], state}
# end
# @impl true
# def handle_child_setup_completed(_child, _ctx, state) do
# {[], state}
# end
# @impl true
# def handle_child_playing(_child, _ctx, state) do
# {[], state}
# end
# @impl true
# def handle_element_start_of_stream(_element, _pad, _ctx, state) do
# {[], state}
# end
# @impl true
# def handle_element_end_of_stream(_element, _pad, _ctx, state) do
# {[], state}
# end
# @impl true
# def handle_child_notification(_notification, _element, _ctx, state) do
# {[], state}
# end
# @impl true
# def handle_parent_notification(_notification, _ctx, state) do
# {[], state}
# end
# @impl true
# def handle_crash_group_down(_group_name, _ctx, state) do
# {[], state}
# end
# @impl true
# def handle_terminate_request(_ctx, state) do
# {[terminate: :normal], state}
# end
# @impl true
# def handle_child_terminated(_child, _ctx, state) do
# {[], state}
# end
# This callback doesn't have a default implementation, but will be called only
# if a `:start_timer` action has been executed. For more information and examples
# of timer usage see https://hexdocs.pm/membrane_core/timer.html.
# @impl true
# def handle_tick(timer_id, context, state) do
# ...
# end
# This callback doesn't have a default implementation and will be called only if
# a child removes it's own dynamic pad. If not implemented, the bin will crash.
# @impl true
# handle_child_pad_removed(element, pad, ctx, state) do
# ...
# end
end