Commit 5a1aa759 authored by Julien Isorce's avatar Julien Isorce Committed by Wim Taymans

rtpmanager: add new rtprtxsend / rtprtxreceive elements

The purpose of the sender RTX object is to keep a history
of RTP packets up to a configurable limit (in time). It will
listen for custom retransmission events from downstream. When
it receives a request for retransmission, it will look up the
requested seqnum in its list of stored packets. If the packet
is available, it will create a RTX packet according to RFC 4588
and send this as an auxiliary stream.

The receiver will listen to the custom retransmission events
from the downstream jitterbuffer and will remember the SSRC1
of the stream and seqnum that was requested. When it sees a
packet with one of the stored seqnum, it associates the SSRC2
of the stream with the SSRC1 of the master stream. From then
on it knows that SSRC2 is the retransmission stream of SSRC1.
This algorithm is stated in RFC 4588. For this algorithm to
work, RFC4588 also states that no two pending retransmission
requests can exist for the same seqnum and different SSRCs or
else it would be impossible to associate the retransmission with
the original requester SSRC.
When the RTX receiver has associated the retransmission packets,
it can depayload and forward them to the source pad of the element.

RTX is SSRC-multiplexed

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=711084
parent 19c0e920
......@@ -10,6 +10,8 @@ libgstrtpmanager_la_SOURCES = gstrtpmanager.c \
gstrtpmux.c \
gstrtpptdemux.c \
gstrtprtxqueue.c \
gstrtprtxreceive.c \
gstrtprtxsend.c \
gstrtpssrcdemux.c \
rtpjitterbuffer.c \
rtpsession.c \
......@@ -24,6 +26,8 @@ noinst_HEADERS = gstrtpbin.h \
gstrtpptdemux.h \
gstrtpssrcdemux.h \
gstrtprtxqueue.h \
gstrtprtxreceive.h \
gstrtprtxsend.h \
rtpjitterbuffer.h \
rtpsession.h \
rtpsource.h \
......
......@@ -26,6 +26,8 @@
#include "gstrtpptdemux.h"
#include "gstrtpsession.h"
#include "gstrtprtxqueue.h"
#include "gstrtprtxreceive.h"
#include "gstrtprtxsend.h"
#include "gstrtpssrcdemux.h"
#include "gstrtpdtmfmux.h"
#include "gstrtpmux.h"
......@@ -51,6 +53,12 @@ plugin_init (GstPlugin * plugin)
if (!gst_rtp_rtx_queue_plugin_init (plugin))
return FALSE;
if (!gst_rtp_rtx_receive_plugin_init (plugin))
return FALSE;
if (!gst_rtp_rtx_send_plugin_init (plugin))
return FALSE;
if (!gst_element_register (plugin, "rtpssrcdemux", GST_RANK_NONE,
GST_TYPE_RTP_SSRC_DEMUX))
return FALSE;
......
This diff is collapsed.
/* RTP Retransmission receiver element for GStreamer
*
* gstrtprtxreceive.h:
*
* Copyright (C) 2013 Collabora Ltd.
* @author Julien Isorce <julien.isorce@collabora.co.uk>
*
* 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 __GST_RTP_RTX_RECEIVE_H__
#define __GST_RTP_RTX_RECEIVE_H__
#include <gst/gst.h>
#include <gst/rtp/gstrtpbuffer.h>
G_BEGIN_DECLS
#define GST_TYPE_RTP_RTX_RECEIVE (gst_rtp_rtx_receive_get_type())
#define GST_RTP_RTX_RECEIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_RTX_RECEIVE, GstRtpRtxReceive))
#define GST_RTP_RTX_RECEIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_RTX_RECEIVE, GstRtpRtxReceiveClass))
#define GST_RTP_RTX_RECEIVE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTP_RTX_RECEIVE, GstRtpRtxReceiveClass))
#define GST_IS_RTP_RTX_RECEIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_RTX_RECEIVE))
#define GST_IS_RTP_RTX_RECEIVE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_RTX_RECEIVE))
typedef struct _GstRtpRtxReceive GstRtpRtxReceive;
typedef struct _GstRtpRtxReceiveClass GstRtpRtxReceiveClass;
struct _GstRtpRtxReceive
{
GstElement element;
/* pad */
GstPad *sinkpad;
GstPad *srcpad;
GMutex lock;
/* retrieve associated master stream from rtx stream
* it also works to retrieve rtx stream from master stream
* as we make sure all ssrc are unique */
GHashTable *ssrc2_ssrc1_map;
/* retrieve master payload type from master stream ssrc */
GHashTable *ssrc1_payload_type_map;
/* contains seqnum of request packets of whom their ssrc have
* not been associated to a rtx stream yet */
GHashTable *seqnum_ssrc1_map;
/* contains a set of payload type for all retranmission stream
* that this element should handle (usually using SDP)
* it allow to recognize if the current packet is from a rtx stream
* or not. It's not deterministic because several rtx streams can use
* the same payload type
*/
GHashTable *rtx_payload_type_set;
/* statistics */
guint num_rtx_requests;
guint num_rtx_packets;
guint num_rtx_assoc_packets;
};
struct _GstRtpRtxReceiveClass
{
GstElementClass parent_class;
};
GType gst_rtp_rtx_receive_get_type (void);
gboolean gst_rtp_rtx_receive_plugin_init (GstPlugin * plugin);
G_END_DECLS
#endif /* __GST_RTP_RTX_RECEIVE_H__ */
This diff is collapsed.
/* RTP Retransmission sender element for GStreamer
*
* gstrtprtxsend.h:
*
* Copyright (C) 2013 Collabora Ltd.
* @author Julien Isorce <julien.isorce@collabora.co.uk>
*
* 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 __GST_RTP_RTX_SEND_H__
#define __GST_RTP_RTX_SEND_H__
#include <gst/gst.h>
#include <gst/rtp/gstrtpbuffer.h>
G_BEGIN_DECLS
#define GST_TYPE_RTP_RTX_SEND (gst_rtp_rtx_send_get_type())
#define GST_RTP_RTX_SEND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_RTX_SEND, GstRtpRtxSend))
#define GST_RTP_RTX_SEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_RTX_SEND, GstRtpRtxSendClass))
#define GST_RTP_RTX_SEND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTP_RTX_SEND, GstRtpRtxSendClass))
#define GST_IS_RTP_RTX_SEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_RTX_SEND))
#define GST_IS_RTP_RTX_SEND_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_RTX_SEND))
typedef struct _GstRtpRtxSend GstRtpRtxSend;
typedef struct _GstRtpRtxSendClass GstRtpRtxSendClass;
struct _GstRtpRtxSend
{
GstElement element;
/* pad */
GstPad *sinkpad;
GstPad *srcpad;
GMutex lock;
/* history of rtp packets */
GQueue *queue;
/* rtp packets that will be pushed upon next buffer */
GList *pending;
guint32 master_ssrc;
guint32 rtx_ssrc;
guint16 next_seqnum;
guint8 rtx_payload_type;
/* retreived from SDP */
guint rtx_payload_type_pending;
guint max_size_time;
guint max_size_packets;
/* statistics */
guint num_rtx_requests;
guint num_rtx_packets;
};
struct _GstRtpRtxSendClass
{
GstElementClass parent_class;
};
GType gst_rtp_rtx_send_get_type (void);
gboolean gst_rtp_rtx_send_plugin_init (GstPlugin * plugin);
G_END_DECLS
#endif /* __GST_RTP_RTX_SEND_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment