Skip to content

Commit 4b45977

Browse files
authored
Merge pull request #12 from membraneframework/assume-more-stream-formats
Allow assuming more stream formats
2 parents 07a2abd + 68048bb commit 4b45977

File tree

3 files changed

+19
-29
lines changed

3 files changed

+19
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The package can be installed by adding `membrane_transcoder_plugin` to your list
1717
```elixir
1818
def deps do
1919
[
20-
{:membrane_transcoder_plugin, "~> 0.3.0"}
20+
{:membrane_transcoder_plugin, "~> 0.3.1"}
2121
]
2222
end
2323
```

lib/transcoder.ex

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ defmodule Membrane.Transcoder do
1010
* `Membrane.VP8`
1111
* `Membrane.VP9`
1212
* `Membrane.RawVideo`
13-
* `Membrane.RemoteStream{content_type: Membrane.VP8}` (only as an input stream)
14-
* `Membrane.RemoteStream{content_type: Membrane.VP9}` (only as an input stream)
13+
* `Membrane.RemoteStream{content_format: Membrane.VP8}` (only as an input stream)
14+
* `Membrane.RemoteStream{content_format: Membrane.VP9}` (only as an input stream)
1515
1616
The following audio stream formats are supported:
1717
* `Membrane.AAC`
1818
* `Membrane.Opus`
1919
* `Membrane.MPEGAudio`
2020
* `Membrane.RawAudio`
21-
* `Membrane.RemoteStream{content_type: Membrane.Opus}` (only as an input stream)
22-
* `Membrane.RemoteStream{content_type: Membrane.MPEGAudio}` (only as an input stream)
21+
* `Membrane.RemoteStream{content_format: Membrane.Opus}` (only as an input stream)
22+
* `Membrane.RemoteStream{content_format: Membrane.MPEGAudio}` (only as an input stream)
2323
"""
2424
use Membrane.Bin
2525

@@ -112,20 +112,23 @@ defmodule Membrane.Transcoder do
112112
"""
113113
],
114114
assumed_input_stream_format: [
115-
spec: %Membrane.RemoteStream{content_format: Membrane.MPEGAudio} | nil,
115+
spec: struct() | nil,
116116
default: nil,
117117
description: """
118-
Allows to override stream format of the input stream with
119-
`%Membrane.RemoteStream{content_format: Membrane.MPEGAudio}`
120-
If nil, the input stream format won't be overriden.
118+
Allows to override stream format of the input stream.
119+
120+
Overriding will fail, the stream format sent on the #{inspect(__MODULE__)}'s input
121+
pad is not `Membrane.RemoteStream`
122+
123+
If nil or not set, the input stream format won't be overriden.
121124
"""
122125
]
123126

124127
@impl true
125128
def handle_init(_ctx, opts) do
126129
spec = [
127130
bin_input()
128-
|> maybe_override_input_stream_format(opts.assumed_input_stream_format)
131+
|> maybe_plug_stream_format_changer(opts.assumed_input_stream_format)
129132
|> child(:connector, %Membrane.Connector{notify_on_stream_format?: true}),
130133
child(:output_funnel, Funnel)
131134
|> bin_output()
@@ -141,26 +144,13 @@ defmodule Membrane.Transcoder do
141144
{[spec: spec], state}
142145
end
143146

144-
defp maybe_override_input_stream_format(
145-
builder,
146-
%Membrane.RemoteStream{content_format: Membrane.MPEGAudio} = stream_format
147-
) do
148-
builder
149-
|> child(:stream_format_changer, %Membrane.Transcoder.StreamFormatChanger{
150-
stream_format: stream_format
151-
})
152-
end
147+
defp maybe_plug_stream_format_changer(builder, nil), do: builder
153148

154-
defp maybe_override_input_stream_format(builder, nil) do
149+
defp maybe_plug_stream_format_changer(builder, enforced_stream_format) do
155150
builder
156-
end
157-
158-
defp maybe_override_input_stream_format(_builder, stream_format) do
159-
raise """
160-
The only input stream format that can be assumed is \
161-
`%Membrane.RemoteStream{content_format: Membrane.MPEGAudio}`, while you wanted to assume: \
162-
#{inspect(stream_format)}
163-
"""
151+
|> child(:stream_format_changer, %__MODULE__.StreamFormatChanger{
152+
stream_format: enforced_stream_format
153+
})
164154
end
165155

166156
@impl true

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Membrane.Transcoder.Plugin.Mixfile do
22
use Mix.Project
33

4-
@version "0.3.0"
4+
@version "0.3.1"
55
@github_url "https://github.com/membraneframework/membrane_transcoder_plugin"
66

77
def project do

0 commit comments

Comments
 (0)