GST_DEBUG_CATEGORY_STATIC (gst_query_debug);
#define GST_CAT_DEFAULT gst_query_debug
-static void gst_query_finalize (GstQuery * query);
-static GstQuery *_gst_query_copy (GstQuery * query);
+static GType _gst_query_type = 0;
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
static GList *_gst_queries = NULL;
static GHashTable *_query_type_to_nick = NULL;
static guint32 _n_values = 1; /* we start from 1 because 0 reserved for NONE */
-static GstMiniObjectClass *parent_class = NULL;
-
static GstQueryTypeDefinition standard_definitions[] = {
{GST_QUERY_POSITION, "position", "Current position", 0},
{GST_QUERY_DURATION, "duration", "Total duration", 0},
}
g_static_mutex_unlock (&mutex);
- g_type_class_ref (gst_query_get_type ());
+ gst_query_get_type ();
}
/**
return def->quark;
}
-G_DEFINE_TYPE (GstQuery, gst_query, GST_TYPE_MINI_OBJECT);
-
-static void
-gst_query_class_init (GstQueryClass * klass)
+GType
+gst_query_get_type (void)
{
- parent_class = g_type_class_peek_parent (klass);
-
- klass->mini_object_class.copy = (GstMiniObjectCopyFunction) _gst_query_copy;
- klass->mini_object_class.finalize =
- (GstMiniObjectFinalizeFunction) gst_query_finalize;
-
-}
-
-static void
-gst_query_init (GstQuery * query)
-{
-}
-
-static void
-gst_query_finalize (GstQuery * query)
-{
- g_return_if_fail (query != NULL);
-
- if (query->structure) {
- gst_structure_set_parent_refcount (query->structure, NULL);
- gst_structure_free (query->structure);
- }
-
-/* GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (query)); */
-}
-
-static GstQuery *
-_gst_query_copy (GstQuery * query)
-{
- GstQuery *copy;
-
- copy = (GstQuery *) gst_mini_object_new (GST_TYPE_QUERY);
-
- copy->type = query->type;
-
- if (query->structure) {
- copy->structure = gst_structure_copy (query->structure);
- gst_structure_set_parent_refcount (copy->structure,
- &query->mini_object.refcount);
+ if (G_UNLIKELY (_gst_query_type == 0)) {
+ _gst_query_type = gst_mini_object_register ("GstQuery");
}
-
- return copy;
+ return _gst_query_type;
}
-
/**
* gst_query_type_register:
* @nick: The nick of the new query
return result;
}
+static void
+_gst_query_free (GstQuery * query)
+{
+ g_return_if_fail (query != NULL);
+
+ if (query->structure) {
+ gst_structure_set_parent_refcount (query->structure, NULL);
+ gst_structure_free (query->structure);
+ }
+
+ 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, query->structure);
+
+ return copy;
+}
+
static GstQuery *
gst_query_new (GstQueryType type, GstStructure * structure)
{
GstQuery *query;
- query = (GstQuery *) gst_mini_object_new (GST_TYPE_QUERY);
+ query = g_slice_new0 (GstQuery);
+
+ gst_mini_object_init (GST_MINI_OBJECT_CAST (query),
+ _gst_query_type, sizeof (GstQuery));
+
+ query->mini_object.copy = (GstMiniObjectCopyFunction) _gst_query_copy;
+ query->mini_object.free = (GstMiniObjectFreeFunction) _gst_query_free;
GST_DEBUG ("creating new query %p %d", query, type);
query->type = type;
+ query->structure = structure;
- if (structure) {
- query->structure = structure;
+ if (structure)
gst_structure_set_parent_refcount (query->structure,
&query->mini_object.refcount);
- } else {
- query->structure = NULL;
- }
return query;
}
* Since: 0.10.4
*/
void
- gst_query_set_formatsv (GstQuery * query, gint n_formats, GstFormat * formats)
+ gst_query_set_formatsv (GstQuery * query, gint n_formats,
+ const GstFormat * formats)
{
GValue list = { 0, };
gint i;
typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition;
typedef struct _GstQuery GstQuery;
-typedef struct _GstQueryClass GstQueryClass;
/**
* GstQueryTypeDefinition:
GQuark quark;
};
-#define GST_TYPE_QUERY (gst_query_get_type())
-#define GST_IS_QUERY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_QUERY))
-#define GST_IS_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_QUERY))
-#define GST_QUERY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_QUERY, GstQueryClass))
-#define GST_QUERY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_QUERY, GstQuery))
-#define GST_QUERY_CAST(obj) ((GstQuery*)(obj)) /* only since 0.10.23 */
-#define GST_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_QUERY, GstQueryClass))
+#define GST_TYPE_QUERY (gst_query_get_type())
+#define GST_IS_QUERY(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_QUERY))
+#define GST_QUERY_CAST(obj) ((GstQuery*)(obj))
+#define GST_QUERY(obj) (GST_QUERY_CAST(obj))
/**
gpointer _gst_reserved;
};
-struct _GstQueryClass {
- GstMiniObjectClass mini_object_class;
-
- /*< private >*/
- gpointer _gst_reserved[GST_PADDING];
-};
-
const gchar* gst_query_type_get_name (GstQueryType query);
GQuark gst_query_type_to_quark (GstQueryType query);
/* formats query */
GstQuery* gst_query_new_formats (void);
void gst_query_set_formats (GstQuery *query, gint n_formats, ...);
- void gst_query_set_formatsv (GstQuery *query, gint n_formats, GstFormat *formats);
+ void gst_query_set_formatsv (GstQuery *query, gint n_formats, const GstFormat *formats);
void gst_query_parse_formats_length (GstQuery *query, guint *n_formats);
void gst_query_parse_formats_nth (GstQuery *query, guint nth, GstFormat *format);
#define GST_CAT_DEFAULT gst_base_parse_debug
/* Supported formats */
- static GstFormat fmtlist[] = {
+ static const GstFormat fmtlist[] = {
GST_FORMAT_DEFAULT,
GST_FORMAT_BYTES,
GST_FORMAT_TIME,
GstIndex *index;
gint index_id;
gboolean own_index;
+ GStaticMutex index_lock;
+
/* seek table entries only maintained if upstream is BYTE seekable */
gboolean upstream_seekable;
gboolean upstream_has_duration;
parse->priv->index = NULL;
}
+ g_static_mutex_free (&parse->priv->index_lock);
+
gst_base_parse_clear_queues (parse);
G_OBJECT_CLASS (parent_class)->finalize (object);
parse->priv->pad_mode = GST_ACTIVATE_NONE;
+ g_static_mutex_init (&parse->priv->index_lock);
+
/* init state */
gst_base_parse_reset (parse);
GST_DEBUG_OBJECT (parse, "init ok");
gst_base_parse_check_frame (GstBaseParse * parse,
GstBaseParseFrame * frame, guint * framesize, gint * skipsize)
{
- *framesize = GST_BUFFER_SIZE (frame->buffer);
+ *framesize = gst_buffer_get_size (frame->buffer);
*skipsize = 0;
return TRUE;
}
if (overhead == -1)
return;
- data_len = GST_BUFFER_SIZE (buffer) - overhead;
+ data_len = gst_buffer_get_size (buffer) - overhead;
parse->priv->data_bytecount += data_len;
/* duration should be valid by now,
associations[1].value = offset;
/* index might change on-the-fly, although that would be nutty app ... */
- GST_OBJECT_LOCK (parse);
+ g_static_mutex_lock (&parse->priv->index_lock);
gst_index_add_associationv (parse->priv->index, parse->priv->index_id,
(key) ? GST_ASSOCIATION_FLAG_KEY_UNIT : GST_ASSOCIATION_FLAG_DELTA_UNIT,
2, (const GstIndexAssociation *) &associations);
- GST_OBJECT_UNLOCK (parse);
+ g_static_mutex_unlock (&parse->priv->index_lock);
if (key) {
parse->priv->index_last_offset = offset;
"parsing frame at offset %" G_GUINT64_FORMAT
" (%#" G_GINT64_MODIFIER "x) of size %d",
GST_BUFFER_OFFSET (buffer), GST_BUFFER_OFFSET (buffer),
- GST_BUFFER_SIZE (buffer));
+ gst_buffer_get_size (buffer));
/* use default handler to provide initial (upstream) metadata */
gst_base_parse_parse_frame (parse, frame);
GstBaseParseFrame *queued_frame;
while ((queued_frame = g_queue_pop_head (&parse->priv->queued_frames))) {
- queued_frame->buffer =
- gst_buffer_make_metadata_writable (queued_frame->buffer);
+ queued_frame->buffer = gst_buffer_make_writable (queued_frame->buffer);
gst_buffer_set_caps (queued_frame->buffer,
GST_PAD_CAPS (GST_BASE_PARSE_SRC_PAD (parse)));
gst_base_parse_push_frame (parse, queued_frame);
GstClockTime last_stop = GST_CLOCK_TIME_NONE;
GstBaseParseClass *klass = GST_BASE_PARSE_GET_CLASS (parse);
GstBuffer *buffer;
+ gsize size;
g_return_val_if_fail (frame != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (frame->buffer != NULL, GST_FLOW_ERROR);
GST_LOG_OBJECT (parse,
"processing buffer of size %d with ts %" GST_TIME_FORMAT
- ", duration %" GST_TIME_FORMAT, GST_BUFFER_SIZE (buffer),
+ ", duration %" GST_TIME_FORMAT, gst_buffer_get_size (buffer),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)));
/* update stats */
- parse->priv->bytecount += GST_BUFFER_SIZE (buffer);
+ size = gst_buffer_get_size (buffer);
+ parse->priv->bytecount += size;
if (G_LIKELY (!(frame->flags & GST_BASE_PARSE_FRAME_FLAG_NO_FRAME))) {
parse->priv->framecount++;
if (GST_BUFFER_DURATION_IS_VALID (buffer)) {
g_return_val_if_fail (buffer != NULL, GST_FLOW_ERROR);
/* decorate */
- buffer = gst_buffer_make_metadata_writable (buffer);
+ buffer = gst_buffer_make_writable (buffer);
gst_buffer_set_caps (buffer, GST_PAD_CAPS (parse->srcpad));
parse->priv->seen_keyframe |= parse->priv->is_video &&
}
if (ret == GST_BASE_PARSE_FLOW_DROPPED) {
- GST_LOG_OBJECT (parse, "frame (%d bytes) dropped",
- GST_BUFFER_SIZE (buffer));
+ GST_LOG_OBJECT (parse, "frame (%" G_GSIZE_FORMAT " bytes) dropped", size);
gst_buffer_unref (buffer);
ret = GST_FLOW_OK;
} else if (ret == GST_FLOW_OK) {
if (parse->segment.rate > 0.0) {
ret = gst_pad_push (parse->srcpad, buffer);
- GST_LOG_OBJECT (parse, "frame (%d bytes) pushed: %s",
- GST_BUFFER_SIZE (buffer), gst_flow_get_name (ret));
+ GST_LOG_OBJECT (parse, "frame (%" G_GSIZE_FORMAT " bytes) pushed: %s",
+ size, gst_flow_get_name (ret));
} else {
- GST_LOG_OBJECT (parse, "frame (%d bytes) queued for now",
- GST_BUFFER_SIZE (buffer));
+ GST_LOG_OBJECT (parse, "frame (%" G_GSIZE_FORMAT " bytes) queued for now",
+ size);
parse->priv->buffers_queued =
g_slist_prepend (parse->priv->buffers_queued, buffer);
ret = GST_FLOW_OK;
}
} else {
gst_buffer_unref (buffer);
- GST_LOG_OBJECT (parse, "frame (%d bytes) not pushed: %s",
- GST_BUFFER_SIZE (buffer), gst_flow_get_name (ret));
+ GST_LOG_OBJECT (parse, "frame (%" G_GSIZE_FORMAT " bytes) not pushed: %s",
+ size, gst_flow_get_name (ret));
/* if we are not sufficiently in control, let upstream decide on EOS */
if (ret == GST_FLOW_UNEXPECTED &&
(parse->priv->passthrough ||
while (parse->priv->buffers_pending) {
buf = GST_BUFFER_CAST (parse->priv->buffers_pending->data);
GST_LOG_OBJECT (parse, "adding pending buffer (size %d)",
- GST_BUFFER_SIZE (buf));
+ gst_buffer_get_size (buf));
gst_adapter_push (parse->priv->adapter, buf);
parse->priv->buffers_pending =
g_slist_delete_link (parse->priv->buffers_pending,
if (G_LIKELY (buffer)) {
GST_LOG_OBJECT (parse, "buffer size: %d, offset = %" G_GINT64_FORMAT,
- GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (buffer));
+ gst_buffer_get_size (buffer), GST_BUFFER_OFFSET (buffer));
if (G_UNLIKELY (parse->priv->passthrough)) {
- frame->buffer = gst_buffer_make_metadata_writable (buffer);
+ frame->buffer = gst_buffer_make_writable (buffer);
return gst_base_parse_push_frame (parse, frame);
}
/* upstream feeding us in reverse playback;
}
/* always pass all available data */
- data = gst_adapter_peek (parse->priv->adapter, av);
- GST_BUFFER_DATA (tmpbuf) = (guint8 *) data;
- GST_BUFFER_SIZE (tmpbuf) = min_size;
+ data = gst_adapter_map (parse->priv->adapter, av);
+ gst_buffer_take_memory (tmpbuf,
+ gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
+ (gpointer) data, NULL, min_size, 0, min_size));
GST_BUFFER_OFFSET (tmpbuf) = parse->priv->offset;
- GST_BUFFER_FLAG_SET (tmpbuf, GST_MINI_OBJECT_FLAG_READONLY);
if (parse->priv->discont) {
GST_DEBUG_OBJECT (parse, "marking DISCONT");
skip = -1;
gst_base_parse_frame_update (parse, frame, tmpbuf);
res = bclass->check_valid_frame (parse, frame, &fsize, &skip);
+ gst_adapter_unmap (parse->priv->adapter, 0);
gst_buffer_replace (&frame->buffer, NULL);
if (res) {
if (gst_adapter_available (parse->priv->adapter) < fsize) {
* fragment coming later, hopefully subclass skips efficiently ... */
timestamp = gst_adapter_prev_timestamp (parse->priv->adapter, NULL);
outbuf = gst_adapter_take_buffer (parse->priv->adapter, skip);
- outbuf = gst_buffer_make_metadata_writable (outbuf);
+ outbuf = gst_buffer_make_writable (outbuf);
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
parse->priv->buffers_pending =
g_slist_prepend (parse->priv->buffers_pending, outbuf);
/* FIXME: Would it be more efficient to make a subbuffer instead? */
outbuf = gst_adapter_take_buffer (parse->priv->adapter, fsize);
- outbuf = gst_buffer_make_metadata_writable (outbuf);
+ outbuf = gst_buffer_make_writable (outbuf);
/* Subclass may want to know the data offset */
GST_BUFFER_OFFSET (outbuf) = parse->priv->offset;
* We do it mainly to avoid pulling buffers of 1 byte all the time */
if (parse->priv->cache) {
gint64 cache_offset = GST_BUFFER_OFFSET (parse->priv->cache);
- gint cache_size = GST_BUFFER_SIZE (parse->priv->cache);
+ gint cache_size = gst_buffer_get_size (parse->priv->cache);
if (cache_offset <= parse->priv->offset &&
(parse->priv->offset + size) <= (cache_offset + cache_size)) {
- *buffer = gst_buffer_create_sub (parse->priv->cache,
+ *buffer = gst_buffer_copy_region (parse->priv->cache, GST_BUFFER_COPY_ALL,
parse->priv->offset - cache_offset, size);
GST_BUFFER_OFFSET (*buffer) = parse->priv->offset;
return GST_FLOW_OK;
return ret;
}
- if (GST_BUFFER_SIZE (parse->priv->cache) >= size) {
- *buffer = gst_buffer_create_sub (parse->priv->cache, 0, size);
+ if (gst_buffer_get_size (parse->priv->cache) >= size) {
+ *buffer =
+ gst_buffer_copy_region (parse->priv->cache, GST_BUFFER_COPY_ALL, 0,
+ size);
GST_BUFFER_OFFSET (*buffer) = parse->priv->offset;
return GST_FLOW_OK;
}
return ret;
}
- if (GST_BUFFER_SIZE (parse->priv->cache) < size) {
+ if (gst_buffer_get_size (parse->priv->cache) < size) {
GST_DEBUG_OBJECT (parse, "Returning short buffer at offset %"
G_GUINT64_FORMAT ": wanted %u bytes, got %u bytes", parse->priv->offset,
- size, GST_BUFFER_SIZE (parse->priv->cache));
+ size, gst_buffer_get_size (parse->priv->cache));
*buffer = parse->priv->cache;
parse->priv->cache = NULL;
return GST_FLOW_OK;
}
- *buffer = gst_buffer_create_sub (parse->priv->cache, 0, size);
+ *buffer =
+ gst_buffer_copy_region (parse->priv->cache, GST_BUFFER_COPY_ALL, 0, size);
GST_BUFFER_OFFSET (*buffer) = parse->priv->offset;
return GST_FLOW_OK;
/* if we got a short read, inform subclass we are draining leftover
* and no more is to be expected */
- if (GST_BUFFER_SIZE (buffer) < min_size)
+ if (gst_buffer_get_size (buffer) < min_size)
parse->priv->drain = TRUE;
skip = -1;
/* reverse playback, and no frames found yet, so we are skipping
* the leading part of a fragment, which may form the tail of
* fragment coming later, hopefully subclass skips efficiently ... */
- outbuf = gst_buffer_create_sub (buffer, 0, skip);
+ outbuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 0, skip);
parse->priv->buffers_pending =
g_slist_prepend (parse->priv->buffers_pending, outbuf);
outbuf = NULL;
else if (skip < 0)
skip = 0;
- if (fsize + skip <= GST_BUFFER_SIZE (buffer)) {
- outbuf = gst_buffer_create_sub (buffer, skip, fsize);
+ if (fsize + skip <= gst_buffer_get_size (buffer)) {
+ outbuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, skip, fsize);
GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buffer) + skip;
GST_BUFFER_TIMESTAMP (outbuf) = GST_CLOCK_TIME_NONE;
gst_buffer_unref (buffer);
ret = gst_base_parse_pull_range (parse, fsize, &outbuf);
if (ret != GST_FLOW_OK)
goto done;
- if (GST_BUFFER_SIZE (outbuf) < fsize) {
+ if (gst_buffer_get_size (outbuf) < fsize) {
gst_buffer_unref (outbuf);
ret = GST_FLOW_UNEXPECTED;
}
*
* By default, announced average bitrate is estimated. The average bitrate
* is used to estimate the total duration of the stream and to estimate
- * a seek position, if there's no index and #GST_BASE_PARSE_FORMAT_FLAG_SYNCABLE
- * is set.
+ * a seek position, if there's no index and the format is syncable
+ * (see gst_base_parse_set_syncable()).
*
* Since: 0.10.33
*/
GST_LOG_OBJECT (parse,
"peek parsing frame at offset %" G_GUINT64_FORMAT
" (%#" G_GINT64_MODIFIER "x) of size %d",
- GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf));
+ GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET (buf),
+ gst_buffer_get_size (buf));
/* get offset first, subclass parsing might dump other stuff in there */
*pos = GST_BUFFER_OFFSET (buf);
goto exit;
}
- GST_OBJECT_LOCK (parse);
+ g_static_mutex_lock (&parse->priv->index_lock);
if (parse->priv->index) {
/* Let's check if we have an index entry for that time */
entry = gst_index_get_assoc_entry (parse->priv->index,
ts = GST_CLOCK_TIME_NONE;
}
}
- GST_OBJECT_UNLOCK (parse);
+ g_static_mutex_unlock (&parse->priv->index_lock);
exit:
if (_ts)
{
GstBaseParse *parse = GST_BASE_PARSE (element);
- GST_OBJECT_LOCK (parse);
+ g_static_mutex_lock (&parse->priv->index_lock);
if (parse->priv->index)
gst_object_unref (parse->priv->index);
if (index) {
parse->priv->index = gst_object_ref (index);
- gst_index_get_writer_id (index, GST_OBJECT (element),
+ gst_index_get_writer_id (index, GST_OBJECT_CAST (element),
&parse->priv->index_id);
parse->priv->own_index = FALSE;
- } else
+ } else {
parse->priv->index = NULL;
- GST_OBJECT_UNLOCK (parse);
+ }
+ g_static_mutex_unlock (&parse->priv->index_lock);
}
static GstIndex *
GstBaseParse *parse = GST_BASE_PARSE (element);
GstIndex *result = NULL;
- GST_OBJECT_LOCK (parse);
+ g_static_mutex_lock (&parse->priv->index_lock);
if (parse->priv->index)
result = gst_object_ref (parse->priv->index);
- GST_OBJECT_UNLOCK (parse);
+ g_static_mutex_unlock (&parse->priv->index_lock);
return result;
}
case GST_STATE_CHANGE_READY_TO_PAUSED:
/* If this is our own index destroy it as the
* old entries might be wrong for the new stream */
+ g_static_mutex_lock (&parse->priv->index_lock);
if (parse->priv->own_index) {
gst_object_unref (parse->priv->index);
parse->priv->index = NULL;
&parse->priv->index_id);
parse->priv->own_index = TRUE;
}
+ g_static_mutex_unlock (&parse->priv->index_lock);
break;
default:
break;
/* upstream caps and size suggestions */
GstCaps *sink_suggest;
- guint size_suggest;
+ gsize size_suggest;
gboolean suggest_pending;
gboolean reconfigure;
static gboolean gst_base_transform_activate (GstBaseTransform * trans,
gboolean active);
static gboolean gst_base_transform_get_unit_size (GstBaseTransform * trans,
- GstCaps * caps, guint * size);
+ GstCaps * caps, gsize * size);
static gboolean gst_base_transform_src_event (GstPad * pad, GstEvent * event);
static gboolean gst_base_transform_src_eventfunc (GstBaseTransform * trans,
static gboolean
gst_base_transform_transform_size (GstBaseTransform * trans,
GstPadDirection direction, GstCaps * caps,
- guint size, GstCaps * othercaps, guint * othersize)
+ gsize size, GstCaps * othercaps, gsize * othersize)
{
- guint inunitsize, outunitsize, units;
+ gsize inunitsize, outunitsize, units;
GstBaseTransformClass *klass;
gboolean ret;
{
GST_DEBUG_OBJECT (trans, "Size %u is not a multiple of unit size %u", size,
inunitsize);
- g_warning ("%s: size %u is not a multiple of unit size %u",
- GST_ELEMENT_NAME (trans), size, inunitsize);
+ g_warning ("%s: size %" G_GSIZE_FORMAT " is not a multiple of unit size %"
+ G_GSIZE_FORMAT, GST_ELEMENT_NAME (trans), size, inunitsize);
return FALSE;
}
no_out_size:
otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad;
/* we can do what the peer can */
- caps = gst_pad_peer_get_caps_reffed (otherpad);
+ caps = gst_pad_peer_get_caps (otherpad);
if (caps) {
GstCaps *temp;
const GstCaps *templ;
GST_DEBUG_OBJECT (trans, "othercaps now %" GST_PTR_FORMAT, othercaps);
- peercaps = gst_pad_get_caps_reffed (otherpeer);
+ peercaps = gst_pad_get_caps (otherpeer);
intersect = gst_caps_intersect (peercaps, othercaps);
gst_caps_unref (peercaps);
gst_caps_unref (othercaps);
/* get all the formats we can handle on this pad */
if (direction == GST_PAD_SRC)
- allowed = gst_pad_get_caps_reffed (trans->srcpad);
+ allowed = gst_pad_get_caps (trans->srcpad);
else
- allowed = gst_pad_get_caps_reffed (trans->sinkpad);
+ allowed = gst_pad_get_caps (trans->sinkpad);
if (!allowed) {
GST_DEBUG_OBJECT (trans, "gst_pad_get_caps() failed");
}
static void
-compute_upstream_suggestion (GstBaseTransform * trans, guint expsize,
+compute_upstream_suggestion (GstBaseTransform * trans, gsize expsize,
GstCaps * caps)
{
GstCaps *othercaps;
* because it should have checked if we could handle these caps. We can
* simply ignore these caps and produce a buffer with our original caps. */
} else {
- guint size_suggest;
+ gsize size_suggest;
GST_DEBUG_OBJECT (trans, "getting size of suggestion");
GstBaseTransformClass *bclass;
GstBaseTransformPrivate *priv;
GstFlowReturn ret = GST_FLOW_OK;
- guint outsize, newsize, expsize;
+ gsize insize, outsize, newsize, expsize;
gboolean discard, setcaps, copymeta;
GstCaps *incaps, *oldcaps, *newcaps, *outcaps;
*out_buf = NULL;
+ insize = gst_buffer_get_size (in_buf);
+
/* figure out how to allocate a buffer based on the current configuration */
if (trans->passthrough) {
GST_DEBUG_OBJECT (trans, "doing passthrough alloc");
/* passthrough, we don't really need to call pad alloc but we still need to
* in order to get upstream negotiation. The output size is the same as the
* input size. */
- outsize = GST_BUFFER_SIZE (in_buf);
+ outsize = insize;
/* we always alloc and discard here */
discard = TRUE;
} else {
if (want_in_place) {
GST_DEBUG_OBJECT (trans, "doing inplace alloc");
/* we alloc a buffer of the same size as the input */
- outsize = GST_BUFFER_SIZE (in_buf);
+ outsize = insize;
/* only discard it when the input was not writable, otherwise, we reuse
* the input buffer. */
discard = gst_buffer_is_writable (in_buf);
/* copy transform, figure out the output size */
if (!gst_base_transform_transform_size (trans,
GST_PAD_SINK, GST_PAD_CAPS (trans->sinkpad),
- GST_BUFFER_SIZE (in_buf), GST_PAD_CAPS (trans->srcpad),
- &outsize)) {
+ insize, GST_PAD_CAPS (trans->srcpad), &outsize)) {
goto unknown_size;
}
/* never discard this buffer, we need it for storing the output */
/* check if we got different caps on this new output buffer */
newcaps = GST_BUFFER_CAPS (*out_buf);
- newsize = GST_BUFFER_SIZE (*out_buf);
+ newsize = gst_buffer_get_size (*out_buf);
if (newcaps && !gst_caps_is_equal (newcaps, oldcaps)) {
GstCaps *othercaps;
GST_DEBUG_OBJECT (trans, "cannot perform transform on current buffer");
gst_base_transform_transform_size (trans,
- GST_PAD_SINK, incaps, GST_BUFFER_SIZE (in_buf), newcaps, &expsize);
+ GST_PAD_SINK, incaps, insize, newcaps, &expsize);
compute_upstream_suggestion (trans, expsize, newcaps);
if (othercaps && !gst_caps_is_empty (othercaps)) {
GST_DEBUG_OBJECT (trans, "we found target caps %" GST_PTR_FORMAT,
othercaps);
- *out_buf = gst_buffer_make_metadata_writable (*out_buf);
+ *out_buf = gst_buffer_make_writable (*out_buf);
gst_buffer_set_caps (*out_buf, othercaps);
gst_caps_unref (othercaps);
newcaps = GST_BUFFER_CAPS (*out_buf);
* expected size here, we will check the size if we are going to use the
* buffer later on. */
gst_base_transform_transform_size (trans,
- GST_PAD_SINK, incaps, GST_BUFFER_SIZE (in_buf), newcaps, &expsize);
+ GST_PAD_SINK, incaps, insize, newcaps, &expsize);
if (can_convert) {
GST_DEBUG_OBJECT (trans, "reconfigure transform for current buffer");
GST_DEBUG_PAD_NAME (trans->srcpad));
bclass->fixate_caps (trans, GST_PAD_SINK, incaps, newcaps);
- *out_buf = gst_buffer_make_metadata_writable (*out_buf);
+ *out_buf = gst_buffer_make_writable (*out_buf);
gst_buffer_set_caps (*out_buf, newcaps);
gst_caps_unref (newcaps);
newcaps = GST_BUFFER_CAPS (*out_buf);
outsize);
/* no valid buffer yet, make one, metadata is writable */
*out_buf = gst_buffer_new_and_alloc (outsize);
- gst_buffer_copy_metadata (*out_buf, in_buf,
- GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS);
+ gst_buffer_copy_into (*out_buf, in_buf,
+ GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
} else {
GST_DEBUG_OBJECT (trans, "reuse input buffer");
*out_buf = in_buf;
if (setcaps || copymeta) {
GST_DEBUG_OBJECT (trans, "setcaps %d, copymeta %d", setcaps, copymeta);
- if (!gst_buffer_is_metadata_writable (*out_buf)) {
- GST_DEBUG_OBJECT (trans, "buffer metadata %p not writable", *out_buf);
+ if (!gst_buffer_is_writable (*out_buf)) {
+ GST_DEBUG_OBJECT (trans, "buffer %p not writable", *out_buf);
if (in_buf == *out_buf)
- *out_buf = gst_buffer_create_sub (in_buf, 0, GST_BUFFER_SIZE (in_buf));
+ *out_buf = gst_buffer_copy (in_buf);
else
- *out_buf = gst_buffer_make_metadata_writable (*out_buf);
+ *out_buf = gst_buffer_make_writable (*out_buf);
}
/* when we get here, the metadata should be writable */
if (setcaps)
gst_buffer_set_caps (*out_buf, outcaps);
if (copymeta)
- gst_buffer_copy_metadata (*out_buf, in_buf,
- GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS);
+ gst_buffer_copy_into (*out_buf, in_buf,
+ GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
/* clear the GAP flag when the subclass does not understand it */
if (!trans->priv->gap_aware)
GST_BUFFER_FLAG_UNSET (*out_buf, GST_BUFFER_FLAG_GAP);
*/
static gboolean
gst_base_transform_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
- guint * size)
+ gsize * size)
{
gboolean res = FALSE;
GstBaseTransformClass *bclass;
GstFlowReturn res;
gboolean proxy, suggest, same_caps;
GstCaps *sink_suggest = NULL;
- guint size_suggest;
+ gsize size_suggest;
trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
if (G_UNLIKELY (trans == NULL))
GST_DEBUG_OBJECT (trans, "Suggested caps is not fixed: %"
GST_PTR_FORMAT, sink_suggest);
- peercaps =
- gst_pad_peer_get_caps_reffed (GST_BASE_TRANSFORM_SINK_PAD (trans));
+ peercaps = gst_pad_peer_get_caps (GST_BASE_TRANSFORM_SINK_PAD (trans));
/* try fixating by intersecting with peer caps */
if (peercaps) {
GstCaps *intersect;
sink_suggest = NULL;
}
- gst_object_unref (trans);
if (sink_suggest)
gst_caps_unref (sink_suggest);
trans->priv->force_alloc = FALSE;
}
+ gst_object_unref (trans);
return res;
/* ERRORS */
GstClockTime running_time;
GstClockTime timestamp;
GstCaps *incaps;
+ gsize insize;
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
}
}
+ insize = gst_buffer_get_size (inbuf);
+
if (GST_BUFFER_OFFSET_IS_VALID (inbuf))
- GST_DEBUG_OBJECT (trans, "handling buffer %p of size %d and offset %"
- G_GUINT64_FORMAT, inbuf, GST_BUFFER_SIZE (inbuf),
- GST_BUFFER_OFFSET (inbuf));
+ GST_DEBUG_OBJECT (trans,
+ "handling buffer %p of size %" G_GSIZE_FORMAT " and offset %"
+ G_GUINT64_FORMAT, inbuf, insize, GST_BUFFER_OFFSET (inbuf));
else
- GST_DEBUG_OBJECT (trans, "handling buffer %p of size %d and offset NONE",
- inbuf, GST_BUFFER_SIZE (inbuf));
+ GST_DEBUG_OBJECT (trans,
+ "handling buffer %p of size %" G_GSIZE_FORMAT " and offset NONE", inbuf,
+ insize);
/* Don't allow buffer handling before negotiation, except in passthrough mode
* or if the class doesn't implement a set_caps function (in which case it doesn't
if (inbuf != *outbuf) {
guint8 *indata, *outdata;
+ gsize insize, outsize;
/* Different buffer. The data can still be the same when we are dealing
* with subbuffers of the same buffer. Note that because of the FIXME in
* prepare_output_buffer() we have decreased the refcounts of inbuf and
* outbuf to keep them writable */
- indata = GST_BUFFER_DATA (inbuf);
- outdata = GST_BUFFER_DATA (*outbuf);
+ indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
+ outdata = gst_buffer_map (*outbuf, &outsize, NULL, GST_MAP_WRITE);
if (indata != outdata)
- memcpy (outdata, indata, GST_BUFFER_SIZE (inbuf));
+ memcpy (outdata, indata, insize);
+
+ gst_buffer_unmap (inbuf, indata, insize);
+ gst_buffer_unmap (*outbuf, outdata, outsize);
}
ret = bclass->transform_ip (trans, *outbuf);
} else {
/* apply DISCONT flag if the buffer is not yet marked as such */
if (trans->priv->discont) {
if (!GST_BUFFER_IS_DISCONT (outbuf)) {
- outbuf = gst_buffer_make_metadata_writable (outbuf);
+ outbuf = gst_buffer_make_writable (outbuf);
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
}
trans->priv->discont = FALSE;
*/
void
gst_base_transform_suggest (GstBaseTransform * trans, GstCaps * caps,
- guint size)
+ gsize size)
{
g_return_if_fail (GST_IS_BASE_TRANSFORM (trans));
/* convenience macro so we don't have to litter the code with if(!quiet) */
#define PRINT if(!quiet)g_print
-#if !defined(GST_DISABLE_LOADSAVE) && !defined(GST_REMOVE_DEPRECATED)
-static GstElement *
-xmllaunch_parse_cmdline (const gchar ** argv)
-{
- GstElement *pipeline = NULL, *e;
- GstXML *xml;
- gboolean err;
- const gchar *arg;
- gchar *element, *property, *value;
- GList *l;
- gint i = 0;
-
- if (!(arg = argv[0])) {
- g_printerr ("%s",
- _("Usage: gst-xmllaunch <file.xml> [ element.property=value ... ]\n"));
- exit (1);
- }
-
- xml = gst_xml_new ();
- /* FIXME guchar from gstxml.c */
- err = gst_xml_parse_file (xml, (guchar *) arg, NULL);
-
- if (err != TRUE) {
- g_printerr (_("ERROR: parse of xml file '%s' failed.\n"), arg);
- exit (1);
- }
-
- l = gst_xml_get_topelements (xml);
- if (!l) {
- g_printerr (_("ERROR: no toplevel pipeline element in file '%s'.\n"), arg);
- exit (1);
- }
-
- if (l->next) {
- g_printerr ("%s",
- _("WARNING: only one toplevel element is supported at this time.\n"));
- }
-
- pipeline = GST_ELEMENT (l->data);
-
- while ((arg = argv[++i])) {
- element = g_strdup (arg);
- property = strchr (element, '.');
- value = strchr (element, '=');
-
- if (!(element < property && property < value)) {
- g_printerr (_("ERROR: could not parse command line argument %d: %s.\n"),
- i, element);
- g_free (element);
- exit (1);
- }
-
- *property++ = '\0';
- *value++ = '\0';
-
- e = gst_bin_get_by_name (GST_BIN (pipeline), element);
- if (!e) {
- g_printerr (_("WARNING: element named '%s' not found.\n"), element);
- } else {
- gst_util_set_object_arg (G_OBJECT (e), property, value);
- }
- g_free (element);
- }
-
- if (!l)
- return NULL;
-
- gst_object_ref (pipeline);
- gst_object_unref (xml);
- return pipeline;
-}
-#endif
-
#ifndef DISABLE_FAULT_HANDLER
#ifndef USE_SIGINFO
static void
gint i;
if (index_stats->len) {
- g_print (_("Index statistics\n"));
+ g_print ("%s:\n", _("Index statistics"));
}
for (i = 0; i < index_stats->len; i++) {
caps_str = GST_BUFFER_CAPS (img) ?
gst_caps_to_string (GST_BUFFER_CAPS (img)) : g_strdup ("unknown");
- str = g_strdup_printf ("buffer of %u bytes, type: %s",
- GST_BUFFER_SIZE (img), caps_str);
+ str = g_strdup_printf ("buffer of %" G_GSIZE_FORMAT " bytes, type: %s",
+ gst_buffer_get_size (img), caps_str);
g_free (caps_str);
} else {
str = g_strdup ("NULL buffer");
N_("Output messages"), NULL},
{"exclude", 'X', 0, G_OPTION_ARG_NONE, &exclude_args,
N_("Do not output status information of TYPE"), N_("TYPE1,TYPE2,...")},
-#if !defined(GST_DISABLE_LOADSAVE) && !defined(GST_REMOVE_DEPRECATED)
- {"output", 'o', 0, G_OPTION_ARG_STRING, &savefile,
- N_("Save xml representation of pipeline to FILE and exit"), N_("FILE")},
-#endif
{"no-fault", 'f', 0, G_OPTION_ARG_NONE, &no_fault,
N_("Do not install a fault handler"), NULL},
{"no-sigusr-handler", '\0', 0, G_OPTION_ARG_NONE, &no_sigusr_handler,
/* make a null-terminated version of argv */
argvn = g_new0 (char *, argc);
memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1));
-#if !defined(GST_DISABLE_LOADSAVE) && !defined(GST_REMOVE_DEPRECATED)
- if (strstr (argv[0], "gst-xmllaunch")) {
- /* FIXME 0.11: remove xmllaunch entirely */
- g_warning ("gst-xmllaunch is deprecated and broken for all but the most "
- "simple pipelines. It will most likely be removed in future. Don't "
- "use it.\n");
- pipeline = xmllaunch_parse_cmdline ((const gchar **) argvn);
- } else
-#endif
{
pipeline =
(GstElement *) gst_parse_launchv ((const gchar **) argvn, &error);
g_signal_connect (pipeline, "deep-notify",
G_CALLBACK (gst_object_default_deep_notify), exclude_list);
}
-#if !defined(GST_DISABLE_LOADSAVE) && !defined(GST_REMOVE_DEPRECATED)
- if (savefile) {
- g_warning ("Pipeline serialization to XML is deprecated and broken for "
- "all but the most simple pipelines. It will most likely be removed "
- "in future. Don't use it.\n");
-
- gst_xml_write_file (GST_ELEMENT (pipeline), fopen (savefile, "w"));
- }
-#endif
if (!savefile) {
GstState state, pending;