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
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2007-04-21 15:10:25 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstbasertpdepayload
|
|
|
|
* @short_description: Base class for RTP depayloader
|
|
|
|
*
|
|
|
|
* Provides a base class for RTP depayloaders
|
|
|
|
*/
|
|
|
|
|
2005-07-14 10:29:30 +00:00
|
|
|
#include "gstbasertpdepayload.h"
|
|
|
|
|
2007-08-11 12:39:51 +00:00
|
|
|
#ifdef GST_DISABLE_DEPRECATED
|
|
|
|
#define QUEUE_LOCK_INIT(base) (g_static_rec_mutex_init(&base->queuelock))
|
|
|
|
#define QUEUE_LOCK_FREE(base) (g_static_rec_mutex_free(&base->queuelock))
|
|
|
|
#define QUEUE_LOCK(base) (g_static_rec_mutex_lock(&base->queuelock))
|
|
|
|
#define QUEUE_UNLOCK(base) (g_static_rec_mutex_unlock(&base->queuelock))
|
|
|
|
#else
|
|
|
|
/* otherwise it's already been defined in the header (FIXME 0.11)*/
|
|
|
|
#endif
|
|
|
|
|
2006-06-23 09:53:09 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (basertpdepayload_debug);
|
2005-07-14 10:29:30 +00:00
|
|
|
#define GST_CAT_DEFAULT (basertpdepayload_debug)
|
|
|
|
|
2007-03-29 16:23:53 +00:00
|
|
|
#define GST_BASE_RTP_DEPAYLOAD_GET_PRIVATE(obj) \
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_BASE_RTP_DEPAYLOAD, GstBaseRTPDepayloadPrivate))
|
|
|
|
|
|
|
|
struct _GstBaseRTPDepayloadPrivate
|
|
|
|
{
|
2007-05-12 16:18:39 +00:00
|
|
|
GstClockTime npt_start;
|
|
|
|
GstClockTime npt_stop;
|
|
|
|
gdouble play_speed;
|
|
|
|
gdouble play_scale;
|
2007-06-05 16:19:30 +00:00
|
|
|
|
2007-09-04 16:18:48 +00:00
|
|
|
gboolean discont;
|
2007-09-16 19:31:06 +00:00
|
|
|
GstClockTime timestamp;
|
2007-09-19 16:09:57 +00:00
|
|
|
GstClockTime duration;
|
2008-05-23 14:14:28 +00:00
|
|
|
|
|
|
|
guint32 next_seqnum;
|
2008-10-13 09:16:59 +00:00
|
|
|
|
|
|
|
gboolean negotiated;
|
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
|
|
|
|
};
|
|
|
|
|
2007-03-29 16:23:53 +00:00
|
|
|
#define DEFAULT_QUEUE_DELAY 0
|
|
|
|
|
2005-07-14 10:29:30 +00:00
|
|
|
enum
|
|
|
|
{
|
2007-03-29 16:23:53 +00:00
|
|
|
PROP_0,
|
2008-05-02 12:11:07 +00:00
|
|
|
PROP_QUEUE_DELAY,
|
|
|
|
PROP_LAST
|
2005-07-14 10:29:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void gst_base_rtp_depayload_finalize (GObject * object);
|
|
|
|
static void gst_base_rtp_depayload_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_base_rtp_depayload_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
|
|
|
|
|
|
|
static gboolean gst_base_rtp_depayload_setcaps (GstPad * pad, GstCaps * caps);
|
|
|
|
static GstFlowReturn gst_base_rtp_depayload_chain (GstPad * pad,
|
|
|
|
GstBuffer * in);
|
2007-03-29 16:23:53 +00:00
|
|
|
static gboolean gst_base_rtp_depayload_handle_sink_event (GstPad * pad,
|
|
|
|
GstEvent * event);
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2005-09-02 15:43:18 +00:00
|
|
|
static GstStateChangeReturn gst_base_rtp_depayload_change_state (GstElement *
|
|
|
|
element, GstStateChange transition);
|
2007-03-29 16:23:53 +00:00
|
|
|
|
2005-08-10 20:52:37 +00:00
|
|
|
static void gst_base_rtp_depayload_set_gst_timestamp
|
2007-09-16 19:31:06 +00:00
|
|
|
(GstBaseRTPDepayload * filter, guint32 rtptime, GstBuffer * buf);
|
2008-05-02 12:11:07 +00:00
|
|
|
static gboolean gst_base_rtp_depayload_packet_lost (GstBaseRTPDepayload *
|
|
|
|
filter, GstEvent * event);
|
2010-12-21 14:02:18 +00:00
|
|
|
static gboolean gst_base_rtp_depayload_handle_event (GstBaseRTPDepayload *
|
|
|
|
filter, GstEvent * event);
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2007-03-29 16:23:53 +00:00
|
|
|
GST_BOILERPLATE (GstBaseRTPDepayload, gst_base_rtp_depayload, GstElement,
|
|
|
|
GST_TYPE_ELEMENT);
|
2005-07-14 10:29:30 +00:00
|
|
|
|
|
|
|
static void
|
2007-03-29 16:23:53 +00:00
|
|
|
gst_base_rtp_depayload_base_init (gpointer klass)
|
2005-07-14 10:29:30 +00:00
|
|
|
{
|
2005-10-26 13:52:42 +00:00
|
|
|
/*GstElementClass *element_class = GST_ELEMENT_CLASS (klass); */
|
2005-07-14 10:29:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_base_rtp_depayload_class_init (GstBaseRTPDepayloadClass * klass)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2007-03-29 16:23:53 +00:00
|
|
|
g_type_class_add_private (klass, sizeof (GstBaseRTPDepayloadPrivate));
|
|
|
|
|
|
|
|
gobject_class->finalize = gst_base_rtp_depayload_finalize;
|
2005-07-14 10:29:30 +00:00
|
|
|
gobject_class->set_property = gst_base_rtp_depayload_set_property;
|
|
|
|
gobject_class->get_property = gst_base_rtp_depayload_get_property;
|
|
|
|
|
2007-09-03 19:19:35 +00:00
|
|
|
/**
|
|
|
|
* GstBaseRTPDepayload::queue-delay
|
|
|
|
*
|
|
|
|
* Control the amount of packets to buffer.
|
|
|
|
*
|
|
|
|
* Deprecated: Use a jitterbuffer or RTP session manager to delay packet
|
|
|
|
* playback. This property has no effect anymore since 0.10.15.
|
|
|
|
*/
|
2007-10-30 20:32:14 +00:00
|
|
|
#ifndef GST_REMOVE_DEPRECATED
|
2007-03-29 16:23:53 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_QUEUE_DELAY,
|
2007-09-03 19:19:35 +00:00
|
|
|
g_param_spec_uint ("queue-delay", "Queue Delay",
|
2007-08-31 15:58:30 +00:00
|
|
|
"Amount of ms to queue/buffer, deprecated", 0, G_MAXUINT,
|
2008-03-22 15:00:53 +00:00
|
|
|
DEFAULT_QUEUE_DELAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2007-10-30 20:32:14 +00:00
|
|
|
#endif
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2005-08-12 13:34:56 +00:00
|
|
|
gstelement_class->change_state = gst_base_rtp_depayload_change_state;
|
|
|
|
|
2005-08-10 20:52:37 +00:00
|
|
|
klass->set_gst_timestamp = gst_base_rtp_depayload_set_gst_timestamp;
|
2008-05-02 12:11:07 +00:00
|
|
|
klass->packet_lost = gst_base_rtp_depayload_packet_lost;
|
2010-12-21 14:02:18 +00:00
|
|
|
klass->handle_event = gst_base_rtp_depayload_handle_event;
|
2005-07-14 10:29:30 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (basertpdepayload_debug, "basertpdepayload", 0,
|
|
|
|
"Base class for RTP Depayloaders");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-03-29 16:23:53 +00:00
|
|
|
gst_base_rtp_depayload_init (GstBaseRTPDepayload * filter,
|
|
|
|
GstBaseRTPDepayloadClass * klass)
|
2005-07-14 10:29:30 +00:00
|
|
|
{
|
|
|
|
GstPadTemplate *pad_template;
|
2007-03-29 16:23:53 +00:00
|
|
|
GstBaseRTPDepayloadPrivate *priv;
|
|
|
|
|
|
|
|
priv = GST_BASE_RTP_DEPAYLOAD_GET_PRIVATE (filter);
|
|
|
|
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");
|
|
|
|
gst_pad_set_setcaps_function (filter->sinkpad,
|
|
|
|
gst_base_rtp_depayload_setcaps);
|
|
|
|
gst_pad_set_chain_function (filter->sinkpad, gst_base_rtp_depayload_chain);
|
2005-12-18 00:56:07 +00:00
|
|
|
gst_pad_set_event_function (filter->sinkpad,
|
|
|
|
gst_base_rtp_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);
|
|
|
|
|
|
|
|
filter->queue = g_queue_new ();
|
2007-03-29 16:23:53 +00:00
|
|
|
filter->queue_delay = DEFAULT_QUEUE_DELAY;
|
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
|
|
|
|
gst_base_rtp_depayload_finalize (GObject * object)
|
|
|
|
{
|
2006-09-22 14:13:34 +00:00
|
|
|
GstBaseRTPDepayload *filter = GST_BASE_RTP_DEPAYLOAD (object);
|
2006-04-11 17:31:29 +00:00
|
|
|
|
2006-09-22 14:13:34 +00:00
|
|
|
g_queue_free (filter->queue);
|
2005-10-25 17:20:55 +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
|
|
|
|
gst_base_rtp_depayload_setcaps (GstPad * pad, GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstBaseRTPDepayload *filter;
|
2006-01-23 10:10:36 +00:00
|
|
|
GstBaseRTPDepayloadClass *bclass;
|
2007-03-29 16:23:53 +00:00
|
|
|
GstBaseRTPDepayloadPrivate *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
|
|
|
|
|
|
|
filter = GST_BASE_RTP_DEPAYLOAD (gst_pad_get_parent (pad));
|
2007-03-29 16:23:53 +00:00
|
|
|
priv = filter->priv;
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2006-01-23 10:10:36 +00:00
|
|
|
bclass = GST_BASE_RTP_DEPAYLOAD_GET_CLASS (filter);
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2007-03-29 16:23:53 +00:00
|
|
|
GST_DEBUG_OBJECT (filter, "Set caps");
|
|
|
|
|
|
|
|
caps_struct = gst_caps_get_structure (caps, 0);
|
|
|
|
|
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;
|
|
|
|
|
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;
|
|
|
|
|
2006-03-07 12:49:03 +00:00
|
|
|
gst_object_unref (filter);
|
2006-09-22 14:13:34 +00:00
|
|
|
|
2006-03-07 12:49:03 +00:00
|
|
|
return res;
|
2005-07-14 10:29:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_base_rtp_depayload_chain (GstPad * pad, GstBuffer * in)
|
|
|
|
{
|
|
|
|
GstBaseRTPDepayload *filter;
|
2007-09-04 16:18:48 +00:00
|
|
|
GstBaseRTPDepayloadPrivate *priv;
|
check/pipelines/simple_launch_lines.c: Fix for bus API.
Original commit message from CVS:
* check/pipelines/simple_launch_lines.c: (run_pipeline):
Fix for bus API.
* gst-libs/gst/rtp/gstbasertpdepayload.c:
(gst_base_rtp_depayload_chain),
(gst_base_rtp_depayload_add_to_queue),
(gst_base_rtp_depayload_push),
(gst_base_rtp_depayload_set_gst_timestamp),
(gst_base_rtp_depayload_queue_release):
Some cleanups.
* gst-libs/gst/rtp/gstbasertppayload.c:
(gst_basertppayload_class_init), (gst_basertppayload_init),
(gst_basertppayload_setcaps), (gst_basertppayload_set_options),
(gst_basertppayload_set_outcaps), (gst_basertppayload_push),
(gst_basertppayload_get_property),
(gst_basertppayload_change_state):
Added debugging category.
2005-09-19 11:24:46 +00:00
|
|
|
GstBaseRTPDepayloadClass *bclass;
|
2005-07-14 10:29:30 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2007-08-31 15:58:30 +00:00
|
|
|
GstBuffer *out_buf;
|
2007-09-16 19:31:06 +00:00
|
|
|
GstClockTime timestamp;
|
2008-05-23 14:14:28 +00:00
|
|
|
guint16 seqnum;
|
2008-10-06 16:29:33 +00:00
|
|
|
guint32 rtptime;
|
2011-04-06 15:25:37 +00:00
|
|
|
gboolean discont;
|
2008-05-23 14:14:28 +00:00
|
|
|
gint gap;
|
2005-07-14 10:29:30 +00:00
|
|
|
|
|
|
|
filter = GST_BASE_RTP_DEPAYLOAD (GST_OBJECT_PARENT (pad));
|
2008-10-13 09:16:59 +00:00
|
|
|
priv = filter->priv;
|
|
|
|
|
|
|
|
/* we must have a setcaps first */
|
|
|
|
if (G_UNLIKELY (!priv->negotiated))
|
|
|
|
goto not_negotiated;
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2008-05-23 14:14:28 +00:00
|
|
|
/* we must validate, it's possible that this element is plugged right after a
|
|
|
|
* network receiver and we don't want to operate on invalid data */
|
2008-10-13 09:16:59 +00:00
|
|
|
if (G_UNLIKELY (!gst_rtp_buffer_validate (in)))
|
2008-05-14 20:28:02 +00:00
|
|
|
goto invalid_buffer;
|
|
|
|
|
2010-08-18 10:34:07 +00:00
|
|
|
if (!priv->discont)
|
|
|
|
priv->discont = GST_BUFFER_IS_DISCONT (in);
|
2007-09-04 16:18:48 +00:00
|
|
|
|
2008-05-23 14:14:28 +00:00
|
|
|
timestamp = GST_BUFFER_TIMESTAMP (in);
|
2007-09-16 19:31:06 +00:00
|
|
|
/* convert to running_time and save the timestamp, this is the timestamp
|
|
|
|
* we put on outgoing buffers. */
|
|
|
|
timestamp = gst_segment_to_running_time (&filter->segment, GST_FORMAT_TIME,
|
|
|
|
timestamp);
|
|
|
|
priv->timestamp = timestamp;
|
2007-09-19 16:09:57 +00:00
|
|
|
priv->duration = GST_BUFFER_DURATION (in);
|
2007-09-16 19:31:06 +00:00
|
|
|
|
2008-05-23 14:14:28 +00:00
|
|
|
seqnum = gst_rtp_buffer_get_seq (in);
|
2008-10-06 16:29:33 +00:00
|
|
|
rtptime = gst_rtp_buffer_get_timestamp (in);
|
2008-05-23 14:14:28 +00:00
|
|
|
discont = FALSE;
|
|
|
|
|
2008-10-06 16:29:33 +00:00
|
|
|
GST_LOG_OBJECT (filter, "discont %d, seqnum %u, rtptime %u, timestamp %"
|
|
|
|
GST_TIME_FORMAT, priv->discont, seqnum, rtptime,
|
|
|
|
GST_TIME_ARGS (timestamp));
|
2008-05-23 14:14:28 +00:00
|
|
|
|
|
|
|
/* Check seqnum. This is a very simple check that makes sure that the seqnums
|
|
|
|
* are striclty increasing, dropping anything that is out of the ordinary. We
|
|
|
|
* 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)) {
|
2008-05-23 14:14:28 +00:00
|
|
|
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 {
|
|
|
|
/* seqnum < next_seqnum, we have seen this packet before 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. 100 misordered
|
|
|
|
* packets is a good threshold. See also RFC 4737. */
|
|
|
|
if (gap < 100)
|
|
|
|
goto dropping;
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (filter,
|
|
|
|
"%d > 100, packet too old, sender likely restarted", gap);
|
|
|
|
discont = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
priv->next_seqnum = (seqnum + 1) & 0xffff;
|
|
|
|
|
2008-10-13 09:16:59 +00:00
|
|
|
if (G_UNLIKELY (discont && !priv->discont)) {
|
2008-05-23 14:14:28 +00:00
|
|
|
GST_LOG_OBJECT (filter, "mark DISCONT on input buffer");
|
|
|
|
/* 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. */
|
|
|
|
priv->discont = TRUE;
|
2010-09-29 14:53:21 +00:00
|
|
|
in = gst_buffer_make_metadata_writable (in);
|
2008-05-23 14:14:28 +00:00
|
|
|
GST_BUFFER_FLAG_SET (in, GST_BUFFER_FLAG_DISCONT);
|
|
|
|
}
|
|
|
|
|
check/pipelines/simple_launch_lines.c: Fix for bus API.
Original commit message from CVS:
* check/pipelines/simple_launch_lines.c: (run_pipeline):
Fix for bus API.
* gst-libs/gst/rtp/gstbasertpdepayload.c:
(gst_base_rtp_depayload_chain),
(gst_base_rtp_depayload_add_to_queue),
(gst_base_rtp_depayload_push),
(gst_base_rtp_depayload_set_gst_timestamp),
(gst_base_rtp_depayload_queue_release):
Some cleanups.
* gst-libs/gst/rtp/gstbasertppayload.c:
(gst_basertppayload_class_init), (gst_basertppayload_init),
(gst_basertppayload_setcaps), (gst_basertppayload_set_options),
(gst_basertppayload_set_outcaps), (gst_basertppayload_push),
(gst_basertppayload_get_property),
(gst_basertppayload_change_state):
Added debugging category.
2005-09-19 11:24:46 +00:00
|
|
|
bclass = GST_BASE_RTP_DEPAYLOAD_GET_CLASS (filter);
|
2005-07-14 10:29:30 +00:00
|
|
|
|
2008-05-23 14:14:28 +00:00
|
|
|
if (G_UNLIKELY (bclass->process == NULL))
|
|
|
|
goto no_process;
|
|
|
|
|
2007-08-31 15:58:30 +00:00
|
|
|
/* let's send it out to processing */
|
|
|
|
out_buf = bclass->process (filter, in);
|
|
|
|
if (out_buf) {
|
2007-09-16 19:31:06 +00:00
|
|
|
/* we pass rtptime as backward compatibility, in reality, the incomming
|
|
|
|
* buffer timestamp is always applied to the outgoing packet. */
|
|
|
|
ret = gst_base_rtp_depayload_push_ts (filter, rtptime, out_buf);
|
2005-07-14 10:29:30 +00:00
|
|
|
}
|
2007-08-31 15:58:30 +00:00
|
|
|
gst_buffer_unref (in);
|
|
|
|
|
2005-07-14 10:29:30 +00:00
|
|
|
return 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 */
|
2010-09-06 17:17:10 +00:00
|
|
|
if (GST_BUFFER_CAPS (in) == NULL) {
|
|
|
|
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"));
|
|
|
|
} else {
|
|
|
|
GST_ELEMENT_ERROR (filter, CORE, NEGOTIATION,
|
|
|
|
("No RTP format was negotiated."),
|
|
|
|
("RTP caps on input buffer were rejected, most likely because they "
|
|
|
|
"were incomplete or contained wrong values. Check the debug log "
|
|
|
|
"for more information."));
|
|
|
|
}
|
2008-10-13 09:16:59 +00:00
|
|
|
gst_buffer_unref (in);
|
|
|
|
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"));
|
|
|
|
gst_buffer_unref (in);
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
2008-05-23 14:14:28 +00:00
|
|
|
dropping:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (filter, "%d <= 100, dropping old packet", gap);
|
|
|
|
gst_buffer_unref (in);
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
no_process:
|
|
|
|
{
|
|
|
|
/* this is not fatal but should be filtered earlier */
|
|
|
|
GST_ELEMENT_ERROR (filter, STREAM, NOT_IMPLEMENTED, (NULL),
|
|
|
|
("The subclass does not have a process method"));
|
|
|
|
gst_buffer_unref (in);
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
2005-07-14 10:29:30 +00:00
|
|
|
}
|
|
|
|
|
2005-12-18 00:56:07 +00:00
|
|
|
static gboolean
|
2010-12-21 14:02:18 +00:00
|
|
|
gst_base_rtp_depayload_handle_event (GstBaseRTPDepayload * filter,
|
|
|
|
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:
|
|
|
|
gst_segment_init (&filter->segment, GST_FORMAT_UNDEFINED);
|
|
|
|
filter->need_newsegment = TRUE;
|
2008-05-23 14:14:28 +00:00
|
|
|
filter->priv->next_seqnum = -1;
|
2007-09-16 19:31:06 +00:00
|
|
|
break;
|
2005-12-18 00:56:07 +00:00
|
|
|
case GST_EVENT_NEWSEGMENT:
|
|
|
|
{
|
2007-09-16 19:31:06 +00:00
|
|
|
gboolean update;
|
|
|
|
gdouble rate;
|
|
|
|
GstFormat fmt;
|
|
|
|
gint64 start, stop, position;
|
2007-08-31 15:58:30 +00:00
|
|
|
|
2007-09-16 19:31:06 +00:00
|
|
|
gst_event_parse_new_segment (event, &update, &rate, &fmt, &start, &stop,
|
|
|
|
&position);
|
2007-08-31 15:58:30 +00:00
|
|
|
|
2007-09-16 19:31:06 +00:00
|
|
|
gst_segment_set_newsegment (&filter->segment, update, rate, fmt,
|
|
|
|
start, stop, position);
|
|
|
|
|
|
|
|
/* don't pass the event downstream, we generate our own segment including
|
|
|
|
* the NTP time and other things we receive in caps */
|
2009-08-31 18:31:56 +00:00
|
|
|
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:
|
|
|
|
{
|
|
|
|
GstBaseRTPDepayloadClass *bclass;
|
|
|
|
|
|
|
|
bclass = GST_BASE_RTP_DEPAYLOAD_GET_CLASS (filter);
|
|
|
|
|
|
|
|
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
|
|
|
|
* implementation will make time progress by pushing out a NEWSEGMENT
|
|
|
|
* update event. Subclasses can override and to one of the following:
|
|
|
|
* - 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
|
|
|
|
gst_base_rtp_depayload_handle_sink_event (GstPad * pad, GstEvent * event)
|
|
|
|
{
|
|
|
|
gboolean res = FALSE;
|
|
|
|
GstBaseRTPDepayload *filter;
|
|
|
|
GstBaseRTPDepayloadClass *bclass;
|
|
|
|
|
2011-01-06 17:20:58 +00:00
|
|
|
filter = GST_BASE_RTP_DEPAYLOAD (gst_pad_get_parent (pad));
|
2011-04-08 13:10:02 +00:00
|
|
|
if (G_UNLIKELY (filter == NULL)) {
|
|
|
|
gst_event_unref (event);
|
2011-01-06 17:20:58 +00:00
|
|
|
return FALSE;
|
2011-04-08 13:10:02 +00:00
|
|
|
}
|
2010-12-21 14:02:18 +00:00
|
|
|
|
|
|
|
bclass = GST_BASE_RTP_DEPAYLOAD_GET_CLASS (filter);
|
|
|
|
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
|
|
|
|
2011-01-06 17:20:58 +00:00
|
|
|
gst_object_unref (filter);
|
2010-12-21 14:02:18 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2008-11-11 16:40:50 +00:00
|
|
|
static GstEvent *
|
|
|
|
create_segment_event (GstBaseRTPDepayload * filter, gboolean update,
|
|
|
|
GstClockTime position)
|
|
|
|
{
|
|
|
|
GstEvent *event;
|
|
|
|
GstClockTime stop;
|
|
|
|
GstBaseRTPDepayloadPrivate *priv;
|
|
|
|
|
|
|
|
priv = filter->priv;
|
|
|
|
|
|
|
|
if (priv->npt_stop != -1)
|
|
|
|
stop = priv->npt_stop - priv->npt_start;
|
|
|
|
else
|
|
|
|
stop = -1;
|
|
|
|
|
|
|
|
event = gst_event_new_new_segment_full (update, priv->play_speed,
|
|
|
|
priv->play_scale, GST_FORMAT_TIME, position, stop,
|
|
|
|
position + priv->npt_start);
|
|
|
|
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2010-12-15 11:58:47 +00:00
|
|
|
typedef struct
|
2005-08-10 20:52:37 +00:00
|
|
|
{
|
2010-12-15 11:58:47 +00:00
|
|
|
GstBaseRTPDepayload *depayload;
|
2006-09-22 14:13:34 +00:00
|
|
|
GstBaseRTPDepayloadClass *bclass;
|
2010-12-15 11:58:47 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
gboolean do_ts;
|
|
|
|
gboolean rtptime;
|
|
|
|
} HeaderData;
|
2007-09-04 16:18:48 +00:00
|
|
|
|
2010-12-15 11:58:47 +00:00
|
|
|
static GstBufferListItem
|
|
|
|
set_headers (GstBuffer ** buffer, guint group, guint idx, HeaderData * data)
|
|
|
|
{
|
|
|
|
GstBaseRTPDepayload *depayload = data->depayload;
|
2006-09-22 14:13:34 +00:00
|
|
|
|
2010-12-15 11:58:47 +00:00
|
|
|
*buffer = gst_buffer_make_metadata_writable (*buffer);
|
|
|
|
gst_buffer_set_caps (*buffer, data->caps);
|
2010-04-30 17:37:33 +00:00
|
|
|
|
2010-12-15 11:58:47 +00:00
|
|
|
/* set the timestamp if we must and can */
|
|
|
|
if (data->bclass->set_gst_timestamp && data->do_ts)
|
|
|
|
data->bclass->set_gst_timestamp (depayload, data->rtptime, *buffer);
|
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
|
|
|
|
2010-12-15 11:58:47 +00:00
|
|
|
return GST_BUFFER_LIST_SKIP_GROUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_base_rtp_depayload_prepare_push (GstBaseRTPDepayload * filter,
|
|
|
|
gboolean do_ts, guint32 rtptime, gboolean is_list, gpointer obj)
|
|
|
|
{
|
|
|
|
HeaderData data;
|
|
|
|
|
|
|
|
data.depayload = filter;
|
|
|
|
data.caps = GST_PAD_CAPS (filter->srcpad);
|
|
|
|
data.rtptime = rtptime;
|
|
|
|
data.do_ts = do_ts;
|
|
|
|
data.bclass = GST_BASE_RTP_DEPAYLOAD_GET_CLASS (filter);
|
|
|
|
|
|
|
|
if (is_list) {
|
2010-12-28 10:41:49 +00:00
|
|
|
GstBufferList **blist = obj;
|
|
|
|
gst_buffer_list_foreach (*blist, (GstBufferListFunc) set_headers, &data);
|
2010-12-15 11:58:47 +00:00
|
|
|
} else {
|
2010-12-28 10:41:49 +00:00
|
|
|
GstBuffer **buf = obj;
|
|
|
|
set_headers (buf, 0, 0, &data);
|
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 */
|
|
|
|
if (G_UNLIKELY (filter->need_newsegment)) {
|
|
|
|
GstEvent *event;
|
|
|
|
|
|
|
|
event = create_segment_event (filter, FALSE, 0);
|
|
|
|
|
|
|
|
gst_pad_push_event (filter->srcpad, event);
|
|
|
|
|
|
|
|
filter->need_newsegment = FALSE;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_base_rtp_depayload_push_ts:
|
|
|
|
* @filter: a #GstBaseRTPDepayload
|
|
|
|
* @timestamp: an RTP timestamp to apply
|
|
|
|
* @out_buf: a #GstBuffer
|
|
|
|
*
|
|
|
|
* Push @out_buf to the peer of @filter. This function takes ownership of
|
|
|
|
* @out_buf.
|
|
|
|
*
|
2010-03-08 11:11:01 +00:00
|
|
|
* Unlike gst_base_rtp_depayload_push(), this function will by default apply
|
|
|
|
* the last incomming timestamp on the outgoing buffer when it didn't have a
|
|
|
|
* timestamp already. The set_get_timestamp vmethod can be overwritten to change
|
|
|
|
* this behaviour (and take, for example, @timestamp into account).
|
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
|
|
|
|
gst_base_rtp_depayload_push_ts (GstBaseRTPDepayload * filter, guint32 timestamp,
|
|
|
|
GstBuffer * out_buf)
|
|
|
|
{
|
2010-12-15 11:58:47 +00:00
|
|
|
GstFlowReturn res;
|
|
|
|
|
|
|
|
res =
|
|
|
|
gst_base_rtp_depayload_prepare_push (filter, TRUE, timestamp, FALSE,
|
2010-12-28 10:41:49 +00:00
|
|
|
&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);
|
|
|
|
|
|
|
|
return res;
|
2006-09-22 14:13:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_base_rtp_depayload_push:
|
|
|
|
* @filter: a #GstBaseRTPDepayload
|
|
|
|
* @out_buf: a #GstBuffer
|
|
|
|
*
|
|
|
|
* Push @out_buf to the peer of @filter. This function takes ownership of
|
|
|
|
* @out_buf.
|
|
|
|
*
|
|
|
|
* Unlike gst_base_rtp_depayload_push_ts(), this function will not apply
|
2010-03-08 11:11:01 +00:00
|
|
|
* any timestamp on the outgoing buffer. Subclasses should therefore timestamp
|
|
|
|
* outgoing buffers themselves.
|
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
|
|
|
|
gst_base_rtp_depayload_push (GstBaseRTPDepayload * filter, GstBuffer * out_buf)
|
|
|
|
{
|
2010-12-15 11:58:47 +00:00
|
|
|
GstFlowReturn res;
|
|
|
|
|
2010-12-28 10:41:49 +00:00
|
|
|
res = gst_base_rtp_depayload_prepare_push (filter, FALSE, 0, 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);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_base_rtp_depayload_push_list:
|
|
|
|
* @filter: a #GstBaseRTPDepayload
|
|
|
|
* @out_list: a #GstBufferList
|
|
|
|
*
|
|
|
|
* Push @out_list to the peer of @filter. This function takes ownership of
|
|
|
|
* @out_list.
|
|
|
|
*
|
|
|
|
* Returns: a #GstFlowReturn.
|
|
|
|
*
|
|
|
|
* Since: 0.10.32
|
|
|
|
*/
|
|
|
|
GstFlowReturn
|
|
|
|
gst_base_rtp_depayload_push_list (GstBaseRTPDepayload * filter,
|
|
|
|
GstBufferList * out_list)
|
|
|
|
{
|
|
|
|
GstFlowReturn res;
|
|
|
|
|
2010-12-28 10:41:49 +00:00
|
|
|
res = gst_base_rtp_depayload_prepare_push (filter, TRUE, 0, 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);
|
|
|
|
|
|
|
|
return res;
|
2006-09-22 14:13:34 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 12:11:07 +00:00
|
|
|
/* convert the PacketLost event form a jitterbuffer to a segment update.
|
|
|
|
* subclasses can override this. */
|
|
|
|
static gboolean
|
|
|
|
gst_base_rtp_depayload_packet_lost (GstBaseRTPDepayload * filter,
|
|
|
|
GstEvent * event)
|
|
|
|
{
|
|
|
|
GstClockTime timestamp, duration, position;
|
|
|
|
GstEvent *sevent;
|
|
|
|
const GstStructure *s;
|
|
|
|
|
|
|
|
s = gst_event_get_structure (event);
|
|
|
|
|
|
|
|
/* first start by parsing the timestamp and duration */
|
|
|
|
timestamp = -1;
|
|
|
|
duration = -1;
|
|
|
|
|
|
|
|
gst_structure_get_clock_time (s, "timestamp", ×tamp);
|
|
|
|
gst_structure_get_clock_time (s, "duration", &duration);
|
|
|
|
|
|
|
|
position = timestamp;
|
|
|
|
if (duration != -1)
|
|
|
|
position += duration;
|
|
|
|
|
|
|
|
/* update the current segment with the elapsed time */
|
|
|
|
sevent = create_segment_event (filter, TRUE, position);
|
|
|
|
|
|
|
|
return gst_pad_push_event (filter->srcpad, sevent);
|
|
|
|
}
|
|
|
|
|
2005-08-10 20:52:37 +00:00
|
|
|
static void
|
|
|
|
gst_base_rtp_depayload_set_gst_timestamp (GstBaseRTPDepayload * filter,
|
2007-09-16 19:31:06 +00:00
|
|
|
guint32 rtptime, GstBuffer * buf)
|
2005-07-14 10:29:30 +00:00
|
|
|
{
|
2007-05-12 16:18:39 +00:00
|
|
|
GstBaseRTPDepayloadPrivate *priv;
|
2007-09-19 16:09:57 +00:00
|
|
|
GstClockTime timestamp, duration;
|
2006-09-22 14:13:34 +00:00
|
|
|
|
2007-05-12 16:18:39 +00:00
|
|
|
priv = filter->priv;
|
|
|
|
|
2007-09-19 16:09:57 +00:00
|
|
|
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
|
|
|
duration = GST_BUFFER_DURATION (buf);
|
|
|
|
|
|
|
|
/* apply last incomming timestamp and duration to outgoing buffer if
|
|
|
|
* not otherwise set. */
|
|
|
|
if (!GST_CLOCK_TIME_IS_VALID (timestamp))
|
|
|
|
GST_BUFFER_TIMESTAMP (buf) = priv->timestamp;
|
|
|
|
if (!GST_CLOCK_TIME_IS_VALID (duration))
|
|
|
|
GST_BUFFER_DURATION (buf) = priv->duration;
|
2005-07-14 10:29:30 +00:00
|
|
|
}
|
|
|
|
|
2005-09-02 15:43:18 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_base_rtp_depayload_change_state (GstElement * element,
|
|
|
|
GstStateChange transition)
|
2005-08-12 13:34:56 +00:00
|
|
|
{
|
|
|
|
GstBaseRTPDepayload *filter;
|
2007-09-16 19:31:06 +00:00
|
|
|
GstBaseRTPDepayloadPrivate *priv;
|
2006-10-06 13:34:46 +00:00
|
|
|
GstStateChangeReturn ret;
|
2005-08-12 13:34:56 +00:00
|
|
|
|
|
|
|
filter = GST_BASE_RTP_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;
|
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;
|
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:
|
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
|
|
|
}
|
|
|
|
|
2005-07-14 10:29:30 +00:00
|
|
|
static void
|
|
|
|
gst_base_rtp_depayload_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstBaseRTPDepayload *filter;
|
|
|
|
|
|
|
|
filter = GST_BASE_RTP_DEPAYLOAD (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2007-03-29 16:23:53 +00:00
|
|
|
case PROP_QUEUE_DELAY:
|
2005-07-14 10:29:30 +00:00
|
|
|
filter->queue_delay = g_value_get_uint (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_base_rtp_depayload_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstBaseRTPDepayload *filter;
|
|
|
|
|
|
|
|
filter = GST_BASE_RTP_DEPAYLOAD (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2007-03-29 16:23:53 +00:00
|
|
|
case PROP_QUEUE_DELAY:
|
2005-07-14 10:29:30 +00:00
|
|
|
g_value_set_uint (value, filter->queue_delay);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|