From f78e88333ad12a309700072bb75159bffa3774d6 Mon Sep 17 00:00:00 2001 From: DominikWolek Date: Wed, 23 Nov 2022 12:34:21 +0100 Subject: [PATCH] Update README usage example to core 0.11 (#37) --- README.md | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 2ea3881..ff8e08c 100644 --- a/README.md +++ b/README.md @@ -27,29 +27,26 @@ it to 44.1 kHz rate. defmodule Resampling.Pipeline do use Membrane.Pipeline - alias Membrane.Element.File alias Membrane.FFmpeg.SWResample.Converter - alias Membrane.RawAudio + alias Membrane.{File, RawAudio} - @doc false @impl true - def handle_init(_) do - children = [ - file_src: %File.Source{location: "/tmp/input.raw"}, - converter: %Converter{ - input_caps: %RawAudio{channels: 2, sample_format: :s24le, sample_rate: 48_000}, - output_caps: %RawAudio{channels: 2, sample_format: :f32le, sample_rate: 44_100} - }, - file_sink: %File.Sink{location: "/tmp/output.raw"}, + def handle_init(_ctx, _opts) do + structure = [ + child(:file_src, %File.Source{location: "/tmp/input.raw"}) + |> child(:converter, %Converter{ + input_stream_format: %RawAudio{channels: 2, sample_format: :s24le, sample_rate: 48_000}, + output_stream_format: %RawAudio{channels: 2, sample_format: :f32le, sample_rate: 44_100} + }) + |> child(:file_sink, %File.Sink{location: "/tmp/output.raw"}) ] - links = [ - link(:file_src) - |> to(:converter) - |> to(:file_sink) - ] + {[spec: structure, playback: :playing], nil} + end - {{:ok, spec: %ParentSpec{children: children, links: links}}, %{}} + @impl true + def handle_element_end_of_stream(:file_sink, _pad, _ctx_, _state) do + {[playback: :stopped], nil} end end ```