mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
gst/gstmessage.c (gst_message_parse_state_changed): Use gst_structure_get_enum instead of gst_structure_get_int
Original commit message from CVS: * gst/gstmessage.c (gst_message_parse_state_changed): Use gst_structure_get_enum instead of gst_structure_get_int * gst/gststructure.c (gst_structure_get_enum): Impl. * gst/gststructure.h (gst_structure_get_enum): Add * docs/gst/gstreamer-sections.txt: Ditto
This commit is contained in:
parent
bdb214775d
commit
d52d4b4a4d
5 changed files with 57 additions and 3 deletions
|
@ -1,5 +1,14 @@
|
|||
2005-09-28 Johan Dahlin <johan@gnome.org>
|
||||
|
||||
* gst/gstmessage.c (gst_message_parse_state_changed): Use
|
||||
gst_structure_get_enum instead of gst_structure_get_int
|
||||
|
||||
* gst/gststructure.c (gst_structure_get_enum): Impl.
|
||||
|
||||
* gst/gststructure.h (gst_structure_get_enum): Add
|
||||
|
||||
* docs/gst/gstreamer-sections.txt: Ditto
|
||||
|
||||
* gst/gstmessage.c (gst_message_new_state_changed): Use
|
||||
GST_TYPE_STATE instead of G_TYPE_INT, mainly for language bindings
|
||||
which does introspection.
|
||||
|
|
|
@ -1633,6 +1633,7 @@ gst_structure_get_double
|
|||
gst_structure_get_string
|
||||
gst_structure_get_date
|
||||
gst_structure_get_clock_time
|
||||
gst_structure_get_enum
|
||||
gst_structure_map_in_place
|
||||
gst_structure_nth_field_name
|
||||
gst_structure_set_parent_refcount
|
||||
|
|
|
@ -370,7 +370,7 @@ gst_message_new_state_changed (GstObject * src, GstState old, GstState new)
|
|||
message = gst_message_new (GST_MESSAGE_STATE_CHANGED, src);
|
||||
|
||||
s = gst_structure_new ("GstMessageState", "old-state", GST_TYPE_STATE,
|
||||
old, "new-state", GST_TYPE_STATE, new, NULL);
|
||||
(gint) old, "new-state", GST_TYPE_STATE, (gint) new, NULL);
|
||||
gst_structure_set_parent_refcount (s, &message->mini_object.refcount);
|
||||
message->structure = s;
|
||||
|
||||
|
@ -520,9 +520,11 @@ gst_message_parse_state_changed (GstMessage * message, GstState * old,
|
|||
g_return_if_fail (GST_IS_MESSAGE (message));
|
||||
g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
|
||||
|
||||
if (!gst_structure_get_int (message->structure, "old-state", (gint *) old))
|
||||
if (!gst_structure_get_enum (message->structure, "old-state",
|
||||
GST_TYPE_STATE, (gint *) old))
|
||||
g_assert_not_reached ();
|
||||
if (!gst_structure_get_int (message->structure, "new-state", (gint *) new))
|
||||
if (!gst_structure_get_enum (message->structure, "new-state",
|
||||
GST_TYPE_STATE, (gint *) new))
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
|
|
|
@ -1088,6 +1088,44 @@ gst_structure_get_string (const GstStructure * structure,
|
|||
return g_value_get_string (&field->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_structure_get_enum:
|
||||
* @structure: a #GstStructure
|
||||
* @fieldname: the name of a field
|
||||
* @enumtype: the enum type of a field
|
||||
* @value: a pointer to an int to set
|
||||
*
|
||||
* Sets the int pointed to by @value corresponding to the value of the
|
||||
* given field. Caller is responsible for making sure the field exists,
|
||||
* has the correct type and that the enumtype is correct.
|
||||
*
|
||||
* Returns: TRUE if the value could be set correctly
|
||||
*/
|
||||
gboolean
|
||||
gst_structure_get_enum (const GstStructure * structure,
|
||||
const gchar * fieldname, GType enumtype, gint * value)
|
||||
{
|
||||
GstStructureField *field;
|
||||
|
||||
g_return_val_if_fail (structure != NULL, FALSE);
|
||||
g_return_val_if_fail (fieldname != NULL, FALSE);
|
||||
g_return_val_if_fail (enumtype != G_TYPE_INVALID, FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
field = gst_structure_get_field (structure, fieldname);
|
||||
|
||||
if (field == NULL)
|
||||
return FALSE;
|
||||
if (!G_VALUE_HOLDS_ENUM (&field->value))
|
||||
return FALSE;
|
||||
if (!G_TYPE_CHECK_VALUE_TYPE (&field->value, enumtype))
|
||||
return FALSE;
|
||||
|
||||
*value = g_value_get_enum (&field->value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
typedef struct _GstStructureAbbreviation
|
||||
{
|
||||
char *type_name;
|
||||
|
|
|
@ -139,6 +139,10 @@ gboolean gst_structure_get_clock_time (const GstStructure
|
|||
GstClockTime *value);
|
||||
G_CONST_RETURN gchar * gst_structure_get_string (const GstStructure *structure,
|
||||
const gchar *fieldname);
|
||||
gboolean gst_structure_get_enum (const GstStructure *structure,
|
||||
const gchar *fieldname,
|
||||
GType enumtype,
|
||||
gint *value);
|
||||
|
||||
gchar * gst_structure_to_string (const GstStructure *structure);
|
||||
GstStructure * gst_structure_from_string (const gchar *string,
|
||||
|
|
Loading…
Reference in a new issue