From 0ab48250a9cc437a7f18fda1acc74d91e77ea45c Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 27 Sep 2023 08:46:35 -0400 Subject: [PATCH] GstCustomMeta: Use simplified API where possible Part-of: --- .../gst-plugins-bad/ext/qroverlay/gstqroverlay.c | 9 +++------ subprojects/gst-plugins-good/ext/vpx/gstvp8enc.c | 3 +-- subprojects/gst-plugins-good/ext/vpx/gstvpxelement.c | 3 +-- subprojects/gst-plugins-good/gst/rtp/gstrtpvp8pay.c | 10 ++++------ .../gst-plugins-good/tests/check/elements/rtpvp8.c | 7 ++----- .../gst-plugins-good/tests/check/elements/vp8enc.c | 8 ++------ subprojects/gstreamer/libs/gst/base/gstaggregator.c | 4 +--- 7 files changed, 14 insertions(+), 30 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/qroverlay/gstqroverlay.c b/subprojects/gst-plugins-bad/ext/qroverlay/gstqroverlay.c index 96d6186605..88fd3e83bf 100644 --- a/subprojects/gst-plugins-bad/ext/qroverlay/gstqroverlay.c +++ b/subprojects/gst-plugins-bad/ext/qroverlay/gstqroverlay.c @@ -88,15 +88,13 @@ get_qrcode_content (GstBaseQROverlay * base, GstBuffer * buf, GstCustomMeta *meta = gst_buffer_get_custom_meta (buf, "GstQROverlayMeta"); if (meta) { gchar *data; - GstStructure *structure = - gst_custom_meta_get_structure ((GstCustomMeta *) meta); - if (gst_structure_get (structure, "data", G_TYPE_STRING, &data, NULL)) { + if (gst_structure_get (meta->structure, "data", G_TYPE_STRING, &data, NULL)) { gboolean keep_data; GST_OBJECT_LOCK (self); self->data_changed = TRUE; - if (gst_structure_get_boolean (structure, "keep_data", &keep_data) + if (gst_structure_get_boolean (meta->structure, "keep_data", &keep_data) && keep_data) { g_free (self->data); self->data = g_strdup (self->data); @@ -162,7 +160,6 @@ gst_qr_overlay_class_init (GstQROverlayClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - static const gchar *tags[] = { NULL }; gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; @@ -177,7 +174,7 @@ gst_qr_overlay_class_init (GstQROverlayClass * klass) "Overlay Qrcodes over each buffer with data passed in", "Thibault Saunier "); - gst_meta_register_custom ("GstQROverlayMeta", tags, NULL, NULL, NULL); + gst_meta_register_custom_simple ("GstQROverlayMeta"); g_object_class_install_property (gobject_class, PROP_DATA, g_param_spec_string ("data", diff --git a/subprojects/gst-plugins-good/ext/vpx/gstvp8enc.c b/subprojects/gst-plugins-good/ext/vpx/gstvp8enc.c index 5222c970a1..f93a23c791 100644 --- a/subprojects/gst-plugins-good/ext/vpx/gstvp8enc.c +++ b/subprojects/gst-plugins-good/ext/vpx/gstvp8enc.c @@ -402,9 +402,8 @@ gst_vp8_enc_preflight_buffer (GstVPXEnc * enc, gboolean layer_sync, guint layer_id, guint8 tl0picidx) { GstCustomMeta *meta = gst_buffer_add_custom_meta (buffer, "GstVP8Meta"); - GstStructure *s = gst_custom_meta_get_structure (meta); - gst_structure_set (s, + gst_structure_set (meta->structure, "use-temporal-scaling", G_TYPE_BOOLEAN, (enc->cfg.ts_periodicity != 0), "layer-sync", G_TYPE_BOOLEAN, layer_sync, "layer-id", G_TYPE_UINT, layer_id, diff --git a/subprojects/gst-plugins-good/ext/vpx/gstvpxelement.c b/subprojects/gst-plugins-good/ext/vpx/gstvpxelement.c index 2550283bf6..b146dd4b9a 100644 --- a/subprojects/gst-plugins-good/ext/vpx/gstvpxelement.c +++ b/subprojects/gst-plugins-good/ext/vpx/gstvpxelement.c @@ -31,9 +31,8 @@ void vpx_element_init (GstPlugin * plugin) { static gsize res = FALSE; - static const gchar *tags[] = { NULL }; if (g_once_init_enter (&res)) { - gst_meta_register_custom ("GstVP8Meta", tags, NULL, NULL, NULL); + gst_meta_register_custom_simple ("GstVP8Meta"); g_once_init_leave (&res, TRUE); } } diff --git a/subprojects/gst-plugins-good/gst/rtp/gstrtpvp8pay.c b/subprojects/gst-plugins-good/gst/rtp/gstrtpvp8pay.c index c216a125cf..f2788310b6 100644 --- a/subprojects/gst-plugins-good/gst/rtp/gstrtpvp8pay.c +++ b/subprojects/gst-plugins-good/gst/rtp/gstrtpvp8pay.c @@ -556,13 +556,12 @@ gst_rtp_vp8_create_header_buffer (GstRtpVP8Pay * self, guint8 partid, gboolean use_temporal_scaling = FALSE; if (meta) { - GstStructure *s = gst_custom_meta_get_structure (meta); - gst_structure_get_boolean (s, "use-temporal-scaling", + gst_structure_get_boolean (meta->structure, "use-temporal-scaling", &use_temporal_scaling); if (use_temporal_scaling) - gst_structure_get (s, "layer-id", G_TYPE_UINT, &temporal_layer, - "layer-sync", G_TYPE_BOOLEAN, &layer_sync, NULL); + gst_structure_get (meta->structure, "layer-id", G_TYPE_UINT, + &temporal_layer, "layer-sync", G_TYPE_BOOLEAN, &layer_sync, NULL); } /* FIXME: Support a prediction structure where higher layers don't @@ -682,13 +681,12 @@ gst_rtp_vp8_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer) } if (meta) { - GstStructure *s = gst_custom_meta_get_structure (meta); gboolean use_temporal_scaling; /* For interop it's most likely better to keep the temporal scalability * fields present if the stream previously had them present. Alternating * whether these fields are present or not may confuse the receiver. */ - gst_structure_get_boolean (s, "use-temporal-scaling", + gst_structure_get_boolean (meta->structure, "use-temporal-scaling", &use_temporal_scaling); if (use_temporal_scaling) self->temporal_scalability_fields_present = TRUE; diff --git a/subprojects/gst-plugins-good/tests/check/elements/rtpvp8.c b/subprojects/gst-plugins-good/tests/check/elements/rtpvp8.c index f0802481a1..e62bcb9ae0 100644 --- a/subprojects/gst-plugins-good/tests/check/elements/rtpvp8.c +++ b/subprojects/gst-plugins-good/tests/check/elements/rtpvp8.c @@ -105,12 +105,10 @@ add_vp8_meta (GstBuffer * buffer, gboolean use_temporal_scaling, gboolean layer_sync, guint layer_id, guint tl0picidx) { GstCustomMeta *meta; - GstStructure *s; meta = gst_buffer_add_custom_meta (buffer, "GstVP8Meta"); fail_unless (meta != NULL); - s = gst_custom_meta_get_structure (meta); - gst_structure_set (s, + gst_structure_set (meta->structure, "use-temporal-scaling", G_TYPE_BOOLEAN, use_temporal_scaling, "layer-sync", G_TYPE_BOOLEAN, layer_sync, "layer-id", G_TYPE_UINT, layer_id, @@ -873,10 +871,9 @@ rtpvp8_suite (void) { Suite *s = suite_create ("rtpvp8"); TCase *tc_chain; - static const gchar *tags[] = { NULL }; /* Register custom GstVP8Meta manually */ - gst_meta_register_custom ("GstVP8Meta", tags, NULL, NULL, NULL); + gst_meta_register_custom_simple ("GstVP8Meta"); suite_add_tcase (s, (tc_chain = tcase_create ("vp8pay"))); tcase_add_loop_test (tc_chain, test_pay_no_meta, 0, diff --git a/subprojects/gst-plugins-good/tests/check/elements/vp8enc.c b/subprojects/gst-plugins-good/tests/check/elements/vp8enc.c index 89dab02099..6ac36650f3 100644 --- a/subprojects/gst-plugins-good/tests/check/elements/vp8enc.c +++ b/subprojects/gst-plugins-good/tests/check/elements/vp8enc.c @@ -219,10 +219,8 @@ GST_END_TEST; guint temporal_layer_id, tl0picidx; \ GstCustomMeta *meta = gst_buffer_get_custom_meta (buffer, \ "GstVP8Meta"); \ - GstStructure *s; \ fail_unless (meta != NULL); \ - s = gst_custom_meta_get_structure (meta); \ - fail_unless (gst_structure_get (s, \ + fail_unless (gst_structure_get (meta->structure, \ "use-temporal-scaling", G_TYPE_BOOLEAN, &use_temporal_scaling, \ "layer-sync", G_TYPE_BOOLEAN, &layer_sync, \ "layer-id", G_TYPE_UINT, &temporal_layer_id, \ @@ -386,7 +384,6 @@ GST_START_TEST (test_encode_fresh_meta) GstBuffer *buffer; GstHarness *h = gst_harness_new ("vp8enc"); GstCustomMeta *meta; - GstStructure *s; gst_harness_set_src_caps (h, gst_caps_new_i420_full (320, 240, 25, 1, 1, 1)); buffer = gst_harness_create_video_buffer_full (h, 0x0, @@ -395,8 +392,7 @@ GST_START_TEST (test_encode_fresh_meta) /* Attach bogus meta to input buffer */ meta = gst_buffer_add_custom_meta (buffer, "GstVP8Meta"); - s = gst_custom_meta_get_structure (meta); - gst_structure_set (s, + gst_structure_set (meta->structure, "use-temporal-scaling", G_TYPE_BOOLEAN, FALSE, "layer-sync", G_TYPE_BOOLEAN, FALSE, "layer-id", G_TYPE_UINT, 0, "tl0picidx", G_TYPE_UINT, 0, NULL); diff --git a/subprojects/gstreamer/libs/gst/base/gstaggregator.c b/subprojects/gstreamer/libs/gst/base/gstaggregator.c index a6aa43af0c..819f7ef71c 100644 --- a/subprojects/gstreamer/libs/gst/base/gstaggregator.c +++ b/subprojects/gstreamer/libs/gst/base/gstaggregator.c @@ -2953,7 +2953,6 @@ gst_aggregator_class_init (GstAggregatorClass * klass) { GObjectClass *gobject_class = (GObjectClass *) klass; GstElementClass *gstelement_class = (GstElementClass *) klass; - static const gchar *meta_tags[] = { NULL }; aggregator_parent_class = g_type_class_peek_parent (klass); @@ -3070,8 +3069,7 @@ gst_aggregator_class_init (GstAggregatorClass * klass) GST_TYPE_CLOCK_TIME, GST_TYPE_CLOCK_TIME, GST_TYPE_STRUCTURE | G_SIGNAL_TYPE_STATIC_SCOPE); - gst_meta_register_custom ("GstAggregatorMissingDataMeta", meta_tags, NULL, - NULL, NULL); + gst_meta_register_custom_simple ("GstAggregatorMissingDataMeta"); } static inline gpointer