Skip to content

Commit

Permalink
Updated core to 0.11.0. (#17)
Browse files Browse the repository at this point in the history
* Updated core to 0.11.0.
  • Loading branch information
roznawsk authored Nov 22, 2022
1 parent d22548d commit cf70db9
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The package can be installed by adding `membrane_rtp_mpegaudio_plugin` to your l
```elixir
def deps do
[
{:membrane_rtp_mpegaudio_plugin, "~> 0.11.0"}
{:membrane_rtp_mpegaudio_plugin, "~> 0.12.0"}
]
end
```
Expand Down
18 changes: 9 additions & 9 deletions lib/membrane_element_mpeg_audio/depayloader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@ defmodule Membrane.RTP.MPEGAudio.Depayloader do
alias Membrane.{Buffer, RemoteStream, RTP}
alias Membrane.Caps.Audio.MPEG

def_input_pad :input, caps: RTP, demand_mode: :auto
def_input_pad :input, accepted_format: RTP, demand_mode: :auto

def_output_pad :output,
caps: {RemoteStream, content_format: MPEG, type: :packetized},
accepted_format: %RemoteStream{content_format: MPEG, type: :packetized},
demand_mode: :auto

@impl true
def handle_init(_opts) do
{:ok, %{}}
def handle_init(_ctx, _opts) do
{[], %{}}
end

@impl true
def handle_caps(:input, _caps, _context, state) do
caps = %RemoteStream{content_format: MPEG, type: :packetized}
{{:ok, caps: {:output, caps}}, state}
def handle_stream_format(:input, _stream_format, _ctx, state) do
stream_format = %RemoteStream{content_format: MPEG, type: :packetized}
{[stream_format: {:output, stream_format}], state}
end

@impl true
def handle_process(:input, buffer, _ctx, state) do
with %Buffer{
payload: <<0::16, _offset::16, depayloaded::binary>>
} <- buffer do
{{:ok, buffer: {:output, %Buffer{buffer | payload: depayloaded}}}, state}
{[buffer: {:output, %Buffer{buffer | payload: depayloaded}}], state}
else
%Buffer{} -> {{:error, :invalid_payload}, state}
%Buffer{} -> raise "Error: invalid payload: #{inspect(buffer.payload)}"
end
end
end
10 changes: 5 additions & 5 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
defmodule Membrane.RTP.MPEGAudio.MixProject do
use Mix.Project

@version "0.11.0"
@version "0.12.0"
@github_url "https://github.com/membraneframework/membrane_rtp_mpegaudio_plugin"

def project do
[
app: :membrane_rtp_mpegaudio_plugin,
version: @version,
elixir: "~> 1.12",
elixir: "~> 1.13",
elixirc_paths: elixirc_paths(Mix.env()),
deps: deps(),
dialyzer: dialyzer(),
Expand Down Expand Up @@ -70,9 +70,9 @@ defmodule Membrane.RTP.MPEGAudio.MixProject do

defp deps do
[
{:membrane_core, "~> 0.10.0"},
{:membrane_rtp_format, "~> 0.5.0"},
{:membrane_caps_audio_mpeg, "~> 0.2.0"},
{:membrane_core, "~> 0.11.0"},
{:membrane_rtp_format, "~> 0.6.0"},
{:membrane_mpegaudio_format, "~> 0.3.0"},

# dev
{:ex_doc, "~> 0.21", only: :dev, runtime: false},
Expand Down
8 changes: 4 additions & 4 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%{
"bunch": {:hex, :bunch, "1.3.1", "f8fe80042f9eb474ef2801ae2c9372f9b13d11e7053265dcfc24b9d912e3750b", [:mix], [], "hexpm", "00e21b16ff9bb698b728a01a2fc4b3bf7fc0e87c4bb9c6e4a442324aa8c5e567"},
"bunch": {:hex, :bunch, "1.5.0", "78530e85bc3f53e1711dba654565692e2015cb6d1685e9b53bf7606b14a36c71", [:mix], [], "hexpm", "2c32f8da5d4c9e7a534c8c25aea150da696dd8624ce64f97c21ee193c12258e5"},
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
"coerce": {:hex, :coerce, "1.0.1", "211c27386315dc2894ac11bc1f413a0e38505d808153367bd5c6e75a4003d096", [:mix], [], "hexpm", "b44a691700f7a1a15b4b7e2ff1fa30bebd669929ac8aa43cffe9e2f8bf051cf1"},
"credo": {:hex, :credo, "1.6.6", "f51f8d45db1af3b2e2f7bee3e6d3c871737bda4a91bff00c5eec276517d1a19c", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "625520ce0984ee0f9f1f198165cd46fa73c1e59a17ebc520038b8fce056a5bdc"},
Expand All @@ -12,9 +12,9 @@
"makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
"makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"membrane_caps_audio_mpeg": {:hex, :membrane_caps_audio_mpeg, "0.2.0", "9cf9a63f03e25b31cf31445325aa68e60a07d36ee1e759caa1422fa45df49367", [:mix], [], "hexpm", "f7a80e4841d46164c148be880932ac7425329f4bcc32eb36ad2e47eafe5f23e4"},
"membrane_core": {:hex, :membrane_core, "0.10.2", "d2d17039f6df746e4a3c47da32f51867fbafe528272cdd9b226d16b1032bc337", [:mix], [{:bunch, "~> 1.3", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.3", [hex: :qex, repo: "hexpm", optional: false]}, {:ratio, "~> 2.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6a4f290f919ada66c772807d64d5830be2962b7c13a2f2bc9ace416a1cd19ee1"},
"membrane_rtp_format": {:hex, :membrane_rtp_format, "0.5.0", "1b6930453be836bcc48ff71daeea76ac969cb726c0afda7203ddbbd76ca2db37", [:mix], [{:membrane_core, "~> 0.10.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "cd4d5c0389b154523d42781e492617e5d02a11af0f11163008f434a9f6179d5a"},
"membrane_core": {:hex, :membrane_core, "0.11.0", "63ae9f56834ec67680d634d8d69f71b2d46b94f4a0ec8fafcf22d8ce216b8f41", [:mix], [{:bunch, "~> 1.5", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.3", [hex: :qex, repo: "hexpm", optional: false]}, {:ratio, "~> 2.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "097584018fe948fa3013bfd6bcf002b3ad7cbd13f2259be4f1903f37a7aad7ab"},
"membrane_mpegaudio_format": {:hex, :membrane_mpegaudio_format, "0.3.0", "d4fee77fad9f953171c52acd6d53b6646cfc7fbb827c63caa7c6a1efeb86450a", [:mix], [], "hexpm", "dec903efd0086133402b44515d04301790832b4f39995747b0e712c8f966d50d"},
"membrane_rtp_format": {:hex, :membrane_rtp_format, "0.6.0", "666a77a19157899a523d7aa2e5bf69523b92798850f132fee1fc3ced821ca277", [:mix], [{:membrane_core, "~> 0.11.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "5ca136b9b5fa32992bfa8541dfb1bf00f2f012ac41ab1a63969a9f2b4f559cd0"},
"nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"},
"numbers": {:hex, :numbers, "5.2.4", "f123d5bb7f6acc366f8f445e10a32bd403c8469bdbce8ce049e1f0972b607080", [:mix], [{:coerce, "~> 1.0", [hex: :coerce, repo: "hexpm", optional: false]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "eeccf5c61d5f4922198395bf87a465b6f980b8b862dd22d28198c5e6fab38582"},
"qex": {:hex, :qex, "0.5.1", "0d82c0f008551d24fffb99d97f8299afcb8ea9cf99582b770bd004ed5af63fd6", [:mix], [], "hexpm", "935a39fdaf2445834b95951456559e9dc2063d0a055742c558a99987b38d6bab"},
Expand Down
7 changes: 4 additions & 3 deletions test/membrane_element_mpeg_audio/depayloader_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ defmodule Membrane.RTP.MPEGAudio.DepayloaderTest do
test "returns error when incoming payload is not valid", %{state: state} do
invalid_buffer = %Buffer{payload: <<0::16>>}

assert Depayloader.handle_process(:input, invalid_buffer, nil, state) ==
{{:error, :invalid_payload}, state}
assert_raise RuntimeError, ~r/Error.*invalid.*payload/, fn ->
Depayloader.handle_process(:input, invalid_buffer, nil, state)
end
end

test "with valid packed strips mbz and offset", %{state: state} do
valid_buffer = %Buffer{payload: <<0::16, 128::16, 256::8, 0::256>>}

assert Depayloader.handle_process(:input, valid_buffer, nil, state) ==
{{:ok, buffer: {:output, %Buffer{payload: <<256::8, 0::256>>}}}, state}
{[buffer: {:output, %Buffer{payload: <<256::8, 0::256>>}}], state}
end
end
end
15 changes: 8 additions & 7 deletions test/membrane_element_mpeg_audio/pipeline_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule Membrane.RTP.MPEGAudio.DepayloaderPipelineTest do
use ExUnit.Case

import Membrane.Testing.Assertions
import Membrane.ChildrenSpec

alias Membrane.RTP
alias Membrane.RTP.MPEGAudio.Depayloader
Expand All @@ -12,14 +13,14 @@ defmodule Membrane.RTP.MPEGAudio.DepayloaderPipelineTest do
base_range = 1..100
data = Enum.map(base_range, fn elem -> <<0::32, elem::256>> end)

{:ok, pipeline} =
Pipeline.start_link(%Pipeline.Options{
elements: [
source: %Source{output: data, caps: %RTP{}},
depayloader: Depayloader,
sink: %Sink{}
{:ok, _supervisor_pid, pipeline} =
Pipeline.start_link(
structure: [
child(:source, %Source{output: data, stream_format: %RTP{}})
|> child(:depayloader, Depayloader)
|> child(:sink, %Sink{})
]
})
)

Enum.each(base_range, fn elem ->
assert_sink_buffer(pipeline, :sink, %Membrane.Buffer{payload: <<^elem::256>>})
Expand Down

0 comments on commit cf70db9

Please sign in to comment.