Skip to content

Commit 9664689

Browse files
committed
gstreamer1: Backport multiqueue: Add stats property
This commit is needed to correct the buffering percentage in WebKit on Nexus systems, where playpump and multiqueue store a significant amount of data and interfere with the queue2 buffering level (used to control pause for rebuffering).
1 parent 38cc37b commit 9664689

File tree

3 files changed

+324
-0
lines changed

3 files changed

+324
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
From 147f30e1eeacd184e78154dbfe961b12627901b5 Mon Sep 17 00:00:00 2001
2+
From: Vivia Nikolaidou <[email protected]>
3+
Date: Thu, 9 Apr 2020 13:12:22 +0300
4+
Subject: [PATCH] multiqueue: Add stats property
5+
6+
The returned "stats" structure contains, for now, one array called
7+
"queues" with one GstStructure per internal queue, containing said
8+
queue's current level of bytes, buffers, and time.
9+
---
10+
plugins/elements/gstmultiqueue.c | 61 ++++++++++++++++++++++++++++++++
11+
1 file changed, 61 insertions(+)
12+
13+
diff --git a/plugins/elements/gstmultiqueue.c b/plugins/elements/gstmultiqueue.c
14+
index d59acaa830..50780b9293 100644
15+
--- a/plugins/elements/gstmultiqueue.c
16+
+++ b/plugins/elements/gstmultiqueue.c
17+
@@ -290,6 +290,7 @@ enum
18+
PROP_SYNC_BY_RUNNING_TIME,
19+
PROP_USE_INTERLEAVE,
20+
PROP_UNLINKED_CACHE_TIME,
21+
+ PROP_STATS,
22+
PROP_LAST
23+
};
24+
25+
@@ -636,6 +637,25 @@ gst_multi_queue_class_init (GstMultiQueueClass * klass)
26+
G_PARAM_STATIC_STRINGS));
27+
28+
29+
+ /**
30+
+ * GstMultiQueue:stats:
31+
+ *
32+
+ * Various #GstMultiQueue statistics. This property returns a #GstStructure
33+
+ * with name "application/x-gst-multi-queue-stats" with the following fields:
34+
+ *
35+
+ * - "queues" GST_TYPE_ARRAY Contains one GstStructure named "queue_%d"
36+
+ * (where %d is the queue's ID) per internal queue:
37+
+ * - "buffers" G_TYPE_UINT The queue's current level of buffers
38+
+ * - "bytes" G_TYPE_UINT The queue's current level of bytes
39+
+ * - "time" G_TYPE_UINT64 The queue's current level of time
40+
+ *
41+
+ * Since: 1.18
42+
+ */
43+
+ g_object_class_install_property (gobject_class, PROP_STATS,
44+
+ g_param_spec_boxed ("stats", "Stats",
45+
+ "Multiqueue Statistics",
46+
+ GST_TYPE_STRUCTURE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
47+
+
48+
gobject_class->finalize = gst_multi_queue_finalize;
49+
50+
gst_element_class_set_static_metadata (gstelement_class,
51+
@@ -820,6 +840,44 @@ gst_multi_queue_set_property (GObject * object, guint prop_id,
52+
}
53+
}
54+
55+
+/* Called with mutex held */
56+
+static GstStructure *
57+
+gst_multi_queue_get_stats (GstMultiQueue * mq)
58+
+{
59+
+ GstStructure *ret =
60+
+ gst_structure_new_empty ("application/x-gst-multi-queue-stats");
61+
+ GList *tmp;
62+
+ GstSingleQueue *sq;
63+
+
64+
+ if (mq->queues != NULL) {
65+
+ GValue queues = G_VALUE_INIT;
66+
+ GValue v = G_VALUE_INIT;
67+
+
68+
+ g_value_init (&queues, GST_TYPE_ARRAY);
69+
+
70+
+ for (tmp = mq->queues; tmp; tmp = g_list_next (tmp)) {
71+
+ GstDataQueueSize level;
72+
+ GstStructure *s;
73+
+ gchar *id;
74+
+ g_value_init (&v, GST_TYPE_STRUCTURE);
75+
+
76+
+ sq = (GstSingleQueue *) tmp->data;
77+
+ gst_data_queue_get_level (sq->queue, &level);
78+
+ id = g_strdup_printf ("queue_%d", sq->id);
79+
+ s = gst_structure_new (id,
80+
+ "buffers", G_TYPE_UINT, level.visible,
81+
+ "bytes", G_TYPE_UINT, level.bytes,
82+
+ "time", G_TYPE_UINT64, sq->cur_time, NULL);
83+
+ g_value_take_boxed (&v, s);
84+
+ gst_value_array_append_and_take_value (&queues, &v);
85+
+ g_free (id);
86+
+ }
87+
+ gst_structure_take_value (ret, "queues", &queues);
88+
+ }
89+
+
90+
+ return ret;
91+
+}
92+
+
93+
static void
94+
gst_multi_queue_get_property (GObject * object, guint prop_id,
95+
GValue * value, GParamSpec * pspec)
96+
@@ -873,6 +931,9 @@ gst_multi_queue_get_property (GObject * object, guint prop_id,
97+
case PROP_UNLINKED_CACHE_TIME:
98+
g_value_set_uint64 (value, mq->unlinked_cache_time);
99+
break;
100+
+ case PROP_STATS:
101+
+ g_value_take_boxed (value, gst_multi_queue_get_stats (mq));
102+
+ break;
103+
default:
104+
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
105+
break;
106+
--
107+
2.17.1
108+
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
From 2300f9677a6bc434d01d27f4b5af5edf08bde374 Mon Sep 17 00:00:00 2001
2+
From: Vivia Nikolaidou <[email protected]>
3+
Date: Thu, 9 Apr 2020 13:12:22 +0300
4+
Subject: [PATCH] multiqueue: Add stats property
5+
6+
The returned "stats" structure contains, for now, one array called
7+
"queues" with one GstStructure per internal queue, containing said
8+
queue's current level of bytes, buffers, and time.
9+
---
10+
plugins/elements/gstmultiqueue.c | 61 ++++++++++++++++++++++++++++++++
11+
1 file changed, 61 insertions(+)
12+
13+
diff --git a/plugins/elements/gstmultiqueue.c b/plugins/elements/gstmultiqueue.c
14+
index bcf8efa87a..90d057e5ee 100644
15+
--- a/plugins/elements/gstmultiqueue.c
16+
+++ b/plugins/elements/gstmultiqueue.c
17+
@@ -273,6 +273,7 @@ enum
18+
PROP_USE_INTERLEAVE,
19+
PROP_UNLINKED_CACHE_TIME,
20+
PROP_MINIMUM_INTERLEAVE,
21+
+ PROP_STATS,
22+
PROP_LAST
23+
};
24+
25+
@@ -625,6 +626,25 @@ gst_multi_queue_class_init (GstMultiQueueClass * klass)
26+
G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
27+
G_PARAM_STATIC_STRINGS));
28+
29+
+ /**
30+
+ * GstMultiQueue:stats:
31+
+ *
32+
+ * Various #GstMultiQueue statistics. This property returns a #GstStructure
33+
+ * with name "application/x-gst-multi-queue-stats" with the following fields:
34+
+ *
35+
+ * - "queues" GST_TYPE_ARRAY Contains one GstStructure named "queue_%d"
36+
+ * (where %d is the queue's ID) per internal queue:
37+
+ * - "buffers" G_TYPE_UINT The queue's current level of buffers
38+
+ * - "bytes" G_TYPE_UINT The queue's current level of bytes
39+
+ * - "time" G_TYPE_UINT64 The queue's current level of time
40+
+ *
41+
+ * Since: 1.18
42+
+ */
43+
+ g_object_class_install_property (gobject_class, PROP_STATS,
44+
+ g_param_spec_boxed ("stats", "Stats",
45+
+ "Multiqueue Statistics",
46+
+ GST_TYPE_STRUCTURE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
47+
+
48+
gobject_class->finalize = gst_multi_queue_finalize;
49+
50+
gst_element_class_set_static_metadata (gstelement_class,
51+
@@ -818,6 +838,44 @@ gst_multi_queue_set_property (GObject * object, guint prop_id,
52+
}
53+
}
54+
55+
+/* Called with mutex held */
56+
+static GstStructure *
57+
+gst_multi_queue_get_stats (GstMultiQueue * mq)
58+
+{
59+
+ GstStructure *ret =
60+
+ gst_structure_new_empty ("application/x-gst-multi-queue-stats");
61+
+ GList *tmp;
62+
+ GstSingleQueue *sq;
63+
+
64+
+ if (mq->queues != NULL) {
65+
+ GValue queues = G_VALUE_INIT;
66+
+ GValue v = G_VALUE_INIT;
67+
+
68+
+ g_value_init (&queues, GST_TYPE_ARRAY);
69+
+
70+
+ for (tmp = mq->queues; tmp; tmp = g_list_next (tmp)) {
71+
+ GstDataQueueSize level;
72+
+ GstStructure *s;
73+
+ gchar *id;
74+
+ g_value_init (&v, GST_TYPE_STRUCTURE);
75+
+
76+
+ sq = (GstSingleQueue *) tmp->data;
77+
+ gst_data_queue_get_level (sq->queue, &level);
78+
+ id = g_strdup_printf ("queue_%d", sq->id);
79+
+ s = gst_structure_new (id,
80+
+ "buffers", G_TYPE_UINT, level.visible,
81+
+ "bytes", G_TYPE_UINT, level.bytes,
82+
+ "time", G_TYPE_UINT64, sq->cur_time, NULL);
83+
+ g_value_take_boxed (&v, s);
84+
+ gst_value_array_append_and_take_value (&queues, &v);
85+
+ g_free (id);
86+
+ }
87+
+ gst_structure_take_value (ret, "queues", &queues);
88+
+ }
89+
+
90+
+ return ret;
91+
+}
92+
+
93+
static void
94+
gst_multi_queue_get_property (GObject * object, guint prop_id,
95+
GValue * value, GParamSpec * pspec)
96+
@@ -874,6 +932,9 @@ gst_multi_queue_get_property (GObject * object, guint prop_id,
97+
case PROP_MINIMUM_INTERLEAVE:
98+
g_value_set_uint64 (value, mq->min_interleave_time);
99+
break;
100+
+ case PROP_STATS:
101+
+ g_value_take_boxed (value, gst_multi_queue_get_stats (mq));
102+
+ break;
103+
default:
104+
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
105+
break;
106+
--
107+
2.17.1
108+
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
From b5b65fc99e4d13cb39cc4b6371b74f8998f39da4 Mon Sep 17 00:00:00 2001
2+
From: Vivia Nikolaidou <[email protected]>
3+
Date: Thu, 9 Apr 2020 13:12:22 +0300
4+
Subject: [PATCH 2/2] multiqueue: Add stats property
5+
6+
The returned "stats" structure contains, for now, one array called
7+
"queues" with one GstStructure per internal queue, containing said
8+
queue's current level of bytes, buffers, and time.
9+
---
10+
plugins/elements/gstmultiqueue.c | 61 ++++++++++++++++++++++++++++++++
11+
1 file changed, 61 insertions(+)
12+
13+
diff --git a/plugins/elements/gstmultiqueue.c b/plugins/elements/gstmultiqueue.c
14+
index ea489013cc..aed1992c2b 100644
15+
--- a/plugins/elements/gstmultiqueue.c
16+
+++ b/plugins/elements/gstmultiqueue.c
17+
@@ -273,6 +273,7 @@ enum
18+
PROP_USE_INTERLEAVE,
19+
PROP_UNLINKED_CACHE_TIME,
20+
PROP_MINIMUM_INTERLEAVE,
21+
+ PROP_STATS,
22+
PROP_LAST
23+
};
24+
25+
@@ -625,6 +626,25 @@ gst_multi_queue_class_init (GstMultiQueueClass * klass)
26+
G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
27+
G_PARAM_STATIC_STRINGS));
28+
29+
+ /**
30+
+ * GstMultiQueue:stats:
31+
+ *
32+
+ * Various #GstMultiQueue statistics. This property returns a #GstStructure
33+
+ * with name "application/x-gst-multi-queue-stats" with the following fields:
34+
+ *
35+
+ * - "queues" GST_TYPE_ARRAY Contains one GstStructure named "queue_%d"
36+
+ * (where %d is the queue's ID) per internal queue:
37+
+ * - "buffers" G_TYPE_UINT The queue's current level of buffers
38+
+ * - "bytes" G_TYPE_UINT The queue's current level of bytes
39+
+ * - "time" G_TYPE_UINT64 The queue's current level of time
40+
+ *
41+
+ * Since: 1.18
42+
+ */
43+
+ g_object_class_install_property (gobject_class, PROP_STATS,
44+
+ g_param_spec_boxed ("stats", "Stats",
45+
+ "Multiqueue Statistics",
46+
+ GST_TYPE_STRUCTURE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
47+
+
48+
gobject_class->finalize = gst_multi_queue_finalize;
49+
50+
gst_element_class_set_static_metadata (gstelement_class,
51+
@@ -818,6 +838,44 @@ gst_multi_queue_set_property (GObject * object, guint prop_id,
52+
}
53+
}
54+
55+
+/* Called with mutex held */
56+
+static GstStructure *
57+
+gst_multi_queue_get_stats (GstMultiQueue * mq)
58+
+{
59+
+ GstStructure *ret =
60+
+ gst_structure_new_empty ("application/x-gst-multi-queue-stats");
61+
+ GList *tmp;
62+
+ GstSingleQueue *sq;
63+
+
64+
+ if (mq->queues != NULL) {
65+
+ GValue queues = G_VALUE_INIT;
66+
+ GValue v = G_VALUE_INIT;
67+
+
68+
+ g_value_init (&queues, GST_TYPE_ARRAY);
69+
+
70+
+ for (tmp = mq->queues; tmp; tmp = g_list_next (tmp)) {
71+
+ GstDataQueueSize level;
72+
+ GstStructure *s;
73+
+ gchar *id;
74+
+ g_value_init (&v, GST_TYPE_STRUCTURE);
75+
+
76+
+ sq = (GstSingleQueue *) tmp->data;
77+
+ gst_data_queue_get_level (sq->queue, &level);
78+
+ id = g_strdup_printf ("queue_%d", sq->id);
79+
+ s = gst_structure_new (id,
80+
+ "buffers", G_TYPE_UINT, level.visible,
81+
+ "bytes", G_TYPE_UINT, level.bytes,
82+
+ "time", G_TYPE_UINT64, sq->cur_time, NULL);
83+
+ g_value_take_boxed (&v, s);
84+
+ gst_value_array_append_and_take_value (&queues, &v);
85+
+ g_free (id);
86+
+ }
87+
+ gst_structure_take_value (ret, "queues", &queues);
88+
+ }
89+
+
90+
+ return ret;
91+
+}
92+
+
93+
static void
94+
gst_multi_queue_get_property (GObject * object, guint prop_id,
95+
GValue * value, GParamSpec * pspec)
96+
@@ -874,6 +932,9 @@ gst_multi_queue_get_property (GObject * object, guint prop_id,
97+
case PROP_MINIMUM_INTERLEAVE:
98+
g_value_set_uint64 (value, mq->min_interleave_time);
99+
break;
100+
+ case PROP_STATS:
101+
+ g_value_take_boxed (value, gst_multi_queue_get_stats (mq));
102+
+ break;
103+
default:
104+
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
105+
break;
106+
--
107+
2.17.1
108+

0 commit comments

Comments
 (0)