reference-properties.rst 19.2 KB
Newer Older
J
jp9000 已提交
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
Properties API Reference (obs_properties_t)
===========================================

Properties are used to enumerate available settings for a libobs object.
Typically this is used to automatically generate user interface widgets,
though can be used to enumerate available and/or valid values for
specific settings as well.

.. type:: obs_properties_t

   Properties object (not reference counted).

.. type:: obs_property_t

   A property object (not reference counted).

.. code:: cpp

   #include <obs.h>


General Functions
-----------------

.. function:: obs_properties_t *obs_properties_create(void)

   :return: A new properties object.

---------------------

.. function:: obs_properties_t *obs_properties_create_param(void *param, void (*destroy)(void *param))

   Creates a new properties object with specific private data *param*
   associated with the object, and is automatically freed with the
   object when the properties are destroyed via the *destroy* function.

   :return: A new properties object.

---------------------

.. function:: void obs_properties_destroy(obs_properties_t *props)

---------------------

.. function:: void obs_properties_set_flags(obs_properties_t *props, uint32_t flags)
              uint32_t obs_properties_get_flags(obs_properties_t *props)

   :param flags: 0 or a bitwise OR combination of one of the following
                 values:
                 
                 - OBS_PROPERTIES_DEFER_UPDATE - A hint that tells the
                   front-end to defers updating the settings until the
                   user has finished editing all properties rather than
                   immediately updating any settings

---------------------

.. function:: void obs_properties_set_param(obs_properties_t *props, void *param, void (*destroy)(void *param))
              void *obs_properties_get_param(obs_properties_t *props)

   Sets custom data associated with this properties object.  If private
   data is already associated with the object, that private data will be
   destroyed before assigning new private data to it.

---------------------

.. function:: void obs_properties_apply_settings(obs_properties_t *props, obs_data_t *settings)

   Applies settings to the properties by calling all the necessary
   modification callbacks

---------------------


Property Object Functions
-------------------------

.. function:: obs_property_t *obs_properties_add_bool(obs_properties_t *props, const char *name, const char *description)

   Adds a boolean property.

   :param    name:        Setting identifier string
   :param    description: Localized name shown to user
   :return:               The property

---------------------

.. function:: obs_property_t *obs_properties_add_int(obs_properties_t *props, const char *name, const char *description, int min, int max, int step)

   Adds an integer property.

   :param    name:        Setting identifier string
   :param    description: Localized name shown to user
   :param    min:         Minimum value
   :param    max:         Maximum value
   :param    step:        Step value
   :return:               The property

---------------------

.. function:: obs_property_t *obs_properties_add_float(obs_properties_t *props, const char *name, const char *description, double min, double max, double step)

   :param    name:        Setting identifier string
   :param    description: Localized name shown to user
   :param    min:         Minimum value
   :param    max:         Maximum value
   :param    step:        Step value
   :return:               The property

---------------------

.. function:: obs_property_t *obs_properties_add_int_slider(obs_properties_t *props, const char *name, const char *description, int min, int max, int step)

   :param    name:        Setting identifier string
   :param    description: Localized name shown to user
   :param    min:         Minimum value
   :param    max:         Maximum value
   :param    step:        Step value
   :return:               The property

---------------------

.. function:: obs_property_t *obs_properties_add_float_slider(obs_properties_t *props, const char *name, const char *description, double min, double max, double step)

   :param    name:        Setting identifier string
   :param    description: Localized name shown to user
   :param    min:         Minimum value
   :param    max:         Maximum value
   :param    step:        Step value
   :return:               The property

---------------------

.. function:: obs_property_t *obs_properties_add_text(obs_properties_t *props, const char *name, const char *description, enum obs_text_type type)

   :param    name:        Setting identifier string
   :param    description: Localized name shown to user
   :param    type:        Can be one of the following values:

                          - **OBS_TEXT_DEFAULT** - Single line of text
                          - **OBS_TEXT_PASSWORD** - Single line of text (passworded)
                          - **OBS_TEXT_MULTILINE** - Multi-line text

   :return:               The property

---------------------

.. function:: obs_property_t *obs_properties_add_path(obs_properties_t *props, const char *name, const char *description, enum obs_path_type type, const char *filter, const char *default_path)

   Adds a 'path' property.  Can be a directory or a file.

   If target is a file path, the filters should be this format, separated by
   double semi-colens, and extensions separated by space::

     "Example types 1 and 2 (*.ex1 *.ex2);;Example type 3 (*.ex3)"

   :param    name:         Setting identifier string
   :param    description:  Localized name shown to user
   :param    type:         Can be one of the following values:

                           - **OBS_PATH_FILE** - File (for reading)
                           - **OBS_PATH_FILE_SAVE** - File (for writing)
                           - **OBS_PATH_DIRECTORY** - Directory

   :param    filter:       If type is a file path, then describes the file filter
                           that the user can browse.  Items are separated via
                           double semi-colens.  If multiple file types in a
                           filter, separate with space.
   :param    default_path: The default path to start in, or *NULL*
   :return:                The property

---------------------

.. function:: obs_property_t *obs_properties_add_list(obs_properties_t *props, const char *name, const char *description, enum obs_combo_type type, enum obs_combo_format format)

   Adds an integer/string/floating point item list.  This would be
   implemented as a combo box in user interface.

   :param    name:        Setting identifier string
   :param    description: Localized name shown to user
   :param    type:        Can be one of the following values:

                          - **OBS_COMBO_TYPE_EDITABLE** - Can be edited.
                            Only used with string lists.
L
luz.paz 已提交
185
                          - **OBS_COMBO_TYPE_LIST** - Not editable.
J
jp9000 已提交
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

   :param    format:      Can be one of the following values:

                          - **OBS_COMBO_FORMAT_INT** - Integer list
                          - **OBS_COMBO_FORMAT_FLOAT** - Floating point
                            list
                          - **OBS_COMBO_FORMAT_STRING** - String list

   :return:               The property

   Important Related Functions:

   - :c:func:`obs_property_list_add_string`
   - :c:func:`obs_property_list_add_int`
   - :c:func:`obs_property_list_add_float`
   - :c:func:`obs_property_list_insert_string`
   - :c:func:`obs_property_list_insert_int`
   - :c:func:`obs_property_list_insert_float`
   - :c:func:`obs_property_list_item_remove`
   - :c:func:`obs_property_list_clear`

---------------------

.. function:: obs_property_t *obs_properties_add_color(obs_properties_t *props, const char *name, const char *description)

   Adds a color property.

   :param    name:        Setting identifier string
   :param    description: Localized name shown to user
   :return:               The property

---------------------

.. function:: obs_property_t *obs_properties_add_button(obs_properties_t *props, const char *name, const char *text, obs_property_clicked_t callback)

   Adds a button property.  This property does not actually store any
   settings; it's used to implement a button in user interface if the
   properties are used to generate user interface.

   :param    name:        Setting identifier string
   :param    description: Localized name shown to user
   :return:               The property

---------------------

.. function:: obs_property_t *obs_properties_add_font(obs_properties_t *props, const char *name, const char *description)

   Adds a font property.

   :param    name:        Setting identifier string
   :param    description: Localized name shown to user
   :return:               The property

---------------------

.. function:: obs_property_t *obs_properties_add_editable_list(obs_properties_t *props, const char *name, const char *description, enum obs_editable_list_type type, const char *filter, const char *default_path)

   Adds a list in which the user can add/insert/remove items.

   :param    name:         Setting identifier string
   :param    description:  Localized name shown to user
   :param    type:         Can be one of the following values:
                          
                           - **OBS_EDITABLE_LIST_TYPE_STRINGS** - An
                             editable list of strings.
                           - **OBS_EDITABLE_LIST_TYPE_FILES** - An
                             editable list of files.
                           - **OBS_EDITABLE_LIST_TYPE_FILES_AND_URLS** -
                             An editable list of files and URLs.

   :param    filter:       File filter to use if a file list
   :param    default_path: Default path if a file list
   :return:                The property

---------------------

.. function:: obs_property_t *obs_properties_add_frame_rate(obs_properties_t *props, const char *name, const char *description)

   Adds a frame rate property.

   :param    name:        Setting identifier string
   :param    description: Localized name shown to user
   :return:               The property

   Important Related Functions:

   - :c:func:`obs_property_frame_rate_option_add`
   - :c:func:`obs_property_frame_rate_fps_range_add`
   - :c:func:`obs_property_frame_rate_option_insert`
   - :c:func:`obs_property_frame_rate_fps_range_insert`

---------------------


Property Enumeration Functions
------------------------------

.. function:: obs_property_t *obs_properties_first(obs_properties_t *props)

   :return: The first property in the properties object.

---------------------

.. function:: obs_property_t *obs_properties_get(obs_properties_t *props, const char *property)

   :param property: The name of the property to get
   :return:         A specific property or *NULL* if not found

---------------------

.. function:: bool                   obs_property_next(obs_property_t **p)

   :param p: Pointer to the pointer of the next property
   :return: *true* if successful, *false* if no more properties

---------------------

.. function:: const char *           obs_property_name(obs_property_t *p)

   :return: The setting identifier string of the property

   *(Author's Note: "name" was a bad name to use here.  Should have been
   "setting")*

---------------------

.. function:: const char *           obs_property_description(obs_property_t *p)

   :return: The actual localized display name of the property

   *(Author's note: This one should have been the "name")*

---------------------

.. function:: const char *           obs_property_long_description(obs_property_t *p)

   :return: A detailed description of what the setting is used for.
            Usually used with things like tooltips.

---------------------

.. function:: enum obs_property_type obs_property_get_type(obs_property_t *p)

   :return: One of the following values:

            - OBS_PROPERTY_INVALID
            - OBS_PROPERTY_BOOL
            - OBS_PROPERTY_INT
            - OBS_PROPERTY_FLOAT
            - OBS_PROPERTY_TEXT
            - OBS_PROPERTY_PATH
            - OBS_PROPERTY_LIST
            - OBS_PROPERTY_COLOR
            - OBS_PROPERTY_BUTTON
            - OBS_PROPERTY_FONT
            - OBS_PROPERTY_EDITABLE_LIST
            - OBS_PROPERTY_FRAME_RATE

---------------------

.. function:: bool                   obs_property_enabled(obs_property_t *p)

---------------------

.. function:: bool                   obs_property_visible(obs_property_t *p)

---------------------

.. function:: int                    obs_property_int_min(obs_property_t *p)

---------------------

.. function:: int                    obs_property_int_max(obs_property_t *p)

---------------------

.. function:: int                    obs_property_int_step(obs_property_t *p)

---------------------

.. function:: enum obs_number_type   obs_property_int_type(obs_property_t *p)

---------------------

.. function:: double                 obs_property_float_min(obs_property_t *p)

---------------------

.. function:: double                 obs_property_float_max(obs_property_t *p)

---------------------

.. function:: double                 obs_property_float_step(obs_property_t *p)

---------------------

.. function:: enum obs_number_type   obs_property_float_type(obs_property_t *p)

---------------------

J
jamacanbacn 已提交
386
.. function:: enum obs_text_type     obs_property_text_type(obs_property_t *p)
J
jp9000 已提交
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 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597

---------------------

.. function:: enum obs_path_type     obs_property_path_type(obs_property_t *p)

---------------------

.. function:: const char *           obs_property_path_filter(obs_property_t *p)

---------------------

.. function:: const char *           obs_property_path_default_path(obs_property_t *p)

---------------------

.. function:: enum obs_combo_type    obs_property_list_type(obs_property_t *p)

---------------------

.. function:: enum obs_combo_format  obs_property_list_format(obs_property_t *p)

---------------------

.. function:: bool obs_property_list_item_disabled(obs_property_t *p, size_t idx)

---------------------

.. function:: size_t      obs_property_list_item_count(obs_property_t *p)

---------------------

.. function:: const char *obs_property_list_item_name(obs_property_t *p, size_t idx)

---------------------

.. function:: const char *obs_property_list_item_string(obs_property_t *p, size_t idx)

---------------------

.. function:: long long   obs_property_list_item_int(obs_property_t *p, size_t idx)

---------------------

.. function:: double      obs_property_list_item_float(obs_property_t *p, size_t idx)

---------------------

.. function:: enum obs_editable_list_type obs_property_editable_list_type(obs_property_t *p)

---------------------

.. function:: const char *obs_property_editable_list_filter(obs_property_t *p)

---------------------

.. function:: const char *obs_property_editable_list_default_path(obs_property_t *p)

---------------------

.. function:: size_t      obs_property_frame_rate_options_count(obs_property_t *p)

---------------------

.. function:: const char *obs_property_frame_rate_option_name(obs_property_t *p, size_t idx)

---------------------

.. function:: const char *obs_property_frame_rate_option_description( obs_property_t *p, size_t idx)

---------------------

.. function:: size_t      obs_property_frame_rate_fps_ranges_count(obs_property_t *p)

---------------------

.. function:: struct media_frames_per_second obs_property_frame_rate_fps_range_min( obs_property_t *p, size_t idx)

---------------------

.. function:: struct media_frames_per_second obs_property_frame_rate_fps_range_max( obs_property_t *p, size_t idx)

---------------------


Property Modification Functions
-------------------------------

.. function:: void obs_property_set_modified_callback(obs_property_t *p, obs_property_modified_t modified)

   Allows the ability to change the properties depending on what
   settings are used by the user.

   Relevant data types used with this function:

.. code:: cpp

   typedef bool (*obs_property_clicked_t)(obs_properties_t *props,
                   obs_property_t *property, void *data);

---------------------

.. function:: bool obs_property_modified(obs_property_t *p, obs_data_t *settings)

---------------------

.. function:: bool obs_property_button_clicked(obs_property_t *p, void *obj)

---------------------

.. function:: void obs_property_set_visible(obs_property_t *p, bool visible)

---------------------

.. function:: void obs_property_set_enabled(obs_property_t *p, bool enabled)

---------------------

.. function:: void obs_property_set_description(obs_property_t *p, const char *description)

   Sets the displayed localized name of the property, shown to the user.

---------------------

.. function:: void obs_property_set_long_description(obs_property_t *p, const char *long_description)

   Sets the localized long description of the property, usually shown to
   a user via tooltip.

---------------------

.. function:: void obs_property_int_set_limits(obs_property_t *p, int min, int max, int step)

---------------------

.. function:: void obs_property_float_set_limits(obs_property_t *p, double min, double max, double step)

---------------------

.. function:: void obs_property_list_clear(obs_property_t *p)

---------------------

.. function:: size_t obs_property_list_add_string(obs_property_t *p, const char *name, const char *val)

   Adds a string to a string list.

---------------------

.. function:: size_t obs_property_list_add_int(obs_property_t *p, const char *name, long long val)

   Adds an integer to a integer list.

---------------------

.. function:: size_t obs_property_list_add_float(obs_property_t *p, const char *name, double val)

   Adds a floating point to a floating point list.

---------------------

.. function:: void obs_property_list_insert_string(obs_property_t *p, size_t idx, const char *name, const char *val)

   Inserts a string in to a string list.

---------------------

.. function:: void obs_property_list_insert_int(obs_property_t *p, size_t idx, const char *name, long long val)

   Inserts an integer in to an integer list.

---------------------

.. function:: void obs_property_list_insert_float(obs_property_t *p, size_t idx, const char *name, double val)

   Inserts a floating point in to a floating point list.

---------------------

.. function:: void obs_property_list_item_disable(obs_property_t *p, size_t idx,

---------------------

.. function:: void obs_property_list_item_remove(obs_property_t *p, size_t idx)

---------------------

.. function:: size_t obs_property_frame_rate_option_add(obs_property_t *p, const char *name, const char *description)

---------------------

.. function:: size_t obs_property_frame_rate_fps_range_add(obs_property_t *p, struct media_frames_per_second min, struct media_frames_per_second max)

---------------------

.. function:: void obs_property_frame_rate_clear(obs_property_t *p)

---------------------

.. function:: void obs_property_frame_rate_options_clear(obs_property_t *p)

---------------------

.. function:: void obs_property_frame_rate_fps_ranges_clear(obs_property_t *p)

---------------------

.. function:: void obs_property_frame_rate_option_insert(obs_property_t *p, size_t idx, const char *name, const char *description)

---------------------

.. function:: void obs_property_frame_rate_fps_range_insert(obs_property_t *p, size_t idx, struct media_frames_per_second min, struct media_frames_per_second max)