message: don't acces the structure directly

This commit is contained in:
Wim Taymans 2011-05-10 13:35:49 +02:00
parent 5dbc49ccf7
commit 556afdef97
8 changed files with 46 additions and 31 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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