|
| 1 | +# Upgrading to v0.12 |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +## Deps upgrade |
| 6 | + |
| 7 | +Upgrade `membrane_core` to `v0.12.1`. |
| 8 | + |
| 9 | +```elixir |
| 10 | +defp deps do |
| 11 | + [ |
| 12 | + {:membrane_core, "~> 0.12.1"}, |
| 13 | + ... |
| 14 | + ] |
| 15 | +end |
| 16 | +``` |
| 17 | + |
| 18 | +## Implement `handle_child_pad_removed/4` callback in bins and pipelines, if it is needed |
| 19 | + |
| 20 | +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. |
| 21 | + |
| 22 | +```elixir |
| 23 | +@impl true |
| 24 | +def handle_child_pad_removed(:rtp, Pad.ref(:rtp_input, _ssrc), _ctx, state) do |
| 25 | + # ... |
| 26 | +end |
| 27 | +``` |
| 28 | + |
| 29 | +## Remove `:playback` action |
| 30 | + |
| 31 | +Now, membrane pipelines enter the playing playback by default and they don't have to return a `:playback` action to do it. |
| 32 | + |
| 33 | +```diff |
| 34 | +- @impl true |
| 35 | +- def handle_setup(_ctx, state) do |
| 36 | +- {[playback: :playing], state} |
| 37 | +- end |
| 38 | +``` |
| 39 | +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`. |
| 40 | + |
| 41 | +```diff |
| 42 | +- @impl true |
| 43 | +- def handle_setup(_ctx, state) do |
| 44 | +- Process.send_after(self(), :play, 1000) |
| 45 | +- {[], state} |
| 46 | +- end |
| 47 | +- |
| 48 | +- @impl true |
| 49 | +- def handle_info(:play, _ctx, state) do |
| 50 | +- {[playback: :playing], state} |
| 51 | +- end |
| 52 | + |
| 53 | ++ @impl true |
| 54 | ++ def handle_setup(_ctx, state) do |
| 55 | ++ Process.send_after(self(), :play, 1000) |
| 56 | ++ {[setup: :incomplete], state} |
| 57 | ++ end |
| 58 | ++ |
| 59 | ++ @impl true |
| 60 | ++ def handle_info(:play, _ctx, state) do |
| 61 | ++ {[setup: :complete], state} |
| 62 | ++ end |
| 63 | +``` |
| 64 | + |
| 65 | +`:setup` action is available not only in pipelines but in bins and elements as well. |
0 commit comments