mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 08:41:07 +00:00
port to new map API
This commit is contained in:
parent
0a817d23e6
commit
33344dc2b9
5 changed files with 30 additions and 34 deletions
|
@ -131,8 +131,7 @@ gst_dp_header_from_buffer_any (const GstBuffer * buffer, GstDPHeaderFlag flags,
|
||||||
{
|
{
|
||||||
guint8 *h;
|
guint8 *h;
|
||||||
guint16 flags_mask;
|
guint16 flags_mask;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
|
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
|
||||||
g_return_val_if_fail (length, FALSE);
|
g_return_val_if_fail (length, FALSE);
|
||||||
|
@ -144,10 +143,10 @@ gst_dp_header_from_buffer_any (const GstBuffer * buffer, GstDPHeaderFlag flags,
|
||||||
/* version, flags, type */
|
/* version, flags, type */
|
||||||
GST_DP_INIT_HEADER (h, version, flags, GST_DP_PAYLOAD_BUFFER);
|
GST_DP_INIT_HEADER (h, version, flags, GST_DP_PAYLOAD_BUFFER);
|
||||||
|
|
||||||
data = gst_buffer_map ((GstBuffer *) buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map ((GstBuffer *) buffer, &map, GST_MAP_READ);
|
||||||
|
|
||||||
/* buffer properties */
|
/* buffer properties */
|
||||||
GST_WRITE_UINT32_BE (h + 6, size);
|
GST_WRITE_UINT32_BE (h + 6, map.size);
|
||||||
GST_WRITE_UINT64_BE (h + 10, GST_BUFFER_TIMESTAMP (buffer));
|
GST_WRITE_UINT64_BE (h + 10, GST_BUFFER_TIMESTAMP (buffer));
|
||||||
GST_WRITE_UINT64_BE (h + 18, GST_BUFFER_DURATION (buffer));
|
GST_WRITE_UINT64_BE (h + 18, GST_BUFFER_DURATION (buffer));
|
||||||
GST_WRITE_UINT64_BE (h + 26, GST_BUFFER_OFFSET (buffer));
|
GST_WRITE_UINT64_BE (h + 26, GST_BUFFER_OFFSET (buffer));
|
||||||
|
@ -161,9 +160,9 @@ gst_dp_header_from_buffer_any (const GstBuffer * buffer, GstDPHeaderFlag flags,
|
||||||
|
|
||||||
GST_WRITE_UINT16_BE (h + 42, GST_BUFFER_FLAGS (buffer) & flags_mask);
|
GST_WRITE_UINT16_BE (h + 42, GST_BUFFER_FLAGS (buffer) & flags_mask);
|
||||||
|
|
||||||
GST_DP_SET_CRC (h, flags, data, size);
|
GST_DP_SET_CRC (h, flags, map.data, map.size);
|
||||||
|
|
||||||
gst_buffer_unmap ((GstBuffer *) buffer, data, size);
|
gst_buffer_unmap ((GstBuffer *) buffer, &map);
|
||||||
|
|
||||||
GST_LOG ("created header from buffer:");
|
GST_LOG ("created header from buffer:");
|
||||||
gst_dp_dump_byte_array (h, GST_DP_HEADER_LENGTH);
|
gst_dp_dump_byte_array (h, GST_DP_HEADER_LENGTH);
|
||||||
|
|
|
@ -308,11 +308,11 @@ gst_gdp_depay_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
|
|
||||||
/* now take the payload if there is any */
|
/* now take the payload if there is any */
|
||||||
if (this->payload_length > 0) {
|
if (this->payload_length > 0) {
|
||||||
guint8 *payload;
|
GstMapInfo map;
|
||||||
|
|
||||||
payload = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||||
gst_adapter_copy (this->adapter, payload, 0, this->payload_length);
|
gst_adapter_copy (this->adapter, map.data, 0, this->payload_length);
|
||||||
gst_buffer_unmap (buf, payload, this->payload_length);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
gst_adapter_flush (this->adapter, this->payload_length);
|
gst_adapter_flush (this->adapter, this->payload_length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,8 +284,8 @@ GST_START_TEST (test_streamheader)
|
||||||
GstPad *srcpad;
|
GstPad *srcpad;
|
||||||
GstElement *gdpdepay;
|
GstElement *gdpdepay;
|
||||||
GstBuffer *buffer, *inbuffer, *outbuffer, *shbuffer;
|
GstBuffer *buffer, *inbuffer, *outbuffer, *shbuffer;
|
||||||
guint8 *caps_header, *caps_payload, *buf_header, *data;
|
guint8 *caps_header, *caps_payload, *buf_header;
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
guint header_len, payload_len;
|
guint header_len, payload_len;
|
||||||
guint i;
|
guint i;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
@ -334,17 +334,17 @@ GST_START_TEST (test_streamheader)
|
||||||
|
|
||||||
payload_len = gst_dp_header_payload_length (caps_header);
|
payload_len = gst_dp_header_payload_length (caps_header);
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
inbuffer = gst_buffer_new_and_alloc (2 * GST_DP_HEADER_LENGTH +
|
inbuffer = gst_buffer_new_and_alloc (2 * GST_DP_HEADER_LENGTH +
|
||||||
payload_len + size);
|
payload_len + map.size);
|
||||||
gst_buffer_fill (inbuffer, 0, caps_header, GST_DP_HEADER_LENGTH);
|
gst_buffer_fill (inbuffer, 0, caps_header, GST_DP_HEADER_LENGTH);
|
||||||
i = GST_DP_HEADER_LENGTH;
|
i = GST_DP_HEADER_LENGTH;
|
||||||
gst_buffer_fill (inbuffer, i, caps_payload, payload_len);
|
gst_buffer_fill (inbuffer, i, caps_payload, payload_len);
|
||||||
i += payload_len;
|
i += payload_len;
|
||||||
gst_buffer_fill (inbuffer, i, buf_header, GST_DP_HEADER_LENGTH);
|
gst_buffer_fill (inbuffer, i, buf_header, GST_DP_HEADER_LENGTH);
|
||||||
i += GST_DP_HEADER_LENGTH;
|
i += GST_DP_HEADER_LENGTH;
|
||||||
gst_buffer_fill (inbuffer, i, data, size);
|
gst_buffer_fill (inbuffer, i, map.data, map.size);
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
|
@ -466,8 +466,7 @@ GST_START_TEST (test_crc)
|
||||||
GstEvent *event;
|
GstEvent *event;
|
||||||
gchar *caps_string;
|
gchar *caps_string;
|
||||||
gint length;
|
gint length;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
guint16 crc_calculated, crc_read;
|
guint16 crc_calculated, crc_read;
|
||||||
|
|
||||||
gdppay = setup_gdppay ();
|
gdppay = setup_gdppay ();
|
||||||
|
@ -508,18 +507,18 @@ GST_START_TEST (test_crc)
|
||||||
/* verify the header checksum */
|
/* verify the header checksum */
|
||||||
/* CRC's start at 58 in the header */
|
/* CRC's start at 58 in the header */
|
||||||
outbuffer = gst_buffer_make_writable (outbuffer);
|
outbuffer = gst_buffer_make_writable (outbuffer);
|
||||||
data = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READWRITE);
|
gst_buffer_map (outbuffer, &map, GST_MAP_READWRITE);
|
||||||
crc_calculated = gst_dp_crc (data, 58);
|
crc_calculated = gst_dp_crc (map.data, 58);
|
||||||
crc_read = GST_READ_UINT16_BE (data + 58);
|
crc_read = GST_READ_UINT16_BE (map.data + 58);
|
||||||
fail_unless_equals_int (crc_calculated, crc_read);
|
fail_unless_equals_int (crc_calculated, crc_read);
|
||||||
|
|
||||||
/* change a byte in the header and verify that the checksum now fails */
|
/* change a byte in the header and verify that the checksum now fails */
|
||||||
data[0] = 0xff;
|
map.data[0] = 0xff;
|
||||||
crc_calculated = gst_dp_crc (data, 58);
|
crc_calculated = gst_dp_crc (map.data, 58);
|
||||||
fail_if (crc_calculated == crc_read,
|
fail_if (crc_calculated == crc_read,
|
||||||
"Introducing a byte error in the header should make the checksum fail");
|
"Introducing a byte error in the header should make the checksum fail");
|
||||||
|
|
||||||
gst_buffer_unmap (outbuffer, data, size);
|
gst_buffer_unmap (outbuffer, &map);
|
||||||
gst_buffer_unref (outbuffer);
|
gst_buffer_unref (outbuffer);
|
||||||
|
|
||||||
/* second buffer is the serialized caps;
|
/* second buffer is the serialized caps;
|
||||||
|
|
|
@ -130,10 +130,9 @@ static GstPadProbeReturn
|
||||||
buffer_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
|
buffer_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
|
||||||
{
|
{
|
||||||
GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
|
GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
|
|
||||||
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_IN_CAPS)) {
|
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_IN_CAPS)) {
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
@ -155,27 +154,26 @@ buffer_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
|
||||||
|
|
||||||
for (i = 0; i < 3; ++i) {
|
for (i = 0; i < 3; ++i) {
|
||||||
GValue *val;
|
GValue *val;
|
||||||
guint8 *data2;
|
GstMapInfo map2;
|
||||||
gsize size2;
|
|
||||||
|
|
||||||
val = &g_array_index (buffers, GValue, i);
|
val = &g_array_index (buffers, GValue, i);
|
||||||
buf = g_value_peek_pointer (val);
|
buf = g_value_peek_pointer (val);
|
||||||
fail_unless (GST_IS_BUFFER (buf));
|
fail_unless (GST_IS_BUFFER (buf));
|
||||||
|
|
||||||
data2 = gst_buffer_map (buf, &size2, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map2, GST_MAP_READ);
|
||||||
if (size2 == size) {
|
if (map2.size == map.size) {
|
||||||
if (memcmp (data2, data, size) == 0) {
|
if (memcmp (map2.data, map.data, map.size) == 0) {
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buf, data2, size2);
|
gst_buffer_unmap (buf, &map2);
|
||||||
}
|
}
|
||||||
fail_unless (found, "Did not find incoming IN_CAPS buffer %p on caps",
|
fail_unless (found, "Did not find incoming IN_CAPS buffer %p on caps",
|
||||||
buffer);
|
buffer);
|
||||||
|
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue