libobs: Add services API, reduce repeated code
Add API for streaming services. The services API simplifies the creation of custom service features and user interface. Custom streaming services later on will be able to do things such as: - Be able to use service-specific APIs via modules, allowing a more direct means of communicating with the service and requesting or setting service-specific information - Get URL/stream key via other means of authentication such as OAuth, or be able to build custom URLs for services that require that sort of thing. - Query information (such as viewer count, chat, follower notifications, and other information) - Set channel information (such as current game, current channel title, activating commercials) Also, I reduce some repeated code that was used for all libobs objects. This includes the name of the object, the private data, settings, as well as the signal and procedure handlers. I also switched to using linked lists for the global object lists, rather than using an array of pointers (you could say it was.. pointless.) ..Anyway, the linked list info is also stored in the shared context data structure.
This commit is contained in:
@@ -25,8 +25,8 @@ static inline void signal_item_remove(struct obs_scene_item *item)
|
||||
calldata_setptr(¶ms, "scene", item->parent);
|
||||
calldata_setptr(¶ms, "item", item);
|
||||
|
||||
signal_handler_signal(item->parent->source->signals, "item_remove",
|
||||
¶ms);
|
||||
signal_handler_signal(item->parent->source->context.signals,
|
||||
"item_remove", ¶ms);
|
||||
calldata_free(¶ms);
|
||||
}
|
||||
|
||||
@@ -205,35 +205,28 @@ static const char *obs_scene_signals[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
void source_init_name(struct obs_source *source, const char *name);
|
||||
|
||||
obs_scene_t obs_scene_create(const char *name)
|
||||
{
|
||||
struct obs_source *source = bzalloc(sizeof(struct obs_source));
|
||||
struct obs_scene *scene;
|
||||
|
||||
if (!obs_source_init_handlers(source)) {
|
||||
if (!obs_source_init_context(source, NULL, name)) {
|
||||
bfree(source);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
signal_handler_add_array(source->signals, obs_scene_signals);
|
||||
signal_handler_add_array(source->context.signals, obs_scene_signals);
|
||||
|
||||
source->settings = obs_data_create();
|
||||
scene = scene_create(source->settings, source);
|
||||
source->data = scene;
|
||||
scene = scene_create(source->context.settings, source);
|
||||
source->context.data = scene;
|
||||
|
||||
assert(scene);
|
||||
if (!scene) {
|
||||
obs_data_release(source->settings);
|
||||
proc_handler_destroy(source->procs);
|
||||
signal_handler_destroy(source->signals);
|
||||
obs_context_data_free(&source->context);
|
||||
bfree(source);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
source_init_name(source, name);
|
||||
|
||||
scene->source = source;
|
||||
obs_source_init(source, &scene_info);
|
||||
memcpy(&source->info, &scene_info, sizeof(struct obs_source_info));
|
||||
@@ -262,7 +255,7 @@ obs_scene_t obs_scene_fromsource(obs_source_t source)
|
||||
if (!source || source->info.type != OBS_SOURCE_TYPE_SCENE)
|
||||
return NULL;
|
||||
|
||||
return source->data;
|
||||
return source->context.data;
|
||||
}
|
||||
|
||||
obs_sceneitem_t obs_scene_findsource(obs_scene_t scene, const char *name)
|
||||
@@ -276,7 +269,7 @@ obs_sceneitem_t obs_scene_findsource(obs_scene_t scene, const char *name)
|
||||
|
||||
item = scene->first_item;
|
||||
while (item) {
|
||||
if (strcmp(item->source->name, name) == 0)
|
||||
if (strcmp(item->source->context.name, name) == 0)
|
||||
break;
|
||||
|
||||
item = item->next;
|
||||
@@ -358,7 +351,8 @@ obs_sceneitem_t obs_scene_add(obs_scene_t scene, obs_source_t source)
|
||||
|
||||
calldata_setptr(¶ms, "scene", scene);
|
||||
calldata_setptr(¶ms, "item", item);
|
||||
signal_handler_signal(scene->source->signals, "item_add", ¶ms);
|
||||
signal_handler_signal(scene->source->context.signals, "item_add",
|
||||
¶ms);
|
||||
calldata_free(¶ms);
|
||||
|
||||
return item;
|
||||
|
Reference in New Issue
Block a user