plugins: port some plugins to the new memory API

This commit is contained in:
Wim Taymans 2011-03-27 16:35:28 +02:00
parent 3d25a4b470
commit 3b03e23559
22 changed files with 321 additions and 269 deletions

View file

@ -1102,16 +1102,16 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
* 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 */
@ -1123,6 +1123,7 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_data)
/* 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);
@ -1130,6 +1131,8 @@ gst_adder_collected (GstCollectPads * pads, gpointer user_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 */

View file

@ -76,7 +76,7 @@ static void gst_audio_convert_dispose (GObject * obj);
/* 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,
@ -361,7 +361,7 @@ not_allowed:
/* BaseTransform vmethods */
static gboolean
gst_audio_convert_get_unit_size (GstBaseTransform * base, GstCaps * caps,
guint * size)
gsize * size)
{
AudioConvertFmt fmt = { 0 };
@ -1069,7 +1069,9 @@ static GstFlowReturn
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;
@ -1079,7 +1081,7 @@ gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
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 */
@ -1089,15 +1091,15 @@ gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
if (insize == 0 || outsize == 0)
return GST_FLOW_OK;
/* check in and outsize */
if (GST_BUFFER_SIZE (inbuf) < insize)
goto wrong_size;
if (GST_BUFFER_SIZE (outbuf) < outsize)
goto wrong_size;
/* get src and dst data */
src = GST_BUFFER_DATA (inbuf);
dst = GST_BUFFER_DATA (outbuf);
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 (srcsize < insize)
goto wrong_size;
if (dstsize < outsize)
goto wrong_size;
/* and convert the samples */
if (!GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP)) {
@ -1108,10 +1110,13 @@ gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
/* 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:
@ -1125,15 +1130,16 @@ wrong_size:
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;
}
}

View file

@ -589,7 +589,7 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
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 */
@ -633,13 +633,17 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
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);
@ -722,7 +726,7 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf)
}
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
@ -738,14 +742,14 @@ send:
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);
}

View file

@ -127,14 +127,14 @@ static void gst_audio_resample_get_property (GObject * object,
/* 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,
@ -282,7 +282,7 @@ gst_audio_resample_stop (GstBaseTransform * base)
static gboolean
gst_audio_resample_get_unit_size (GstBaseTransform * base, GstCaps * caps,
guint * size)
gsize * size)
{
gint width, channels;
GstStructure *structure;
@ -530,8 +530,8 @@ _gcd (gint a, gint b)
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;
@ -824,6 +824,7 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
guint out_len, out_processed;
gint err;
guint num, den;
guint8 *data;
g_assert (resample->state != NULL);
@ -851,6 +852,8 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
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,
@ -866,17 +869,20 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
/* 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));
@ -914,13 +920,10 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
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));
@ -1025,12 +1028,17 @@ static GstFlowReturn
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);
@ -1062,7 +1070,7 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
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;
@ -1095,11 +1103,13 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
&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 */
@ -1108,17 +1118,18 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
/* 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;
}
}
@ -1156,14 +1167,15 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
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));
@ -1180,7 +1192,6 @@ gst_audio_resample_transform (GstBaseTransform * base, GstBuffer * inbuf,
GstBuffer * outbuf)
{
GstAudioResample *resample = GST_AUDIO_RESAMPLE (base);
gulong size;
GstFlowReturn ret;
if (resample->state == NULL) {
@ -1194,12 +1205,10 @@ gst_audio_resample_transform (GstBaseTransform * base, GstBuffer * inbuf,
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));

View file

@ -1034,6 +1034,7 @@ gst_audio_test_src_create (GstBaseSrc * basesrc, guint64 offset,
gint64 next_sample, next_byte;
gint bytes, samples;
GstElementClass *eclass;
guint8 *data;
src = GST_AUDIO_TEST_SRC (basesrc);
@ -1130,7 +1131,9 @@ gst_audio_test_src_create (GstBaseSrc * basesrc, guint64 offset,
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))) {

View file

@ -43,7 +43,6 @@ gst_ff_vid_caps_new (AVCodecContext * context,
/*
* Read a palette from a caps.
*/
static void
gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
{
@ -52,15 +51,15 @@ gst_ff_vid_caps_new (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);
}
}
@ -71,9 +70,13 @@ gst_ffmpeg_set_palette (GstCaps * caps, AVCodecContext * context)
{
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);
}

View file

@ -87,7 +87,7 @@ GType gst_ffmpegcsp_get_type (void);
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);
@ -396,7 +396,7 @@ gst_ffmpegcsp_init (GstFFMpegCsp * space, GstFFMpegCspClass * klass)
static gboolean
gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
guint * size)
gsize * size)
{
GstStructure *structure = NULL;
AVCodecContext *ctx = NULL;
@ -448,6 +448,8 @@ gst_ffmpegcsp_transform (GstBaseTransform * btrans, GstBuffer * inbuf,
{
GstFFMpegCsp *space;
gint result;
guint8 *indata, *outdata;
gsize insize, outsize;
space = GST_FFMPEGCSP (btrans);
@ -458,8 +460,9 @@ gst_ffmpegcsp_transform (GstBaseTransform * btrans, GstBuffer * inbuf,
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 */
@ -467,13 +470,17 @@ gst_ffmpegcsp_transform (GstBaseTransform * btrans, GstBuffer * inbuf,
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;

View file

@ -285,17 +285,23 @@ gst_gdp_depay_chain (GstPad * pad, GstBuffer * buffer)
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;
@ -309,9 +315,11 @@ gst_gdp_depay_chain (GstPad * pad, GstBuffer * buffer)
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 */
@ -319,12 +327,12 @@ gst_gdp_depay_chain (GstPad * pad, GstBuffer * buffer)
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;

View file

@ -77,9 +77,7 @@ GST_BOILERPLATE_FULL (GstGDPPay, gst_gdp_pay, GstElement,
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 *
@ -112,7 +110,6 @@ static void
gst_gdp_pay_class_init (GstGDPPayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
@ -216,7 +213,7 @@ static void
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);
}
@ -224,12 +221,9 @@ static GstBuffer *
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))
@ -237,13 +231,13 @@ gst_gdp_buffer_from_caps (GstGDPPay * this, GstCaps * caps)
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);
@ -259,9 +253,7 @@ static GstBuffer *
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,
@ -270,8 +262,8 @@ gst_gdp_pay_buffer_from_buffer (GstGDPPay * this, GstBuffer * buffer)
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);
@ -290,13 +282,9 @@ static GstBuffer *
gst_gdp_buffer_from_event (GstGDPPay * this, GstEvent * event)
{
GstBuffer *headerbuf;
GstBuffer *payloadbuf;
guint8 *header, *payload;
guint len;
guint len, plen;
gboolean ret;
ret =
@ -307,13 +295,13 @@ gst_gdp_buffer_from_event (GstGDPPay * this, GstEvent * event)
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);
@ -333,14 +321,10 @@ static GstFlowReturn
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 };
@ -474,10 +458,9 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
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 */
@ -579,11 +562,8 @@ static GstFlowReturn
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));
@ -698,11 +678,8 @@ static gboolean
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)",
@ -784,7 +761,6 @@ static gboolean
gst_gdp_pay_src_event (GstPad * pad, GstEvent * event)
{
GstGDPPay *this;
gboolean res = TRUE;
this = GST_GDP_PAY (gst_pad_get_parent (pad));
@ -865,7 +841,6 @@ static GstStateChangeReturn
gst_gdp_pay_change_state (GstElement * element, GstStateChange transition)
{
GstStateChangeReturn ret;
GstGDPPay *this = GST_GDP_PAY (element);
switch (transition) {

View file

@ -592,7 +592,7 @@ gst_stream_synchronizer_sink_chain (GstPad * pad, GstBuffer * buffer)
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));
@ -607,7 +607,7 @@ gst_stream_synchronizer_sink_chain (GstPad * pad, GstBuffer * 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;
}

View file

@ -138,8 +138,8 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
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");
@ -157,12 +157,15 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
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]")) {
@ -171,16 +174,17 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
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;
@ -269,8 +273,8 @@ gst_ssa_parse_push_line (GstSsaParse * parse, gchar * txt,
/* 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;
@ -299,6 +303,8 @@ gst_ssa_parse_chain (GstPad * sinkpad, GstBuffer * buf)
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;
@ -314,7 +320,10 @@ gst_ssa_parse_chain (GstPad * sinkpad, GstBuffer * buf)
}
/* 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;

View file

@ -1418,6 +1418,8 @@ feed_textbuf (GstSubParse * self, GstBuffer * buf)
gboolean discont;
gsize consumed;
gchar *input = NULL;
const guint8 *data;
gsize avail;
discont = GST_BUFFER_IS_DISCONT (buf);
@ -1442,19 +1444,20 @@ feed_textbuf (GstSubParse * self, GstBuffer * 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);
@ -1465,12 +1468,13 @@ handle_buffer (GstSubParse * self, GstBuffer * buf)
{
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;
@ -1520,8 +1524,9 @@ handle_buffer (GstSubParse * self, GstBuffer * buf)
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;
@ -1602,13 +1607,13 @@ gst_sub_parse_sink_event (GstPad * pad, GstEvent * event)
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);
}

View file

@ -1391,7 +1391,7 @@ gst_multi_fd_sink_client_queue_buffer (GstMultiFdSink * sink,
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);
@ -1403,7 +1403,7 @@ gst_multi_fd_sink_client_queue_buffer (GstMultiFdSink * sink,
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);
@ -1490,7 +1490,7 @@ get_buffers_max (GstMultiFdSink * sink, gint64 max)
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;
@ -1573,7 +1573,7 @@ find_limits (GstMultiFdSink * sink,
}
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) {
@ -1980,10 +1980,14 @@ gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink,
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
@ -1992,12 +1996,11 @@ gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink,
#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.. */
@ -2499,14 +2502,14 @@ gst_multi_fd_sink_render (GstBaseSink * bsink, GstBuffer * buf)
/* 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 */
@ -2554,13 +2557,13 @@ gst_multi_fd_sink_render (GstBaseSink * bsink, GstBuffer * buf)
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;

View file

@ -228,6 +228,7 @@ gst_tcp_read_buffer (GstElement * this, int socket, GstPoll * fdset,
int ret;
ssize_t bytes_read;
int readsize;
guint8 *data;
*buf = NULL;
@ -251,7 +252,9 @@ gst_tcp_read_buffer (GstElement * this, int socket, GstPoll * fdset,
*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;
@ -260,7 +263,7 @@ gst_tcp_read_buffer (GstElement * this, int socket, GstPoll * fdset,
/* 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 */
@ -317,6 +320,8 @@ gst_tcp_gdp_read_buffer (GstElement * this, int socket, GstPoll * fdset,
{
GstFlowReturn ret;
guint8 *header = NULL;
guint8 *data;
gsize size;
GST_LOG_OBJECT (this, "Reading %d bytes for buffer packet header",
GST_DP_HEADER_LENGTH);
@ -341,8 +346,9 @@ gst_tcp_gdp_read_buffer (GstElement * this, int socket, GstPoll * fdset,
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;

View file

@ -196,19 +196,21 @@ gst_tcp_client_sink_render (GstBaseSink * bsink, GstBuffer * buf)
{
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;
@ -222,8 +224,8 @@ 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;
}
}

View file

@ -199,7 +199,7 @@ gst_tcp_client_src_create (GstPushSrc * psrc, GstBuffer ** 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));

View file

@ -207,7 +207,7 @@ restart:
"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));

View file

@ -130,7 +130,7 @@ static gboolean
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 */
@ -222,7 +222,7 @@ static GstStaticCaps uri_caps = GST_STATIC_CAPS ("text/uri-list");
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;
@ -287,7 +287,7 @@ xml_check_first_element (GstTypeFind * tf, const gchar * element, guint elen,
gboolean strict)
{
gboolean got_xmldec;
guint8 *data;
const guint8 *data;
guint offset = 0;
guint pos = 0;
@ -351,7 +351,7 @@ static GstStaticCaps sdp_caps = GST_STATIC_CAPS ("application/sdp");
static gboolean
sdp_check_header (GstTypeFind * tf)
{
guint8 *data;
const guint8 *data;
data = gst_type_find_peek (tf, 0, 5);
if (!data)
@ -398,9 +398,9 @@ static GstStaticCaps html_caps = GST_STATIC_CAPS ("text/html");
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;
@ -409,7 +409,7 @@ html_type_find (GstTypeFind * tf, gpointer unused)
} 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);
}
@ -424,7 +424,7 @@ static GstStaticCaps mid_caps = GST_STATIC_CAPS ("audio/midi");
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'
@ -440,7 +440,7 @@ static GstStaticCaps mxmf_caps = GST_STATIC_CAPS ("audio/mobile-xmf");
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);
@ -468,7 +468,7 @@ static GstStaticCaps flx_caps = GST_STATIC_CAPS ("video/x-fli");
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 */
@ -499,7 +499,7 @@ static GstStaticCaps id3_caps = GST_STATIC_CAPS ("application/x-id3");
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 &&
@ -512,7 +512,7 @@ id3v2_type_find (GstTypeFind * tf, gpointer unused)
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);
@ -527,7 +527,7 @@ static GstStaticCaps apetag_caps = GST_STATIC_CAPS ("application/x-apetag");
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);
@ -552,7 +552,7 @@ static GstStaticCaps tta_caps = GST_STATIC_CAPS ("audio/x-ttafile");
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) {
@ -950,8 +950,8 @@ static void
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;
@ -975,7 +975,7 @@ mp3_type_find_at_offset (GstTypeFind * tf, guint64 start_off,
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;
@ -1089,7 +1089,7 @@ static void
mp3_type_find (GstTypeFind * tf, gpointer unused)
{
GstTypeFindProbability prob, mid_prob;
guint8 *data;
const guint8 *data;
guint layer, mid_layer;
guint64 length;
@ -1159,7 +1159,7 @@ GST_STATIC_CAPS ("audio/x-musepack, streamversion= (int) { 7, 8 }");
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;
@ -1481,7 +1481,7 @@ wavpack_type_find (GstTypeFind * tf, gpointer unused)
{
guint64 offset;
guint32 blocksize;
guint8 *data;
const guint8 *data;
data = gst_type_find_peek (tf, 0, 32);
if (!data)
@ -1544,7 +1544,7 @@ GST_STATIC_CAPS ("application/postscript");
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;
@ -1594,8 +1594,8 @@ GST_STATIC_CAPS ("multipart/x-mixed-replace");
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);
@ -1704,7 +1704,7 @@ mpeg_sys_is_valid_pack (GstTypeFind * tf, const guint8 * data, guint len,
}
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;
@ -1732,7 +1732,7 @@ mpeg_sys_is_valid_pes (GstTypeFind * tf, guint8 * data, guint 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;
@ -1773,7 +1773,7 @@ mpeg_sys_is_valid_sys (GstTypeFind * tf, guint8 * data, guint 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;
@ -1914,7 +1914,7 @@ mpeg_ts_probe_headers (GstTypeFind * tf, guint64 offset, gint packet_size)
{
/* 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) {
@ -1939,8 +1939,7 @@ mpeg_ts_type_find (GstTypeFind * tf, gpointer unused)
/* 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;
@ -2375,7 +2374,7 @@ static GstStaticCaps aiff_caps = GST_STATIC_CAPS ("audio/x-aiff");
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;
@ -2392,7 +2391,7 @@ static GstStaticCaps svx_caps = GST_STATIC_CAPS ("audio/x-svx");
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;
@ -2409,7 +2408,7 @@ static GstStaticCaps shn_caps = GST_STATIC_CAPS ("audio/x-shorten");
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);
@ -2428,7 +2427,7 @@ static GstStaticCaps ape_caps = GST_STATIC_CAPS ("application/x-ape");
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);
@ -2445,7 +2444,7 @@ static GstStaticCaps m4a_caps = GST_STATIC_CAPS ("audio/x-m4a");
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);
@ -2482,7 +2481,7 @@ q3gp_type_find (GstTypeFind * tf, gpointer unused)
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;
@ -2532,7 +2531,7 @@ static GstStaticCaps jp2_caps = GST_STATIC_CAPS ("image/jp2");
static void
jp2_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data;
const guint8 *data;
data = gst_type_find_peek (tf, 0, 24);
if (!data)
@ -2563,7 +2562,7 @@ static GstStaticCaps qt_caps = GST_STATIC_CAPS ("video/quicktime");
static void
qt_type_find (GstTypeFind * tf, gpointer unused)
{
guint8 *data;
const guint8 *data;
guint tip = 0;
guint64 offset = 0;
guint64 size;
@ -2630,7 +2629,7 @@ qt_type_find (GstTypeFind * tf, gpointer unused)
}
}
if (size == 1) {
guint8 *sizedata;
const guint8 *sizedata;
sizedata = gst_type_find_peek (tf, offset + 8, 8);
if (sizedata == NULL)
@ -2726,7 +2725,7 @@ static GstStaticCaps mod_caps = GST_STATIC_CAPS ("audio/x-mod");
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) {
@ -2782,7 +2781,7 @@ mod_type_find (GstTypeFind * tf, gpointer unused)
}
/* 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) {
@ -2793,7 +2792,7 @@ mod_type_find (GstTypeFind * tf, gpointer unused)
}
/* 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) {
@ -2807,7 +2806,7 @@ mod_type_find (GstTypeFind * tf, gpointer unused)
}
/* 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) {
@ -2838,7 +2837,7 @@ mod_type_find (GstTypeFind * tf, gpointer unused)
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;
@ -2859,7 +2858,7 @@ GST_STATIC_CAPS ("application/x-shockwave-flash");
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') {
@ -3050,7 +3049,7 @@ static GstStaticCaps tiff_le_caps = GST_STATIC_CAPS ("image/tiff, "
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 };
@ -3167,7 +3166,7 @@ static GstStaticCaps sds_caps = GST_STATIC_CAPS ("audio/x-sds");
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;
@ -3188,7 +3187,7 @@ static GstStaticCaps ircam_caps = GST_STATIC_CAPS ("audio/x-ircam");
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;
@ -3220,7 +3219,7 @@ static gboolean
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)
@ -3348,7 +3347,7 @@ static GstStaticCaps dv_caps = GST_STATIC_CAPS ("video/x-dv, "
static void
dv_type_find (GstTypeFind * tf, gpointer private)
{
guint8 *data;
const guint8 *data;
data = gst_type_find_peek (tf, 0, 5);
@ -3380,7 +3379,7 @@ static GstStaticCaps ogg_annodex_caps =
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)) {
@ -3402,7 +3401,7 @@ static GstStaticCaps vorbis_caps = GST_STATIC_CAPS ("audio/x-vorbis");
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;
@ -3447,7 +3446,7 @@ static GstStaticCaps theora_caps = GST_STATIC_CAPS ("video/x-theora");
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)
@ -3464,7 +3463,7 @@ theora_type_find (GstTypeFind * tf, gpointer private)
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))
@ -3497,7 +3496,7 @@ GST_STATIC_CAPS ("application/x-ogm-video");
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)
@ -3512,7 +3511,7 @@ GST_STATIC_CAPS ("application/x-ogm-audio");
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)
@ -3527,7 +3526,7 @@ static GstStaticCaps ogmtext_caps = GST_STATIC_CAPS ("application/x-ogm-text");
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)
@ -3544,7 +3543,7 @@ static GstStaticCaps speex_caps = GST_STATIC_CAPS ("audio/x-speex");
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 "
@ -3580,7 +3579,7 @@ static GstStaticCaps celt_caps = GST_STATIC_CAPS ("audio/x-celt");
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 " */
@ -3599,7 +3598,7 @@ GST_STATIC_CAPS ("application/x-ogg-skeleton, parsed=(boolean)FALSE");
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 */
@ -3625,7 +3624,7 @@ static void
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) {
@ -3652,7 +3651,7 @@ static GstStaticCaps tar_caps = GST_STATIC_CAPS ("application/x-tar");
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 */
@ -3674,7 +3673,7 @@ static GstStaticCaps ar_caps = GST_STATIC_CAPS ("application/x-ar");
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;
@ -3701,7 +3700,7 @@ static GstStaticCaps au_caps = GST_STATIC_CAPS ("audio/x-au");
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) {
@ -3723,7 +3722,7 @@ static GstStaticCaps nuv_caps = GST_STATIC_CAPS ("video/x-nuv");
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
@ -3741,7 +3740,7 @@ static GstStaticCaps paris_caps = GST_STATIC_CAPS ("audio/x-paris");
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) {
@ -3758,7 +3757,7 @@ static GstStaticCaps ilbc_caps = GST_STATIC_CAPS ("audio/iLBC-sh");
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) {
@ -3776,7 +3775,7 @@ GST_STATIC_CAPS ("application/x-ms-dos-executable");
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) {
@ -3803,7 +3802,7 @@ mmsh_type_find (GstTypeFind * tf, gpointer unused)
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 &&
@ -3825,7 +3824,7 @@ static GstStaticCaps dirac_caps = GST_STATIC_CAPS ("video/x-dirac");
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) {
@ -3846,7 +3845,7 @@ vivo_type_find (GstTypeFind * tf, gpointer unused)
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);
@ -3884,7 +3883,7 @@ xdgmime_typefind (GstTypeFind * find, gpointer user_data)
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)
@ -3936,7 +3935,7 @@ xdgmime_typefind (GstTypeFind * find, gpointer user_data)
static void
windows_icon_typefind (GstTypeFind * find, gpointer user_data)
{
guint8 *data;
const guint8 *data;
gint64 datalen;
guint16 type, nimages;
gint32 size, offset;
@ -4035,7 +4034,7 @@ static void
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)),
@ -4075,7 +4074,7 @@ static void
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;

View file

@ -463,8 +463,7 @@ gst_video_rate_flush_prev (GstVideoRate * videorate, gboolean duplicate)
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;

View file

@ -201,7 +201,7 @@ static GstCaps *gst_video_scale_transform_caps (GstBaseTransform * trans,
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,
@ -443,7 +443,7 @@ done:
static gboolean
gst_video_scale_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
guint * size)
gsize * size)
{
GstVideoFormat format;
gint width, height;
@ -1016,18 +1016,22 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
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
@ -1035,17 +1039,15 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
|| 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) {
@ -1252,7 +1254,11 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
}
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;
@ -1262,13 +1268,15 @@ unsupported:
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;
}
}

View file

@ -828,10 +828,11 @@ static GstFlowReturn
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);
@ -860,7 +861,7 @@ gst_video_test_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
/* 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) {
@ -874,13 +875,14 @@ gst_video_test_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
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);

View file

@ -874,7 +874,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
{
GstVolume *self = GST_VOLUME (base);
guint8 *data;
guint size;
gsize size;
GstControlSource *mute_csource, *volume_csource;
if (G_UNLIKELY (!self->negotiated))
@ -885,8 +885,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
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");
@ -954,6 +953,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
} else if (self->current_volume != 1.0) {
self->process (self, data, size);
}
gst_buffer_unmap (outbuf, data, size);
return GST_FLOW_OK;
@ -973,6 +973,7 @@ controller_failure:
GST_ELEMENT_ERROR (self, CORE, FAILED,
("Failed to get values from controller"), (NULL));
gst_buffer_unmap (outbuf, data, size);
return GST_FLOW_ERROR;
}
}