Bläddra i källkod

libobs: add helper for source filter count

Add function size_t obs_source_get_filter_count(obs_source_t *source)
which returns the number of filters a source has. Update docs for it.
Anton Bershanskiy 4 år sedan
förälder
incheckning
54cbd98d91
3 ändrade filer med 16 tillägg och 0 borttagningar
  1. 6 0
      docs/sphinx/reference-sources.rst
  2. 7 0
      libobs/obs-source.c
  3. 3 0
      libobs/obs.h

+ 6 - 0
docs/sphinx/reference-sources.rst

@@ -1013,6 +1013,12 @@ General Source Functions
 
 ---------------------
 
+.. function:: size_t obs_source_filter_count(const obs_source_t *source)
+
+   Returns the number of filters the source has.
+
+---------------------
+
 .. function:: bool obs_source_enabled(const obs_source_t *source)
               void obs_source_set_enabled(obs_source_t *source, bool enabled)
 

+ 7 - 0
libobs/obs-source.c

@@ -4309,6 +4309,13 @@ obs_source_t *obs_source_get_filter_by_name(obs_source_t *source,
 	return filter;
 }
 
+size_t obs_source_filter_count(const obs_source_t *source)
+{
+	return obs_source_valid(source, "obs_source_filter_count")
+		       ? source->filters.num
+		       : 0;
+}
+
 bool obs_source_enabled(const obs_source_t *source)
 {
 	return obs_source_valid(source, "obs_source_enabled") ? source->enabled

+ 3 - 0
libobs/obs.h

@@ -1101,6 +1101,9 @@ EXPORT void obs_source_enum_filters(obs_source_t *source,
 EXPORT obs_source_t *obs_source_get_filter_by_name(obs_source_t *source,
 						   const char *name);
 
+/** Gets the number of filters the source has. */
+EXPORT size_t obs_source_filter_count(const obs_source_t *source);
+
 EXPORT void obs_source_copy_filters(obs_source_t *dst, obs_source_t *src);
 EXPORT void obs_source_copy_single_filter(obs_source_t *dst,
 					  obs_source_t *filter);