libobs: Add ability to get output congestion

From 0.0 (not congested) to 1.0 (completely congested/dropping).
This commit is contained in:
jp9000 2017-01-24 15:30:01 -08:00
parent 85c43cd666
commit d8500b47ea
3 changed files with 18 additions and 0 deletions

View File

@ -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;
}

View File

@ -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,

View File

@ -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 */