summaryrefslogtreecommitdiff
path: root/gst/gdp
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2011-03-27 16:35:28 +0200
committerTim-Philipp Müller <tim@centricular.net>2012-09-11 01:54:34 +0100
commit0e90a4536599cd3aeff85929ef5bb27f83bd92f4 (patch)
treec5a0f4cc86f1118b33be7db2aaf77e89156e8dd6 /gst/gdp
parentce639b529bdedff0d528d782131a2cc6133e801f (diff)
downloadgstreamer-plugins-bad-0e90a4536599cd3aeff85929ef5bb27f83bd92f4.tar.gz
plugins: port some plugins to the new memory API
Diffstat (limited to 'gst/gdp')
-rw-r--r--gst/gdp/gstgdpdepay.c28
-rw-r--r--gst/gdp/gstgdppay.c59
2 files changed, 35 insertions, 52 deletions
diff --git a/gst/gdp/gstgdpdepay.c b/gst/gdp/gstgdpdepay.c
index 702e63fed..28a8564c3 100644
--- a/gst/gdp/gstgdpdepay.c
+++ b/gst/gdp/gstgdpdepay.c
@@ -285,17 +285,23 @@ gst_gdp_depay_chain (GstPad * pad, GstBuffer * buffer)
goto wrong_type;
}
- if (this->payload_length
- && (!gst_dp_validate_payload (GST_DP_HEADER_LENGTH, this->header,
- gst_adapter_peek (this->adapter, this->payload_length)))) {
- goto payload_validate_error;
+ if (this->payload_length) {
+ const guint8 *data;
+ gboolean res;
+
+ data = gst_adapter_map (this->adapter, this->payload_length);
+ res = gst_dp_validate_payload (GST_DP_HEADER_LENGTH, this->header,
+ data);
+ gst_adapter_unmap (this->adapter, 0);
+
+ if (!res)
+ goto payload_validate_error;
}
break;
}
case GST_GDP_DEPAY_STATE_BUFFER:
{
-
/* if we receive a buffer without caps first, we error out */
if (!this->caps)
goto no_caps;
@@ -309,9 +315,11 @@ gst_gdp_depay_chain (GstPad * pad, GstBuffer * buffer)
if (this->payload_length > 0) {
guint8 *payload;
- payload = gst_adapter_take (this->adapter, this->payload_length);
- memcpy (GST_BUFFER_DATA (buf), payload, this->payload_length);
- g_free (payload);
+ payload = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+ gst_adapter_copy (this->adapter, payload, 0, this->payload_length);
+ gst_buffer_unmap (buf, payload, this->payload_length);
+
+ gst_adapter_flush (this->adapter, this->payload_length);
}
/* set caps and push */
@@ -319,12 +327,12 @@ gst_gdp_depay_chain (GstPad * pad, GstBuffer * buffer)
GST_LOG_OBJECT (this, "deserialized buffer %p, pushing, timestamp %"
GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT
", offset %" G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT
- ", size %d, flags 0x%x",
+ ", size %" G_GSIZE_FORMAT ", flags 0x%x",
buf,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)),
GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),
- GST_BUFFER_SIZE (buf), GST_BUFFER_FLAGS (buf));
+ gst_buffer_get_size (buf), GST_BUFFER_FLAGS (buf));
ret = gst_pad_push (this->srcpad, buf);
if (ret != GST_FLOW_OK)
goto push_error;
diff --git a/gst/gdp/gstgdppay.c b/gst/gdp/gstgdppay.c
index 6da4967f7..b0e3fc81f 100644
--- a/gst/gdp/gstgdppay.c
+++ b/gst/gdp/gstgdppay.c
@@ -77,9 +77,7 @@ GST_BOILERPLATE_FULL (GstGDPPay, gst_gdp_pay, GstElement,
static void gst_gdp_pay_reset (GstGDPPay * this);
static GstFlowReturn gst_gdp_pay_chain (GstPad * pad, GstBuffer * buffer);
-
static gboolean gst_gdp_pay_src_event (GstPad * pad, GstEvent * event);
-
static gboolean gst_gdp_pay_sink_event (GstPad * pad, GstEvent * event);
static GstStateChangeReturn gst_gdp_pay_change_state (GstElement *
@@ -112,7 +110,6 @@ static void
gst_gdp_pay_class_init (GstGDPPayClass * klass)
{
GObjectClass *gobject_class;
-
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
@@ -216,7 +213,7 @@ static void
gst_gdp_stamp_buffer (GstGDPPay * this, GstBuffer * buffer)
{
GST_BUFFER_OFFSET (buffer) = this->offset;
- GST_BUFFER_OFFSET_END (buffer) = this->offset + GST_BUFFER_SIZE (buffer);
+ GST_BUFFER_OFFSET_END (buffer) = this->offset + gst_buffer_get_size (buffer);
this->offset = GST_BUFFER_OFFSET_END (buffer);
}
@@ -224,12 +221,9 @@ static GstBuffer *
gst_gdp_buffer_from_caps (GstGDPPay * this, GstCaps * caps)
{
GstBuffer *headerbuf;
-
GstBuffer *payloadbuf;
-
guint8 *header, *payload;
-
- guint len;
+ guint len, plen;
if (!this->packetizer->packet_from_caps (caps, this->header_flag, &len,
&header, &payload))
@@ -237,13 +231,13 @@ gst_gdp_buffer_from_caps (GstGDPPay * this, GstCaps * caps)
GST_LOG_OBJECT (this, "creating GDP header and payload buffer from caps");
headerbuf = gst_buffer_new ();
- gst_buffer_set_data (headerbuf, header, len);
- GST_BUFFER_MALLOCDATA (headerbuf) = header;
+ gst_buffer_take_memory (headerbuf,
+ gst_memory_new_wrapped (0, header, g_free, len, 0, len));
payloadbuf = gst_buffer_new ();
- gst_buffer_set_data (payloadbuf, payload,
- gst_dp_header_payload_length (header));
- GST_BUFFER_MALLOCDATA (payloadbuf) = payload;
+ plen = gst_dp_header_payload_length (header);
+ gst_buffer_take_memory (payloadbuf,
+ gst_memory_new_wrapped (0, payload, g_free, plen, 0, plen));
return gst_buffer_join (headerbuf, payloadbuf);
@@ -259,9 +253,7 @@ static GstBuffer *
gst_gdp_pay_buffer_from_buffer (GstGDPPay * this, GstBuffer * buffer)
{
GstBuffer *headerbuf;
-
guint8 *header;
-
guint len;
if (!this->packetizer->header_from_buffer (buffer, this->header_flag, &len,
@@ -270,8 +262,8 @@ gst_gdp_pay_buffer_from_buffer (GstGDPPay * this, GstBuffer * buffer)
GST_LOG_OBJECT (this, "creating GDP header and payload buffer from buffer");
headerbuf = gst_buffer_new ();
- gst_buffer_set_data (headerbuf, header, len);
- GST_BUFFER_MALLOCDATA (headerbuf) = header;
+ gst_buffer_take_memory (headerbuf,
+ gst_memory_new_wrapped (0, header, g_free, len, 0, len));
/* we do not want to lose the ref on the incoming buffer */
gst_buffer_ref (buffer);
@@ -290,13 +282,9 @@ static GstBuffer *
gst_gdp_buffer_from_event (GstGDPPay * this, GstEvent * event)
{
GstBuffer *headerbuf;
-
GstBuffer *payloadbuf;
-
guint8 *header, *payload;
-
- guint len;
-
+ guint len, plen;
gboolean ret;
ret =
@@ -307,13 +295,13 @@ gst_gdp_buffer_from_event (GstGDPPay * this, GstEvent * event)
GST_LOG_OBJECT (this, "creating GDP header and payload buffer from event");
headerbuf = gst_buffer_new ();
- gst_buffer_set_data (headerbuf, header, len);
- GST_BUFFER_MALLOCDATA (headerbuf) = header;
+ gst_buffer_take_memory (headerbuf,
+ gst_memory_new_wrapped (0, header, g_free, len, 0, len));
payloadbuf = gst_buffer_new ();
- gst_buffer_set_data (payloadbuf, payload,
- gst_dp_header_payload_length (header));
- GST_BUFFER_MALLOCDATA (payloadbuf) = payload;
+ plen = gst_dp_header_payload_length (header);
+ gst_buffer_take_memory (payloadbuf,
+ gst_memory_new_wrapped (0, payload, g_free, plen, 0, plen));
return gst_buffer_join (headerbuf, payloadbuf);
@@ -333,14 +321,10 @@ static GstFlowReturn
gst_gdp_pay_reset_streamheader (GstGDPPay * this)
{
GstCaps *caps;
-
/* We use copies of these to avoid circular refcounts */
GstBuffer *new_segment_buf, *caps_buf, *tag_buf;
-
GstStructure *structure;
-
GstFlowReturn r = GST_FLOW_OK;
-
gboolean version_one_zero = TRUE;
GValue array = { 0 };
@@ -474,10 +458,9 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
GST_DEBUG_OBJECT (this, "Setting caps on src pad %" GST_PTR_FORMAT, caps);
gst_pad_set_caps (this->srcpad, caps);
- this->caps_buf = gst_buffer_make_metadata_writable (this->caps_buf);
+ this->caps_buf = gst_buffer_make_writable (this->caps_buf);
gst_buffer_set_caps (this->caps_buf, caps);
- this->new_segment_buf =
- gst_buffer_make_metadata_writable (this->new_segment_buf);
+ this->new_segment_buf = gst_buffer_make_writable (this->new_segment_buf);
gst_buffer_set_caps (this->new_segment_buf, caps);
/* if these are our first ever buffers, send out new_segment first */
@@ -579,11 +562,8 @@ static GstFlowReturn
gst_gdp_pay_chain (GstPad * pad, GstBuffer * buffer)
{
GstGDPPay *this;
-
GstCaps *caps;
-
GstBuffer *outbuffer;
-
GstFlowReturn ret;
this = GST_GDP_PAY (gst_pad_get_parent (pad));
@@ -698,11 +678,8 @@ static gboolean
gst_gdp_pay_sink_event (GstPad * pad, GstEvent * event)
{
GstBuffer *outbuffer;
-
GstGDPPay *this = GST_GDP_PAY (gst_pad_get_parent (pad));
-
GstFlowReturn flowret;
-
gboolean ret = TRUE;
GST_DEBUG_OBJECT (this, "received event %p of type %s (%d)",
@@ -784,7 +761,6 @@ static gboolean
gst_gdp_pay_src_event (GstPad * pad, GstEvent * event)
{
GstGDPPay *this;
-
gboolean res = TRUE;
this = GST_GDP_PAY (gst_pad_get_parent (pad));
@@ -865,7 +841,6 @@ static GstStateChangeReturn
gst_gdp_pay_change_state (GstElement * element, GstStateChange transition)
{
GstStateChangeReturn ret;
-
GstGDPPay *this = GST_GDP_PAY (element);
switch (transition) {