Current section

Files

Jump to
membrane_core templates bin.ex
Raw

templates/bin.ex

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