Commit 108dff22 authored by Wim Taymans's avatar Wim Taymans

message: hide the message structure field

Make a private structure to hold the GstStructure bits of the message.
Add some more useful macros like we have for events.
parent 8f13bb9e
......@@ -289,10 +289,7 @@ gst_bus_post (GstBus * bus, GstMessage * message)
g_return_val_if_fail (GST_IS_BUS (bus), FALSE);
g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
GST_DEBUG_OBJECT (bus, "[msg %p] posting on bus, type %s, %" GST_PTR_FORMAT
" from source %" GST_PTR_FORMAT,
message, GST_MESSAGE_TYPE_NAME (message), message->structure,
message->src);
GST_DEBUG_OBJECT (bus, "[msg %p] posting on bus %" GST_PTR_FORMAT, message);
GST_OBJECT_LOCK (bus);
/* check if the bus is flushing */
......
......@@ -649,9 +649,12 @@ gst_debug_print_object (gpointer ptr)
if (GST_IS_MESSAGE (object)) {
GstMessage *msg = GST_MESSAGE_CAST (object);
gchar *s, *ret;
GstStructure *structure;
structure = (GstStructure *) gst_message_get_structure (msg);
if (msg->structure) {
s = gst_info_structure_to_string (msg->structure);
if (structure) {
s = gst_info_structure_to_string (structure);
} else {
s = g_strdup ("(NULL)");
}
......
This diff is collapsed.
......@@ -283,20 +283,15 @@ struct _GstMessage
{
GstMiniObject mini_object;
/*< private >*//* with MESSAGE_LOCK */
GMutex *lock; /* lock and cond for async delivery */
GCond *cond;
/*< public > *//* with COW */
GstMessageType type;
guint64 timestamp;
GstObject *src;
guint32 seqnum;
GstStructure *structure;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
/*< private >*//* with MESSAGE_LOCK */
GMutex *lock; /* lock and cond for async delivery */
GCond *cond;
};
GType gst_message_get_type (void);
......@@ -361,6 +356,14 @@ gst_message_copy (const GstMessage * msg)
return GST_MESSAGE_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (msg)));
}
/**
* gst_message_is_writable:
* @msg: a #GstMessage
*
* Tests if you can safely write into a message's structure or validly
* modify the seqnum and timestamp fields.
*/
#define gst_message_is_writable(msg) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (msg))
/**
* gst_message_make_writable:
* @msg: (transfer full): the message to make writable
......@@ -373,6 +376,32 @@ gst_message_copy (const GstMessage * msg)
* MT safe
*/
#define gst_message_make_writable(msg) GST_MESSAGE_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (msg)))
/**
* gst_message_replace:
* @old_message: (inout) (transfer full): pointer to a pointer to a #GstMessage
* to be replaced.
* @new_message: (allow-none) (transfer none): pointer to a #GstMessage that will
* replace the message pointed to by @old_message.
*
* Modifies a pointer to a #GstMessage to point to a different #GstMessage. The
* modification is done atomically (so this is useful for ensuring thread safety
* in some cases), and the reference counts are updated appropriately (the old
* message is unreffed, the new one is reffed).
*
* Either @new_message or the #GstMessage pointed to by @old_message may be NULL.
*/
#define gst_message_replace(old_message,new_message) \
gst_mini_object_replace ((GstMiniObject **)(old_message), GST_MINI_OBJECT_CAST (new_message))
/* custom messages */
GstMessage * gst_message_new_custom (GstMessageType type,
GstObject * src,
GstStructure * structure);
const GstStructure *
gst_message_get_structure (GstMessage *message);
gboolean gst_message_has_name (GstMessage *message, const gchar *name);
/* identifiers for events and messages */
guint32 gst_message_get_seqnum (GstMessage *message);
......@@ -516,12 +545,6 @@ void gst_message_parse_progress (GstMessage * message, GstPro
gchar ** text);
/* custom messages */
GstMessage * gst_message_new_custom (GstMessageType type,
GstObject * src,
GstStructure * structure);
const GstStructure * gst_message_get_structure (GstMessage *message);
G_END_DECLS
#endif /* __GST_MESSAGE_H__ */
......@@ -399,9 +399,11 @@ gst_fake_sink_event (GstBaseSink * bsink, GstEvent * event)
if (GST_EVENT_TYPE (event) == GST_EVENT_SINK_MESSAGE) {
GstMessage *msg;
const GstStructure *structure;
gst_event_parse_sink_message (event, &msg);
sstr = gst_structure_to_string (msg->structure);
structure = gst_message_get_structure (msg);
sstr = gst_structure_to_string (structure);
sink->last_message =
g_strdup_printf ("message ******* M (type: %d, %s) %p",
GST_MESSAGE_TYPE (msg), sstr, msg);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment