Current section

Files

Jump to
membrane_rtsp_plugin lib membrane_rtsp_plugin.ex
Raw

lib/membrane_rtsp_plugin.ex

defmodule MembraneRtspPlugin do
@moduledoc false
use Membrane.Pipeline
def start(options) do
Pipeline.start(__MODULE__, options)
end
@impl true
def handle_init(_ctx, _opts) do
spec = [
child(:source, %Membrane.RTSP.Source{
transport: :tcp,
allowed_media_types: [:video],
# stream_uri: "rtsp://admin:Permanex1@wg9.evercam.io:20317/main"
# stream_uri: "rtsp://root:Mehcam4Mehcam@wg7.evercam.io:22564/onvif-media/media.amp"
stream_uri: "rtsp://admin:Mehcam4Mehcam@10.42.0.100:554/ISAPI/Streaming/channels/101"
# stream_uri: "rtsp://admin:Mehcam4Mehcam@wg2.evercam.io:20109/ISAPI/Streaming/channels/101"
})
]
{[spec: spec], %{}}
end
def handle_child_notification({:new_track, ssrc, _track}, _element, _ctx, state) do
spec = [
get_child(:source)
|> via_out(Pad.ref(:output, ssrc))
# |> child({:funnel, ssrc}, Membrane.Funnel)
|> child({:sink, ssrc}, %Membrane.Debug.Sink{
handle_event: &IO.inspect/1,
handle_stream_format: &IO.inspect/1,
handle_buffer: &IO.inspect(&1.pts)
})
]
{[spec: spec], state}
end
@impl true
def handle_child_notification(_message, _element, _ctx, state) do
{[], state}
end
@impl true
def handle_child_pad_removed(:source, _pad, _ctx, state) do
{[], state}
end
end