mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-01 15:49:51 +08:00
rtmp-services: Add Amazon IVS ingest refresh infrastructure
This commit is contained in:
@@ -59,6 +59,11 @@ extern void load_twitch_data(void);
|
||||
extern void unload_twitch_data(void);
|
||||
extern void twitch_ingests_refresh(int seconds);
|
||||
|
||||
extern void init_amazon_ivs_data(void);
|
||||
extern void load_amazon_ivs_data(void);
|
||||
extern void unload_amazon_ivs_data(void);
|
||||
extern void amazon_ivs_ingests_refresh(int seconds);
|
||||
|
||||
static void refresh_callback(void *unused, calldata_t *cd)
|
||||
{
|
||||
int seconds = (int)calldata_int(cd, "seconds");
|
||||
@@ -72,10 +77,24 @@ static void refresh_callback(void *unused, calldata_t *cd)
|
||||
UNUSED_PARAMETER(unused);
|
||||
}
|
||||
|
||||
static void amazon_ivs_refresh_callback(void *unused, calldata_t *cd)
|
||||
{
|
||||
int seconds = (int)calldata_int(cd, "seconds");
|
||||
if (seconds <= 0)
|
||||
seconds = 3;
|
||||
if (seconds > 10)
|
||||
seconds = 10;
|
||||
|
||||
amazon_ivs_ingests_refresh(seconds);
|
||||
|
||||
UNUSED_PARAMETER(unused);
|
||||
}
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
init_twitch_data();
|
||||
init_dacast_data();
|
||||
init_amazon_ivs_data();
|
||||
|
||||
dstr_copy(&module_name, "rtmp-services plugin (libobs ");
|
||||
dstr_cat(&module_name, obs_get_version_string());
|
||||
@@ -84,6 +103,8 @@ bool obs_module_load(void)
|
||||
proc_handler_t *ph = obs_get_proc_handler();
|
||||
proc_handler_add(ph, "void twitch_ingests_refresh(int seconds)",
|
||||
refresh_callback, NULL);
|
||||
proc_handler_add(ph, "void amazon_ivs_ingests_refresh(int seconds)",
|
||||
amazon_ivs_refresh_callback, NULL);
|
||||
|
||||
#if defined(ENABLE_SERVICE_UPDATES)
|
||||
char *local_dir = obs_module_file("");
|
||||
@@ -100,6 +121,7 @@ bool obs_module_load(void)
|
||||
}
|
||||
|
||||
load_twitch_data();
|
||||
load_amazon_ivs_data();
|
||||
|
||||
bfree(local_dir);
|
||||
bfree(cache_dir);
|
||||
@@ -116,5 +138,6 @@ void obs_module_unload(void)
|
||||
unload_twitch_data();
|
||||
free_showroom_data();
|
||||
unload_dacast_data();
|
||||
unload_amazon_ivs_data();
|
||||
dstr_free(&module_name);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,16 @@ static struct service_ingests twitch = {
|
||||
.cache_old_filename = "twitch_ingests.json",
|
||||
.cache_new_filename = "twitch_ingests.new.json"};
|
||||
|
||||
static struct service_ingests amazon_ivs = {
|
||||
.update_info = NULL,
|
||||
.mutex = PTHREAD_MUTEX_INITIALIZER,
|
||||
.ingests_refreshed = false,
|
||||
.ingests_refreshing = false,
|
||||
.ingests_loaded = false,
|
||||
.cur_ingests = {0},
|
||||
.cache_old_filename = "amazon_ivs_ingests.json",
|
||||
.cache_new_filename = "amazon_ivs_ingests.new.json"};
|
||||
|
||||
static void free_ingests(struct service_ingests *si)
|
||||
{
|
||||
for (size_t i = 0; i < si->cur_ingests.num; i++) {
|
||||
@@ -259,3 +269,49 @@ void unload_twitch_data(void)
|
||||
{
|
||||
unload_service_data(&twitch);
|
||||
}
|
||||
|
||||
void init_amazon_ivs_data(void)
|
||||
{
|
||||
init_service_data(&amazon_ivs);
|
||||
}
|
||||
|
||||
void load_amazon_ivs_data(void)
|
||||
{
|
||||
struct ingest def = {
|
||||
.name = bstrdup("Default"),
|
||||
.url = bstrdup(
|
||||
"rtmps://ingest.global-contribute.live-video.net:443/app/")};
|
||||
load_service_data(&amazon_ivs, "amazon_ivs_ingests.json", &def);
|
||||
}
|
||||
|
||||
void unload_amazon_ivs_data(void)
|
||||
{
|
||||
unload_service_data(&amazon_ivs);
|
||||
}
|
||||
|
||||
void amazon_ivs_ingests_refresh(int seconds)
|
||||
{
|
||||
service_ingests_refresh(
|
||||
&amazon_ivs, seconds, "[amazon ivs ingest update] ",
|
||||
"https://ingest.contribute.live-video.net/ingests");
|
||||
}
|
||||
|
||||
void amazon_ivs_ingests_lock(void)
|
||||
{
|
||||
pthread_mutex_lock(&amazon_ivs.mutex);
|
||||
}
|
||||
|
||||
void amazon_ivs_ingests_unlock(void)
|
||||
{
|
||||
pthread_mutex_unlock(&amazon_ivs.mutex);
|
||||
}
|
||||
|
||||
size_t amazon_ivs_ingest_count(void)
|
||||
{
|
||||
return amazon_ivs.cur_ingests.num;
|
||||
}
|
||||
|
||||
struct twitch_ingest amazon_ivs_ingest(size_t idx)
|
||||
{
|
||||
return get_ingest(&amazon_ivs, idx);
|
||||
}
|
||||
|
||||
@@ -9,3 +9,8 @@ extern void twitch_ingests_lock(void);
|
||||
extern void twitch_ingests_unlock(void);
|
||||
extern size_t twitch_ingest_count(void);
|
||||
extern struct twitch_ingest twitch_ingest(size_t idx);
|
||||
|
||||
extern void amazon_ivs_ingests_lock(void);
|
||||
extern void amazon_ivs_ingests_unlock(void);
|
||||
extern size_t amazon_ivs_ingest_count(void);
|
||||
extern struct twitch_ingest amazon_ivs_ingest(size_t idx);
|
||||
|
||||
Reference in New Issue
Block a user