reference-frontend-api.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. OBS Studio Frontend API
  2. =======================
  3. The OBS Studio frontend API is the API specific to OBS Studio itself.
  4. .. code:: cpp
  5. #include <obs-frontend-api.h>
  6. Structures/Enumerations
  7. -----------------------
  8. .. type:: enum obs_frontend_event
  9. Specifies a front-end event. Can be one of the following values:
  10. - **OBS_FRONTEND_EVENT_STREAMING_STARTING**
  11. Triggered when streaming is starting.
  12. - **OBS_FRONTEND_EVENT_STREAMING_STARTED**
  13. Triggered when streaming has successfully started.
  14. - **OBS_FRONTEND_EVENT_STREAMING_STOPPING**
  15. Triggered when streaming is stopping.
  16. - **OBS_FRONTEND_EVENT_STREAMING_STOPPED**
  17. Triggered when streaming has fully stopped.
  18. - **OBS_FRONTEND_EVENT_RECORDING_STARTING**
  19. Triggered when recording is starting.
  20. - **OBS_FRONTEND_EVENT_RECORDING_STARTED**
  21. Triggered when recording has successfully started.
  22. - **OBS_FRONTEND_EVENT_RECORDING_STOPPING**
  23. Triggered when recording is stopping.
  24. - **OBS_FRONTEND_EVENT_RECORDING_STOPPED**
  25. Triggered when recording has fully stopped.
  26. - **OBS_FRONTEND_EVENT_SCENE_CHANGED**
  27. Triggered when the current scene has changed.
  28. - **OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED**
  29. Triggered when a scenes has been added/removed/reordered by the
  30. user.
  31. - **OBS_FRONTEND_EVENT_TRANSITION_CHANGED**
  32. Triggered when the current transition has changed by the user.
  33. - **OBS_FRONTEND_EVENT_TRANSITION_STOPPED**
  34. Triggered when a transition has completed.
  35. - **OBS_FRONTEND_EVENT_TRANSITION_LIST_CHANGED**
  36. Triggered when the user adds/removes transitions.
  37. - **OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED**
  38. Triggered when the user has changed the current scene collection.
  39. - **OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED**
  40. Triggered when the user has added/removed/renamed scene
  41. collections.
  42. - **OBS_FRONTEND_EVENT_PROFILE_CHANGED**
  43. Triggered when the user has changed the current profile.
  44. - **OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED**
  45. Triggered when the user has added/removed/renamed profiles.
  46. - **OBS_FRONTEND_EVENT_EXIT**
  47. Triggered when the program is about to exit.
  48. - **OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTING**
  49. Triggered when the replay buffer is starting.
  50. - **OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTED**
  51. Triggered when the replay buffer has successfully started.
  52. - **OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPING**
  53. Triggered when the replay buffer is stopping.
  54. - **OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPED**
  55. Triggered when the replay buffer has fully stopped.
  56. - **OBS_FRONTEND_EVENT_STUDIO_MODE_ENABLED**
  57. Triggered when the user has turned on studio mode.
  58. - **OBS_FRONTEND_EVENT_STUDIO_MODE_DISABLED**
  59. Triggered when the user has turned off studio mode.
  60. - **OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED**
  61. Triggered when the current preview scene has changed in studio
  62. mode.
  63. - **OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP**
  64. Triggered when a scene collection has been completely unloaded, and
  65. the program is either about to load a new scene collection, or the
  66. program is about to exit.
  67. - **OBS_FRONTEND_FINISHED_LOADING**
  68. Triggered when the program has finished loading.
  69. - **OBS_FRONTEND_EVENT_RECORDING_PAUSED**
  70. Triggered when the recording has been paused.
  71. - **OBS_FRONTEND_EVENT_RECORDING_UNPAUSED**
  72. Triggered when the recording has been unpaused.
  73. .. type:: struct obs_frontend_source_list
  74. - DARRAY(obs_source_t*) **sources**
  75. Example usage:
  76. .. code:: cpp
  77. struct obs_frontend_source_list scenes;
  78. obs_frontend_get_scenes(&scenes);
  79. for (size_t i = 0; i < scenes.num; i++) {
  80. obs_source_t *source = scenes.sources.array[i];
  81. [...]
  82. }
  83. obs_frontend_source_list_free(&scenes);
  84. .. type:: typedef void (*obs_frontend_cb)(void *private_data)
  85. Frontend tool menu callback.
  86. .. type:: typedef void (*obs_frontend_event_cb)(enum obs_frontend_event event, void *private_data)
  87. Frontend event callback.
  88. .. type:: typedef void (*obs_frontend_save_cb)(obs_data_t *save_data, bool saving, void *private_data)
  89. Frontend save/load callback.
  90. .. type:: typedef bool (*obs_frontend_translate_ui_cb)(const char *text, const char **out)
  91. Translation callback.
  92. Functions
  93. ---------
  94. .. function:: void obs_frontend_source_list_free(struct obs_frontend_source_list *source_list)
  95. Releases sources within a source list and frees the list.
  96. :param source_list: Source list to free.
  97. ---------------------------------------
  98. .. function:: void *obs_frontend_get_main_window(void)
  99. :return: The QMainWindow pointer to the OBS Studio window.
  100. ---------------------------------------
  101. .. function:: void *obs_frontend_get_main_window_handle(void)
  102. :return: The native window handle of the OBS Studio window.
  103. ---------------------------------------
  104. .. function:: char **obs_frontend_get_scene_names(void)
  105. :return: The scene name list, ending with NULL. The list is stored
  106. within one contiguous segment of memory, so freeing the
  107. returned pointer with :c:func:`bfree()` will free the entire
  108. list.
  109. ---------------------------------------
  110. .. function:: void obs_frontend_get_scenes(struct obs_frontend_source_list *sources)
  111. :param sources: Pointer to a :c:type:`obs_frontend_source_list`
  112. structure to receive the list of
  113. reference-incremented scenes. Release with
  114. :c:func:`obs_frontend_source_list_free`.
  115. ---------------------------------------
  116. .. function:: obs_source_t *obs_frontend_get_current_scene(void)
  117. :return: A new reference to the currently active scene.
  118. ---------------------------------------
  119. .. function:: void obs_frontend_set_current_scene(obs_source_t *scene)
  120. :param scene: The scene to set as the current scene.
  121. ---------------------------------------
  122. .. function:: void obs_frontend_get_transitions(struct obs_frontend_source_list *sources)
  123. :param sources: Pointer to a :c:type:`obs_frontend_source_list`
  124. structure to receive the list of
  125. reference-incremented transitions. Release with
  126. :c:func:`obs_frontend_source_list_free`.
  127. ---------------------------------------
  128. .. function:: obs_source_t *obs_frontend_get_current_transition(void)
  129. :return: A new reference to the currently active transition.
  130. ---------------------------------------
  131. .. function:: void obs_frontend_set_current_transition(obs_source_t *transition)
  132. :param transition: The transition to set as the current transition.
  133. ---------------------------------------
  134. .. function:: int obs_frontend_get_transition_duration(void)
  135. :return: The transition duration (in milliseconds) currently set in the UI.
  136. ---------------------------------------
  137. .. function:: void obs_frontend_set_transition_duration(int duration)
  138. :param duration: Desired transition duration (in milliseconds)
  139. ---------------------------------------
  140. .. function:: char **obs_frontend_get_scene_collections(void)
  141. :return: The list of profile names, ending with NULL. The list is
  142. stored within one contiguous segment of memory, so freeing
  143. the returned pointer with :c:func:`bfree()` will free the
  144. entire list.
  145. ---------------------------------------
  146. .. function:: char *obs_frontend_get_current_scene_collection(void)
  147. :return: A new pointer to the current scene collection name. Free
  148. with :c:func:`bfree()`.
  149. ---------------------------------------
  150. .. function:: void obs_frontend_set_current_scene_collection(const char *collection)
  151. :param profile: Name of the scene collection to activate.
  152. ---------------------------------------
  153. .. function:: char **obs_frontend_get_profiles(void)
  154. :return: The list of profile names, ending with NULL. The list is
  155. stored within one contiguous segment of memory, so freeing
  156. the returned pointer with :c:func:`bfree()` will free the
  157. entire list.
  158. ---------------------------------------
  159. .. function:: char *obs_frontend_get_current_profile(void)
  160. :return: A new pointer to the current profile name. Free with
  161. :c:func:`bfree()`.
  162. ---------------------------------------
  163. .. function:: void obs_frontend_set_current_profile(const char *profile)
  164. :param profile: Name of the profile to activate.
  165. ---------------------------------------
  166. .. function:: void obs_frontend_add_event_callback(obs_frontend_event_cb callback, void *private_data)
  167. Adds a callback that will be called when a frontend event occurs.
  168. See :c:type:`obs_frontend_event` on what sort of events can be
  169. triggered.
  170. :param callback: Callback to use when a frontend event occurs.
  171. :param private_data: Private data associated with the callback.
  172. ---------------------------------------
  173. .. function:: void obs_frontend_remove_event_callback(obs_frontend_event_cb callback, void *private_data)
  174. Removes an event callback.
  175. :param callback: Callback to remove.
  176. :param private_data: Private data associated with the callback.
  177. ---------------------------------------
  178. .. function:: void obs_frontend_add_save_callback(obs_frontend_save_cb callback, void *private_data)
  179. Adds a callback that will be called when the current scene collection
  180. is being saved/loaded.
  181. :param callback: Callback to use when saving/loading a scene
  182. collection.
  183. :param private_data: Private data associated with the callback.
  184. ---------------------------------------
  185. .. function:: void obs_frontend_remove_save_callback(obs_frontend_save_cb callback, void *private_data)
  186. Removes a save/load callback.
  187. :param callback: Callback to remove.
  188. :param private_data: Private data associated with the callback.
  189. ---------------------------------------
  190. .. function:: void obs_frontend_add_preload_callback(obs_frontend_save_cb callback, void *private_data)
  191. Adds a callback that will be called right before a scene collection
  192. is loaded. Useful if you
  193. :param callback: Callback to use when pre-loading.
  194. :param private_data: Private data associated with the callback.
  195. ---------------------------------------
  196. .. function:: void obs_frontend_remove_preload_callback(obs_frontend_save_cb callback, void *private_data)
  197. Removes a pre-load callback.
  198. :param callback: Callback to remove.
  199. :param private_data: Private data associated with the callback.
  200. ---------------------------------------
  201. .. function:: void obs_frontend_push_ui_translation(obs_frontend_translate_ui_cb translate)
  202. Pushes a UI translation callback. This allows a front-end plugin to
  203. intercept when Qt is automatically generating translating data.
  204. Typically this is just called with obs_module_get_string.
  205. :param translate: The translation callback to use.
  206. ---------------------------------------
  207. .. function:: void obs_frontend_pop_ui_translation(void)
  208. Pops the current UI translation callback.
  209. ---------------------------------------
  210. .. function:: void obs_frontend_streaming_start(void)
  211. Starts streaming.
  212. ---------------------------------------
  213. .. function:: void obs_frontend_streaming_stop(void)
  214. Stops streaming.
  215. ---------------------------------------
  216. .. function:: bool obs_frontend_streaming_active(void)
  217. :return: *true* if streaming active, *false* otherwise.
  218. ---------------------------------------
  219. .. function:: void obs_frontend_recording_start(void)
  220. Starts recording.
  221. ---------------------------------------
  222. .. function:: void obs_frontend_recording_stop(void)
  223. Stops recording.
  224. ---------------------------------------
  225. .. function:: bool obs_frontend_recording_active(void)
  226. :return: *true* if recording active, *false* otherwise.
  227. ---------------------------------------
  228. .. function:: void obs_frontend_recording_pause(bool pause)
  229. :pause: *true* to pause recording, *false* to unpause.
  230. ---------------------------------------
  231. .. function:: bool obs_frontend_recording_paused(void)
  232. :return: *true* if recording paused, *false* otherwise.
  233. ---------------------------------------
  234. .. function:: void obs_frontend_replay_buffer_start(void)
  235. Starts replay buffer.
  236. ---------------------------------------
  237. .. function:: void obs_frontend_replay_buffer_stop(void)
  238. Stops replay buffer.
  239. ---------------------------------------
  240. .. function:: void obs_frontend_replay_buffer_save(void)
  241. Saves a replay if the replay buffer is active.
  242. ---------------------------------------
  243. .. function:: bool obs_frontend_replay_buffer_active(void)
  244. :return: *true* if replay buffer active, *false* otherwise.
  245. ---------------------------------------
  246. .. function:: void obs_frontend_save(void)
  247. Saves the current scene collection.
  248. ---------------------------------------
  249. .. function:: obs_output_t *obs_frontend_get_streaming_output(void)
  250. :return: A new reference to the current streaming output.
  251. ---------------------------------------
  252. .. function:: obs_output_t *obs_frontend_get_recording_output(void)
  253. :return: A new reference to the current srecording output.
  254. ---------------------------------------
  255. .. function:: obs_output_t *obs_frontend_get_replay_buffer_output(void)
  256. :return: A new reference to the current replay buffer output.
  257. ---------------------------------------
  258. .. function:: void obs_frontend_set_streaming_service(obs_service_t *service)
  259. Sets the current streaming service to stream with.
  260. :param service: The streaming service to set.
  261. ---------------------------------------
  262. .. function:: obs_service_t *obs_frontend_get_streaming_service(void)
  263. :return: A new reference to the current streaming service object.
  264. ---------------------------------------
  265. .. function:: void obs_frontend_save_streaming_service(void)
  266. Saves the current streaming service data.
  267. ---------------------------------------
  268. .. function:: bool obs_frontend_preview_program_mode_active(void)
  269. :return: *true* if studio mode is active, *false* otherwise.
  270. ---------------------------------------
  271. .. function:: void obs_frontend_set_preview_program_mode(bool enable)
  272. Activates/deactivates studio mode.
  273. :param enable: *true* to activate studio mode, *false* to deactivate
  274. studio mode.
  275. ---------------------------------------
  276. .. function:: void obs_frontend_preview_program_trigger_transition(void)
  277. Triggers a preview-to-program transition if studio mode is active.
  278. ---------------------------------------
  279. .. function:: obs_source_t *obs_frontend_get_current_preview_scene(void)
  280. :return: A new reference to the current preview scene if studio mode
  281. is active, or the current scene if studio mode is not
  282. active.
  283. ---------------------------------------
  284. .. function:: void obs_frontend_set_current_preview_scene(obs_source_t *scene)
  285. Sets the current preview scene in studio mode, or the currently
  286. active scene if not in studio mode.
  287. :param scene: The scene to set as the current preview.