1 #pragma once
2
3 #include <obs.h>
4 #include <util/darray.h>
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 struct config_data;
11 typedef struct config_data config_t;
12
13 struct obs_data;
14 typedef struct obs_data obs_data_t;
15
16 enum obs_frontend_event {
17 OBS_FRONTEND_EVENT_STREAMING_STARTING,
18 OBS_FRONTEND_EVENT_STREAMING_STARTED,
19 OBS_FRONTEND_EVENT_STREAMING_STOPPING,
20 OBS_FRONTEND_EVENT_STREAMING_STOPPED,
21 OBS_FRONTEND_EVENT_RECORDING_STARTING,
22 OBS_FRONTEND_EVENT_RECORDING_STARTED,
23 OBS_FRONTEND_EVENT_RECORDING_STOPPING,
24 OBS_FRONTEND_EVENT_RECORDING_STOPPED,
25 OBS_FRONTEND_EVENT_SCENE_CHANGED,
26 OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED,
27 OBS_FRONTEND_EVENT_TRANSITION_CHANGED,
28 OBS_FRONTEND_EVENT_TRANSITION_STOPPED,
29 OBS_FRONTEND_EVENT_TRANSITION_LIST_CHANGED,
30 OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED,
31 OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED,
32 OBS_FRONTEND_EVENT_PROFILE_CHANGED,
33 OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED,
34 OBS_FRONTEND_EVENT_EXIT,
35
36 OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTING,
37 OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTED,
38 OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPING,
39 OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPED,
40
41 OBS_FRONTEND_EVENT_STUDIO_MODE_ENABLED,
42 OBS_FRONTEND_EVENT_STUDIO_MODE_DISABLED,
43 OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED,
44
45 OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP,
46 OBS_FRONTEND_EVENT_FINISHED_LOADING,
47
48 OBS_FRONTEND_EVENT_RECORDING_PAUSED,
49 OBS_FRONTEND_EVENT_RECORDING_UNPAUSED,
50
51 OBS_FRONTEND_EVENT_TRANSITION_DURATION_CHANGED,
52 OBS_FRONTEND_EVENT_REPLAY_BUFFER_SAVED,
53
54 OBS_FRONTEND_EVENT_VIRTUALCAM_STARTED,
55 OBS_FRONTEND_EVENT_VIRTUALCAM_STOPPED,
56
57 OBS_FRONTEND_EVENT_TBAR_VALUE_CHANGED,
58 };
59
60 /* ------------------------------------------------------------------------- */
61
62 #ifndef SWIG
63
64 struct obs_frontend_source_list {
65 DARRAY(obs_source_t *) sources;
66 };
67
68 static inline void
obs_frontend_source_list_free(struct obs_frontend_source_list * source_list)69 obs_frontend_source_list_free(struct obs_frontend_source_list *source_list)
70 {
71 size_t num = source_list->sources.num;
72 for (size_t i = 0; i < num; i++)
73 obs_source_release(source_list->sources.array[i]);
74 da_free(source_list->sources);
75 }
76
77 #endif //!SWIG
78
79 /* ------------------------------------------------------------------------- */
80
81 /* NOTE: Functions that return char** string lists are a single allocation of
82 * memory with pointers to itself. Free with a single call to bfree on the
83 * base char** pointer. */
84
85 /* NOTE: User interface should not use typical Qt locale translation methods,
86 * as the OBS UI bypasses it to use a custom translation implementation. Use
87 * standard module translation methods, obs_module_text. For text in a Qt
88 * window, use obs_frontend_push_ui_translation when the text is about to be
89 * translated, and obs_frontend_pop_ui_translation when translation is
90 * complete. */
91
92 #ifndef SWIG
93
94 EXPORT void *obs_frontend_get_main_window(void);
95 EXPORT void *obs_frontend_get_main_window_handle(void);
96 EXPORT void *obs_frontend_get_system_tray(void);
97
98 EXPORT char **obs_frontend_get_scene_names(void);
99 EXPORT void obs_frontend_get_scenes(struct obs_frontend_source_list *sources);
100 EXPORT obs_source_t *obs_frontend_get_current_scene(void);
101 EXPORT void obs_frontend_set_current_scene(obs_source_t *scene);
102
103 EXPORT void
104 obs_frontend_get_transitions(struct obs_frontend_source_list *sources);
105 EXPORT obs_source_t *obs_frontend_get_current_transition(void);
106 EXPORT void obs_frontend_set_current_transition(obs_source_t *transition);
107 EXPORT int obs_frontend_get_transition_duration(void);
108 EXPORT void obs_frontend_set_transition_duration(int duration);
109 EXPORT void obs_frontend_release_tbar(void);
110 EXPORT void obs_frontend_set_tbar_position(int position);
111 EXPORT int obs_frontend_get_tbar_position(void);
112
113 EXPORT char **obs_frontend_get_scene_collections(void);
114 EXPORT char *obs_frontend_get_current_scene_collection(void);
115 EXPORT void obs_frontend_set_current_scene_collection(const char *collection);
116 EXPORT bool obs_frontend_add_scene_collection(const char *name);
117
118 EXPORT char **obs_frontend_get_profiles(void);
119 EXPORT char *obs_frontend_get_current_profile(void);
120 EXPORT char *obs_frontend_get_current_profile_path(void);
121 EXPORT void obs_frontend_set_current_profile(const char *profile);
122 EXPORT void obs_frontend_create_profile(const char *name);
123 EXPORT void obs_frontend_duplicate_profile(const char *name);
124 EXPORT void obs_frontend_delete_profile(const char *profile);
125
126 typedef void (*obs_frontend_cb)(void *private_data);
127
128 EXPORT void *obs_frontend_add_tools_menu_qaction(const char *name);
129 EXPORT void obs_frontend_add_tools_menu_item(const char *name,
130 obs_frontend_cb callback,
131 void *private_data);
132
133 /* takes QDockWidget and returns QAction */
134 EXPORT void *obs_frontend_add_dock(void *dock);
135
136 typedef void (*obs_frontend_event_cb)(enum obs_frontend_event event,
137 void *private_data);
138
139 EXPORT void obs_frontend_add_event_callback(obs_frontend_event_cb callback,
140 void *private_data);
141 EXPORT void obs_frontend_remove_event_callback(obs_frontend_event_cb callback,
142 void *private_data);
143
144 typedef void (*obs_frontend_save_cb)(obs_data_t *save_data, bool saving,
145 void *private_data);
146
147 EXPORT void obs_frontend_add_save_callback(obs_frontend_save_cb callback,
148 void *private_data);
149 EXPORT void obs_frontend_remove_save_callback(obs_frontend_save_cb callback,
150 void *private_data);
151
152 EXPORT void obs_frontend_add_preload_callback(obs_frontend_save_cb callback,
153 void *private_data);
154 EXPORT void obs_frontend_remove_preload_callback(obs_frontend_save_cb callback,
155 void *private_data);
156
157 typedef bool (*obs_frontend_translate_ui_cb)(const char *text,
158 const char **out);
159
160 EXPORT void
161 obs_frontend_push_ui_translation(obs_frontend_translate_ui_cb translate);
162 EXPORT void obs_frontend_pop_ui_translation(void);
163
164 #endif //!SWIG
165
166 EXPORT void obs_frontend_streaming_start(void);
167 EXPORT void obs_frontend_streaming_stop(void);
168 EXPORT bool obs_frontend_streaming_active(void);
169
170 EXPORT void obs_frontend_recording_start(void);
171 EXPORT void obs_frontend_recording_stop(void);
172 EXPORT bool obs_frontend_recording_active(void);
173 EXPORT void obs_frontend_recording_pause(bool pause);
174 EXPORT bool obs_frontend_recording_paused(void);
175
176 EXPORT void obs_frontend_replay_buffer_start(void);
177 EXPORT void obs_frontend_replay_buffer_save(void);
178 EXPORT void obs_frontend_replay_buffer_stop(void);
179 EXPORT bool obs_frontend_replay_buffer_active(void);
180
181 EXPORT void obs_frontend_open_projector(const char *type, int monitor,
182 const char *geometry, const char *name);
183 EXPORT void obs_frontend_save(void);
184 EXPORT void obs_frontend_defer_save_begin(void);
185 EXPORT void obs_frontend_defer_save_end(void);
186
187 EXPORT obs_output_t *obs_frontend_get_streaming_output(void);
188 EXPORT obs_output_t *obs_frontend_get_recording_output(void);
189 EXPORT obs_output_t *obs_frontend_get_replay_buffer_output(void);
190
191 EXPORT config_t *obs_frontend_get_profile_config(void);
192 EXPORT config_t *obs_frontend_get_global_config(void);
193
194 EXPORT void obs_frontend_set_streaming_service(obs_service_t *service);
195 EXPORT obs_service_t *obs_frontend_get_streaming_service(void);
196 EXPORT void obs_frontend_save_streaming_service(void);
197
198 EXPORT bool obs_frontend_preview_program_mode_active(void);
199 EXPORT void obs_frontend_set_preview_program_mode(bool enable);
200 EXPORT void obs_frontend_preview_program_trigger_transition(void);
201
202 EXPORT void obs_frontend_set_preview_enabled(bool enable);
203 EXPORT bool obs_frontend_preview_enabled(void);
204
205 EXPORT obs_source_t *obs_frontend_get_current_preview_scene(void);
206 EXPORT void obs_frontend_set_current_preview_scene(obs_source_t *scene);
207
208 EXPORT void obs_frontend_take_screenshot(void);
209 EXPORT void obs_frontend_take_source_screenshot(obs_source_t *source);
210
211 EXPORT obs_output_t *obs_frontend_get_virtualcam_output(void);
212 EXPORT void obs_frontend_start_virtualcam(void);
213 EXPORT void obs_frontend_stop_virtualcam(void);
214 EXPORT bool obs_frontend_virtualcam_active(void);
215
216 EXPORT void obs_frontend_reset_video(void);
217
218 EXPORT void obs_frontend_open_source_properties(obs_source_t *source);
219 EXPORT void obs_frontend_open_source_filters(obs_source_t *source);
220
221 /* ------------------------------------------------------------------------- */
222
223 #ifdef __cplusplus
224 }
225 #endif
226