From d1c1e366216a72f9f28555f4a5fda114c6415ae5 Mon Sep 17 00:00:00 2001 From: Mateusz Front Date: Wed, 6 Jun 2018 19:38:55 +0200 Subject: [PATCH] taking deps from hex, readme improvements --- README.md | 17 ++++++++- .../converter.ex | 8 +++- mix.exs | 37 ++++++++++++++----- mix.lock | 8 ++-- 4 files changed, 53 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 61f0280..7a5c0aa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,19 @@ # Membrane.Element.FFmpeg.SWResample -This element performs audio conversion, resampling and channel mixing, using SWResample module of FFmpeg library. +Element of [Membrane Multimedia Framework](https://membraneframework.org) performing audio conversion, resampling and channel mixing, using SWResample module of [FFmpeg](https://www.ffmpeg.org/) library. + +Documentation is available at [HexDocs](https://hexdocs.pm/membrane_element_portaudio/) + +## Installation + +Add the following line to your `deps` in `mix.exs`. Run `mix deps.get`. + +```elixir +{:membrane_element_ffmpeg_swresample, "~> 0.1"} +``` + +You also need to have [FFmpeg](https://www.ffmpeg.org/) library installed. +For usage on windows, see `Using on Windows` section below. ## Sample usage @@ -46,4 +59,4 @@ It is possible to compile and use this element on Windows platform. That require * adding directory with DLLs to `PATH` environment variable * placing them in current directory (where you start `mix run`) * placing them in the directory where erlang executable is located - * making them available system-wide by placing in system (`C:\Windows\System32`, `C:\Windows\SysWOW64`) or Windows (`C:\Windows`) directory \ No newline at end of file + * making them available system-wide by placing in system (`C:\Windows\System32`, `C:\Windows\SysWOW64`) or Windows (`C:\Windows`) directory diff --git a/lib/membrane_element_ffmpeg_swresample/converter.ex b/lib/membrane_element_ffmpeg_swresample/converter.ex index 520a017..c39c87e 100644 --- a/lib/membrane_element_ffmpeg_swresample/converter.ex +++ b/lib/membrane_element_ffmpeg_swresample/converter.ex @@ -152,7 +152,7 @@ defmodule Membrane.Element.FFmpeg.SWResample.Converter do when byte_size(queue) + byte_size(payload) > 2 * frame_size do {payload, q} = (queue <> payload) - |> Helper.Binary.int_rem(frame_size) + |> binary_int_rem(frame_size) with {:ok, result} <- @native.convert(native, payload) do {:ok, {result, q}} @@ -160,4 +160,10 @@ defmodule Membrane.Element.FFmpeg.SWResample.Converter do end defp convert(_native, _frame_size, payload, queue), do: {:ok, {<<>>, queue <> payload}} + + defp binary_int_rem(b, d) when is_binary(b) and is_integer(d) do + len = b |> byte_size |> int_part(d) + <> = b + {b, r} + end end diff --git a/mix.exs b/mix.exs index 3a08c5d..76e5847 100644 --- a/mix.exs +++ b/mix.exs @@ -2,6 +2,8 @@ defmodule Membrane.Element.FFmpeg.SWResample.Mixfile do use Mix.Project Application.put_env(:bundlex, :membrane_element_ffmpeg_swresample, __ENV__) + @github_url "https://github.com/membraneframework/membrane-element-ffmpeg-swresample" + def project do [ app: :membrane_element_ffmpeg_swresample, @@ -12,8 +14,8 @@ defmodule Membrane.Element.FFmpeg.SWResample.Mixfile do description: "Membrane Multimedia Framework (FFmpeg SWResample Element)", package: package(), name: "Membrane Element: FFmpeg SWResample", - source_url: link(), - homepage_url: "https://membraneframework.org", + source_url: @github_url, + docs: docs(), deps: deps() ] end @@ -28,26 +30,41 @@ defmodule Membrane.Element.FFmpeg.SWResample.Mixfile do defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(_), do: ["lib"] - defp link do - "https://github.com/membraneframework/membrane-element-ffmpeg-swresample" + defp docs do + [ + main: "readme", + extras: ["README.md"] + ] end defp package do [ maintainers: ["Membrane Team"], licenses: ["Apache 2.0"], - links: %{"GitHub" => link()} + links: %{ + "GitHub" => @github_url, + "Membrane Framework Homepage" => "https://membraneframework.org" + }, + files: [ + "lib", + "c_src", + "ext", + "mix.exs", + "README*", + "LICENSE*", + ".formatter.exs", + "bundlex.exs" + ] ] end defp deps do [ {:ex_doc, "~> 0.18", only: :dev, runtime: false}, - {:membrane_core, git: "git@github.com:membraneframework/membrane-core.git"}, - {:membrane_caps_audio_raw, - git: "git@github.com:membraneframework/membrane-caps-audio-raw.git"}, - {:membrane_common_c, git: "git@github.com:membraneframework/membrane-common-c.git"}, - {:bundlex, git: "git@github.com:radiokit/bundlex.git"}, + {:membrane_core, "~> 0.1"}, + {:membrane_caps_audio_raw, "~> 0.1"}, + {:membrane_common_c, "~> 0.1"}, + {:bundlex, "~> 0.1"}, {:mockery, "~> 2.1", runtime: false} ] end diff --git a/mix.lock b/mix.lock index 1c5e884..5178486 100644 --- a/mix.lock +++ b/mix.lock @@ -1,13 +1,13 @@ %{ "bimap": {:hex, :bimap, "0.1.1", "f0406e59f65ba903af678383d2356d0a6e59fb794adc1a7dd32bd8fabe0f028f", [:mix], [], "hexpm"}, - "bundlex": {:git, "git@github.com:radiokit/bundlex.git", "78f8f42f8c3ec497680dd2f036619961b64d47f3", []}, + "bundlex": {:hex, :bundlex, "0.1.0", "fa28a7f5b5605f0c788b0e8ada69fa9aa6ab8d0fadf03a519f43f780e160e3cc", [:mix], [{:porcelain, "~> 2.0", [hex: :porcelain, repo: "hexpm", optional: false]}], "hexpm"}, "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], []}, "earmark": {:hex, :earmark, "1.2.5", "4d21980d5d2862a2e13ec3c49ad9ad783ffc7ca5769cf6ff891a4553fbaae761", [:mix], [], "hexpm"}, "ex_doc": {:hex, :ex_doc, "0.18.3", "f4b0e4a2ec6f333dccf761838a4b253d75e11f714b85ae271c9ae361367897b7", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, "membrane_caps_audio_mpeg": {:git, "git@github.com:membraneframework/membrane-caps-audio-mpeg.git", "4f29dec1b3058cdf1d113484240569b64d4334b2", []}, - "membrane_caps_audio_raw": {:git, "git@github.com:membraneframework/membrane-caps-audio-raw.git", "a9fa796731424ee36dd6af1ea0a4456677e85caf", []}, - "membrane_common_c": {:git, "git@github.com:membraneframework/membrane-common-c.git", "a2f5a600de77bec6f3ec42392e6205daf8797e6b", []}, - "membrane_core": {:git, "git@github.com:membraneframework/membrane-core.git", "c30d56d1dc1dda34b82eb13af6cf83aee8d8984f", []}, + "membrane_caps_audio_raw": {:hex, :membrane_caps_audio_raw, "0.1.0", "e56c154ac91ed42a429982120f1bd2f55ec411cf5cc4b45d39788ce792346575", [:mix], [{:bimap, "~> 0.1", [hex: :bimap, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.1", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm"}, + "membrane_common_c": {:hex, :membrane_common_c, "0.1.0", "1ca2ca66b9244a8f08efa2d43ca56d149c91e63b198f386857ec1b25c91119ec", [:mix], [{:bundlex, "~> 0.1", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm"}, + "membrane_core": {:hex, :membrane_core, "0.1.0", "f9cd2f35e910a1ba050b6af68871e94e699d060da710a301551c28671857f0ca", [:mix], [{:qex, "~> 0.3", [hex: :qex, repo: "hexpm", optional: false]}], "hexpm"}, "mockery": {:hex, :mockery, "2.1.0", "75f2ae11f1f1ebd006d9e80fa4d2a181ed1bd45c7d48c4e501644c3f5c0012e5", [:mix], [], "hexpm"}, "porcelain": {:hex, :porcelain, "2.0.3", "2d77b17d1f21fed875b8c5ecba72a01533db2013bd2e5e62c6d286c029150fdc", [:mix], [], "hexpm"}, "qex": {:hex, :qex, "0.3.4", "92fba2ca8fa162d4619d572ec6d9124f47564a5c8dd1e252147c29d3435d2608", [:mix], [], "hexpm"},