@@ -40,7 +40,7 @@ defmodule MyProject.Pipeline do
4040 end
4141
4242 @impl true
43- def handle_child_pad_added ( :source , :output , _ctx , state) do
43+ def handle_child_notification ({ :set_up_tracks , tracks}, _child , _ctx , state) do
4444 hls_config = %Membrane .HTTPAdaptiveStream .SinkBin {
4545 manifest_module: Membrane .HTTPAdaptiveStream .HLS ,
4646 target_window_duration: Membrane .Time .seconds (120 ),
@@ -49,22 +49,26 @@ defmodule MyProject.Pipeline do
4949 }
5050 }
5151
52+ video_track = Enum .find (tracks, & (&1 .type == :video ))
53+
5254 spec = [
5355 get_child (:source )
56+ |> via_out (Pad .ref (:output , video_track.control_path))
5457 |> child (:depayloader , Membrane .H264 .RTP .Depayloader )
5558 |> child (:parser , Membrane .H264 .Parser )
5659 |> child (:decoder , Membrane .H264 .FFmpeg .Decoder )
57- |> child (:segmentation_filter , MyProject .ObjectSegmentationFilter ) # filter talking with the side-car Python OS process running RF-DETR model
60+ # filter talking with the side-car Python OS process running RF-DETR model
61+ |> child (:segmentation_filter , MyProject .ObjectSegmentationFilter )
5862 |> child (:encoder , %Membrane .H264 .FFmpeg .Encoder {preset: :fast })
5963 |> via_in (:input , options: [encoding: :H264 , segment_duration: Membrane .Time .seconds (10 )])
6064 |> child (:hls , hls_config)
6165 ]
6266
63- {[spec: structure ], state}
67+ {[spec: spec ], state}
6468 end
6569
6670 @impl true
67- def handle_child_pad_added ( _child , _pad , _ctx , state), do: {:ok , state}
71+ def handle_child_notification ( _notificaiton , _child , _ctx , state), do: {[] , state}
6872end
6973```
7074
@@ -75,15 +79,25 @@ This allows you to treat the pipeline and its dependencies as a single unit.
7579defmodule MyProject .InfrastructureSupervisor do
7680 use Supervisor
7781
78- def start_link (init_arg ) do
79- Supervisor .start_link (__MODULE__ , init_arg , name: __MODULE__ )
82+ def start_link (args ) do
83+ Supervisor .start_link (__MODULE__ , args , name: __MODULE__ )
8084 end
8185
8286 @impl true
83- def init (rtsp_url ) do
87+ def init (args ) do
8488 children = [
85- {MuonTrap .Daemon , [" python" , [" run_model.py" , " rf-detr-large-2026.pth" ], [log_output: :debug ]], restart: :transient ]}
86- {MyProject .Pipeline , [input_url: rtsp_url], restart: :transient }
89+ %{
90+ id: Pipeline ,
91+ start: {Membrane .Pipeline , :start_link , [MyProject .Pipeline , args[:rtsp_url ]]},
92+ restart: :transient
93+ },
94+ %{
95+ id: SideCar ,
96+ start:
97+ {MuonTrap .Daemon , :start_link ,
98+ [" python" , [" run_model.py" , " rf-detr-large-2026.pth" ], [log_output: :debug ]]},
99+ restart: :transient
100+ }
87101 ]
88102
89103 Supervisor .init (children, strategy: :one_for_all )
0 commit comments