port some more to new memory API
This commit is contained in:
parent
21073e98cf
commit
9dc7571c75
@ -1974,14 +1974,13 @@ gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink,
|
|||||||
if (client->sending) {
|
if (client->sending) {
|
||||||
ssize_t wrote;
|
ssize_t wrote;
|
||||||
GstBuffer *head;
|
GstBuffer *head;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
/* pick first buffer from list */
|
/* pick first buffer from list */
|
||||||
head = GST_BUFFER (client->sending->data);
|
head = GST_BUFFER (client->sending->data);
|
||||||
|
|
||||||
data = gst_buffer_map (head, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (head, &map, GST_MAP_READ);
|
||||||
maxsize = size - client->bufoffset;
|
maxsize = map.size - client->bufoffset;
|
||||||
|
|
||||||
/* try to write the complete buffer */
|
/* try to write the complete buffer */
|
||||||
#ifdef MSG_NOSIGNAL
|
#ifdef MSG_NOSIGNAL
|
||||||
@ -1990,11 +1989,11 @@ gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink,
|
|||||||
#define FLAGS 0
|
#define FLAGS 0
|
||||||
#endif
|
#endif
|
||||||
if (client->is_socket) {
|
if (client->is_socket) {
|
||||||
wrote = send (fd, data + client->bufoffset, maxsize, FLAGS);
|
wrote = send (fd, map.data + client->bufoffset, maxsize, FLAGS);
|
||||||
} else {
|
} 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) {
|
if (wrote < 0) {
|
||||||
/* hmm error.. */
|
/* hmm error.. */
|
||||||
|
@ -166,24 +166,23 @@ gst_irtsp_parse_check_valid_frame (GstBaseParse * parse,
|
|||||||
GstBuffer *buf = frame->buffer;
|
GstBuffer *buf = frame->buffer;
|
||||||
GstByteReader reader;
|
GstByteReader reader;
|
||||||
gint off;
|
gint off;
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
guint8 *data;
|
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
if (G_UNLIKELY (size < 4))
|
if (G_UNLIKELY (map.size < 4))
|
||||||
goto exit;
|
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,
|
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);
|
GST_LOG_OBJECT (parse, "possible sync at buffer offset %d", off);
|
||||||
|
|
||||||
/* didn't find anything that looks like a sync word, skip */
|
/* didn't find anything that looks like a sync word, skip */
|
||||||
if (off < 0) {
|
if (off < 0) {
|
||||||
*skipsize = size - 3;
|
*skipsize = map.size - 3;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,12 +192,12 @@ gst_irtsp_parse_check_valid_frame (GstBaseParse * parse,
|
|||||||
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);
|
GST_LOG_OBJECT (parse, "got frame size %d", *framesize);
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
gst_buffer_unmap (buf, data, -1);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,7 @@ gst_pcap_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||||||
if (gst_pcap_parse_scan_frame (self, data, self->cur_packet_size,
|
if (gst_pcap_parse_scan_frame (self, data, self->cur_packet_size,
|
||||||
&payload_data, &payload_size)) {
|
&payload_data, &payload_size)) {
|
||||||
GstBuffer *out_buf;
|
GstBuffer *out_buf;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
|
|
||||||
out_buf = gst_buffer_new_and_alloc (payload_size);
|
out_buf = gst_buffer_new_and_alloc (payload_size);
|
||||||
if (out_buf) {
|
if (out_buf) {
|
||||||
@ -485,9 +485,9 @@ gst_pcap_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data = gst_buffer_map (out_buf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (out_buf, &map, GST_MAP_WRITE);
|
||||||
memcpy (data, payload_data, payload_size);
|
memcpy (map.data, payload_data, payload_size);
|
||||||
gst_buffer_unmap (out_buf, data, -1);
|
gst_buffer_unmap (out_buf, &map);
|
||||||
GST_BUFFER_TIMESTAMP (out_buf) = self->cur_ts;
|
GST_BUFFER_TIMESTAMP (out_buf) = self->cur_ts;
|
||||||
|
|
||||||
if (!self->newsegment_sent &&
|
if (!self->newsegment_sent &&
|
||||||
|
@ -100,6 +100,7 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer)
|
|||||||
GstBitReader *reader = NULL;
|
GstBitReader *reader = NULL;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
GstMapInfo map;
|
||||||
int i;
|
int i;
|
||||||
gboolean keyframe;
|
gboolean keyframe;
|
||||||
guint32 partition0_size;
|
guint32 partition0_size;
|
||||||
@ -113,10 +114,11 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer)
|
|||||||
if (G_UNLIKELY (gst_buffer_get_size (buffer) < 3))
|
if (G_UNLIKELY (gst_buffer_get_size (buffer) < 3))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
if (!gst_buffer_map (buffer, &map, GST_MAP_READ) || !map.data)
|
||||||
if (data == NULL)
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
data = map.data;
|
||||||
|
size = map.size;
|
||||||
reader = gst_bit_reader_new (data, size);
|
reader = gst_bit_reader_new (data, size);
|
||||||
|
|
||||||
self->is_keyframe = keyframe = ((data[0] & 0x1) == 0);
|
self->is_keyframe = keyframe = ((data[0] & 0x1) == 0);
|
||||||
@ -255,14 +257,14 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer)
|
|||||||
self->partition_offset[i + 1] = size;
|
self->partition_offset[i + 1] = size;
|
||||||
|
|
||||||
gst_bit_reader_free (reader);
|
gst_bit_reader_free (reader);
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
GST_DEBUG ("Failed to parse frame");
|
GST_DEBUG ("Failed to parse frame");
|
||||||
if (reader) {
|
if (reader) {
|
||||||
gst_bit_reader_free (reader);
|
gst_bit_reader_free (reader);
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -219,12 +219,15 @@ gst_dirac_parse_check_valid_frame (GstBaseParse * parse,
|
|||||||
{
|
{
|
||||||
int off;
|
int off;
|
||||||
guint32 next_header;
|
guint32 next_header;
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
gboolean have_picture = FALSE;
|
gboolean have_picture = FALSE;
|
||||||
int offset;
|
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))
|
if (G_UNLIKELY (size < 13))
|
||||||
goto out;
|
goto out;
|
||||||
@ -286,7 +289,7 @@ gst_dirac_parse_check_valid_frame (GstBaseParse * parse,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (frame->buffer, data, size);
|
gst_buffer_unmap (frame->buffer, &map);
|
||||||
|
|
||||||
*framesize = offset;
|
*framesize = offset;
|
||||||
GST_DEBUG ("framesize %d", *framesize);
|
GST_DEBUG ("framesize %d", *framesize);
|
||||||
@ -294,7 +297,7 @@ gst_dirac_parse_check_valid_frame (GstBaseParse * parse,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
gst_buffer_unmap (frame->buffer, data, size);
|
gst_buffer_unmap (frame->buffer, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,6 +305,7 @@ static GstFlowReturn
|
|||||||
gst_dirac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
gst_dirac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
||||||
{
|
{
|
||||||
GstDiracParse *diracparse = GST_DIRAC_PARSE (parse);
|
GstDiracParse *diracparse = GST_DIRAC_PARSE (parse);
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
@ -309,7 +313,9 @@ gst_dirac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||||||
a checked frame. */
|
a checked frame. */
|
||||||
/* MUST implement */
|
/* 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_ERROR("got here %d", size);
|
||||||
|
|
||||||
@ -343,7 +349,7 @@ gst_dirac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (frame->buffer, data, size);
|
gst_buffer_unmap (frame->buffer, &map);
|
||||||
|
|
||||||
gst_base_parse_set_min_frame_size (parse, 13);
|
gst_base_parse_set_min_frame_size (parse, 13);
|
||||||
|
|
||||||
|
@ -151,13 +151,12 @@ gst_h263_parse_sink_event (GstBaseParse * parse, GstEvent * event)
|
|||||||
static guint
|
static guint
|
||||||
find_psc (GstBuffer * buffer, guint skip)
|
find_psc (GstBuffer * buffer, guint skip)
|
||||||
{
|
{
|
||||||
guint8 *buf_data;
|
GstMapInfo map;
|
||||||
gsize buf_size;
|
|
||||||
GstByteReader br;
|
GstByteReader br;
|
||||||
guint psc_pos = -1, psc;
|
guint psc_pos = -1, psc;
|
||||||
|
|
||||||
buf_data = gst_buffer_map (buffer, &buf_size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
gst_byte_reader_init (&br, buf_data, buf_size);
|
gst_byte_reader_init (&br, map.data, map.size);
|
||||||
|
|
||||||
if (!gst_byte_reader_set_pos (&br, skip))
|
if (!gst_byte_reader_set_pos (&br, skip))
|
||||||
goto out;
|
goto out;
|
||||||
@ -175,7 +174,7 @@ find_psc (GstBuffer * buffer, guint skip)
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
gst_buffer_unmap (buffer, buf_data, buf_size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return psc_pos;
|
return psc_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -627,6 +627,7 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse,
|
|||||||
{
|
{
|
||||||
GstH264Parse *h264parse = GST_H264_PARSE (parse);
|
GstH264Parse *h264parse = GST_H264_PARSE (parse);
|
||||||
GstBuffer *buffer = frame->buffer;
|
GstBuffer *buffer = frame->buffer;
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
guint current_off = 0;
|
guint current_off = 0;
|
||||||
@ -634,11 +635,13 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse,
|
|||||||
GstH264NalParser *nalparser = h264parse->nalparser;
|
GstH264NalParser *nalparser = h264parse->nalparser;
|
||||||
GstH264NalUnit nalu;
|
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 */
|
/* expect at least 3 bytes startcode == sc, and 2 bytes NALU payload */
|
||||||
if (G_UNLIKELY (size < 5)) {
|
if (G_UNLIKELY (size < 5)) {
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -770,7 +773,7 @@ end:
|
|||||||
*framesize = nalu.offset + nalu.size - h264parse->nalu.sc_offset;
|
*framesize = nalu.offset + nalu.size - h264parse->nalu.sc_offset;
|
||||||
h264parse->current_off = current_off;
|
h264parse->current_off = current_off;
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
parsing_error:
|
parsing_error:
|
||||||
@ -795,7 +798,7 @@ more:
|
|||||||
|
|
||||||
/* Fall-through. */
|
/* Fall-through. */
|
||||||
out:
|
out:
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
invalid:
|
invalid:
|
||||||
@ -811,7 +814,8 @@ gst_h264_parse_make_codec_data (GstH264Parse * h264parse)
|
|||||||
gint i, sps_size = 0, pps_size = 0, num_sps = 0, num_pps = 0;
|
gint i, sps_size = 0, pps_size = 0, num_sps = 0, num_pps = 0;
|
||||||
guint8 profile_idc = 0, profile_comp = 0, level_idc = 0;
|
guint8 profile_idc = 0, profile_comp = 0, level_idc = 0;
|
||||||
gboolean found = FALSE;
|
gboolean found = FALSE;
|
||||||
guint8 *buf_data, *data;
|
GstMapInfo map;
|
||||||
|
guint8 *data;
|
||||||
|
|
||||||
/* only nal payload in stored nals */
|
/* only nal payload in stored nals */
|
||||||
|
|
||||||
@ -846,8 +850,8 @@ gst_h264_parse_make_codec_data (GstH264Parse * h264parse)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
buf = gst_buffer_new_allocate (NULL, 5 + 1 + sps_size + 1 + pps_size, 0);
|
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);
|
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||||
data = buf_data;
|
data = map.data;
|
||||||
|
|
||||||
data[0] = 1; /* AVC Decoder Configuration Record ver. 1 */
|
data[0] = 1; /* AVC Decoder Configuration Record ver. 1 */
|
||||||
data[1] = profile_idc; /* profile_idc */
|
data[1] = profile_idc; /* profile_idc */
|
||||||
@ -877,7 +881,7 @@ gst_h264_parse_make_codec_data (GstH264Parse * h264parse)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buf, buf_data, -1);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -1007,15 +1011,14 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps)
|
|||||||
h264parse->align == GST_H264_PARSE_ALIGN_AU) {
|
h264parse->align == GST_H264_PARSE_ALIGN_AU) {
|
||||||
buf = gst_h264_parse_make_codec_data (h264parse);
|
buf = gst_h264_parse_make_codec_data (h264parse);
|
||||||
if (buf && h264parse->codec_data) {
|
if (buf && h264parse->codec_data) {
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
gpointer data;
|
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
if (size != gst_buffer_get_size (h264parse->codec_data) ||
|
if (map.size != gst_buffer_get_size (h264parse->codec_data) ||
|
||||||
gst_buffer_memcmp (h264parse->codec_data, 0, data, size))
|
gst_buffer_memcmp (h264parse->codec_data, 0, map.data, map.size))
|
||||||
modified = TRUE;
|
modified = TRUE;
|
||||||
|
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
} else {
|
} else {
|
||||||
if (h264parse->codec_data)
|
if (h264parse->codec_data)
|
||||||
buf = gst_buffer_ref (h264parse->codec_data);
|
buf = gst_buffer_ref (h264parse->codec_data);
|
||||||
@ -1292,12 +1295,12 @@ static GstFlowReturn
|
|||||||
gst_h264_parse_push_codec_buffer (GstH264Parse * h264parse, GstBuffer * nal,
|
gst_h264_parse_push_codec_buffer (GstH264Parse * h264parse, GstBuffer * nal,
|
||||||
GstClockTime ts)
|
GstClockTime ts)
|
||||||
{
|
{
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
data = gst_buffer_map (nal, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (nal, &map, GST_MAP_READ);
|
||||||
nal = gst_h264_parse_wrap_nal (h264parse, h264parse->format, data, size);
|
nal = gst_h264_parse_wrap_nal (h264parse, h264parse->format,
|
||||||
gst_buffer_unmap (nal, data, size);
|
map.data, map.size);
|
||||||
|
gst_buffer_unmap (nal, &map);
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (nal) = ts;
|
GST_BUFFER_TIMESTAMP (nal) = ts;
|
||||||
GST_BUFFER_DURATION (nal) = 0;
|
GST_BUFFER_DURATION (nal) = 0;
|
||||||
@ -1548,6 +1551,7 @@ gst_h264_parse_set_caps (GstBaseParse * parse, GstCaps * caps)
|
|||||||
/* packetized video has a codec_data */
|
/* packetized video has a codec_data */
|
||||||
if (format != GST_H264_PARSE_FORMAT_BYTE &&
|
if (format != GST_H264_PARSE_FORMAT_BYTE &&
|
||||||
(value = gst_structure_get_value (str, "codec_data"))) {
|
(value = gst_structure_get_value (str, "codec_data"))) {
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
guint num_sps, num_pps, profile;
|
guint num_sps, num_pps, profile;
|
||||||
gint i;
|
gint i;
|
||||||
@ -1559,16 +1563,18 @@ gst_h264_parse_set_caps (GstBaseParse * parse, GstCaps * caps)
|
|||||||
codec_data = gst_value_get_buffer (value);
|
codec_data = gst_value_get_buffer (value);
|
||||||
if (!codec_data)
|
if (!codec_data)
|
||||||
goto wrong_type;
|
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 */
|
/* parse the avcC data */
|
||||||
if (size < 8) {
|
if (size < 8) {
|
||||||
gst_buffer_unmap (codec_data, data, size);
|
gst_buffer_unmap (codec_data, &map);
|
||||||
goto avcc_too_small;
|
goto avcc_too_small;
|
||||||
}
|
}
|
||||||
/* parse the version, this must be 1 */
|
/* parse the version, this must be 1 */
|
||||||
if (data[0] != 1) {
|
if (data[0] != 1) {
|
||||||
gst_buffer_unmap (codec_data, data, size);
|
gst_buffer_unmap (codec_data, &map);
|
||||||
goto wrong_version;
|
goto wrong_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1591,7 +1597,7 @@ gst_h264_parse_set_caps (GstBaseParse * parse, GstCaps * caps)
|
|||||||
parseres = gst_h264_parser_identify_nalu_avc (h264parse->nalparser,
|
parseres = gst_h264_parser_identify_nalu_avc (h264parse->nalparser,
|
||||||
data, off, size, 2, &nalu);
|
data, off, size, 2, &nalu);
|
||||||
if (parseres != GST_H264_PARSER_OK) {
|
if (parseres != GST_H264_PARSER_OK) {
|
||||||
gst_buffer_unmap (codec_data, data, size);
|
gst_buffer_unmap (codec_data, &map);
|
||||||
goto avcc_too_small;
|
goto avcc_too_small;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1606,7 +1612,7 @@ gst_h264_parse_set_caps (GstBaseParse * parse, GstCaps * caps)
|
|||||||
parseres = gst_h264_parser_identify_nalu_avc (h264parse->nalparser,
|
parseres = gst_h264_parser_identify_nalu_avc (h264parse->nalparser,
|
||||||
data, off, size, 2, &nalu);
|
data, off, size, 2, &nalu);
|
||||||
if (parseres != GST_H264_PARSER_OK) {
|
if (parseres != GST_H264_PARSER_OK) {
|
||||||
gst_buffer_unmap (codec_data, data, size);
|
gst_buffer_unmap (codec_data, &map);
|
||||||
goto avcc_too_small;
|
goto avcc_too_small;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1614,7 +1620,7 @@ gst_h264_parse_set_caps (GstBaseParse * parse, GstCaps * caps)
|
|||||||
off = nalu.offset + nalu.size;
|
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);
|
h264parse->codec_data = gst_buffer_ref (codec_data);
|
||||||
|
|
||||||
@ -1840,8 +1846,7 @@ gst_h264_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||||||
GstH264ParserResult parse_res;
|
GstH264ParserResult parse_res;
|
||||||
GstH264NalUnit nalu;
|
GstH264NalUnit nalu;
|
||||||
const guint nl = h264parse->nal_length_size;
|
const guint nl = h264parse->nal_length_size;
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
if (nl < 1 || nl > 4) {
|
if (nl < 1 || nl > 4) {
|
||||||
GST_DEBUG_OBJECT (h264parse, "insufficient data to split input");
|
GST_DEBUG_OBJECT (h264parse, "insufficient data to split input");
|
||||||
@ -1850,13 +1855,13 @@ gst_h264_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||||||
return GST_FLOW_NOT_NEGOTIATED;
|
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,
|
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,
|
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) {
|
while (parse_res == GST_H264_PARSER_OK) {
|
||||||
GST_DEBUG_OBJECT (h264parse, "AVC nal offset %d",
|
GST_DEBUG_OBJECT (h264parse, "AVC nal offset %d",
|
||||||
@ -1881,10 +1886,10 @@ gst_h264_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
parse_res = gst_h264_parser_identify_nalu_avc (h264parse->nalparser,
|
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) {
|
if (h264parse->split_packetized) {
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
@ -369,12 +369,15 @@ gst_mpeg4vparse_check_valid_frame (GstBaseParse * parse,
|
|||||||
{
|
{
|
||||||
GstMpeg4VParse *mp4vparse = GST_MPEG4VIDEO_PARSE (parse);
|
GstMpeg4VParse *mp4vparse = GST_MPEG4VIDEO_PARSE (parse);
|
||||||
GstMpeg4Packet packet;
|
GstMpeg4Packet packet;
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data = NULL;
|
guint8 *data = NULL;
|
||||||
gsize size;
|
gsize size;
|
||||||
gint off = 0;
|
gint off = 0;
|
||||||
gboolean ret = FALSE;
|
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:
|
retry:
|
||||||
/* at least start code and subsequent byte */
|
/* at least start code and subsequent byte */
|
||||||
@ -475,7 +478,7 @@ next:
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
gst_buffer_unmap (frame->buffer, data, size);
|
gst_buffer_unmap (frame->buffer, &map);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,16 +674,17 @@ gst_mpeg4vparse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||||||
"interval since last config %" GST_TIME_FORMAT, GST_TIME_ARGS (diff));
|
"interval since last config %" GST_TIME_FORMAT, GST_TIME_ARGS (diff));
|
||||||
|
|
||||||
if (GST_TIME_AS_SECONDS (diff) >= mp4vparse->interval || push_codec) {
|
if (GST_TIME_AS_SECONDS (diff) >= mp4vparse->interval || push_codec) {
|
||||||
guint8 *cdata;
|
GstMapInfo cmap;
|
||||||
gsize csize;
|
gsize csize;
|
||||||
gboolean diffconf;
|
gboolean diffconf;
|
||||||
|
|
||||||
/* we need to send config now first */
|
/* we need to send config now first */
|
||||||
GST_INFO_OBJECT (parse, "inserting config in stream");
|
GST_INFO_OBJECT (parse, "inserting config in stream");
|
||||||
cdata = gst_buffer_map (mp4vparse->config, &csize, NULL, GST_MAP_READ);
|
gst_buffer_map (mp4vparse->config, &cmap, GST_MAP_READ);
|
||||||
diffconf = (gst_buffer_get_size (buffer) < csize)
|
diffconf = (gst_buffer_get_size (buffer) < cmap.size)
|
||||||
|| gst_buffer_memcmp (buffer, 0, cdata, csize);
|
|| gst_buffer_memcmp (buffer, 0, cmap.data, cmap.size);
|
||||||
gst_buffer_unmap (mp4vparse->config, cdata, csize);
|
csize = cmap.size;
|
||||||
|
gst_buffer_unmap (mp4vparse->config, &cmap);
|
||||||
|
|
||||||
/* avoid inserting duplicate config */
|
/* avoid inserting duplicate config */
|
||||||
if (diffconf) {
|
if (diffconf) {
|
||||||
@ -713,6 +717,7 @@ gst_mpeg4vparse_set_caps (GstBaseParse * parse, GstCaps * caps)
|
|||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
const GValue *value;
|
const GValue *value;
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
@ -728,7 +733,9 @@ gst_mpeg4vparse_set_caps (GstBaseParse * parse, GstCaps * caps)
|
|||||||
/* best possible parse attempt,
|
/* best possible parse attempt,
|
||||||
* src caps are based on sink caps so it will end up in there
|
* src caps are based on sink caps so it will end up in there
|
||||||
* whether sucessful or not */
|
* 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);
|
res = gst_mpeg4_parse (&packet, TRUE, NULL, data, 0, size);
|
||||||
|
|
||||||
while (res == GST_MPEG4_PARSER_OK || res == GST_MPEG4_PARSER_NO_PACKET_END) {
|
while (res == GST_MPEG4_PARSER_OK || res == GST_MPEG4_PARSER_NO_PACKET_END) {
|
||||||
@ -742,7 +749,7 @@ gst_mpeg4vparse_set_caps (GstBaseParse * parse, GstCaps * caps)
|
|||||||
|
|
||||||
/* And take it as config */
|
/* And take it as config */
|
||||||
gst_mpeg4vparse_process_config (mp4vparse, data, 3, size);
|
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 */
|
/* let's not interfere and accept regardless of config parsing success */
|
||||||
|
@ -229,21 +229,21 @@ gst_mpegv_parse_process_config (GstMpegvParse * mpvparse, GstBuffer * buf,
|
|||||||
guint size)
|
guint size)
|
||||||
{
|
{
|
||||||
GList *tmp;
|
GList *tmp;
|
||||||
guint8 *buf_data, *data;
|
GstMapInfo map;
|
||||||
gsize buf_size;
|
guint8 *data;
|
||||||
|
|
||||||
buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
data = buf_data + mpvparse->seq_offset;
|
data = map.data + mpvparse->seq_offset;
|
||||||
|
|
||||||
/* only do stuff if something new */
|
/* only do stuff if something new */
|
||||||
if (mpvparse->config && size == gst_buffer_get_size (mpvparse->config) &&
|
if (mpvparse->config && size == gst_buffer_get_size (mpvparse->config) &&
|
||||||
gst_buffer_memcmp (mpvparse->config, 0, data, size) == 0) {
|
gst_buffer_memcmp (mpvparse->config, 0, data, size) == 0) {
|
||||||
gst_buffer_unmap (buf, buf_data, buf_size);
|
gst_buffer_unmap (buf, &map);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gst_mpeg_video_parse_sequence_header (&mpvparse->sequencehdr, data,
|
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) {
|
if (mpvparse->fps_num == 0 || mpvparse->fps_den == 0) {
|
||||||
mpvparse->fps_num = mpvparse->sequencehdr.fps_n;
|
mpvparse->fps_num = mpvparse->sequencehdr.fps_n;
|
||||||
mpvparse->fps_den = mpvparse->sequencehdr.fps_d;
|
mpvparse->fps_den = mpvparse->sequencehdr.fps_d;
|
||||||
@ -252,7 +252,7 @@ gst_mpegv_parse_process_config (GstMpegvParse * mpvparse, GstBuffer * buf,
|
|||||||
GST_DEBUG_OBJECT (mpvparse,
|
GST_DEBUG_OBJECT (mpvparse,
|
||||||
"failed to parse config data (size %d) at offset %d",
|
"failed to parse config data (size %d) at offset %d",
|
||||||
size, mpvparse->seq_offset);
|
size, mpvparse->seq_offset);
|
||||||
gst_buffer_unmap (buf, buf_data, buf_size);
|
gst_buffer_unmap (buf, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ gst_mpegv_parse_process_config (GstMpegvParse * mpvparse, GstBuffer * buf,
|
|||||||
mpvparse->mpeg_version = 2;
|
mpvparse->mpeg_version = 2;
|
||||||
|
|
||||||
if (gst_mpeg_video_parse_sequence_extension (&mpvparse->sequenceext,
|
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->fps_num =
|
||||||
mpvparse->sequencehdr.fps_n * (mpvparse->sequenceext.fps_n_ext +
|
mpvparse->sequencehdr.fps_n * (mpvparse->sequenceext.fps_n_ext +
|
||||||
1) * 2;
|
1) * 2;
|
||||||
@ -292,7 +292,7 @@ gst_mpegv_parse_process_config (GstMpegvParse * mpvparse, GstBuffer * buf,
|
|||||||
/* trigger src caps update */
|
/* trigger src caps update */
|
||||||
mpvparse->update_caps = TRUE;
|
mpvparse->update_caps = TRUE;
|
||||||
|
|
||||||
gst_buffer_unmap (buf, buf_data, buf_size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -359,12 +359,11 @@ static void
|
|||||||
parse_picture_extension (GstMpegvParse * mpvparse, GstBuffer * buf, guint off)
|
parse_picture_extension (GstMpegvParse * mpvparse, GstBuffer * buf, guint off)
|
||||||
{
|
{
|
||||||
GstMpegVideoPictureExt ext;
|
GstMpegVideoPictureExt ext;
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
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;
|
mpvparse->frame_repeat_count = 1;
|
||||||
|
|
||||||
if (ext.repeat_first_field) {
|
if (ext.repeat_first_field) {
|
||||||
@ -379,7 +378,7 @@ parse_picture_extension (GstMpegvParse * mpvparse, GstBuffer * buf, guint off)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* caller guarantees at least start code in @buf at @off */
|
/* caller guarantees at least start code in @buf at @off */
|
||||||
@ -438,11 +437,11 @@ gst_mpegv_parse_process_sc (GstMpegvParse * mpvparse,
|
|||||||
|
|
||||||
/* extract some picture info if there is any in the frame being terminated */
|
/* extract some picture info if there is any in the frame being terminated */
|
||||||
if (ret && mpvparse->pic_offset >= 0 && mpvparse->pic_offset < off) {
|
if (ret && mpvparse->pic_offset >= 0 && mpvparse->pic_offset < off) {
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
gpointer data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
|
||||||
|
|
||||||
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
if (gst_mpeg_video_parse_picture_header (&mpvparse->pichdr,
|
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"
|
GST_LOG_OBJECT (mpvparse, "picture_coding_type %d (%s), ending"
|
||||||
"frame of size %d", mpvparse->pichdr.pic_type,
|
"frame of size %d", mpvparse->pichdr.pic_type,
|
||||||
picture_type_name (mpvparse->pichdr.pic_type), off - 4);
|
picture_type_name (mpvparse->pichdr.pic_type), off - 4);
|
||||||
@ -450,7 +449,7 @@ gst_mpegv_parse_process_sc (GstMpegvParse * mpvparse,
|
|||||||
GST_LOG_OBJECT (mpvparse, "Couldn't parse picture at offset %d",
|
GST_LOG_OBJECT (mpvparse, "Couldn't parse picture at offset %d",
|
||||||
mpvparse->pic_offset);
|
mpvparse->pic_offset);
|
||||||
|
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -503,7 +502,7 @@ gst_mpegv_parse_check_valid_frame (GstBaseParse * parse,
|
|||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
GList *tmp;
|
GList *tmp;
|
||||||
gint off = 0, fsize = -1;
|
gint off = 0, fsize = -1;
|
||||||
gpointer buf_data;
|
GstMapInfo map;
|
||||||
gsize buf_size;
|
gsize buf_size;
|
||||||
|
|
||||||
update_frame_parsing_status (mpvparse, frame);
|
update_frame_parsing_status (mpvparse, frame);
|
||||||
@ -511,9 +510,10 @@ gst_mpegv_parse_check_valid_frame (GstBaseParse * parse,
|
|||||||
if (mpvparse->last_sc >= 0)
|
if (mpvparse->last_sc >= 0)
|
||||||
off = mpvparse->last_sc;
|
off = mpvparse->last_sc;
|
||||||
|
|
||||||
buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
mpvparse->typeoffsize = gst_mpeg_video_parse (buf_data, buf_size, off);
|
buf_size = map.size;
|
||||||
gst_buffer_unmap (buf, buf_data, buf_size);
|
mpvparse->typeoffsize = gst_mpeg_video_parse (map.data, map.size, off);
|
||||||
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
/* No sc found */
|
/* No sc found */
|
||||||
if (mpvparse->typeoffsize == NULL)
|
if (mpvparse->typeoffsize == NULL)
|
||||||
|
@ -73,18 +73,17 @@ gst_h263_parse_get_params (H263Params * params, GstBuffer * buffer,
|
|||||||
};
|
};
|
||||||
|
|
||||||
GstBitReader br;
|
GstBitReader br;
|
||||||
guint8 *buf_data;
|
GstMapInfo map;
|
||||||
gsize buf_size;
|
|
||||||
guint8 tr;
|
guint8 tr;
|
||||||
guint32 psc = 0, temp32;
|
guint32 psc = 0, temp32;
|
||||||
guint8 temp8, pquant;
|
guint8 temp8, pquant;
|
||||||
gboolean hasplusptype;
|
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
|
/* FIXME: we can optimise a little by checking the value of available
|
||||||
* instead of calling using the bit reader's get_bits_* functions. */
|
* 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 */
|
/* Default PCF is CIF PCF = 30000/1001 */
|
||||||
params->pcfnum = 30000;
|
params->pcfnum = 30000;
|
||||||
@ -449,12 +448,12 @@ gst_h263_parse_get_params (H263Params * params, GstBuffer * buffer,
|
|||||||
done:
|
done:
|
||||||
*state = GOT_HEADER;
|
*state = GOT_HEADER;
|
||||||
more:
|
more:
|
||||||
gst_buffer_unmap (buffer, buf_data, buf_size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
*state = PASSTHROUGH;
|
*state = PASSTHROUGH;
|
||||||
gst_buffer_unmap (buffer, buf_data, buf_size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user