Skip to content

Commit

Permalink
address CR
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-hek committed Aug 7, 2024
1 parent 72f56ad commit 8c23f2a
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 42 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ workflows:
build:
jobs:
- elixir/build_test:
cache-version: 3
cache-version: 6
filters: &filters
tags:
only: /v.*/
- elixir/test:
cache-version: 3
cache-version: 6
filters:
<<: *filters
- elixir/lint:
cache-version: 3
cache-version: 6
filters:
<<: *filters
- elixir/hex_publish:
cache-version: 3
cache-version: 6
requires:
- elixir/build_test
- elixir/test
Expand Down
13 changes: 8 additions & 5 deletions lib/boombox/mp4.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ defmodule Boombox.MP4 do
spec =
get_child(:mp4_demuxer)
|> via_out(Pad.ref(:output, id))
|> child(Membrane.AAC.Parser)
|> child(:aac_decoder, Membrane.AAC.FDK.Decoder)
|> child(:mp4_in_aac_parser, Membrane.AAC.Parser)
|> child(:mp4_in_aac_decoder, Membrane.AAC.FDK.Decoder)

{:audio, spec}

Expand All @@ -49,14 +49,17 @@ defmodule Boombox.MP4 do
Enum.map(track_builders, fn
{:audio, builder} ->
builder
|> child(Membrane.AAC.FDK.Encoder)
|> child(%Membrane.AAC.Parser{out_encapsulation: :none, output_config: :esds})
|> child(:mp4_out_aac_encoder, Membrane.AAC.FDK.Encoder)
|> child(:mp4_out_aac_parser, %Membrane.AAC.Parser{
out_encapsulation: :none,
output_config: :esds
})
|> via_in(Pad.ref(:input, :audio))
|> get_child(:mp4_muxer)

{:video, builder} ->
builder
|> child(%Membrane.H264.Parser{output_stream_structure: :avc3})
|> child(:mp4_out_h264_parser, %Membrane.H264.Parser{output_stream_structure: :avc3})
|> via_in(Pad.ref(:input, :video))
|> get_child(:mp4_muxer)
end)
Expand Down
15 changes: 13 additions & 2 deletions lib/boombox/pipeline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ defmodule Boombox.Pipeline do

use Membrane.Pipeline

require Membrane.Logger

@type track_builders :: %{
optional(:audio) => Membrane.ChildrenSpec.t(),
optional(:video) => Membrane.ChildrenSpec.t()
Expand Down Expand Up @@ -115,7 +117,12 @@ defmodule Boombox.Pipeline do

@impl true
def handle_child_notification({:new_tracks, tracks}, :webrtc_output, ctx, state) do
%{status: :awaiting_output_link} = state
unless state.status == :awaiting_output_link do
raise """
Invalid status: #{inspect(state.status)}, expected :awaiting_output_link. \
This is probably a bug in Boombox.
"""
end

Boombox.WebRTC.handle_output_tracks_negotiated(
state.track_builders,
Expand All @@ -140,7 +147,11 @@ defmodule Boombox.Pipeline do
end

@impl true
def handle_child_notification(_notification, _child, _ctx, state) do
def handle_child_notification(notification, child, _ctx, state) do
Membrane.Logger.debug_verbose(
"Ignoring notification #{inspect(notification)} from child #{inspect(child)}"
)

{[], state}
end

Expand Down
6 changes: 3 additions & 3 deletions lib/boombox/rtmp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ defmodule Boombox.RTMP do
spec = [
child(:rtmp_source, %Membrane.RTMP.SourceBin{client_ref: client_ref})
|> via_out(:audio)
|> child(Membrane.AAC.Parser)
|> child(:aac_decoder, Membrane.AAC.FDK.Decoder)
|> child(:rtmp_in_aac_parser, Membrane.AAC.Parser)
|> child(:rtmp_in_aac_decoder, Membrane.AAC.FDK.Decoder)
]

track_builders = %{
audio: get_child(:aac_decoder),
audio: get_child(:rtmp_in_aac_decoder),
video: get_child(:rtmp_source) |> via_out(:video)
}

Expand Down
12 changes: 6 additions & 6 deletions lib/boombox/webrtc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule Boombox.WebRTC do
spec =
get_child(:webrtc_input)
|> via_out(Pad.ref(:output, id))
|> child(:opus_decoder, Membrane.Opus.Decoder)
|> child(:webrtc_in_opus_decoder, Membrane.Opus.Decoder)

{:audio, spec}

Expand Down Expand Up @@ -74,22 +74,22 @@ defmodule Boombox.WebRTC do
Enum.map(track_builders, fn
{:audio, builder} ->
builder
|> child(%Membrane.FFmpeg.SWResample.Converter{
|> child(:webrtc_out_resampler, %Membrane.FFmpeg.SWResample.Converter{
output_stream_format: %Membrane.RawAudio{
sample_format: :s16le,
sample_rate: 48_000,
channels: 2
}
})
|> child(Membrane.Opus.Encoder)
|> child(Membrane.Realtimer)
|> child(:webrtc_out_opus_encoder, Membrane.Opus.Encoder)
|> child(:webrtc_out_audio_realtimer, Membrane.Realtimer)
|> via_in(Pad.ref(:input, tracks.audio), options: [kind: :audio])
|> get_child(:webrtc_output)

{:video, builder} ->
builder
|> child(Membrane.Realtimer)
|> child(%Membrane.H264.Parser{
|> child(:webrtc_out_video_realtimer, Membrane.Realtimer)
|> child(:webrtc_out_h264_parser, %Membrane.H264.Parser{
output_stream_structure: :annexb,
output_alignment: :nalu
})
Expand Down
19 changes: 9 additions & 10 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,17 @@ defmodule Boombox.Mixfile do

defp deps do
[
{:membrane_core, "~> 1.0"},
{:membrane_webrtc_plugin, "~> 0.20.0"},
{:membrane_opus_plugin, ">= 0.0.0"},
{:membrane_aac_plugin, ">= 0.0.0"},
{:membrane_aac_fdk_plugin, ">= 0.0.0"},
{:membrane_h26x_plugin, ">= 0.0.0"},
{:membrane_h264_ffmpeg_plugin, ">= 0.0.0"},
{:membrane_core, "~> 1.1"},
{:membrane_webrtc_plugin, "~> 0.21.0"},
{:membrane_opus_plugin, "~> 0.20.0"},
{:membrane_aac_plugin, "~> 0.18.0"},
{:membrane_aac_fdk_plugin, "~> 0.18.0"},
{:membrane_h26x_plugin, "~> 0.10.0"},
{:membrane_h264_ffmpeg_plugin, "~> 0.32.0"},
{:membrane_mp4_plugin, github: "membraneframework/membrane_mp4_plugin", branch: "wip-avc3"},
{:membrane_realtimer_plugin, ">= 0.0.0"},
# {:membrane_rtmp_plugin, ">= 0.0.0"},
{:membrane_realtimer_plugin, "~> 0.9.0"},
{:membrane_rtmp_plugin, github: "membraneframework/membrane_rtmp_plugin"},
{:membrane_ffmpeg_swresample_plugin, ">= 0.0.0"},
{:membrane_ffmpeg_swresample_plugin, "~> 0.20.0"},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:dialyxir, ">= 0.0.0", only: :dev, runtime: false},
{:credo, ">= 0.0.0", only: :dev, runtime: false}
Expand Down
Loading

0 comments on commit 8c23f2a

Please sign in to comment.