liquidsoap icon indicating copy to clipboard operation
liquidsoap copied to clipboard

liq-2.1.4 - good way to try fallback in order at startup ?

Open YoannQueret opened this issue 1 year ago • 0 comments

Hi,

I try to have 2 or more stream sources as backup.

I need to have 2 or more sources (as backup) and retreive via a socket the current input currently used.

1 - Problem with fallback at startup At startup the fallback always start by the end :

  • switch on blank
  • switch on input2
  • switch on input1
2023/08/24 21:31:07 [clock.main:3] Streaming loop starts in auto-sync mode
2023/08/24 21:31:07 [clock.main:3] Delegating synchronisation to CPU clock
2023/08/24 21:31:07 [fallback:3] Switch to blank.
2023/08/24 21:31:08 [video.text:3] Using gstreamer implementation
2023/08/24 21:31:08 [fallback:3] Switch to fallback_input2 with transition.
2023/08/24 21:31:08 [lang:3] SWITCH from  to http://127.0.0.2:8000/stream2 
2023/08/24 21:31:10 [fallback:3] Switch to fallback_input1 with transition.
2023/08/24 21:31:10 [lang:3] SWITCH from http://127.0.0.2:8000/stream2 to  
2023/08/24 21:31:10 [lang:3] SWITCH from  to http://127.0.0.1:8000/stream1
[...]
2023/08/24 21:33:30 [lang:3] SWITCH from http://127.0.0.1:8000/stream1 to http://127.0.0.2:8000/stream2

Probably because i use 2 input stream and liquidsoap need time to connect and process ? is there a way to "wait" or an other method ?

2 - what is the best way to retreive the fallback status to known the input currently running ? i try with comparaison of source_url, but i'm pretty sure there have a better solution

Below my liq test :

source1 = input.http(
	id="input_1",
	poll_delay=5.,
	"http://127.0.0.1:8000/stream1" 
)
source2 = input.http(
	id="input_2",
	poll_delay=5.,
	"http://127.0.0.2:8000/stream2" 
)

source = fallback(
	id="fallback",
	track_sensitive=false,
	replay_metadata=true,
	[
		blank.strip(id="fallback_input1", track_sensitive=false, max_blank=10., min_noise=30., threshold=-40., source1),
		blank.strip(id="fallback_input2", track_sensitive=false, max_blank=10., min_noise=30., threshold=-40., source2),
		blank(id="blank")
	]
)

last_source = ref("")

def fallback_source_change(m) =
	current_source = m['source_url']
	if current_source != !last_source then
		log("SWITCH from #{!last_source} to #{current_source} ")
		last_source := m['source_url']
	end
	
end
source.on_track(fallback_source_change)

YoannQueret avatar Aug 24 '23 19:08 YoannQueret