1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
|
Service API Reference (obs_service_t)
=====================================
Services are custom implementations of streaming services, which are
used with outputs that stream. For example, you could have a custom
implementation for streaming to Twitch, and another for YouTube to allow
the ability to log in and use their APIs to do things such as get the
RTMP servers or control the channel. The `libobs/obs-service.h`_ file
is the dedicated header for implementing services.
*(Author's note: the service API is incomplete as of this writing)*
.. type:: obs_service_t
A reference-counted service object.
.. type:: obs_weak_service_t
A weak reference to a service object.
.. code:: cpp
#include <obs.h>
Service Definition Structure
----------------------------
.. struct:: obs_service_info
Service definition structure.
.. member:: const char *obs_service_info.id
Unique string identifier for the service (required).
.. member:: const char *(*obs_service_info.get_name)(void *type_data)
Get the translated name of the service type.
:param type_data: The type_data variable of this structure
:return: The translated name of the service type
.. member:: void *(*obs_service_info.create)(obs_data_t *settings, obs_service_t *service)
Creates the implementation data for the service.
:param settings: Settings to initialize the service with
:param service: Source that this data is associated with
:return: The implementation data associated with this service
.. member:: void (*obs_service_info.destroy)(void *data)
Destroys the implementation data for the service.
.. member:: void (*obs_service_info.get_defaults)(obs_data_t *settings)
void (*obs_service_info.get_defaults2)(void *type_data, obs_data_t *settings)
Sets the default settings for this service.
:param settings: Default settings. Call obs_data_set_default*
functions on this object to set default setting
values
.. member:: obs_properties_t *(*obs_service_info.get_properties)(void *data)
obs_properties_t *(*obs_service_info.get_properties2)(void *data, void *type_data)
Gets the property information of this service.
(Optional)
:return: The properties of the service
.. member:: void (*obs_service_info.update)(void *data, obs_data_t *settings)
Updates the settings for this service.
(Optional)
:param settings: New settings for this service
.. member:: bool (*obs_service_info.initialize)(void *data, obs_output_t *output)
Called when getting ready to start up an output, before the encoders
and output are initialized.
(Optional)
:param output: Output context to use this service with
:return: *true* to allow the output to start up,
*false* to prevent output from starting up
.. member:: const char *(*obs_service_info.get_url)(void *data)
:return: The stream URL
.. member:: const char *(*obs_service_info.get_key)(void *data)
:return: The stream key
.. member:: const char *(*obs_service_info.get_username)(void *data)
(Optional)
:return: The username
.. member:: const char *(*obs_service_info.get_password)(void *data)
(Optional)
:return: The password
.. member:: void (*obs_service_info.apply_encoder_settings)(void *data, obs_data_t *video_encoder_settings, obs_data_t *audio_encoder_settings)
This function is called to apply custom encoder settings specific to
this service. For example, if a service requires a specific keyframe
interval, or has a bitrate limit, the settings for the video and
audio encoders can be optionally modified if the front-end optionally
calls :c:func:`obs_service_apply_encoder_settings()`.
(Optional)
:param video_encoder_settings: The audio encoder settings to change
:param audio_encoder_settings: The video encoder settings to change
.. member:: void *obs_service_info.type_data
void (*obs_service_info.free_type_data)(void *type_data)
Private data associated with this entry. Note that this is not the
same as the implementation data; this is used to differentiate
between two different types if the same callbacks are used for more
than one different type.
(Optional)
.. member:: const char *(*obs_service_info.get_output_type)(void *data)
(Optional)
:return: The output type that should be preferred with this service
.. member:: const char **(*get_supported_video_codecs)(void *data)
(Optional)
:return: A string pointer array of the supported video codecs, should
be stored by the plugin so the caller does not need to free
the data manually (typically best to use strlist_split to
generate this)
.. member:: const char **(*get_supported_audio_codecs)(void *data)
(Optional)
:return: A string pointer array of the supported audio codecs, should
be stored by the plugin so the caller does not need to free
the data manually (typically best to use strlist_split to
generate this)
.. versionadded:: 29.1
.. member:: const char *(*obs_service_info.get_protocol)(void *data)
:return: The protocol used by the service
.. versionadded:: 29.1
.. 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`.
.. versionadded:: 29.1
.. member:: bool (*obs_service_info.can_try_to_connect)(void *data)
(Optional)
: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.
.. versionadded:: 29.1
General Service Functions
-------------------------
.. function:: void obs_register_service(struct obs_service_info *info)
Registers a service type. Typically used in
:c:func:`obs_module_load()` or in the program's initialization phase.
---------------------
.. function:: const char *obs_service_get_display_name(const char *id)
Calls the :c:member:`obs_service_info.get_name` callback to get the
translated display name of a service type.
:param id: The service type string identifier
:return: The translated display name of a service type
---------------------
.. function:: obs_service_t *obs_service_create(const char *id, const char *name, obs_data_t *settings, obs_data_t *hotkey_data)
Creates a service with the specified settings.
The "service" context is used for encoding video/audio data. Use
obs_service_release to release it.
:param id: The service type string identifier
:param name: The desired name of the service. If this is
not unique, it will be made to be unique
:param settings: The settings for the service, or *NULL* if
none
:param hotkey_data: Saved hotkey data for the service, or *NULL*
if none
:return: A reference to the newly created service, or
*NULL* if failed
---------------------
.. function:: void obs_service_addref(obs_service_t *service)
Adds a reference to a service.
.. deprecated:: 27.2.0
Use :c:func:`obs_service_get_ref()` instead.
---------------------
.. function:: obs_service_t *obs_service_get_ref(obs_service_t *service)
Returns an incremented reference if still valid, otherwise returns
*NULL*. Release with :c:func:`obs_service_release()`.
---------------------
.. function:: void obs_service_release(obs_service_t *service)
Releases a reference to a service. When the last reference is
released, the service is destroyed.
---------------------
.. function:: obs_weak_service_t *obs_service_get_weak_service(obs_service_t *service)
obs_service_t *obs_weak_service_get_service(obs_weak_service_t *weak)
These functions are used to get a weak reference from a strong service
reference, or a strong service reference from a weak reference. If
the service is destroyed, *obs_weak_service_get_service* will return
*NULL*.
---------------------
.. function:: void obs_weak_service_addref(obs_weak_service_t *weak)
void obs_weak_service_release(obs_weak_service_t *weak)
Adds/releases a weak reference to a service.
---------------------
.. function:: const char *obs_service_get_name(const obs_service_t *service)
:return: The name of the service
---------------------
.. function:: obs_data_t *obs_service_defaults(const char *id)
:return: An incremented reference to the service's default settings.
Release with :c:func:`obs_data_release()`.
---------------------
.. function:: obs_properties_t *obs_service_properties(const obs_service_t *service)
obs_properties_t *obs_get_service_properties(const char *id)
Use these functions to get the properties of a service or service
type. Properties are optionally used (if desired) to automatically
generate user interface widgets to allow users to update settings.
:return: The properties list for a specific existing service. Free
with :c:func:`obs_properties_destroy()`
---------------------
.. function:: obs_data_t *obs_service_get_settings(const obs_service_t *service)
:return: An incremented reference to the service's settings. Release with
:c:func:`obs_data_release()`.
---------------------
.. function:: void obs_service_update(obs_service_t *service, obs_data_t *settings)
Updates the settings for this service context.
---------------------
.. function:: const char *obs_service_get_url(const obs_service_t *service)
: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)
Applies service-specific video encoder settings.
:param video_encoder_settings: Video encoder settings. Can be *NULL*
:param audio_encoder_settings: Audio encoder settings. Can be *NULL*
---------------------
.. function:: const char **obs_service_get_supported_video_codecs(const obs_service_t *service)
:return: An array of string pointers containing the supported video
codecs for the service, terminated with a *NULL* pointer.
Does not need to be freed
---------------------
.. function:: const char **obs_service_get_supported_audio_codecs(const obs_service_t *service)
:return: An array of string pointers containing the supported audio
codecs for the service, terminated with a *NULL* pointer.
Does not need to be freed
.. versionadded:: 29.1
---------------------
.. function:: const char *obs_service_get_protocol(const obs_service_t *service)
:return: Protocol currently used for this service
.. versionadded:: 29.1
---------------------
.. function:: const char *obs_service_get_preferred_output_type(const obs_service_t *service)
:return: The output type that should be preferred with this service
.. versionadded:: 29.1
---------------------
.. 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.
.. versionadded:: 29.1
---------------------
.. 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.
.. versionadded:: 29.1
.. ---------------------------------------------------------------------------
.. _libobs/obs-service.h: https://github.com/obsproject/obs-studio/blob/master/libobs/obs-service.h
|