mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-02-26 20:33:53 +01:00
lot of new apis
This commit is contained in:
83
plugin.lua
83
plugin.lua
@@ -41,51 +41,51 @@ function set_rds_slc_data(slc_data) end
|
||||
---@return integer
|
||||
function get_rds_slc_data() end
|
||||
|
||||
---@param ct integer 0 or 1
|
||||
---@param ct boolean
|
||||
function set_rds_ct(ct) end
|
||||
---@return integer
|
||||
---@return boolean
|
||||
function get_rds_ct() end
|
||||
|
||||
---@param dpty integer 0 or 1
|
||||
---@param dpty boolean
|
||||
function set_rds_dpty(dpty) end
|
||||
---@return integer
|
||||
---@return boolean
|
||||
function get_rds_dpty() end
|
||||
|
||||
---@param tp integer 0 or 1
|
||||
---@param tp boolean
|
||||
function set_rds_tp(tp) end
|
||||
---@return integer
|
||||
---@return boolean
|
||||
function get_rds_tp() end
|
||||
|
||||
---@param ta integer 0 or 1
|
||||
---@param ta boolean
|
||||
function set_rds_ta(ta) end
|
||||
---@return integer
|
||||
---@return boolean
|
||||
function get_rds_ta() end
|
||||
|
||||
-- Feature Flags
|
||||
---@param enabled integer 0 or 1
|
||||
---@param enabled boolean
|
||||
function set_rds_rt1_enabled(enabled) end
|
||||
---@return integer
|
||||
---@return boolean
|
||||
function get_rds_rt1_enabled() end
|
||||
|
||||
---@param enabled integer 0 or 1
|
||||
---@param enabled boolean
|
||||
function set_rds_rt2_enabled(enabled) end
|
||||
---@return integer
|
||||
---@return boolean
|
||||
function get_rds_rt2_enabled() end
|
||||
|
||||
---@param enabled integer 0 or 1
|
||||
---@param enabled boolean
|
||||
function set_rds_ptyn_enabled(enabled) end
|
||||
---@return integer
|
||||
---@return boolean
|
||||
function get_rds_ptyn_enabled() end
|
||||
|
||||
---@param rt_type integer 0 (RT A/B) or 1 (RT C)
|
||||
---@param rt_type boolean
|
||||
function set_rds_rt_type(rt_type) end
|
||||
---@return integer
|
||||
---@return boolean
|
||||
function get_rds_rt_type() end
|
||||
|
||||
-- Modulation & Generation
|
||||
---@param mode integer
|
||||
---@param mode boolean
|
||||
function set_rds_rds2mod(mode) end
|
||||
---@return integer
|
||||
---@return boolean
|
||||
function get_rds_rds2mod() end
|
||||
|
||||
---@param rdsgen integer
|
||||
@@ -99,9 +99,9 @@ function set_rds_level(level) end
|
||||
function get_rds_level() end
|
||||
|
||||
-- Program & Linking
|
||||
---@param linkage integer
|
||||
---@param linkage boolean
|
||||
function set_rds_link(linkage) end
|
||||
---@return integer
|
||||
---@return boolean
|
||||
function get_rds_link() end
|
||||
|
||||
---@param program_idx integer 0 to (max_programs - 1)
|
||||
@@ -125,7 +125,7 @@ function get_rds_rt_text_timeout() end
|
||||
function set_rds_ptyn(ptyn) end
|
||||
---@param ps string Program Service (8 chars)
|
||||
function set_rds_ps(ps) end
|
||||
---@param tps string Text PS (Scrolling PS)
|
||||
---@param tps string Traffic PS
|
||||
function set_rds_tps(tps) end
|
||||
---@param rt1 string Radio Text 1 (max 64 chars)
|
||||
function set_rds_rt1(rt1) end
|
||||
@@ -137,45 +137,36 @@ function set_rds_lps(lps) end
|
||||
---@return string
|
||||
function get_rds_lps() end
|
||||
|
||||
---@param ert string
|
||||
function set_rds_ert(ert) end
|
||||
---@return string
|
||||
function get_rds_ert() end
|
||||
|
||||
---@param grpseq string
|
||||
function set_rds_grpseq(grpseq) end
|
||||
---@return string
|
||||
function get_rds_grpseq() end
|
||||
|
||||
|
||||
function set_rds_grpseq2(grpseq) end
|
||||
---@param grpseq2 string
|
||||
function set_rds_grpseq2(grpseq2) end
|
||||
---@return string
|
||||
function get_rds_grpseq2() end
|
||||
|
||||
-- RT Plus Tags
|
||||
---Sets RT+ tags: type1, start1, len1, type2, start2, len2
|
||||
---@param ertp boolean
|
||||
---@param t1 integer
|
||||
---@param s1 integer
|
||||
---@param l1 integer
|
||||
---@param t2 integer
|
||||
---@param s2 integer
|
||||
---@param l2 integer
|
||||
function set_rds_rtplus_tags(t1, s1, l1, t2, s2, l2) end
|
||||
function set_rds_rtplus_tags(ertp, t1, s1, l1, t2, s2, l2) end
|
||||
|
||||
---Gets RT+ tags: type1, start1, len1, type2, start2, len2
|
||||
---@return integer, integer, integer, integer, integer, integer
|
||||
function get_rds_rtplus_tags() end
|
||||
|
||||
---Sets eRT+ tags: type1, start1, len1, type2, start2, len2
|
||||
---@param t1 integer
|
||||
---@param s1 integer
|
||||
---@param l1 integer
|
||||
---@param t2 integer
|
||||
---@param s2 integer
|
||||
---@param l2 integer
|
||||
function set_rds_ertplus_tags(t1, s1, l1, t2, s2, l2) end
|
||||
|
||||
---Gets eRT+ tags: type1, start1, len1, type2, start2, len2
|
||||
---@return integer, integer, integer, integer, integer, integer
|
||||
function get_rds_ertplus_tags() end
|
||||
---@param ertp boolean
|
||||
---@return integer type1, integer start1, integer len1, integer type2, integer start2, integer len2
|
||||
function get_rds_rtplus_tags(ertp) end
|
||||
|
||||
---Puts in a RDS1 group in the buffer, note that block A is filled in always
|
||||
---@param b integer
|
||||
@@ -189,3 +180,17 @@ function put_rds_custom_group(b, c, d) end
|
||||
---@param c integer
|
||||
---@param d integer
|
||||
function put_rds2_custom_group(a, b, c, d) end
|
||||
|
||||
---Toggles RTP or ERTP's toggle switch
|
||||
---@param ertp boolean
|
||||
function toggle_rds_rtp(ertp) end
|
||||
|
||||
---Sets the metadata of RTP or ERTP
|
||||
---@param ertp boolean
|
||||
---@param enabled boolean
|
||||
---@param running boolean
|
||||
function set_rds_rtp_meta(ertp, enabled, running) end
|
||||
---Gets the metadata of RTP and ERTP
|
||||
---@param ertp boolean
|
||||
---@return boolean enabled, boolean running
|
||||
function get_rds_rtp_meta(ertp) end
|
||||
@@ -145,24 +145,6 @@ static void handle_site(char *arg, RDSModulator* mod, char* output) {
|
||||
strcpy(output, "+");
|
||||
}
|
||||
|
||||
static void handle_rtprun(char *arg, RDSModulator *mod, char *output) {
|
||||
int flag1 = 0, flag2 = 0;
|
||||
if (sscanf(arg, "%d,%d", &flag1, &flag2) < 1) flag1 = atoi(arg);
|
||||
mod->enc->rtpData[mod->enc->program][0].enabled = (flag1 == 2);
|
||||
mod->enc->rtpData[mod->enc->program][0].running = flag1 & 1;
|
||||
if (flag2) TOGGLE(mod->enc->rtpState[mod->enc->program][0].toggle);
|
||||
strcpy(output, "+");
|
||||
}
|
||||
|
||||
static void handle_ertprun(char *arg, RDSModulator* mod, char* output) {
|
||||
int flag1 = 0, flag2 = 0;
|
||||
if (sscanf(arg, "%d,%d", &flag1, &flag2) < 1) flag1 = atoi(arg);
|
||||
mod->enc->rtpData[mod->enc->program][1].enabled = (flag1 == 2);
|
||||
mod->enc->rtpData[mod->enc->program][1].running = flag1 & 1;
|
||||
if (flag2) TOGGLE(mod->enc->rtpState[mod->enc->program][1].toggle);
|
||||
strcpy(output, "+");
|
||||
}
|
||||
|
||||
static void handle_eonen(char *arg, char *pattern, RDSModulator* mod, char* output) {
|
||||
mod->enc->data[mod->enc->program].eon[atoi(pattern)-1].enabled = atoi(arg);
|
||||
strcpy(output, "+");
|
||||
@@ -257,14 +239,6 @@ static const command_handler_t commands_eq5[] = {
|
||||
{"SITE", handle_site, 4}
|
||||
};
|
||||
|
||||
static const command_handler_t commands_eq7[] = {
|
||||
{"RTPRUN", handle_rtprun, 6},
|
||||
};
|
||||
|
||||
static const command_handler_t commands_eq8[] = {
|
||||
{"ERTPRUN", handle_ertprun, 7},
|
||||
};
|
||||
|
||||
static const pattern_command_handler_t pattern_commands[] = {
|
||||
{"EON", "EN", handle_eonen},
|
||||
{"EON", "PI", handle_eonpi},
|
||||
@@ -378,14 +352,6 @@ void process_ascii_cmd(RDSModulator* mod, char *str, char *cmd_output) {
|
||||
table = commands_eq5;
|
||||
table_size = sizeof(commands_eq5) / sizeof(command_handler_t);
|
||||
break;
|
||||
case 6:
|
||||
table = commands_eq7;
|
||||
table_size = sizeof(commands_eq7) / sizeof(command_handler_t);
|
||||
break;
|
||||
case 7:
|
||||
table = commands_eq8;
|
||||
table_size = sizeof(commands_eq8) / sizeof(command_handler_t);
|
||||
break;
|
||||
}
|
||||
|
||||
process_command_table(table, table_size, cmd, arg, output, mod);
|
||||
|
||||
@@ -14,16 +14,32 @@ if type(data) == "string" and data ~= nil then
|
||||
elseif data == "pty" then return string.format("PTY=%s\r\n", string.format("%d", get_rds_pty()))
|
||||
elseif data == "ecc" then return string.format("ECC=%s\r\n", string.format("%x", get_rds_ecc()))
|
||||
elseif data == "slcd" then return string.format("SLCD=%s\r\n", string.format("%x", get_rds_slc_data()))
|
||||
elseif data == "ct" then return string.format("CT=%s\r\n", string.format("%d", get_rds_ct()))
|
||||
elseif data == "dpty" then return string.format("DPTY=%s\r\n", string.format("%d", get_rds_dpty()))
|
||||
elseif data == "tp" then return string.format("TP=%s\r\n", string.format("%d", get_rds_tp()))
|
||||
elseif data == "ta" then return string.format("TA=%s\r\n", string.format("%d", get_rds_ta()))
|
||||
elseif data == "ct" then return string.format("CT=%s\r\n", string.format("%d", (get_rds_ct() and 1 or 0)))
|
||||
elseif data == "dpty" then return string.format("DPTY=%s\r\n", string.format("%d", (get_rds_dpty() and 1 or 0)))
|
||||
elseif data == "tp" then return string.format("TP=%s\r\n", string.format("%d", (get_rds_tp() and 1 or 0)))
|
||||
elseif data == "ta" then return string.format("TA=%s\r\n", string.format("%d", (get_rds_ta() and 1 or 0)))
|
||||
elseif data == "rt1en" then return string.format("RT1EN=%s\r\n", string.format("%d", (get_rds_rt1_enabled() and 1 or 0)))
|
||||
elseif data == "rt2en" then return string.format("RT2EN=%s\r\n", string.format("%d", (get_rds_rt2_enabled() and 1 or 0)))
|
||||
elseif data == "ptynen" then return string.format("PTYNEN=%s\r\n", string.format("%d", (get_rds_ptyn_enabled() and 1 or 0)))
|
||||
elseif data == "rttype" then return string.format("RTTYPE=%s\r\n", string.format("%d", (get_rds_rt_type() and 1 or 0)))
|
||||
elseif data == "rds2mod" then return string.format("RDS2MOD=%s\r\n", string.format("%d", (get_rds_rds2mod() and 1 or 0)))
|
||||
elseif data == "rdsgen" then return string.format("RDSGEN=%s\r\n", string.format("%d",get_rds_rdsgen()))
|
||||
elseif data == "level" then return string.format("LEVEL=%s\r\n", string.format("%d", get_rds_level() * 255))
|
||||
elseif data == "link" then return string.format("LINK=%s\r\n", string.format("%d", (get_rds_link() and 1 or 0)))
|
||||
elseif data == "rtp" then
|
||||
local t1, s1, l1, t2, s2, l2 = get_rds_rtplus_tags()
|
||||
local t1, s1, l1, t2, s2, l2 = get_rds_rtplus_tags(false)
|
||||
return string.format("RTP=%d,%d,%d,%d,%d,%d\r\n", t1, s1, l1, t2, s2, l2)
|
||||
elseif data == "ertp" then
|
||||
local t1, s1, l1, t2, s2, l2 = get_rds_ertplus_tags()
|
||||
local t1, s1, l1, t2, s2, l2 = get_rds_rtplus_tags(true)
|
||||
return string.format("ERTP=%d,%d,%d,%d,%d,%d\r\n", t1, s1, l1, t2, s2, l2)
|
||||
elseif data == "rtprun" then
|
||||
local enabled, running = get_rds_rtp_meta(false)
|
||||
local f1 = enabled and 2 or (running and 1 or 0)
|
||||
return string.format("RTPRUN=%d\r\n", f1)
|
||||
elseif data == "ertprun" then
|
||||
local enabled, running = get_rds_rtp_meta(true)
|
||||
local f1 = enabled and 2 or (running and 1 or 0)
|
||||
return string.format("ERTPRUN=%d\r\n", f1)
|
||||
else return "?" end
|
||||
-- TODO: more
|
||||
end
|
||||
@@ -52,47 +68,47 @@ if type(data) == "string" and data ~= nil then
|
||||
elseif cmd == "ct" then
|
||||
local ct = tonumber(value)
|
||||
if not ct then return "-" end
|
||||
set_rds_ct(ct)
|
||||
set_rds_ct(ct ~= 0)
|
||||
return "+"
|
||||
elseif cmd == "dpty" then
|
||||
local dpty = tonumber(value)
|
||||
if not dpty then return "-" end
|
||||
set_rds_dpty(dpty)
|
||||
set_rds_dpty(dpty ~= 0)
|
||||
return "+"
|
||||
elseif cmd == "tp" then
|
||||
local tp = tonumber(value)
|
||||
if not tp then return "-" end
|
||||
set_rds_tp(tp)
|
||||
set_rds_tp(tp ~= 0)
|
||||
return "+"
|
||||
elseif cmd == "ta" then
|
||||
local ta = tonumber(value)
|
||||
if not ta then return "-" end
|
||||
set_rds_ta(ta)
|
||||
set_rds_ta(ta ~= 0)
|
||||
return "+"
|
||||
elseif cmd == "rt1en" then
|
||||
local en = tonumber(value)
|
||||
if not en then return "-" end
|
||||
set_rds_rt1_enabled(en)
|
||||
set_rds_rt1_enabled(en ~= 0)
|
||||
return "+"
|
||||
elseif cmd == "rt2en" then
|
||||
local en = tonumber(value)
|
||||
if not en then return "-" end
|
||||
set_rds_rt2_enabled(en)
|
||||
set_rds_rt2_enabled(en ~= 0)
|
||||
return "+"
|
||||
elseif cmd == "ptynen" then
|
||||
local en = tonumber(value)
|
||||
if not en then return "-" end
|
||||
set_rds_ptyn_enabled(en)
|
||||
set_rds_ptyn_enabled(en ~= 0)
|
||||
return "+"
|
||||
elseif cmd == "rttype" then
|
||||
local type = tonumber(value)
|
||||
if not type then return "-" end
|
||||
set_rds_rt_type(type)
|
||||
set_rds_rt_type(type ~= 0)
|
||||
return "+"
|
||||
elseif cmd == "rds2mod" then
|
||||
local type = tonumber(value)
|
||||
if not type then return "-" end
|
||||
set_rds_rds2mod(type)
|
||||
set_rds_rds2mod(type ~= 0)
|
||||
return "+"
|
||||
elseif cmd == "rdsgen" then
|
||||
local type = tonumber(value)
|
||||
@@ -123,7 +139,7 @@ if type(data) == "string" and data ~= nil then
|
||||
elseif cmd == "link" then
|
||||
local link = tonumber(value)
|
||||
if not link then return "-" end
|
||||
set_rds_link(link)
|
||||
set_rds_link(link ~= 0)
|
||||
return "+"
|
||||
elseif cmd == "rtper" then
|
||||
local period = tonumber(value)
|
||||
@@ -152,18 +168,16 @@ if type(data) == "string" and data ~= nil then
|
||||
elseif cmd == "grpseq2" then
|
||||
set_rds_grpseq2(value)
|
||||
return "+"
|
||||
elseif cmd == "rtp" then
|
||||
elseif cmd == "rtp" or cmd == "ertp" then
|
||||
local is_ertp = (cmd == "ertp")
|
||||
local t1, s1, l1, t2, s2, l2 = value:match("(%d+),(%d+),(%d+),(%d+),(%d+),(%d+)")
|
||||
if not t1 or not l2 then return "-" end
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
set_rds_rtplus_tags(tonumber(t1), tonumber(s1), tonumber(l1), tonumber(t2), tonumber(s2), tonumber(l2))
|
||||
return "+"
|
||||
|
||||
elseif cmd == "ertp" then
|
||||
local t1, s1, l1, t2, s2, l2 = value:match("(%d+),(%d+),(%d+),(%d+),(%d+),(%d+)")
|
||||
if not t1 or not l2 then return "-" end
|
||||
if not l2 then return "-" end
|
||||
set_rds_rtplus_tags(
|
||||
is_ertp,
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
set_rds_ertplus_tags(tonumber(t1), tonumber(s1), tonumber(l1), tonumber(t2), tonumber(s2), tonumber(l2))
|
||||
tonumber(t1), tonumber(s1), tonumber(l1), tonumber(t2), tonumber(s2), tonumber(l2)
|
||||
)
|
||||
return "+"
|
||||
elseif cmd == "g" then
|
||||
local a, b, c, d = value:match("^(%x%x%x%x)(%x%x%x%x)(%x%x%x%x)(%x%x%x%x)$")
|
||||
@@ -179,6 +193,20 @@ if type(data) == "string" and data ~= nil then
|
||||
end
|
||||
|
||||
return "-"
|
||||
elseif cmd == "rtprun" or cmd == "ertprun" then
|
||||
local is_ertp = (cmd == "ertprun")
|
||||
|
||||
local f1_str, f2_str = value:match("([^,]+),?([^,]*)")
|
||||
if not f1_str then return "-" end
|
||||
|
||||
local f1 = tonumber(f1_str) or 0
|
||||
local f2 = tonumber(f2_str) or 0
|
||||
local enabled = (f1 == 2)
|
||||
local running = (f1 & 1) ~= 0
|
||||
|
||||
set_rds_rtp_meta(is_ertp, enabled, running)
|
||||
if f2 ~= 0 then toggle_rds_rtp(is_ertp) end
|
||||
return "+"
|
||||
else
|
||||
return "?"
|
||||
end
|
||||
|
||||
133
src/lua_rds.c
133
src/lua_rds.c
@@ -20,6 +20,12 @@ int lua_reset_rds(lua_State *localL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define BOOL_SETTER(name) \
|
||||
int lua_set_rds_##name(lua_State *localL) { \
|
||||
if (!lua_isboolean(localL, 1)) return luaL_error(localL, "boolean expected, got %s", luaL_typename(localL, 1)); \
|
||||
mod->enc->data[mod->enc->program].name = lua_toboolean(localL, 1); \
|
||||
return 0; \
|
||||
}
|
||||
#define INT_SETTER(name) \
|
||||
int lua_set_rds_##name(lua_State *localL) { \
|
||||
mod->enc->data[mod->enc->program].name = luaL_checkinteger(localL, 1); \
|
||||
@@ -43,6 +49,11 @@ int lua_get_rds_##name(lua_State *localL) { \
|
||||
lua_pushinteger(localL, mod->enc->data[mod->enc->program].name); \
|
||||
return 1; \
|
||||
}
|
||||
#define BOOL_GETTER(name) \
|
||||
int lua_get_rds_##name(lua_State *localL) { \
|
||||
lua_pushboolean(localL, mod->enc->data[mod->enc->program].name); \
|
||||
return 1; \
|
||||
}
|
||||
#define STR_RAW_GETTER(name) \
|
||||
int lua_get_rds_##name(lua_State *localL) { \
|
||||
lua_pushstring(localL, mod->enc->data[mod->enc->program].name); \
|
||||
@@ -60,36 +71,37 @@ INT_GETTER(ecc)
|
||||
INT_SETTER(slc_data)
|
||||
INT_GETTER(slc_data)
|
||||
|
||||
INT_SETTER(ct)
|
||||
INT_GETTER(ct)
|
||||
BOOL_SETTER(ct)
|
||||
BOOL_GETTER(ct)
|
||||
|
||||
INT_SETTER(dpty)
|
||||
INT_GETTER(dpty)
|
||||
BOOL_SETTER(dpty)
|
||||
BOOL_GETTER(dpty)
|
||||
|
||||
INT_SETTER(tp)
|
||||
INT_GETTER(tp)
|
||||
BOOL_SETTER(tp)
|
||||
BOOL_GETTER(tp)
|
||||
|
||||
INT_SETTER(ta)
|
||||
INT_GETTER(ta)
|
||||
BOOL_SETTER(ta)
|
||||
BOOL_GETTER(ta)
|
||||
|
||||
INT_SETTER(rt1_enabled)
|
||||
INT_GETTER(rt1_enabled)
|
||||
BOOL_SETTER(rt1_enabled)
|
||||
BOOL_GETTER(rt1_enabled)
|
||||
|
||||
INT_SETTER(rt2_enabled)
|
||||
INT_GETTER(rt2_enabled)
|
||||
BOOL_SETTER(rt2_enabled)
|
||||
BOOL_GETTER(rt2_enabled)
|
||||
|
||||
INT_SETTER(ptyn_enabled)
|
||||
INT_GETTER(ptyn_enabled)
|
||||
BOOL_SETTER(ptyn_enabled)
|
||||
BOOL_GETTER(ptyn_enabled)
|
||||
|
||||
INT_SETTER(rt_type)
|
||||
INT_GETTER(rt_type)
|
||||
BOOL_SETTER(rt_type)
|
||||
BOOL_GETTER(rt_type)
|
||||
|
||||
int lua_set_rds_rds2mod(lua_State *localL) {
|
||||
mod->enc->encoder_data.rds2_mode = luaL_checkinteger(localL, 1);
|
||||
if (!lua_isboolean(localL, 1)) return luaL_error(localL, "boolean expected, got %s", luaL_typename(localL, 1));
|
||||
mod->enc->encoder_data.rds2_mode = lua_toboolean(localL, 1);
|
||||
return 0;
|
||||
}
|
||||
int lua_get_rds_rds2mod(lua_State *localL) {
|
||||
lua_pushinteger(localL, mod->enc->encoder_data.rds2_mode);
|
||||
lua_pushboolean(localL, mod->enc->encoder_data.rds2_mode);
|
||||
return 1;
|
||||
}
|
||||
int lua_set_rds_rdsgen(lua_State *localL) {
|
||||
@@ -102,11 +114,12 @@ int lua_get_rds_rdsgen(lua_State *localL) {
|
||||
}
|
||||
|
||||
int lua_set_rds_link(lua_State *localL) {
|
||||
mod->enc->state[mod->enc->program].eon_linkage = luaL_checkinteger(localL, 1);
|
||||
if (!lua_isboolean(localL, 1)) return luaL_error(localL, "boolean expected, got %s", luaL_typename(localL, 1));
|
||||
mod->enc->state[mod->enc->program].eon_linkage = lua_toboolean(localL, 1);
|
||||
return 0;
|
||||
}
|
||||
int lua_get_rds_link(lua_State *localL) {
|
||||
lua_pushinteger(localL, mod->enc->state[mod->enc->program].eon_linkage);
|
||||
lua_pushboolean(localL, mod->enc->state[mod->enc->program].eon_linkage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -157,42 +170,27 @@ int lua_get_rds_level(lua_State *localL) {
|
||||
|
||||
int lua_set_rds_rtplus_tags(lua_State *localL) {
|
||||
uint8_t tags[6];
|
||||
tags[0] = luaL_checkinteger(localL, 1);
|
||||
tags[1] = luaL_checkinteger(localL, 2);
|
||||
tags[2] = luaL_checkinteger(localL, 3);
|
||||
tags[3] = luaL_checkinteger(localL, 4);
|
||||
tags[4] = luaL_checkinteger(localL, 5);
|
||||
tags[5] = luaL_checkinteger(localL, 6);
|
||||
set_rds_rtplus_tags(mod->enc, tags);
|
||||
if (!lua_isboolean(localL, 1)) return luaL_error(localL, "boolean expected, got %s", luaL_typename(localL, 1));
|
||||
int ertp = lua_toboolean(localL, 1);
|
||||
tags[0] = luaL_checkinteger(localL, 2);
|
||||
tags[1] = luaL_checkinteger(localL, 3);
|
||||
tags[2] = luaL_checkinteger(localL, 4);
|
||||
tags[3] = luaL_checkinteger(localL, 5);
|
||||
tags[4] = luaL_checkinteger(localL, 6);
|
||||
tags[5] = luaL_checkinteger(localL, 7);
|
||||
if(ertp == 1) set_rds_ertplus_tags(mod->enc, tags);
|
||||
else set_rds_rtplus_tags(mod->enc, tags);
|
||||
return 0;
|
||||
}
|
||||
int lua_get_rds_rtplus_tags(lua_State *localL) {
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][0].type[0]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][0].start[0]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][0].len[0]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][0].type[1]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][0].start[1]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][0].len[1]);
|
||||
return 6;
|
||||
}
|
||||
int lua_set_rds_ertplus_tags(lua_State *localL) {
|
||||
uint8_t tags[6];
|
||||
tags[0] = luaL_checkinteger(localL, 1);
|
||||
tags[1] = luaL_checkinteger(localL, 2);
|
||||
tags[2] = luaL_checkinteger(localL, 3);
|
||||
tags[3] = luaL_checkinteger(localL, 4);
|
||||
tags[4] = luaL_checkinteger(localL, 5);
|
||||
tags[5] = luaL_checkinteger(localL, 6);
|
||||
set_rds_ertplus_tags(mod->enc, tags);
|
||||
return 0;
|
||||
}
|
||||
int lua_get_rds_ertplus_tags(lua_State *localL) {
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][1].type[0]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][1].start[0]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][1].len[0]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][1].type[1]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][1].start[1]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][1].len[1]);
|
||||
if (!lua_isboolean(localL, 1)) return luaL_error(localL, "boolean expected, got %s", luaL_typename(localL, 1));
|
||||
int ertp = lua_toboolean(localL, 1);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][ertp].type[0]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][ertp].start[0]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][ertp].len[0]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][ertp].type[1]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][ertp].start[1]);
|
||||
lua_pushinteger(localL, mod->enc->rtpData[mod->enc->program][ertp].len[1]);
|
||||
return 6;
|
||||
}
|
||||
|
||||
@@ -212,6 +210,30 @@ int lua_put_rds2_custom_group(lua_State *localL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lua_toggle_rds_rtp(lua_State *localL) {
|
||||
if (!lua_isboolean(localL, 1)) return luaL_error(localL, "boolean expected, got %s", luaL_typename(localL, 1));
|
||||
int ertp = lua_toboolean(localL, 1);
|
||||
TOGGLE(mod->enc->rtpState[mod->enc->program][ertp].toggle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lua_set_rds_rtp_meta(lua_State *localL) {
|
||||
if (!lua_isboolean(localL, 1)) return luaL_error(localL, "boolean expected, got %s", luaL_typename(localL, 1));
|
||||
if (!lua_isboolean(localL, 2)) return luaL_error(localL, "boolean expected, got %s", luaL_typename(localL, 2));
|
||||
if (!lua_isboolean(localL, 3)) return luaL_error(localL, "boolean expected, got %s", luaL_typename(localL, 3));
|
||||
int ertp = lua_toboolean(localL, 1);
|
||||
mod->enc->rtpData[mod->enc->program][ertp].enabled = lua_toboolean(localL, 2);
|
||||
mod->enc->rtpData[mod->enc->program][ertp].running = lua_toboolean(localL, 3);
|
||||
return 0;
|
||||
}
|
||||
int lua_get_rds_rtp_meta(lua_State *localL) {
|
||||
if (!lua_isboolean(localL, 1)) return luaL_error(localL, "boolean expected, got %s", luaL_typename(localL, 1));
|
||||
int ertp = lua_toboolean(localL, 1);
|
||||
lua_pushboolean(localL, mod->enc->rtpData[mod->enc->program][ertp].enabled);
|
||||
lua_pushboolean(localL, mod->enc->rtpData[mod->enc->program][ertp].running);
|
||||
return 2;
|
||||
}
|
||||
|
||||
STR_SETTER(ptyn, set_rds_ptyn)
|
||||
STR_SETTER(ps, set_rds_ps)
|
||||
STR_SETTER(tps, set_rds_tps)
|
||||
@@ -338,9 +360,10 @@ void init_lua(RDSModulator* rds_mod) {
|
||||
|
||||
lua_register(L, "set_rds_rtplus_tags", lua_set_rds_rtplus_tags);
|
||||
lua_register(L, "get_rds_rtplus_tags", lua_get_rds_rtplus_tags);
|
||||
lua_register(L, "toggle_rds_rtp", lua_toggle_rds_rtp);
|
||||
|
||||
lua_register(L, "set_rds_ertplus_tags", lua_set_rds_ertplus_tags);
|
||||
lua_register(L, "get_rds_ertplus_tags", lua_get_rds_ertplus_tags);
|
||||
lua_register(L, "set_rds_rtp_meta", lua_set_rds_rtp_meta);
|
||||
lua_register(L, "get_rds_rtp_meta", lua_get_rds_rtp_meta);
|
||||
|
||||
lua_register(L, "put_rds_custom_group", lua_put_rds_custom_group);
|
||||
lua_register(L, "put_rds2_custom_group", lua_put_rds2_custom_group);
|
||||
|
||||
Reference in New Issue
Block a user