浏览代码

libobs: Add obs_save_sources_filtered (skip)

(Note: This commit breaks UI compilation.  Skip if bisecting)

Adds a means of saving specific sources that the front-end chooses,
rather than being forced to use the now-removed "user list".
Palana 10 年之前
父节点
当前提交
ec86bdaa09
共有 2 个文件被更改,包括 20 次插入2 次删除
  1. 16 2
      libobs/obs.c
  2. 4 0
      libobs/obs.h

+ 16 - 2
libobs/obs.c

@@ -1572,7 +1572,8 @@ obs_data_t *obs_save_source(obs_source_t *source)
 	return source_data;
 }
 
-obs_data_array_t *obs_save_sources(void)
+obs_data_array_t *obs_save_sources_filtered(obs_save_source_filter_cb cb,
+		void *data_)
 {
 	struct obs_core_data *data = &obs->data;
 	obs_data_array_t *array;
@@ -1587,7 +1588,8 @@ obs_data_array_t *obs_save_sources(void)
 	source = data->first_source;
 
 	while (source) {
-		if ((source->info.type == OBS_SOURCE_TYPE_INPUT) != 0) {
+		if ((source->info.type == OBS_SOURCE_TYPE_INPUT) != 0 &&
+				cb(data_, source)) {
 			obs_data_t *source_data = obs_save_source(source);
 
 			obs_data_array_push_back(array, source_data);
@@ -1602,6 +1604,18 @@ obs_data_array_t *obs_save_sources(void)
 	return array;
 }
 
+static bool save_source_filter(void *data, obs_source_t *source)
+{
+	UNUSED_PARAMETER(data);
+	UNUSED_PARAMETER(source);
+	return true;
+}
+
+obs_data_array_t *obs_save_sources(void)
+{
+	return obs_save_sources_filtered(save_source_filter, NULL);
+}
+
 /* ensures that names are never blank */
 static inline char *dup_name(const char *name)
 {

+ 4 - 0
libobs/obs.h

@@ -560,6 +560,10 @@ EXPORT void obs_load_sources(obs_data_array_t *array);
 /** Saves sources to a data array */
 EXPORT obs_data_array_t *obs_save_sources(void);
 
+typedef bool (*obs_save_source_filter_cb)(void *data, obs_source_t *source);
+EXPORT obs_data_array_t *obs_save_sources_filtered(obs_save_source_filter_cb cb,
+		void *data);
+
 
 /* ------------------------------------------------------------------------- */
 /* View context */