summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>2014-11-28 17:58:34 -0500
committerOlivier CrĂȘte <olivier.crete@collabora.com>2015-01-27 16:38:39 -0500
commit645b9490bb3ec507cac2b01061c9b67c18abb5ae (patch)
treed1f26842e025208afb5ae9845ab04a2cb88fed1d /gst
parent9102709e6f8a0b9c390e8636589c3d80f9b1810a (diff)
downloadfarstream-645b9490bb3ec507cac2b01061c9b67c18abb5ae.tar.gz
rtpxdatapay: Add support for MTU and split long messages into multiple packets
Split all messages into max 1200 bytes of payload and send a GstBufferList when needed Keep sending a normal buffer in case the buffer is smaller than 1200 bytes to things slightly faster
Diffstat (limited to 'gst')
-rw-r--r--gst/fsrtpxdata/fsrtpxdatapay.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/gst/fsrtpxdata/fsrtpxdatapay.c b/gst/fsrtpxdata/fsrtpxdatapay.c
index 338d3c33..90a4d6b9 100644
--- a/gst/fsrtpxdata/fsrtpxdatapay.c
+++ b/gst/fsrtpxdata/fsrtpxdatapay.c
@@ -48,6 +48,8 @@ GST_STATIC_PAD_TEMPLATE ("src",
"encoding-name = (string) \"X-DATA\"")
);
+#define MAX_PAYLOAD_SIZE 1200
+
static gboolean fs_rtp_xdata_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
static GstFlowReturn fs_rtp_xdata_pay_handle_buffer (GstRTPBasePayload *payload,
@@ -90,6 +92,8 @@ fs_rtp_xdata_pay_init (FsRTPXdataPay * rtpxdatapay)
gst_rtp_base_payload_set_options (rtpbasepayload, "application", TRUE,
"X-DATA", 90000);
+ GST_RTP_BASE_PAYLOAD_MTU(rtpbasepayload) = MAX_PAYLOAD_SIZE +
+ gst_rtp_buffer_calc_header_len (0);
}
static gboolean
@@ -102,11 +106,34 @@ static GstFlowReturn
fs_rtp_xdata_pay_handle_buffer (GstRTPBasePayload *payload, GstBuffer *buffer)
{
GstBuffer *rtpbuf;
-
- rtpbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
- rtpbuf = gst_buffer_append (rtpbuf, buffer);
-
- return gst_rtp_base_payload_push (payload, rtpbuf);
+ gsize size;
+ guint mtu;
+
+ size = gst_buffer_get_size (buffer);
+ mtu = GST_RTP_BASE_PAYLOAD_MTU(payload);
+ mtu -= gst_rtp_buffer_calc_header_len (0);
+
+ if (size <= mtu) {
+ rtpbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
+ rtpbuf = gst_buffer_append (rtpbuf, buffer);
+
+ return gst_rtp_base_payload_push (payload, rtpbuf);
+ } else {
+ GstBufferList *rtplist = gst_buffer_list_new_sized (2);
+ gsize offset = 0;
+ gsize new_size;
+
+ while (size > 0) {
+ new_size = size > mtu ? mtu : size;
+
+ rtpbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
+ rtpbuf = gst_buffer_append_region (rtpbuf, buffer, offset, new_size);
+ gst_buffer_list_add (rtplist, rtpbuf);
+ offset += new_size;
+ size -= new_size;
+ }
+ return gst_rtp_base_payload_push_list (payload, rtplist);
+ }
}
gboolean