* are the only one referencing this buffer. If this is the last (and
* only) GAP buffer, it will automatically copy the GAP flag. */
outbuf = gst_buffer_make_writable (inbuf);
- outdata = GST_BUFFER_DATA (outbuf);
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (adder->srcpad));
+
+ outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
} else {
if (!is_gap) {
/* we had a previous output buffer, mix this non-GAP buffer */
guint8 *indata;
- guint insize;
+ gsize insize;
- indata = GST_BUFFER_DATA (inbuf);
- insize = GST_BUFFER_SIZE (inbuf);
+ indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
/* all buffers should have outsize, there are no short buffers because we
* asked for the max size above */
/* further buffers, need to add them */
adder->func ((gpointer) outdata, (gpointer) indata,
insize / adder->sample_size);
+ gst_buffer_unmap (inbuf, indata, insize);
} else {
/* skip gap buffer */
GST_LOG_OBJECT (adder, "channel %p: skipping GAP buffer", collect_data);
gst_buffer_unref (inbuf);
}
}
+ if (outbuf)
+ gst_buffer_unmap (outbuf, outdata, outsize);
if (outbuf == NULL) {
/* no output buffer, reuse one of the GAP buffers then if we have one */
/* gstreamer functions */
static gboolean gst_audio_convert_get_unit_size (GstBaseTransform * base,
- GstCaps * caps, guint * size);
+ GstCaps * caps, gsize * size);
static GstCaps *gst_audio_convert_transform_caps (GstBaseTransform * base,
GstPadDirection direction, GstCaps * caps);
static void gst_audio_convert_fixate_caps (GstBaseTransform * base,
/* BaseTransform vmethods */
static gboolean
gst_audio_convert_get_unit_size (GstBaseTransform * base, GstCaps * caps,
- guint * size)
+ gsize * size)
{
AudioConvertFmt fmt = { 0 };
gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
GstBuffer * outbuf)
{
+ GstFlowReturn ret;
GstAudioConvert *this = GST_AUDIO_CONVERT (base);
+ gsize srcsize, dstsize;
gint insize, outsize;
gint samples;
gpointer src, dst;
GST_BUFFER_CAPS (outbuf));
/* get amount of samples to convert. */
- samples = GST_BUFFER_SIZE (inbuf) / this->ctx.in.unit_size;
+ samples = gst_buffer_get_size (inbuf) / this->ctx.in.unit_size;
/* get in/output sizes, to see if the buffers we got are of correct
* sizes */
if (insize == 0 || outsize == 0)
return GST_FLOW_OK;
+ /* get src and dst data */
+ src = gst_buffer_map (inbuf, &srcsize, NULL, GST_MAP_READ);
+ dst = gst_buffer_map (outbuf, &dstsize, NULL, GST_MAP_WRITE);
+
/* check in and outsize */
- if (GST_BUFFER_SIZE (inbuf) < insize)
+ if (srcsize < insize)
goto wrong_size;
- if (GST_BUFFER_SIZE (outbuf) < outsize)
+ if (dstsize < outsize)
goto wrong_size;
- /* get src and dst data */
- src = GST_BUFFER_DATA (inbuf);
- dst = GST_BUFFER_DATA (outbuf);
-
/* and convert the samples */
if (!GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP)) {
if (!audio_convert_convert (&this->ctx, src, dst,
/* Create silence buffer */
gst_audio_convert_create_silence_buffer (this, dst, outsize);
}
+ ret = GST_FLOW_OK;
- GST_BUFFER_SIZE (outbuf) = outsize;
+done:
+ gst_buffer_unmap (outbuf, dst, outsize);
+ gst_buffer_unmap (inbuf, src, srcsize);
- return GST_FLOW_OK;
+ return ret;
/* ERRORS */
error:
GST_ELEMENT_ERROR (this, STREAM, FORMAT,
(NULL),
("input/output buffers are of wrong size in: %d < %d or out: %d < %d",
- GST_BUFFER_SIZE (inbuf), insize, GST_BUFFER_SIZE (outbuf),
- outsize));
- return GST_FLOW_ERROR;
+ srcsize, insize, dstsize, outsize));
+ ret = GST_FLOW_ERROR;
+ goto done;
}
convert_error:
{
GST_ELEMENT_ERROR (this, STREAM, FORMAT,
(NULL), ("error while converting"));
- return GST_FLOW_ERROR;
+ ret = GST_FLOW_ERROR;
+ goto done;
}
}
in_time = audiorate->next_ts;
}
- in_size = GST_BUFFER_SIZE (buf);
+ in_size = gst_buffer_get_size (buf);
in_samples = in_size / audiorate->bytes_per_sample;
/* calculate the buffer offset */
while (fillsamples > 0) {
guint64 cursamples = MIN (fillsamples, audiorate->rate);
+ guint8 *data;
fillsamples -= cursamples;
fillsize = cursamples * audiorate->bytes_per_sample;
fill = gst_buffer_new_and_alloc (fillsize);
+
+ data = gst_buffer_map (fill, NULL, NULL, GST_MAP_WRITE);
/* FIXME, 0 might not be the silence byte for the negotiated format. */
- memset (GST_BUFFER_DATA (fill), 0, fillsize);
+ memset (data, 0, fillsize);
+ gst_buffer_unmap (fill, data, fillsize);
GST_DEBUG_OBJECT (audiorate, "inserting %" G_GUINT64_FORMAT " samples",
cursamples);
}
send:
- if (GST_BUFFER_SIZE (buf) == 0)
+ if (gst_buffer_get_size (buf) == 0)
goto beach;
/* Now calculate parameters for whichever buffer (either the original
if (audiorate->discont) {
/* we need to output a discont buffer, do so now */
GST_DEBUG_OBJECT (audiorate, "marking DISCONT on output buffer");
- buf = gst_buffer_make_metadata_writable (buf);
+ buf = gst_buffer_make_writable (buf);
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
audiorate->discont = FALSE;
} else if (GST_BUFFER_IS_DISCONT (buf)) {
/* else we make everything continuous so we can safely remove the DISCONT
* flag from the buffer if there was one */
GST_DEBUG_OBJECT (audiorate, "removing DISCONT from buffer");
- buf = gst_buffer_make_metadata_writable (buf);
+ buf = gst_buffer_make_writable (buf);
GST_BUFFER_FLAG_UNSET (buf, GST_BUFFER_FLAG_DISCONT);
}
/* vmethods */
static gboolean gst_audio_resample_get_unit_size (GstBaseTransform * base,
- GstCaps * caps, guint * size);
+ GstCaps * caps, gsize * size);
static GstCaps *gst_audio_resample_transform_caps (GstBaseTransform * base,
GstPadDirection direction, GstCaps * caps);
static void gst_audio_resample_fixate_caps (GstBaseTransform * base,
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
static gboolean gst_audio_resample_transform_size (GstBaseTransform * trans,
- GstPadDirection direction, GstCaps * incaps, guint insize,
- GstCaps * outcaps, guint * outsize);
+ GstPadDirection direction, GstCaps * incaps, gsize insize,
+ GstCaps * outcaps, gsize * outsize);
static gboolean gst_audio_resample_set_caps (GstBaseTransform * base,
GstCaps * incaps, GstCaps * outcaps);
static GstFlowReturn gst_audio_resample_transform (GstBaseTransform * base,
static gboolean
gst_audio_resample_get_unit_size (GstBaseTransform * base, GstCaps * caps,
- guint * size)
+ gsize * size)
{
gint width, channels;
GstStructure *structure;
static gboolean
gst_audio_resample_transform_size (GstBaseTransform * base,
- GstPadDirection direction, GstCaps * caps, guint size, GstCaps * othercaps,
- guint * othersize)
+ GstPadDirection direction, GstCaps * caps, gsize size, GstCaps * othercaps,
+ gsize * othersize)
{
gboolean ret = TRUE;
guint32 ratio_den, ratio_num;
guint out_len, out_processed;
gint err;
guint num, den;
+ guint8 *data;
g_assert (resample->state != NULL);
return;
}
+ data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
+
if (resample->funcs->width != resample->width) {
/* need to convert data format; allocate workspace */
if (!gst_audio_resample_workspace_realloc (&resample->tmp_out,
/* convert output format */
gst_audio_resample_convert_buffer (resample, resample->tmp_out,
- GST_BUFFER_DATA (outbuf), out_processed, TRUE);
+ data, out_processed, TRUE);
} else {
/* don't need to convert data format; process */
err = resample->funcs->process (resample->state, NULL, &in_processed,
- GST_BUFFER_DATA (outbuf), &out_processed);
+ data, &out_processed);
}
/* If we wrote more than allocated something is really wrong now
* and we should better abort immediately */
g_assert (out_len >= out_processed);
+ outsize = out_processed * resample->channels * (resample->width / 8);
+ gst_buffer_unmap (outbuf, data, outsize);
+
if (G_UNLIKELY (err != RESAMPLER_ERR_SUCCESS)) {
GST_WARNING_OBJECT (resample, "Failed to process drain: %s",
resample->funcs->strerror (err));
return;
}
- GST_BUFFER_SIZE (outbuf) =
- out_processed * resample->channels * (resample->width / 8);
-
GST_LOG_OBJECT (resample,
"Pushing drain buffer of %u bytes with timestamp %" GST_TIME_FORMAT
" duration %" GST_TIME_FORMAT " offset %" G_GUINT64_FORMAT " offset_end %"
- G_GUINT64_FORMAT, GST_BUFFER_SIZE (outbuf),
+ G_GUINT64_FORMAT, outsize,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)), GST_BUFFER_OFFSET (outbuf),
GST_BUFFER_OFFSET_END (outbuf));
gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
GstBuffer * outbuf)
{
+ gsize in_size, out_size;
+ guint8 *in_data, *out_data;
guint32 in_len, in_processed;
guint32 out_len, out_processed;
guint filt_len = resample->funcs->get_filt_len (resample->state);
- in_len = GST_BUFFER_SIZE (inbuf) / resample->channels;
- out_len = GST_BUFFER_SIZE (outbuf) / resample->channels;
+ in_data = gst_buffer_map (inbuf, &in_size, NULL, GST_MAP_READ);
+ out_data = gst_buffer_map (outbuf, &out_size, NULL, GST_MAP_WRITE);
+
+ in_len = in_size / resample->channels;
+ out_len = out_size / resample->channels;
in_len /= (resample->width / 8);
out_len /= (resample->width / 8);
else
out_processed = 0;
- memset (GST_BUFFER_DATA (outbuf), 0, GST_BUFFER_SIZE (outbuf));
+ memset (out_data, 0, out_size);
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
resample->num_gap_samples += in_len;
in_processed = in_len;
&resample->tmp_out_size, out_len * resample->channels *
(resample->funcs->width / 8))) {
GST_ERROR_OBJECT (resample, "failed to allocate workspace");
+ gst_buffer_unmap (inbuf, in_data, in_size);
+ gst_buffer_unmap (outbuf, out_data, out_size);
return GST_FLOW_ERROR;
}
/* convert input */
- gst_audio_resample_convert_buffer (resample, GST_BUFFER_DATA (inbuf),
+ gst_audio_resample_convert_buffer (resample, in_data,
resample->tmp_in, in_len, FALSE);
/* process */
/* convert output */
gst_audio_resample_convert_buffer (resample, resample->tmp_out,
- GST_BUFFER_DATA (outbuf), out_processed, TRUE);
+ out_data, out_processed, TRUE);
} else {
/* no format conversion required; process */
err = resample->funcs->process (resample->state,
- GST_BUFFER_DATA (inbuf), &in_processed,
- GST_BUFFER_DATA (outbuf), &out_processed);
+ in_data, &in_processed, out_data, &out_processed);
}
if (G_UNLIKELY (err != RESAMPLER_ERR_SUCCESS)) {
GST_ERROR_OBJECT (resample, "Failed to convert data: %s",
resample->funcs->strerror (err));
+ gst_buffer_unmap (inbuf, in_data, in_size);
+ gst_buffer_unmap (outbuf, out_data, out_size);
return GST_FLOW_ERROR;
}
}
resample->samples_out += out_processed;
resample->samples_in += in_len;
- GST_BUFFER_SIZE (outbuf) =
- out_processed * resample->channels * (resample->width / 8);
+ out_size = out_processed * resample->channels * (resample->width / 8);
+ gst_buffer_unmap (inbuf, in_data, in_size);
+ gst_buffer_unmap (outbuf, out_data, out_size);
GST_LOG_OBJECT (resample,
"Converted to buffer of %" G_GUINT32_FORMAT
" samples (%u bytes) with timestamp %" GST_TIME_FORMAT ", duration %"
GST_TIME_FORMAT ", offset %" G_GUINT64_FORMAT ", offset_end %"
- G_GUINT64_FORMAT, out_processed, GST_BUFFER_SIZE (outbuf),
+ G_GUINT64_FORMAT, out_processed, out_size,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)),
GST_BUFFER_OFFSET (outbuf), GST_BUFFER_OFFSET_END (outbuf));
GstBuffer * outbuf)
{
GstAudioResample *resample = GST_AUDIO_RESAMPLE (base);
- gulong size;
GstFlowReturn ret;
if (resample->state == NULL) {
gst_audio_resample_get_funcs (resample->width, resample->fp);
}
- size = GST_BUFFER_SIZE (inbuf);
-
GST_LOG_OBJECT (resample, "transforming buffer of %ld bytes, ts %"
GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT ", offset %"
G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT,
- size, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (inbuf)),
+ gst_buffer_get_size (inbuf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (inbuf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (inbuf)),
GST_BUFFER_OFFSET (inbuf), GST_BUFFER_OFFSET_END (inbuf));
gint64 next_sample, next_byte;
gint bytes, samples;
GstElementClass *eclass;
+ guint8 *data;
src = GST_AUDIO_TEST_SRC (basesrc);
src->generate_samples_per_buffer,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
- src->process (src, GST_BUFFER_DATA (buf));
+ data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+ src->process (src, data);
+ gst_buffer_unmap (buf, data, bytes);
if (G_UNLIKELY ((src->wave == GST_AUDIO_TEST_SRC_WAVE_SILENCE)
|| (src->volume == 0.0))) {
/*
* Read a palette from a caps.
*/
-
static void
gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
{
/* do we have a palette? */
if ((palette_v = gst_structure_get_value (str, "palette_data")) && context) {
- const GstBuffer *palette;
+ GstBuffer *palette;
palette = gst_value_get_buffer (palette_v);
- if (palette && GST_BUFFER_SIZE (palette) >= 256 * 4) {
+ if (palette && gst_buffer_get_size (palette) >= 256 * 4) {
if (context->palctrl)
av_free (context->palctrl);
context->palctrl = av_malloc (sizeof (AVPaletteControl));
context->palctrl->palette_changed = 1;
- memcpy (context->palctrl->palette, GST_BUFFER_DATA (palette),
+ gst_buffer_extract (palette, 0, context->palctrl->palette,
AVPALETTE_SIZE);
}
}
{
if (context->palctrl) {
GstBuffer *palette = gst_buffer_new_and_alloc (256 * 4);
+ guint8 *data;
+ gsize size;
+
+ data = gst_buffer_map (palette, &size, NULL, GST_MAP_WRITE);
+ memcpy (data, context->palctrl->palette, AVPALETTE_SIZE);
+ gst_buffer_unmap (palette, data, size);
- memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
- AVPALETTE_SIZE);
gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, palette, NULL);
gst_buffer_unref (palette);
}
static gboolean gst_ffmpegcsp_set_caps (GstBaseTransform * btrans,
GstCaps * incaps, GstCaps * outcaps);
static gboolean gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans,
- GstCaps * caps, guint * size);
+ GstCaps * caps, gsize * size);
static GstFlowReturn gst_ffmpegcsp_transform (GstBaseTransform * btrans,
GstBuffer * inbuf, GstBuffer * outbuf);
static gboolean
gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
- guint * size)
+ gsize * size)
{
GstStructure *structure = NULL;
AVCodecContext *ctx = NULL;
{
GstFFMpegCsp *space;
gint result;
+ guint8 *indata, *outdata;
+ gsize insize, outsize;
space = GST_FFMPEGCSP (btrans);
goto unknown_format;
/* fill from with source data */
+ indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
gst_ffmpegcsp_avpicture_fill (&space->from_frame,
- GST_BUFFER_DATA (inbuf), space->from_pixfmt, space->width, space->height,
+ indata, space->from_pixfmt, space->width, space->height,
space->interlaced);
/* fill optional palette */
space->from_frame.data[1] = (uint8_t *) space->palette->palette;
/* fill target frame */
+ outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
gst_ffmpegcsp_avpicture_fill (&space->to_frame,
- GST_BUFFER_DATA (outbuf), space->to_pixfmt, space->width, space->height,
+ outdata, space->to_pixfmt, space->width, space->height,
space->interlaced);
/* and convert */
result = img_convert (&space->to_frame, space->to_pixfmt,
&space->from_frame, space->from_pixfmt, space->width, space->height);
+ gst_buffer_unmap (outbuf, outdata, outsize);
+ gst_buffer_unmap (inbuf, indata, insize);
+
if (result == -1)
goto not_supported;
goto wrong_type;
}
- if (this->payload_length
- && (!gst_dp_validate_payload (GST_DP_HEADER_LENGTH, this->header,
- gst_adapter_peek (this->adapter, this->payload_length)))) {
- goto payload_validate_error;
+ if (this->payload_length) {
+ const guint8 *data;
+ gboolean res;
+
+ data = gst_adapter_map (this->adapter, this->payload_length);
+ res = gst_dp_validate_payload (GST_DP_HEADER_LENGTH, this->header,
+ data);
+ gst_adapter_unmap (this->adapter, 0);
+
+ if (!res)
+ goto payload_validate_error;
}
break;
}
case GST_GDP_DEPAY_STATE_BUFFER:
{
-
/* if we receive a buffer without caps first, we error out */
if (!this->caps)
goto no_caps;
if (this->payload_length > 0) {
guint8 *payload;
- payload = gst_adapter_take (this->adapter, this->payload_length);
- memcpy (GST_BUFFER_DATA (buf), payload, this->payload_length);
- g_free (payload);
+ payload = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+ gst_adapter_copy (this->adapter, payload, 0, this->payload_length);
+ gst_buffer_unmap (buf, payload, this->payload_length);
+
+ gst_adapter_flush (this->adapter, this->payload_length);
}
/* set caps and push */
GST_LOG_OBJECT (this, "deserialized buffer %p, pushing, timestamp %"
GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT
", offset %" G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT
- ", size %d, flags 0x%x",
+ ", size %" G_GSIZE_FORMAT ", flags 0x%x",
buf,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)),
GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),
- GST_BUFFER_SIZE (buf), GST_BUFFER_FLAGS (buf));
+ gst_buffer_get_size (buf), GST_BUFFER_FLAGS (buf));
ret = gst_pad_push (this->srcpad, buf);
if (ret != GST_FLOW_OK)
goto push_error;
static void gst_gdp_pay_reset (GstGDPPay * this);
static GstFlowReturn gst_gdp_pay_chain (GstPad * pad, GstBuffer * buffer);
-
static gboolean gst_gdp_pay_src_event (GstPad * pad, GstEvent * event);
-
static gboolean gst_gdp_pay_sink_event (GstPad * pad, GstEvent * event);
static GstStateChangeReturn gst_gdp_pay_change_state (GstElement *
gst_gdp_pay_class_init (GstGDPPayClass * klass)
{
GObjectClass *gobject_class;
-
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
gst_gdp_stamp_buffer (GstGDPPay * this, GstBuffer * buffer)
{
GST_BUFFER_OFFSET (buffer) = this->offset;
- GST_BUFFER_OFFSET_END (buffer) = this->offset + GST_BUFFER_SIZE (buffer);
+ GST_BUFFER_OFFSET_END (buffer) = this->offset + gst_buffer_get_size (buffer);
this->offset = GST_BUFFER_OFFSET_END (buffer);
}
gst_gdp_buffer_from_caps (GstGDPPay * this, GstCaps * caps)
{
GstBuffer *headerbuf;
-
GstBuffer *payloadbuf;
-
guint8 *header, *payload;
-
- guint len;
+ guint len, plen;
if (!this->packetizer->packet_from_caps (caps, this->header_flag, &len,
&header, &payload))
GST_LOG_OBJECT (this, "creating GDP header and payload buffer from caps");
headerbuf = gst_buffer_new ();
- gst_buffer_set_data (headerbuf, header, len);
- GST_BUFFER_MALLOCDATA (headerbuf) = header;
+ gst_buffer_take_memory (headerbuf,
+ gst_memory_new_wrapped (0, header, g_free, len, 0, len));
payloadbuf = gst_buffer_new ();
- gst_buffer_set_data (payloadbuf, payload,
- gst_dp_header_payload_length (header));
- GST_BUFFER_MALLOCDATA (payloadbuf) = payload;
+ plen = gst_dp_header_payload_length (header);
+ gst_buffer_take_memory (payloadbuf,
+ gst_memory_new_wrapped (0, payload, g_free, plen, 0, plen));
return gst_buffer_join (headerbuf, payloadbuf);
gst_gdp_pay_buffer_from_buffer (GstGDPPay * this, GstBuffer * buffer)
{
GstBuffer *headerbuf;
-
guint8 *header;
-
guint len;
if (!this->packetizer->header_from_buffer (buffer, this->header_flag, &len,
GST_LOG_OBJECT (this, "creating GDP header and payload buffer from buffer");
headerbuf = gst_buffer_new ();
- gst_buffer_set_data (headerbuf, header, len);
- GST_BUFFER_MALLOCDATA (headerbuf) = header;
+ gst_buffer_take_memory (headerbuf,
+ gst_memory_new_wrapped (0, header, g_free, len, 0, len));
/* we do not want to lose the ref on the incoming buffer */
gst_buffer_ref (buffer);
gst_gdp_buffer_from_event (GstGDPPay * this, GstEvent * event)
{
GstBuffer *headerbuf;
-
GstBuffer *payloadbuf;
-
guint8 *header, *payload;
-
- guint len;
-
+ guint len, plen;
gboolean ret;
ret =
GST_LOG_OBJECT (this, "creating GDP header and payload buffer from event");
headerbuf = gst_buffer_new ();
- gst_buffer_set_data (headerbuf, header, len);
- GST_BUFFER_MALLOCDATA (headerbuf) = header;
+ gst_buffer_take_memory (headerbuf,
+ gst_memory_new_wrapped (0, header, g_free, len, 0, len));
payloadbuf = gst_buffer_new ();
- gst_buffer_set_data (payloadbuf, payload,
- gst_dp_header_payload_length (header));
- GST_BUFFER_MALLOCDATA (payloadbuf) = payload;
+ plen = gst_dp_header_payload_length (header);
+ gst_buffer_take_memory (payloadbuf,
+ gst_memory_new_wrapped (0, payload, g_free, plen, 0, plen));
return gst_buffer_join (headerbuf, payloadbuf);
gst_gdp_pay_reset_streamheader (GstGDPPay * this)
{
GstCaps *caps;
-
/* We use copies of these to avoid circular refcounts */
GstBuffer *new_segment_buf, *caps_buf, *tag_buf;
-
GstStructure *structure;
-
GstFlowReturn r = GST_FLOW_OK;
-
gboolean version_one_zero = TRUE;
GValue array = { 0 };
GST_DEBUG_OBJECT (this, "Setting caps on src pad %" GST_PTR_FORMAT, caps);
gst_pad_set_caps (this->srcpad, caps);
- this->caps_buf = gst_buffer_make_metadata_writable (this->caps_buf);
+ this->caps_buf = gst_buffer_make_writable (this->caps_buf);
gst_buffer_set_caps (this->caps_buf, caps);
- this->new_segment_buf =
- gst_buffer_make_metadata_writable (this->new_segment_buf);
+ this->new_segment_buf = gst_buffer_make_writable (this->new_segment_buf);
gst_buffer_set_caps (this->new_segment_buf, caps);
/* if these are our first ever buffers, send out new_segment first */
gst_gdp_pay_chain (GstPad * pad, GstBuffer * buffer)
{
GstGDPPay *this;
-
GstCaps *caps;
-
GstBuffer *outbuffer;
-
GstFlowReturn ret;
this = GST_GDP_PAY (gst_pad_get_parent (pad));
gst_gdp_pay_sink_event (GstPad * pad, GstEvent * event)
{
GstBuffer *outbuffer;
-
GstGDPPay *this = GST_GDP_PAY (gst_pad_get_parent (pad));
-
GstFlowReturn flowret;
-
gboolean ret = TRUE;
GST_DEBUG_OBJECT (this, "received event %p of type %s (%d)",
gst_gdp_pay_src_event (GstPad * pad, GstEvent * event)
{
GstGDPPay *this;
-
gboolean res = TRUE;
this = GST_GDP_PAY (gst_pad_get_parent (pad));
gst_gdp_pay_change_state (GstElement * element, GstStateChange transition)
{
GstStateChangeReturn ret;
-
GstGDPPay *this = GST_GDP_PAY (element);
switch (transition) {
GST_LOG_OBJECT (pad, "Handling buffer %p: size=%u, timestamp=%"
GST_TIME_FORMAT " duration=%" GST_TIME_FORMAT
" offset=%" G_GUINT64_FORMAT " offset_end=%" G_GUINT64_FORMAT,
- buffer, GST_BUFFER_SIZE (buffer),
+ buffer, gst_buffer_get_size (buffer),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)),
GST_BUFFER_OFFSET (buffer), GST_BUFFER_OFFSET_END (buffer));
stream->seen_data = TRUE;
if (stream && stream->drop_discont) {
- buffer = gst_buffer_make_metadata_writable (buffer);
+ buffer = gst_buffer_make_writable (buffer);
GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_DISCONT);
stream->drop_discont = FALSE;
}
GstStructure *s;
const guchar bom_utf8[] = { 0xEF, 0xBB, 0xBF };
GstBuffer *priv;
- gchar *data;
- guint size;
+ gchar *data, *ptr;
+ gsize size, left;
s = gst_caps_get_structure (caps, 0);
val = gst_structure_get_value (s, "codec_data");
gst_buffer_ref (priv);
- data = (gchar *) GST_BUFFER_DATA (priv);
- size = GST_BUFFER_SIZE (priv);
+ data = gst_buffer_map (priv, &size, NULL, GST_MAP_READ);
+
+ ptr = data;
+ left = size;
+
/* skip UTF-8 BOM */
- if (size >= 3 && memcmp (data, bom_utf8, 3) == 0) {
- data += 3;
- size -= 3;
+ if (left >= 3 && memcmp (ptr, bom_utf8, 3) == 0) {
+ ptr += 3;
+ left -= 3;
}
if (!strstr (data, "[Script Info]")) {
return FALSE;
}
- if (!g_utf8_validate (data, size, NULL)) {
+ if (!g_utf8_validate (ptr, left, NULL)) {
GST_WARNING_OBJECT (parse, "Init section is not valid UTF-8");
gst_buffer_unref (priv);
return FALSE;
}
/* FIXME: parse initial section */
- parse->ini = g_strndup (data, size);
+ parse->ini = g_strndup (ptr, left);
GST_LOG_OBJECT (parse, "Init section:\n%s", parse->ini);
+ gst_buffer_unmap (priv, data, size);
gst_buffer_unref (priv);
return TRUE;
/* allocate enough for a terminating NUL, but don't include it in buf size */
buf = gst_buffer_new_and_alloc (len + 1);
- memcpy (GST_BUFFER_DATA (buf), escaped, len + 1);
- GST_BUFFER_SIZE (buf) = len;
+ gst_buffer_fill (buf, 0, escaped, len + 1);
+ gst_buffer_set_size (buf, len);
g_free (escaped);
GST_BUFFER_TIMESTAMP (buf) = start;
GstSsaParse *parse = GST_SSA_PARSE (GST_PAD_PARENT (sinkpad));
GstClockTime ts;
gchar *txt;
+ gchar *data;
+ gsize size;
if (G_UNLIKELY (!parse->framed))
goto not_framed;
}
/* make double-sure it's 0-terminated and all */
- txt = g_strndup ((gchar *) GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+ data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ txt = g_strndup (data, size);
+ gst_buffer_unmap (buf, data, size);
+
if (txt == NULL)
goto empty_text;
gboolean discont;
gsize consumed;
gchar *input = NULL;
+ const guint8 *data;
+ gsize avail;
discont = GST_BUFFER_IS_DISCONT (buf);
* subtitles which are discontinuous by nature. */
}
- self->offset = GST_BUFFER_OFFSET (buf) + GST_BUFFER_SIZE (buf);
+ self->offset = GST_BUFFER_OFFSET (buf) + gst_buffer_get_size (buf);
self->next_offset = self->offset;
gst_adapter_push (self->adapter, buf);
- input =
- convert_encoding (self, (const gchar *) gst_adapter_peek (self->adapter,
- gst_adapter_available (self->adapter)),
- (gsize) gst_adapter_available (self->adapter), &consumed);
+ avail = gst_adapter_available (self->adapter);
+ data = gst_adapter_map (self->adapter, avail),
+ input = convert_encoding (self, (const gchar *) data, avail, &consumed);
if (input && consumed > 0) {
self->textbuf = g_string_append (self->textbuf, input);
- gst_adapter_flush (self->adapter, consumed);
+ gst_adapter_unmap (self->adapter, consumed);
+ } else {
+ gst_adapter_unmap (self->adapter, 0);
}
g_free (input);
{
GstFlowReturn ret = GST_FLOW_OK;
GstCaps *caps = NULL;
- gchar *line, *subtitle;
+ gchar *line, *subtitle, *data;
+ gsize size;
if (self->first_buffer) {
- self->detected_encoding =
- detect_encoding ((gchar *) GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ self->detected_encoding = detect_encoding (data, size);
+ gst_buffer_unmap (buf, data, size);
self->first_buffer = FALSE;
self->state.fps_n = self->fps_n;
self->state.fps_d = self->fps_d;
if (ret == GST_FLOW_OK) {
/* copy terminating NUL character as well */
- memcpy (GST_BUFFER_DATA (buf), subtitle, subtitle_len + 1);
- GST_BUFFER_SIZE (buf) = subtitle_len;
+ gst_buffer_fill (buf, 0, subtitle, subtitle_len + 1);
+ gst_buffer_set_size (buf, subtitle_len);
+
GST_BUFFER_TIMESTAMP (buf) = self->state.start_time;
GST_BUFFER_DURATION (buf) = self->state.duration;
self->parser_type == GST_SUB_PARSE_FORMAT_TMPLAYER ||
self->parser_type == GST_SUB_PARSE_FORMAT_MPL2 ||
self->parser_type == GST_SUB_PARSE_FORMAT_QTTEXT) {
+ gchar term_chars[] = { '\n', '\n', '\0' };
GstBuffer *buf = gst_buffer_new_and_alloc (2 + 1);
GST_DEBUG ("EOS. Pushing remaining text (if any)");
- GST_BUFFER_DATA (buf)[0] = '\n';
- GST_BUFFER_DATA (buf)[1] = '\n';
- GST_BUFFER_DATA (buf)[2] = '\0'; /* play it safe */
- GST_BUFFER_SIZE (buf) = 2;
+ gst_buffer_fill (buf, 0, term_chars, 3);
+ gst_buffer_set_size (buf, 2);
+
GST_BUFFER_OFFSET (buf) = self->offset;
gst_sub_parse_chain (pad, buf);
}
buffer = g_value_peek_pointer (bufval);
GST_DEBUG_OBJECT (sink,
"[fd %5d] queueing streamheader buffer of length %d",
- client->fd.fd, GST_BUFFER_SIZE (buffer));
+ client->fd.fd, gst_buffer_get_size (buffer));
gst_buffer_ref (buffer);
client->sending = g_slist_append (client->sending, buffer);
caps = NULL;
GST_LOG_OBJECT (sink, "[fd %5d] queueing buffer of length %d",
- client->fd.fd, GST_BUFFER_SIZE (buffer));
+ client->fd.fd, gst_buffer_get_size (buffer));
gst_buffer_ref (buffer);
client->sending = g_slist_append (client->sending, buffer);
for (i = 0; i < len; i++) {
buf = g_array_index (sink->bufqueue, GstBuffer *, i);
- acc += GST_BUFFER_SIZE (buf);
+ acc += gst_buffer_get_size (buf);
if (acc > max)
return i + 1;
}
buf = g_array_index (sink->bufqueue, GstBuffer *, i);
- bytes += GST_BUFFER_SIZE (buf);
+ bytes += gst_buffer_get_size (buf);
/* take timestamp and save for the base first timestamp */
if ((time = GST_BUFFER_TIMESTAMP (buf)) != -1) {
if (client->sending) {
ssize_t wrote;
GstBuffer *head;
+ guint8 *data;
+ gsize size;
/* pick first buffer from list */
head = GST_BUFFER (client->sending->data);
- maxsize = GST_BUFFER_SIZE (head) - client->bufoffset;
+
+ data = gst_buffer_map (head, &size, NULL, GST_MAP_READ);
+ maxsize = size - client->bufoffset;
/* try to write the complete buffer */
#ifdef MSG_NOSIGNAL
#define FLAGS 0
#endif
if (client->is_socket) {
- wrote =
- send (fd, GST_BUFFER_DATA (head) + client->bufoffset, maxsize,
- FLAGS);
+ wrote = send (fd, data + client->bufoffset, maxsize, FLAGS);
} else {
- wrote = write (fd, GST_BUFFER_DATA (head) + client->bufoffset, maxsize);
+ wrote = write (fd, data + client->bufoffset, maxsize);
}
+ gst_buffer_unmap (head, data, size);
if (wrote < 0) {
/* hmm error.. */
/* stamp the buffer with previous caps if no caps set */
if (!bufcaps) {
- if (!gst_buffer_is_metadata_writable (buf)) {
+ if (!gst_buffer_is_writable (buf)) {
/* metadata is not writable, copy will be made and original buffer
* will be unreffed so we need to ref so that we don't lose the
* buffer in the render method. */
gst_buffer_ref (buf);
/* the new buffer is ours only, we keep it out of the scope of this
* function */
- buf = gst_buffer_make_metadata_writable (buf);
+ buf = gst_buffer_make_writable (buf);
} else {
/* else the metadata is writable, we ref because we keep the buffer
* out of the scope of this method */
if (in_caps) {
GST_DEBUG_OBJECT (sink,
"appending IN_CAPS buffer with length %d to streamheader",
- GST_BUFFER_SIZE (buf));
+ gst_buffer_get_size (buf));
sink->streamheader = g_slist_append (sink->streamheader, buf);
} else {
/* queue the buffer, this is a regular data buffer. */
gst_multi_fd_sink_queue_buffer (sink, buf);
- sink->bytes_to_serve += GST_BUFFER_SIZE (buf);
+ sink->bytes_to_serve += gst_buffer_get_size (buf);
}
return GST_FLOW_OK;
int ret;
ssize_t bytes_read;
int readsize;
+ guint8 *data;
*buf = NULL;
*buf = gst_buffer_new_and_alloc (readsize);
- bytes_read = read (socket, GST_BUFFER_DATA (*buf), readsize);
+ data = gst_buffer_map (*buf, NULL, NULL, GST_MAP_WRITE);
+ bytes_read = read (socket, data, readsize);
+ gst_buffer_unmap (*buf, data, bytes_read);
if (bytes_read < 0)
goto read_error;
/* but mom, you promised to give me readsize bytes! */
goto short_read;
- GST_LOG_OBJECT (this, "returning buffer of size %d", GST_BUFFER_SIZE (*buf));
+ GST_LOG_OBJECT (this, "returning buffer of size %d", bytes_read);
return GST_FLOW_OK;
/* ERRORS */
{
GstFlowReturn ret;
guint8 *header = NULL;
+ guint8 *data;
+ gsize size;
GST_LOG_OBJECT (this, "Reading %d bytes for buffer packet header",
GST_DP_HEADER_LENGTH);
g_free (header);
- ret = gst_tcp_socket_read (this, socket, GST_BUFFER_DATA (*buf),
- GST_BUFFER_SIZE (*buf), fdset);
+ data = gst_buffer_map (*buf, &size, NULL, GST_MAP_WRITE);
+ ret = gst_tcp_socket_read (this, socket, data, size, fdset);
+ gst_buffer_unmap (*buf, data, size);
if (ret != GST_FLOW_OK)
goto data_read_error;
{
size_t wrote = 0;
GstTCPClientSink *sink;
- gint size;
+ guint8 *data;
+ gsize size;
sink = GST_TCP_CLIENT_SINK (bsink);
g_return_val_if_fail (GST_OBJECT_FLAG_IS_SET (sink, GST_TCP_CLIENT_SINK_OPEN),
GST_FLOW_WRONG_STATE);
- size = GST_BUFFER_SIZE (buf);
-
- GST_LOG_OBJECT (sink, "writing %d bytes for buffer data", size);
+ data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ GST_LOG_OBJECT (sink, "writing %" G_GSIZE_FORMAT " bytes for buffer data",
+ size);
/* write buffer data */
- wrote = gst_tcp_socket_write (sink->sock_fd.fd, GST_BUFFER_DATA (buf), size);
+ wrote = gst_tcp_socket_write (sink->sock_fd.fd, data, size);
+ gst_buffer_unmap (buf, data, size);
if (wrote < size)
goto write_error;
{
GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
(_("Error while sending data to \"%s:%d\"."), sink->host, sink->port),
- ("Only %" G_GSIZE_FORMAT " of %u bytes written: %s",
- wrote, GST_BUFFER_SIZE (buf), g_strerror (errno)));
+ ("Only %" G_GSIZE_FORMAT " of %" G_GSIZE_FORMAT " bytes written: %s",
+ wrote, size, g_strerror (errno)));
return GST_FLOW_ERROR;
}
}
"Returning buffer from _get of size %d, ts %"
GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT
", offset %" G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT,
- GST_BUFFER_SIZE (*outbuf),
+ gst_buffer_get_size (*outbuf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (*outbuf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (*outbuf)),
GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf));
"Returning buffer from _get of size %d, ts %"
GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT
", offset %" G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT,
- GST_BUFFER_SIZE (*outbuf),
+ gst_buffer_get_size (*outbuf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (*outbuf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (*outbuf)),
GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf));
utf8_type_find_have_valid_utf8_at_offset (GstTypeFind * tf, guint64 offset,
GstTypeFindProbability * prob)
{
- guint8 *data;
+ const guint8 *data;
/* randomly decided values */
guint min_size = 16; /* minimum size */
static void
uri_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, BUFFER_SIZE);
+ const guint8 *data = gst_type_find_peek (tf, 0, BUFFER_SIZE);
guint pos = 0;
guint offset = 0;
gboolean strict)
{
gboolean got_xmldec;
- guint8 *data;
+ const guint8 *data;
guint offset = 0;
guint pos = 0;
static gboolean
sdp_check_header (GstTypeFind * tf)
{
- guint8 *data;
+ const guint8 *data;
data = gst_type_find_peek (tf, 0, 5);
if (!data)
static void
html_type_find (GstTypeFind * tf, gpointer unused)
{
- gchar *d, *data;
+ const gchar *d, *data;
- data = (gchar *) gst_type_find_peek (tf, 0, 16);
+ data = (const gchar *) gst_type_find_peek (tf, 0, 16);
if (!data)
return;
} else if (xml_check_first_element (tf, "html", 4, FALSE)) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, HTML_CAPS);
} else if ((d = memchr (data, '<', 16))) {
- data = (gchar *) gst_type_find_peek (tf, d - data, 6);
+ data = (const gchar *) gst_type_find_peek (tf, d - data, 6);
if (data && g_ascii_strncasecmp (data, "<html>", 6) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, HTML_CAPS);
}
static void
mid_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 4);
+ const guint8 *data = gst_type_find_peek (tf, 0, 4);
/* http://jedi.ks.uiuc.edu/~johns/links/music/midifile.html */
if (data && data[0] == 'M' && data[1] == 'T' && data[2] == 'h'
static void
mxmf_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = NULL;
+ const guint8 *data = NULL;
/* Search FileId "XMF_" 4 bytes */
data = gst_type_find_peek (tf, 0, 4);
static void
flx_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 134);
+ const guint8 *data = gst_type_find_peek (tf, 0, 134);
if (data) {
/* check magic and the frame type of the first frame */
static void
id3v2_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 10);
+ const guint8 *data = gst_type_find_peek (tf, 0, 10);
if (data && memcmp (data, "ID3", 3) == 0 &&
data[3] != 0xFF && data[4] != 0xFF &&
static void
id3v1_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, -128, 3);
+ const guint8 *data = gst_type_find_peek (tf, -128, 3);
if (data && memcmp (data, "TAG", 3) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, ID3_CAPS);
static void
apetag_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data;
+ const guint8 *data;
/* APEv1/2 at start of file */
data = gst_type_find_peek (tf, 0, 8);
static void
tta_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 3);
+ const guint8 *data = gst_type_find_peek (tf, 0, 3);
if (data) {
if (memcmp (data, "TTA", 3) == 0) {
mp3_type_find_at_offset (GstTypeFind * tf, guint64 start_off,
guint * found_layer, GstTypeFindProbability * found_prob)
{
- guint8 *data = NULL;
- guint8 *data_end = NULL;
+ const guint8 *data = NULL;
+ const guint8 *data_end = NULL;
guint size;
guint64 skipped;
gint last_free_offset = -1;
data_end = data + size;
}
if (*data == 0xFF) {
- guint8 *head_data = NULL;
+ const guint8 *head_data = NULL;
guint layer = 0, bitrate, samplerate, channels;
guint found = 0; /* number of valid headers found */
guint64 offset = skipped;
mp3_type_find (GstTypeFind * tf, gpointer unused)
{
GstTypeFindProbability prob, mid_prob;
- guint8 *data;
+ const guint8 *data;
guint layer, mid_layer;
guint64 length;
static void
musepack_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 4);
+ const guint8 *data = gst_type_find_peek (tf, 0, 4);
GstTypeFindProbability prop = GST_TYPE_FIND_MINIMUM;
gint streamversion = -1;
{
guint64 offset;
guint32 blocksize;
- guint8 *data;
+ const guint8 *data;
data = gst_type_find_peek (tf, 0, 32);
if (!data)
static void
postscript_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 3);
+ const guint8 *data = gst_type_find_peek (tf, 0, 3);
if (!data)
return;
static void
multipart_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data;
- guint8 *x;
+ const guint8 *data;
+ const guint8 *x;
#define MULTIPART_MAX_BOUNDARY_OFFSET 16
data = gst_type_find_peek (tf, 0, MULTIPART_MAX_BOUNDARY_OFFSET);
}
static gboolean
-mpeg_sys_is_valid_pes (GstTypeFind * tf, guint8 * data, guint len,
+mpeg_sys_is_valid_pes (GstTypeFind * tf, const guint8 * data, guint len,
guint * pack_size)
{
guint pes_packet_len;
}
static gboolean
-mpeg_sys_is_valid_sys (GstTypeFind * tf, guint8 * data, guint len,
+mpeg_sys_is_valid_sys (GstTypeFind * tf, const guint8 * data, guint len,
guint * pack_size)
{
guint sys_hdr_len;
static void
mpeg_sys_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data, *data0, *first_sync, *end;
+ const guint8 *data, *data0, *first_sync, *end;
gint mpegversion = 0;
guint pack_headers = 0;
guint pes_headers = 0;
{
/* We always enter this function having found at least one header already */
gint found = 1;
- guint8 *data = NULL;
+ const guint8 *data = NULL;
GST_LOG ("looking for mpeg-ts packets of size %u", packet_size);
while (found < GST_MPEGTS_TYPEFIND_MAX_HEADERS) {
/* TS packet sizes to test: normal, DVHS packet size and
* FEC with 16 or 20 byte codes packet size. */
const gint pack_sizes[] = { 188, 192, 204, 208 };
-
- guint8 *data = NULL;
+ const guint8 *data = NULL;
guint size = 0;
guint64 skipped = 0;
static void
aiff_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 4);
+ const guint8 *data = gst_type_find_peek (tf, 0, 4);
if (data && memcmp (data, "FORM", 4) == 0) {
data += 8;
static void
svx_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 4);
+ const guint8 *data = gst_type_find_peek (tf, 0, 4);
if (data && memcmp (data, "FORM", 4) == 0) {
data += 8;
static void
shn_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 4);
+ const guint8 *data = gst_type_find_peek (tf, 0, 4);
if (data && memcmp (data, "ajkg", 4) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SHN_CAPS);
static void
ape_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 4);
+ const guint8 *data = gst_type_find_peek (tf, 0, 4);
if (data && memcmp (data, "MAC ", 4) == 0) {
gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY + 10, APE_CAPS);
static void
m4a_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 4, 8);
+ const guint8 *data = gst_type_find_peek (tf, 4, 8);
if (data && (memcmp (data, "ftypM4A ", 8) == 0)) {
gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, M4A_CAPS);
const gchar *profile;
guint32 ftyp_size = 0;
gint offset = 0;
- guint8 *data = NULL;
+ const guint8 *data = NULL;
if ((data = gst_type_find_peek (tf, 0, 12)) == NULL) {
return;
static void
jp2_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data;
+ const guint8 *data;
data = gst_type_find_peek (tf, 0, 24);
if (!data)
static void
qt_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data;
+ const guint8 *data;
guint tip = 0;
guint64 offset = 0;
guint64 size;
}
}
if (size == 1) {
- guint8 *sizedata;
+ const guint8 *sizedata;
sizedata = gst_type_find_peek (tf, offset + 8, 8);
if (sizedata == NULL)
static void
mod_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data;
+ const guint8 *data;
/* MOD */
if ((data = gst_type_find_peek (tf, 1080, 4)) != NULL) {
}
/* DSM */
if (memcmp (data, "RIFF", 4) == 0) {
- guint8 *data2 = gst_type_find_peek (tf, 8, 4);
+ const guint8 *data2 = gst_type_find_peek (tf, 8, 4);
if (data2) {
if (memcmp (data2, "DSMF", 4) == 0) {
}
/* FAM */
if (memcmp (data, "FAM\xFE", 4) == 0) {
- guint8 *data2 = gst_type_find_peek (tf, 44, 3);
+ const guint8 *data2 = gst_type_find_peek (tf, 44, 3);
if (data2) {
if (memcmp (data2, "compare", 3) == 0) {
}
/* GDM */
if (memcmp (data, "GDM\xFE", 4) == 0) {
- guint8 *data2 = gst_type_find_peek (tf, 71, 4);
+ const guint8 *data2 = gst_type_find_peek (tf, 71, 4);
if (data2) {
if (memcmp (data2, "GMFS", 4) == 0) {
if ((data = gst_type_find_peek (tf, 20, 8)) != NULL) {
if (g_ascii_strncasecmp ((gchar *) data, "!Scream!", 8) == 0 ||
g_ascii_strncasecmp ((gchar *) data, "BMOD2STM", 8) == 0) {
- guint8 *id, *stmtype;
+ const guint8 *id, *stmtype;
if ((id = gst_type_find_peek (tf, 28, 1)) == NULL)
return;
static void
swf_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 4);
+ const guint8 *data = gst_type_find_peek (tf, 0, 4);
if (data && (data[0] == 'F' || data[0] == 'C') &&
data[1] == 'W' && data[2] == 'S') {
static void
tiff_type_find (GstTypeFind * tf, gpointer ununsed)
{
- guint8 *data = gst_type_find_peek (tf, 0, 8);
+ const guint8 *data = gst_type_find_peek (tf, 0, 8);
guint8 le_header[4] = { 0x49, 0x49, 0x2A, 0x00 };
guint8 be_header[4] = { 0x4D, 0x4D, 0x00, 0x2A };
static void
sds_type_find (GstTypeFind * tf, gpointer ununsed)
{
- guint8 *data = gst_type_find_peek (tf, 0, 4);
+ const guint8 *data = gst_type_find_peek (tf, 0, 4);
guint8 mask[4] = { 0xFF, 0xFF, 0x80, 0xFF };
guint8 match[4] = { 0xF0, 0x7E, 0, 0x01 };
gint x;
static void
ircam_type_find (GstTypeFind * tf, gpointer ununsed)
{
- guint8 *data = gst_type_find_peek (tf, 0, 4);
+ const guint8 *data = gst_type_find_peek (tf, 0, 4);
guint8 mask[4] = { 0xFF, 0xFF, 0xF8, 0xFF };
guint8 match[4] = { 0x64, 0xA3, 0x00, 0x00 };
gint x;
ebml_check_header (GstTypeFind * tf, const gchar * doctype, int doctype_len)
{
/* 4 bytes for EBML ID, 1 byte for header length identifier */
- guint8 *data = gst_type_find_peek (tf, 0, 4 + 1);
+ const guint8 *data = gst_type_find_peek (tf, 0, 4 + 1);
gint len_mask = 0x80, size = 1, n = 1, total;
if (!data)
static void
dv_type_find (GstTypeFind * tf, gpointer private)
{
- guint8 *data;
+ const guint8 *data;
data = gst_type_find_peek (tf, 0, 5);
static void
ogganx_type_find (GstTypeFind * tf, gpointer private)
{
- guint8 *data = gst_type_find_peek (tf, 0, 4);
+ const guint8 *data = gst_type_find_peek (tf, 0, 4);
if ((data != NULL) && (memcmp (data, "OggS", 4) == 0)) {
static void
vorbis_type_find (GstTypeFind * tf, gpointer private)
{
- guint8 *data = gst_type_find_peek (tf, 0, 30);
+ const guint8 *data = gst_type_find_peek (tf, 0, 30);
if (data) {
guint blocksize_0;
static void
theora_type_find (GstTypeFind * tf, gpointer private)
{
- guint8 *data = gst_type_find_peek (tf, 0, 7); //42);
+ const guint8 *data = gst_type_find_peek (tf, 0, 7); //42);
if (data) {
if (data[0] != 0x80)
static void
kate_type_find (GstTypeFind * tf, gpointer private)
{
- guint8 *data = gst_type_find_peek (tf, 0, 64);
+ const guint8 *data = gst_type_find_peek (tf, 0, 64);
gchar category[16] = { 0, };
if (G_UNLIKELY (data == NULL))
static void
ogmvideo_type_find (GstTypeFind * tf, gpointer private)
{
- guint8 *data = gst_type_find_peek (tf, 0, 9);
+ const guint8 *data = gst_type_find_peek (tf, 0, 9);
if (data) {
if (memcmp (data, "\001video\000\000\000", 9) != 0)
static void
ogmaudio_type_find (GstTypeFind * tf, gpointer private)
{
- guint8 *data = gst_type_find_peek (tf, 0, 9);
+ const guint8 *data = gst_type_find_peek (tf, 0, 9);
if (data) {
if (memcmp (data, "\001audio\000\000\000", 9) != 0)
static void
ogmtext_type_find (GstTypeFind * tf, gpointer private)
{
- guint8 *data = gst_type_find_peek (tf, 0, 9);
+ const guint8 *data = gst_type_find_peek (tf, 0, 9);
if (data) {
if (memcmp (data, "\001text\000\000\000\000", 9) != 0)
static void
speex_type_find (GstTypeFind * tf, gpointer private)
{
- guint8 *data = gst_type_find_peek (tf, 0, 80);
+ const guint8 *data = gst_type_find_peek (tf, 0, 80);
if (data) {
/* 8 byte string "Speex "
static void
celt_type_find (GstTypeFind * tf, gpointer private)
{
- guint8 *data = gst_type_find_peek (tf, 0, 8);
+ const guint8 *data = gst_type_find_peek (tf, 0, 8);
if (data) {
/* 8 byte string "CELT " */
static void
oggskel_type_find (GstTypeFind * tf, gpointer private)
{
- guint8 *data = gst_type_find_peek (tf, 0, 12);
+ const guint8 *data = gst_type_find_peek (tf, 0, 12);
if (data) {
/* 8 byte string "fishead\0" for the ogg skeleton stream */
cmml_type_find (GstTypeFind * tf, gpointer private)
{
/* Header is 12 bytes minimum (though we don't check the minor version */
- guint8 *data = gst_type_find_peek (tf, 0, 12);
+ const guint8 *data = gst_type_find_peek (tf, 0, 12);
if (data) {
static void
tar_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 257, 8);
+ const guint8 *data = gst_type_find_peek (tf, 257, 8);
/* of course we are not certain, but we don't want other typefind funcs
* to detect formats of files within the tar archive, e.g. mp3s */
static void
ar_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 24);
+ const guint8 *data = gst_type_find_peek (tf, 0, 24);
if (data && memcmp (data, "!<arch>", 7) == 0) {
gint i;
static void
au_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 4);
+ const guint8 *data = gst_type_find_peek (tf, 0, 4);
if (data) {
if (memcmp (data, ".snd", 4) == 0 || memcmp (data, "dns.", 4) == 0) {
static void
nuv_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 11);
+ const guint8 *data = gst_type_find_peek (tf, 0, 11);
if (data) {
if (memcmp (data, "MythTVVideo", 11) == 0
static void
paris_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 4);
+ const guint8 *data = gst_type_find_peek (tf, 0, 4);
if (data) {
if (memcmp (data, " paf", 4) == 0 || memcmp (data, "fap ", 4) == 0) {
static void
ilbc_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 8);
+ const guint8 *data = gst_type_find_peek (tf, 0, 8);
if (data) {
if (memcmp (data, "#!iLBC30", 8) == 0 || memcmp (data, "#!iLBC20", 8) == 0) {
static void
msdos_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 64);
+ const guint8 *data = gst_type_find_peek (tf, 0, 64);
if (data && data[0] == 'M' && data[1] == 'Z' &&
GST_READ_UINT16_LE (data + 8) == 4) {
0xcf, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c
};
- guint8 *data;
+ const guint8 *data;
data = gst_type_find_peek (tf, 0, 2 + 2 + 4 + 2 + 2 + 16);
if (data && data[0] == 0x24 && data[1] == 0x48 &&
static void
dirac_type_find (GstTypeFind * tf, gpointer unused)
{
- guint8 *data = gst_type_find_peek (tf, 0, 8);
+ const guint8 *data = gst_type_find_peek (tf, 0, 8);
if (data) {
if (memcmp (data, "BBCD", 4) == 0 || memcmp (data, "KW-DIRAC", 8) == 0) {
static const guint8 vivo_marker[] = { 'V', 'e', 'r', 's', 'i', 'o', 'n',
':', 'V', 'i', 'v', 'o', '/'
};
- guint8 *data;
+ const guint8 *data;
guint hdr_len, pos;
data = gst_type_find_peek (tf, 0, 1024);
gchar *mimetype;
gsize length = 16384;
guint64 tf_length;
- guint8 *data;
+ const guint8 *data;
gchar *tmp;
if ((tf_length = gst_type_find_get_length (find)) > 0)
static void
windows_icon_typefind (GstTypeFind * find, gpointer user_data)
{
- guint8 *data;
+ const guint8 *data;
gint64 datalen;
guint16 type, nimages;
gint32 size, offset;
start_with_type_find (GstTypeFind * tf, gpointer private)
{
GstTypeFindData *start_with = (GstTypeFindData *) private;
- guint8 *data;
+ const guint8 *data;
GST_LOG ("trying to find mime type %s with the first %u bytes of data",
gst_structure_get_name (gst_caps_get_structure (start_with->caps, 0)),
riff_type_find (GstTypeFind * tf, gpointer private)
{
GstTypeFindData *riff_data = (GstTypeFindData *) private;
- guint8 *data = gst_type_find_peek (tf, 0, 12);
+ const guint8 *data = gst_type_find_peek (tf, 0, 12);
if (data && (memcmp (data, "RIFF", 4) == 0 || memcmp (data, "AVF0", 4) == 0)) {
data += 8;
goto eos_before_buffers;
/* make sure we can write to the metadata */
- outbuf = gst_buffer_make_metadata_writable
- (gst_buffer_ref (videorate->prevbuf));
+ outbuf = gst_buffer_make_writable (gst_buffer_ref (videorate->prevbuf));
GST_BUFFER_OFFSET (outbuf) = videorate->out;
GST_BUFFER_OFFSET_END (outbuf) = videorate->out + 1;
static gboolean gst_video_scale_set_caps (GstBaseTransform * trans,
GstCaps * in, GstCaps * out);
static gboolean gst_video_scale_get_unit_size (GstBaseTransform * trans,
- GstCaps * caps, guint * size);
+ GstCaps * caps, gsize * size);
static GstFlowReturn gst_video_scale_transform (GstBaseTransform * trans,
GstBuffer * in, GstBuffer * out);
static void gst_video_scale_fixate_caps (GstBaseTransform * base,
static gboolean
gst_video_scale_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
- guint * size)
+ gsize * size)
{
GstVideoFormat format;
gint width, height;
gint method;
const guint8 *black = _get_black_for_format (videoscale->format);
gboolean add_borders;
+ guint8 *in_data, *out_data;
+ gsize in_size, out_size;
GST_OBJECT_LOCK (videoscale);
method = videoscale->method;
add_borders = videoscale->add_borders;
GST_OBJECT_UNLOCK (videoscale);
+ in_data = gst_buffer_map (in, &in_size, NULL, GST_MAP_READ);
+ out_data = gst_buffer_map (out, &out_size, NULL, GST_MAP_WRITE);
+
gst_video_scale_setup_vs_image (&src, videoscale->format, 0,
- videoscale->from_width, videoscale->from_height, 0, 0,
- GST_BUFFER_DATA (in));
+ videoscale->from_width, videoscale->from_height, 0, 0, in_data);
gst_video_scale_setup_vs_image (&dest, videoscale->format, 0,
videoscale->to_width, videoscale->to_height, videoscale->borders_w,
- videoscale->borders_h, GST_BUFFER_DATA (out));
+ videoscale->borders_h, out_data);
if (videoscale->format == GST_VIDEO_FORMAT_I420
|| videoscale->format == GST_VIDEO_FORMAT_YV12
|| videoscale->format == GST_VIDEO_FORMAT_Y42B
|| videoscale->format == GST_VIDEO_FORMAT_Y41B) {
gst_video_scale_setup_vs_image (&src_u, videoscale->format, 1,
- videoscale->from_width, videoscale->from_height, 0, 0,
- GST_BUFFER_DATA (in));
+ videoscale->from_width, videoscale->from_height, 0, 0, in_data);
gst_video_scale_setup_vs_image (&src_v, videoscale->format, 2,
- videoscale->from_width, videoscale->from_height, 0, 0,
- GST_BUFFER_DATA (in));
+ videoscale->from_width, videoscale->from_height, 0, 0, in_data);
gst_video_scale_setup_vs_image (&dest_u, videoscale->format, 1,
videoscale->to_width, videoscale->to_height, videoscale->borders_w,
- videoscale->borders_h, GST_BUFFER_DATA (out));
+ videoscale->borders_h, out_data);
gst_video_scale_setup_vs_image (&dest_v, videoscale->format, 2,
videoscale->to_width, videoscale->to_height, videoscale->borders_w,
- videoscale->borders_h, GST_BUFFER_DATA (out));
+ videoscale->borders_h, out_data);
}
switch (videoscale->format) {
}
GST_LOG_OBJECT (videoscale, "pushing buffer of %d bytes",
- GST_BUFFER_SIZE (out));
+ gst_buffer_get_size (out));
+
+done:
+ gst_buffer_unmap (in, in_data, in_size);
+ gst_buffer_unmap (out, out_data, out_size);
return ret;
GST_ELEMENT_ERROR (videoscale, STREAM, NOT_IMPLEMENTED, (NULL),
("Unsupported format %d for scaling method %d",
videoscale->format, method));
- return GST_FLOW_ERROR;
+ ret = GST_FLOW_ERROR;
+ goto done;
}
unknown_mode:
{
GST_ELEMENT_ERROR (videoscale, STREAM, NOT_IMPLEMENTED, (NULL),
("Unknown scaling method %d", videoscale->method));
- return GST_FLOW_ERROR;
+ ret = GST_FLOW_ERROR;
+ goto done;
}
}
gst_video_test_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
{
GstVideoTestSrc *src;
- gulong newsize, size;
+ gsize newsize, size;
GstBuffer *outbuf = NULL;
GstFlowReturn res;
GstClockTime next_time;
+ guint8 *data;
src = GST_VIDEO_TEST_SRC (psrc);
/* the buffer could have renegotiated, we need to discard any buffers of the
* wrong size. */
- size = GST_BUFFER_SIZE (outbuf);
+ size = gst_buffer_get_size (outbuf);
newsize = gst_video_test_src_get_size (src, src->width, src->height);
if (size != newsize) {
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (GST_BASE_SRC_PAD (psrc)));
}
- memset (GST_BUFFER_DATA (outbuf), 0, GST_BUFFER_SIZE (outbuf));
+ data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
+ memset (data, 0, size);
src->tmpline_u8 = g_malloc (src->width + 8);
src->tmpline = g_malloc ((src->width + 8) * 4);
src->tmpline2 = g_malloc ((src->width + 8) * 4);
- src->make_image (src, (void *) GST_BUFFER_DATA (outbuf),
- src->width, src->height);
+ src->make_image (src, (void *) data, src->width, src->height);
+ gst_buffer_unmap (outbuf, data, size);
g_free (src->tmpline);
g_free (src->tmpline2);
{
GstVolume *self = GST_VOLUME (base);
guint8 *data;
- guint size;
+ gsize size;
GstControlSource *mute_csource, *volume_csource;
if (G_UNLIKELY (!self->negotiated))
GST_BUFFER_FLAG_IS_SET (outbuf, GST_BUFFER_FLAG_GAP))
return GST_FLOW_OK;
- data = GST_BUFFER_DATA (outbuf);
- size = GST_BUFFER_SIZE (outbuf);
+ data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE);
mute_csource = gst_object_get_control_source (G_OBJECT (self), "mute");
volume_csource = gst_object_get_control_source (G_OBJECT (self), "volume");
} else if (self->current_volume != 1.0) {
self->process (self, data, size);
}
+ gst_buffer_unmap (outbuf, data, size);
return GST_FLOW_OK;
GST_ELEMENT_ERROR (self, CORE, FAILED,
("Failed to get values from controller"), (NULL));
+ gst_buffer_unmap (outbuf, data, size);
return GST_FLOW_ERROR;
}
}