From 556afdef9794ecc3730d41e3e9604b93d712ef56 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 10 May 2011 13:35:49 +0200 Subject: [PATCH] message: don't acces the structure directly --- gst-libs/gst/pbutils/gstdiscoverer.c | 12 ++++++---- gst-libs/gst/pbutils/missing-plugins.c | 31 ++++++++++++++++---------- gst/playback/gstplaybin.c | 13 +++++++---- gst/playback/gststreamsynchronizer.c | 4 +--- gst/playback/gsturidecodebin.c | 10 +++++---- tests/examples/gio/giosrc-mounting.c | 3 +-- tests/examples/seek/jsseek.c | 2 +- tests/examples/seek/seek.c | 2 +- 8 files changed, 46 insertions(+), 31 deletions(-) diff --git a/gst-libs/gst/pbutils/gstdiscoverer.c b/gst-libs/gst/pbutils/gstdiscoverer.c index be27e18a49..8e41941616 100644 --- a/gst-libs/gst/pbutils/gstdiscoverer.c +++ b/gst-libs/gst/pbutils/gstdiscoverer.c @@ -1079,16 +1079,20 @@ handle_message (GstDiscoverer * dc, GstMessage * msg) case GST_MESSAGE_ELEMENT: { - GQuark sttype = gst_structure_get_name_id (msg->structure); + GQuark sttype; + const GstStructure *structure; + + structure = gst_message_get_structure (msg); + sttype = gst_structure_get_name_id (structure); GST_DEBUG_OBJECT (GST_MESSAGE_SRC (msg), - "structure %" GST_PTR_FORMAT, msg->structure); + "structure %" GST_PTR_FORMAT, structure); if (sttype == _MISSING_PLUGIN_QUARK) { GST_DEBUG_OBJECT (GST_MESSAGE_SRC (msg), "Setting result to MISSING_PLUGINS"); dc->priv->current_info->result = GST_DISCOVERER_MISSING_PLUGINS; - dc->priv->current_info->misc = gst_structure_copy (msg->structure); + dc->priv->current_info->misc = gst_structure_copy (structure); } else if (sttype == _STREAM_TOPOLOGY_QUARK) { - dc->priv->current_topology = gst_structure_copy (msg->structure); + dc->priv->current_topology = gst_structure_copy (structure); } } break; diff --git a/gst-libs/gst/pbutils/missing-plugins.c b/gst-libs/gst/pbutils/missing-plugins.c index 1b6d44bb20..896d28dd60 100644 --- a/gst-libs/gst/pbutils/missing-plugins.c +++ b/gst-libs/gst/pbutils/missing-plugins.c @@ -406,18 +406,20 @@ gst_missing_plugin_message_get_installer_detail (GstMessage * msg) GString *str = NULL; gchar *detail = NULL; gchar *desc; + const GstStructure *structure; g_return_val_if_fail (gst_is_missing_plugin_message (msg), NULL); - GST_LOG ("Parsing missing-plugin message: %" GST_PTR_FORMAT, msg->structure); + structure = gst_message_get_structure (msg); + GST_LOG ("Parsing missing-plugin message: %" GST_PTR_FORMAT, structure); - missing_type = missing_structure_get_type (msg->structure); + missing_type = missing_structure_get_type (structure); if (missing_type == GST_MISSING_TYPE_UNKNOWN) { GST_WARNING ("couldn't parse 'type' field"); goto error; } - type = gst_structure_get_string (msg->structure, "type"); + type = gst_structure_get_string (structure, "type"); g_assert (type != NULL); /* validity already checked above */ /* FIXME: use gst_installer_detail_new() here too */ @@ -444,14 +446,14 @@ gst_missing_plugin_message_get_installer_detail (GstMessage * msg) case GST_MISSING_TYPE_URISOURCE: case GST_MISSING_TYPE_URISINK: case GST_MISSING_TYPE_ELEMENT: - if (!missing_structure_get_string_detail (msg->structure, &detail)) + if (!missing_structure_get_string_detail (structure, &detail)) goto error; break; case GST_MISSING_TYPE_DECODER: case GST_MISSING_TYPE_ENCODER:{ GstCaps *caps = NULL; - if (!missing_structure_get_caps_detail (msg->structure, &caps)) + if (!missing_structure_get_caps_detail (structure, &caps)) goto error; detail = gst_caps_to_string (caps); @@ -498,19 +500,21 @@ gst_missing_plugin_message_get_description (GstMessage * msg) GstMissingType missing_type; const gchar *desc; gchar *ret = NULL; + const GstStructure *structure; g_return_val_if_fail (gst_is_missing_plugin_message (msg), NULL); - GST_LOG ("Parsing missing-plugin message: %" GST_PTR_FORMAT, msg->structure); + structure = gst_message_get_structure (msg); + GST_LOG ("Parsing missing-plugin message: %" GST_PTR_FORMAT, structure); - desc = gst_structure_get_string (msg->structure, "name"); + desc = gst_structure_get_string (structure, "name"); if (desc != NULL && *desc != '\0') { ret = g_strdup (desc); goto done; } /* fallback #1 */ - missing_type = missing_structure_get_type (msg->structure); + missing_type = missing_structure_get_type (structure); switch (missing_type) { case GST_MISSING_TYPE_URISOURCE: @@ -518,7 +522,7 @@ gst_missing_plugin_message_get_description (GstMessage * msg) case GST_MISSING_TYPE_ELEMENT:{ gchar *detail = NULL; - if (missing_structure_get_string_detail (msg->structure, &detail)) { + if (missing_structure_get_string_detail (structure, &detail)) { if (missing_type == GST_MISSING_TYPE_URISOURCE) ret = gst_pb_utils_get_source_description (detail); else if (missing_type == GST_MISSING_TYPE_URISINK) @@ -533,7 +537,7 @@ gst_missing_plugin_message_get_description (GstMessage * msg) case GST_MISSING_TYPE_ENCODER:{ GstCaps *caps = NULL; - if (missing_structure_get_caps_detail (msg->structure, &caps)) { + if (missing_structure_get_caps_detail (structure, &caps)) { if (missing_type == GST_MISSING_TYPE_DECODER) ret = gst_pb_utils_get_decoder_description (caps); else @@ -591,13 +595,16 @@ done: gboolean gst_is_missing_plugin_message (GstMessage * msg) { + const GstStructure *structure; + g_return_val_if_fail (msg != NULL, FALSE); g_return_val_if_fail (GST_IS_MESSAGE (msg), FALSE); - if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ELEMENT || msg->structure == NULL) + structure = gst_message_get_structure (msg); + if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ELEMENT || structure == NULL) return FALSE; - return gst_structure_has_name (msg->structure, "missing-plugin"); + return gst_structure_has_name (structure, "missing-plugin"); } /* takes ownership of the description */ diff --git a/gst/playback/gstplaybin.c b/gst/playback/gstplaybin.c index f2c267e95e..f1fc1eefaf 100644 --- a/gst/playback/gstplaybin.c +++ b/gst/playback/gstplaybin.c @@ -1859,14 +1859,16 @@ gst_play_bin_handle_redirect_message (GstPlayBin * playbin, GstMessage * msg) guint size, i; GstPlayBaseBin *playbasebin = GST_PLAY_BASE_BIN (playbin); guint connection_speed = playbasebin->connection_speed; + const GstStructure *structure; GST_DEBUG_OBJECT (playbin, "redirect message: %" GST_PTR_FORMAT, msg); GST_DEBUG_OBJECT (playbin, "connection speed: %u", connection_speed); - if (connection_speed == 0 || msg->structure == NULL) + structure = gst_message_get_structure (msg); + if (connection_speed == 0 || structure == NULL) return msg; - locations_list = gst_structure_get_value (msg->structure, "locations"); + locations_list = gst_structure_get_value (structure, "locations"); if (locations_list == NULL) return msg; @@ -1918,8 +1920,11 @@ gst_play_bin_handle_redirect_message (GstPlayBin * playbin, GstMessage * msg) static void gst_play_bin_handle_message (GstBin * bin, GstMessage * msg) { - if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ELEMENT && msg->structure != NULL - && gst_structure_has_name (msg->structure, "redirect")) { + const GstStructure *structure; + + structure = gst_message_get_structure (msg); + if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ELEMENT && structure != NULL + && gst_structure_has_name (structure, "redirect")) { msg = gst_play_bin_handle_redirect_message (GST_PLAY_BIN (bin), msg); } diff --git a/gst/playback/gststreamsynchronizer.c b/gst/playback/gststreamsynchronizer.c index b904ac2b3a..208126b5ea 100644 --- a/gst/playback/gststreamsynchronizer.c +++ b/gst/playback/gststreamsynchronizer.c @@ -288,9 +288,7 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstEvent * event) GstMessage *message; gst_event_parse_sink_message (event, &message); - if (message->structure - && gst_structure_has_name (message->structure, - "playbin2-stream-changed")) { + if (gst_message_has_name (message, "playbin2-stream-changed")) { GstStream *stream; GST_STREAM_SYNCHRONIZER_LOCK (self); diff --git a/gst/playback/gsturidecodebin.c b/gst/playback/gsturidecodebin.c index 08812773f3..5e5bd750d5 100644 --- a/gst/playback/gsturidecodebin.c +++ b/gst/playback/gsturidecodebin.c @@ -2033,14 +2033,16 @@ handle_redirect_message (GstURIDecodeBin * dec, GstMessage * msg) GList *l_good = NULL, *l_neutral = NULL, *l_bad = NULL; GValue new_list = { 0, }; guint size, i; + const GstStructure *structure; GST_DEBUG_OBJECT (dec, "redirect message: %" GST_PTR_FORMAT, msg); GST_DEBUG_OBJECT (dec, "connection speed: %u", dec->connection_speed); - if (dec->connection_speed == 0 || msg->structure == NULL) + structure = gst_message_get_structure (msg); + if (dec->connection_speed == 0 || structure == NULL) return msg; - locations_list = gst_structure_get_value (msg->structure, "locations"); + locations_list = gst_structure_get_value (structure, "locations"); if (locations_list == NULL) return msg; @@ -2092,8 +2094,8 @@ handle_redirect_message (GstURIDecodeBin * dec, GstMessage * msg) static void handle_message (GstBin * bin, GstMessage * msg) { - if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ELEMENT && msg->structure != NULL - && gst_structure_has_name (msg->structure, "redirect")) { + if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ELEMENT + && gst_message_has_name (msg, "redirect")) { /* sort redirect messages based on the connection speed. This simplifies * the user of this element as it can in most cases just pick the first item * of the sorted list as a good redirection candidate. It can of course diff --git a/tests/examples/gio/giosrc-mounting.c b/tests/examples/gio/giosrc-mounting.c index 0a8e202a2b..cf34f55c35 100644 --- a/tests/examples/gio/giosrc-mounting.c +++ b/tests/examples/gio/giosrc-mounting.c @@ -57,8 +57,7 @@ message_handler (GstBus * bus, GstMessage * message, gpointer user_data) if (strcmp (name, "not-mounted") == 0) { GMountOperation *mop = gtk_mount_operation_new (NULL); GFile *file = - G_FILE (g_value_get_object (gst_structure_get_value - (message->structure, "file"))); + G_FILE (g_value_get_object (gst_structure_get_value (s, "file"))); g_print ("not-mounted\n"); gst_element_set_state (pipeline, GST_STATE_NULL); diff --git a/tests/examples/seek/jsseek.c b/tests/examples/seek/jsseek.c index 614ccf4131..39ae6d43b1 100644 --- a/tests/examples/seek/jsseek.c +++ b/tests/examples/seek/jsseek.c @@ -2456,7 +2456,7 @@ static GstBusSyncReply bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * data) { if ((GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) && - gst_structure_has_name (message->structure, "prepare-xwindow-id")) { + gst_message_has_name (message, "prepare-xwindow-id")) { GstElement *element = GST_ELEMENT (GST_MESSAGE_SRC (message)); g_print ("got prepare-xwindow-id, setting XID %lu\n", embed_xid); diff --git a/tests/examples/seek/seek.c b/tests/examples/seek/seek.c index 9a37413192..0780cd6989 100644 --- a/tests/examples/seek/seek.c +++ b/tests/examples/seek/seek.c @@ -2445,7 +2445,7 @@ static GstBusSyncReply bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * data) { if ((GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) && - gst_structure_has_name (message->structure, "prepare-xwindow-id")) { + gst_message_has_name (message, "prepare-xwindow-id")) { GstElement *element = GST_ELEMENT (GST_MESSAGE_SRC (message)); g_print ("got prepare-xwindow-id, setting XID %lu\n", embed_xid);