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 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 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840
|
OBS Studio Frontend API
=======================
The OBS Studio frontend API is the API specific to OBS Studio itself.
.. code:: cpp
#include <obs-frontend-api.h>
Structures/Enumerations
-----------------------
.. enum:: obs_frontend_event
Specifies a front-end event. Can be one of the following values:
- **OBS_FRONTEND_EVENT_STREAMING_STARTING**
Triggered when streaming is starting.
- **OBS_FRONTEND_EVENT_STREAMING_STARTED**
Triggered when streaming has successfully started.
- **OBS_FRONTEND_EVENT_STREAMING_STOPPING**
Triggered when streaming is stopping.
- **OBS_FRONTEND_EVENT_STREAMING_STOPPED**
Triggered when streaming has fully stopped.
- **OBS_FRONTEND_EVENT_RECORDING_STARTING**
Triggered when recording is starting.
- **OBS_FRONTEND_EVENT_RECORDING_STARTED**
Triggered when recording has successfully started.
- **OBS_FRONTEND_EVENT_RECORDING_STOPPING**
Triggered when recording is stopping.
- **OBS_FRONTEND_EVENT_RECORDING_STOPPED**
Triggered when recording has fully stopped.
- **OBS_FRONTEND_EVENT_RECORDING_PAUSED**
Triggered when the recording has been paused.
- **OBS_FRONTEND_EVENT_RECORDING_UNPAUSED**
Triggered when the recording has been unpaused.
- **OBS_FRONTEND_EVENT_SCENE_CHANGED**
Triggered when the current scene has changed.
- **OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED**
Triggered when a scenes has been added/removed/reordered by the
user.
- **OBS_FRONTEND_EVENT_TRANSITION_CHANGED**
Triggered when the current transition has changed by the user.
- **OBS_FRONTEND_EVENT_TRANSITION_STOPPED**
Triggered when a transition has completed.
- **OBS_FRONTEND_EVENT_TRANSITION_LIST_CHANGED**
Triggered when the user adds/removes transitions.
- **OBS_FRONTEND_EVENT_TRANSITION_DURATION_CHANGED**
Triggered when the transition duration has been changed by the
user.
- **OBS_FRONTEND_EVENT_TBAR_VALUE_CHANGED**
Triggered when the transition bar is moved.
- **OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGING**
Triggered when the current scene collection is about to change.
- **OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED**
Triggered when the current scene collection has changed.
- **OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED**
Triggered when a scene collection has been added or removed.
- **OBS_FRONTEND_EVENT_SCENE_COLLECTION_RENAMED**
Triggered when a scene collection has been renamed.
- **OBS_FRONTEND_EVENT_PROFILE_CHANGING**
Triggered when the current profile is about to change.
- **OBS_FRONTEND_EVENT_PROFILE_CHANGED**
Triggered when the current profile has changed.
- **OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED**
Triggered when a profile has been added or removed.
- **OBS_FRONTEND_EVENT_PROFILE_RENAMED**
Triggered when a profile has been renamed.
- **OBS_FRONTEND_EVENT_FINISHED_LOADING**
Triggered when the program has finished loading.
- **OBS_FRONTEND_EVENT_SCRIPTING_SHUTDOWN**
Triggered when scripts need to know that OBS is exiting. The
**OBS_FRONTEND_EVENT_EXIT** event is normally called after scripts
have been destroyed.
- **OBS_FRONTEND_EVENT_EXIT**
Triggered when the program is about to exit.
- **OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTING**
Triggered when the replay buffer is starting.
- **OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTED**
Triggered when the replay buffer has successfully started.
- **OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPING**
Triggered when the replay buffer is stopping.
- **OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPED**
Triggered when the replay buffer has fully stopped.
- **OBS_FRONTEND_EVENT_REPLAY_BUFFER_SAVED**
Triggered when the replay buffer has been saved.
- **OBS_FRONTEND_EVENT_STUDIO_MODE_ENABLED**
Triggered when the user has turned on studio mode.
- **OBS_FRONTEND_EVENT_STUDIO_MODE_DISABLED**
Triggered when the user has turned off studio mode.
- **OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED**
Triggered when the current preview scene has changed in studio
mode.
- **OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP**
Triggered when a scene collection has been completely unloaded, and
the program is either about to load a new scene collection, or the
program is about to exit.
- **OBS_FRONTEND_EVENT_VIRTUALCAM_STARTED**
Triggered when the virtual camera is started.
- **OBS_FRONTEND_EVENT_VIRTUALCAM_STOPPED**
Triggered when the virtual camera is stopped.
- **OBS_FRONTEND_EVENT_THEME_CHANGED**
Triggered when the theme is changed.
.. versionadded:: 29.0.0
- **OBS_FRONTEND_EVENT_SCREENSHOT_TAKEN**
Triggered when a screenshot is taken.
.. versionadded:: 29.0.0
.. struct:: obs_frontend_source_list
- DARRAY(obs_source_t*) **sources**
Example usage:
.. code:: cpp
struct obs_frontend_source_list scenes = {0};
obs_frontend_get_scenes(&scenes);
for (size_t i = 0; i < scenes.num; i++) {
obs_source_t *source = scenes.sources.array[i];
[...]
}
obs_frontend_source_list_free(&scenes);
.. type:: void (*obs_frontend_cb)(void *private_data)
Frontend tool menu callback
.. type:: void (*obs_frontend_event_cb)(enum obs_frontend_event event, void *private_data)
Frontend event callback
.. type:: void (*obs_frontend_save_cb)(obs_data_t *save_data, bool saving, void *private_data)
Frontend save/load callback
.. type:: bool (*obs_frontend_translate_ui_cb)(const char *text, const char **out)
Translation callback
Functions
---------
.. function:: void obs_frontend_source_list_free(struct obs_frontend_source_list *source_list)
Releases sources within a source list and frees the list.
:param source_list: Source list to free
---------------------------------------
.. function:: void *obs_frontend_get_main_window(void)
:return: The QMainWindow pointer to the OBS Studio window
---------------------------------------
.. function:: void *obs_frontend_get_main_window_handle(void)
:return: The native window handle of the OBS Studio window
---------------------------------------
.. function:: char **obs_frontend_get_scene_names(void)
:return: The scene name list, ending with NULL. The list is stored
within one contiguous segment of memory, so freeing the
returned pointer with :c:func:`bfree()` will free the entire
list.
---------------------------------------
.. function:: void obs_frontend_get_scenes(struct obs_frontend_source_list *sources)
:param sources: Pointer to a :c:type:`obs_frontend_source_list`
structure to receive the list of
reference-incremented scenes. Release with
:c:func:`obs_frontend_source_list_free`
---------------------------------------
.. function:: obs_source_t *obs_frontend_get_current_scene(void)
:return: A new reference to the currently active scene. Release with
:c:func:`obs_source_release()`.
---------------------------------------
.. function:: void obs_frontend_set_current_scene(obs_source_t *scene)
:param scene: The scene to set as the current scene
---------------------------------------
.. function:: void obs_frontend_get_transitions(struct obs_frontend_source_list *sources)
:param sources: Pointer to a :c:type:`obs_frontend_source_list`
structure to receive the list of
reference-incremented transitions. Release with
:c:func:`obs_frontend_source_list_free`
---------------------------------------
.. function:: obs_source_t *obs_frontend_get_current_transition(void)
:return: A new reference to the currently active transition.
Release with :c:func:`obs_source_release()`.
---------------------------------------
.. function:: void obs_frontend_set_current_transition(obs_source_t *transition)
:param transition: The transition to set as the current transition
---------------------------------------
.. function:: int obs_frontend_get_transition_duration(void)
:return: The transition duration (in milliseconds) currently set in the UI
---------------------------------------
.. function:: void obs_frontend_set_transition_duration(int duration)
:param duration: Desired transition duration, in milliseconds
---------------------------------------
.. function:: void obs_frontend_release_tbar(void)
Emulate a mouse button release on the transition bar and determine transition status.
---------------------------------------
.. function:: void obs_frontend_set_tbar_position(int position)
Set the value of the transition bar.
:param position: The position to set the T-bar to, with a range of 0-1023
---------------------------------------
.. function:: int obs_frontend_get_tbar_position(void)
Get the value of the transition bar.
:return: The value of the position of the T-bar to, with a range of 0-1023
---------------------------------------
.. function:: char **obs_frontend_get_scene_collections(void)
:return: The list of profile names, ending with NULL. The list is
stored within one contiguous segment of memory, so freeing
the returned pointer with :c:func:`bfree()` will free the
entire list.
---------------------------------------
.. function:: char *obs_frontend_get_current_scene_collection(void)
:return: A new pointer to the current scene collection name. Free
with :c:func:`bfree()`
---------------------------------------
.. function:: void obs_frontend_set_current_scene_collection(const char *collection)
:param profile: Name of the scene collection to activate
---------------------------------------
.. function:: bool obs_frontend_add_scene_collection(const char *name)
Add a new scene collection, then switch to it.
:param name: Name of the scene collection to add/create
---------------------------------------
.. function:: char **obs_frontend_get_profiles(void)
:return: The list of profile names, ending with NULL. The list is
stored within one contiguous segment of memory, so freeing
the returned pointer with :c:func:`bfree()` will free the
entire list.
---------------------------------------
.. function:: char *obs_frontend_get_current_profile(void)
:return: A new pointer to the current profile name. Free with
:c:func:`bfree()`
---------------------------------------
.. function:: char *obs_frontend_get_current_profile_path(void)
:return: A new pointer to the current profile's path on the
filesystem. Free with :c:func:`bfree()`
---------------------------------------
.. function:: void obs_frontend_set_current_profile(const char *profile)
:param profile: Name of the profile to activate
---------------------------------------
.. function:: bool obs_frontend_create_profile(const char *name)
:param name: Name of the new profile to create (must be unique)
---------------------------------------
.. function:: bool obs_frontend_duplicate_profile(const char *name)
:param name: Name of the duplicate profile to create (must be unique)
---------------------------------------
.. function:: void obs_frontend_delete_profile(const char *profile)
:param profile: Name of the profile to delete
---------------------------------------
.. function:: void *obs_frontend_add_tools_menu_qaction(const char *name)
Adds a QAction to the tools menu then returns it.
:param name: Name for the new menu item
:return: A pointer to the added QAction
---------------------------------------
.. function:: void obs_frontend_add_tools_menu_item(const char *name, obs_frontend_cb callback, void *private_data)
Adds a tools menu item and links the ::clicked signal to the
callback.
:param name: The name for the new menu item
:param callback: Callback to use when the menu item is clicked
:param private_data: Private data associated with the callback
---------------------------------------
.. function:: void* obs_frontend_add_dock(void *dock)
Adds a QDockWidget to the UI's Docks menu.
:param dock: QDockWidget to add/create
:return: A pointer to the added QAction
---------------------------------------
.. function:: void obs_frontend_add_event_callback(obs_frontend_event_cb callback, void *private_data)
Adds a callback that will be called when a frontend event occurs.
See :c:type:`obs_frontend_event` on what sort of events can be
triggered.
:param callback: Callback to use when a frontend event occurs
:param private_data: Private data associated with the callback
---------------------------------------
.. function:: void obs_frontend_remove_event_callback(obs_frontend_event_cb callback, void *private_data)
Removes an event callback.
:param callback: Callback to remove
:param private_data: Private data associated with the callback
---------------------------------------
.. function:: void obs_frontend_add_save_callback(obs_frontend_save_cb callback, void *private_data)
Adds a callback that will be called when the current scene collection
is being saved/loaded.
:param callback: Callback to use when saving/loading a scene
collection
:param private_data: Private data associated with the callback
---------------------------------------
.. function:: void obs_frontend_remove_save_callback(obs_frontend_save_cb callback, void *private_data)
Removes a save/load callback.
:param callback: Callback to remove
:param private_data: Private data associated with the callback
---------------------------------------
.. function:: void obs_frontend_add_preload_callback(obs_frontend_save_cb callback, void *private_data)
Adds a callback that will be called right before a scene collection
is loaded.
:param callback: Callback to use when pre-loading
:param private_data: Private data associated with the callback
---------------------------------------
.. function:: void obs_frontend_remove_preload_callback(obs_frontend_save_cb callback, void *private_data)
Removes a pre-load callback.
:param callback: Callback to remove
:param private_data: Private data associated with the callback
---------------------------------------
.. function:: void obs_frontend_push_ui_translation(obs_frontend_translate_ui_cb translate)
Pushes a UI translation callback. This allows a front-end plugin to
intercept when Qt is automatically generating translating data.
Typically this is just called with obs_module_get_string.
:param translate: The translation callback to use
---------------------------------------
.. function:: void obs_frontend_pop_ui_translation(void)
Pops the current UI translation callback.
---------------------------------------
.. function:: void obs_frontend_streaming_start(void)
Starts streaming.
---------------------------------------
.. function:: void obs_frontend_streaming_stop(void)
Stops streaming.
---------------------------------------
.. function:: bool obs_frontend_streaming_active(void)
:return: *true* if streaming active, *false* otherwise
---------------------------------------
.. function:: void obs_frontend_recording_start(void)
Starts recording.
---------------------------------------
.. function:: void obs_frontend_recording_stop(void)
Stops recording.
---------------------------------------
.. function:: bool obs_frontend_recording_active(void)
:return: *true* if recording active, *false* otherwise
---------------------------------------
.. function:: void obs_frontend_recording_pause(bool pause)
:pause: *true* to pause recording, *false* to unpause
---------------------------------------
.. function:: bool obs_frontend_recording_paused(void)
:return: *true* if recording paused, *false* otherwise
---------------------------------------
.. function:: bool obs_frontend_recording_split_file(void)
Asks OBS to split the current recording file.
:return: *true* if splitting was successfully requested (this
does not mean that splitting has finished or guarantee that it
split successfully), *false* if recording is inactive or paused
or if file splitting is disabled.
---------------------------------------
.. function:: void obs_frontend_replay_buffer_start(void)
Starts the replay buffer.
---------------------------------------
.. function:: void obs_frontend_replay_buffer_stop(void)
Stops the replay buffer.
---------------------------------------
.. function:: void obs_frontend_replay_buffer_save(void)
Saves a replay if the replay buffer is active.
---------------------------------------
.. function:: bool obs_frontend_replay_buffer_active(void)
:return: *true* if replay buffer active, *false* otherwise
---------------------------------------
.. function:: void obs_frontend_open_projector(const char *type, int monitor, const char *geometry, const char *name)
:param type: "Preview", "Source", "Scene", "StudioProgram", or "Multiview" (case insensitive)
:param monitor: Monitor to open the projector on. If -1, this opens a window.
:param geometry: If *monitor* is -1, size and position of the projector window. Encoded in Base64 using Qt's geometry encoding.
:param name: If *type* is "Source" or "Scene", name of the source or scene to be displayed
---------------------------------------
.. function:: void obs_frontend_save(void)
Saves the current scene collection.
---------------------------------------
.. function:: obs_output_t *obs_frontend_get_streaming_output(void)
:return: A new reference to the current streaming output.
Release with :c:func:`obs_output_release()`.
---------------------------------------
.. function:: obs_output_t *obs_frontend_get_recording_output(void)
:return: A new reference to the current recording output.
Release with :c:func:`obs_output_release()`.
---------------------------------------
.. function:: obs_output_t *obs_frontend_get_replay_buffer_output(void)
:return: A new reference to the current replay buffer output.
Release with :c:func:`obs_output_release()`.
---------------------------------------
.. function:: config_t *obs_frontend_get_profile_config(void)
:return: The config_t* associated with the current profile
---------------------------------------
.. function:: config_t *obs_frontend_get_global_config(void)
:return: The config_t* associated with the global config (global.ini)
---------------------------------------
.. function:: void obs_frontend_set_streaming_service(obs_service_t *service)
Sets the current streaming service to stream with.
:param service: The streaming service to set
---------------------------------------
.. function:: obs_service_t *obs_frontend_get_streaming_service(void)
:return: The current streaming service object. Does not increment the
reference.
---------------------------------------
.. function:: void obs_frontend_save_streaming_service(void)
Saves the current streaming service data.
---------------------------------------
.. function:: bool obs_frontend_preview_program_mode_active(void)
:return: *true* if studio mode is active, *false* otherwise
---------------------------------------
.. function:: void obs_frontend_set_preview_program_mode(bool enable)
Activates/deactivates studio mode.
:param enable: *true* to activate studio mode, *false* to deactivate
studio mode
---------------------------------------
.. function:: void obs_frontend_preview_program_trigger_transition(void)
Triggers a preview-to-program transition if studio mode is active.
---------------------------------------
.. function:: obs_source_t *obs_frontend_get_current_preview_scene(void)
:return: A new reference to the current preview scene if studio mode
is active, or *NULL* if studio mode is not active. Release
with :c:func:`obs_source_release()`.
---------------------------------------
.. function:: void obs_frontend_set_current_preview_scene(obs_source_t *scene)
Sets the current preview scene in studio mode. Does nothing if studio
mode is disabled.
:param scene: The scene to set as the current preview
---------------------------------------
.. function:: void obs_frontend_set_preview_enabled(bool enable)
Sets the enable state of the preview display. Only relevant with
studio mode disabled.
:param enable: *true* to enable preview, *false* to disable preview
---------------------------------------
.. function:: bool obs_frontend_preview_enabled(void)
:return: *true* if the preview display is enabled, *false* otherwise
---------------------------------------
.. function:: void *obs_frontend_take_screenshot(void)
Takes a screenshot of the main OBS output.
---------------------------------------
.. function:: void *obs_frontend_take_source_screenshot(obs_source_t *source)
Takes a screenshot of the specified source.
:param source: The source to take screenshot of
---------------------------------------
.. function:: obs_output_t *obs_frontend_get_virtualcam_output(void)
:return: A new reference to the current virtual camera output.
Release with :c:func:`obs_output_release()`.
---------------------------------------
.. function:: void obs_frontend_start_virtualcam(void)
Starts the virtual camera.
---------------------------------------
.. function:: void obs_frontend_stop_virtualcam(void)
Stops the virtual camera.
---------------------------------------
.. function:: bool obs_frontend_virtualcam_active(void)
:return: *true* if virtual camera is active, *false* otherwise
---------------------------------------
.. function:: void obs_frontend_reset_video(void)
Reloads the UI canvas and resets libobs video with latest data from
the current profile.
---------------------------------------
.. function:: void *obs_frontend_open_source_properties(obs_source_t *source)
Opens the properties window of the specified source.
:param source: The source to open the properties window of
---------------------------------------
.. function:: void *obs_frontend_open_source_filters(obs_source_t *source)
Opens the filters window of the specified source.
:param source: The source to open the filters window of
---------------------------------------
.. function:: void *obs_frontend_open_source_interaction(obs_source_t *source)
Opens the interact window of the specified source. Only call if
source has the *OBS_SOURCE_INTERACTION* output flag.
:param source: The source to open the interact window of
---------------------------------------
.. function:: char *obs_frontend_get_current_record_output_path(void)
:return: A new pointer to the current record output path. Free
with :c:func:`bfree()`
---------------------------------------
.. function:: const char *obs_frontend_get_locale_string(const char *string)
:return: Gets the frontend translation of a given string.
---------------------------------------
.. function:: bool obs_frontend_is_theme_dark(void)
:return: Checks if the current theme is dark or light.
.. versionadded:: 29.0.0
---------------------------------------
.. function:: char *obs_frontend_get_last_recording(void)
:return: The file path of the last recording. Free with :c:func:`bfree()`
.. versionadded:: 29.0.0
---------------------------------------
.. function:: char *obs_frontend_get_last_screenshot(void)
:return: The file path of the last screenshot taken. Free with
:c:func:`bfree()`
.. versionadded:: 29.0.0
---------------------------------------
.. function:: char *obs_frontend_get_last_replay(void)
:return: The file path of the last replay buffer saved. Free with
:c:func:`bfree()`
.. versionadded:: 29.0.0
|