}
static GstFlowReturn
-gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay,
- const guint8 * data, guint payload_len)
+gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay, GstBuffer * buf)
{
GstRTPBasePayload *basepayload;
GstClockTime duration;
guint frames;
GstBuffer *outbuf;
- guint8 *payload;
GstFlowReturn ret;
GstRTPBuffer rtp = { NULL };
+ guint payload_len = gst_buffer_get_size (buf);
basepayload = GST_RTP_BASE_PAYLOAD (rtpg729pay);
payload_len, GST_TIME_ARGS (rtpg729pay->next_ts));
/* create buffer to hold the payload */
- outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
+ outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
gst_rtp_buffer_map (outbuf, GST_MAP_READWRITE, &rtp);
- /* copy payload */
- payload = gst_rtp_buffer_get_payload (&rtp);
- memcpy (payload, data, payload_len);
-
/* set metadata */
frames =
(payload_len / G729_FRAME_SIZE) + ((payload_len % G729_FRAME_SIZE) >> 1);
}
gst_rtp_buffer_unmap (&rtp);
- ret = gst_rtp_base_payload_push (basepayload, outbuf);
-
- return ret;
-}
+ /* append payload */
+ outbuf = gst_buffer_append (outbuf, buf);
-static GstFlowReturn
-gst_rtp_g729_pay_push_and_free (GstRTPG729Pay * rtpg729pay,
- guint8 * data, guint payload_len)
-{
- GstFlowReturn ret;
+ ret = gst_rtp_base_payload_push (basepayload, outbuf);
- ret = gst_rtp_g729_pay_push (rtpg729pay, data, payload_len);
- g_free (data);
return ret;
}
if (GST_BUFFER_IS_DISCONT (buf)) {
/* flush remainder */
if (available > 0) {
- gst_rtp_g729_pay_push_and_free (rtpg729pay,
- gst_adapter_take (adapter, available), available);
+ gst_rtp_g729_pay_push (rtpg729pay,
+ gst_adapter_take_buffer_fast (adapter, available));
available = 0;
}
rtpg729pay->discont = TRUE;
rtpg729pay->next_ts = timestamp;
if (available == 0 && size >= min_payload_len && size <= max_payload_len) {
- GstMapInfo map;
-
- gst_buffer_map (buf, &map, GST_MAP_READ);
- ret = gst_rtp_g729_pay_push (rtpg729pay, map.data, map.size);
- gst_buffer_unmap (buf, &map);
- gst_buffer_unref (buf);
+ ret = gst_rtp_g729_pay_push (rtpg729pay, gst_buffer_ref (buf));
return ret;
}
(available / G729_FRAME_SIZE) * G729_FRAME_SIZE);
}
- ret = gst_rtp_g729_pay_push_and_free (rtpg729pay,
- gst_adapter_take (adapter, payload_len), payload_len);
+ ret = gst_rtp_g729_pay_push (rtpg729pay,
+ gst_adapter_take_buffer_fast (adapter, payload_len));
available -= payload_len;
}