Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.2.4
* Add `:handle_end_of_stream` and `:handle_start_of_stream` options to debug elements. [#993](https://github.com/membraneframework/membrane_core/pull/993)

## 1.2.3
* Deprecate calling a children group `nil` in [#964](https://github.com/membraneframework/membrane_core/pull/964)
* Adds new fields for the handle_child_terminated context: crash_initiator, exit_reason and group_name in [#964](https://github.com/membraneframework/membrane_core/pull/964)
Expand Down
39 changes: 35 additions & 4 deletions lib/membrane/debug/filter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,18 @@ defmodule Membrane.Debug.Filter do
@spec noop(any()) :: :ok
def noop(_arg), do: :ok

def_options handle_buffer: [
@spec noop() :: :ok
def noop(), do: :ok

def_options handle_start_of_stream: [
spec: (-> any()),
default: &__MODULE__.noop/0,
description: """
Function with arity 0, that will be called when the start of stream is received on the input pad.
Result of this function is ignored.
"""
],
handle_buffer: [
spec: (Buffer.t() -> any()),
default: &__MODULE__.noop/1,
description: """
Expand All @@ -51,28 +62,48 @@ defmodule Membrane.Debug.Filter do
Function with arity 1, that will be called with all stream formats handled by this sink.
Result of this function is ignored.
"""
],
handle_end_of_stream: [
spec: (-> any()),
default: &__MODULE__.noop/0,
description: """
Function with arity 0, that will be called when the end of stream is received on the input pad.
Result of this function is ignored.
"""
]

@impl true
def handle_init(_ctx, opts) do
{[], Map.from_struct(opts)}
end

@impl true
def handle_start_of_stream(:input, _ctx, state) do
_ignored = state.handle_start_of_stream.()
{[], state}
end

@impl true
def handle_buffer(:input, buffer, _ctx, state) do
_ingored = state.handle_buffer.(buffer)
_ignored = state.handle_buffer.(buffer)
{[buffer: {:output, buffer}], state}
end

@impl true
def handle_event(_pad, event, _ctx, state) do
_ingored = state.handle_event.(event)
_ignored = state.handle_event.(event)
{[forward: event], state}
end

@impl true
def handle_stream_format(:input, stream_format, _ctx, state) do
_ingored = state.handle_stream_format.(stream_format)
_ignored = state.handle_stream_format.(stream_format)
{[stream_format: {:output, stream_format}], state}
end

@impl true
def handle_end_of_stream(:input, _ctx, state) do
_ignored = state.handle_end_of_stream.()
{[end_of_stream: :output], state}
end
end
33 changes: 32 additions & 1 deletion lib/membrane/debug/sink.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,18 @@ defmodule Membrane.Debug.Sink do
@spec noop(any()) :: :ok
def noop(_arg), do: :ok

def_options handle_buffer: [
@spec noop() :: :ok
def noop(), do: :ok

def_options handle_start_of_stream: [
spec: (-> any()),
default: &__MODULE__.noop/0,
description: """
Function with arity 0, that will be called when the start of stream is received on the input pad.
Result of this function is ignored.
"""
],
handle_buffer: [
spec: (Buffer.t() -> any()),
default: &__MODULE__.noop/1,
description: """
Expand All @@ -46,13 +57,27 @@ defmodule Membrane.Debug.Sink do
Function with arity 1, that will be called with all stream formats handled by this sink.
Result of this function is ignored.
"""
],
handle_end_of_stream: [
spec: (-> any()),
default: &__MODULE__.noop/0,
description: """
Function with arity 0, that will be called when the end of stream is received on the input pad.
Result of this function is ignored.
"""
]

@impl true
def handle_init(_ctx, opts) do
{[], Map.from_struct(opts)}
end

@impl true
def handle_start_of_stream(:input, _ctx, state) do
_ignored = state.handle_start_of_stream.()
{[], state}
end

@impl true
def handle_buffer(:input, buffer, _ctx, state) do
_ignored = state.handle_buffer.(buffer)
Expand All @@ -70,4 +95,10 @@ defmodule Membrane.Debug.Sink do
_ignored = state.handle_stream_format.(stream_format)
{[], state}
end

@impl true
def handle_end_of_stream(:input, _ctx, state) do
_ignored = state.handle_end_of_stream.()
{[], state}
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Membrane.Mixfile do
use Mix.Project

@version "1.2.3"
@version "1.2.4"
@source_ref "v#{@version}"

def project do
Expand Down
Loading