diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2014-05-06 17:01:53 -0400 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2014-09-18 13:38:00 -0400 |
commit | 3bf911fd7586d8cb72368c4d3d25fe27c58c2e16 (patch) | |
tree | 032cb36a29a8f074d8440183711f7ac0046933f2 /gst | |
parent | ac98be9a8a48f6f21babd2d5b41df0f5b85a3e42 (diff) | |
download | farstream-3bf911fd7586d8cb72368c4d3d25fe27c58c2e16.tar.gz |
fsrtpxdata: Add RTP pay/depay for Microsoft Lync RTP x-data
Diffstat (limited to 'gst')
-rw-r--r-- | gst/fsrtpxdata/Makefile.am | 15 | ||||
-rw-r--r-- | gst/fsrtpxdata/fsrtpxdata.c | 47 | ||||
-rw-r--r-- | gst/fsrtpxdata/fsrtpxdatadepay.c | 102 | ||||
-rw-r--r-- | gst/fsrtpxdata/fsrtpxdatadepay.h | 60 | ||||
-rw-r--r-- | gst/fsrtpxdata/fsrtpxdatapay.c | 117 | ||||
-rw-r--r-- | gst/fsrtpxdata/fsrtpxdatapay.h | 58 |
6 files changed, 399 insertions, 0 deletions
diff --git a/gst/fsrtpxdata/Makefile.am b/gst/fsrtpxdata/Makefile.am new file mode 100644 index 00000000..1cf9ffd7 --- /dev/null +++ b/gst/fsrtpxdata/Makefile.am @@ -0,0 +1,15 @@ +plugin_LTLIBRARIES = libfsrtpxdata.la + +libfsrtpxdata_la_SOURCES = fsrtpxdata.c fsrtpxdatapay.c fsrtpxdatadepay.c +libfsrtpxdata_la_CFLAGS = \ + $(FS_CFLAGS) \ + $(GST_BASE_CFLAGS) \ + $(GST_CFLAGS) +libfsrtpxdata_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) +libfsrtpxdata_la_LIBADD = \ + $(FS_LIBS) \ + $(GST_BASE_LIBS) \ + $(GST_LIBS) \ + -lgstrtp-@GST_API_VERSION@ + +noinst_HEADERS = fsrtpxdatapay.h fsrtpxdatadepay.h diff --git a/gst/fsrtpxdata/fsrtpxdata.c b/gst/fsrtpxdata/fsrtpxdata.c new file mode 100644 index 00000000..e1845cab --- /dev/null +++ b/gst/fsrtpxdata/fsrtpxdata.c @@ -0,0 +1,47 @@ +/* + * Microsoft Lync RTP x-data Gst Element + * + * Copyright 2014 Collabora Ltd. + * @author: Olivier Crete <olivier.crete@collabora.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write tox the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "fsrtpxdatapay.h" +#include "fsrtpxdatadepay.h" + +static gboolean +plugin_init (GstPlugin * plugin) +{ + if (!fs_rtp_xdata_depay_plugin_init (plugin)) + return FALSE; + + if (!fs_rtp_xdata_pay_plugin_init (plugin)) + return FALSE; + + return TRUE; +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + fsrtpxdata, + "Farstream Microsoft Lync x-data RTP plugin", + plugin_init, VERSION, "LGPL", "Farstream", + "http://www.freedesktop.org/wiki/Software/Farstream") diff --git a/gst/fsrtpxdata/fsrtpxdatadepay.c b/gst/fsrtpxdata/fsrtpxdatadepay.c new file mode 100644 index 00000000..66996e4f --- /dev/null +++ b/gst/fsrtpxdata/fsrtpxdatadepay.c @@ -0,0 +1,102 @@ +/* + * Microsoft Lync RTP x-data Depayloader Gst Element + * + * Copyright 2014 Collabora Ltd. + * @author: Olivier Crete <olivier.crete@collabora.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write tox the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <string.h> +#include <stdlib.h> +#include <gst/rtp/gstrtpbuffer.h> +#include "fsrtpxdatadepay.h" + +static GstStaticPadTemplate fs_rtp_xdata_depay_sink_template = +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/x-rtp, " + "media = (string) \"application\", " + "encoding-name = (string) \"X-DATA\"") + ); + +static GstStaticPadTemplate fs_rtp_xdata_depay_src_template = +GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/octet-stream") + ); + +static GstBuffer *fs_rtp_xdata_depay_process (GstRTPBaseDepayload * depayload, + GstBuffer * buf); + +G_DEFINE_TYPE (FsRTPXdataDepay, fs_rtp_xdata_depay, + GST_TYPE_RTP_BASE_DEPAYLOAD); + +static void +fs_rtp_xdata_depay_class_init (FsRTPXdataDepayClass * klass) +{ + GstElementClass *gstelement_class; + GstRTPBaseDepayloadClass *gstrtpbasedepayload_class; + + gstelement_class = (GstElementClass *) klass; + gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass; + + gstrtpbasedepayload_class->process = fs_rtp_xdata_depay_process; + + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&fs_rtp_xdata_depay_src_template)); + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&fs_rtp_xdata_depay_sink_template)); + gst_element_class_set_static_metadata (gstelement_class, + "RTP Depayloader for Microsoft Lync x-data", + "Codec/Depayloader/Network/RTP", + "Extracts data from Microsoft Lync RTP x-data packets", + "Olivier Crete <olivier.crete@collabora.com>"); +} + +static void +fs_rtp_xdata_depay_init (FsRTPXdataDepay * rtpxdatadepay) +{ + GstRTPBaseDepayload *depayload = GST_RTP_BASE_DEPAYLOAD (rtpxdatadepay); + + depayload->clock_rate = 90000; +} + +static GstBuffer * +fs_rtp_xdata_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf) +{ + GstBuffer *outbuf; + GstRTPBuffer rtp = { NULL }; + + gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp); + outbuf = gst_rtp_buffer_get_payload_buffer (&rtp); + gst_rtp_buffer_unmap (&rtp); + + return outbuf; +} + +gboolean +fs_rtp_xdata_depay_plugin_init (GstPlugin * plugin) +{ + return gst_element_register (plugin, "fsrtpxdatadepay", + GST_RANK_SECONDARY, FS_TYPE_RTP_XDATA_DEPAY); +} diff --git a/gst/fsrtpxdata/fsrtpxdatadepay.h b/gst/fsrtpxdata/fsrtpxdatadepay.h new file mode 100644 index 00000000..255f6ee5 --- /dev/null +++ b/gst/fsrtpxdata/fsrtpxdatadepay.h @@ -0,0 +1,60 @@ +/* + * Microsoft Lync RTP x-data Depayloader Gst Element + * + * Copyright 2014 Collabora Ltd. + * @author: Olivier Crete <olivier.crete@collabora.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __FS_RTP_XDATA_DEPAY_H__ +#define __FS_RTP_XDATA_DEPAY_H__ + +#include <gst/gst.h> +#include <gst/rtp/gstrtpbasedepayload.h> + +G_BEGIN_DECLS typedef struct _FsRTPXdataDepay FsRTPXdataDepay; +typedef struct _FsRTPXdataDepayClass FsRTPXdataDepayClass; + +#define FS_TYPE_RTP_XDATA_DEPAY \ + (fs_rtp_xdata_depay_get_type()) +#define FS_RTP_XDATA_DEPAY(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),FS_TYPE_RTP_XDATA_DEPAY,FsRTPXdataDepay)) +#define FS_RTP_XDATA_DEPAY_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),FS_TYPE_RTP_XDATA_DEPAY,FsRTPXdataDepayClass)) +#define FS_IS_RTP_XDATA_DEPAY(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),FS_TYPE_RTP_XDATA_DEPAY)) +#define FS_IS_RTP_XDATA_DEPAY_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),FS_TYPE_RTP_XDATA_DEPAY)) + + +struct _FsRTPXdataDepay +{ + GstRTPBaseDepayload depayload; + +}; + +struct _FsRTPXdataDepayClass +{ + GstRTPBaseDepayloadClass parent_class; +}; + +GType fs_rtp_xdata_depay_get_type (void); + +gboolean fs_rtp_xdata_depay_plugin_init (GstPlugin * plugin); + +G_END_DECLS +#endif /* __FS_RTP_XDATA_DEPAY_H__ */ diff --git a/gst/fsrtpxdata/fsrtpxdatapay.c b/gst/fsrtpxdata/fsrtpxdatapay.c new file mode 100644 index 00000000..338d3c33 --- /dev/null +++ b/gst/fsrtpxdata/fsrtpxdatapay.c @@ -0,0 +1,117 @@ +/* + * Microsoft Lync RTP x-data Payloader Gst Element + * + * Copyright 2014 Collabora Ltd. + * @author: Olivier Crete <olivier.crete@collabora.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "fsrtpxdatapay.h" +#include <gst/rtp/gstrtpbuffer.h> + +GST_DEBUG_CATEGORY_STATIC (rtpxdatapay_debug); +#define GST_CAT_DEFAULT (rtpxdatapay_debug) + +static GstStaticPadTemplate fs_rtp_xdata_pay_sink_template = +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/octet-stream") + ); + +static GstStaticPadTemplate fs_rtp_xdata_pay_src_template = +GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/x-rtp, " + "media = (string) \"application\", " + "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", " + "clock-rate = (int) 90000, " + "encoding-name = (string) \"X-DATA\"") + ); + +static gboolean fs_rtp_xdata_pay_setcaps (GstRTPBasePayload * payload, + GstCaps * caps); +static GstFlowReturn fs_rtp_xdata_pay_handle_buffer (GstRTPBasePayload *payload, + GstBuffer *buffer); + +G_DEFINE_TYPE (FsRTPXdataPay, fs_rtp_xdata_pay, + GST_TYPE_RTP_BASE_PAYLOAD); + +static void +fs_rtp_xdata_pay_class_init (FsRTPXdataPayClass * klass) +{ + GstElementClass *gstelement_class; + GstRTPBasePayloadClass *gstrtpbasepayload_class; + + gstelement_class = (GstElementClass *) klass; + gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass; + + gstrtpbasepayload_class->set_caps = fs_rtp_xdata_pay_setcaps; + gstrtpbasepayload_class->handle_buffer = fs_rtp_xdata_pay_handle_buffer; + + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&fs_rtp_xdata_pay_sink_template)); + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&fs_rtp_xdata_pay_src_template)); + gst_element_class_set_static_metadata (gstelement_class, + "RTP Payloader for Microsoft Lync x-data", "Codec/Payloader/Network/RTP", + "Packetize Microsoft Lync x-data streams into RTP packets", + "Olivier Crete <olivier.crete@collabora.com>"); + + GST_DEBUG_CATEGORY_INIT (rtpxdatapay_debug, "fsrtpxdatapay", 0, + "Microsoft Lync x-data RTP payloader"); +} + +static void +fs_rtp_xdata_pay_init (FsRTPXdataPay * rtpxdatapay) +{ + GstRTPBasePayload *rtpbasepayload; + + rtpbasepayload = GST_RTP_BASE_PAYLOAD (rtpxdatapay); + + gst_rtp_base_payload_set_options (rtpbasepayload, "application", TRUE, + "X-DATA", 90000); +} + +static gboolean +fs_rtp_xdata_pay_setcaps (GstRTPBasePayload * rtpbasepayload, GstCaps * caps) +{ + return gst_rtp_base_payload_set_outcaps (rtpbasepayload, NULL); +} + +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); +} + +gboolean +fs_rtp_xdata_pay_plugin_init (GstPlugin * plugin) +{ + return gst_element_register (plugin, "fsrtpxdatapay", + GST_RANK_SECONDARY, FS_TYPE_RTP_XDATA_PAY); +} diff --git a/gst/fsrtpxdata/fsrtpxdatapay.h b/gst/fsrtpxdata/fsrtpxdatapay.h new file mode 100644 index 00000000..4f5053cd --- /dev/null +++ b/gst/fsrtpxdata/fsrtpxdatapay.h @@ -0,0 +1,58 @@ +/* + * Microsoft Lync RTP x-data Payloader Gst Element + * + * Copyright 2014 Collabora Ltd. + * @author: Olivier Crete <olivier.crete@collabora.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __FS_RTP_XDATA_PAY_H__ +#define __FS_RTP_XDATA_PAY_H__ + +#include <gst/gst.h> +#include <gst/rtp/gstrtpbasepayload.h> + +G_BEGIN_DECLS +#define FS_TYPE_RTP_XDATA_PAY \ + (fs_rtp_xdata_pay_get_type()) +#define FS_RTP_XDATA_PAY(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),FS_TYPE_RTP_XDATA_PAY,FsRTPXdataPay)) +#define FS_RTP_XDATA_PAY_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),FS_TYPE_RTP_XDATA_PAY,FsRTPXdataPayClass)) +#define FS_IS_RTP_XDATA_PAY(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),FS_TYPE_RTP_XDATA_PAY)) +#define FS_IS_RTP_XDATA_PAY_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),FS_TYPE_RTP_XDATA_PAY)) +typedef struct _FsRTPXdataPay FsRTPXdataPay; +typedef struct _FsRTPXdataPayClass FsRTPXdataPayClass; + +struct _FsRTPXdataPay +{ + GstRTPBasePayload payload; +}; + +struct _FsRTPXdataPayClass +{ + GstRTPBasePayloadClass parent_class; +}; + +GType fs_rtp_xdata_pay_get_type (void); + +gboolean fs_rtp_xdata_pay_plugin_init (GstPlugin * plugin); + +G_END_DECLS +#endif /* __FS_RTP_XDATA_PAY_H__ */ |