}
}
+ if (flags & GST_BUFFER_COPY_CAPS) {
+ gst_caps_replace (&GST_BUFFER_CAPS (dest), GST_BUFFER_CAPS (src));
+ }
+
if (flags & GST_BUFFER_COPY_MEMORY) {
GstMemory *mem;
gsize skip, left, len, i, bsize;
GST_CAT_LOG (GST_CAT_BUFFER, "finalize %p", buffer);
- gst_context_replace (&GST_BUFFER_CONTEXT (buffer), NULL);
+ gst_caps_replace (&GST_BUFFER_CAPS (buffer), NULL);
/* free metadata */
for (walk = GST_BUFFER_META (buffer); walk; walk = next) {
(GstMiniObjectFreeFunction) _gst_buffer_free;
GST_BUFFER (buffer)->pool = NULL;
- GST_BUFFER_CONTEXT (buffer) = NULL;
+ GST_BUFFER_CAPS (buffer) = NULL;
GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE;
GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE;
GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET_NONE;
}
/**
- * gst_buffer_get_context:
+ * gst_buffer_get_caps:
* @buffer: a #GstBuffer.
*
- * Gets the context of the buffer. This can be NULL if there
- * is no context attached to this buffer.
+ * Gets the media type of the buffer. This can be NULL if there
+ * is no media type attached to this buffer.
*
- * Returns: (transfer full): a reference to the #GstContext. unref after usage.
- * Returns NULL if there was no context on this buffer.
+ * Returns: (transfer full): a reference to the #GstCaps. unref after usage.
+ * Returns NULL if there were no caps on this buffer.
*/
/* this is not made atomic because if the buffer were reffed from multiple
* threads, it would have a refcount > 2 and thus be immutable.
*/
-GstContext *
-gst_buffer_get_context (GstBuffer * buffer)
+GstCaps *
+gst_buffer_get_caps (GstBuffer * buffer)
{
- GstContext *ret;
+ GstCaps *ret;
g_return_val_if_fail (buffer != NULL, NULL);
- ret = GST_BUFFER_CONTEXT (buffer);
+ ret = GST_BUFFER_CAPS (buffer);
if (ret)
- gst_context_ref (ret);
+ gst_caps_ref (ret);
return ret;
}
/**
- * gst_buffer_set_context:
+ * gst_buffer_set_caps:
* @buffer: a #GstBuffer.
- * @context: (transfer none): a #GstContext.
+ * @caps: (transfer none): a #GstCaps.
*
- * Sets the media type on the buffer. The refcount of the context will
- * be increased and any previous context on the buffer will be
+ * Sets the media type on the buffer. The refcount of the caps will
+ * be increased and any previous caps on the buffer will be
* unreffed.
*/
/* this is not made atomic because if the buffer were reffed from multiple
* threads, it would have a refcount > 2 and thus be immutable.
*/
void
-gst_buffer_set_context (GstBuffer * buffer, GstContext * context)
+gst_buffer_set_caps (GstBuffer * buffer, GstCaps * caps)
{
g_return_if_fail (buffer != NULL);
- g_return_if_fail (gst_buffer_is_writable (buffer));
+ g_return_if_fail (caps == NULL || GST_CAPS_IS_SIMPLE (caps));
- gst_context_replace (&GST_BUFFER_CONTEXT (buffer), context);
+#if GST_VERSION_NANO == 1
+ /* we enable this extra debugging in git versions only for now */
+ g_warn_if_fail (gst_buffer_is_writable (buffer));
+ /* FIXME: would be nice to also check if caps are fixed here, but expensive */
+#endif
+
+ gst_caps_replace (&GST_BUFFER_CAPS (buffer), caps);
}
/**
* gst_buffer_copy_region:
* @parent: a #GstBuffer.
- * @offset: the offset into parent #GstBuffer at which the new sub-buffer
+ * @offset: the offset into parent #GstBuffer at which the new sub-buffer
* begins.
* @size: the size of the new #GstBuffer sub-buffer, in bytes.
*
* Creates a sub-buffer from @parent at @offset and @size.
* This sub-buffer uses the actual memory space of the parent buffer.
* This function will copy the offset and timestamp fields when the
- * offset is 0. If not, they will be set to #GST_CLOCK_TIME_NONE and
+ * offset is 0. If not, they will be set to #GST_CLOCK_TIME_NONE and
* #GST_BUFFER_OFFSET_NONE.
* If @offset equals 0 and @size equals the total size of @buffer, the
* duration and offset end fields are also copied. If not they will be set
else
return NULL;
}
-
-GstCaps *
-gst_buffer_caps (GstBuffer * buffer)
-{
- GstContext *context;
- GstEvent *event;
- GstCaps *caps = NULL;
-
- if (!(context = GST_BUFFER_CONTEXT (buffer)))
- return NULL;
-
- if (!(event = gst_context_get (context, GST_EVENT_CAPS)))
- return NULL;
-
- gst_event_parse_caps (event, &caps);
- gst_event_unref (event);
-
- return caps;
-}