if (client->sending) {
ssize_t wrote;
GstBuffer *head;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
/* pick first buffer from list */
head = GST_BUFFER (client->sending->data);
- data = gst_buffer_map (head, &size, NULL, GST_MAP_READ);
- maxsize = size - client->bufoffset;
+ gst_buffer_map (head, &map, GST_MAP_READ);
+ maxsize = map.size - client->bufoffset;
/* try to write the complete buffer */
#ifdef MSG_NOSIGNAL
#define FLAGS 0
#endif
if (client->is_socket) {
- wrote = send (fd, data + client->bufoffset, maxsize, FLAGS);
+ wrote = send (fd, map.data + client->bufoffset, maxsize, FLAGS);
} else {
- wrote = write (fd, data + client->bufoffset, maxsize);
+ wrote = write (fd, map.data + client->bufoffset, maxsize);
}
- gst_buffer_unmap (head, data, size);
+ gst_buffer_unmap (head, &map);
if (wrote < 0) {
/* hmm error.. */
GstBuffer *buf = frame->buffer;
GstByteReader reader;
gint off;
- gsize size;
- guint8 *data;
+ GstMapInfo map;
gboolean ret = FALSE;
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- if (G_UNLIKELY (size < 4))
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ if (G_UNLIKELY (map.size < 4))
goto exit;
- gst_byte_reader_init (&reader, data, size);
+ gst_byte_reader_init (&reader, map.data, map.size);
off = gst_byte_reader_masked_scan_uint32 (&reader, 0xffff0000,
- 0x24000000 + (IRTSPParse->channel_id << 16), 0, size);
+ 0x24000000 + (IRTSPParse->channel_id << 16), 0, map.size);
GST_LOG_OBJECT (parse, "possible sync at buffer offset %d", off);
/* didn't find anything that looks like a sync word, skip */
if (off < 0) {
- *skipsize = size - 3;
+ *skipsize = map.size - 3;
goto exit;
}
goto exit;
}
- *framesize = GST_READ_UINT16_BE (data + 2) + 4;
+ *framesize = GST_READ_UINT16_BE (map.data + 2) + 4;
GST_LOG_OBJECT (parse, "got frame size %d", *framesize);
ret = TRUE;
exit:
- gst_buffer_unmap (buf, data, -1);
+ gst_buffer_unmap (buf, &map);
return ret;
}
if (gst_pcap_parse_scan_frame (self, data, self->cur_packet_size,
&payload_data, &payload_size)) {
GstBuffer *out_buf;
- guint8 *data;
+ GstMapInfo map;
out_buf = gst_buffer_new_and_alloc (payload_size);
if (out_buf) {
}
}
- data = gst_buffer_map (out_buf, NULL, NULL, GST_MAP_WRITE);
- memcpy (data, payload_data, payload_size);
- gst_buffer_unmap (out_buf, data, -1);
+ gst_buffer_map (out_buf, &map, GST_MAP_WRITE);
+ memcpy (map.data, payload_data, payload_size);
+ gst_buffer_unmap (out_buf, &map);
GST_BUFFER_TIMESTAMP (out_buf) = self->cur_ts;
if (!self->newsegment_sent &&
GstBitReader *reader = NULL;
guint8 *data;
gsize size;
+ GstMapInfo map;
int i;
gboolean keyframe;
guint32 partition0_size;
if (G_UNLIKELY (gst_buffer_get_size (buffer) < 3))
goto error;
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
- if (data == NULL)
+ if (!gst_buffer_map (buffer, &map, GST_MAP_READ) || !map.data)
goto error;
+ data = map.data;
+ size = map.size;
reader = gst_bit_reader_new (data, size);
self->is_keyframe = keyframe = ((data[0] & 0x1) == 0);
self->partition_offset[i + 1] = size;
gst_bit_reader_free (reader);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
return TRUE;
error:
GST_DEBUG ("Failed to parse frame");
if (reader) {
gst_bit_reader_free (reader);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
}
return FALSE;
}
{
int off;
guint32 next_header;
+ GstMapInfo map;
guint8 *data;
gsize size;
gboolean have_picture = FALSE;
int offset;
- data = gst_buffer_map (frame->buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (frame->buffer, &map, GST_MAP_READ);
+ data = map.data;
+ size = map.size;
if (G_UNLIKELY (size < 13))
goto out;
}
}
- gst_buffer_unmap (frame->buffer, data, size);
+ gst_buffer_unmap (frame->buffer, &map);
*framesize = offset;
GST_DEBUG ("framesize %d", *framesize);
return TRUE;
out:
- gst_buffer_unmap (frame->buffer, data, size);
+ gst_buffer_unmap (frame->buffer, &map);
return FALSE;
}
gst_dirac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
{
GstDiracParse *diracparse = GST_DIRAC_PARSE (parse);
+ GstMapInfo map;
guint8 *data;
gsize size;
a checked frame. */
/* MUST implement */
- data = gst_buffer_map (frame->buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (frame->buffer, &map, GST_MAP_READ);
+ data = map.data;
+ size = map.size;
//GST_ERROR("got here %d", size);
}
}
- gst_buffer_unmap (frame->buffer, data, size);
+ gst_buffer_unmap (frame->buffer, &map);
gst_base_parse_set_min_frame_size (parse, 13);
static guint
find_psc (GstBuffer * buffer, guint skip)
{
- guint8 *buf_data;
- gsize buf_size;
+ GstMapInfo map;
GstByteReader br;
guint psc_pos = -1, psc;
- buf_data = gst_buffer_map (buffer, &buf_size, NULL, GST_MAP_READ);
- gst_byte_reader_init (&br, buf_data, buf_size);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
+ gst_byte_reader_init (&br, map.data, map.size);
if (!gst_byte_reader_set_pos (&br, skip))
goto out;
}
out:
- gst_buffer_unmap (buffer, buf_data, buf_size);
+ gst_buffer_unmap (buffer, &map);
return psc_pos;
}
{
GstH264Parse *h264parse = GST_H264_PARSE (parse);
GstBuffer *buffer = frame->buffer;
+ GstMapInfo map;
guint8 *data;
gsize size;
guint current_off = 0;
GstH264NalParser *nalparser = h264parse->nalparser;
GstH264NalUnit nalu;
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
+ data = map.data;
+ size = map.size;
/* expect at least 3 bytes startcode == sc, and 2 bytes NALU payload */
if (G_UNLIKELY (size < 5)) {
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
return FALSE;
}
*framesize = nalu.offset + nalu.size - h264parse->nalu.sc_offset;
h264parse->current_off = current_off;
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
return TRUE;
parsing_error:
/* Fall-through. */
out:
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
return FALSE;
invalid:
gint i, sps_size = 0, pps_size = 0, num_sps = 0, num_pps = 0;
guint8 profile_idc = 0, profile_comp = 0, level_idc = 0;
gboolean found = FALSE;
- guint8 *buf_data, *data;
+ GstMapInfo map;
+ guint8 *data;
/* only nal payload in stored nals */
return NULL;
buf = gst_buffer_new_allocate (NULL, 5 + 1 + sps_size + 1 + pps_size, 0);
- buf_data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
- data = buf_data;
+ gst_buffer_map (buf, &map, GST_MAP_WRITE);
+ data = map.data;
data[0] = 1; /* AVC Decoder Configuration Record ver. 1 */
data[1] = profile_idc; /* profile_idc */
}
}
- gst_buffer_unmap (buf, buf_data, -1);
+ gst_buffer_unmap (buf, &map);
return buf;
}
h264parse->align == GST_H264_PARSE_ALIGN_AU) {
buf = gst_h264_parse_make_codec_data (h264parse);
if (buf && h264parse->codec_data) {
- gsize size;
- gpointer data;
+ GstMapInfo map;
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- if (size != gst_buffer_get_size (h264parse->codec_data) ||
- gst_buffer_memcmp (h264parse->codec_data, 0, data, size))
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ if (map.size != gst_buffer_get_size (h264parse->codec_data) ||
+ gst_buffer_memcmp (h264parse->codec_data, 0, map.data, map.size))
modified = TRUE;
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
} else {
if (h264parse->codec_data)
buf = gst_buffer_ref (h264parse->codec_data);
gst_h264_parse_push_codec_buffer (GstH264Parse * h264parse, GstBuffer * nal,
GstClockTime ts)
{
- gpointer data;
- gsize size;
+ GstMapInfo map;
- data = gst_buffer_map (nal, &size, NULL, GST_MAP_READ);
- nal = gst_h264_parse_wrap_nal (h264parse, h264parse->format, data, size);
- gst_buffer_unmap (nal, data, size);
+ gst_buffer_map (nal, &map, GST_MAP_READ);
+ nal = gst_h264_parse_wrap_nal (h264parse, h264parse->format,
+ map.data, map.size);
+ gst_buffer_unmap (nal, &map);
GST_BUFFER_TIMESTAMP (nal) = ts;
GST_BUFFER_DURATION (nal) = 0;
/* packetized video has a codec_data */
if (format != GST_H264_PARSE_FORMAT_BYTE &&
(value = gst_structure_get_value (str, "codec_data"))) {
+ GstMapInfo map;
guint8 *data;
guint num_sps, num_pps, profile;
gint i;
codec_data = gst_value_get_buffer (value);
if (!codec_data)
goto wrong_type;
- data = gst_buffer_map (codec_data, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (codec_data, &map, GST_MAP_READ);
+ data = map.data;
+ size = map.size;
/* parse the avcC data */
if (size < 8) {
- gst_buffer_unmap (codec_data, data, size);
+ gst_buffer_unmap (codec_data, &map);
goto avcc_too_small;
}
/* parse the version, this must be 1 */
if (data[0] != 1) {
- gst_buffer_unmap (codec_data, data, size);
+ gst_buffer_unmap (codec_data, &map);
goto wrong_version;
}
parseres = gst_h264_parser_identify_nalu_avc (h264parse->nalparser,
data, off, size, 2, &nalu);
if (parseres != GST_H264_PARSER_OK) {
- gst_buffer_unmap (codec_data, data, size);
+ gst_buffer_unmap (codec_data, &map);
goto avcc_too_small;
}
parseres = gst_h264_parser_identify_nalu_avc (h264parse->nalparser,
data, off, size, 2, &nalu);
if (parseres != GST_H264_PARSER_OK) {
- gst_buffer_unmap (codec_data, data, size);
+ gst_buffer_unmap (codec_data, &map);
goto avcc_too_small;
}
off = nalu.offset + nalu.size;
}
- gst_buffer_unmap (codec_data, data, size);
+ gst_buffer_unmap (codec_data, &map);
h264parse->codec_data = gst_buffer_ref (codec_data);
GstH264ParserResult parse_res;
GstH264NalUnit nalu;
const guint nl = h264parse->nal_length_size;
- gpointer data;
- gsize size;
+ GstMapInfo map;
if (nl < 1 || nl > 4) {
GST_DEBUG_OBJECT (h264parse, "insufficient data to split input");
return GST_FLOW_NOT_NEGOTIATED;
}
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
GST_LOG_OBJECT (h264parse,
- "processing packet buffer of size %" G_GSIZE_FORMAT, size);
+ "processing packet buffer of size %" G_GSIZE_FORMAT, map.size);
parse_res = gst_h264_parser_identify_nalu_avc (h264parse->nalparser,
- data, 0, size, nl, &nalu);
+ map.data, 0, map.size, nl, &nalu);
while (parse_res == GST_H264_PARSER_OK) {
GST_DEBUG_OBJECT (h264parse, "AVC nal offset %d",
}
parse_res = gst_h264_parser_identify_nalu_avc (h264parse->nalparser,
- data, nalu.offset + nalu.size, size, nl, &nalu);
+ map.data, nalu.offset + nalu.size, map.size, nl, &nalu);
}
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
if (h264parse->split_packetized) {
gst_buffer_unref (buffer);
{
GstMpeg4VParse *mp4vparse = GST_MPEG4VIDEO_PARSE (parse);
GstMpeg4Packet packet;
+ GstMapInfo map;
guint8 *data = NULL;
gsize size;
gint off = 0;
gboolean ret = FALSE;
- data = gst_buffer_map (frame->buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (frame->buffer, &map, GST_MAP_READ);
+ data = map.data;
+ size = map.size;
retry:
/* at least start code and subsequent byte */
}
out:
- gst_buffer_unmap (frame->buffer, data, size);
+ gst_buffer_unmap (frame->buffer, &map);
return ret;
}
"interval since last config %" GST_TIME_FORMAT, GST_TIME_ARGS (diff));
if (GST_TIME_AS_SECONDS (diff) >= mp4vparse->interval || push_codec) {
- guint8 *cdata;
+ GstMapInfo cmap;
gsize csize;
gboolean diffconf;
/* we need to send config now first */
GST_INFO_OBJECT (parse, "inserting config in stream");
- cdata = gst_buffer_map (mp4vparse->config, &csize, NULL, GST_MAP_READ);
- diffconf = (gst_buffer_get_size (buffer) < csize)
- || gst_buffer_memcmp (buffer, 0, cdata, csize);
- gst_buffer_unmap (mp4vparse->config, cdata, csize);
+ gst_buffer_map (mp4vparse->config, &cmap, GST_MAP_READ);
+ diffconf = (gst_buffer_get_size (buffer) < cmap.size)
+ || gst_buffer_memcmp (buffer, 0, cmap.data, cmap.size);
+ csize = cmap.size;
+ gst_buffer_unmap (mp4vparse->config, &cmap);
/* avoid inserting duplicate config */
if (diffconf) {
GstStructure *s;
const GValue *value;
GstBuffer *buf;
+ GstMapInfo map;
guint8 *data;
gsize size;
/* best possible parse attempt,
* src caps are based on sink caps so it will end up in there
* whether sucessful or not */
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ data = map.data;
+ size = map.size;
res = gst_mpeg4_parse (&packet, TRUE, NULL, data, 0, size);
while (res == GST_MPEG4_PARSER_OK || res == GST_MPEG4_PARSER_NO_PACKET_END) {
/* And take it as config */
gst_mpeg4vparse_process_config (mp4vparse, data, 3, size);
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
}
/* let's not interfere and accept regardless of config parsing success */
guint size)
{
GList *tmp;
- guint8 *buf_data, *data;
- gsize buf_size;
+ GstMapInfo map;
+ guint8 *data;
- buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
- data = buf_data + mpvparse->seq_offset;
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ data = map.data + mpvparse->seq_offset;
/* only do stuff if something new */
if (mpvparse->config && size == gst_buffer_get_size (mpvparse->config) &&
gst_buffer_memcmp (mpvparse->config, 0, data, size) == 0) {
- gst_buffer_unmap (buf, buf_data, buf_size);
+ gst_buffer_unmap (buf, &map);
return TRUE;
}
if (gst_mpeg_video_parse_sequence_header (&mpvparse->sequencehdr, data,
- buf_size - mpvparse->seq_offset, 0)) {
+ map.size - mpvparse->seq_offset, 0)) {
if (mpvparse->fps_num == 0 || mpvparse->fps_den == 0) {
mpvparse->fps_num = mpvparse->sequencehdr.fps_n;
mpvparse->fps_den = mpvparse->sequencehdr.fps_d;
GST_DEBUG_OBJECT (mpvparse,
"failed to parse config data (size %d) at offset %d",
size, mpvparse->seq_offset);
- gst_buffer_unmap (buf, buf_data, buf_size);
+ gst_buffer_unmap (buf, &map);
return FALSE;
}
mpvparse->mpeg_version = 2;
if (gst_mpeg_video_parse_sequence_extension (&mpvparse->sequenceext,
- buf_data, buf_size, tpoffsz->offset)) {
+ map.data, map.size, tpoffsz->offset)) {
mpvparse->fps_num =
mpvparse->sequencehdr.fps_n * (mpvparse->sequenceext.fps_n_ext +
1) * 2;
/* trigger src caps update */
mpvparse->update_caps = TRUE;
- gst_buffer_unmap (buf, buf_data, buf_size);
+ gst_buffer_unmap (buf, &map);
return TRUE;
}
parse_picture_extension (GstMpegvParse * mpvparse, GstBuffer * buf, guint off)
{
GstMpegVideoPictureExt ext;
- gpointer data;
- gsize size;
+ GstMapInfo map;
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
- if (gst_mpeg_video_parse_picture_extension (&ext, data, size, off)) {
+ if (gst_mpeg_video_parse_picture_extension (&ext, map.data, map.size, off)) {
mpvparse->frame_repeat_count = 1;
if (ext.repeat_first_field) {
}
}
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
}
/* caller guarantees at least start code in @buf at @off */
/* extract some picture info if there is any in the frame being terminated */
if (ret && mpvparse->pic_offset >= 0 && mpvparse->pic_offset < off) {
- gsize size;
- gpointer data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ GstMapInfo map;
+ gst_buffer_map (buf, &map, GST_MAP_READ);
if (gst_mpeg_video_parse_picture_header (&mpvparse->pichdr,
- data, size, mpvparse->pic_offset))
+ map.data, map.size, mpvparse->pic_offset))
GST_LOG_OBJECT (mpvparse, "picture_coding_type %d (%s), ending"
"frame of size %d", mpvparse->pichdr.pic_type,
picture_type_name (mpvparse->pichdr.pic_type), off - 4);
GST_LOG_OBJECT (mpvparse, "Couldn't parse picture at offset %d",
mpvparse->pic_offset);
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
}
return ret;
gboolean ret = FALSE;
GList *tmp;
gint off = 0, fsize = -1;
- gpointer buf_data;
+ GstMapInfo map;
gsize buf_size;
update_frame_parsing_status (mpvparse, frame);
if (mpvparse->last_sc >= 0)
off = mpvparse->last_sc;
- buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
- mpvparse->typeoffsize = gst_mpeg_video_parse (buf_data, buf_size, off);
- gst_buffer_unmap (buf, buf_data, buf_size);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ buf_size = map.size;
+ mpvparse->typeoffsize = gst_mpeg_video_parse (map.data, map.size, off);
+ gst_buffer_unmap (buf, &map);
/* No sc found */
if (mpvparse->typeoffsize == NULL)
};
GstBitReader br;
- guint8 *buf_data;
- gsize buf_size;
+ GstMapInfo map;
guint8 tr;
guint32 psc = 0, temp32;
guint8 temp8, pquant;
gboolean hasplusptype;
- buf_data = gst_buffer_map (buffer, &buf_size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
/* FIXME: we can optimise a little by checking the value of available
* instead of calling using the bit reader's get_bits_* functions. */
- gst_bit_reader_init (&br, buf_data, buf_size);
+ gst_bit_reader_init (&br, map.data, map.size);
/* Default PCF is CIF PCF = 30000/1001 */
params->pcfnum = 30000;
done:
*state = GOT_HEADER;
more:
- gst_buffer_unmap (buffer, buf_data, buf_size);
+ gst_buffer_unmap (buffer, &map);
return GST_FLOW_OK;
beach:
*state = PASSTHROUGH;
- gst_buffer_unmap (buffer, buf_data, buf_size);
+ gst_buffer_unmap (buffer, &map);
return GST_FLOW_OK;
}