@@ -2,7 +2,6 @@ defmodule Membrane.HLS.Source do
22 use Membrane.Source
33 require Membrane.Pad , as: Pad
44
5- alias ExHLS.Client
65 alias __MODULE__ . ClientGenServer
76
87 alias Membrane . {
@@ -12,14 +11,14 @@ defmodule Membrane.HLS.Source do
1211 }
1312
1413 def_output_pad :video_output ,
15- accepted_format: any_of ( H264 , % RemoteStream { content_type : H264 } ) ,
14+ accepted_format: any_of ( H264 , % RemoteStream { content_format : H264 } ) ,
1615 availability: :on_request ,
1716 max_instances: 1 ,
1817 flow_control: :manual ,
1918 demand_unit: :buffers
2019
2120 def_output_pad :audio_output ,
22- accepted_format: any_of ( AAC , % RemoteStream { content_type : AAC } ) ,
21+ accepted_format: any_of ( AAC , % RemoteStream { content_format : AAC } ) ,
2322 availability: :on_request ,
2423 max_instances: 1 ,
2524 flow_control: :manual ,
@@ -50,8 +49,8 @@ defmodule Membrane.HLS.Source do
5049 :fmp4 -> ExHLS.DemuxingEngine.CMAF
5150 end
5251
53- { :ok , clinet_genserver } = ClientGenServer . start_link ( url , demuxing_engine )
54- % { state | client_genserver: clinet_genserver }
52+ { :ok , clinet_genserver } = ClientGenServer . start_link ( state . url , demuxing_engine )
53+ { [ ] , % { state | client_genserver: clinet_genserver } }
5554 end
5655
5756 @ impl true
@@ -61,7 +60,7 @@ defmodule Membrane.HLS.Source do
6160 end
6261
6362 @ impl true
64- def handle_playing ( _ctx , state ) do
63+ def handle_playing ( ctx , state ) do
6564 if ctx . pads |> map_size ( ) < 2 do
6665 raise "HLS Source requires both audio and video output pads to be present"
6766 end
@@ -70,16 +69,18 @@ defmodule Membrane.HLS.Source do
7069 ClientGenServer . get_tracks_info ( state . client_genserver )
7170 |> Map . values ( )
7271 |> Enum . split_with ( fn
73- % RemoteStream { content_type : AAC } -> true
74- % RemoteStream { content_type : H264 } -> false
72+ % RemoteStream { content_format : AAC } -> true
73+ % RemoteStream { content_format : H264 } -> false
7574 % AAC { } -> true
7675 % H264 { } -> false
7776 end )
7877
79- { [
80- stream_format: { :audio_output , audio_stream_format } ,
81- stream_format: { :video_output , video_stream_format }
82- ] , % { state | client_server: client_server } }
78+ actions = [
79+ stream_format: { state . audio_output . pad_ref , audio_stream_format } ,
80+ stream_format: { state . video_output . pad_ref , video_stream_format }
81+ ]
82+
83+ { actions , state }
8384 end
8485
8586 @ impl true
@@ -107,7 +108,7 @@ defmodule Membrane.HLS.Source do
107108 { [ redemand: state [ pad_name ] . pad_ref ] , state }
108109 end
109110
110- defp pop_buffers ( Pad . ref ( pad_name , _id ) = pad_ref , demand , state ) do
111+ defp pop_buffers ( Pad . ref ( pad_name , _id ) , demand , state ) do
111112 range_upperbound = min ( state [ pad_name ] . qex_size , demand )
112113
113114 if range_upperbound > 0 do
@@ -135,8 +136,8 @@ defmodule Membrane.HLS.Source do
135136 end
136137
137138 defp request_frames ( state ) do
138- [ audio_output: :request_audio , video_output: :request_video ]
139- |> Enum . reduce ( state , fn { pad_name , request_type } , state ->
139+ [ :audio_output , :video_output ]
140+ |> Enum . reduce ( state , fn pad_name , state ->
140141 request_size = state . buffer_size - state [ pad_name ] . qex_size - state [ pad_name ] . requested
141142 :ok = do_request ( state , pad_name , request_size )
142143
@@ -145,7 +146,7 @@ defmodule Membrane.HLS.Source do
145146 end )
146147 end
147148
148- defp do_request ( _state , _pad_name , 0 ) , do: :ok
149+ defp do_request ( _state , _pad_name , request_size ) when request_size < 1 , do: :ok
149150
150151 defp do_request ( state , :audio_output , request_size ) do
151152 1 .. request_size
0 commit comments