message, bus: do extended message types slightly differently

https://bugzilla.gnome.org/show_bug.cgi?id=678402
This commit is contained in:
Tim-Philipp Müller 2014-03-16 14:08:00 +00:00
parent 302484ac4f
commit 5c47cf759a
7 changed files with 32 additions and 72 deletions

View file

@ -668,7 +668,6 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
g_type_class_ref (gst_lock_flags_get_type ());
g_type_class_ref (gst_allocator_flags_get_type ());
g_type_class_ref (gst_stream_flags_get_type ());
g_type_class_ref (gst_message_extended_type_get_type ());
_priv_gst_event_initialize ();
_priv_gst_buffer_initialize ();
@ -1064,8 +1063,6 @@ gst_deinit (void)
g_type_class_unref (g_type_class_peek (gst_allocator_flags_get_type ()));
g_type_class_unref (g_type_class_peek (gst_stream_flags_get_type ()));
g_type_class_unref (g_type_class_peek (gst_debug_color_mode_get_type ()));
g_type_class_unref (g_type_class_peek (gst_message_extended_type_get_type
()));
gst_deinitialized = TRUE;
GST_INFO ("deinitialized GStreamer");

View file

@ -588,7 +588,8 @@ gst_bus_timed_pop (GstBus * bus, GstClockTime timeout)
* Get a message matching @type from the bus. Will discard all messages on
* the bus that do not match @type and that have been posted before the first
* message that does match @type. If there is no message matching @type on
* the bus, all messages will be discarded.
* the bus, all messages will be discarded. It is not possible to use message
* enums beyond #GST_MESSAGE_EXTENDED in the @events mask.
*
* Returns: (transfer full): the next #GstMessage matching @type that is on
* the bus, or NULL if the bus is empty or there is no message matching
@ -1012,7 +1013,7 @@ poll_destroy_timeout (GstBusPollData * poll_data)
* gst_bus_poll:
* @bus: a #GstBus
* @events: a mask of #GstMessageType, representing the set of message types to
* poll for.
* poll for (note special handling of extended message types below)
* @timeout: the poll timeout, as a #GstClockTime, or #GST_CLOCK_TIME_NONE to poll
* indefinitely.
*
@ -1021,6 +1022,8 @@ poll_destroy_timeout (GstBusPollData * poll_data)
* @timeout is negative, this function will block indefinitely.
*
* All messages not in @events will be popped off the bus and will be ignored.
* It is not possible to use message enums beyond #GST_MESSAGE_EXTENDED in the
* @events mask
*
* Because poll is implemented using the "message" signal enabled by
* gst_bus_add_signal_watch(), calling gst_bus_poll() will cause the "message"

View file

@ -60,8 +60,6 @@ typedef struct
{
GstMessage message;
GstMessageExtendedType extended_type;
GstStructure *structure;
} GstMessageImpl;
@ -107,7 +105,6 @@ static GstMessageQuarks message_quarks[] = {
{GST_MESSAGE_STREAM_START, "stream-start", 0},
{GST_MESSAGE_NEED_CONTEXT, "need-context", 0},
{GST_MESSAGE_HAVE_CONTEXT, "have-context", 0},
{GST_MESSAGE_EXTENDED, "extended", 0},
{GST_MESSAGE_DEVICE_ADDED, "device-added", 0},
{GST_MESSAGE_DEVICE_REMOVED, "device-removed", 0},
{0, NULL, 0}
@ -240,16 +237,6 @@ _gst_message_copy (GstMessage * message)
return GST_MESSAGE_CAST (copy);
}
GstMessageExtendedType
gst_message_get_extended_type (GstMessage * msg)
{
GstMessageImpl *message = (GstMessageImpl *) msg;
g_return_val_if_fail (GST_IS_MESSAGE (msg), 0);
return message->extended_type;
}
static void
gst_message_init (GstMessageImpl * message, GstMessageType type,
GstObject * src)
@ -315,20 +302,6 @@ had_parent:
}
}
static inline GstMessage *
gst_message_new_extended (GstMessageExtendedType extended_type, GstObject * src,
GstStructure * structure)
{
GstMessageImpl *message;
message = (GstMessageImpl *) gst_message_new_custom (GST_MESSAGE_EXTENDED,
src, structure);
message->extended_type = extended_type;
return GST_MESSAGE_CAST (message);
}
/**
* gst_message_get_seqnum:
* @message: A #GstMessage.
@ -2378,9 +2351,12 @@ gst_message_new_device_added (GstObject * src, GstDevice * device)
GstMessage *message;
GstStructure *structure;
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_ADDED),
GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
message = gst_message_new_extended (GST_MESSAGE_DEVICE_ADDED, src, structure);
message = gst_message_new_custom (GST_MESSAGE_DEVICE_ADDED, src, structure);
return message;
}
@ -2400,9 +2376,7 @@ void
gst_message_parse_device_added (GstMessage * message, GstDevice ** device)
{
g_return_if_fail (GST_IS_MESSAGE (message));
g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_EXTENDED);
g_return_if_fail (gst_message_get_extended_type (message) ==
GST_MESSAGE_DEVICE_ADDED);
g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_ADDED);
if (device)
gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
@ -2428,10 +2402,12 @@ gst_message_new_device_removed (GstObject * src, GstDevice * device)
GstMessage *message;
GstStructure *structure;
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_REMOVED),
GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
message = gst_message_new_extended (GST_MESSAGE_DEVICE_REMOVED, src,
structure);
message = gst_message_new_custom (GST_MESSAGE_DEVICE_REMOVED, src, structure);
return message;
}
@ -2451,9 +2427,7 @@ void
gst_message_parse_device_removed (GstMessage * message, GstDevice ** device)
{
g_return_if_fail (GST_IS_MESSAGE (message));
g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_EXTENDED);
g_return_if_fail (gst_message_get_extended_type (message) ==
GST_MESSAGE_DEVICE_REMOVED);
g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_REMOVED);
if (device)
gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),

View file

@ -99,11 +99,18 @@ typedef struct _GstMessage GstMessage;
* the URI for the next title has been set).
* @GST_MESSAGE_NEED_CONTEXT: Message indicating that an element wants a specific context (Since 1.2)
* @GST_MESSAGE_HAVE_CONTEXT: Message indicating that an element created a context (Since 1.2)
* @GST_MESSAGE_EXTENDED: See gst_message_get_extended_type() to get the type (Since 1.2)
* @GST_MESSAGE_EXTENDED: Message is an extended message type (see below).
* These extended message IDs can't be used directly with mask-based API
* like gst_bus_poll() or gst_bus_timed_pop_filtered(), but you can still
* filter for GST_MESSAGE_EXTENDED and then check the result for the
* specific type. (Since 1.4)
* @GST_MESSAGE_DEVICE_ADDED: Message indicating a #GstDevice was added to
* a #GstDeviceMonitor (Since 1.4)
* @GST_MESSAGE_DEVICE_REMOVED: Message indicating a #GstDevice was removed
* from a #GstDeviceMonitor (Since 1.4)
* @GST_MESSAGE_ANY: mask for all of the above messages.
*
* The different message types that are available. Also see
* #GstMessageExtendedType for more types.
* The different message types that are available.
*/
/* NOTE: keep in sync with quark registration in gstmessage.c
* NOTE: keep GST_MESSAGE_ANY a valid gint to avoid compiler warnings.
@ -144,27 +151,11 @@ typedef enum
GST_MESSAGE_NEED_CONTEXT = (1 << 29),
GST_MESSAGE_HAVE_CONTEXT = (1 << 30),
GST_MESSAGE_EXTENDED = (1 << 31),
GST_MESSAGE_DEVICE_ADDED = GST_MESSAGE_EXTENDED + 1,
GST_MESSAGE_DEVICE_REMOVED = GST_MESSAGE_EXTENDED + 2,
GST_MESSAGE_ANY = ~0
} GstMessageType;
/**
* GstMessageExtendedType:
* @GST_MESSAGE_DEVICE_ADDED: A #GstDevice addition according to
* a #GstDeviceMonitor (Since 1.4)
* @GST_MESSAGE_DEVICE_REMOVED: A #GstDevice removal according to
* a #GstDeviceMonitor (Since 1.4)
*
* Extra message types, see #GstMessageType for the basic types
*
* Since: 1.4
*/
typedef enum {
/* Skip those defined in #GstMessage to avoid confusion */
GST_MESSAGE_DEVICE_ADDED = 3,
GST_MESSAGE_DEVICE_REMOVED = 5
} GstMessageExtendedType;
#include <gst/gstminiobject.h>
#include <gst/gstobject.h>
#include <gst/gstelement.h>
@ -323,8 +314,6 @@ GType gst_message_get_type (void);
const gchar* gst_message_type_get_name (GstMessageType type);
GQuark gst_message_type_to_quark (GstMessageType type);
GstMessageExtendedType gst_message_get_extended_type (GstMessage * msg);
/* refcounting */
/**
* gst_message_ref:

View file

@ -68,7 +68,7 @@ static const gchar *_quark_strings[] = {
"GstEventSegmentDone",
"GstEventStreamStart", "stream-id", "GstQueryContext",
"GstMessageNeedContext", "GstMessageHaveContext", "context", "context-type",
"GstMessageStreamStart", "group-id", "uri-redirection", "GstMessageExtended",
"GstMessageStreamStart", "group-id", "uri-redirection",
"GstMessageDeviceAdded", "GstMessageDeviceRemoved", "device"
};

View file

@ -196,11 +196,10 @@ typedef enum _GstQuarkId
GST_QUARK_MESSAGE_STREAM_START = 167,
GST_QUARK_GROUP_ID = 168,
GST_QUARK_URI_REDIRECTION = 169,
GST_QUARK_MESSAGE_EXTENDED = 170,
GST_QUARK_MESSAGE_DEVICE_ADDED = 171,
GST_QUARK_MESSAGE_DEVICE_REMOVED = 172,
GST_QUARK_DEVICE = 173,
GST_QUARK_MAX = 174
GST_QUARK_MESSAGE_DEVICE_ADDED = 170,
GST_QUARK_MESSAGE_DEVICE_REMOVED = 171,
GST_QUARK_DEVICE = 172,
GST_QUARK_MAX = 173
} GstQuarkId;
extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];

View file

@ -621,8 +621,6 @@ EXPORTS
gst_memory_resize
gst_memory_share
gst_memory_unmap
gst_message_extended_type_get_type
gst_message_get_extended_type
gst_message_get_seqnum
gst_message_get_stream_status_object
gst_message_get_structure