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 @@ -17,7 +17,7 @@ The package can be installed by adding `membrane_transcoder_plugin` to your list
```elixir
def deps do
[
{:membrane_transcoder_plugin, "~> 0.3.0"}
{:membrane_transcoder_plugin, "~> 0.3.1"}
]
end
```
Expand Down
44 changes: 17 additions & 27 deletions lib/transcoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ defmodule Membrane.Transcoder do
* `Membrane.VP8`
* `Membrane.VP9`
* `Membrane.RawVideo`
* `Membrane.RemoteStream{content_type: Membrane.VP8}` (only as an input stream)
* `Membrane.RemoteStream{content_type: Membrane.VP9}` (only as an input stream)
* `Membrane.RemoteStream{content_format: Membrane.VP8}` (only as an input stream)
* `Membrane.RemoteStream{content_format: Membrane.VP9}` (only as an input stream)

The following audio stream formats are supported:
* `Membrane.AAC`
* `Membrane.Opus`
* `Membrane.MPEGAudio`
* `Membrane.RawAudio`
* `Membrane.RemoteStream{content_type: Membrane.Opus}` (only as an input stream)
* `Membrane.RemoteStream{content_type: Membrane.MPEGAudio}` (only as an input stream)
* `Membrane.RemoteStream{content_format: Membrane.Opus}` (only as an input stream)
* `Membrane.RemoteStream{content_format: Membrane.MPEGAudio}` (only as an input stream)
"""
use Membrane.Bin

Expand Down Expand Up @@ -112,20 +112,23 @@ defmodule Membrane.Transcoder do
"""
],
assumed_input_stream_format: [
spec: %Membrane.RemoteStream{content_format: Membrane.MPEGAudio} | nil,
spec: struct() | nil,
default: nil,
description: """
Allows to override stream format of the input stream with
`%Membrane.RemoteStream{content_format: Membrane.MPEGAudio}`
If nil, the input stream format won't be overriden.
Allows to override stream format of the input stream.

Overriding will fail, the stream format sent on the #{inspect(__MODULE__)}'s input
pad is not `Membrane.RemoteStream`

If nil or not set, the input stream format won't be overriden.
"""
]

@impl true
def handle_init(_ctx, opts) do
spec = [
bin_input()
|> maybe_override_input_stream_format(opts.assumed_input_stream_format)
|> maybe_plug_stream_format_changer(opts.assumed_input_stream_format)
|> child(:connector, %Membrane.Connector{notify_on_stream_format?: true}),
child(:output_funnel, Funnel)
|> bin_output()
Expand All @@ -141,26 +144,13 @@ defmodule Membrane.Transcoder do
{[spec: spec], state}
end

defp maybe_override_input_stream_format(
builder,
%Membrane.RemoteStream{content_format: Membrane.MPEGAudio} = stream_format
) do
builder
|> child(:stream_format_changer, %Membrane.Transcoder.StreamFormatChanger{
stream_format: stream_format
})
end
defp maybe_plug_stream_format_changer(builder, nil), do: builder

defp maybe_override_input_stream_format(builder, nil) do
defp maybe_plug_stream_format_changer(builder, enforced_stream_format) do
builder
end

defp maybe_override_input_stream_format(_builder, stream_format) do
raise """
The only input stream format that can be assumed is \
`%Membrane.RemoteStream{content_format: Membrane.MPEGAudio}`, while you wanted to assume: \
#{inspect(stream_format)}
"""
|> child(:stream_format_changer, %__MODULE__.StreamFormatChanger{
stream_format: enforced_stream_format
})
end

@impl true
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Membrane.Transcoder.Plugin.Mixfile do
use Mix.Project

@version "0.3.0"
@version "0.3.1"
@github_url "https://github.com/membraneframework/membrane_transcoder_plugin"

def project do
Expand Down