2005-07-14 10:29:30 +00:00
|
|
|
/* GStreamer
|
2011-05-23 20:12:50 +00:00
|
|
|
* Copyright (C) <2005> Philippe Khalaf <burger@speedy.org>
|
2006-02-02 00:04:37 +00:00
|
|
|
* Copyright (C) <2005> Nokia Corporation <kai.vehmanen@nokia.com>
|
2005-07-14 10:29:30 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2005-07-14 10:29:30 +00:00
|
|
|
*/
|
|
|
|
|
2007-04-21 15:10:25 +00:00
|
|
|
/**
|
2011-11-11 11:32:23 +00:00
|
|
|
* SECTION:gstrtpbasedepayload
|
2017-01-23 19:36:11 +00:00
|
|
|
* @title: GstRTPBaseDepayload
|
2007-04-21 15:10:25 +00:00
|
|
|
* @short_description: Base class for RTP depayloader
|
|
|
|
*
|
|
|
|
* Provides a base class for RTP depayloaders
|
|
|
|
*/
|
2018-04-28 13:50:11 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2007-04-21 15:10:25 +00:00
|
|
|
|
2011-11-11 11:32:23 +00:00
|
|
|
#include "gstrtpbasedepayload.h"
|
2018-10-10 18:16:12 +00:00
|
|
|
#include "gstrtpmeta.h"
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2011-11-11 11:32:23 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (rtpbasedepayload_debug);
|
|
|
|
#define GST_CAT_DEFAULT (rtpbasedepayload_debug)
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
struct _GstRTPBaseDepayloadPrivate
|
2007-03-29 16:23:53 +00:00
|
|
|
{
|
2007-05-12 16:18:39 +00:00
|
|
|
GstClockTime npt_start;
|
|
|
|
GstClockTime npt_stop;
|
|
|
|
gdouble play_speed;
|
|
|
|
gdouble play_scale;
|
2015-03-27 20:22:36 +00:00
|
|
|
guint clock_base;
|
2019-07-12 14:56:52 +00:00
|
|
|
gboolean onvif_mode;
|
2007-06-05 16:19:30 +00:00
|
|
|
|
2007-09-04 16:18:48 +00:00
|
|
|
gboolean discont;
|
2011-11-10 16:18:00 +00:00
|
|
|
GstClockTime pts;
|
|
|
|
GstClockTime dts;
|
2007-09-19 16:09:57 +00:00
|
|
|
GstClockTime duration;
|
2008-05-23 14:14:28 +00:00
|
|
|
|
2016-04-02 08:37:55 +00:00
|
|
|
guint32 last_ssrc;
|
2014-04-12 05:10:36 +00:00
|
|
|
guint32 last_seqnum;
|
|
|
|
guint32 last_rtptime;
|
2008-05-23 14:14:28 +00:00
|
|
|
guint32 next_seqnum;
|
2019-06-13 08:36:05 +00:00
|
|
|
gint max_reorder;
|
2008-10-13 09:16:59 +00:00
|
|
|
|
|
|
|
gboolean negotiated;
|
2013-04-10 19:45:37 +00:00
|
|
|
|
|
|
|
GstCaps *last_caps;
|
2015-03-27 20:22:36 +00:00
|
|
|
GstEvent *segment_event;
|
2018-06-05 15:24:55 +00:00
|
|
|
guint32 segment_seqnum; /* Note: this is a GstEvent seqnum */
|
2018-10-10 18:16:12 +00:00
|
|
|
|
|
|
|
gboolean source_info;
|
|
|
|
GstBuffer *input_buffer;
|
2019-11-22 02:04:14 +00:00
|
|
|
|
|
|
|
GstFlowReturn process_flow_ret;
|
2007-03-29 16:23:53 +00:00
|
|
|
};
|
|
|
|
|
2005-07-14 10:29:30 +00:00
|
|
|
/* Filter signals and args */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2018-10-10 18:16:12 +00:00
|
|
|
#define DEFAULT_SOURCE_INFO FALSE
|
2019-06-13 08:36:05 +00:00
|
|
|
#define DEFAULT_MAX_REORDER 100
|
2018-10-10 18:16:12 +00:00
|
|
|
|
2005-07-14 10:29:30 +00:00
|
|
|
enum
|
|
|
|
{
|
2007-03-29 16:23:53 +00:00
|
|
|
PROP_0,
|
2014-04-12 05:10:36 +00:00
|
|
|
PROP_STATS,
|
2018-10-10 18:16:12 +00:00
|
|
|
PROP_SOURCE_INFO,
|
2019-06-13 08:36:05 +00:00
|
|
|
PROP_MAX_REORDER,
|
2008-05-02 12:11:07 +00:00
|
|
|
PROP_LAST
|
2005-07-14 10:29:30 +00:00
|
|
|
};
|
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
static void gst_rtp_base_depayload_finalize (GObject * object);
|
|
|
|
static void gst_rtp_base_depayload_set_property (GObject * object,
|
2005-07-14 10:29:30 +00:00
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
2011-11-11 11:24:08 +00:00
|
|
|
static void gst_rtp_base_depayload_get_property (GObject * object,
|
2005-07-14 10:29:30 +00:00
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
static GstFlowReturn gst_rtp_base_depayload_chain (GstPad * pad,
|
2011-11-17 11:48:25 +00:00
|
|
|
GstObject * parent, GstBuffer * in);
|
2015-05-21 12:59:55 +00:00
|
|
|
static GstFlowReturn gst_rtp_base_depayload_chain_list (GstPad * pad,
|
|
|
|
GstObject * parent, GstBufferList * list);
|
2011-11-11 11:24:08 +00:00
|
|
|
static gboolean gst_rtp_base_depayload_handle_sink_event (GstPad * pad,
|
2011-11-17 11:48:25 +00:00
|
|
|
GstObject * parent, GstEvent * event);
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
static GstStateChangeReturn gst_rtp_base_depayload_change_state (GstElement *
|
2005-09-02 15:43:18 +00:00
|
|
|
element, GstStateChange transition);
|
2007-03-29 16:23:53 +00:00
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
static gboolean gst_rtp_base_depayload_packet_lost (GstRTPBaseDepayload *
|
2008-05-02 12:11:07 +00:00
|
|
|
filter, GstEvent * event);
|
2011-11-11 11:24:08 +00:00
|
|
|
static gboolean gst_rtp_base_depayload_handle_event (GstRTPBaseDepayload *
|
2010-12-21 14:02:18 +00:00
|
|
|
filter, GstEvent * event);
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2011-04-18 16:29:35 +00:00
|
|
|
static GstElementClass *parent_class = NULL;
|
2018-06-23 19:33:16 +00:00
|
|
|
static gint private_offset = 0;
|
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
static void gst_rtp_base_depayload_class_init (GstRTPBaseDepayloadClass *
|
2011-04-18 16:29:35 +00:00
|
|
|
klass);
|
2011-11-11 11:32:23 +00:00
|
|
|
static void gst_rtp_base_depayload_init (GstRTPBaseDepayload * rtpbasepayload,
|
2011-11-11 11:24:08 +00:00
|
|
|
GstRTPBaseDepayloadClass * klass);
|
2015-03-27 20:22:36 +00:00
|
|
|
static GstEvent *create_segment_event (GstRTPBaseDepayload * filter,
|
|
|
|
guint rtptime, GstClockTime position);
|
2011-04-18 16:29:35 +00:00
|
|
|
|
|
|
|
GType
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_rtp_base_depayload_get_type (void)
|
2005-07-14 10:29:30 +00:00
|
|
|
{
|
2011-11-11 11:24:08 +00:00
|
|
|
static GType rtp_base_depayload_type = 0;
|
2011-04-18 16:29:35 +00:00
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
if (g_once_init_enter ((gsize *) & rtp_base_depayload_type)) {
|
|
|
|
static const GTypeInfo rtp_base_depayload_info = {
|
|
|
|
sizeof (GstRTPBaseDepayloadClass),
|
2011-04-18 16:29:35 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2011-11-11 11:24:08 +00:00
|
|
|
(GClassInitFunc) gst_rtp_base_depayload_class_init,
|
2011-04-18 16:29:35 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2011-11-11 11:24:08 +00:00
|
|
|
sizeof (GstRTPBaseDepayload),
|
2011-04-18 16:29:35 +00:00
|
|
|
0,
|
2011-11-11 11:24:08 +00:00
|
|
|
(GInstanceInitFunc) gst_rtp_base_depayload_init,
|
2011-04-18 16:29:35 +00:00
|
|
|
};
|
2018-06-23 19:33:16 +00:00
|
|
|
GType _type;
|
|
|
|
|
|
|
|
_type = g_type_register_static (GST_TYPE_ELEMENT, "GstRTPBaseDepayload",
|
|
|
|
&rtp_base_depayload_info, G_TYPE_FLAG_ABSTRACT);
|
|
|
|
|
|
|
|
private_offset =
|
|
|
|
g_type_add_instance_private (_type,
|
|
|
|
sizeof (GstRTPBaseDepayloadPrivate));
|
2011-04-18 16:29:35 +00:00
|
|
|
|
2018-06-23 19:33:16 +00:00
|
|
|
g_once_init_leave ((gsize *) & rtp_base_depayload_type, _type);
|
2011-04-18 16:29:35 +00:00
|
|
|
}
|
2011-11-11 11:24:08 +00:00
|
|
|
return rtp_base_depayload_type;
|
2005-07-14 10:29:30 +00:00
|
|
|
}
|
|
|
|
|
2018-06-23 19:33:16 +00:00
|
|
|
static inline GstRTPBaseDepayloadPrivate *
|
|
|
|
gst_rtp_base_depayload_get_instance_private (GstRTPBaseDepayload * self)
|
|
|
|
{
|
|
|
|
return (G_STRUCT_MEMBER_P (self, private_offset));
|
|
|
|
}
|
|
|
|
|
2005-07-14 10:29:30 +00:00
|
|
|
static void
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_rtp_base_depayload_class_init (GstRTPBaseDepayloadClass * klass)
|
2005-07-14 10:29:30 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
2005-08-12 13:34:56 +00:00
|
|
|
GstElementClass *gstelement_class;
|
2005-07-14 10:29:30 +00:00
|
|
|
|
|
|
|
gobject_class = G_OBJECT_CLASS (klass);
|
2005-08-12 13:34:56 +00:00
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2005-10-26 20:00:46 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2018-06-23 19:33:16 +00:00
|
|
|
if (private_offset != 0)
|
|
|
|
g_type_class_adjust_private_offset (klass, &private_offset);
|
2007-03-29 16:23:53 +00:00
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
gobject_class->finalize = gst_rtp_base_depayload_finalize;
|
|
|
|
gobject_class->set_property = gst_rtp_base_depayload_set_property;
|
|
|
|
gobject_class->get_property = gst_rtp_base_depayload_get_property;
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2014-04-12 05:10:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstRTPBaseDepayload:stats:
|
|
|
|
*
|
|
|
|
* Various depayloader statistics retrieved atomically (and are therefore
|
|
|
|
* synchroized with each other). This property return a GstStructure named
|
|
|
|
* application/x-rtp-depayload-stats containing the following fields relating to
|
|
|
|
* the last processed buffer and current state of the stream being depayloaded:
|
|
|
|
*
|
2017-01-23 19:36:11 +00:00
|
|
|
* * `clock-rate`: #G_TYPE_UINT, clock-rate of the stream
|
|
|
|
* * `npt-start`: #G_TYPE_UINT64, time of playback start
|
|
|
|
* * `npt-stop`: #G_TYPE_UINT64, time of playback stop
|
|
|
|
* * `play-speed`: #G_TYPE_DOUBLE, the playback speed
|
|
|
|
* * `play-scale`: #G_TYPE_DOUBLE, the playback scale
|
|
|
|
* * `running-time-dts`: #G_TYPE_UINT64, the last running-time of the
|
2014-04-12 05:10:36 +00:00
|
|
|
* last DTS
|
2017-01-23 19:36:11 +00:00
|
|
|
* * `running-time-pts`: #G_TYPE_UINT64, the last running-time of the
|
2014-04-12 05:10:36 +00:00
|
|
|
* last PTS
|
2017-01-23 19:36:11 +00:00
|
|
|
* * `seqnum`: #G_TYPE_UINT, the last seen seqnum
|
|
|
|
* * `timestamp`: #G_TYPE_UINT, the last seen RTP timestamp
|
2014-04-12 05:10:36 +00:00
|
|
|
**/
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_STATS,
|
|
|
|
g_param_spec_boxed ("stats", "Statistics", "Various statistics",
|
|
|
|
GST_TYPE_STRUCTURE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2018-10-10 18:16:12 +00:00
|
|
|
/**
|
|
|
|
* GstRTPBaseDepayload:source-info:
|
|
|
|
*
|
|
|
|
* Add RTP source information found in RTP header as meta to output buffer.
|
|
|
|
*
|
|
|
|
* Since: 1.16
|
|
|
|
**/
|
|
|
|
g_object_class_install_property (gobject_class, PROP_SOURCE_INFO,
|
|
|
|
g_param_spec_boolean ("source-info", "RTP source information",
|
|
|
|
"Add RTP source information as buffer meta",
|
|
|
|
DEFAULT_SOURCE_INFO, G_PARAM_READWRITE));
|
|
|
|
|
2019-06-13 08:36:05 +00:00
|
|
|
/**
|
|
|
|
* GstRTPBaseDepayload:max-reorder:
|
|
|
|
*
|
|
|
|
* Max seqnum reorder before the sender is assumed to have restarted.
|
|
|
|
*
|
|
|
|
* When max-reorder is set to 0 all reordered/duplicate packets are
|
|
|
|
* considered coming from a restarted sender.
|
|
|
|
*
|
|
|
|
* Since: 1.18
|
|
|
|
**/
|
|
|
|
g_object_class_install_property (gobject_class, PROP_MAX_REORDER,
|
|
|
|
g_param_spec_int ("max-reorder", "Max Reorder",
|
|
|
|
"Max seqnum reorder before assuming sender has restarted",
|
|
|
|
0, G_MAXINT, DEFAULT_MAX_REORDER, G_PARAM_READWRITE));
|
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
gstelement_class->change_state = gst_rtp_base_depayload_change_state;
|
2005-08-12 13:34:56 +00:00
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
klass->packet_lost = gst_rtp_base_depayload_packet_lost;
|
|
|
|
klass->handle_event = gst_rtp_base_depayload_handle_event;
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2011-11-11 11:32:23 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (rtpbasedepayload_debug, "rtpbasedepayload", 0,
|
2005-07-14 10:29:30 +00:00
|
|
|
"Base class for RTP Depayloaders");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_rtp_base_depayload_init (GstRTPBaseDepayload * filter,
|
|
|
|
GstRTPBaseDepayloadClass * klass)
|
2005-07-14 10:29:30 +00:00
|
|
|
{
|
|
|
|
GstPadTemplate *pad_template;
|
2011-11-11 11:24:08 +00:00
|
|
|
GstRTPBaseDepayloadPrivate *priv;
|
2007-03-29 16:23:53 +00:00
|
|
|
|
2018-06-23 19:33:16 +00:00
|
|
|
priv = gst_rtp_base_depayload_get_instance_private (filter);
|
|
|
|
|
2007-03-29 16:23:53 +00:00
|
|
|
filter->priv = priv;
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2005-10-31 15:32:54 +00:00
|
|
|
GST_DEBUG_OBJECT (filter, "init");
|
2005-07-14 10:29:30 +00:00
|
|
|
|
|
|
|
pad_template =
|
2007-03-29 16:23:53 +00:00
|
|
|
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (klass), "sink");
|
2005-07-14 10:29:30 +00:00
|
|
|
g_return_if_fail (pad_template != NULL);
|
|
|
|
filter->sinkpad = gst_pad_new_from_template (pad_template, "sink");
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_pad_set_chain_function (filter->sinkpad, gst_rtp_base_depayload_chain);
|
2015-05-21 12:59:55 +00:00
|
|
|
gst_pad_set_chain_list_function (filter->sinkpad,
|
|
|
|
gst_rtp_base_depayload_chain_list);
|
2005-12-18 00:56:07 +00:00
|
|
|
gst_pad_set_event_function (filter->sinkpad,
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_rtp_base_depayload_handle_sink_event);
|
2005-07-14 10:29:30 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
|
|
|
|
|
|
|
|
pad_template =
|
2007-03-29 16:23:53 +00:00
|
|
|
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (klass), "src");
|
2005-07-14 10:29:30 +00:00
|
|
|
g_return_if_fail (pad_template != NULL);
|
|
|
|
filter->srcpad = gst_pad_new_from_template (pad_template, "src");
|
2006-09-27 11:06:54 +00:00
|
|
|
gst_pad_use_fixed_caps (filter->srcpad);
|
2005-07-14 10:29:30 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
|
|
|
|
|
2014-04-12 05:10:36 +00:00
|
|
|
priv->npt_start = 0;
|
|
|
|
priv->npt_stop = -1;
|
|
|
|
priv->play_speed = 1.0;
|
|
|
|
priv->play_scale = 1.0;
|
2015-03-27 20:22:36 +00:00
|
|
|
priv->clock_base = -1;
|
2019-07-12 14:56:52 +00:00
|
|
|
priv->onvif_mode = FALSE;
|
2014-04-12 05:10:36 +00:00
|
|
|
priv->dts = -1;
|
|
|
|
priv->pts = -1;
|
|
|
|
priv->duration = -1;
|
2018-10-10 18:16:12 +00:00
|
|
|
priv->source_info = DEFAULT_SOURCE_INFO;
|
2019-06-13 08:36:05 +00:00
|
|
|
priv->max_reorder = DEFAULT_MAX_REORDER;
|
2014-04-12 05:10:36 +00:00
|
|
|
|
2007-09-16 19:31:06 +00:00
|
|
|
gst_segment_init (&filter->segment, GST_FORMAT_UNDEFINED);
|
2005-07-14 10:29:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_rtp_base_depayload_finalize (GObject * object)
|
2005-07-14 10:29:30 +00:00
|
|
|
{
|
2006-09-22 14:13:34 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2005-07-14 10:29:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_rtp_base_depayload_setcaps (GstRTPBaseDepayload * filter, GstCaps * caps)
|
2005-07-14 10:29:30 +00:00
|
|
|
{
|
2011-11-11 11:24:08 +00:00
|
|
|
GstRTPBaseDepayloadClass *bclass;
|
|
|
|
GstRTPBaseDepayloadPrivate *priv;
|
2006-03-07 12:49:03 +00:00
|
|
|
gboolean res;
|
2007-03-29 16:23:53 +00:00
|
|
|
GstStructure *caps_struct;
|
|
|
|
const GValue *value;
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2007-03-29 16:23:53 +00:00
|
|
|
priv = filter->priv;
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
bclass = GST_RTP_BASE_DEPAYLOAD_GET_CLASS (filter);
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2013-04-10 19:45:37 +00:00
|
|
|
GST_DEBUG_OBJECT (filter, "Set caps %" GST_PTR_FORMAT, caps);
|
|
|
|
|
|
|
|
if (priv->last_caps) {
|
|
|
|
if (gst_caps_is_equal (priv->last_caps, caps)) {
|
|
|
|
res = TRUE;
|
|
|
|
goto caps_not_changed;
|
|
|
|
} else {
|
|
|
|
gst_caps_unref (priv->last_caps);
|
|
|
|
priv->last_caps = NULL;
|
|
|
|
}
|
|
|
|
}
|
2007-03-29 16:23:53 +00:00
|
|
|
|
|
|
|
caps_struct = gst_caps_get_structure (caps, 0);
|
|
|
|
|
2019-07-12 14:56:52 +00:00
|
|
|
value = gst_structure_get_value (caps_struct, "onvif-mode");
|
|
|
|
if (value && G_VALUE_HOLDS_BOOLEAN (value))
|
|
|
|
priv->onvif_mode = g_value_get_boolean (value);
|
|
|
|
else
|
|
|
|
priv->onvif_mode = FALSE;
|
|
|
|
GST_DEBUG_OBJECT (filter, "Onvif mode: %d", priv->onvif_mode);
|
|
|
|
|
|
|
|
if (priv->onvif_mode)
|
|
|
|
filter->need_newsegment = FALSE;
|
|
|
|
|
2007-05-12 16:18:39 +00:00
|
|
|
/* get other values for newsegment */
|
|
|
|
value = gst_structure_get_value (caps_struct, "npt-start");
|
|
|
|
if (value && G_VALUE_HOLDS_UINT64 (value))
|
|
|
|
priv->npt_start = g_value_get_uint64 (value);
|
|
|
|
else
|
|
|
|
priv->npt_start = 0;
|
2007-10-08 18:04:34 +00:00
|
|
|
GST_DEBUG_OBJECT (filter, "NPT start %" G_GUINT64_FORMAT, priv->npt_start);
|
2007-05-12 16:18:39 +00:00
|
|
|
|
|
|
|
value = gst_structure_get_value (caps_struct, "npt-stop");
|
|
|
|
if (value && G_VALUE_HOLDS_UINT64 (value))
|
|
|
|
priv->npt_stop = g_value_get_uint64 (value);
|
|
|
|
else
|
|
|
|
priv->npt_stop = -1;
|
|
|
|
|
2007-10-08 18:04:34 +00:00
|
|
|
GST_DEBUG_OBJECT (filter, "NPT stop %" G_GUINT64_FORMAT, priv->npt_stop);
|
2007-09-16 19:31:06 +00:00
|
|
|
|
2007-05-12 16:18:39 +00:00
|
|
|
value = gst_structure_get_value (caps_struct, "play-speed");
|
|
|
|
if (value && G_VALUE_HOLDS_DOUBLE (value))
|
|
|
|
priv->play_speed = g_value_get_double (value);
|
|
|
|
else
|
|
|
|
priv->play_speed = 1.0;
|
|
|
|
|
|
|
|
value = gst_structure_get_value (caps_struct, "play-scale");
|
|
|
|
if (value && G_VALUE_HOLDS_DOUBLE (value))
|
|
|
|
priv->play_scale = g_value_get_double (value);
|
|
|
|
else
|
|
|
|
priv->play_scale = 1.0;
|
|
|
|
|
2015-03-27 20:22:36 +00:00
|
|
|
value = gst_structure_get_value (caps_struct, "clock-base");
|
|
|
|
if (value && G_VALUE_HOLDS_UINT (value))
|
|
|
|
priv->clock_base = g_value_get_uint (value);
|
|
|
|
else
|
|
|
|
priv->clock_base = -1;
|
|
|
|
|
2010-09-06 17:17:10 +00:00
|
|
|
if (bclass->set_caps) {
|
2006-03-07 12:49:03 +00:00
|
|
|
res = bclass->set_caps (filter, caps);
|
2010-09-06 17:17:10 +00:00
|
|
|
if (!res) {
|
|
|
|
GST_WARNING_OBJECT (filter, "Subclass rejected caps %" GST_PTR_FORMAT,
|
|
|
|
caps);
|
|
|
|
}
|
|
|
|
} else {
|
2006-03-07 12:49:03 +00:00
|
|
|
res = TRUE;
|
2010-09-06 17:17:10 +00:00
|
|
|
}
|
2006-03-07 12:49:03 +00:00
|
|
|
|
2008-10-13 09:16:59 +00:00
|
|
|
priv->negotiated = res;
|
|
|
|
|
2013-04-10 19:45:37 +00:00
|
|
|
if (priv->negotiated)
|
|
|
|
priv->last_caps = gst_caps_ref (caps);
|
|
|
|
|
2006-03-07 12:49:03 +00:00
|
|
|
return res;
|
2013-04-10 19:45:37 +00:00
|
|
|
|
|
|
|
caps_not_changed:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (filter, "Caps did not change");
|
|
|
|
return res;
|
|
|
|
}
|
2005-07-14 10:29:30 +00:00
|
|
|
}
|
|
|
|
|
2015-12-11 10:25:00 +00:00
|
|
|
/* takes ownership of the input buffer */
|
2005-07-14 10:29:30 +00:00
|
|
|
static GstFlowReturn
|
2015-05-21 12:59:55 +00:00
|
|
|
gst_rtp_base_depayload_handle_buffer (GstRTPBaseDepayload * filter,
|
|
|
|
GstRTPBaseDepayloadClass * bclass, GstBuffer * in)
|
2005-07-14 10:29:30 +00:00
|
|
|
{
|
2015-05-27 17:55:20 +00:00
|
|
|
GstBuffer *(*process_rtp_packet_func) (GstRTPBaseDepayload * base,
|
|
|
|
GstRTPBuffer * rtp_buffer);
|
|
|
|
GstBuffer *(*process_func) (GstRTPBaseDepayload * base, GstBuffer * in);
|
2011-11-11 11:24:08 +00:00
|
|
|
GstRTPBaseDepayloadPrivate *priv;
|
2007-08-31 15:58:30 +00:00
|
|
|
GstBuffer *out_buf;
|
2016-04-02 08:37:55 +00:00
|
|
|
guint32 ssrc;
|
2008-05-23 14:14:28 +00:00
|
|
|
guint16 seqnum;
|
2008-10-06 16:29:33 +00:00
|
|
|
guint32 rtptime;
|
2013-08-21 10:34:24 +00:00
|
|
|
gboolean discont, buf_discont;
|
2008-05-23 14:14:28 +00:00
|
|
|
gint gap;
|
2011-12-05 17:42:24 +00:00
|
|
|
GstRTPBuffer rtp = { NULL };
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2008-10-13 09:16:59 +00:00
|
|
|
priv = filter->priv;
|
2019-11-22 02:04:14 +00:00
|
|
|
priv->process_flow_ret = GST_FLOW_OK;
|
2008-10-13 09:16:59 +00:00
|
|
|
|
2015-05-27 17:55:20 +00:00
|
|
|
process_func = bclass->process;
|
|
|
|
process_rtp_packet_func = bclass->process_rtp_packet;
|
|
|
|
|
2008-10-13 09:16:59 +00:00
|
|
|
/* we must have a setcaps first */
|
|
|
|
if (G_UNLIKELY (!priv->negotiated))
|
|
|
|
goto not_negotiated;
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2012-07-17 14:35:06 +00:00
|
|
|
if (G_UNLIKELY (!gst_rtp_buffer_map (in, GST_MAP_READ, &rtp)))
|
2008-05-14 20:28:02 +00:00
|
|
|
goto invalid_buffer;
|
|
|
|
|
2013-08-21 10:34:24 +00:00
|
|
|
buf_discont = GST_BUFFER_IS_DISCONT (in);
|
2007-09-04 16:18:48 +00:00
|
|
|
|
2015-08-05 19:32:54 +00:00
|
|
|
priv->pts = GST_BUFFER_PTS (in);
|
|
|
|
priv->dts = GST_BUFFER_DTS (in);
|
2007-09-19 16:09:57 +00:00
|
|
|
priv->duration = GST_BUFFER_DURATION (in);
|
2007-09-16 19:31:06 +00:00
|
|
|
|
2016-04-02 08:37:55 +00:00
|
|
|
ssrc = gst_rtp_buffer_get_ssrc (&rtp);
|
2011-03-27 11:55:15 +00:00
|
|
|
seqnum = gst_rtp_buffer_get_seq (&rtp);
|
|
|
|
rtptime = gst_rtp_buffer_get_timestamp (&rtp);
|
|
|
|
|
2014-04-12 05:10:36 +00:00
|
|
|
priv->last_seqnum = seqnum;
|
|
|
|
priv->last_rtptime = rtptime;
|
|
|
|
|
2013-08-21 10:34:24 +00:00
|
|
|
discont = buf_discont;
|
2008-05-23 14:14:28 +00:00
|
|
|
|
2011-11-10 16:18:00 +00:00
|
|
|
GST_LOG_OBJECT (filter, "discont %d, seqnum %u, rtptime %u, pts %"
|
2013-08-21 10:34:24 +00:00
|
|
|
GST_TIME_FORMAT ", dts %" GST_TIME_FORMAT, buf_discont, seqnum, rtptime,
|
2015-08-05 19:32:54 +00:00
|
|
|
GST_TIME_ARGS (priv->pts), GST_TIME_ARGS (priv->dts));
|
2008-05-23 14:14:28 +00:00
|
|
|
|
|
|
|
/* Check seqnum. This is a very simple check that makes sure that the seqnums
|
2015-07-07 18:56:52 +00:00
|
|
|
* are strictly increasing, dropping anything that is out of the ordinary. We
|
2008-05-23 14:14:28 +00:00
|
|
|
* can only do this when the next_seqnum is known. */
|
2008-10-13 09:16:59 +00:00
|
|
|
if (G_LIKELY (priv->next_seqnum != -1)) {
|
2016-04-02 08:37:55 +00:00
|
|
|
if (ssrc != priv->last_ssrc) {
|
|
|
|
GST_LOG_OBJECT (filter,
|
|
|
|
"New ssrc %u (current ssrc %u), sender restarted",
|
|
|
|
ssrc, priv->last_ssrc);
|
2016-04-12 13:34:00 +00:00
|
|
|
discont = TRUE;
|
2016-04-02 08:37:55 +00:00
|
|
|
} else {
|
|
|
|
gap = gst_rtp_buffer_compare_seqnum (seqnum, priv->next_seqnum);
|
|
|
|
|
|
|
|
/* if we have no gap, all is fine */
|
|
|
|
if (G_UNLIKELY (gap != 0)) {
|
|
|
|
GST_LOG_OBJECT (filter, "got packet %u, expected %u, gap %d", seqnum,
|
|
|
|
priv->next_seqnum, gap);
|
|
|
|
if (gap < 0) {
|
|
|
|
/* seqnum > next_seqnum, we are missing some packets, this is always a
|
|
|
|
* DISCONT. */
|
|
|
|
GST_LOG_OBJECT (filter, "%d missing packets", gap);
|
|
|
|
discont = TRUE;
|
|
|
|
} else {
|
2019-06-13 08:36:05 +00:00
|
|
|
/* seqnum < next_seqnum, we have seen this packet before, have a
|
|
|
|
* reordered packet or the sender could be restarted. If the packet
|
|
|
|
* is not too old, we throw it away as a duplicate. Otherwise we
|
|
|
|
* mark discont and continue assuming the sender has restarted. See
|
|
|
|
* also RFC 4737. */
|
|
|
|
GST_WARNING ("gap %d <= priv->max_reorder %d -> dropping %d",
|
|
|
|
gap, priv->max_reorder, gap <= priv->max_reorder);
|
|
|
|
if (gap <= priv->max_reorder)
|
2016-04-02 08:37:55 +00:00
|
|
|
goto dropping;
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (filter,
|
2019-06-13 08:36:05 +00:00
|
|
|
"%d > %d, packet too old, sender likely restarted", gap,
|
|
|
|
priv->max_reorder);
|
2016-04-02 08:37:55 +00:00
|
|
|
discont = TRUE;
|
|
|
|
}
|
2008-05-23 14:14:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
priv->next_seqnum = (seqnum + 1) & 0xffff;
|
2016-04-02 08:37:55 +00:00
|
|
|
priv->last_ssrc = ssrc;
|
2008-05-23 14:14:28 +00:00
|
|
|
|
2013-08-21 10:34:24 +00:00
|
|
|
if (G_UNLIKELY (discont)) {
|
2008-05-23 14:14:28 +00:00
|
|
|
priv->discont = TRUE;
|
2013-08-21 10:34:24 +00:00
|
|
|
if (!buf_discont) {
|
2015-12-11 11:01:53 +00:00
|
|
|
gpointer old_inbuf = in;
|
|
|
|
|
2013-08-21 10:34:24 +00:00
|
|
|
/* we detected a seqnum discont but the buffer was not flagged with a discont,
|
|
|
|
* set the discont flag so that the subclass can throw away old data. */
|
|
|
|
GST_LOG_OBJECT (filter, "mark DISCONT on input buffer");
|
|
|
|
in = gst_buffer_make_writable (in);
|
|
|
|
GST_BUFFER_FLAG_SET (in, GST_BUFFER_FLAG_DISCONT);
|
2015-12-11 11:01:53 +00:00
|
|
|
/* depayloaders will check flag on rtpbuffer->buffer, so if the input
|
|
|
|
* buffer was not writable already we need to remap to make our
|
|
|
|
* newly-flagged buffer current on the rtpbuffer */
|
|
|
|
if (in != old_inbuf) {
|
|
|
|
gst_rtp_buffer_unmap (&rtp);
|
|
|
|
if (G_UNLIKELY (!gst_rtp_buffer_map (in, GST_MAP_READ, &rtp)))
|
|
|
|
goto invalid_buffer;
|
|
|
|
}
|
2013-08-21 10:34:24 +00:00
|
|
|
}
|
2008-05-23 14:14:28 +00:00
|
|
|
}
|
|
|
|
|
2015-03-27 20:22:36 +00:00
|
|
|
/* prepare segment event if needed */
|
|
|
|
if (filter->need_newsegment) {
|
|
|
|
priv->segment_event = create_segment_event (filter, rtptime,
|
|
|
|
GST_BUFFER_PTS (in));
|
|
|
|
filter->need_newsegment = FALSE;
|
|
|
|
}
|
|
|
|
|
2018-10-10 18:16:12 +00:00
|
|
|
priv->input_buffer = in;
|
|
|
|
|
2015-05-27 17:55:20 +00:00
|
|
|
if (process_rtp_packet_func != NULL) {
|
|
|
|
out_buf = process_rtp_packet_func (filter, &rtp);
|
|
|
|
gst_rtp_buffer_unmap (&rtp);
|
|
|
|
} else if (process_func != NULL) {
|
|
|
|
gst_rtp_buffer_unmap (&rtp);
|
|
|
|
out_buf = process_func (filter, in);
|
|
|
|
} else {
|
2008-05-23 14:14:28 +00:00
|
|
|
goto no_process;
|
2015-05-27 17:55:20 +00:00
|
|
|
}
|
2008-05-23 14:14:28 +00:00
|
|
|
|
2007-08-31 15:58:30 +00:00
|
|
|
/* let's send it out to processing */
|
|
|
|
if (out_buf) {
|
2019-11-22 02:04:14 +00:00
|
|
|
if (priv->process_flow_ret == GST_FLOW_OK)
|
|
|
|
priv->process_flow_ret = gst_rtp_base_depayload_push (filter, out_buf);
|
|
|
|
else
|
|
|
|
gst_buffer_unref (out_buf);
|
2005-07-14 10:29:30 +00:00
|
|
|
}
|
2007-08-31 15:58:30 +00:00
|
|
|
|
2015-12-11 10:25:00 +00:00
|
|
|
gst_buffer_unref (in);
|
2018-10-10 18:16:12 +00:00
|
|
|
priv->input_buffer = NULL;
|
2015-12-11 10:25:00 +00:00
|
|
|
|
2019-11-22 02:04:14 +00:00
|
|
|
return priv->process_flow_ret;
|
2008-05-14 20:28:02 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
2008-10-13 09:16:59 +00:00
|
|
|
not_negotiated:
|
|
|
|
{
|
|
|
|
/* this is not fatal but should be filtered earlier */
|
2011-05-09 11:05:12 +00:00
|
|
|
GST_ELEMENT_ERROR (filter, CORE, NEGOTIATION,
|
|
|
|
("No RTP format was negotiated."),
|
|
|
|
("Input buffers need to have RTP caps set on them. This is usually "
|
|
|
|
"achieved by setting the 'caps' property of the upstream source "
|
|
|
|
"element (often udpsrc or appsrc), or by putting a capsfilter "
|
|
|
|
"element before the depayloader and setting the 'caps' property "
|
|
|
|
"on that. Also see http://cgit.freedesktop.org/gstreamer/"
|
|
|
|
"gst-plugins-good/tree/gst/rtp/README"));
|
2015-12-11 10:25:00 +00:00
|
|
|
gst_buffer_unref (in);
|
2008-10-13 09:16:59 +00:00
|
|
|
return GST_FLOW_NOT_NEGOTIATED;
|
|
|
|
}
|
2008-05-14 20:28:02 +00:00
|
|
|
invalid_buffer:
|
|
|
|
{
|
|
|
|
/* this is not fatal but should be filtered earlier */
|
|
|
|
GST_ELEMENT_WARNING (filter, STREAM, DECODE, (NULL),
|
|
|
|
("Received invalid RTP payload, dropping"));
|
2015-12-11 10:25:00 +00:00
|
|
|
gst_buffer_unref (in);
|
2008-05-14 20:28:02 +00:00
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
2008-05-23 14:14:28 +00:00
|
|
|
dropping:
|
|
|
|
{
|
2015-07-30 11:50:56 +00:00
|
|
|
gst_rtp_buffer_unmap (&rtp);
|
2019-06-13 08:36:05 +00:00
|
|
|
GST_WARNING_OBJECT (filter, "%d <= %d, dropping old packet", gap,
|
|
|
|
priv->max_reorder);
|
2015-12-11 10:25:00 +00:00
|
|
|
gst_buffer_unref (in);
|
2008-05-23 14:14:28 +00:00
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
no_process:
|
|
|
|
{
|
2015-07-30 11:50:56 +00:00
|
|
|
gst_rtp_buffer_unmap (&rtp);
|
2008-05-23 14:14:28 +00:00
|
|
|
/* this is not fatal but should be filtered earlier */
|
|
|
|
GST_ELEMENT_ERROR (filter, STREAM, NOT_IMPLEMENTED, (NULL),
|
2015-05-27 17:55:20 +00:00
|
|
|
("The subclass does not have a process or process_rtp_packet method"));
|
2015-12-11 10:25:00 +00:00
|
|
|
gst_buffer_unref (in);
|
2008-05-23 14:14:28 +00:00
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
2005-07-14 10:29:30 +00:00
|
|
|
}
|
|
|
|
|
2015-05-21 12:59:55 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_rtp_base_depayload_chain (GstPad * pad, GstObject * parent, GstBuffer * in)
|
|
|
|
{
|
|
|
|
GstRTPBaseDepayloadClass *bclass;
|
|
|
|
GstRTPBaseDepayload *basedepay;
|
|
|
|
GstFlowReturn flow_ret;
|
|
|
|
|
|
|
|
basedepay = GST_RTP_BASE_DEPAYLOAD_CAST (parent);
|
|
|
|
|
|
|
|
bclass = GST_RTP_BASE_DEPAYLOAD_GET_CLASS (basedepay);
|
|
|
|
|
|
|
|
flow_ret = gst_rtp_base_depayload_handle_buffer (basedepay, bclass, in);
|
|
|
|
|
|
|
|
return flow_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_rtp_base_depayload_chain_list (GstPad * pad, GstObject * parent,
|
|
|
|
GstBufferList * list)
|
|
|
|
{
|
|
|
|
GstRTPBaseDepayloadClass *bclass;
|
|
|
|
GstRTPBaseDepayload *basedepay;
|
|
|
|
GstFlowReturn flow_ret;
|
|
|
|
GstBuffer *buffer;
|
|
|
|
guint i, len;
|
|
|
|
|
|
|
|
basedepay = GST_RTP_BASE_DEPAYLOAD_CAST (parent);
|
|
|
|
|
|
|
|
bclass = GST_RTP_BASE_DEPAYLOAD_GET_CLASS (basedepay);
|
|
|
|
|
|
|
|
flow_ret = GST_FLOW_OK;
|
|
|
|
|
|
|
|
/* chain each buffer in list individually */
|
|
|
|
len = gst_buffer_list_length (list);
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
buffer = gst_buffer_list_get (list, i);
|
|
|
|
|
2015-12-11 10:25:00 +00:00
|
|
|
/* handle_buffer takes ownership of input buffer */
|
|
|
|
/* FIXME: add a way to steal buffers from list as we will unref it anyway */
|
|
|
|
gst_buffer_ref (buffer);
|
|
|
|
|
2015-05-21 12:59:55 +00:00
|
|
|
/* Should we fix up any missing timestamps for list buffers here
|
|
|
|
* (e.g. set to first or previous timestamp in list) or just assume
|
|
|
|
* the's a jitterbuffer that will have done that for us? */
|
|
|
|
flow_ret = gst_rtp_base_depayload_handle_buffer (basedepay, bclass, buffer);
|
|
|
|
if (flow_ret != GST_FLOW_OK)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
|
|
|
gst_buffer_list_unref (list);
|
|
|
|
|
|
|
|
return flow_ret;
|
|
|
|
}
|
|
|
|
|
2005-12-18 00:56:07 +00:00
|
|
|
static gboolean
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_rtp_base_depayload_handle_event (GstRTPBaseDepayload * filter,
|
2010-12-21 14:02:18 +00:00
|
|
|
GstEvent * event)
|
2005-12-18 00:56:07 +00:00
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
2009-08-31 18:31:56 +00:00
|
|
|
gboolean forward = TRUE;
|
2005-12-18 00:56:07 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2007-09-16 19:31:06 +00:00
|
|
|
case GST_EVENT_FLUSH_STOP:
|
2015-08-15 13:33:14 +00:00
|
|
|
GST_OBJECT_LOCK (filter);
|
2007-09-16 19:31:06 +00:00
|
|
|
gst_segment_init (&filter->segment, GST_FORMAT_UNDEFINED);
|
2015-08-15 13:33:14 +00:00
|
|
|
GST_OBJECT_UNLOCK (filter);
|
|
|
|
|
2019-07-12 14:56:52 +00:00
|
|
|
filter->need_newsegment = !filter->priv->onvif_mode;
|
2008-05-23 14:14:28 +00:00
|
|
|
filter->priv->next_seqnum = -1;
|
2015-03-27 20:22:36 +00:00
|
|
|
gst_event_replace (&filter->priv->segment_event, NULL);
|
2007-09-16 19:31:06 +00:00
|
|
|
break;
|
2011-06-02 17:21:24 +00:00
|
|
|
case GST_EVENT_CAPS:
|
|
|
|
{
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
gst_event_parse_caps (event, &caps);
|
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
res = gst_rtp_base_depayload_setcaps (filter, caps);
|
2011-06-02 17:21:24 +00:00
|
|
|
forward = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2011-05-16 11:48:11 +00:00
|
|
|
case GST_EVENT_SEGMENT:
|
2005-12-18 00:56:07 +00:00
|
|
|
{
|
2016-05-02 06:48:09 +00:00
|
|
|
GstSegment segment;
|
|
|
|
|
2015-08-15 13:33:14 +00:00
|
|
|
GST_OBJECT_LOCK (filter);
|
2016-05-02 06:48:09 +00:00
|
|
|
gst_event_copy_segment (event, &segment);
|
|
|
|
|
|
|
|
if (segment.format != GST_FORMAT_TIME) {
|
|
|
|
GST_ERROR_OBJECT (filter, "Segment with non-TIME format not supported");
|
|
|
|
res = FALSE;
|
|
|
|
}
|
2018-06-05 15:24:55 +00:00
|
|
|
filter->priv->segment_seqnum = gst_event_get_seqnum (event);
|
2016-05-02 06:48:09 +00:00
|
|
|
filter->segment = segment;
|
2015-08-15 13:33:14 +00:00
|
|
|
GST_OBJECT_UNLOCK (filter);
|
|
|
|
|
2019-07-12 14:56:52 +00:00
|
|
|
/* In ONVIF mode, upstream is expected to send us the correct segment */
|
|
|
|
if (!filter->priv->onvif_mode) {
|
|
|
|
/* don't pass the event downstream, we generate our own segment including
|
|
|
|
* the NTP time and other things we receive in caps */
|
|
|
|
forward = FALSE;
|
|
|
|
}
|
2007-09-16 19:31:06 +00:00
|
|
|
break;
|
2006-07-27 10:52:52 +00:00
|
|
|
}
|
2008-05-02 12:11:07 +00:00
|
|
|
case GST_EVENT_CUSTOM_DOWNSTREAM:
|
|
|
|
{
|
2011-11-11 11:24:08 +00:00
|
|
|
GstRTPBaseDepayloadClass *bclass;
|
2008-05-02 12:11:07 +00:00
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
bclass = GST_RTP_BASE_DEPAYLOAD_GET_CLASS (filter);
|
2008-05-02 12:11:07 +00:00
|
|
|
|
|
|
|
if (gst_event_has_name (event, "GstRTPPacketLost")) {
|
|
|
|
/* we get this event from the jitterbuffer when it considers a packet as
|
|
|
|
* being lost. We send it to our packet_lost vmethod. The default
|
2012-09-05 10:00:50 +00:00
|
|
|
* implementation will make time progress by pushing out a GAP event.
|
2014-01-30 23:06:30 +00:00
|
|
|
* Subclasses can override and do one of the following:
|
2008-05-02 12:11:07 +00:00
|
|
|
* - Adjust timestamp/duration to something more accurate before
|
|
|
|
* calling the parent (default) packet_lost method.
|
|
|
|
* - do some more advanced error concealing on the already received
|
|
|
|
* (fragmented) packets.
|
|
|
|
* - ignore the packet lost.
|
|
|
|
*/
|
|
|
|
if (bclass->packet_lost)
|
|
|
|
res = bclass->packet_lost (filter, event);
|
2009-08-31 18:31:56 +00:00
|
|
|
forward = FALSE;
|
2008-05-02 12:11:07 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-12-18 00:56:07 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-08-31 18:31:56 +00:00
|
|
|
|
|
|
|
if (forward)
|
|
|
|
res = gst_pad_push_event (filter->srcpad, event);
|
|
|
|
else
|
|
|
|
gst_event_unref (event);
|
|
|
|
|
2005-12-18 00:56:07 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2010-12-21 14:02:18 +00:00
|
|
|
static gboolean
|
2011-11-17 11:48:25 +00:00
|
|
|
gst_rtp_base_depayload_handle_sink_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event)
|
2010-12-21 14:02:18 +00:00
|
|
|
{
|
|
|
|
gboolean res = FALSE;
|
2011-11-11 11:24:08 +00:00
|
|
|
GstRTPBaseDepayload *filter;
|
|
|
|
GstRTPBaseDepayloadClass *bclass;
|
2010-12-21 14:02:18 +00:00
|
|
|
|
2011-11-17 11:48:25 +00:00
|
|
|
filter = GST_RTP_BASE_DEPAYLOAD (parent);
|
2011-11-11 11:24:08 +00:00
|
|
|
bclass = GST_RTP_BASE_DEPAYLOAD_GET_CLASS (filter);
|
2010-12-21 14:02:18 +00:00
|
|
|
if (bclass->handle_event)
|
|
|
|
res = bclass->handle_event (filter, event);
|
2011-04-08 13:10:02 +00:00
|
|
|
else
|
|
|
|
gst_event_unref (event);
|
2010-12-21 14:02:18 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2008-11-11 16:40:50 +00:00
|
|
|
static GstEvent *
|
2015-03-27 20:22:36 +00:00
|
|
|
create_segment_event (GstRTPBaseDepayload * filter, guint rtptime,
|
|
|
|
GstClockTime position)
|
2008-11-11 16:40:50 +00:00
|
|
|
{
|
|
|
|
GstEvent *event;
|
2015-03-27 20:22:36 +00:00
|
|
|
GstClockTime start, stop, running_time;
|
2011-11-11 11:24:08 +00:00
|
|
|
GstRTPBaseDepayloadPrivate *priv;
|
2011-05-16 11:48:11 +00:00
|
|
|
GstSegment segment;
|
2008-11-11 16:40:50 +00:00
|
|
|
|
|
|
|
priv = filter->priv;
|
|
|
|
|
2015-08-15 13:33:14 +00:00
|
|
|
/* We don't need the object lock around - the segment
|
|
|
|
* can't change here while we're holding the STREAM_LOCK
|
|
|
|
*/
|
|
|
|
|
2015-05-05 11:14:12 +00:00
|
|
|
/* determining the start of the segment */
|
2015-07-10 16:49:01 +00:00
|
|
|
start = filter->segment.start;
|
2015-03-27 20:22:36 +00:00
|
|
|
if (priv->clock_base != -1 && position != -1) {
|
|
|
|
GstClockTime exttime, gap;
|
|
|
|
|
|
|
|
exttime = priv->clock_base;
|
|
|
|
gst_rtp_buffer_ext_timestamp (&exttime, rtptime);
|
|
|
|
gap = gst_util_uint64_scale_int (exttime - priv->clock_base,
|
|
|
|
filter->clock_rate, GST_SECOND);
|
|
|
|
|
|
|
|
/* account for lost packets */
|
2015-05-05 11:14:12 +00:00
|
|
|
if (position > gap) {
|
|
|
|
GST_DEBUG_OBJECT (filter,
|
|
|
|
"Found gap of %" GST_TIME_FORMAT ", adjusting start: %"
|
|
|
|
GST_TIME_FORMAT " = %" GST_TIME_FORMAT " - %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (gap), GST_TIME_ARGS (position - gap),
|
|
|
|
GST_TIME_ARGS (position), GST_TIME_ARGS (gap));
|
2015-03-27 20:22:36 +00:00
|
|
|
start = position - gap;
|
2015-05-05 11:14:12 +00:00
|
|
|
}
|
2015-03-27 20:22:36 +00:00
|
|
|
}
|
|
|
|
|
2015-05-05 11:14:12 +00:00
|
|
|
/* determining the stop of the segment */
|
2015-07-10 16:49:01 +00:00
|
|
|
stop = filter->segment.stop;
|
2008-11-11 16:40:50 +00:00
|
|
|
if (priv->npt_stop != -1)
|
2015-03-27 20:22:36 +00:00
|
|
|
stop = start + (priv->npt_stop - priv->npt_start);
|
2008-11-11 16:40:50 +00:00
|
|
|
|
2015-03-25 22:40:25 +00:00
|
|
|
if (position == -1)
|
2015-07-10 16:49:01 +00:00
|
|
|
position = start;
|
2015-03-25 22:40:25 +00:00
|
|
|
|
2016-11-01 19:09:04 +00:00
|
|
|
running_time = gst_segment_to_running_time (&filter->segment,
|
|
|
|
GST_FORMAT_TIME, start);
|
2015-03-25 22:40:25 +00:00
|
|
|
|
2011-05-16 11:48:11 +00:00
|
|
|
gst_segment_init (&segment, GST_FORMAT_TIME);
|
|
|
|
segment.rate = priv->play_speed;
|
|
|
|
segment.applied_rate = priv->play_scale;
|
2015-03-27 20:22:36 +00:00
|
|
|
segment.start = start;
|
2011-05-16 11:48:11 +00:00
|
|
|
segment.stop = stop;
|
|
|
|
segment.time = priv->npt_start;
|
|
|
|
segment.position = position;
|
2015-03-25 22:40:25 +00:00
|
|
|
segment.base = running_time;
|
2011-05-16 11:48:11 +00:00
|
|
|
|
2015-05-05 11:14:12 +00:00
|
|
|
GST_DEBUG_OBJECT (filter, "Creating segment event %" GST_SEGMENT_FORMAT,
|
|
|
|
&segment);
|
2011-05-16 11:48:11 +00:00
|
|
|
event = gst_event_new_segment (&segment);
|
2018-06-05 15:24:55 +00:00
|
|
|
if (filter->priv->segment_seqnum != GST_SEQNUM_INVALID)
|
|
|
|
gst_event_set_seqnum (event, filter->priv->segment_seqnum);
|
2008-11-11 16:40:50 +00:00
|
|
|
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2019-06-12 12:31:09 +00:00
|
|
|
static gboolean
|
|
|
|
foreach_metadata_drop (GstBuffer * buffer, GstMeta ** meta, gpointer user_data)
|
|
|
|
{
|
|
|
|
GType drop_api_type = (GType) user_data;
|
|
|
|
const GstMetaInfo *info = (*meta)->info;
|
|
|
|
|
|
|
|
if (info->api == drop_api_type)
|
|
|
|
*meta = NULL;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-10-10 18:16:12 +00:00
|
|
|
static void
|
|
|
|
add_rtp_source_meta (GstBuffer * outbuf, GstBuffer * rtpbuf)
|
|
|
|
{
|
|
|
|
GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
|
|
|
|
GstRTPSourceMeta *meta;
|
|
|
|
guint32 ssrc;
|
2019-06-12 12:31:09 +00:00
|
|
|
GType source_meta_api = gst_rtp_source_meta_api_get_type ();
|
2018-10-10 18:16:12 +00:00
|
|
|
|
|
|
|
if (!gst_rtp_buffer_map (rtpbuf, GST_MAP_READ, &rtp))
|
|
|
|
return;
|
|
|
|
|
|
|
|
ssrc = gst_rtp_buffer_get_ssrc (&rtp);
|
2019-06-12 12:31:09 +00:00
|
|
|
|
|
|
|
/* remove any pre-existing source-meta */
|
|
|
|
gst_buffer_foreach_meta (outbuf, foreach_metadata_drop,
|
|
|
|
(gpointer) source_meta_api);
|
|
|
|
|
2018-10-10 18:16:12 +00:00
|
|
|
meta = gst_buffer_add_rtp_source_meta (outbuf, &ssrc, NULL, 0);
|
|
|
|
if (meta != NULL) {
|
|
|
|
gint i;
|
|
|
|
gint csrc_count = gst_rtp_buffer_get_csrc_count (&rtp);
|
|
|
|
for (i = 0; i < csrc_count; i++) {
|
|
|
|
guint32 csrc = gst_rtp_buffer_get_csrc (&rtp, i);
|
|
|
|
gst_rtp_source_meta_append_csrc (meta, &csrc, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_rtp_buffer_unmap (&rtp);
|
|
|
|
}
|
|
|
|
|
2011-03-31 15:47:43 +00:00
|
|
|
static gboolean
|
2016-07-15 18:48:02 +00:00
|
|
|
set_headers (GstBuffer ** buffer, guint idx, GstRTPBaseDepayload * depayload)
|
2010-12-15 11:58:47 +00:00
|
|
|
{
|
2011-11-11 11:24:08 +00:00
|
|
|
GstRTPBaseDepayloadPrivate *priv = depayload->priv;
|
2011-11-10 16:18:00 +00:00
|
|
|
GstClockTime pts, dts, duration;
|
2006-09-22 14:13:34 +00:00
|
|
|
|
2011-03-27 11:55:15 +00:00
|
|
|
*buffer = gst_buffer_make_writable (*buffer);
|
2010-04-30 17:37:33 +00:00
|
|
|
|
2011-11-10 16:18:00 +00:00
|
|
|
pts = GST_BUFFER_PTS (*buffer);
|
|
|
|
dts = GST_BUFFER_DTS (*buffer);
|
|
|
|
duration = GST_BUFFER_DURATION (*buffer);
|
|
|
|
|
2019-08-29 17:42:39 +00:00
|
|
|
/* apply last incoming timestamp and duration to outgoing buffer if
|
2011-11-10 16:18:00 +00:00
|
|
|
* not otherwise set. */
|
|
|
|
if (!GST_CLOCK_TIME_IS_VALID (pts))
|
|
|
|
GST_BUFFER_PTS (*buffer) = priv->pts;
|
|
|
|
if (!GST_CLOCK_TIME_IS_VALID (dts))
|
|
|
|
GST_BUFFER_DTS (*buffer) = priv->dts;
|
|
|
|
if (!GST_CLOCK_TIME_IS_VALID (duration))
|
|
|
|
GST_BUFFER_DURATION (*buffer) = priv->duration;
|
2006-09-22 14:13:34 +00:00
|
|
|
|
2010-12-15 11:58:47 +00:00
|
|
|
if (G_UNLIKELY (depayload->priv->discont)) {
|
|
|
|
GST_LOG_OBJECT (depayload, "Marking DISCONT on output buffer");
|
|
|
|
GST_BUFFER_FLAG_SET (*buffer, GST_BUFFER_FLAG_DISCONT);
|
|
|
|
depayload->priv->discont = FALSE;
|
|
|
|
}
|
2006-09-22 14:13:34 +00:00
|
|
|
|
2011-11-10 16:18:00 +00:00
|
|
|
/* make sure we only set the timestamp on the first packet */
|
|
|
|
priv->pts = GST_CLOCK_TIME_NONE;
|
|
|
|
priv->dts = GST_CLOCK_TIME_NONE;
|
|
|
|
priv->duration = GST_CLOCK_TIME_NONE;
|
|
|
|
|
2018-10-10 18:16:12 +00:00
|
|
|
if (priv->source_info && priv->input_buffer)
|
|
|
|
add_rtp_source_meta (*buffer, priv->input_buffer);
|
|
|
|
|
2011-03-31 15:47:43 +00:00
|
|
|
return TRUE;
|
2010-12-15 11:58:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_rtp_base_depayload_prepare_push (GstRTPBaseDepayload * filter,
|
2011-11-10 16:18:00 +00:00
|
|
|
gboolean is_list, gpointer obj)
|
2010-12-15 11:58:47 +00:00
|
|
|
{
|
|
|
|
if (is_list) {
|
2010-12-28 10:41:49 +00:00
|
|
|
GstBufferList **blist = obj;
|
2016-07-15 18:48:02 +00:00
|
|
|
gst_buffer_list_foreach (*blist, (GstBufferListFunc) set_headers, filter);
|
2010-12-15 11:58:47 +00:00
|
|
|
} else {
|
2010-12-28 10:41:49 +00:00
|
|
|
GstBuffer **buf = obj;
|
2016-07-15 18:48:02 +00:00
|
|
|
set_headers (buf, 0, filter);
|
2010-12-15 11:58:47 +00:00
|
|
|
}
|
2006-09-22 14:13:34 +00:00
|
|
|
|
2008-11-11 16:40:50 +00:00
|
|
|
/* if this is the first buffer send a NEWSEGMENT */
|
2015-03-27 20:22:36 +00:00
|
|
|
if (G_UNLIKELY (filter->priv->segment_event)) {
|
|
|
|
gst_pad_push_event (filter->srcpad, filter->priv->segment_event);
|
|
|
|
filter->priv->segment_event = NULL;
|
2008-11-11 16:40:50 +00:00
|
|
|
GST_DEBUG_OBJECT (filter, "Pushed newsegment event on this first buffer");
|
|
|
|
}
|
|
|
|
|
2010-12-15 11:58:47 +00:00
|
|
|
return GST_FLOW_OK;
|
2006-09-22 14:13:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-11-11 11:24:08 +00:00
|
|
|
* gst_rtp_base_depayload_push:
|
|
|
|
* @filter: a #GstRTPBaseDepayload
|
2006-09-22 14:13:34 +00:00
|
|
|
* @out_buf: a #GstBuffer
|
|
|
|
*
|
|
|
|
* Push @out_buf to the peer of @filter. This function takes ownership of
|
|
|
|
* @out_buf.
|
|
|
|
*
|
2019-08-29 17:42:39 +00:00
|
|
|
* This function will by default apply the last incoming timestamp on
|
2011-11-10 16:18:00 +00:00
|
|
|
* the outgoing buffer when it didn't have a timestamp already.
|
2006-09-22 14:13:34 +00:00
|
|
|
*
|
2007-03-29 16:23:53 +00:00
|
|
|
* Returns: a #GstFlowReturn.
|
2006-09-22 14:13:34 +00:00
|
|
|
*/
|
|
|
|
GstFlowReturn
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_rtp_base_depayload_push (GstRTPBaseDepayload * filter, GstBuffer * out_buf)
|
2006-09-22 14:13:34 +00:00
|
|
|
{
|
2010-12-15 11:58:47 +00:00
|
|
|
GstFlowReturn res;
|
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
res = gst_rtp_base_depayload_prepare_push (filter, FALSE, &out_buf);
|
2010-12-15 11:58:47 +00:00
|
|
|
|
|
|
|
if (G_LIKELY (res == GST_FLOW_OK))
|
|
|
|
res = gst_pad_push (filter->srcpad, out_buf);
|
|
|
|
else
|
|
|
|
gst_buffer_unref (out_buf);
|
|
|
|
|
2019-11-22 02:04:14 +00:00
|
|
|
if (res != GST_FLOW_OK)
|
|
|
|
filter->priv->process_flow_ret = res;
|
|
|
|
|
2010-12-15 11:58:47 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-11-11 11:24:08 +00:00
|
|
|
* gst_rtp_base_depayload_push_list:
|
|
|
|
* @filter: a #GstRTPBaseDepayload
|
2010-12-15 11:58:47 +00:00
|
|
|
* @out_list: a #GstBufferList
|
|
|
|
*
|
|
|
|
* Push @out_list to the peer of @filter. This function takes ownership of
|
|
|
|
* @out_list.
|
|
|
|
*
|
|
|
|
* Returns: a #GstFlowReturn.
|
|
|
|
*/
|
|
|
|
GstFlowReturn
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_rtp_base_depayload_push_list (GstRTPBaseDepayload * filter,
|
2010-12-15 11:58:47 +00:00
|
|
|
GstBufferList * out_list)
|
|
|
|
{
|
|
|
|
GstFlowReturn res;
|
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
res = gst_rtp_base_depayload_prepare_push (filter, TRUE, &out_list);
|
2010-12-15 11:58:47 +00:00
|
|
|
|
|
|
|
if (G_LIKELY (res == GST_FLOW_OK))
|
|
|
|
res = gst_pad_push_list (filter->srcpad, out_list);
|
|
|
|
else
|
|
|
|
gst_buffer_list_unref (out_list);
|
|
|
|
|
2019-11-22 02:04:14 +00:00
|
|
|
if (res != GST_FLOW_OK)
|
|
|
|
filter->priv->process_flow_ret = res;
|
|
|
|
|
2010-12-15 11:58:47 +00:00
|
|
|
return res;
|
2006-09-22 14:13:34 +00:00
|
|
|
}
|
|
|
|
|
2014-01-30 23:06:30 +00:00
|
|
|
/* convert the PacketLost event from a jitterbuffer to a GAP event.
|
2008-05-02 12:11:07 +00:00
|
|
|
* subclasses can override this. */
|
|
|
|
static gboolean
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_rtp_base_depayload_packet_lost (GstRTPBaseDepayload * filter,
|
2008-05-02 12:11:07 +00:00
|
|
|
GstEvent * event)
|
|
|
|
{
|
2012-10-29 20:29:36 +00:00
|
|
|
GstClockTime timestamp, duration;
|
2008-05-02 12:11:07 +00:00
|
|
|
GstEvent *sevent;
|
|
|
|
const GstStructure *s;
|
rtpbasedepayload: condition the sending of gap events
The default implementation for packet loss handling previously
always sent a gap event.
While this is correct as long as we know the packet that was
lost was actually a media packet, with ULPFEC this becomes
a bit more complicated, as we do not know whether the packet
that was lost was a FEC packet, in which case it is better
to not actually send any gap events in the default implementation.
Some payloaders can be more clever about, for example VP8 can
use the picture-id, and the M and S bits to determine whether
the missing packet was inside an encoded frame or outside,
and thus whether if it was a media packet or a FEC packet,
which is why ulpfecdec still lets these lost events go through,
though stripping them of their seqnum, and appending a new
"might-have-been-fec" field to them.
This is all a bit terrible, but necessary to have ULPFEC
integrate properly with the rest of our RTP stack.
https://bugzilla.gnome.org/show_bug.cgi?id=794909
2018-04-06 18:02:13 +00:00
|
|
|
gboolean might_have_been_fec;
|
|
|
|
gboolean res = TRUE;
|
2008-05-02 12:11:07 +00:00
|
|
|
|
|
|
|
s = gst_event_get_structure (event);
|
|
|
|
|
|
|
|
/* first start by parsing the timestamp and duration */
|
|
|
|
timestamp = -1;
|
|
|
|
duration = -1;
|
|
|
|
|
2015-12-14 12:11:21 +00:00
|
|
|
if (!gst_structure_get_clock_time (s, "timestamp", ×tamp) ||
|
|
|
|
!gst_structure_get_clock_time (s, "duration", &duration)) {
|
|
|
|
GST_ERROR_OBJECT (filter,
|
|
|
|
"Packet loss event without timestamp or duration");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-05-02 12:11:07 +00:00
|
|
|
|
2016-08-30 11:48:00 +00:00
|
|
|
sevent = gst_pad_get_sticky_event (filter->srcpad, GST_EVENT_SEGMENT, 0);
|
|
|
|
if (G_UNLIKELY (!sevent)) {
|
|
|
|
/* Typically happens if lost event arrives before first buffer */
|
|
|
|
GST_DEBUG_OBJECT (filter,
|
|
|
|
"Ignore packet loss because segment event missing");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
gst_event_unref (sevent);
|
|
|
|
|
rtpbasedepayload: condition the sending of gap events
The default implementation for packet loss handling previously
always sent a gap event.
While this is correct as long as we know the packet that was
lost was actually a media packet, with ULPFEC this becomes
a bit more complicated, as we do not know whether the packet
that was lost was a FEC packet, in which case it is better
to not actually send any gap events in the default implementation.
Some payloaders can be more clever about, for example VP8 can
use the picture-id, and the M and S bits to determine whether
the missing packet was inside an encoded frame or outside,
and thus whether if it was a media packet or a FEC packet,
which is why ulpfecdec still lets these lost events go through,
though stripping them of their seqnum, and appending a new
"might-have-been-fec" field to them.
This is all a bit terrible, but necessary to have ULPFEC
integrate properly with the rest of our RTP stack.
https://bugzilla.gnome.org/show_bug.cgi?id=794909
2018-04-06 18:02:13 +00:00
|
|
|
if (!gst_structure_get_boolean (s, "might-have-been-fec",
|
|
|
|
&might_have_been_fec) || !might_have_been_fec) {
|
|
|
|
/* send GAP event */
|
|
|
|
sevent = gst_event_new_gap (timestamp, duration);
|
|
|
|
res = gst_pad_push_event (filter->srcpad, sevent);
|
|
|
|
}
|
2008-05-02 12:11:07 +00:00
|
|
|
|
rtpbasedepayload: condition the sending of gap events
The default implementation for packet loss handling previously
always sent a gap event.
While this is correct as long as we know the packet that was
lost was actually a media packet, with ULPFEC this becomes
a bit more complicated, as we do not know whether the packet
that was lost was a FEC packet, in which case it is better
to not actually send any gap events in the default implementation.
Some payloaders can be more clever about, for example VP8 can
use the picture-id, and the M and S bits to determine whether
the missing packet was inside an encoded frame or outside,
and thus whether if it was a media packet or a FEC packet,
which is why ulpfecdec still lets these lost events go through,
though stripping them of their seqnum, and appending a new
"might-have-been-fec" field to them.
This is all a bit terrible, but necessary to have ULPFEC
integrate properly with the rest of our RTP stack.
https://bugzilla.gnome.org/show_bug.cgi?id=794909
2018-04-06 18:02:13 +00:00
|
|
|
return res;
|
2008-05-02 12:11:07 +00:00
|
|
|
}
|
|
|
|
|
2005-09-02 15:43:18 +00:00
|
|
|
static GstStateChangeReturn
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_rtp_base_depayload_change_state (GstElement * element,
|
2005-09-02 15:43:18 +00:00
|
|
|
GstStateChange transition)
|
2005-08-12 13:34:56 +00:00
|
|
|
{
|
2011-11-11 11:24:08 +00:00
|
|
|
GstRTPBaseDepayload *filter;
|
|
|
|
GstRTPBaseDepayloadPrivate *priv;
|
2006-10-06 13:34:46 +00:00
|
|
|
GstStateChangeReturn ret;
|
2005-08-12 13:34:56 +00:00
|
|
|
|
2011-11-11 11:24:08 +00:00
|
|
|
filter = GST_RTP_BASE_DEPAYLOAD (element);
|
2007-09-16 19:31:06 +00:00
|
|
|
priv = filter->priv;
|
2005-08-12 13:34:56 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
2005-09-02 15:43:18 +00:00
|
|
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
2005-08-12 13:34:56 +00:00
|
|
|
break;
|
2005-09-02 15:43:18 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2007-03-29 16:23:53 +00:00
|
|
|
filter->need_newsegment = TRUE;
|
2007-09-16 19:31:06 +00:00
|
|
|
priv->npt_start = 0;
|
|
|
|
priv->npt_stop = -1;
|
|
|
|
priv->play_speed = 1.0;
|
|
|
|
priv->play_scale = 1.0;
|
2015-03-27 20:22:36 +00:00
|
|
|
priv->clock_base = -1;
|
2019-07-12 14:56:52 +00:00
|
|
|
priv->onvif_mode = FALSE;
|
2008-10-13 09:16:59 +00:00
|
|
|
priv->next_seqnum = -1;
|
|
|
|
priv->negotiated = FALSE;
|
2010-08-18 10:34:07 +00:00
|
|
|
priv->discont = FALSE;
|
2018-06-05 15:24:55 +00:00
|
|
|
priv->segment_seqnum = GST_SEQNUM_INVALID;
|
2005-08-12 13:34:56 +00:00
|
|
|
break;
|
2005-09-02 15:43:18 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
2005-08-12 13:34:56 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-10-06 13:34:46 +00:00
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
|
2005-08-12 13:34:56 +00:00
|
|
|
switch (transition) {
|
2005-09-02 15:43:18 +00:00
|
|
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
2005-08-12 13:34:56 +00:00
|
|
|
break;
|
2005-09-02 15:43:18 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
2013-04-10 19:45:37 +00:00
|
|
|
gst_caps_replace (&priv->last_caps, NULL);
|
2015-07-07 14:05:59 +00:00
|
|
|
gst_event_replace (&priv->segment_event, NULL);
|
2005-08-12 13:34:56 +00:00
|
|
|
break;
|
2005-09-02 15:43:18 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
2005-08-12 13:34:56 +00:00
|
|
|
break;
|
2005-09-02 15:43:18 +00:00
|
|
|
default:
|
|
|
|
break;
|
2005-08-12 13:34:56 +00:00
|
|
|
}
|
2006-10-06 13:34:46 +00:00
|
|
|
return ret;
|
2005-08-12 13:34:56 +00:00
|
|
|
}
|
|
|
|
|
2014-04-12 05:10:36 +00:00
|
|
|
static GstStructure *
|
|
|
|
gst_rtp_base_depayload_create_stats (GstRTPBaseDepayload * depayload)
|
|
|
|
{
|
|
|
|
GstRTPBaseDepayloadPrivate *priv;
|
|
|
|
GstStructure *s;
|
2015-08-15 13:33:14 +00:00
|
|
|
GstClockTime pts = GST_CLOCK_TIME_NONE, dts = GST_CLOCK_TIME_NONE;
|
2014-04-12 05:10:36 +00:00
|
|
|
|
|
|
|
priv = depayload->priv;
|
|
|
|
|
2015-08-15 13:33:14 +00:00
|
|
|
GST_OBJECT_LOCK (depayload);
|
|
|
|
if (depayload->segment.format != GST_FORMAT_UNDEFINED) {
|
|
|
|
pts = gst_segment_to_running_time (&depayload->segment, GST_FORMAT_TIME,
|
|
|
|
priv->pts);
|
|
|
|
dts = gst_segment_to_running_time (&depayload->segment, GST_FORMAT_TIME,
|
|
|
|
priv->dts);
|
|
|
|
}
|
|
|
|
GST_OBJECT_UNLOCK (depayload);
|
2015-08-05 19:32:54 +00:00
|
|
|
|
2014-04-12 05:10:36 +00:00
|
|
|
s = gst_structure_new ("application/x-rtp-depayload-stats",
|
|
|
|
"clock_rate", G_TYPE_UINT, depayload->clock_rate,
|
|
|
|
"npt-start", G_TYPE_UINT64, priv->npt_start,
|
|
|
|
"npt-stop", G_TYPE_UINT64, priv->npt_stop,
|
|
|
|
"play-speed", G_TYPE_DOUBLE, priv->play_speed,
|
|
|
|
"play-scale", G_TYPE_DOUBLE, priv->play_scale,
|
2015-08-05 19:32:54 +00:00
|
|
|
"running-time-dts", G_TYPE_UINT64, dts,
|
|
|
|
"running-time-pts", G_TYPE_UINT64, pts,
|
2014-04-12 05:10:36 +00:00
|
|
|
"seqnum", G_TYPE_UINT, (guint) priv->last_seqnum,
|
|
|
|
"timestamp", G_TYPE_UINT, (guint) priv->last_rtptime, NULL);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-14 10:29:30 +00:00
|
|
|
static void
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_rtp_base_depayload_set_property (GObject * object, guint prop_id,
|
2005-07-14 10:29:30 +00:00
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2018-10-10 18:16:12 +00:00
|
|
|
GstRTPBaseDepayload *depayload;
|
2019-06-13 08:36:05 +00:00
|
|
|
GstRTPBaseDepayloadPrivate *priv;
|
2018-10-10 18:16:12 +00:00
|
|
|
|
|
|
|
depayload = GST_RTP_BASE_DEPAYLOAD (object);
|
2019-06-13 08:36:05 +00:00
|
|
|
priv = depayload->priv;
|
2018-10-10 18:16:12 +00:00
|
|
|
|
2005-07-14 10:29:30 +00:00
|
|
|
switch (prop_id) {
|
2018-10-10 18:16:12 +00:00
|
|
|
case PROP_SOURCE_INFO:
|
|
|
|
gst_rtp_base_depayload_set_source_info_enabled (depayload,
|
|
|
|
g_value_get_boolean (value));
|
|
|
|
break;
|
2019-06-13 08:36:05 +00:00
|
|
|
case PROP_MAX_REORDER:
|
|
|
|
priv->max_reorder = g_value_get_int (value);
|
|
|
|
break;
|
2005-07-14 10:29:30 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-11 11:24:08 +00:00
|
|
|
gst_rtp_base_depayload_get_property (GObject * object, guint prop_id,
|
2005-07-14 10:29:30 +00:00
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2014-04-12 05:10:36 +00:00
|
|
|
GstRTPBaseDepayload *depayload;
|
2019-06-13 08:36:05 +00:00
|
|
|
GstRTPBaseDepayloadPrivate *priv;
|
2014-04-12 05:10:36 +00:00
|
|
|
|
|
|
|
depayload = GST_RTP_BASE_DEPAYLOAD (object);
|
2019-06-13 08:36:05 +00:00
|
|
|
priv = depayload->priv;
|
2014-04-12 05:10:36 +00:00
|
|
|
|
2005-07-14 10:29:30 +00:00
|
|
|
switch (prop_id) {
|
2014-04-12 05:10:36 +00:00
|
|
|
case PROP_STATS:
|
|
|
|
g_value_take_boxed (value,
|
|
|
|
gst_rtp_base_depayload_create_stats (depayload));
|
|
|
|
break;
|
2018-10-10 18:16:12 +00:00
|
|
|
case PROP_SOURCE_INFO:
|
|
|
|
g_value_set_boolean (value,
|
|
|
|
gst_rtp_base_depayload_is_source_info_enabled (depayload));
|
|
|
|
break;
|
2019-06-13 08:36:05 +00:00
|
|
|
case PROP_MAX_REORDER:
|
|
|
|
g_value_set_int (value, priv->max_reorder);
|
|
|
|
break;
|
2005-07-14 10:29:30 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-10-10 18:16:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtp_base_depayload_set_source_info_enabled:
|
|
|
|
* @depayload: a #GstRTPBaseDepayload
|
|
|
|
* @enable: whether to add meta about RTP sources to buffer
|
|
|
|
*
|
|
|
|
* Enable or disable adding #GstRTPSourceMeta to depayloaded buffers.
|
|
|
|
*
|
|
|
|
* Since: 1.16
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gst_rtp_base_depayload_set_source_info_enabled (GstRTPBaseDepayload * depayload,
|
|
|
|
gboolean enable)
|
|
|
|
{
|
|
|
|
depayload->priv->source_info = enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtp_base_depayload_is_source_info_enabled:
|
|
|
|
* @depayload: a #GstRTPBaseDepayload
|
|
|
|
*
|
|
|
|
* Queries whether #GstRTPSourceMeta will be added to depayloaded buffers.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if source-info is enabled.
|
|
|
|
*
|
|
|
|
* Since: 1.16
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gst_rtp_base_depayload_is_source_info_enabled (GstRTPBaseDepayload * depayload)
|
|
|
|
{
|
|
|
|
return depayload->priv->source_info;
|
|
|
|
}
|