GST_EVENT_STRUCTURE (copy) = gst_structure_copy (s);
gst_structure_set_parent_refcount (GST_EVENT_STRUCTURE (copy),
©->event.mini_object.refcount);
+ } else {
+ GST_EVENT_STRUCTURE (copy) = NULL;
}
return GST_EVENT_CAST (copy);
}
GST_EVENT_SEQNUM (event) = gst_util_seqnum_next ();
}
-static GstEvent *
-gst_event_new (GstEventType type)
-{
- GstEventImpl *event;
-
- event = g_slice_new0 (GstEventImpl);
-
- GST_CAT_DEBUG (GST_CAT_EVENT, "creating new event %p %s %d", event,
- gst_event_type_get_name (type), type);
-
- gst_event_init (event, sizeof (GstEventImpl), type);
-
- return GST_EVENT_CAST (event);
-}
/**
* gst_event_new_custom:
GstEvent *
gst_event_new_custom (GstEventType type, GstStructure * structure)
{
- GstEvent *event;
+ GstEventImpl *event;
+
+ event = g_slice_new0 (GstEventImpl);
+
+ GST_CAT_DEBUG (GST_CAT_EVENT, "creating new event %p %s %d", event,
+ gst_event_type_get_name (type), type);
- /* structure must not have a parent */
- event = gst_event_new (type);
if (structure) {
+ /* structure must not have a parent */
if (!gst_structure_set_parent_refcount (structure,
- &event->mini_object.refcount))
+ &event->event.mini_object.refcount))
goto had_parent;
- GST_EVENT_STRUCTURE (event) = structure;
}
- return event;
+ gst_event_init (event, sizeof (GstEventImpl), type);
+
+ GST_EVENT_STRUCTURE (event) = structure;
+
+ return GST_EVENT_CAST (event);
/* ERRORS */
had_parent:
{
- gst_event_unref (event);
+ g_slice_free1 (GST_MINI_OBJECT_SIZE (event), event);
g_warning ("structure is already owned by another object");
return NULL;
}
GstEvent *
gst_event_new_flush_start (void)
{
- return gst_event_new (GST_EVENT_FLUSH_START);
+ return gst_event_new_custom (GST_EVENT_FLUSH_START, NULL);
}
/**
GstEvent *
gst_event_new_eos (void)
{
- return gst_event_new (GST_EVENT_EOS);
+ return gst_event_new_custom (GST_EVENT_EOS, NULL);
}
/**
GstEvent *
gst_event_new_stream_start (void)
{
- return gst_event_new (GST_EVENT_STREAM_START);
+ return gst_event_new_custom (GST_EVENT_STREAM_START, NULL);
}
g_slice_free1 (GST_MINI_OBJECT_SIZE (message), message);
}
+static void
+gst_message_init (GstMessageImpl * message, gsize size, GstMessageType type,
+ GstObject * src);
+
static GstMessage *
_gst_message_copy (GstMessage * message)
{
copy = g_slice_new0 (GstMessageImpl);
- gst_mini_object_init (GST_MINI_OBJECT_CAST (copy),
- _gst_message_type, sizeof (GstMessageImpl));
-
- copy->message.mini_object.copy =
- (GstMiniObjectCopyFunction) _gst_message_copy;
- copy->message.mini_object.free =
- (GstMiniObjectFreeFunction) _gst_message_free;
+ gst_message_init (copy, sizeof (GstMessageImpl), GST_MESSAGE_TYPE (message),
+ GST_MESSAGE_SRC (message));
- GST_MESSAGE_TYPE (copy) = GST_MESSAGE_TYPE (message);
GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
- if (GST_MESSAGE_SRC (message)) {
- GST_MESSAGE_SRC (copy) = gst_object_ref (GST_MESSAGE_SRC (message));
- }
structure = GST_MESSAGE_STRUCTURE (message);
if (structure) {
- copy->structure = gst_structure_copy (structure);
- gst_structure_set_parent_refcount (copy->structure,
+ GST_MESSAGE_STRUCTURE (copy) = gst_structure_copy (structure);
+ gst_structure_set_parent_refcount (GST_MESSAGE_STRUCTURE (copy),
©->message.mini_object.refcount);
+ } else {
+ GST_MESSAGE_STRUCTURE (copy) = NULL;
}
return GST_MESSAGE_CAST (copy);
}
+static void
+gst_message_init (GstMessageImpl * message, gsize size, GstMessageType type,
+ GstObject * src)
+{
+ gst_mini_object_init (GST_MINI_OBJECT_CAST (message), _gst_message_type,
+ size);
+
+ message->message.mini_object.copy =
+ (GstMiniObjectCopyFunction) _gst_message_copy;
+ message->message.mini_object.free =
+ (GstMiniObjectFreeFunction) _gst_message_free;
+
+ GST_MESSAGE_TYPE (message) = type;
+ if (src)
+ gst_object_ref (src);
+ GST_MESSAGE_SRC (message) = src;
+ GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
+ GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
+}
+
+
/**
* gst_message_new_custom:
* @type: The #GstMessageType to distinguish messages
message = g_slice_new0 (GstMessageImpl);
- gst_mini_object_init (GST_MINI_OBJECT_CAST (message),
- _gst_message_type, sizeof (GstMessageImpl));
-
- message->message.mini_object.copy =
- (GstMiniObjectCopyFunction) _gst_message_copy;
- message->message.mini_object.free =
- (GstMiniObjectFreeFunction) _gst_message_free;
-
GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
(src ? GST_OBJECT_NAME (src) : "NULL"), message,
gst_message_type_get_name (type));
- GST_MESSAGE_TYPE (message) = type;
- if (src)
- gst_object_ref (src);
- GST_MESSAGE_SRC (message) = src;
- GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
- GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
-
if (structure) {
- gst_structure_set_parent_refcount (structure,
- &message->message.mini_object.refcount);
+ /* structure must not have a parent */
+ if (!gst_structure_set_parent_refcount (structure,
+ &message->message.mini_object.refcount))
+ goto had_parent;
}
- message->structure = structure;
+ gst_message_init (message, sizeof (GstMessageImpl), type, src);
+
+ GST_MESSAGE_STRUCTURE (message) = structure;
return GST_MESSAGE_CAST (message);
+
+ /* ERRORS */
+had_parent:
+ {
+ g_slice_free1 (GST_MINI_OBJECT_SIZE (message), message);
+ g_warning ("structure is already owned by another object");
+ return NULL;
+ }
}
/**
g_slice_free1 (GST_MINI_OBJECT_SIZE (query), query);
}
-static GstQuery *gst_query_new (GstQueryType type, GstStructure * structure);
-
static GstQuery *
_gst_query_copy (GstQuery * query)
{
GstQuery *copy;
- copy = gst_query_new (query->type, GST_QUERY_STRUCTURE (query));
+ copy = gst_query_new_custom (query->type, GST_QUERY_STRUCTURE (query));
return copy;
}
-static GstQuery *
-gst_query_new (GstQueryType type, GstStructure * structure)
+static void
+gst_query_init (GstQueryImpl * query, gsize size, GstQueryType type)
{
- GstQueryImpl *query;
-
- query = g_slice_new0 (GstQueryImpl);
-
- gst_mini_object_init (GST_MINI_OBJECT_CAST (query),
- _gst_query_type, sizeof (GstQueryImpl));
+ gst_mini_object_init (GST_MINI_OBJECT_CAST (query), _gst_query_type, size);
query->query.mini_object.copy = (GstMiniObjectCopyFunction) _gst_query_copy;
query->query.mini_object.free = (GstMiniObjectFreeFunction) _gst_query_free;
- GST_DEBUG ("creating new query %p %s", query, gst_query_type_get_name (type));
-
- GST_QUERY_TYPE (query) = type;
- query->structure = structure;
-
- if (structure)
- gst_structure_set_parent_refcount (structure,
- &query->query.mini_object.refcount);
-
- return GST_QUERY_CAST (query);
+ GST_EVENT_TYPE (query) = type;
}
/**
GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
GST_QUARK (CURRENT), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
- query = gst_query_new (GST_QUERY_POSITION, structure);
+ query = gst_query_new_custom (GST_QUERY_POSITION, structure);
return query;
}
GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
GST_QUARK (DURATION), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
- query = gst_query_new (GST_QUERY_DURATION, structure);
+ query = gst_query_new_custom (GST_QUERY_DURATION, structure);
return query;
}
GST_QUARK (MIN_LATENCY), G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
GST_QUARK (MAX_LATENCY), G_TYPE_UINT64, G_GUINT64_CONSTANT (-1), NULL);
- query = gst_query_new (GST_QUERY_LATENCY, structure);
+ query = gst_query_new_custom (GST_QUERY_LATENCY, structure);
return query;
}
GST_QUARK (DEST_FORMAT), GST_TYPE_FORMAT, dest_format,
GST_QUARK (DEST_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
- query = gst_query_new (GST_QUERY_CONVERT, structure);
+ query = gst_query_new_custom (GST_QUERY_CONVERT, structure);
return query;
}
GST_QUARK (START_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
GST_QUARK (STOP_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
- query = gst_query_new (GST_QUERY_SEGMENT, structure);
+ query = gst_query_new_custom (GST_QUERY_SEGMENT, structure);
return query;
}
GstQuery *
gst_query_new_custom (GstQueryType type, GstStructure * structure)
{
- g_return_val_if_fail (gst_query_type_get_details (type) != NULL, NULL);
- g_return_val_if_fail (structure != NULL, NULL);
+ GstQueryImpl *query;
+
+ query = g_slice_new0 (GstQueryImpl);
- return gst_query_new (type, structure);
+ GST_DEBUG ("creating new query %p %s", query, gst_query_type_get_name (type));
+
+ if (structure) {
+ /* structure must not have a parent */
+ if (!gst_structure_set_parent_refcount (structure,
+ &query->query.mini_object.refcount))
+ goto had_parent;
+ }
+ gst_query_init (query, sizeof (GstQueryImpl), type);
+
+ GST_QUERY_STRUCTURE (query) = structure;
+
+ return GST_QUERY_CAST (query);
+
+ /* ERRORS */
+had_parent:
+ {
+ g_slice_free1 (GST_MINI_OBJECT_SIZE (query), query);
+ g_warning ("structure is already owned by another object");
+ return NULL;
+ }
}
/**
GST_QUARK (SEGMENT_START), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
GST_QUARK (SEGMENT_END), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
- query = gst_query_new (GST_QUERY_SEEKING, structure);
+ query = gst_query_new_custom (GST_QUERY_SEEKING, structure);
return query;
}
GstStructure *structure;
structure = gst_structure_new_id_empty (GST_QUARK (QUERY_FORMATS));
- query = gst_query_new (GST_QUERY_FORMATS, structure);
+ query = gst_query_new_custom (GST_QUERY_FORMATS, structure);
return query;
}
GST_QUARK (START_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
GST_QUARK (STOP_VALUE), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
- query = gst_query_new (GST_QUERY_BUFFERING, structure);
+ query = gst_query_new_custom (GST_QUERY_BUFFERING, structure);
return query;
}
structure = gst_structure_new_id (GST_QUARK (QUERY_URI),
GST_QUARK (URI), G_TYPE_STRING, NULL, NULL);
- query = gst_query_new (GST_QUERY_URI, structure);
+ query = gst_query_new_custom (GST_QUERY_URI, structure);
return query;
}
GST_QUARK (ALIGN), G_TYPE_UINT, 0,
GST_QUARK (POOL), GST_TYPE_BUFFER_POOL, NULL, NULL);
- query = gst_query_new (GST_QUERY_ALLOCATION, structure);
+ query = gst_query_new_custom (GST_QUERY_ALLOCATION, structure);
return query;
}
GST_QUARK (MINSIZE), G_TYPE_INT, 1,
GST_QUARK (MAXSIZE), G_TYPE_INT, -1,
GST_QUARK (ALIGN), G_TYPE_INT, 0, NULL);
- query = gst_query_new (GST_QUERY_SCHEDULING, structure);
+ query = gst_query_new_custom (GST_QUERY_SCHEDULING, structure);
return query;
}
structure = gst_structure_new_id (GST_QUARK (QUERY_ACCEPT_CAPS),
GST_QUARK (CAPS), GST_TYPE_CAPS, caps,
GST_QUARK (RESULT), G_TYPE_BOOLEAN, FALSE, NULL);
- query = gst_query_new (GST_QUERY_ACCEPT_CAPS, structure);
+ query = gst_query_new_custom (GST_QUERY_ACCEPT_CAPS, structure);
return query;
}
structure = gst_structure_new_id (GST_QUARK (QUERY_CAPS),
GST_QUARK (FILTER), GST_TYPE_CAPS, filter,
GST_QUARK (CAPS), GST_TYPE_CAPS, NULL, NULL);
- query = gst_query_new (GST_QUERY_CAPS, structure);
+ query = gst_query_new_custom (GST_QUERY_CAPS, structure);
return query;
}