GstPad parent;
GstBuffer *pen;
+ GstMapInfo map; /* mapped data to read from / write to */
/* index for the pad per direction (starting from 0) */
guint index;
/* these are only used for sink pads */
guint samples_avail; /* available mono sample frames */
- gfloat *data; /* data pointer to read from / write to */
};
static GType
self->group_in = g_new0 (GstSignalProcessorGroup, klass->num_group_in);
self->group_out = g_new0 (GstSignalProcessorGroup, klass->num_group_out);
- self->audio_in = g_new0 (gfloat *, klass->num_audio_in);
- self->audio_out = g_new0 (gfloat *, klass->num_audio_out);
- self->control_in = g_new0 (gfloat, klass->num_control_in);
- self->control_out = g_new0 (gfloat, klass->num_control_out);
+ self->audio_in = g_new0 (GstMapInfo, klass->num_audio_in);
+ self->audio_out = g_new0 (GstMapInfo, klass->num_audio_out);
/* init */
self->pending_in = klass->num_group_in + klass->num_audio_in;
self->audio_in = NULL;
g_free (self->audio_out);
self->audio_out = NULL;
- g_free (self->control_in);
- self->control_in = NULL;
- g_free (self->control_out);
- self->control_out = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
}
for (i = 0; i < klass->num_group_in; ++i) {
g_free (self->group_in[i].buffer);
- memset (&self->group_in[i], '\0', sizeof (GstSignalProcessorGroup));
+ memset (&self->group_in[i], 0, sizeof (GstSignalProcessorGroup));
}
for (i = 0; i < klass->num_group_out; ++i) {
g_free (self->group_out[i].buffer);
- memset (&self->group_in[i], '\0', sizeof (GstSignalProcessorGroup));
+ memset (&self->group_out[i], 0, sizeof (GstSignalProcessorGroup));
}
self->state = GST_SIGNAL_PROCESSOR_STATE_NULL;
{
guint i, j;
g_assert (group->nframes == nframes);
- g_assert (group->interleaved_buffer);
+ g_assert (group->interleaved_map.data);
g_assert (group->buffer);
for (i = 0; i < nframes; ++i)
for (j = 0; j < group->channels; ++j)
group->buffer[(j * nframes) + i]
- = group->interleaved_buffer[(i * group->channels) + j];
+ = group->interleaved_map.data[(i * group->channels) + j];
}
/* Interleave a pad (plugin => gstreamer) */
{
guint i, j;
g_assert (group->nframes == nframes);
- g_assert (group->interleaved_buffer);
+ g_assert (group->interleaved_map.data);
g_assert (group->buffer);
for (i = 0; i < nframes; ++i)
for (j = 0; j < group->channels; ++j)
- group->interleaved_buffer[(i * group->channels) + j]
+ group->interleaved_map.data[(i * group->channels) + j]
= group->buffer[(j * nframes) + i];
}
samples_avail = MIN (samples_avail, sinkpad->samples_avail);
if (sinkpad->channels > 1) {
GstSignalProcessorGroup *group = &self->group_in[in_group_index++];
- group->interleaved_buffer = sinkpad->data;
+ group->interleaved_map.data = sinkpad->map.data;
/* allocate buffer for de-interleaving */
if (!group->buffer || group->channels < sinkpad->channels
|| group->nframes < samples_avail) {
group->nframes = samples_avail;
gst_signal_processor_deinterleave_group (group, samples_avail);
} else {
- self->audio_in[sinkpad->index] = sinkpad->data;
+ self->audio_in[sinkpad->index] = sinkpad->map;
}
}
g_assert (sinkpad->samples_avail == samples_avail);
srcpad->pen = sinkpad->pen;
sinkpad->pen = NULL;
- self->audio_out[srcpad->index] = sinkpad->data;
+ self->audio_out[srcpad->index] = sinkpad->map;
self->pending_out++;
srcs = srcs->next;
if (srcpad->channels > 1) {
GstSignalProcessorGroup *group = &self->group_out[out_group_index++];
- group->interleaved_buffer =
- (gfloat *) gst_buffer_map (srcpad->pen, NULL, NULL,
- GST_MAP_READWRITE);
+ gst_buffer_map (srcpad->pen, &group->interleaved_map, GST_MAP_READWRITE);
if (!group->buffer || group->channels < srcpad->channels
|| group->nframes < samples_avail)
group->buffer =
group->nframes = samples_avail;
self->pending_out++;
} else {
- self->audio_out[srcpad->index] =
- (gfloat *) gst_buffer_map (srcpad->pen, NULL, NULL,
+ gst_buffer_map (srcpad->pen, &self->audio_out[srcpad->index],
GST_MAP_READWRITE);
self->pending_out++;
}
if (!sinkpad->pen) {
/* this buffer was used up */
self->pending_in++;
- sinkpad->data = NULL;
+ sinkpad->map.data = NULL;
sinkpad->samples_avail = 0;
} else {
/* advance ->data pointers and decrement ->samples_avail, unreffing buffer
if no samples are left */
sinkpad->samples_avail -= nprocessed;
- sinkpad->data += nprocessed * sinkpad->channels; /* gfloat* arithmetic */
+ sinkpad->map.data += nprocessed * sinkpad->channels; /* gfloat* arithmetic */
}
}
}
GstBuffer * buffer)
{
GstSignalProcessorPad *spad = (GstSignalProcessorPad *) pad;
- gsize size;
if (spad->pen)
goto had_buffer;
/* keep the reference */
spad->pen = buffer;
- spad->data =
- (gfloat *) gst_buffer_map (buffer, &size, NULL, GST_MAP_READWRITE);
- spad->samples_avail = size / sizeof (float) / spad->channels;
+ gst_buffer_map (buffer, &spad->map, GST_MAP_READWRITE);
+ spad->samples_avail = spad->map.size / sizeof (float) / spad->channels;
g_assert (self->pending_in != 0);
GstSignalProcessorPad *spad = (GstSignalProcessorPad *) pads->data;
if (spad->pen) {
- gst_buffer_unmap (spad->pen, spad->data, -1);
+ gst_buffer_unmap (spad->pen, &spad->map);
gst_buffer_unref (spad->pen);
spad->pen = NULL;
- spad->data = NULL;
spad->samples_avail = 0;
}
}
struct _GstSignalProcessorGroup {
guint channels; /**< Number of channels in buffers */
guint nframes; /**< Number of frames currently allocated per channel */
- gfloat *interleaved_buffer; /**< Interleaved buffer (c1c2c1c2...)*/
+ GstMapInfo interleaved_map; /**< Interleaved buffer (c1c2c1c2...)*/
gfloat *buffer; /**< De-interleaved buffer (c1c1...c2c2...) */
};
GstSignalProcessorGroup *group_out;
/* single channel signal pads */
- gfloat **audio_in;
- gfloat **audio_out;
+ GstMapInfo *audio_in;
+ GstMapInfo *audio_out;
- /* controls */
- gfloat *control_in;
- gfloat *control_out;
-
/* sampling rate */
gint sample_rate;
guint num_group_out;
guint num_audio_in;
guint num_audio_out;
- guint num_control_in;
- guint num_control_out;
guint flags;
GstBuffer *inbuf;
guint64 dist, ts;
guint avail, sbpf;
- gpointer adata, vdata;
+ gpointer adata;
gboolean (*render) (GstBaseAudioVisualizer * scope, GstBuffer * audio,
GstBuffer * video);
GST_LOG_OBJECT (scope, "avail: %u, bpf: %u", avail, sbpf);
while (avail >= sbpf) {
GstBuffer *outbuf;
+ GstMapInfo map;
/* get timestamp of the current adapter content */
ts = gst_adapter_prev_timestamp (scope->adapter, &dist);
GST_BUFFER_TIMESTAMP (outbuf) = ts;
GST_BUFFER_DURATION (outbuf) = scope->frame_duration;
- vdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
if (scope->shader) {
- memcpy (vdata, scope->pixelbuf, scope->bpf);
+ memcpy (map.data, scope->pixelbuf, scope->bpf);
} else {
- memset (vdata, 0, scope->bpf);
+ memset (map.data, 0, scope->bpf);
}
/* this can fail as the data size we need could have changed */
} else {
/* run various post processing (shading and geometri transformation */
if (scope->shader) {
- scope->shader (scope, vdata, scope->pixelbuf);
+ scope->shader (scope, map.data, scope->pixelbuf);
}
}
}
- gst_buffer_unmap (outbuf, vdata, scope->bpf);
+ gst_buffer_unmap (outbuf, &map);
+ gst_buffer_resize (outbuf, 0, scope->bpf);
g_mutex_unlock (&scope->config_lock);
ret = gst_pad_push (scope->srcpad, outbuf);
GstBuffer * video)
{
GstSpaceScope *scope = GST_SPACE_SCOPE (base);
- gsize asize;
- guint32 *vdata =
- (guint32 *) gst_buffer_map (video, NULL, NULL, GST_MAP_WRITE);
- gint16 *adata = (gint16 *) gst_buffer_map (audio, &asize, NULL, GST_MAP_READ);
+ GstMapInfo vmap, amap;
guint num_samples;
- num_samples = asize / (base->channels * sizeof (gint16));
- scope->process (base, vdata, adata, num_samples);
- gst_buffer_unmap (video, vdata, -1);
- gst_buffer_unmap (audio, adata, -1);
+ gst_buffer_map (audio, &amap, GST_MAP_READ);
+ gst_buffer_map (video, &vmap, GST_MAP_WRITE);
+
+ num_samples = amap.size / (base->channels * sizeof (gint16));
+ scope->process (base, (guint32 *) vmap.data, (gint16 *) amap.data,
+ num_samples);
+ gst_buffer_unmap (video, &vmap);
+ gst_buffer_unmap (audio, &amap);
return TRUE;
}
GstBuffer * video)
{
GstSpectraScope *scope = GST_SPECTRA_SCOPE (bscope);
- gsize asize;
- guint32 *vdata =
- (guint32 *) gst_buffer_map (video, NULL, NULL, GST_MAP_WRITE);
- gint16 *adata = (gint16 *) gst_buffer_map (audio, &asize, NULL, GST_MAP_READ);
- gint16 *mono_adata = (gint16 *) g_memdup (adata, asize);
+ gint16 *mono_adata;
GstFFTS16Complex *fdata = scope->freq_data;
guint x, y, off;
guint l, h = bscope->height - 1;
gfloat fr, fi;
guint w = bscope->width;
+ GstMapInfo amap, vmap;
+ guint32 *vdata;
+
+ gst_buffer_map (audio, &amap, GST_MAP_READ);
+ gst_buffer_map (video, &vmap, GST_MAP_WRITE);
+ vdata = (guint32 *) vmap.data;
+
+ mono_adata = (gint16 *) g_memdup (amap.data, amap.size);
if (bscope->channels > 1) {
guint ch = bscope->channels;
- guint num_samples = asize / (ch * sizeof (gint16));
+ guint num_samples = amap.size / (ch * sizeof (gint16));
guint i, c, v, s = 0;
/* deinterleave and mixdown adata */
/* run fft */
gst_fft_s16_window (scope->fft_ctx, mono_adata, GST_FFT_WINDOW_HAMMING);
gst_fft_s16_fft (scope->fft_ctx, mono_adata, fdata);
- g_free (adata);
+ g_free (mono_adata);
/* draw lines */
for (x = 0; x < bscope->width; x++) {
add_pixel (&vdata[off], 0x007F7F7F);
}
}
- gst_buffer_unmap (video, vdata, -1);
- gst_buffer_unmap (audio, adata, -1);
+ gst_buffer_unmap (video, &vmap);
+ gst_buffer_unmap (audio, &amap);
return TRUE;
}
GstBuffer * video)
{
GstSynaeScope *scope = GST_SYNAE_SCOPE (bscope);
- gsize asize;
- guint32 *vdata =
- (guint32 *) gst_buffer_map (video, NULL, NULL, GST_MAP_WRITE);
- gint16 *adata = (gint16 *) gst_buffer_map (audio, &asize, NULL, GST_MAP_READ);
+ GstMapInfo amap, vmap;
+ guint32 *vdata;
+ gint16 *adata;
gint16 *adata_l = scope->adata_l;
gint16 *adata_r = scope->adata_r;
GstFFTS16Complex *fdata_l = scope->freq_data_l;
guint *shade = scope->shade;
//guint w2 = w /2;
guint ch = bscope->channels;
- guint num_samples = asize / (ch * sizeof (gint16));
+ guint num_samples;
gint i, j, b;
gint br, br1, br2;
gint clarity;
gdouble frl, fil, frr, fir;
const guint sl = 30;
+ gst_buffer_map (video, &vmap, GST_MAP_WRITE);
+ gst_buffer_map (audio, &amap, GST_MAP_READ);
+
+ vdata = (guint32 *) vmap.data;
+ adata = (gint16 *) amap.data;
+
+ num_samples = amap.size / (ch * sizeof (gint16));
+
/* deinterleave */
for (i = 0, j = 0; i < num_samples; i++) {
adata_l[i] = adata[j++];
}
}
}
+ gst_buffer_unmap (video, &vmap);
+ gst_buffer_unmap (audio, &amap);
return TRUE;
}
GstBuffer * video)
{
GstWaveScope *scope = GST_WAVE_SCOPE (base);
- guint32 *vdata;
- gsize asize;
- gint16 *adata;
+ GstMapInfo amap, vmap;
guint num_samples;
- adata = gst_buffer_map (audio, &asize, NULL, GST_MAP_READ);
- vdata = gst_buffer_map (video, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (audio, &amap, GST_MAP_READ);
+ gst_buffer_map (video, &vmap, GST_MAP_WRITE);
- num_samples = asize / (base->channels * sizeof (gint16));
- scope->process (base, vdata, adata, num_samples);
+ num_samples = amap.size / (base->channels * sizeof (gint16));
+ scope->process (base, (guint32 *) vmap.data, (gint16 *) amap.data,
+ num_samples);
- gst_buffer_unmap (video, vdata, -1);
- gst_buffer_unmap (audio, adata, -1);
+ gst_buffer_unmap (video, &vmap);
+ gst_buffer_unmap (audio, &amap);
return TRUE;
}
GstBuffer * outbuf)
{
GstBayer2RGB *filter = GST_BAYER2RGB (base);
- uint8_t *input, *output;
+ GstMapInfo map;
+ uint8_t *output;
GstVideoFrame frame;
GST_DEBUG ("transforming buffer");
- input = gst_buffer_map (inbuf, NULL, NULL, GST_MAP_READ);
+ gst_buffer_map (inbuf, &map, GST_MAP_READ);
gst_video_frame_map (&frame, &filter->info, inbuf, GST_MAP_WRITE);
output = GST_VIDEO_FRAME_PLANE_DATA (&frame, 0);
gst_bayer2rgb_process (filter, output, filter->width * 4,
- input, filter->width);
+ map.data, filter->width);
gst_video_frame_unmap (&frame);
- gst_buffer_unmap (inbuf, input, -1);
+ gst_buffer_unmap (inbuf, &map);
return GST_FLOW_OK;
}
GstBuffer * outbuf)
{
GstRGB2Bayer *rgb2bayer = GST_RGB_2_BAYER (trans);
+ GstMapInfo map;
guint8 *dest;
guint8 *src;
int i, j;
gst_video_frame_map (&frame, &rgb2bayer->info, inbuf, GST_MAP_READ);
- dest = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_READ);
+ gst_buffer_map (outbuf, &map, GST_MAP_READ);
+ dest = map.data;
src = GST_VIDEO_FRAME_PLANE_DATA (&frame, 0);
for (j = 0; j < height; j++) {
}
}
}
- gst_buffer_unmap (outbuf, dest, -1);
+ gst_buffer_unmap (outbuf, &map);
gst_video_frame_unmap (&frame);
return GST_FLOW_OK;
gint dtmf_count;
gchar dtmfbuf[MAX_DTMF_DIGITS] = "";
gint i;
- gpointer data;
- gsize size;
+ GstMapInfo map;
if (GST_BUFFER_IS_DISCONT (buf))
zap_dtmf_detect_init (&self->dtmf_state);
if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP))
return GST_FLOW_OK;
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
- zap_dtmf_detect (&self->dtmf_state, (gint16 *) data, size / 2, FALSE);
+ zap_dtmf_detect (&self->dtmf_state, (gint16 *) map.data, map.size / 2, FALSE);
dtmf_count = zap_dtmf_get (&self->dtmf_state, dtmfbuf, MAX_DTMF_DIGITS);
else
GST_LOG_OBJECT (self, "Got no DTMF events");
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
for (i = 0; i < dtmf_count; i++) {
GstMessage *dtmf_message = NULL;
float duration, gint sample_rate)
{
GstBuffer *buffer;
+ GstMapInfo map;
gint16 *p;
gint tone_size;
double i = 0;
buffer = gst_buffer_new_allocate (NULL, tone_size, 1);
- p = (gint16 *) gst_buffer_map (buffer, NULL, NULL, GST_MAP_READWRITE);
+ gst_buffer_map (buffer, &map, GST_MAP_READWRITE);
+ p = (gint16 *) map.data;
volume_factor = pow (10, (-event->volume) / 20);
(event->sample)++;
}
- gst_buffer_unmap (buffer, p, tone_size);
+ gst_buffer_unmap (buffer, &map);
return buffer;
}
GstRTPDTMFPayload payload)
{
GstBuffer *buf;
+ GstMapInfo map;
gint16 *p;
gint tone_size;
double i = 0;
GST_BUFFER_DURATION (buf) = payload.duration * GST_SECOND / clock_rate;
volume = payload.volume;
- p = (gint16 *) gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (buf, &map, GST_MAP_WRITE);
+ p = (gint16 *) map.data;
volume_factor = pow (10, (-volume) / 20);
(rtpdtmfdepay->sample)++;
}
- gst_buffer_unmap (buf, p, tone_size);
+ gst_buffer_unmap (buf, &map);
return buf;
}
gst_dvbsub_overlay_process_text (GstDVBSubOverlay * overlay, GstBuffer * buffer,
guint64 pts)
{
- guint8 *data;
- gsize size;
+ GstMapInfo map;
GST_DEBUG_OBJECT (overlay,
"Processing subtitles with fake PTS=%" G_GUINT64_FORMAT
" which is a running time of %" GST_TIME_FORMAT,
pts, GST_TIME_ARGS (pts));
- GST_DEBUG_OBJECT (overlay, "Feeding %" G_GSIZE_FORMAT " bytes to libdvbsub",
- size);
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
+
+ GST_DEBUG_OBJECT (overlay, "Feeding %" G_GSIZE_FORMAT " bytes to libdvbsub",
+ map.size);
g_mutex_lock (&overlay->dvbsub_mutex);
- dvb_sub_feed_with_pts (overlay->dvb_sub, pts, data, size);
+ dvb_sub_feed_with_pts (overlay->dvb_sub, pts, map.data, map.size);
g_mutex_unlock (&overlay->dvbsub_mutex);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer);
}
* we've collected */
guint8 packet_type;
guint16 packet_size;
- guint8 *data, *ptr, *end;
- gsize size;
+ GstMapInfo map;
+ guint8 *ptr, *end;
gboolean invalid = FALSE;
- data = gst_buffer_map (dvdspu->partial_spu, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (dvdspu->partial_spu, &map, GST_MAP_READ);
- ptr = data;
- end = ptr + size;
+ ptr = map.data;
+ end = ptr + map.size;
/* FIXME: There's no need to walk the command set each time. We can set a
* marker and resume where we left off next time */
break;
}
}
- gst_buffer_unmap (dvdspu->partial_spu, data, size);
+ gst_buffer_unmap (dvdspu->partial_spu, &map);
if (invalid) {
gst_buffer_unref (dvdspu->partial_spu);
} else if (ptr == end) {
GST_DEBUG_OBJECT (dvdspu,
"Have complete PGS packet of size %" G_GSIZE_FORMAT ". Enqueueing.",
- size);
+ map.size);
submit_new_spu_packet (dvdspu, dvdspu->partial_spu);
dvdspu->partial_spu = NULL;
}
gint
gstspu_exec_pgs_buffer (GstDVDSpu * dvdspu, GstBuffer * buf)
{
- guint8 *data, *pos, *end;
- gsize size;
+ GstMapInfo map;
+ guint8 *pos, *end;
guint8 type;
guint16 packet_len;
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
- pos = data;
- end = pos + size;
+ pos = map.data;
+ end = pos + map.size;
/* Need at least 3 bytes */
if (pos + 3 > end) {
pos += 2;
if (pos + packet_len > end) {
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
PGS_DUMP ("Invalid packet length %u (only have %u bytes)\n", packet_len,
end - pos);
goto error;
} while (pos + 3 <= end);
PGS_DUMP ("End dumping command buffer with %u bytes remaining\n", end - pos);
- return (pos - data);
+ return (pos - map.data);
/* ERRORS */
error:
{
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
return -1;
}
}
gstspu_vobsub_handle_new_buf (GstDVDSpu * dvdspu, GstClockTime event_ts,
GstBuffer * buf)
{
+ GstMapInfo map;
guint8 *start, *end;
- gsize size;
SpuState *state = &dvdspu->spu_state;
#if DUMP_DCSQ
state->vobsub.buf = buf;
state->vobsub.base_ts = event_ts;
- start = gst_buffer_map (state->vobsub.buf, &size, NULL, GST_MAP_READ);
- end = start + size;
+ gst_buffer_map (state->vobsub.buf, &map, GST_MAP_READ);
+ start = map.data;
+ end = start + map.size;
/* Configure the first command block in this buffer as our initial blk */
state->vobsub.cur_cmd_blk = GST_READ_UINT16_BE (start + 2);
g_free (state->vobsub.line_ctrl_i);
state->vobsub.line_ctrl_i = NULL;
}
- gst_buffer_unmap (state->vobsub.buf, start, size);
+ gst_buffer_unmap (state->vobsub.buf, &map);
return;
invalid:
gboolean
gstspu_vobsub_execute_event (GstDVDSpu * dvdspu)
{
+ GstMapInfo map;
guint8 *start, *cmd_blk, *end;
guint16 next_blk;
- gsize size;
SpuState *state = &dvdspu->spu_state;
if (state->vobsub.buf == NULL)
" @ offset %u", GST_TIME_ARGS (state->next_ts),
state->vobsub.cur_cmd_blk);
- start = gst_buffer_map (state->vobsub.buf, &size, NULL, GST_MAP_READ);
- end = start + size;
+ gst_buffer_map (state->vobsub.buf, &map, GST_MAP_READ);
+ start = map.data;
+ end = start + map.size;
cmd_blk = start + state->vobsub.cur_cmd_blk;
if (G_UNLIKELY (cmd_blk + 5 >= end)) {
- gst_buffer_unmap (state->vobsub.buf, start, size);
+ gst_buffer_unmap (state->vobsub.buf, &map);
/* Invalid. Finish the buffer and loop again */
gst_dvd_spu_finish_spu_buf (dvdspu);
return FALSE;
} else {
/* Next Block points to the current block, so we're finished with this
* SPU buffer */
- gst_buffer_unmap (state->vobsub.buf, start, size);
+ gst_buffer_unmap (state->vobsub.buf, &map);
gst_dvd_spu_finish_spu_buf (dvdspu);
return FALSE;
}
- gst_buffer_unmap (state->vobsub.buf, start, size);
+ gst_buffer_unmap (state->vobsub.buf, &map);
return TRUE;
}
/* table ids 0x70 - 0x73 do not have a crc */
if (G_LIKELY (section->table_id < 0x70 || section->table_id > 0x73)) {
- gpointer data;
- gsize size;
+ GstMapInfo map;
- data = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ);
- if (G_UNLIKELY (mpegts_base_calc_crc32 (data, size) != 0)) {
- gst_buffer_unmap (section->buffer, data, size);
+ gst_buffer_map (section->buffer, &map, GST_MAP_READ);
+ if (G_UNLIKELY (mpegts_base_calc_crc32 (map.data, map.size) != 0)) {
+ gst_buffer_unmap (section->buffer, &map);
GST_WARNING_OBJECT (base, "bad crc in psi pid 0x%x", section->pid);
return FALSE;
}
- gst_buffer_unmap (section->buffer, data, size);
+ gst_buffer_unmap (section->buffer, &map);
}
switch (section->table_id) {
packet->data = data;
- gst_buffer_unmap (packet->buffer, packet->bufdata, packet->bufsize);
+ gst_buffer_unmap (packet->buffer, &packet->bufmap);
if (packet->adaptation_field_control & 0x02)
if (!mpegts_packetizer_parse_adaptation_field_control (packetizer, packet))
mpegts_packetizer_parse_section_header (MpegTSPacketizer2 * packetizer,
MpegTSPacketizerStream * stream, MpegTSPacketizerSection * section)
{
+ GstMapInfo map;
guint8 tmp;
- guint8 *bufdata, *data, *crc_data;
- gsize size;
+ guint8 *data, *crc_data;
MpegTSPacketizerStreamSubtable *subtable;
GSList *subtable_list = NULL;
/* get the section buffer, pass the ownership to the caller */
section->buffer = gst_adapter_take_buffer (stream->section_adapter,
3 + stream->section_length);
- bufdata = data = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ);
+ gst_buffer_map (section->buffer, &map, GST_MAP_READ);
+ data = map.data;
GST_BUFFER_OFFSET (section->buffer) = stream->offset;
section->table_id = *data++;
goto not_applicable;
/* CRC is at the end of the section */
- crc_data = bufdata + size - 4;
+ crc_data = map.data + map.size - 4;
section->crc = GST_READ_UINT32_BE (crc_data);
if (section->version_number == subtable->version_number &&
subtable->crc = section->crc;
stream->section_table_id = section->table_id;
- gst_buffer_unmap (section->buffer, bufdata, size);
+ gst_buffer_unmap (section->buffer, &map);
return TRUE;
section->pid, section->table_id, section->subtable_extension,
section->current_next_indicator, section->version_number, section->crc);
section->complete = FALSE;
- gst_buffer_unmap (section->buffer, bufdata, size);
+ gst_buffer_unmap (section->buffer, &map);
gst_buffer_unref (section->buffer);
return TRUE;
}
MpegTSPacketizerSection * section)
{
GstStructure *pat_info = NULL;
- guint8 *bufdata, *data, *end;
- gsize size;
+ GstMapInfo map;
+ guint8 *data, *end;
guint transport_stream_id;
guint8 tmp;
guint program_number;
GstStructure *entry = NULL;
gchar *struct_name;
- bufdata = data = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ);
+ gst_buffer_map (section->buffer, &map, GST_MAP_READ);
+ data = map.data;
section->table_id = *data++;
section->section_length = GST_READ_UINT16_BE (data) & 0x0FFF;
g_value_init (&entries, GST_TYPE_LIST);
/* stop at the CRC */
- end = bufdata + size;
+ end = map.data + map.size;
while (data < end - 4) {
program_number = GST_READ_UINT16_BE (data);
gst_structure_id_set_value (pat_info, QUARK_PROGRAMS, &entries);
g_value_unset (&entries);
- gst_buffer_unmap (section->buffer, bufdata, size);
+ gst_buffer_unmap (section->buffer, &map);
if (data != end - 4) {
/* FIXME: check the CRC before parsing the packet */
MpegTSPacketizerSection * section)
{
GstStructure *pmt = NULL;
- guint8 *bufdata, *data, *end;
- gsize size;
+ GstMapInfo map;
+ guint8 *data, *end;
guint16 program_number;
guint8 tmp;
guint pcr_pid;
GstStructure *stream_info = NULL;
gchar *struct_name;
- data = bufdata = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ);
+ gst_buffer_map (section->buffer, &map, GST_MAP_READ);
+ data = map.data;
/* fixed header + CRC == 16 */
- if (size < 16) {
+ if (map.size < 16) {
GST_WARNING ("PID %d invalid PMT size %d",
section->pid, section->section_length);
goto error;
}
- end = data + size;
+ end = map.data + map.size;
section->table_id = *data++;
section->section_length = GST_READ_UINT16_BE (data) & 0x0FFF;
gst_structure_id_set_value (pmt, QUARK_STREAMS, &programs);
g_value_unset (&programs);
- gst_buffer_unmap (section->buffer, bufdata, size);
+ gst_buffer_unmap (section->buffer, &map);
g_assert (data == end - 4);
error:
if (pmt)
gst_structure_free (pmt);
- gst_buffer_unmap (section->buffer, bufdata, size);
+ gst_buffer_unmap (section->buffer, &map);
return NULL;
}
MpegTSPacketizerSection * section)
{
GstStructure *nit = NULL, *transport = NULL, *delivery_structure = NULL;
- guint8 *bufdata, *data, *end, *entry_begin;
- gsize size;
+ GstMapInfo map;
+ guint8 *data, *end, *entry_begin;
guint16 network_id, transport_stream_id, original_network_id;
guint tmp;
guint16 descriptors_loop_length, transport_stream_loop_length;
GST_DEBUG ("NIT");
- data = bufdata = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ);
+ gst_buffer_map (section->buffer, &map, GST_MAP_READ);
+ data = map.data;
/* fixed header + CRC == 16 */
- if (size < 23) {
+ if (map.size < 23) {
GST_WARNING ("PID %d invalid NIT size %d",
section->pid, section->section_length);
goto error;
}
- end = data + size;
+ end = map.data + map.size;
section->table_id = *data++;
section->section_length = GST_READ_UINT16_BE (data) & 0x0FFF;
if (data != end - 4) {
GST_WARNING ("PID %d invalid NIT parsed %d length %" G_GSIZE_FORMAT,
- section->pid, (gint) (data - bufdata), size);
+ section->pid, (gint) (data - map.data), map.size);
goto error;
}
gst_structure_id_set_value (nit, QUARK_TRANSPORTS, &transports);
g_value_unset (&transports);
- gst_buffer_unmap (section->buffer, bufdata, size);
+ gst_buffer_unmap (section->buffer, &map);
GST_DEBUG ("NIT %" GST_PTR_FORMAT, nit);
if (nit)
gst_structure_free (nit);
- gst_buffer_unmap (section->buffer, bufdata, size);
+ gst_buffer_unmap (section->buffer, &map);
if (GST_VALUE_HOLDS_LIST (&transports))
g_value_unset (&transports);
mpegts_packetizer_parse_sdt (MpegTSPacketizer2 * packetizer,
MpegTSPacketizerSection * section)
{
+ GstMapInfo map;
GstStructure *sdt = NULL, *service = NULL;
- guint8 *data, *bufdata, *end, *entry_begin;
- gsize size;
+ guint8 *data, *end, *entry_begin;
guint16 transport_stream_id, original_network_id, service_id;
guint tmp;
guint sdt_info_length;
GST_DEBUG ("SDT");
- data = bufdata = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ);
+ gst_buffer_map (section->buffer, &map, GST_MAP_READ);
+ data = map.data;
/* fixed header + CRC == 16 */
- if (size < 14) {
+ if (map.size < 14) {
GST_WARNING ("PID %d invalid SDT size %d",
section->pid, section->section_length);
goto error;
}
- end = data + size;
+ end = map.data + map.size;
section->table_id = *data++;
section->section_length = GST_READ_UINT16_BE (data) & 0x0FFF;
if (data != end - 4) {
GST_WARNING ("PID %d invalid SDT parsed %d length %" G_GSIZE_FORMAT,
- section->pid, (gint) (data - bufdata), size);
+ section->pid, (gint) (data - map.data), map.size);
goto error;
}
gst_structure_id_set_value (sdt, QUARK_SERVICES, &services);
g_value_unset (&services);
- gst_buffer_unmap (section->buffer, bufdata, size);
+ gst_buffer_unmap (section->buffer, &map);
return sdt;
if (sdt)
gst_structure_free (sdt);
- gst_buffer_unmap (section->buffer, bufdata, size);
+ gst_buffer_unmap (section->buffer, &map);
if (GST_VALUE_HOLDS_LIST (&services))
g_value_unset (&services);
guint16 mjd;
guint year, month, day, hour, minute, second;
guint duration;
- guint8 *data, *bufdata, *end, *duration_ptr, *utc_ptr;
- gsize size;
+ GstMapInfo map;
+ guint8 *data, *end, *duration_ptr, *utc_ptr;
guint16 descriptors_loop_length;
GValue events = { 0 };
GValue event_value = { 0 };
gchar *event_name;
guint tmp;
- data = bufdata = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ);
+ gst_buffer_map (section->buffer, &map, GST_MAP_READ);
+ data = map.data;
/* fixed header + CRC == 16 */
- if (size < 18) {
+ if (map.size < 18) {
GST_WARNING ("PID %d invalid EIT size %d",
section->pid, section->section_length);
goto error;
}
- end = data + size;
+ end = map.data + map.size;
section->table_id = *data++;
section->section_length = GST_READ_UINT16_BE (data) & 0x0FFF;
if (data != end - 4) {
GST_WARNING ("PID %d invalid EIT parsed %d length %" G_GSIZE_FORMAT,
- section->pid, (gint) (data - bufdata), size);
+ section->pid, (gint) (data - map.data), map.size);
goto error;
}
gst_structure_id_set_value (eit, QUARK_EVENTS, &events);
g_value_unset (&events);
- gst_buffer_unmap (section->buffer, bufdata, size);
+ gst_buffer_unmap (section->buffer, &map);
GST_DEBUG ("EIT %" GST_PTR_FORMAT, eit);
if (eit)
gst_structure_free (eit);
- gst_buffer_unmap (section->buffer, bufdata, size);
+ gst_buffer_unmap (section->buffer, &map);
if (GST_VALUE_HOLDS_LIST (&events))
g_value_unset (&events);
GstStructure *tdt = NULL;
guint16 mjd;
guint year, month, day, hour, minute, second;
- guint8 *data, *bufdata, *end, *utc_ptr;
- gsize size;
+ GstMapInfo map;
+ guint8 *data, *end, *utc_ptr;
GST_DEBUG ("TDT");
- data = bufdata = gst_buffer_map (section->buffer, &size, 0, GST_MAP_READ);
+ gst_buffer_map (section->buffer, &map, GST_MAP_READ);
+ data = map.data;
/* length always 8 */
- if (G_UNLIKELY (size != 8)) {
+ if (G_UNLIKELY (map.size != 8)) {
GST_WARNING ("PID %d invalid TDT size %d",
section->pid, section->section_length);
goto error;
}
- end = data + size;
+ end = map.data + map.size;
section->table_id = *data++;
section->section_length = GST_READ_UINT16_BE (data) & 0x0FFF;
"hour", G_TYPE_UINT, hour,
"minute", G_TYPE_UINT, minute, "second", G_TYPE_UINT, second, NULL);
- gst_buffer_unmap (section->buffer, bufdata, size);
+ gst_buffer_unmap (section->buffer, &map);
return tdt;
if (tdt)
gst_structure_free (tdt);
- gst_buffer_unmap (section->buffer, bufdata, size);
+ gst_buffer_unmap (section->buffer, &map);
return NULL;
}
packet->buffer = gst_adapter_take_buffer (packetizer->adapter,
packetizer->packet_size);
- bufdata = packet->bufdata = packet->data_start =
- gst_buffer_map (packet->buffer, &packet->bufsize, 0, GST_MAP_READ);
+ gst_buffer_map (packet->buffer, &packet->bufmap, GST_MAP_READ);
+
+ bufdata = packet->data_start = packet->bufmap.data;
/* M2TS packets don't start with the sync byte, all other variants do */
if (packetizer->packet_size == MPEGTS_M2TS_PACKETSIZE)
if (G_UNLIKELY (i == packetizer->packet_size)) {
GST_ERROR ("REALLY lost the sync");
- gst_buffer_unmap (packet->buffer, bufdata, packet->bufsize);
+ gst_buffer_unmap (packet->buffer, &packet->bufmap);
gst_buffer_unref (packet->buffer);
goto done;
}
}
/* Pop out the remaining data... */
- gst_buffer_resize (packet->buffer, i, packet->bufsize - i);
+ gst_buffer_resize (packet->buffer, i, packet->bufmap.size - i);
GST_BUFFER_OFFSET (packet->buffer) += i;
tmpbuf =
gst_adapter_take_buffer (packetizer->adapter,
section->section_length = GST_READ_UINT24_BE (data) & 0x000FFF;
section->buffer =
gst_buffer_copy_region (packet->buffer, GST_BUFFER_COPY_ALL,
- data - packet->bufdata, section->section_length + 3);
+ data - packet->bufmap.data, section->section_length + 3);
section->table_id = table_id;
section->complete = TRUE;
res = TRUE;
/* create a sub buffer from the start of the section (table_id and
* section_length included) to the end */
sub_buf = gst_buffer_copy_region (packet->buffer, GST_BUFFER_COPY_ALL,
- data - packet->bufdata, packet->data_end - data);
+ data - packet->bufmap.data, packet->data_end - data);
stream = packetizer->streams[packet->pid];
guint8 continuity_counter;
guint8 *payload;
- /* temporary copies of gst_buffer_map */
- guint8 *bufdata;
- gsize bufsize;
+ /* gst_buffer_map */
+ GstMapInfo bufmap;
guint8 *data_start; /* Location of 0x47 marker byte */
guint8 *data_end;
for (i = 0; (i < 20) && (nbpcr < numpcr); i++) {
guint offset;
- gsize size, bufsize;
- gpointer data;
+ GstMapInfo map;
+ gsize size;
ret =
gst_pad_pull_range (base->sinkpad,
if (G_UNLIKELY (ret != GST_FLOW_OK))
goto beach;
- data = gst_buffer_map (buf, &bufsize, 0, GST_MAP_READ);
- size = bufsize;
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ size = map.size;
- gst_byte_reader_init (&br, data, size);
+ gst_byte_reader_init (&br, map.data, map.size);
offset = 0;
0, base->packetsize);
if (offset == -1) {
- gst_buffer_unmap (buf, data, bufsize);
+ gst_buffer_unmap (buf, &map);
continue;
}
size -= base->packetsize;
offset += base->packetsize;
}
- gst_buffer_unmap (buf, data, bufsize);
+ gst_buffer_unmap (buf, &map);
}
beach:
GstBuffer *buf = stream->pendingbuffers[0];
GstFlowReturn res = GST_FLOW_OK;
gint offset = 0;
- guint8 *data;
- gsize length;
+ GstMapInfo map;
guint64 bufferoffset;
PESParsingResult parseres;
GstClockTime origts;
- data = gst_buffer_map (buf, &length, 0, GST_MAP_READ);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
bufferoffset = GST_BUFFER_OFFSET (buf);
origts = GST_BUFFER_TIMESTAMP (buf);
- GST_MEMDUMP ("Header buffer", data, MIN (length, 32));
+ GST_MEMDUMP ("Header buffer", map.data, MIN (map.size, 32));
- parseres = mpegts_parse_pes_header (data, length, &header, &offset);
+ parseres = mpegts_parse_pes_header (map.data, map.size, &header, &offset);
if (G_UNLIKELY (parseres == PES_PARSING_NEED_MORE))
goto discont;
if (header.DTS != -1)
gst_ts_demux_record_dts (demux, stream, header.DTS, bufferoffset);
- gst_buffer_unmap (buf, data, length);
+ gst_buffer_unmap (buf, &map);
/* Remove PES headers */
GST_DEBUG ("Moving data forward by %d bytes", header.header_size);
- gst_buffer_resize (buf, header.header_size, length - header.header_size);
+ gst_buffer_resize (buf, header.header_size, map.size - header.header_size);
/* FIXME : responsible for switching to PENDING_PACKET_BUFFER and
* creating the bufferlist */
MpegTSPacketizerPacket * packet)
{
GstBuffer *buf;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
GST_DEBUG ("state:%d", stream->state);
buf = packet->buffer;
- data = gst_buffer_map (buf, &size, 0, GST_MAP_READ);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
GST_DEBUG ("Resizing buffer to %d (size:%d) (Was %" G_GSIZE_FORMAT
- " bytes long)", (int) (packet->payload - data),
- (int) (packet->data_end - packet->payload), size);
- gst_buffer_unmap (buf, data, size);
-
- gst_buffer_resize (buf, packet->payload - data,
+ " bytes long)", (int) (packet->payload - map.data),
+ (int) (packet->data_end - packet->payload), map.size);
+ gst_buffer_resize (buf, packet->payload - map.data,
packet->data_end - packet->payload);
+ gst_buffer_unmap (buf, &map);
if (stream->state == PENDING_PACKET_EMPTY) {
if (G_UNLIKELY (!packet->payload_unit_start_indicator)) {