X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fultimate.lua;h=566b465c65c1be8784e4ff258ccc252819752414;hb=4d2991a8d05b23222912fb904b436af5f4d740c2;hp=198ac6457f8a51559a13ea148e44cd7856b199c5;hpb=087accbb6caf2e3e2f42dcd92e7802a601de5503;p=ultimatescore diff --git a/nageru/ultimate.lua b/nageru/ultimate.lua index 198ac64..566b465 100644 --- a/nageru/ultimate.lua +++ b/nageru/ultimate.lua @@ -33,9 +33,9 @@ local INPUT2_SIGNAL_NUM = 2 local INPUT3_SIGNAL_NUM = 3 local INPUT4_SIGNAL_NUM = 4 local INPUT5_SIGNAL_NUM = 5 -local SBS_SIGNAL_NUM = NUM_CAMERAS -local STATIC_SIGNAL_NUM = NUM_CAMERAS + 1 -local VIDEO_SIGNAL_NUM = NUM_CAMERAS + 2 +local VIDEO_SIGNAL_NUM = NUM_CAMERAS +local SBS_SIGNAL_NUM = NUM_CAMERAS + 1 +local STATIC_SIGNAL_NUM = NUM_CAMERAS + 2 -- Preview-only signal showing the current signal with the overlay. -- Not valid for live_signal_num! @@ -61,6 +61,8 @@ local iptv_video = VideoInput.new(futatabi_server, Nageru.VIDEO_FORMAT_YCBCR) iptv_video:change_rate(10.0) local static_image = ImageInput.new(cef_path .. "/nageru/dsn-bg.png") +local first_frame = true +local multiviewer_enabled = false function reload_cef() cef_input:reload() @@ -71,6 +73,10 @@ function disconnect_iptv() iptv_video:disconnect() end +function toggle_multiviewer() + multiviewer_enabled = not multiviewer_enabled +end + -- An overlay with variable alpha. function make_overlay(scene, base) local image = scene:add_input(cef_input) @@ -191,13 +197,12 @@ function make_simple_scene() scene.scene:finalize() return scene end - local simple_scene = make_simple_scene() -- Load all the stinger frames. local stinger_images = {} for idx=0,24 do - local filename = cef_path .. "/stinger/blur" .. string.rep("0", 3 - string.len(tostring(idx))) .. idx .. ".png" + local filename = cef_path .. "/stinger/esk-blur" .. string.rep("0", 3 - string.len(tostring(idx))) .. idx .. ".png" stinger_images[idx] = ImageInput.new(filename) end @@ -222,6 +227,36 @@ local overlay_scene_lq = Scene.new(16, 9) local overlay_scene_lq_input = overlay_scene_lq:add_input(cef_input) overlay_scene_lq:finalize(false) +-- A debugging scene to show a simple multiviewer. HQ only, since there is no preview. +function make_multiview_scene() + local scene = Scene.new(16, 9) + local bg = scene:add_input(ImageInput.new(cef_path .. "/nageru/white.png")) + local mv_width = 1280 / 3 + local mv_height = 720 / 3 + local mv_offset = (720 - mv_height * 2) / 2 + + for input_idx=0,5 do + local input = scene:add_input(input_idx) + + local resize = scene:add_effect(ResizeEffect.new()) + resize:set_int("width", mv_width) + resize:set_int("height", mv_height) + + local padding = scene:add_effect(IntegralPaddingEffect.new()) + padding:set_int("width", 1280) + padding:set_int("height", 720) + padding:set_int("left", (input_idx % 3) * mv_width) + padding:set_int("top", math.floor(input_idx / 3) * mv_height + mv_offset) + + local overlay = scene:add_effect(OverlayEffect.new(), bg, padding) + bg = overlay + end + + scene:finalize(true) + return scene +end +local multiview_scene_hq = make_multiview_scene() + function needs_scale(signals, signal_num, width, height) if signal_num == STATIC_SIGNAL_NUM then -- We assume this is already correctly scaled at load time. @@ -335,13 +370,9 @@ function channel_name(channel) elseif signal_num == INPUT3_SIGNAL_NUM then return "Goal R (" .. get_channel_resolution(signal_num) .. ")" elseif signal_num == INPUT4_SIGNAL_NUM then - return "Commentators (" .. get_channel_resolution(signal_num) .. ")" + return "Ambience (" .. get_channel_resolution(signal_num) .. ")" elseif signal_num == INPUT5_SIGNAL_NUM then - return "Laptop (" .. get_channel_resolution(signal_num) .. ")" - elseif signal_num == SBS_SIGNAL_NUM then - return "Side-by-side" - elseif signal_num == STATIC_SIGNAL_NUM then - return "Static picture" + return "Commentators (" .. get_channel_resolution(signal_num) .. ")" elseif signal_num == VIDEO_SIGNAL_NUM then local res = last_resolution[iptv_video:get_signal_num()] if (not res) or res.last_subtitle == nil then @@ -349,6 +380,10 @@ function channel_name(channel) else return "Futatabi (" .. get_futatabi_status(res.last_subtitle) .. ")" end + elseif signal_num == SBS_SIGNAL_NUM then + return "Side-by-side" + elseif signal_num == STATIC_SIGNAL_NUM then + return "Static picture" elseif signal_num == OVERLAY_SIGNAL_NUM then return "Overlay" end @@ -689,6 +724,25 @@ function fetch_input_resolution(signals, signal_num) return res end +function update_volume() + if Nageru.get_num_audio_buses() < 3 or + Nageru.get_audio_bus_name(2) ~= 'Sound Shark' then + -- We haven't loaded the right audio mapping. + return + end + + if first_frame then + Nageru.set_audio_bus_fader_level_db(2, -math.huge) + first_frame = false + end + + local volume_db = Nageru.get_audio_bus_fader_level_db(2) + if Nageru.get_audio_bus_mute(2) or volume_db < -100.0 then + volume_db = -100.0 + end + cef_input:execute_javascript_async("set_sound_shark_volume_db(" .. volume_db .. ")") +end + local last_rate = 0.0 -- API ENTRY POINT @@ -708,6 +762,10 @@ local last_rate = 0.0 -- want to set (through set_int() etc.). The parameters will be snapshot -- at return time and used during rendering. function get_scene(num, t, width, height, signals) + if num == 0 then + update_volume() + end + local input_resolution = {} for signal_num=0,(NUM_CAMERAS-1) do input_resolution[signal_num] = fetch_input_resolution(signals, signal_num) @@ -730,6 +788,10 @@ function get_scene(num, t, width, height, signals) last_rate = new_rate end + if num == 0 and multiviewer_enabled then -- Live, with debugging on. + return multiview_scene_hq + end + if num == 0 then -- Live. -- See if we're in a transition. finish_transitions(t) @@ -871,7 +933,7 @@ end function prepare_sbs_scene(state, scene, t, transition_type, src_signal, dst_signal, screen_width, screen_height, input_resolution, hq) scene.input0.input:display(0) - scene.input1.input:display(4) + scene.input1.input:display(5) -- Both inputs are the same size (true side-by-side). local pos0 = pos_from_top_left(1280 - 616 - 16, 186, 616, 347, screen_width, screen_height) @@ -1072,5 +1134,6 @@ end ThemeMenu.set( { "Reload overlay", reload_cef }, - { "Disconnect IPTV", disconnect_iptv } + { "Disconnect IPTV", disconnect_iptv }, + { "Toggle multiviewer", toggle_multiviewer } )