Browse Source

libobs: Add ability to get output congestion

From 0.0 (not congested) to 1.0 (completely congested/dropping).
jp9000 8 years ago
parent
commit
d8500b47ea
3 changed files with 18 additions and 0 deletions
  1. 14 0
      libobs/obs-output.c
  2. 2 0
      libobs/obs-output.h
  3. 2 0
      libobs/obs.h

+ 14 - 0
libobs/obs-output.c

@@ -2103,3 +2103,17 @@ void obs_output_output_caption_text1(obs_output_t *output, const char *text)
 	pthread_mutex_unlock(&output->caption_mutex);
 }
 #endif
+
+float obs_output_get_congestion(obs_output_t *output)
+{
+	if (!obs_output_valid(output, "obs_output_get_congestion"))
+		return 0;
+
+	if (output->info.get_congestion) {
+		float val = output->info.get_congestion(output->context.data);
+		if (val < 0.0f) val = 0.0f;
+		else if (val > 1.0f) val = 1.0f;
+		return val;
+	}
+	return 0;
+}

+ 2 - 0
libobs/obs-output.h

@@ -64,6 +64,8 @@ struct obs_output_info {
 
 	void *type_data;
 	void (*free_type_data)(void *type_data);
+
+	float (*get_congestion)(void *data);
 };
 
 EXPORT void obs_register_output_s(const struct obs_output_info *info,

+ 2 - 0
libobs/obs.h

@@ -1465,6 +1465,8 @@ EXPORT void obs_output_output_caption_text1(obs_output_t *output,
 		const char *text);
 #endif
 
+EXPORT float obs_output_get_congestion(obs_output_t *output);
+
 /* ------------------------------------------------------------------------- */
 /* Functions used by outputs */