Skip to content

Commit 8ada813

Browse files
committed
enforce_transcoding -> force_transcoding
1 parent 16409b6 commit 8ada813

File tree

11 files changed

+41
-39
lines changed

11 files changed

+41
-39
lines changed

lib/boombox.ex

+12-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defmodule Boombox do
99

1010
alias Membrane.RTP
1111

12-
@type enforce_transcoding_value() :: boolean() | :audio | :video
12+
@type force_transcoding_value() :: boolean() | :audio | :video
1313

1414
@type webrtc_signaling :: Membrane.WebRTC.Signaling.t() | String.t()
1515
@type in_stream_opts :: [
@@ -66,7 +66,7 @@ defmodule Boombox do
6666
| {:address, :inet.ip_address() | String.t()}
6767
| {:port, :inet.port_number()}
6868
| {:target, String.t()}
69-
| {:enforce_transcoding, enforce_transcoding_value()}
69+
| {:force_transcoding, force_transcoding_value()}
7070
]
7171

7272
@type input ::
@@ -82,12 +82,12 @@ defmodule Boombox do
8282
@type output ::
8383
(path_or_uri :: String.t())
8484
| {:mp4, location :: String.t()}
85-
| {:mp4, location :: String.t(), [{:enforce_transcoding, enforce_transcoding_value()}]}
85+
| {:mp4, location :: String.t(), [{:force_transcoding, force_transcoding_value()}]}
8686
| {:webrtc, webrtc_signaling()}
87-
| {:webrtc, webrtc_signaling(), [{:enforce_transcoding, enforce_transcoding_value()}]}
87+
| {:webrtc, webrtc_signaling(), [{:force_transcoding, force_transcoding_value()}]}
8888
| {:whip, uri :: String.t(), [{:token, String.t()} | {bandit_option :: atom(), term()}]}
8989
| {:hls, location :: String.t()}
90-
| {:hls, location :: String.t(), [{:enforce_transcoding, enforce_transcoding_value()}]}
90+
| {:hls, location :: String.t(), [{:force_transcoding, force_transcoding_value()}]}
9191
| {:rtp, out_rtp_opts()}
9292
| {:stream, out_stream_opts()}
9393

@@ -135,7 +135,7 @@ defmodule Boombox do
135135
opts
136136
|> Keyword.validate!(@endpoint_opts)
137137
|> Map.new(fn {key, value} -> {key, parse_endpoint_opt!(key, value)} end)
138-
|> resolve_enforce_transcoding()
138+
|> resolve_force_transcoding()
139139

140140
:ok = maybe_log_transcoding_related_warning(opts)
141141

@@ -275,11 +275,11 @@ defmodule Boombox do
275275
@spec maybe_log_transcoding_related_warning(opts_map()) :: :ok
276276
def maybe_log_transcoding_related_warning(opts) do
277277
if is_webrtc_endpoint(opts.output) and not is_webrtc_endpoint(opts.input) and
278-
opts.enforce_transcoding not in [true, :video] do
278+
opts.force_transcoding not in [true, :video] do
279279
Logger.warning("""
280280
Boombox output protocol is WebRTC, while Boombox input doesn't support keyframe requests. This \
281281
might lead to issues with the output video if the output stream isn't sent only by localhost. You \
282-
can solve this by setting `:enforce_transcoding` output option to `true` or `:video`, but be aware \
282+
can solve this by setting `:force_transcoding` output option to `true` or `:video`, but be aware \
283283
that it will increase Boombox CPU usage.
284284
""")
285285
end
@@ -421,17 +421,17 @@ defmodule Boombox do
421421
end
422422
end
423423

424-
defp resolve_enforce_transcoding(opts) do
424+
defp resolve_force_transcoding(opts) do
425425
maybe_keyword =
426426
opts.output
427427
|> Tuple.to_list()
428428
|> List.last()
429429

430-
enforce_transcoding =
431-
Keyword.keyword?(maybe_keyword) && Keyword.get(maybe_keyword, :enforce_transcoding, false)
430+
force_transcoding =
431+
Keyword.keyword?(maybe_keyword) && Keyword.get(maybe_keyword, :force_transcoding, false)
432432

433433
opts
434-
|> Map.put(:enforce_transcoding, enforce_transcoding)
434+
|> Map.put(:force_transcoding, force_transcoding)
435435
|> Map.update!(:output, fn
436436
{:webrtc, signaling, _opts} -> {:webrtc, signaling}
437437
{:hls, location, _opts} -> {:hls, location}

lib/boombox/elixir_stream.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ defmodule Boombox.ElixirStream do
6767
builder
6868
|> child(:elixir_stream_video_transcoder, %Membrane.Transcoder{
6969
output_stream_format: Membrane.RawVideo,
70-
enforce_transcoding?: state.enforce_transcoding in [true, :video]
70+
force_transcoding?: state.force_transcoding in [true, :video]
7171
})
7272
|> child(:elixir_stream_rgb_converter, %Membrane.FFmpeg.SWScale.Converter{
7373
format: :RGB

lib/boombox/hls.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ defmodule Boombox.HLS do
4646
builder
4747
|> child(:hls_audio_transcoder, %Membrane.Transcoder{
4848
output_stream_format: Membrane.AAC,
49-
enforce_transcoding?: state.enforce_transcoding in [true, :audio]
49+
force_transcoding?: state.force_transcoding in [true, :audio]
5050
})
5151
|> via_in(Pad.ref(:input, :audio),
5252
options: [encoding: :AAC, segment_duration: Time.milliseconds(2000)]
@@ -57,7 +57,7 @@ defmodule Boombox.HLS do
5757
builder
5858
|> child(:hls_video_transcoder, %Membrane.Transcoder{
5959
output_stream_format: %H264{alignment: :au, stream_structure: :avc3},
60-
enforce_transcoding?: state.enforce_transcoding in [true, :video]
60+
force_transcoding?: state.force_transcoding in [true, :video]
6161
})
6262
|> via_in(Pad.ref(:input, :video),
6363
options: [encoding: :H264, segment_duration: Time.milliseconds(2000)]

lib/boombox/mp4.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ defmodule Boombox.MP4 do
6868
builder
6969
|> child(:mp4_audio_transcoder, %Membrane.Transcoder{
7070
output_stream_format: Membrane.AAC,
71-
enforce_transcoding?: state.enforce_transcoding in [true, :audio]
71+
force_transcoding?: state.force_transcoding in [true, :audio]
7272
})
7373
|> child(:mp4_out_aac_parser, %Membrane.AAC.Parser{
7474
out_encapsulation: :none,
@@ -93,7 +93,7 @@ defmodule Boombox.MP4 do
9393
_not_h26x ->
9494
%H264{stream_structure: :avc3, alignment: :au}
9595
end,
96-
enforce_transcoding?: state.enforce_transcoding in [true, :video]
96+
force_transcoding?: state.force_transcoding in [true, :video]
9797
})
9898
|> via_in(Pad.ref(:input, :video))
9999
|> get_child(:mp4_muxer)

lib/boombox/pipeline.ex

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ defmodule Boombox.Pipeline do
5858
:input,
5959
:output,
6060
:parent,
61-
:enforce_transcoding
61+
:force_transcoding
6262
]
6363

6464
defstruct @enforce_keys ++
@@ -102,7 +102,7 @@ defmodule Boombox.Pipeline do
102102
rtsp_state: Boombox.RTSP.state() | nil,
103103
parent: pid(),
104104
output_webrtc_state: Boombox.WebRTC.output_webrtc_state() | nil,
105-
enforce_transcoding: Boombox.enforce_transcoding_value()
105+
force_transcoding: Boombox.force_transcoding_value()
106106
}
107107
end
108108

@@ -112,7 +112,7 @@ defmodule Boombox.Pipeline do
112112
input: opts.input,
113113
output: opts.output,
114114
parent: opts.parent,
115-
enforce_transcoding: opts.enforce_transcoding,
115+
force_transcoding: opts.force_transcoding,
116116
status: :init
117117
}
118118

lib/boombox/rtp.ex

+6-6
Original file line numberDiff line numberDiff line change
@@ -138,35 +138,35 @@ defmodule Boombox.RTP do
138138
Enum.map(track_builders, fn {media_type, builder} ->
139139
track_config = parsed_opts.track_configs[media_type]
140140

141-
{output_stream_format, parser, payloader, enforce_transcoding?} =
141+
{output_stream_format, parser, payloader, force_transcoding?} =
142142
case track_config.encoding_name do
143143
:H264 ->
144144
{%Membrane.H264{stream_structure: :annexb, alignment: :nalu},
145145
%Membrane.H264.Parser{output_stream_structure: :annexb, output_alignment: :nalu},
146-
Membrane.RTP.H264.Payloader, state.enforce_transcoding in [true, :video]}
146+
Membrane.RTP.H264.Payloader, state.force_transcoding in [true, :video]}
147147

148148
:AAC ->
149149
{%Membrane.AAC{encapsulation: :none},
150150
%Membrane.AAC.Parser{out_encapsulation: :none},
151151
%Membrane.RTP.AAC.Payloader{
152152
mode: track_config.encoding_specific_params.aac_bitrate_mode,
153153
frames_per_packet: 1
154-
}, state.enforce_transcoding in [true, :video]}
154+
}, state.force_transcoding in [true, :video]}
155155

156156
:OPUS ->
157157
{Membrane.Opus, %Membrane.Opus.Parser{delimitation: :undelimit},
158-
Membrane.RTP.Opus.Payloader, state.enforce_transcoding in [true, :audio]}
158+
Membrane.RTP.Opus.Payloader, state.force_transcoding in [true, :audio]}
159159

160160
:H265 ->
161161
{%Membrane.H265{stream_structure: :annexb, alignment: :nalu},
162162
%Membrane.H265.Parser{output_stream_structure: :annexb, output_alignment: :nalu},
163-
Membrane.RTP.H265.Payloader, state.enforce_transcoding in [true, :audio]}
163+
Membrane.RTP.H265.Payloader, state.force_transcoding in [true, :audio]}
164164
end
165165

166166
builder
167167
|> child({:rtp_transcoder, media_type}, %Membrane.Transcoder{
168168
output_stream_format: output_stream_format,
169-
enforce_transcoding?: enforce_transcoding?
169+
force_transcoding?: force_transcoding?
170170
})
171171
|> child({:rtp_out_parser, media_type}, parser)
172172
|> child({:rtp_payloader, media_type}, payloader)

lib/boombox/utils/cli.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ defmodule Boombox.Utils.CLI do
2525
vps: {:string, :binary},
2626
whip: {:string, :string},
2727
token: {:string, :string},
28-
enforce_transcoding: {:boolean, :boolean}
28+
force_transcoding: {:boolean, :boolean}
2929
]
3030

3131
@spec parse_argv([String.t()]) ::

lib/boombox/webrtc.ex

+6-6
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ defmodule Boombox.WebRTC do
149149
builder
150150
|> child(:mp4_audio_transcoder, %Membrane.Transcoder{
151151
output_stream_format: Membrane.Opus,
152-
enforce_transcoding?: state.enforce_transcoding in [true, :audio]
152+
force_transcoding?: state.force_transcoding in [true, :audio]
153153
})
154154
|> child(:webrtc_out_audio_realtimer, Membrane.Realtimer)
155155
|> via_in(Pad.ref(:input, tracks.audio), options: [kind: :audio])
@@ -159,7 +159,7 @@ defmodule Boombox.WebRTC do
159159
negotiated_codecs = state.output_webrtc_state.negotiated_video_codecs
160160
vp8_negotiated? = :vp8 in negotiated_codecs
161161
h264_negotiated? = :h264 in negotiated_codecs
162-
enforce_transcoding? = state.enforce_transcoding in [true, :video]
162+
force_transcoding? = state.force_transcoding in [true, :video]
163163

164164
builder
165165
|> child(:webrtc_out_video_realtimer, Membrane.Realtimer)
@@ -169,9 +169,9 @@ defmodule Boombox.WebRTC do
169169
&1,
170170
vp8_negotiated?,
171171
h264_negotiated?,
172-
enforce_transcoding?
172+
force_transcoding?
173173
),
174-
enforce_transcoding?: enforce_transcoding?
174+
force_transcoding?: force_transcoding?
175175
})
176176
|> via_in(Pad.ref(:input, tracks.video), options: [kind: :video])
177177
|> get_child(:webrtc_output)
@@ -185,7 +185,7 @@ defmodule Boombox.WebRTC do
185185
input_stream_format,
186186
vp8_negotiated?,
187187
h264_negotiated?,
188-
false = _enforce_transcoding?
188+
false = _force_transcoding?
189189
) do
190190
case input_stream_format do
191191
%H264{} = h264 when h264_negotiated? ->
@@ -210,7 +210,7 @@ defmodule Boombox.WebRTC do
210210
_input_stream_format,
211211
vp8_negotiated?,
212212
h264_negotiated?,
213-
true = _enforce_transcoding?
213+
true = _force_transcoding?
214214
) do
215215
# if we have to perform transcoding one way or another, we always choose H264 if it is possilbe,
216216
# because H264 Encoder comsumes less CPU than VP8 Encoder

mix.exs

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ defmodule Boombox.Mixfile do
4747
defp deps do
4848
[
4949
{:membrane_core, "~> 1.1"},
50-
{:membrane_transcoder_plugin, "~> 0.1.3"},
50+
# {:membrane_transcoder_plugin, "~> 0.1.3"},
51+
{:membrane_transcoder_plugin,
52+
github: "membraneframework/membrane_transcoder_plugin", branch: "force-transcoding"},
5153
{:membrane_webrtc_plugin, "~> 0.24.0"},
5254
{:membrane_mp4_plugin, "~> 0.35.2"},
5355
{:membrane_realtimer_plugin, "~> 0.9.0"},

0 commit comments

Comments
 (0)