0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 04:42:18 +02:00

libobs,docs: Add connect infos check to the Services API

This new function allows to know if the service has all the info needed
to try to connect.
This commit is contained in:
tytan652 2023-01-19 16:08:35 +01:00
parent 5e4ed49a2d
commit 22ebed8d02
5 changed files with 30 additions and 1 deletions

View File

@ -184,6 +184,14 @@ Service Definition Structure
Irrelevant or unused types can return `NULL`.
.. member:: bool (*obs_service_info.can_try_to_connect)(void *data)
:return: If the service has all the needed connection info to be
able to connect.
NOTE: If not set, :c:func:`obs_service_can_try_to_connect()`
returns *true* by default.
General Service Functions
-------------------------
@ -378,6 +386,12 @@ General Service Functions
type values.
:return: Connection info related to the type value.
.. function:: bool obs_service_can_try_to_connect(const obs_service_t *service)
:return: If the service has all the needed connection info to be
able to connect. Returns `true` if
:c:member:`obs_service_info.can_try_to_connect` is not set.
.. ---------------------------------------------------------------------------
.. _libobs/obs-service.h: https://github.com/obsproject/obs-studio/blob/master/libobs/obs-service.h

View File

@ -290,7 +290,8 @@ bool obs_output_start(obs_output_t *output)
return false;
has_service = (output->info.flags & OBS_OUTPUT_SERVICE) != 0;
if (has_service && !obs_service_initialize(output->service, output))
if (has_service && !(obs_service_can_try_to_connect(output->service) &&
obs_service_initialize(output->service, output)))
return false;
encoded = (output->info.flags & OBS_OUTPUT_ENCODED) != 0;

View File

@ -512,3 +512,13 @@ const char *obs_service_get_connect_info(const obs_service_t *service,
return NULL;
return service->info.get_connect_info(service->context.data, type);
}
bool obs_service_can_try_to_connect(const obs_service_t *service)
{
if (!obs_service_valid(service, "obs_service_can_connect"))
return false;
if (!service->info.can_try_to_connect)
return true;
return service->info.can_try_to_connect(service->context.data);
}

View File

@ -106,6 +106,8 @@ struct obs_service_info {
const char **(*get_supported_audio_codecs)(void *data);
const char *(*get_connect_info)(void *data, uint32_t type);
bool (*can_try_to_connect)(void *data);
};
EXPORT void obs_register_service_s(const struct obs_service_info *info,

View File

@ -2566,6 +2566,8 @@ obs_service_get_preferred_output_type(const obs_service_t *service);
EXPORT const char *obs_service_get_connect_info(const obs_service_t *service,
uint32_t type);
EXPORT bool obs_service_can_try_to_connect(const obs_service_t *service);
/* ------------------------------------------------------------------------- */
/* Source frame allocation functions */
EXPORT void obs_source_frame_init(struct obs_source_frame *frame,