@@ -27,6 +27,20 @@ defmodule MyProject.Pipeline do
2727
2828 @impl true
2929 def handle_init (_ctx , rtsp_url) do
30+ spec = [
31+ child (:source , %Membrane .RTSP .Source {
32+ transport: :tcp ,
33+ allowed_media_types: [:video ],
34+ stream_uri: rtsp_url,
35+ on_connection_closed: :send_eos
36+ })
37+ ]
38+
39+ {[spec: spec], %{}}
40+ end
41+
42+ @impl true
43+ def handle_child_pad_added (:source , :output , _ctx , state) do
3044 hls_config = %Membrane .HTTPAdaptiveStream .SinkBin {
3145 manifest_module: Membrane .HTTPAdaptiveStream .HLS ,
3246 target_window_duration: Membrane .Time .seconds (120 ),
@@ -36,12 +50,7 @@ defmodule MyProject.Pipeline do
3650 }
3751
3852 spec = [
39- child (:source , %Membrane .RTSP .Source {
40- transport: :tcp ,
41- allowed_media_types: [:video ],
42- stream_uri: rtsp_url,
43- on_connection_closed: :send_eos
44- })
53+ get_child (:source )
4554 |> child (:depayloader , Membrane .H264 .RTP .Depayloader )
4655 |> child (:parser , Membrane .H264 .Parser )
4756 |> child (:decoder , Membrane .H264 .FFmpeg .Decoder )
@@ -51,8 +60,11 @@ defmodule MyProject.Pipeline do
5160 |> child (:hls , hls_config)
5261 ]
5362
54- {[spec: spec ], %{} }
63+ {[spec: structure ], state }
5564 end
65+
66+ @impl true
67+ def handle_child_pad_added (_child , _pad , _ctx , state), do: {:ok , state}
5668end
5769```
5870
0 commit comments