Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ For the full list of input and output options, see [`Boombox.run/2`](https://hex
To use Boombox as an Elixir library, add

```elixir
{:boombox, "~> 0.2.4"}
{:boombox, "~> 0.2.5"}
```

to your dependencies or `Mix.install`.
Expand Down
13 changes: 3 additions & 10 deletions lib/boombox.ex
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,8 @@ defmodule Boombox do
@type input ::
(path_or_uri :: String.t())
| {path_or_uri :: String.t(),
[
hls_variant_selection_policy_opt()
| hls_mode_opt()
| {:framerate, Membrane.H264.framerate() | Membrane.H265.framerate_t()}
]}
[hls_variant_selection_policy_opt() | hls_mode_opt()]
| [{:framerate, Membrane.H264.framerate() | Membrane.H265.framerate_t()}]}
| {:mp4 | :aac | :wav | :mp3 | :ivf | :ogg | :h264 | :h265, location :: String.t()}
| {:mp4 | :aac | :wav | :mp3 | :ivf | :ogg, location :: String.t(),
transport: :file | :http}
Expand All @@ -109,11 +106,7 @@ defmodule Boombox do
| {:rtsp, url :: String.t()}
| {:rtp, in_rtp_opts()}
| {:hls, url :: String.t()}
| {:hls, url :: String.t(),
[
hls_mode_opt()
| hls_variant_selection_policy_opt()
]}
| {:hls, url :: String.t(), [hls_variant_selection_policy_opt() | hls_mode_opt()]}
| {:srt, url :: String.t()}
| {:srt, url :: String.t(), srt_auth_opts()}
| {:srt, server_awaiting_accept :: ExLibSRT.Server.t()}
Expand Down
5 changes: 1 addition & 4 deletions lib/boombox/internal_bin.ex
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ defmodule Boombox.InternalBin do
{"rtsp", _ext, :input} ->
{:rtsp, value}

{scheme, ".m3u8", :input} when scheme in ["http", "https"] ->
{scheme, ".m3u8", :input} when scheme in [nil, "http", "https"] ->
{:hls, value, opts}

{nil, ".m3u8", :output} ->
Expand Down Expand Up @@ -928,9 +928,6 @@ defmodule Boombox.InternalBin do
{:stream, opts} ->
Keyword.get(opts, :is_live, false)

{:hls, _location, opts} ->
Keyword.get(opts, :mode) == :live

_other ->
false
end
Expand Down
11 changes: 10 additions & 1 deletion lib/boombox/internal_bin/hls.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@ defmodule Boombox.InternalBin.HLS do
@moduledoc false

import Membrane.ChildrenSpec

require Logger
require Membrane.Pad, as: Pad
alias Boombox.InternalBin.{Ready, Wait}
alias Membrane.{AAC, H264, HTTPAdaptiveStream, RemoteStream, Time, Transcoder}

@spec create_input(String.t(), [Boombox.hls_variant_selection_policy_opt()]) :: Wait.t()
def create_input(url, opts) do
maybe_hls_mode = Keyword.get(opts, :mode, nil)

if maybe_hls_mode != nil do
Logger.warning("""
Option :mode is deprecated for HLS input. Its value will be ignored.
It was set to #{inspect(maybe_hls_mode)}.
""")
end

variant_selection_policy = Keyword.get(opts, :variant_selection_policy, :highest_resolution)

spec =
Expand Down
62 changes: 42 additions & 20 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Boombox.Mixfile do
use Mix.Project

@version "0.2.4"
@version "0.2.5"
@github_url "https://github.com/membraneframework/boombox"

def project do
Expand Down Expand Up @@ -51,7 +51,7 @@ defmodule Boombox.Mixfile do
{:membrane_webrtc_plugin, "~> 0.25.0"},
{:membrane_mp4_plugin, "~> 0.36.0"},
{:membrane_realtimer_plugin, "~> 0.9.0"},
{:membrane_http_adaptive_stream_plugin, "~> 0.19.0"},
{:membrane_http_adaptive_stream_plugin, "~> 0.20.1"},
{:membrane_rtmp_plugin, "~> 0.27.2"},
{:membrane_rtsp_plugin, "~> 0.6.1"},
{:membrane_rtp_plugin, "~> 0.30.0"},
Expand All @@ -71,11 +71,7 @@ defmodule Boombox.Mixfile do
{:membrane_simple_rtsp_server, "~> 0.1.5", only: :test},
{:image, "~> 0.54.0"},
{:async_test, github: "software-mansion-labs/elixir_async_test", only: :test},
# {:playwright, "~> 1.49.1-alpha.1", only: :test},
{:playwright,
github: "membraneframework-labs/playwright-elixir",
ref: "5c02249512fa543f5e619a69b7e5c9e046605fe5",
only: :test},
{:playwright, "~> 1.49.1-alpha.2", only: :test},
{:burrito, "~> 1.0", runtime: burrito?(), optional: true},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:dialyxir, ">= 0.0.0", only: :dev, runtime: false},
Expand Down Expand Up @@ -199,31 +195,57 @@ defmodule Boombox.Mixfile do
# with new symlinks pointing to bundlex's
# priv/shared/precompiled directory
defp restore_symlinks(release) do
base_dir = "#{__DIR__}/_build/dev/rel/boombox/lib"
base_dir =
Path.join([
__DIR__,
"_build",
Atom.to_string(Mix.env()),
"rel",
Atom.to_string(release.name),
"lib"
])

shared =
Path.wildcard("#{base_dir}/bundlex*/priv/shared/precompiled/*")
Path.join(base_dir, "bundlex*/priv/shared/precompiled/*")
|> Path.wildcard()
|> Enum.map(&Path.relative_to(&1, base_dir))
|> Map.new(&{Path.basename(&1), &1})

Path.wildcard("#{base_dir}/*/priv/bundlex/*/*")
|> Enum.each(fn path ->
name = Path.basename(path)

case shared[name] do
nil ->
:ok

shared_dir ->
File.rm_rf!(path)
depth = path |> Path.relative_to(base_dir) |> Path.split() |> length()
ln = String.duplicate("../", depth - 1) <> shared_dir
dbg(path)
dbg(ln)
File.ln_s!(ln, path)
if Map.has_key?(shared, name) do
ln =
Path.join([base_dir, shared[name], "lib"])
|> Path.relative_to(Path.dirname(path), force: true)

File.rm_rf!(path)
File.ln_s!(ln, path)
end
end)

Path.join(base_dir, "bundlex*/priv/shared/precompiled/*/lib")
|> Path.wildcard()
|> Enum.map(fn lib_dir ->
File.ls!(lib_dir)
|> Enum.group_by(&(String.split(&1, ".") |> List.first()))
|> Enum.each(fn {_lib_name, libs} ->
lib_to_symlink_to =
Enum.max_by(libs, &String.length/1)

libs
|> Enum.filter(&(&1 != lib_to_symlink_to))
|> Enum.map(fn lib_to_replace ->
lib_to_replace_path =
Path.join(lib_dir, lib_to_replace)

File.rm_rf!(lib_to_replace_path)
File.ln_s!(lib_to_symlink_to, lib_to_replace_path)
end)
end)
end)

release
end
end
Loading