Ver Fonte

libobs: Add transition and showing counter functions

This commit adds a function to forcefully stop a transition, and to
increment/decrement the showing counter for a source with the MAIN_VIEW
type.

These functions are needed for the transition previews to work as
intended.
VodBox há 6 anos atrás
pai
commit
52235ba86d
3 ficheiros alterados com 43 adições e 0 exclusões
  1. 5 0
      libobs/obs-source-transition.c
  2. 13 0
      libobs/obs-source.c
  3. 25 0
      libobs/obs.h

+ 5 - 0
libobs/obs-source-transition.c

@@ -665,6 +665,11 @@ static inline void handle_stop(obs_source_t *transition)
 			"transition_stop");
 }
 
+void obs_transition_force_stop(obs_source_t *transition)
+{
+	handle_stop(transition);
+}
+
 void obs_transition_video_render(obs_source_t *transition,
 		obs_transition_video_render_callback_t callback)
 {

+ 13 - 0
libobs/obs-source.c

@@ -3674,12 +3674,25 @@ void obs_source_inc_showing(obs_source_t *source)
 		obs_source_activate(source, AUX_VIEW);
 }
 
+void obs_source_inc_active(obs_source_t *source)
+{
+	if (obs_source_valid(source, "obs_source_inc_active"))
+		obs_source_activate(source, MAIN_VIEW);
+}
+
 void obs_source_dec_showing(obs_source_t *source)
 {
 	if (obs_source_valid(source, "obs_source_dec_showing"))
 		obs_source_deactivate(source, AUX_VIEW);
 }
 
+void obs_source_dec_active(obs_source_t *source)
+{
+	if (obs_source_valid(source, "obs_source_dec_active"))
+		obs_source_deactivate(source, MAIN_VIEW);
+}
+
+
 void obs_source_enum_filters(obs_source_t *source,
 		obs_source_enum_proc_t callback, void *param)
 {

+ 25 - 0
libobs/obs.h

@@ -1017,6 +1017,18 @@ EXPORT uint32_t obs_source_get_audio_mixers(const obs_source_t *source);
  */
 EXPORT void obs_source_inc_showing(obs_source_t *source);
 
+/**
+ * Increments the 'active' reference counter to indicate that the source is
+ * fully active.  If the reference counter was 0, will call the 'activate'
+ * callback.
+ *
+ * Unlike obs_source_inc_showing, this will cause children of this source to be
+ * considered showing as well (currently used by transition previews to make
+ * the stinger transition show correctly).  obs_source_inc_showing should
+ * generally be used instead.
+ */
+EXPORT void obs_source_inc_active(obs_source_t *source);
+
 /**
  * Decrements the 'showing' reference counter to indicate that the source is
  * no longer being shown somewhere.  If the reference counter is set to 0,
@@ -1024,6 +1036,17 @@ EXPORT void obs_source_inc_showing(obs_source_t *source);
  */
 EXPORT void obs_source_dec_showing(obs_source_t *source);
 
+/**
+ * Decrements the 'active' reference counter to indicate that the source is no
+ * longer fully active.  If the reference counter is set to 0, will call the
+ * 'deactivate' callback
+ *
+ * Unlike obs_source_dec_showing, this will cause children of this source to be
+ * considered not showing as well.  obs_source_dec_showing should generally be
+ * used instead.
+ */
+EXPORT void obs_source_dec_active(obs_source_t *source);
+
 /** Enumerates filters assigned to the source */
 EXPORT void obs_source_enum_filters(obs_source_t *source,
 		obs_source_enum_proc_t callback, void *param);
@@ -1342,6 +1365,8 @@ typedef float (*obs_transition_audio_mix_callback_t)(void *data, float t);
 
 EXPORT float obs_transition_get_time(obs_source_t *transition);
 
+EXPORT void obs_transition_force_stop(obs_source_t *transition);
+
 EXPORT void obs_transition_video_render(obs_source_t *transition,
 		obs_transition_video_render_callback_t callback);