Packages
membrane_mpeg_ts_plugin
1.3.1
2.4.9
2.4.8
2.4.7
2.4.6
2.4.5
2.4.4
2.4.3
2.4.2
2.4.1
2.4.0
2.3.18
2.3.17
2.3.16
2.3.15
2.3.14
2.3.12
2.3.11
2.3.10
2.3.9
2.3.8
2.3.7
2.3.6
2.3.5
2.3.4
2.3.3
2.3.2
2.3.1
2.3.0
2.2.1
2.2.0
2.1.5
2.1.4
2.1.3
2.1.2
2.1.1
2.1.0
2.0.2
2.0.1
2.0.0
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.0
1.0.3
1.0.2
1.0.1
1.0.0
MPEG-TS Demuxer that implements the Membrane.Filter behaviour.
Current section
Files
Jump to
Current section
Files
lib/membrane/mpeg/ts/av_demuxer.ex
defmodule Membrane.MPEG.TS.AVDemuxer do
@moduledoc """
Utility module for extracting the first audio and video streams found in the
input TS stream.
"""
use Membrane.Bin
def_input_pad(:input,
accepted_format: Membrane.RemoteStream
)
def_output_pad(:video,
accepted_format: Membrane.RemoteStream
)
def_output_pad(:audio,
accepted_format: Membrane.RemoteStream
)
@impl true
def handle_init(_ctx, _opts) do
spec = [
bin_input(:input)
|> child(:demuxer, Membrane.MPEG.TS.Demuxer),
child({:audio, :funnel}, Membrane.Funnel)
|> bin_output(:audio),
child({:video, :funnel}, Membrane.Funnel)
|> bin_output(:video)
]
{[spec: spec], %{}}
end
@impl true
def handle_child_notification({:mpeg_ts_pmt, pmt}, _element, _context, state) do
audio_stream =
Enum.find_value(pmt.streams, fn {sid, x} ->
if x.stream_type == :AAC, do: sid
end)
video_stream =
Enum.find_value(pmt.streams, fn {sid, x} ->
if x.stream_type == :H264, do: sid
end)
spec = [
get_child(:demuxer)
|> via_out(Pad.ref(:output, {:stream_id, audio_stream}))
|> get_child({:audio, :funnel}),
get_child(:demuxer)
|> via_out(Pad.ref(:output, {:stream_id, video_stream}))
|> get_child({:video, :funnel})
]
{[spec: spec], state}
end
end