|
| 1 | +defmodule Membrane.TemplateEndpoint do |
| 2 | + @moduledoc """ |
| 3 | + This is a generated template for an Endpoint. Uncomment the snippets as necessary. |
| 4 | + """ |
| 5 | + use Membrane.Endpoint |
| 6 | + |
| 7 | + # def_input_pad :input, |
| 8 | + # accepted_format: _any, |
| 9 | + # availability: :on_request | :always, |
| 10 | + # max_instances: positive integer, |
| 11 | + # flow_control: :manual | :auto | :push, |
| 12 | + # demand_unit: :buffers | :bytes, |
| 13 | + # options: [ |
| 14 | + # Same structure as in def_options/1 |
| 15 | + # ] |
| 16 | + |
| 17 | + # def_output_pad :output, |
| 18 | + # accepted_format: _any, |
| 19 | + # availability: :on_request | :always, |
| 20 | + # max_instances: positive integer, |
| 21 | + # flow_control: :manual | :auto | :push, |
| 22 | + # demand_unit: :buffers | :bytes, |
| 23 | + # options: [ |
| 24 | + # Same structure as in def_options/1 |
| 25 | + # ] |
| 26 | + |
| 27 | + # def_options some_option: [ |
| 28 | + # spec: typespec of the option, |
| 29 | + # default: default value, |
| 30 | + # inspector: function converting fields' value to a string for documentation purposes (optional), |
| 31 | + # description: """ |
| 32 | + # Desription of the option. |
| 33 | + # """ |
| 34 | + # ] |
| 35 | + |
| 36 | + defmodule State do |
| 37 | + # Using this struct is not strictly necessary, but it's considered a good practice |
| 38 | + # and is strongly encouraged. Having a state with static fields with defined |
| 39 | + # typespecs adds robustness to the codebase and can prevent many bugs. |
| 40 | + @moduledoc false |
| 41 | + |
| 42 | + # When you add new fields to the struct remember to add them to this spec too. |
| 43 | + @type t :: %__MODULE__{} |
| 44 | + |
| 45 | + defstruct [] |
| 46 | + end |
| 47 | + |
| 48 | + # ----------------- |
| 49 | + # --- CALLBACKS --- |
| 50 | + # ----------------- |
| 51 | + |
| 52 | + # Important: this callback only needs to be implemented when any output pads operate |
| 53 | + # in `:manual` flow control. |
| 54 | + # @impl true |
| 55 | + # def handle_demand(pad, size, unit, context, state) do |
| 56 | + # ... |
| 57 | + # end |
| 58 | + |
| 59 | + # ---------------------------------------------- |
| 60 | + # --- CALLBACKS WITH DEFAULT IMPLEMENTATIONS --- |
| 61 | + # ---------------------------------------------- |
| 62 | + |
| 63 | + # Note: by default this callback will return with state set to an empty map %{}, |
| 64 | + # however we recommend using a dedicated State struct. |
| 65 | + @impl true |
| 66 | + def handle_init(_ctx, opts) do |
| 67 | + {[], %State{}} |
| 68 | + end |
| 69 | + |
| 70 | + # @impl true |
| 71 | + # def handle_setup(_context, state) do |
| 72 | + # {[], state} |
| 73 | + # end |
| 74 | + |
| 75 | + # @impl true |
| 76 | + # def handle_playing(_context, state) do |
| 77 | + # {[], state} |
| 78 | + # end |
| 79 | + |
| 80 | + # @impl true |
| 81 | + # def handle_info(message, _context, state) do |
| 82 | + # Membrane.Logger.warning(""" |
| 83 | + # Received message but no handle_info callback has been specified. Ignoring. |
| 84 | + # Message: #{inspect(message)}\ |
| 85 | + # """) |
| 86 | + # |
| 87 | + # {[], state} |
| 88 | + # end |
| 89 | + |
| 90 | + # @impl true |
| 91 | + # def handle_pad_added(_pad, _context, state) do |
| 92 | + # {[], state} |
| 93 | + # end |
| 94 | + |
| 95 | + # @impl true |
| 96 | + # def handle_pad_removed(_pad, _context, state) do |
| 97 | + # {[], state} |
| 98 | + # end |
| 99 | + |
| 100 | + # @impl true |
| 101 | + # def handle_stream_format(_pad, _stream_format, _context, state) do |
| 102 | + # {[], state} |
| 103 | + # end |
| 104 | + |
| 105 | + # @impl true |
| 106 | + # def handle_start_of_stream(_pad, _context, state) do |
| 107 | + # {[], state} |
| 108 | + # end |
| 109 | + |
| 110 | + # @impl true |
| 111 | + # def handle_event(_pad, _event, _context, state) do |
| 112 | + # {[], state} |
| 113 | + # end |
| 114 | + |
| 115 | + # @impl true |
| 116 | + # def handle_parent_notification(_notification, _ctx, state) do |
| 117 | + # {[], state} |
| 118 | + # end |
| 119 | + |
| 120 | + # @impl true |
| 121 | + # def handle_end_of_stream(_pad, _context, state) do |
| 122 | + # {[], state} |
| 123 | + # end |
| 124 | + |
| 125 | + # @impl true |
| 126 | + # def handle_terminate_request(_ctx, state) do |
| 127 | + # {[terminate: :normal], state} |
| 128 | + # end |
| 129 | + |
| 130 | + # -------------------------- |
| 131 | + # --- OPTIONAL CALLBACKS --- |
| 132 | + # -------------------------- |
| 133 | + |
| 134 | + # @impl true |
| 135 | + # def handle_tick(timer_id, context, state) do |
| 136 | + # ... |
| 137 | + # end |
| 138 | +end |
0 commit comments