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;
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 */
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;
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 *
gst_gdp_pay_class_init (GstGDPPayClass * klass)
{
GObjectClass *gobject_class;
-
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
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);
}
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))
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);
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,
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);
gst_gdp_buffer_from_event (GstGDPPay * this, GstEvent * event)
{
GstBuffer *headerbuf;
-
GstBuffer *payloadbuf;
-
guint8 *header, *payload;
-
- guint len;
-
+ guint len, plen;
gboolean ret;
ret =
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);
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 };
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 */
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));
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)",
gst_gdp_pay_src_event (GstPad * pad, GstEvent * event)
{
GstGDPPay *this;
-
gboolean res = TRUE;
this = GST_GDP_PAY (gst_pad_get_parent (pad));
gst_gdp_pay_change_state (GstElement * element, GstStateChange transition)
{
GstStateChangeReturn ret;
-
GstGDPPay *this = GST_GDP_PAY (element);
switch (transition) {