feat: Add stream management functions for scheduling, canceling, and rendering scenes and schedules

This commit is contained in:
2025-12-30 11:26:05 +00:00
parent 5e3d778223
commit d90dab645c
7 changed files with 102 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
--- Cancel a scheduled stream
---@param stream_id string Stream ID to cancel
---@return CancelStreamAction Cancel stream action
local function cancel_stream(stream_id)
return {
action = "cancel_stream",
stream_id = stream_id
}
end
return cancel_stream

View File

@@ -0,0 +1,15 @@
--- Create a new scene
---@param name string Scene name
---@param sources? table[] Scene sources
---@return CreateSceneAction Create scene action
local function create_scene(name, sources)
return {
action = "create_scene",
data = {
name = name,
sources = sources or {}
}
}
end
return create_scene

View File

@@ -0,0 +1,17 @@
local render_scene = require("render_scene")
--- Render list of scenes
---@param scenes Scene[] Array of scenes
---@return SceneListComponent Scene list component
local function render_scene_list(scenes)
local items = {}
for _, scene in ipairs(scenes) do
table.insert(items, render_scene(scene))
end
return {
type = "scene_list",
children = items
}
end
return render_scene_list

View File

@@ -0,0 +1,16 @@
--- Render a schedule item
---@param stream ScheduledStream Scheduled stream data
---@return ScheduleItemComponent Schedule item component
local function render_schedule_item(stream)
return {
type = "schedule_item",
props = {
title = stream.title,
start_time = stream.start_time,
duration = stream.duration,
thumbnail = stream.thumbnail
}
}
end
return render_schedule_item

View File

@@ -0,0 +1,17 @@
local render_schedule_item = require("render_schedule_item")
--- Render schedule list
---@param streams ScheduledStream[] Array of scheduled streams
---@return ScheduleListComponent Schedule list component
local function render_schedule_list(streams)
local items = {}
for _, stream in ipairs(streams) do
table.insert(items, render_schedule_item(stream))
end
return {
type = "schedule_list",
children = items
}
end
return render_schedule_list

View File

@@ -0,0 +1,15 @@
--- Schedule a new stream
---@param data { title: string, start_time: string, duration?: number } Schedule data
---@return ScheduleStreamAction Schedule stream action
local function schedule_stream(data)
return {
action = "schedule_stream",
data = {
title = data.title,
start_time = data.start_time,
duration = data.duration or 60
}
}
end
return schedule_stream

View File

@@ -0,0 +1,11 @@
--- Switch to a scene
---@param scene_id string Scene ID to switch to
---@return SwitchSceneAction Switch scene action
local function switch_scene(scene_id)
return {
action = "switch_scene",
scene_id = scene_id
}
end
return switch_scene