Skip to content

Commit 64ee4df

Browse files
committed
Add missing callbacks and uncomment pad specs
1 parent d5cea39 commit 64ee4df

7 files changed

Lines changed: 44 additions & 25 deletions

File tree

lib/mix/tasks/membrane.gen.component.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@moduledoc """
88
Generates a template for a Membrane #{component_name} with the provided module name.
99
10-
$ mix membrane.gen.#{String.downcase(component_name)} module_name [-l target_location]
10+
$ mix membrane.gen.#{String.downcase(component_name)} module_name [-l target_location]
1111
1212
## Options
1313
* `-l, --location` - If a target location is provided, the #{component_name} will be created there, relative to the `lib` directory.

templates/bin.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ defmodule Membrane.TemplateBin do
4848
# Note: by default this callback will return with state set to an empty map %{},
4949
# however we recommend using a dedicated State struct.
5050
@impl true
51-
def handle_init(_ctx, opts) do
51+
def handle_init(_ctx, _opts) do
5252
{[], %State{}}
5353
end
5454

templates/endpoint.ex

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ defmodule Membrane.TemplateEndpoint do
44
"""
55
use Membrane.Endpoint
66

7-
# def_input_pad :input,
8-
# accepted_format: _any,
7+
def_input_pad :input,
8+
accepted_format: _any,
9+
flow_control: :auto # | :manual | :push,
910
# availability: :on_request | :always,
1011
# max_instances: positive integer,
11-
# flow_control: :manual | :auto | :push,
1212
# demand_unit: :buffers | :bytes,
1313
# options: [
1414
# Same structure as in def_options/1
1515
# ]
1616

17-
# def_output_pad :output,
18-
# accepted_format: _any,
17+
def_output_pad :output,
18+
accepted_format: _any,
19+
flow_control: :auto # | :manual | :push,
1920
# availability: :on_request | :always,
2021
# max_instances: positive integer,
21-
# flow_control: :manual | :auto | :push,
2222
# demand_unit: :buffers | :bytes,
2323
# options: [
2424
# Same structure as in def_options/1
@@ -56,14 +56,19 @@ defmodule Membrane.TemplateEndpoint do
5656
# ...
5757
# end
5858

59+
@impl true
60+
def handle_buffer(_pad, buffer, _ctx, state) do
61+
{[forward: buffer], state}
62+
end
63+
5964
# ----------------------------------------------
6065
# --- CALLBACKS WITH DEFAULT IMPLEMENTATIONS ---
6166
# ----------------------------------------------
6267

6368
# Note: by default this callback will return with state set to an empty map %{},
6469
# however we recommend using a dedicated State struct.
6570
@impl true
66-
def handle_init(_ctx, opts) do
71+
def handle_init(_ctx, _opts) do
6772
{[], %State{}}
6873
end
6974

templates/filter.ex

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ defmodule Membrane.TemplateFilter do
44
"""
55
use Membrane.Filter
66

7-
# def_input_pad :input,
8-
# accepted_format: _any,
7+
def_input_pad :input,
8+
accepted_format: _any,
9+
flow_control: :auto # | :manual | :push,
910
# availability: :on_request | :always,
1011
# max_instances: positive integer,
11-
# flow_control: :manual | :auto | :push,
1212
# demand_unit: :buffers | :bytes,
1313
# options: [
1414
# Same structure as in def_options/1
1515
# ]
1616

17-
# def_output_pad :output,
18-
# accepted_format: _any,
17+
def_output_pad :output,
18+
accepted_format: _any,
19+
flow_control: :auto # | :manual | :push,
1920
# availability: :on_request | :always,
2021
# max_instances: positive integer,
21-
# flow_control: :manual | :auto | :push,
2222
# demand_unit: :buffers | :bytes,
2323
# options: [
2424
# Same structure as in def_options/1
@@ -56,14 +56,19 @@ defmodule Membrane.TemplateFilter do
5656
# ...
5757
# end
5858

59+
@impl true
60+
def handle_buffer(_pad, buffer, _ctx, state) do
61+
{[forward: buffer], state}
62+
end
63+
5964
# ----------------------------------------------
6065
# --- CALLBACKS WITH DEFAULT IMPLEMENTATIONS ---
6166
# ----------------------------------------------
6267

6368
# Note: by default this callback will return with state set to an empty map %{},
6469
# however we recommend using a dedicated State struct.
6570
@impl true
66-
def handle_init(_ctx, opts) do
71+
def handle_init(_ctx, _opts) do
6772
{[], %State{}}
6873
end
6974

templates/pipeline.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule Membrane.TemplatePipeline do
2323
# Note: by default this callback will return with state set to an empty map %{},
2424
# however we recommend using a dedicated State struct.
2525
@impl true
26-
def handle_init(_ctx, opts) do
26+
def handle_init(_ctx, _opts) do
2727
{[], %State{}}
2828
end
2929

templates/sink.ex

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ defmodule Membrane.TemplateSink do
44
"""
55
use Membrane.Sink
66

7-
# def_input_pad :input,
8-
# accepted_format: _any,
7+
def_input_pad :input,
8+
accepted_format: _any,
9+
flow_control: :auto # | :manual | :push,
910
# availability: :on_request | :always,
1011
# max_instances: positive integer,
11-
# flow_control: :manual | :auto | :push,
1212
# demand_unit: :buffers | :bytes,
1313
# options: [
1414
# Same structure as in def_options/1
@@ -34,6 +34,15 @@ defmodule Membrane.TemplateSink do
3434

3535
defstruct []
3636
end
37+
38+
# -----------------
39+
# --- CALLBACKS ---
40+
# -----------------
41+
42+
@impl true
43+
def handle_buffer(_pad, buffer, _ctx, state) do
44+
{[forward: buffer], state}
45+
end
3746

3847
# ----------------------------------------------
3948
# --- CALLBACKS WITH DEFAULT IMPLEMENTATIONS ---
@@ -42,7 +51,7 @@ defmodule Membrane.TemplateSink do
4251
# Note: by default this callback will return with state set to an empty map %{},
4352
# however we recommend using a dedicated State struct.
4453
@impl true
45-
def handle_init(_ctx, opts) do
54+
def handle_init(_ctx, _opts) do
4655
{[], %State{}}
4756
end
4857

templates/source.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ defmodule Membrane.TemplateSource do
44
"""
55
use Membrane.Source
66

7-
# def_output_pad :output,
8-
# accepted_format: _any,
7+
def_output_pad :output,
8+
accepted_format: _any,
9+
flow_control: :auto # | :manual | :push,
910
# availability: :on_request | :always,
1011
# max_instances: positive integer,
11-
# flow_control: :manual | :auto | :push,
1212
# demand_unit: :buffers | :bytes,
1313
# options: [
1414
# Same structure as in def_options/1
@@ -53,7 +53,7 @@ defmodule Membrane.TemplateSource do
5353
# Note: by default this callback will return with state set to an empty map %{},
5454
# however we recommend using a dedicated State struct.
5555
@impl true
56-
def handle_init(_ctx, opts) do
56+
def handle_init(_ctx, _opts) do
5757
{[], %State{}}
5858
end
5959

0 commit comments

Comments
 (0)