Commit ef02634d authored by Mark Nauwelaerts's avatar Mark Nauwelaerts
Browse files

rtpmanager: port to 0.11

* use G_DEFINE_TYPE
* adjust to new GstBuffer and corresponding rtp and rtcp buffer interfaces
* misc caps and segment handling changes

FIXME: also relies on being able to pass caps along with a buffer,
which has no evident equivalent yet, so that either needs one,
or still needs quite some code path modification to drag along caps.
parent 794320a2
......@@ -117,7 +117,8 @@ enum
LAST_SIGNAL
};
GST_BOILERPLATE (GstRtpPtDemux, gst_rtp_pt_demux, GstElement, GST_TYPE_ELEMENT);
#define gst_rtp_pt_demux_parent_class parent_class
G_DEFINE_TYPE (GstRtpPtDemux, gst_rtp_pt_demux, GST_TYPE_ELEMENT);
static void gst_rtp_pt_demux_finalize (GObject * object);
......@@ -137,22 +138,6 @@ static gboolean gst_rtp_pt_demux_src_event (GstPad * pad, GstEvent * event);
static guint gst_rtp_pt_demux_signals[LAST_SIGNAL] = { 0 };
static void
gst_rtp_pt_demux_base_init (gpointer g_class)
{
GstElementClass *gstelement_klass = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (gstelement_klass,
gst_static_pad_template_get (&rtp_pt_demux_sink_template));
gst_element_class_add_pad_template (gstelement_klass,
gst_static_pad_template_get (&rtp_pt_demux_src_template));
gst_element_class_set_details_simple (gstelement_klass, "RTP Demux",
"Demux/Network/RTP",
"Parses codec streams transmitted in the same RTP session",
"Kai Vehmanen <kai.vehmanen@nokia.com>");
}
static void
gst_rtp_pt_demux_class_init (GstRtpPtDemuxClass * klass)
{
......@@ -222,12 +207,22 @@ gst_rtp_pt_demux_class_init (GstRtpPtDemuxClass * klass)
klass->clear_pt_map = GST_DEBUG_FUNCPTR (gst_rtp_pt_demux_clear_pt_map);
gst_element_class_add_pad_template (gstelement_klass,
gst_static_pad_template_get (&rtp_pt_demux_sink_template));
gst_element_class_add_pad_template (gstelement_klass,
gst_static_pad_template_get (&rtp_pt_demux_src_template));
gst_element_class_set_details_simple (gstelement_klass, "RTP Demux",
"Demux/Network/RTP",
"Parses codec streams transmitted in the same RTP session",
"Kai Vehmanen <kai.vehmanen@nokia.com>");
GST_DEBUG_CATEGORY_INIT (gst_rtp_pt_demux_debug,
"rtpptdemux", 0, "RTP codec demuxer");
}
static void
gst_rtp_pt_demux_init (GstRtpPtDemux * ptdemux, GstRtpPtDemuxClass * g_class)
gst_rtp_pt_demux_init (GstRtpPtDemux * ptdemux)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (ptdemux);
......@@ -274,9 +269,7 @@ gst_rtp_pt_demux_get_caps (GstRtpPtDemux * rtpdemux, guint pt)
caps = g_value_dup_boxed (&ret);
g_value_unset (&ret);
if (caps == NULL) {
caps = GST_PAD_CAPS (rtpdemux->sink);
if (caps)
gst_caps_ref (caps);
caps = gst_pad_get_current_caps (rtpdemux->sink);
}
GST_DEBUG ("pt %d, got caps %" GST_PTR_FORMAT, pt, caps);
......@@ -309,13 +302,16 @@ gst_rtp_pt_demux_chain (GstPad * pad, GstBuffer * buf)
GstPad *srcpad;
GstRtpPtDemuxPad *rtpdemuxpad;
GstCaps *caps;
GstRTPBuffer rtp;
rtpdemux = GST_RTP_PT_DEMUX (GST_OBJECT_PARENT (pad));
if (!gst_rtp_buffer_validate (buf))
goto invalid_buffer;
pt = gst_rtp_buffer_get_payload_type (buf);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
pt = gst_rtp_buffer_get_payload_type (&rtp);
gst_rtp_buffer_unmap (&rtp);
GST_DEBUG_OBJECT (rtpdemux, "received buffer for pt %d", pt);
......@@ -385,8 +381,6 @@ gst_rtp_pt_demux_chain (GstPad * pad, GstBuffer * buf)
rtpdemuxpad->newcaps = FALSE;
}
gst_buffer_set_caps (buf, GST_PAD_CAPS (srcpad));
/* push to srcpad */
ret = gst_pad_push (srcpad, buf);
......@@ -490,11 +484,13 @@ gst_rtp_pt_demux_src_event (GstPad * pad, GstEvent * event)
GstRtpPtDemuxPad *dpad = (GstRtpPtDemuxPad *) walk->data;
if (dpad->pad == pad) {
GstStructure *ws;
event =
GST_EVENT_CAST (gst_mini_object_make_writable
(GST_MINI_OBJECT_CAST (event)));
gst_structure_set (event->structure,
"payload", G_TYPE_UINT, dpad->pt, NULL);
ws = gst_event_writable_structure (event);
gst_structure_set (ws, "payload", G_TYPE_UINT, dpad->pt, NULL);
break;
}
}
......
......@@ -284,9 +284,12 @@ static void gst_rtp_session_get_property (GObject * object, guint prop_id,
static GstStateChangeReturn gst_rtp_session_change_state (GstElement * element,
GstStateChange transition);
static GstPad *gst_rtp_session_request_new_pad (GstElement * element,
GstPadTemplate * templ, const gchar * name);
GstPadTemplate * templ, const gchar * name, const GstCaps * caps);
static void gst_rtp_session_release_pad (GstElement * element, GstPad * pad);
static gboolean gst_rtp_session_sink_setcaps (GstPad * pad, GstCaps * caps);
static gboolean gst_rtp_session_setcaps_send_rtp (GstPad * pad, GstCaps * caps);
static void gst_rtp_session_clear_pt_map (GstRtpSession * rtpsession);
static guint gst_rtp_session_signals[LAST_SIGNAL] = { 0 };
......@@ -365,35 +368,8 @@ on_sender_timeout (RTPSession * session, RTPSource * src, GstRtpSession * sess)
src->ssrc);
}
GST_BOILERPLATE (GstRtpSession, gst_rtp_session, GstElement, GST_TYPE_ELEMENT);
static void
gst_rtp_session_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
/* sink pads */
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&rtpsession_recv_rtp_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&rtpsession_recv_rtcp_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&rtpsession_send_rtp_sink_template));
/* src pads */
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&rtpsession_recv_rtp_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&rtpsession_sync_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&rtpsession_send_rtp_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&rtpsession_send_rtcp_src_template));
gst_element_class_set_details_simple (element_class, "RTP Session",
"Filter/Network/RTP",
"Implement an RTP session", "Wim Taymans <wim.taymans@gmail.com>");
}
#define gst_rtp_session_parent_class parent_class
G_DEFINE_TYPE (GstRtpSession, gst_rtp_session, GST_TYPE_ELEMENT);
static void
gst_rtp_session_class_init (GstRtpSessionClass * klass)
......@@ -611,12 +587,34 @@ gst_rtp_session_class_init (GstRtpSessionClass * klass)
klass->clear_pt_map = GST_DEBUG_FUNCPTR (gst_rtp_session_clear_pt_map);
/* sink pads */
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&rtpsession_recv_rtp_sink_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&rtpsession_recv_rtcp_sink_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&rtpsession_send_rtp_sink_template));
/* src pads */
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&rtpsession_recv_rtp_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&rtpsession_sync_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&rtpsession_send_rtp_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&rtpsession_send_rtcp_src_template));
gst_element_class_set_details_simple (gstelement_class, "RTP Session",
"Filter/Network/RTP",
"Implement an RTP session", "Wim Taymans <wim.taymans@gmail.com>");
GST_DEBUG_CATEGORY_INIT (gst_rtp_session_debug,
"rtpsession", 0, "RTP Session");
}
static void
gst_rtp_session_init (GstRtpSession * rtpsession, GstRtpSessionClass * klass)
gst_rtp_session_init (GstRtpSession * rtpsession)
{
rtpsession->priv = GST_RTP_SESSION_GET_PRIVATE (rtpsession);
rtpsession->priv->lock = g_mutex_new ();
......@@ -977,7 +975,7 @@ gst_rtp_session_change_state (GstElement * element, GstStateChange transition)
break;
}
res = parent_class->change_state (element, transition);
res = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
......@@ -1099,12 +1097,10 @@ gst_rtp_session_send_rtcp (RTPSession * sess, RTPSource * src,
GstCaps *caps;
/* set rtcp caps on output pad */
if (!(caps = GST_PAD_CAPS (rtcp_src))) {
if (!(caps = gst_pad_get_current_caps (rtcp_src))) {
caps = gst_caps_new_simple ("application/x-rtcp", NULL);
gst_pad_set_caps (rtcp_src, caps);
} else
gst_caps_ref (caps);
gst_buffer_set_caps (buffer, caps);
}
gst_caps_unref (caps);
gst_object_ref (rtcp_src);
......@@ -1158,12 +1154,10 @@ gst_rtp_session_sync_rtcp (RTPSession * sess, RTPSource * src,
GstCaps *caps;
/* set rtcp caps on output pad */
if (!(caps = GST_PAD_CAPS (sync_src))) {
if (!(caps = gst_pad_get_current_caps (sync_src))) {
caps = gst_caps_new_simple ("application/x-rtcp", NULL);
gst_pad_set_caps (sync_src, caps);
} else
gst_caps_ref (caps);
gst_buffer_set_caps (buffer, caps);
}
gst_caps_unref (caps);
gst_object_ref (sync_src);
......@@ -1334,37 +1328,36 @@ gst_rtp_session_event_recv_rtp_sink (GstPad * pad, GstEvent * event)
GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CAPS:
{
GstCaps *caps;
/* process */
gst_event_parse_caps (event, &caps);
gst_rtp_session_sink_setcaps (pad, caps);
/* and eat */
gst_event_unref (event);
break;
}
case GST_EVENT_FLUSH_STOP:
gst_segment_init (&rtpsession->recv_rtp_seg, GST_FORMAT_UNDEFINED);
ret = gst_pad_push_event (rtpsession->recv_rtp_src, event);
break;
case GST_EVENT_NEWSEGMENT:
case GST_EVENT_SEGMENT:
{
gboolean update;
gdouble rate, arate;
GstFormat format;
gint64 start, stop, time;
GstSegment *segment;
GstSegment *segment, in_segment;
segment = &rtpsession->recv_rtp_seg;
/* the newsegment event is needed to convert the RTP timestamp to
* running_time, which is needed to generate a mapping from RTP to NTP
* timestamps in SR reports */
gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
&start, &stop, &time);
GST_DEBUG_OBJECT (rtpsession,
"configured NEWSEGMENT update %d, rate %lf, applied rate %lf, "
"format GST_FORMAT_TIME, "
"%" GST_TIME_FORMAT " -- %" GST_TIME_FORMAT
", time %" GST_TIME_FORMAT ", accum %" GST_TIME_FORMAT,
update, rate, arate, GST_TIME_ARGS (segment->start),
GST_TIME_ARGS (segment->stop), GST_TIME_ARGS (segment->time),
GST_TIME_ARGS (segment->accum));
gst_event_copy_segment (event, &in_segment);
GST_DEBUG_OBJECT (rtpsession, "received segment %" GST_SEGMENT_FORMAT,
in_segment);
gst_segment_set_newsegment_full (segment, update, rate,
arate, format, start, stop, time);
/* accept upstream */
gst_segment_copy_into (&in_segment, segment);
/* push event forward */
ret = gst_pad_push_event (rtpsession->recv_rtp_src, event);
......@@ -1475,8 +1468,12 @@ gst_rtp_session_iterate_internal_links (GstPad * pad)
GST_RTP_SESSION_UNLOCK (rtpsession);
if (otherpad) {
it = gst_iterator_new_single (GST_TYPE_PAD, otherpad,
(GstCopyFunction) gst_object_ref, (GFreeFunc) gst_object_unref);
GValue val = { 0, };
g_value_init (&val, GST_TYPE_PAD);
g_value_set_object (&val, otherpad);
it = gst_iterator_new_single (GST_TYPE_PAD, &val);
g_value_unset (&val);
gst_object_unref (otherpad);
}
......@@ -1664,36 +1661,35 @@ gst_rtp_session_event_send_rtp_sink (GstPad * pad, GstEvent * event)
GST_DEBUG_OBJECT (rtpsession, "received event");
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CAPS:
{
GstCaps *caps;
/* process */
gst_event_parse_caps (event, &caps);
gst_rtp_session_setcaps_send_rtp (pad, caps);
/* and eat */
gst_event_unref (event);
break;
}
case GST_EVENT_FLUSH_STOP:
gst_segment_init (&rtpsession->send_rtp_seg, GST_FORMAT_UNDEFINED);
ret = gst_pad_push_event (rtpsession->send_rtp_src, event);
break;
case GST_EVENT_NEWSEGMENT:{
gboolean update;
gdouble rate, arate;
GstFormat format;
gint64 start, stop, time;
GstSegment *segment;
case GST_EVENT_SEGMENT:{
GstSegment *segment, in_segment;
segment = &rtpsession->send_rtp_seg;
/* the newsegment event is needed to convert the RTP timestamp to
* running_time, which is needed to generate a mapping from RTP to NTP
* timestamps in SR reports */
gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
&start, &stop, &time);
GST_DEBUG_OBJECT (rtpsession,
"configured NEWSEGMENT update %d, rate %lf, applied rate %lf, "
"format GST_FORMAT_TIME, "
"%" GST_TIME_FORMAT " -- %" GST_TIME_FORMAT
", time %" GST_TIME_FORMAT ", accum %" GST_TIME_FORMAT,
update, rate, arate, GST_TIME_ARGS (segment->start),
GST_TIME_ARGS (segment->stop), GST_TIME_ARGS (segment->time),
GST_TIME_ARGS (segment->accum));
gst_event_copy_segment (event, &in_segment);
GST_DEBUG_OBJECT (rtpsession, "received segment %" GST_SEGMENT_FORMAT,
in_segment);
gst_segment_set_newsegment_full (segment, update, rate,
arate, format, start, stop, time);
/* accept upstream */
gst_segment_copy_into (&in_segment, segment);
/* push event forward */
ret = gst_pad_push_event (rtpsession->send_rtp_src, event);
......@@ -1733,7 +1729,7 @@ gst_rtp_session_event_send_rtp_sink (GstPad * pad, GstEvent * event)
}
static GstCaps *
gst_rtp_session_getcaps_send_rtp (GstPad * pad)
gst_rtp_session_getcaps_send_rtp (GstPad * pad, GstCaps * filter)
{
GstRtpSession *rtpsession;
GstRtpSessionPrivate *priv;
......@@ -1754,6 +1750,13 @@ gst_rtp_session_getcaps_send_rtp (GstPad * pad)
result = gst_caps_new_full (s1, s2, NULL);
if (filter) {
GstCaps *caps = result;
result = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (caps);
}
GST_DEBUG_OBJECT (rtpsession, "getting caps %" GST_PTR_FORMAT, result);
gst_object_unref (rtpsession);
......@@ -1806,7 +1809,7 @@ gst_rtp_session_chain_send_rtp_common (GstPad * pad, gpointer data,
/* All groups in an list have the same timestamp.
* So, just take it from the first group. */
buffer = gst_buffer_list_get (GST_BUFFER_LIST_CAST (data), 0, 0);
buffer = gst_buffer_list_get (GST_BUFFER_LIST_CAST (data), 0);
if (buffer)
timestamp = GST_BUFFER_TIMESTAMP (buffer);
else
......@@ -1872,8 +1875,6 @@ create_recv_rtp_sink (GstRtpSession * rtpsession)
gst_rtp_session_chain_recv_rtp);
gst_pad_set_event_function (rtpsession->recv_rtp_sink,
(GstPadEventFunction) gst_rtp_session_event_recv_rtp_sink);
gst_pad_set_setcaps_function (rtpsession->recv_rtp_sink,
gst_rtp_session_sink_setcaps);
gst_pad_set_iterate_internal_links_function (rtpsession->recv_rtp_sink,
gst_rtp_session_iterate_internal_links);
gst_pad_set_active (rtpsession->recv_rtp_sink, TRUE);
......@@ -1986,8 +1987,6 @@ create_send_rtp_sink (GstRtpSession * rtpsession)
gst_rtp_session_chain_send_rtp_list);
gst_pad_set_getcaps_function (rtpsession->send_rtp_sink,
gst_rtp_session_getcaps_send_rtp);
gst_pad_set_setcaps_function (rtpsession->send_rtp_sink,
gst_rtp_session_setcaps_send_rtp);
gst_pad_set_event_function (rtpsession->send_rtp_sink,
(GstPadEventFunction) gst_rtp_session_event_send_rtp_sink);
gst_pad_set_iterate_internal_links_function (rtpsession->send_rtp_sink,
......@@ -2064,7 +2063,7 @@ remove_send_rtcp_src (GstRtpSession * rtpsession)
static GstPad *
gst_rtp_session_request_new_pad (GstElement * element,
GstPadTemplate * templ, const gchar * name)
GstPadTemplate * templ, const gchar * name, const GstCaps * caps)
{
GstRtpSession *rtpsession;
GstElementClass *klass;
......
......@@ -95,9 +95,8 @@ enum
LAST_SIGNAL
};
GST_BOILERPLATE (GstRtpSsrcDemux, gst_rtp_ssrc_demux, GstElement,
GST_TYPE_ELEMENT);
#define gst_rtp_ssrc_demux_parent_class parent_class
G_DEFINE_TYPE (GstRtpSsrcDemux, gst_rtp_ssrc_demux, GST_TYPE_ELEMENT);
/* GObject vmethods */
static void gst_rtp_ssrc_demux_dispose (GObject * object);
......@@ -164,6 +163,7 @@ find_or_create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc)
GstPadTemplate *templ;
gchar *padname;
GstRtpSsrcDemuxPad *demuxpad;
GstCaps *caps;
GST_DEBUG_OBJECT (demux, "creating pad for SSRC %08x", ssrc);
......@@ -198,9 +198,13 @@ find_or_create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc)
demux->srcpads = g_slist_prepend (demux->srcpads, demuxpad);
/* copy caps from input */
gst_pad_set_caps (rtp_pad, GST_PAD_CAPS (demux->rtp_sink));
caps = gst_pad_get_current_caps (demux->rtp_sink);
gst_pad_set_caps (rtp_pad, caps);
gst_caps_unref (caps);
gst_pad_use_fixed_caps (rtp_pad);
gst_pad_set_caps (rtcp_pad, GST_PAD_CAPS (demux->rtcp_sink));
caps = gst_pad_get_current_caps (demux->rtcp_sink);
gst_pad_set_caps (rtcp_pad, caps);
gst_caps_unref (caps);
gst_pad_use_fixed_caps (rtcp_pad);
gst_pad_set_event_function (rtp_pad, gst_rtp_ssrc_demux_src_event);
......@@ -225,26 +229,6 @@ find_or_create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc)
return demuxpad;
}
static void
gst_rtp_ssrc_demux_base_init (gpointer g_class)
{
GstElementClass *gstelement_klass = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (gstelement_klass,
gst_static_pad_template_get (&rtp_ssrc_demux_sink_template));
gst_element_class_add_pad_template (gstelement_klass,
gst_static_pad_template_get (&rtp_ssrc_demux_rtcp_sink_template));
gst_element_class_add_pad_template (gstelement_klass,
gst_static_pad_template_get (&rtp_ssrc_demux_src_template));
gst_element_class_add_pad_template (gstelement_klass,
gst_static_pad_template_get (&rtp_ssrc_demux_rtcp_src_template));
gst_element_class_set_details_simple (gstelement_klass, "RTP SSRC Demux",
"Demux/Network/RTP",
"Splits RTP streams based on the SSRC",
"Wim Taymans <wim.taymans@gmail.com>");
}
static void
gst_rtp_ssrc_demux_class_init (GstRtpSsrcDemuxClass * klass)
{
......@@ -307,13 +291,26 @@ gst_rtp_ssrc_demux_class_init (GstRtpSsrcDemuxClass * klass)
gstrtpssrcdemux_klass->clear_ssrc =
GST_DEBUG_FUNCPTR (gst_rtp_ssrc_demux_clear_ssrc);
gst_element_class_add_pad_template (gstelement_klass,
gst_static_pad_template_get (&rtp_ssrc_demux_sink_template));
gst_element_class_add_pad_template (gstelement_klass,
gst_static_pad_template_get (&rtp_ssrc_demux_rtcp_sink_template));
gst_element_class_add_pad_template (gstelement_klass,
gst_static_pad_template_get (&rtp_ssrc_demux_src_template));
gst_element_class_add_pad_template (gstelement_klass,
gst_static_pad_template_get (&rtp_ssrc_demux_rtcp_src_template));
gst_element_class_set_details_simple (gstelement_klass, "RTP SSRC Demux",
"Demux/Network/RTP",
"Splits RTP streams based on the SSRC",
"Wim Taymans <wim.taymans@gmail.com>");
GST_DEBUG_CATEGORY_INIT (gst_rtp_ssrc_demux_debug,
"rtpssrcdemux", 0, "RTP SSRC demuxer");
}
static void
gst_rtp_ssrc_demux_init (GstRtpSsrcDemux * demux,
GstRtpSsrcDemuxClass * g_class)
gst_rtp_ssrc_demux_init (GstRtpSsrcDemux * demux)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (demux);
......@@ -437,7 +434,6 @@ gst_rtp_ssrc_demux_sink_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_STOP:
gst_segment_init (&demux->segment, GST_FORMAT_UNDEFINED);
case GST_EVENT_NEWSEGMENT:
default:
{
GSList *walk;
......@@ -481,7 +477,6 @@ gst_rtp_ssrc_demux_rtcp_sink_event (GstPad * pad, GstEvent * event)
demux = GST_RTP_SSRC_DEMUX (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:
default:
{
GSList *walk;
......@@ -518,13 +513,16 @@ gst_rtp_ssrc_demux_chain (GstPad * pad, GstBuffer * buf)
GstRtpSsrcDemux *demux;
guint32 ssrc;
GstRtpSsrcDemuxPad *dpad;
GstRTPBuffer rtp;
demux = GST_RTP_SSRC_DEMUX (GST_OBJECT_PARENT (pad));
if (!gst_rtp_buffer_validate (buf))
goto invalid_payload;
ssrc = gst_rtp_buffer_get_ssrc (buf);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
ssrc = gst_rtp_buffer_get_ssrc (&rtp);
gst_rtp_buffer_unmap (&rtp);
GST_DEBUG_OBJECT (demux, "received buffer of SSRC %08x", ssrc);
......@@ -563,14 +561,18 @@ gst_rtp_ssrc_demux_rtcp_chain (GstPad * pad, GstBuffer * buf)
guint32 ssrc;
GstRtpSsrcDemuxPad *dpad;
GstRTCPPacket packet;
GstRTCPBuffer rtcp;
demux = GST_RTP_SSRC_DEMUX (GST_OBJECT_PARENT (pad));
if (!gst_rtcp_buffer_validate (buf))
goto invalid_rtcp;
if (!gst_rtcp_buffer_get_first_packet (buf, &packet))
gst_rtcp_buffer_map (buf, GST_MAP_READ, &rtcp);
if (!gst_rtcp_buffer_get_first_packet (&rtcp, &packet)) {
gst_rtcp_buffer_unmap (&rtcp);
goto invalid_rtcp;
}
/* first packet must be SR or RR or else the validate would have failed */
switch (gst_rtcp_packet_get_type (&packet)) {
......@@ -582,6 +584,7 @@ gst_rtp_ssrc_demux_rtcp_chain (GstPad * pad, GstBuffer * buf)
default:
goto unexpected_rtcp;
}
gst_rtcp_buffer_unmap (&rtcp);
GST_DEBUG_OBJECT (demux, "received RTCP of SSRC %08x", ssrc);
......@@ -639,11 +642,13 @@ gst_rtp_ssrc_demux_src_event (GstPad * pad, GstEvent * event)
GstRtpSsrcDemuxPad *dpad = (GstRtpSsrcDemuxPad *) walk->data;
if (dpad->rtp_pad == pad || dpad->rtcp_pad == pad) {
GstStructure *ws;
event =
GST_EVENT_CAST (gst_mini_object_make_writable
(GST_MINI_OBJECT_CAST (event)));
gst_structure_set (event->structure, "ssrc", G_TYPE_UINT,
dpad->ssrc, NULL);
ws = gst_event_writable_structure (event);
gst_structure_set (ws, "ssrc", G_TYPE_UINT, dpad->ssrc, NULL);
break;
}
}
......@@ -683,8 +688,15 @@ gst_rtp_ssrc_demux_iterate_internal_links_src (GstPad * pad)
break;
}
}
it = gst_iterator_new_single (GST_TYPE_PAD, otherpad,
(GstCopyFunction) gst_object_ref, (GFreeFunc) gst_object_unref);
if (otherpad) {
GValue val = { 0, };
g_value_init (&val, GST_TYPE_PAD);
g_value_set_object (&val, otherpad);
it = gst_iterator_new_single (GST_TYPE_PAD, &val);
g_value_unset (&val);
gst_object_unref (otherpad);
}
GST_PAD_UNLOCK (demux);
gst_object_unref (demux);
......
......@@ -608,18 +608,24 @@ rtp_jitter_buffer_insert (RTPJitterBuffer * jbuf, GstBuffer * buf,
GList *list;
guint32 rtptime;
guint16 seqnum;
GstRTPBuffer rtp;
g_return_val_if_fail (jbuf != NULL, FALSE);
g_return_val_if_fail (buf != NULL, FALSE);
seqnum = gst_rtp_buffer_get_seq (buf);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
seqnum = gst_rtp_buffer_get_seq (&rtp);
/* loop the list to skip strictly smaller seqnum buffers */
for (list = jbuf->packets->head; list; list = g_list_next (list)) {
guint16 qseq;
gint gap;
GstRTPBuffer rtpb;
qseq = gst_rtp_buffer_get_seq (GST_BUFFER_CAST (list->data));
gst_rtp_buffer_map (GST_BUFFER_CAST (list->data), GST_MAP_READ, &rtpb);
qseq = gst_rtp_buffer_get_seq (&rtpb);
gst_rtp_buffer_unmap (&rtpb);