diff --git a/docs/sphinx/reference-services.rst b/docs/sphinx/reference-services.rst index 1429d9d42..5d3a33ab5 100644 --- a/docs/sphinx/reference-services.rst +++ b/docs/sphinx/reference-services.rst @@ -161,6 +161,28 @@ Service Definition Structure :return: The protocol used by the service +.. member:: const char *(*obs_service_info.get_connect_info)(void *data, uint32_t type) + + Output a service connection info related to a given type value: + + - **OBS_SERVICE_CONNECT_INFO_SERVER_URL** - Server URL (0) + + - **OBS_SERVICE_CONNECT_INFO_STREAM_ID** - Stream ID (2) + + - **OBS_SERVICE_CONNECT_INFO_STREAM_KEY** - Stream key (alias of **OBS_SERVICE_CONNECT_INFO_STREAM_ID**) + + - **OBS_SERVICE_CONNECT_INFO_USERNAME** - Username (4) + + - **OBS_SERVICE_CONNECT_INFO_PASSWORD** - Password (6) + + - **OBS_SERVICE_CONNECT_INFO_ENCRYPT_PASSPHRASE** - Encryption passphrase (8) + + - Odd values as types are reserved for third-party protocols + + Depending on the protocol, the service will have to provide information + to the output to be able to connect. + + Irrelevant or unused types can return `NULL`. General Service Functions ------------------------- @@ -283,24 +305,36 @@ General Service Functions :return: The URL currently used for this service +.. deprecated:: 29.1.0 + Use :c:func:`obs_service_get_connect_info()` instead. + --------------------- .. function:: const char *obs_service_get_key(const obs_service_t *service) :return: Stream key (if any) currently used for this service +.. deprecated:: 29.1.0 + Use :c:func:`obs_service_get_connect_info()` instead. + --------------------- .. function:: const char *obs_service_get_username(const obs_service_t *service) :return: User name (if any) currently used for this service +.. deprecated:: 29.1.0 + Use :c:func:`obs_service_get_connect_info()` instead. + --------------------- .. function:: const char *obs_service_get_password(const obs_service_t *service) :return: Password (if any) currently used for this service +.. deprecated:: 29.1.0 + Use :c:func:`obs_service_get_connect_info()` instead. + --------------------- .. function:: void obs_service_apply_encoder_settings(obs_service_t *service, obs_data_t *video_encoder_settings, obs_data_t *audio_encoder_settings) @@ -338,6 +372,12 @@ General Service Functions :return: The output type that should be preferred with this service +.. function:: const char *obs_service_get_connect_info(const obs_service_t *service, uint32_t type) + + :param type: Check :c:member:`obs_service_info.get_connect_info` for + type values. + :return: Connection info related to the type value. + .. --------------------------------------------------------------------------- .. _libobs/obs-service.h: https://github.com/obsproject/obs-studio/blob/master/libobs/obs-service.h diff --git a/libobs/obs-service.c b/libobs/obs-service.c index fd7919fd9..b9f667342 100644 --- a/libobs/obs-service.c +++ b/libobs/obs-service.c @@ -501,3 +501,14 @@ const char *obs_service_get_preferred_output_type(const obs_service_t *service) return service->info.get_output_type(service->context.data); return NULL; } + +const char *obs_service_get_connect_info(const obs_service_t *service, + uint32_t type) +{ + if (!obs_service_valid(service, "obs_service_get_info")) + return NULL; + + if (!service->info.get_connect_info) + return NULL; + return service->info.get_connect_info(service->context.data, type); +} diff --git a/libobs/obs-service.h b/libobs/obs-service.h index 352a4c08d..7a653d1fe 100644 --- a/libobs/obs-service.h +++ b/libobs/obs-service.h @@ -33,6 +33,17 @@ struct obs_service_resolution { int cy; }; +/* NOTE: Odd numbers are reserved for custom info from third-party protocols */ +enum obs_service_connect_info { + OBS_SERVICE_CONNECT_INFO_SERVER_URL = 0, + OBS_SERVICE_CONNECT_INFO_STREAM_ID = 2, + OBS_SERVICE_CONNECT_INFO_STREAM_KEY = + 2, // Alias of OBS_SERVICE_CONNECT_INFO_STREAM_ID + OBS_SERVICE_CONNECT_INFO_USERNAME = 4, + OBS_SERVICE_CONNECT_INFO_PASSWORD = 6, + OBS_SERVICE_CONNECT_INFO_ENCRYPT_PASSPHRASE = 8, +}; + struct obs_service_info { /* required */ const char *id; @@ -93,6 +104,8 @@ struct obs_service_info { const char *(*get_protocol)(void *data); const char **(*get_supported_audio_codecs)(void *data); + + const char *(*get_connect_info)(void *data, uint32_t type); }; EXPORT void obs_register_service_s(const struct obs_service_info *info, diff --git a/libobs/obs.h b/libobs/obs.h index ff28e807f..6b4329646 100644 --- a/libobs/obs.h +++ b/libobs/obs.h @@ -2508,16 +2508,20 @@ EXPORT void obs_service_update(obs_service_t *service, obs_data_t *settings); EXPORT obs_data_t *obs_service_get_settings(const obs_service_t *service); /** Returns the URL for this service context */ -EXPORT const char *obs_service_get_url(const obs_service_t *service); +OBS_DEPRECATED EXPORT const char * +obs_service_get_url(const obs_service_t *service); /** Returns the stream key (if any) for this service context */ -EXPORT const char *obs_service_get_key(const obs_service_t *service); +OBS_DEPRECATED EXPORT const char * +obs_service_get_key(const obs_service_t *service); /** Returns the username (if any) for this service context */ -EXPORT const char *obs_service_get_username(const obs_service_t *service); +OBS_DEPRECATED EXPORT const char * +obs_service_get_username(const obs_service_t *service); /** Returns the password (if any) for this service context */ -EXPORT const char *obs_service_get_password(const obs_service_t *service); +OBS_DEPRECATED EXPORT const char * +obs_service_get_password(const obs_service_t *service); /** * Applies service-specific video encoder settings. @@ -2559,6 +2563,9 @@ EXPORT const char *obs_service_get_protocol(const obs_service_t *service); EXPORT const char * 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); + /* ------------------------------------------------------------------------- */ /* Source frame allocation functions */ EXPORT void obs_source_frame_init(struct obs_source_frame *frame,