Skip to content

Commit 2ae23dd

Browse files
authored
Merge pull request #8 from membraneframework/allow-format-changes
Allow format changes
2 parents 61a5ef4 + 0f0a259 commit 2ae23dd

File tree

6 files changed

+17
-139
lines changed

6 files changed

+17
-139
lines changed

README.md

+1-1
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.2.0"}
20+
{:membrane_transcoder_plugin, "~> 0.2.1"}
2121
]
2222
end
2323
```

lib/transcoder.ex

+11-17
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ defmodule Membrane.Transcoder do
2222
require __MODULE__.Video
2323
require Membrane.Logger
2424

25-
alias __MODULE__.{Audio, ForwardingFilter, Video}
25+
alias __MODULE__.{Audio, Video}
2626
alias Membrane.{AAC, Funnel, H264, H265, Opus, RawAudio, RawVideo, RemoteStream, VP8}
2727

2828
@typedoc """
@@ -86,7 +86,7 @@ defmodule Membrane.Transcoder do
8686
def handle_init(_ctx, opts) do
8787
spec = [
8888
bin_input()
89-
|> child(:forwarding_filter, ForwardingFilter),
89+
|> child(:connector, %Membrane.Connector{notify_on_stream_format?: true}),
9090
child(:output_funnel, Funnel)
9191
|> bin_output()
9292
]
@@ -102,12 +102,8 @@ defmodule Membrane.Transcoder do
102102
end
103103

104104
@impl true
105-
def handle_child_notification(
106-
{:stream_format, format},
107-
:forwarding_filter,
108-
_ctx,
109-
%{input_stream_format: nil} = state
110-
) do
105+
def handle_child_notification({:stream_format, _pad, format}, :connector, _ctx, state)
106+
when state.input_stream_format == nil do
111107
state =
112108
%{state | input_stream_format: format}
113109
|> resolve_output_stream_format()
@@ -118,7 +114,7 @@ defmodule Membrane.Transcoder do
118114
end
119115

120116
spec =
121-
get_child(:forwarding_filter)
117+
get_child(:connector)
122118
|> plug_transcoding(
123119
format,
124120
state.output_stream_format,
@@ -130,16 +126,14 @@ defmodule Membrane.Transcoder do
130126
end
131127

132128
@impl true
133-
def handle_child_notification(
134-
{:stream_format, new_format},
135-
:forwarding_filter,
136-
_ctx,
137-
%{input_stream_format: non_nil_stream_format} = state
138-
) do
139-
if new_format != non_nil_stream_format do
129+
def handle_child_notification({:stream_format, _pad, new_format}, :connector, _ctx, state) do
130+
%new_stream_format_module{} = new_format
131+
%old_stream_format_module{} = state.input_stream_format
132+
133+
if new_stream_format_module != old_stream_format_module do
140134
raise """
141135
Received new stream format on transcoder's input: #{inspect(new_format)}
142-
which doesn't match the first received input stream format: #{inspect(non_nil_stream_format)}
136+
which doesn't match the first received input stream format: #{inspect(state.input_stream_format)}
143137
Transcoder doesn't support updating the input stream format.
144138
"""
145139
end

lib/transcoder/forwarding_filter.ex

-117
This file was deleted.

mix.exs

+2-2
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.2.0"
4+
@version "0.2.1"
55
@github_url "https://github.com/membraneframework/membrane_transcoder_plugin"
66

77
def project do
@@ -37,7 +37,7 @@ defmodule Membrane.Transcoder.Plugin.Mixfile do
3737

3838
defp deps do
3939
[
40-
{:membrane_core, "~> 1.1"},
40+
{:membrane_core, "~> 1.2 and >= 1.2.1"},
4141
{:membrane_opus_plugin, "~> 0.20.3"},
4242
{:membrane_aac_plugin, "~> 0.19.0"},
4343
{:membrane_aac_fdk_plugin, "~> 0.18.0"},

mix.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"membrane_aac_format": {:hex, :membrane_aac_format, "0.8.0", "515631eabd6e584e0e9af2cea80471fee6246484dbbefc4726c1d93ece8e0838", [:mix], [{:bimap, "~> 1.1", [hex: :bimap, repo: "hexpm", optional: false]}], "hexpm", "a30176a94491033ed32be45e51d509fc70a5ee6e751f12fd6c0d60bd637013f6"},
2525
"membrane_aac_plugin": {:hex, :membrane_aac_plugin, "0.19.0", "58a15efaaa4f2cc91b968464cfd269244e035efdd983aac2e3ddeb176fcf0585", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_aac_format, "~> 0.8.0", [hex: :membrane_aac_format, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "eb7e786e650608ee205f4eebff4c1df3677e545acf09802458f77f64f9942fe9"},
2626
"membrane_common_c": {:hex, :membrane_common_c, "0.16.0", "caf3f29d2f5a1d32d8c2c122866110775866db2726e4272be58e66dfdf4bce40", [:mix], [{:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:shmex, "~> 0.5.0", [hex: :shmex, repo: "hexpm", optional: false]}, {:unifex, "~> 1.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "a3c7e91de1ce1f8b23b9823188a5d13654d317235ea0ca781c05353ed3be9b1c"},
27-
"membrane_core": {:hex, :membrane_core, "1.2.0", "c74ef043791e11d149a01e344d9973de34d6dd2e3b8a6bdc79ff5b183a74b243", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.3", [hex: :qex, repo: "hexpm", optional: false]}, {:ratio, "~> 3.0 or ~> 4.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "0133e3478af608b1749729d82bc747a0357e207f5819a6bd4d31614ce7d0a463"},
27+
"membrane_core": {:hex, :membrane_core, "1.2.1", "96cd9c8a255585c0ed2906d093a6c6e5e4198f1b23cfe5e62a613673fcb1da30", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.3", [hex: :qex, repo: "hexpm", optional: false]}, {:ratio, "~> 3.0 or ~> 4.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "becc0e6fabe8732f360c91607b708f196dda1ab5ab1f15fc4a979909cc76d49d"},
2828
"membrane_ffmpeg_swresample_plugin": {:hex, :membrane_ffmpeg_swresample_plugin, "0.20.2", "2e669f0b25418d10b51a73bc52d2e12e4a3a26b416c5c1199d852c3f781a18b3", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:bundlex, "~> 1.2", [hex: :bundlex, repo: "hexpm", optional: false]}, {:membrane_common_c, "~> 0.16.0", [hex: :membrane_common_c, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_precompiled_dependency_provider, "~> 0.1.0", [hex: :membrane_precompiled_dependency_provider, repo: "hexpm", optional: false]}, {:membrane_raw_audio_format, "~> 0.12.0", [hex: :membrane_raw_audio_format, repo: "hexpm", optional: false]}, {:mockery, "~> 2.1", [hex: :mockery, repo: "hexpm", optional: false]}, {:unifex, "~> 1.1", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "6c8d3bcd61d568dd94cabb9b45f29e8926e0076e4432d8f419378e004e02147c"},
2929
"membrane_file_plugin": {:hex, :membrane_file_plugin, "0.17.2", "650e134c2345d946f930082fac8bac9f5aba785a7817d38a9a9da41ffc56fa92", [:mix], [{:logger_backends, "~> 1.0", [hex: :logger_backends, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "df50c6040004cd7b901cf057bd7e99c875bbbd6ae574efc93b2c753c96f43b9d"},
3030
"membrane_funnel_plugin": {:hex, :membrane_funnel_plugin, "0.9.1", "9e108f4ef9d905ebff2da3ba5e58a5b756b58812f4fa68bd576add68fda310a0", [:mix], [{:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "39fdef1bf29eac949f65a37ea941f997c22ed042c55af044d27a781b63e82f6b"},

test/support/preprocessors.ex

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ defmodule Membrane.Transcoder.Support.Preprocessors do
2020

2121
@spec parse_h264(Membrane.ChildrenSpec.builder()) :: Membrane.ChildrenSpec.builder()
2222
def parse_h264(link_builder) do
23-
child(link_builder, %Membrane.H264.Parser{
23+
link_builder
24+
|> child(%Membrane.H264.Parser{
2425
output_alignment: :au,
2526
output_stream_structure: :annexb,
2627
generate_best_effort_timestamps: %{framerate: {30, 1}}

0 commit comments

Comments
 (0)