Skip to content

Commit

Permalink
Release v0.12.9
Browse files Browse the repository at this point in the history
  • Loading branch information
FelonEkonom committed Sep 14, 2023
1 parent c260827 commit 7d691fa
Show file tree
Hide file tree
Showing 51 changed files with 585 additions and 287 deletions.
46 changes: 36 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,53 @@
# Changelog

## 1.0.0
# 0.12.9
* Add `:pause_auto_demand` and `:resume_auto_demand` actions. [#586](https://github.com/membraneframework/membrane_core/pull/586)
* Fix process leak in starting clocks. [#594](https://github.com/membraneframework/membrane_core/pull/594)
* Add child exit reason to the supervisor exit reason. [#595](https://github.com/membraneframework/membrane_core/pull/595)

# 0.12.8
* Fix race condition in links deletion. [#591](https://github.com/membraneframework/membrane_core/pull/591)
* Improve error message, when stream format does not match the accepted format pattern. [#591](https://github.com/membraneframework/membrane_core/pull/591)
* Fix bug in default pipeline functions specs. [#585](https://github.com/membraneframework/membrane_core/pull/585)

# 0.12.7
* Fix bug in generating processes names. [#584](https://github.com/membraneframework/membrane_core/pull/584)
* Fix bug in registering metrics. [#582](https://github.com/membraneframework/membrane_core/pull/582)
* Improve error message on lack of `handle_child_pad_removed/4` callback implementation. [#581](https://github.com/membraneframework/membrane_core/pull/581)
* Improve actions docs. [#580](https://github.com/membraneframework/membrane_core/pull/580)

# 0.12.6
* Implement functionalities needed for integration with `membrane_kino_dashboard`. [#571](https://github.com/membraneframework/membrane_core/pull/571)

# 0.12.5
* Fix compilation error occurring with Elixir 1.15. [#573](https://github.com/membraneframework/membrane_core/pull/573)

# 0.12.4
* Fix compilation error occurring with Elixir 1.15. [#570](https://github.com/membraneframework/membrane_core/pull/570)

# 0.12.3
* Fix bug in fields naming in callback contexts. [#569](https://github.com/membraneframework/membrane_core/pull/569)
* Update exit reasons of Membrane Components and their supervisors. [#567](https://github.com/membraneframework/membrane_core/pull/567)

## 0.12.2
* Fix bug in order of handling actions returned from callbacks.

## 0.12.1
* Introduce `:remove_link` action in pipelines and bins.
* Add children groups - a mechanism that allows refering to multiple children with a single identifier.
* Rename `remove_child` action into `remove_children` and allow for removing a children group with a single action.
* Add an ability to spawn anonymous children.
* Replace `Membrane.Time.round_to_<unit_name>` with `Membrane.Time.as_<unit_name>/2` with second argument equal `:round`. Rename `Membrane.Time.round_to_timebase` to `Membrane.Time.divide_by_timebase/2`. [#494](https://github.com/membraneframework/membrane_core/pull/494)
* Remove `:playback` action. Introduce `:setup` action. [#496](https://github.com/membraneframework/membrane_core/pull/496)
* Add `Membrane.Testing.Pipeline.get_child_pid/2`. [#497](https://github.com/membraneframework/membrane_core/pull/497)
* Make callback contexts to be maps. [#504](https://github.com/membraneframework/membrane_core/pull/504)
* All Membrane Elements can be compatible till now on - pads working in `:pull` mode, handling different `demand_units`, can be now linked.
* Output pads working in `:pull` mode should have their `demand_unit` specified. If case it's not available, it's assumed that the pad handles demands in both `:bytes` and `:buffers` units.
* Rename callbacks `handle_process/4` and `handle_write/4` to `handle_buffer/4` in [#506](https://github.com/membraneframework/membrane_core/pull/506)
* The flow control of the pad is now set with a single `:flow_control` option instead of `:mode` and `:demand_mode` options.
* Remove _t suffix from types [#509](https://github.com/membraneframework/membrane_core/pull/509)
* Implement automatic demands in Membrane Sinks and Endpoints. [#512](https://github.com/membraneframework/membrane_core/pull/512)
* Add `handle_child_pad_removed/4` callback in Bins and Pipelines. [#513](https://github.com/membraneframework/membrane_core/pull/513)
* Introduce support for crash groups in Bins. [#521](https://github.com/membraneframework/membrane_core/pull/521)
* Remove `assert_pipeline_play/2` from `Membrane.Testing.Assertions`. [#528](https://github.com/membraneframework/membrane_core/pull/528)
* Make sure enumerable with all elements being `Membrane.Buffer.t()`, passed as `:output` parameter for `Membrane.Testing.Source` won't get rewrapped in `Membrane.Buffer.t()` struct.
* Implement `Membrane.Debug.Filter` and `Membrane.Debug.Sink`. [#552](https://github.com/membraneframework/membrane_core/pull/552)
* Add `:pause_auto_demand` and `:resume_auto_demand` actions. [#586](https://github.com/membraneframework/membrane_core/pull/586)
* Send `:end_of_stream`, even if it is not preceded by `:start_of_stream`. [#557](https://github.com/membraneframework/membrane_core/pull/577)
* Fix process leak in starting clocks. [#594](https://github.com/membraneframework/membrane_core/pull/594)
* Add child exit reason to the supervisor exit reason. [#595](https://github.com/membraneframework/membrane_core/pull/595)

Expand All @@ -35,9 +61,9 @@
* New `spec` action syntax - the structure of pipeline is now defined with the use of `Membrane.ChildrenSpec`
* Rename `:caps` to `:stream_format`.
* Use Elixir patterns as `:accepted_format` in pad definition.
* Delete `:ok` from tuples returned from callbacks.
* Remove `:type` from specs passed to `def_options/1` macro in bins and elements.
* Add `Membrane.Testing.MockResourceGuard`.
* Delete `:ok` from tuples returned from callbacks
* Remove `:type` from specs passed to `def_options/1` macro in bins and elements.
* Add `Membrane.Testing.MockResourceGuard`

## 0.10.0
* Remove all deprecated stuff [#399](https://github.com/membraneframework/membrane_core/pull/399)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This package provides core of the [Membrane Multimedia Framework](https://membra
Add the following line to your `deps` in `mix.exs`. Run `mix deps.get`.

```elixir
{:membrane_core, "~> 0.11.0"}
{:membrane_core, "~> 0.12.9"}
```

Or, if you'd like to try the latest release candidate, use this version:
Expand Down
4 changes: 2 additions & 2 deletions benchmark/run/branched_filter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ defmodule Benchmark.Run.BranchedFilter do

alias Benchmark.Run.Reductions

def_input_pad :input, accepted_format: _any, availability: :on_request
def_output_pad :output, accepted_format: _any, availability: :on_request
def_input_pad :input, accepted_format: _any, availability: :on_request, flow_control: :auto
def_output_pad :output, accepted_format: _any, availability: :on_request, flow_control: :auto

def_options number_of_reductions: [spec: integer()],
generator: [spec: (integer() -> integer())],
Expand Down
4 changes: 2 additions & 2 deletions benchmark/run/linear_filter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ defmodule Benchmark.Run.LinearFilter do

alias Benchmark.Run.Reductions

def_input_pad :input, accepted_format: _any
def_output_pad :output, accepted_format: _any
def_input_pad :input, accepted_format: _any, flow_control: :auto
def_output_pad :output, accepted_format: _any, flow_control: :auto

def_options number_of_reductions: [spec: integer()],
generator: [spec: (integer() -> integer())]
Expand Down
2 changes: 1 addition & 1 deletion guides/upgrading/v0.11.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Upgrading to v0.11

Improvements in v0.11 required some breaking changes, so here comes the guide that will help you adjust your code to the new API. See the [changelog](https://github.com/membraneframework/membrane_core/releases/tag/v0.11.0) for details.
Improvements in v0.11 required some breaking changes, so here comes the guide that will help you adjust your code to the new API. See the [release notes](https://github.com/membraneframework/membrane_core/releases/tag/v0.11.0) for details.

## Deps upgrade

Expand Down
65 changes: 65 additions & 0 deletions guides/upgrading/v0.12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Upgrading to v0.12

Between v0.11 and v0.12 some breaking changes have occurred, so here comes the guide that will help you adjust your code to the new API. See the [release notes](https://github.com/membraneframework/membrane_core/releases/tag/v0.12.1) for details.

## Deps upgrade

Upgrade `membrane_core` to `v0.12.1`.

```elixir
defp deps do
[
{:membrane_core, "~> 0.12.1"},
...
]
end
```

## Implement `handle_child_pad_removed/4` callback in bins and pipelines, if it is needed

Now, if bin removes its pad (e.g. by removing an element linked to the bin's inner pad), bin's parent has to have implemented proper `handle_child_pad_removed/4` callback, to handle it. If there is no such a callback, default behaviour is to raise an error.

```elixir
@impl true
def handle_child_pad_removed(:rtp, Pad.ref(:rtp_input, _ssrc), _ctx, state) do
# ...
end
```

## Remove `:playback` action

Now, membrane pipelines enter the playing playback by default and they don't have to return a `:playback` action to do it.

```diff
- @impl true
- def handle_setup(_ctx, state) do
- {[playback: :playing], state}
- end
```
Instead of it, there is a new action introduced in `membrane_core` v0.12, `setup: :incomplete | :complete`. If you want to defer a moment when a component enters the playing playback, you can return `{:setup, :incomplete}` action from `handle_setup` callback. If you do that, a component will enter the playing playback only when you return `{:setup, :complete}` action from another callback, e.g. `handle_info`.

```diff
- @impl true
- def handle_setup(_ctx, state) do
- Process.send_after(self(), :play, 1000)
- {[], state}
- end
-
- @impl true
- def handle_info(:play, _ctx, state) do
- {[playback: :playing], state}
- end

+ @impl true
+ def handle_setup(_ctx, state) do
+ Process.send_after(self(), :play, 1000)
+ {[setup: :incomplete], state}
+ end
+
+ @impl true
+ def handle_info(:play, _ctx, state) do
+ {[setup: :complete], state}
+ end
```

`:setup` action is available not only in pipelines but in bins and elements as well.
2 changes: 1 addition & 1 deletion guides/upgrading/v1.0.0-rc0.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Upgrading to v1.0.0-rc0

Between v0.11 and v1.0.0-rc0 some breaking changes have occurred, so here comes the guide that will help you adjust your code to the new API. See the [changelog](https://github.com/membraneframework/membrane_core/releases/tag/v1.0.0-rc0) for detailed description of the changes.
Between v0.11 and v1.0.0-rc0 some breaking changes have occurred, so here comes the guide that will help you adjust your code to the new API. See the [release notes](https://github.com/membraneframework/membrane_core/releases/tag/v1.0.0-rc0) for detailed description of the changes.

### Deps upgrade

Expand Down
6 changes: 3 additions & 3 deletions lib/membrane/bin.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ defmodule Membrane.Bin do
Callback that is called when new pad has been added to bin. Executed
ONLY for dynamic pads.
Context passed to this callback contains additional field `:pad_options`.
Context passed to this callback contains additional field `:options`.
By default, it does nothing.
"""
@callback handle_pad_added(
Expand All @@ -64,7 +64,7 @@ defmodule Membrane.Bin do
Callback that is called when some pad of the bin has been removed. Executed
ONLY for dynamic pads.
Context passed to this callback contains additional field `:pad_options`.
Context passed to this callback contains additional field `:options`.
By default, it does nothing.
"""
@callback handle_pad_removed(
Expand Down Expand Up @@ -98,7 +98,7 @@ defmodule Membrane.Bin do
Callback invoked when a child removes its pad.
The callback won't be invoked, when you have initiated the pad removal,
eg. when you have returned `t:Membrane.Bin.Action.remove_link()` action
e.g. when you have returned `t:Membrane.Bin.Action.remove_link()` action
which made one of your children's pads be removed.
By default, it does nothing.
"""
Expand Down
8 changes: 8 additions & 0 deletions lib/membrane/bin/action.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ defmodule Membrane.Bin.Action do
| Membrane.Child.group()
| [Membrane.Child.group()]}

@type remove_child ::
{:remove_child,
Child.name()
| [Child.name()]
| Membrane.Child.group()
| [Membrane.Child.group()]}

@typedoc """
Action that removes link, which relates to specified child and pad.
Expand Down Expand Up @@ -134,6 +141,7 @@ defmodule Membrane.Bin.Action do
| notify_parent
| spec
| remove_children
| remove_child
| remove_link
| start_timer
| timer_interval
Expand Down
10 changes: 3 additions & 7 deletions lib/membrane/bin/callback_context.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ defmodule Membrane.Bin.CallbackContext do
@typedoc """
Type describing context passed to the `Membrane.Bin` callbacks.
Field `:pad_options` is present only in `c:Membrane.Bin.handle_pad_added/3`
Field `:options` is present only in `c:Membrane.Bin.handle_pad_added/3`
and `c:Membrane.Bin.handle_pad_removed/3`.
Field `:start_of_stream_received?` is present only in
`c:Membrane.Bin.handle_element_end_of_stream/4`.
Fields `:members` and `:crash_initiator` are present only in
`c:Membrane.Pipeline.handle_crash_group_down/3`.
"""
Expand All @@ -24,9 +21,8 @@ defmodule Membrane.Bin.CallbackContext do
:playback => Membrane.Playback.t(),
:resource_guard => Membrane.ResourceGuard.t(),
:utility_supervisor => Membrane.UtilitySupervisor.t(),
optional(:pad_options) => map(),
optional(:options) => map(),
optional(:members) => [Membrane.Child.name()],
optional(:crash_initiator) => Membrane.Child.name(),
optional(:start_of_stream_received?) => boolean()
optional(:crash_initiator) => Membrane.Child.name()
}
end
18 changes: 9 additions & 9 deletions lib/membrane/clock.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ defmodule Membrane.Clock do
non_neg_integer
| ratio
| {numerator :: non_neg_integer, denominator :: pos_integer()}}

@typedoc """
Ratio message sent by the Clock to all its subscribers. It contains the ratio
of the custom clock time to the reference time.
Expand Down Expand Up @@ -119,7 +118,7 @@ defmodule Membrane.Clock do

state =
%{
ratio: Ratio.new(1),
ratio: 1,
subscribers: %{},
time_provider: options |> Keyword.get(:time_provider, fn -> Time.monotonic_time() end)
}
Expand All @@ -141,7 +140,7 @@ defmodule Membrane.Clock do
subscribe(proxy_for)
state
else
broadcast_and_update_ratio(Ratio.new(1), state)
broadcast_and_update_ratio(1, state)
end

{:noreply, state}
Expand Down Expand Up @@ -201,7 +200,7 @@ defmodule Membrane.Clock do
defp get_proxy_options(true, _proxy_for), do: %{proxy: true, proxy_for: nil}

defp get_proxy_options(_proxy, _proxy_for),
do: %{init_time: nil, clock_time: Ratio.new(0), till_next: nil, proxy: false}
do: %{init_time: nil, clock_time: 0, till_next: nil, proxy: false}

defp handle_unsubscribe(pid, state) do
Process.demonitor(state.subscribers[pid].monitor, [:flush])
Expand All @@ -214,13 +213,13 @@ defmodule Membrane.Clock do
end

defp handle_clock_update(till_next, state) do
till_next = Ratio.new(till_next)
use Ratio

if Ratio.lt?(till_next, 0) do
if till_next < 0 do
raise "Clock update time cannot be negative, received: #{inspect(till_next)}"
end

till_next = Ratio.mult(till_next, Ratio.new(Time.millisecond()))
till_next = till_next * Time.millisecond()

case state.init_time do
nil -> %{state | init_time: state.time_provider.(), till_next: till_next}
Expand All @@ -229,9 +228,10 @@ defmodule Membrane.Clock do
end

defp do_handle_clock_update(till_next, state) do
use Ratio
%{till_next: from_previous, clock_time: clock_time} = state
clock_time = Ratio.add(clock_time, from_previous)
ratio = Ratio.div(clock_time, Ratio.new(state.time_provider.() - state.init_time))
clock_time = clock_time + from_previous
ratio = clock_time / (state.time_provider.() - state.init_time)
state = %{state | clock_time: clock_time, till_next: till_next}
broadcast_and_update_ratio(ratio, state)
end
Expand Down
3 changes: 1 addition & 2 deletions lib/membrane/core/bin.ex
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,14 @@ defmodule Membrane.Core.Bin do
end

defp do_handle_info(
Message.new(:stream_management_event, [element_name, pad_ref, event, event_params]),
Message.new(:stream_management_event, [element_name, pad_ref, event]),
state
) do
state =
Parent.LifecycleController.handle_stream_management_event(
event,
element_name,
pad_ref,
event_params,
state
)

Expand Down
5 changes: 5 additions & 0 deletions lib/membrane/core/bin/action_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ defmodule Membrane.Core.Bin.ActionHandler do
Parent.ChildLifeController.handle_remove_children(children, state)
end

@impl CallbackHandler
def handle_action({:remove_child, children}, _cb, _params, state) do
Parent.ChildLifeController.handle_remove_children(children, state)
end

@impl CallbackHandler
def handle_action({:remove_link, {child_name, pad_ref}}, _cb, _params, state) do
Parent.ChildLifeController.handle_remove_link(child_name, pad_ref, state)
Expand Down
5 changes: 1 addition & 4 deletions lib/membrane/core/bin/callback_context.ex
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
defmodule Membrane.Core.Bin.CallbackContext do
@moduledoc false

@type optional_fields ::
[pad_options: map()]
| [members: [Membrane.Child.name()], crash_initiator: Membrane.Child.name()]
| [start_of_stream_received?: boolean()]
@type optional_fields :: [options: map()]

@spec from_state(Membrane.Core.Bin.State.t(), optional_fields()) ::
Membrane.Bin.CallbackContext.t()
Expand Down
2 changes: 1 addition & 1 deletion lib/membrane/core/bin/pad_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ defmodule Membrane.Core.Bin.PadController do
%{options: pad_opts, availability: availability} = PadModel.get_data!(state, ref)

if Pad.availability_mode(availability) == :dynamic do
context = &CallbackContext.from_state(&1, pad_options: pad_opts)
context = &CallbackContext.from_state(&1, options: pad_opts)

CallbackHandler.exec_and_handle_callback(
:handle_pad_added,
Expand Down
Loading

0 comments on commit 7d691fa

Please sign in to comment.