From 9dac5fdaf51535000ebc20006a3219415c1592ec Mon Sep 17 00:00:00 2001 From: Julian Bouzas Date: Thu, 5 Dec 2019 10:46:34 -0500 Subject: [PATCH] parser-streams: add get_lowest_stream API --- modules/module-config-policy/parser-streams.c | 15 +++++++++++++++ modules/module-config-policy/parser-streams.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/modules/module-config-policy/parser-streams.c b/modules/module-config-policy/parser-streams.c index 46e7caf3..b1c718aa 100644 --- a/modules/module-config-policy/parser-streams.c +++ b/modules/module-config-policy/parser-streams.c @@ -31,6 +31,21 @@ wp_parser_streams_find_stream (const struct WpParserStreamsData *data, return NULL; } +const struct WpParserStreamsStreamData * +wp_parser_streams_get_lowest_stream (const struct WpParserStreamsData *data) +{ + const struct WpParserStreamsStreamData *res = NULL; + guint lowest = G_MAXUINT; + for (guint i = 0; i < data->n_streams; i++) { + const struct WpParserStreamsStreamData *s = data->streams + i; + if (s->priority < lowest) { + lowest = s->priority; + res = s; + } + } + return res; +} + static void wp_parser_streams_config_parser_init (gpointer iface, gpointer iface_data); diff --git a/modules/module-config-policy/parser-streams.h b/modules/module-config-policy/parser-streams.h index 79dba324..75c6209b 100644 --- a/modules/module-config-policy/parser-streams.h +++ b/modules/module-config-policy/parser-streams.h @@ -32,6 +32,8 @@ struct WpParserStreamsData { /* Helpers */ const struct WpParserStreamsStreamData *wp_parser_streams_find_stream ( const struct WpParserStreamsData *data, const char *name); +const struct WpParserStreamsStreamData *wp_parser_streams_get_lowest_stream ( + const struct WpParserStreamsData *data); #define WP_TYPE_PARSER_STREAMS (wp_parser_streams_get_type ()) G_DECLARE_FINAL_TYPE (WpParserStreams, wp_parser_streams,