From 3bf911fd7586d8cb72368c4d3d25fe27c58c2e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Tue, 6 May 2014 17:01:53 -0400 Subject: fsrtpxdata: Add RTP pay/depay for Microsoft Lync RTP x-data --- configure.ac | 4 +- docs/plugins/Makefile.am | 5 +- docs/plugins/farstream-plugins-docs.sgml | 2 + docs/plugins/farstream-plugins-sections.txt | 30 +++++++ gst/fsrtpxdata/Makefile.am | 15 ++++ gst/fsrtpxdata/fsrtpxdata.c | 47 +++++++++++ gst/fsrtpxdata/fsrtpxdatadepay.c | 102 ++++++++++++++++++++++++ gst/fsrtpxdata/fsrtpxdatadepay.h | 60 ++++++++++++++ gst/fsrtpxdata/fsrtpxdatapay.c | 117 ++++++++++++++++++++++++++++ gst/fsrtpxdata/fsrtpxdatapay.h | 58 ++++++++++++++ 10 files changed, 438 insertions(+), 2 deletions(-) create mode 100644 gst/fsrtpxdata/Makefile.am create mode 100644 gst/fsrtpxdata/fsrtpxdata.c create mode 100644 gst/fsrtpxdata/fsrtpxdatadepay.c create mode 100644 gst/fsrtpxdata/fsrtpxdatadepay.h create mode 100644 gst/fsrtpxdata/fsrtpxdatapay.c create mode 100644 gst/fsrtpxdata/fsrtpxdatapay.h diff --git a/configure.ac b/configure.ac index 4f918a30..c60ae7cc 100644 --- a/configure.ac +++ b/configure.ac @@ -115,7 +115,8 @@ FS_PLUGINS_ALL=" \ fsrtpconference \ fsmsnconference \ fsrtcpfilter \ - fsvideoanyrate + fsvideoanyrate \ + fsrtpxdata \ " AC_SUBST(FS_PLUGINS_ALL) @@ -383,6 +384,7 @@ gst/fsrtpconference/Makefile gst/fsmsnconference/Makefile gst/fsrtcpfilter/Makefile gst/fsvideoanyrate/Makefile +gst/fsrtpxdata/Makefile farstream/Makefile transmitters/Makefile transmitters/rawudp/Makefile diff --git a/docs/plugins/Makefile.am b/docs/plugins/Makefile.am index 7c2c985d..da8678ff 100644 --- a/docs/plugins/Makefile.am +++ b/docs/plugins/Makefile.am @@ -62,7 +62,8 @@ SCANOBJ_DEPS = \ $(top_builddir)/gst/fsrtpconference/libfsrtpconference_doc.la \ $(top_builddir)/gst/fsmsnconference/libfsmsnconference_doc.la \ $(top_builddir)/gst/fsrawconference/libfsrawconference_doc.la \ - $(top_builddir)/gst/fsvideoanyrate/libfsvideoanyrate.la + $(top_builddir)/gst/fsvideoanyrate/libfsvideoanyrate.la \ + $(top_builddir)/gst/fsrtpxdata/libfsrtpxdata.la # Header files to ignore when scanning. IGNORE_HFILES = @@ -78,6 +79,8 @@ IGNORE_CFILES = EXTRA_HFILES = \ $(top_srcdir)/gst/fsvideoanyrate/videoanyrate.h \ + $(top_srcdir)/gst/fsrtpxdata/fsrtpxdatapay.h \ + $(top_srcdir)/gst/fsrtpxdata/fsrtpxdatadepay.h \ $(top_srcdir)/gst/fsrtpconference/fs-rtp-conference.h \ $(top_srcdir)/gst/fsrtpconference/fs-rtp-session.h \ $(top_srcdir)/gst/fsrtpconference/fs-rtp-stream.h \ diff --git a/docs/plugins/farstream-plugins-docs.sgml b/docs/plugins/farstream-plugins-docs.sgml index fd70b27e..1a7a365e 100644 --- a/docs/plugins/farstream-plugins-docs.sgml +++ b/docs/plugins/farstream-plugins-docs.sgml @@ -55,5 +55,7 @@ Utility elements + + diff --git a/docs/plugins/farstream-plugins-sections.txt b/docs/plugins/farstream-plugins-sections.txt index 25627e33..0564c134 100644 --- a/docs/plugins/farstream-plugins-sections.txt +++ b/docs/plugins/farstream-plugins-sections.txt @@ -13,6 +13,36 @@ FsVideoanyrateClass FS_IS_VIDEOANYRATE_CLASS +
+element-fsrtpxdatapay +FsRTPXdataPay +FsRTPXdataPay + +FS_IS_RTP_XDATA_PAY +FS_IS_RTP_XDATA_PAY_CLASS +FS_RTP_XDATA_PAY +FS_RTP_XDATA_PAY_CLASS +FS_TYPE_RTP_XDATA_PAY +FsRTPXdataPayClass +fs_rtp_xdata_pay_get_type +fs_rtp_xdata_pay_plugin_init +
+ +
+element-fsrtpxdatadepay +FsRTPXdataDepay +FsRTPXdataDepay + +FS_IS_RTP_XDATA_DEPAY +FS_IS_RTP_XDATA_DEPAY_CLASS +FS_RTP_XDATA_DEPAY +FS_RTP_XDATA_DEPAY_CLASS +FS_TYPE_RTP_XDATA_DEPAY +FsRTPXdataDepayClass +fs_rtp_xdata_depay_get_type +fs_rtp_xdata_depay_plugin_init +
+
element-fsrtpconference FsRtpConference 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 + * + * 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 + * + * 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 +#include +#include +#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 "); +} + +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 + * + * 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 +#include + +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 + * + * 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_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 "); + + 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 + * + * 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 +#include + +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__ */ -- cgit v1.2.1