summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunjun Ko <zzoon.ko@samsung.com>2015-10-02 16:16:32 +0900
committerSebastian Dröge <sebastian@centricular.com>2015-10-02 16:39:29 +0300
commit2b1f52755df222d56f1e9c4a52826539e8f9c062 (patch)
tree80293b25462a2f023dbb716284ea2c7156b0087d
parent040467d118ec633260424660bfa2946eb50a8c3f (diff)
rtpmanager: add new on-new-sender-ssrc, on-sender-ssrc-active signals
Allows for applications to get internal source's RTP statistics. (eg. sender sources for a server/client) https://bugzilla.gnome.org/show_bug.cgi?id=746747
-rw-r--r--docs/plugins/gst-plugins-good-plugins.signals34
-rw-r--r--gst/rtpmanager/gstrtpbin.c52
-rw-r--r--gst/rtpmanager/gstrtpbin.h3
-rw-r--r--gst/rtpmanager/gstrtpsession.c52
-rw-r--r--gst/rtpmanager/gstrtpsession.h2
-rw-r--r--gst/rtpmanager/rtpsession.c68
-rw-r--r--gst/rtpmanager/rtpsession.h2
7 files changed, 212 insertions, 1 deletions
diff --git a/docs/plugins/gst-plugins-good-plugins.signals b/docs/plugins/gst-plugins-good-plugins.signals
index ea2a04ba0..169f54e69 100644
--- a/docs/plugins/gst-plugins-good-plugins.signals
+++ b/docs/plugins/gst-plugins-good-plugins.signals
@@ -349,6 +349,24 @@ guint arg1
</SIGNAL>
<SIGNAL>
+<NAME>GstRtpBin::on-new-sender-ssrc</NAME>
+<RETURNS>void</RETURNS>
+<FLAGS>l</FLAGS>
+GstRtpBin *gstrtpbin
+guint arg1
+guint arg2
+</SIGNAL>
+
+<SIGNAL>
+<NAME>GstRtpBin::on-sender-ssrc-active</NAME>
+<RETURNS>void</RETURNS>
+<FLAGS>l</FLAGS>
+GstRtpBin *gstrtpbin
+guint arg1
+guint arg2
+</SIGNAL>
+
+<SIGNAL>
<NAME>GstRtpJitterBuffer::clear-pt-map</NAME>
<RETURNS>void</RETURNS>
<FLAGS>la</FLAGS>
@@ -507,6 +525,22 @@ guint arg1
</SIGNAL>
<SIGNAL>
+<NAME>GstRtpSession::on-new-sender-ssrc</NAME>
+<RETURNS>void</RETURNS>
+<FLAGS>l</FLAGS>
+GstRtpSession *gstrtpsession
+guint arg1
+</SIGNAL>
+
+<SIGNAL>
+<NAME>GstRtpSession::on-sender-ssrc-active</NAME>
+<RETURNS>void</RETURNS>
+<FLAGS>l</FLAGS>
+GstRtpSession *gstrtpsession
+guint arg1
+</SIGNAL>
+
+<SIGNAL>
<NAME>GstRtpSsrcDemux::clear-ssrc</NAME>
<RETURNS>void</RETURNS>
<FLAGS>la</FLAGS>
diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c
index c7a025326..86a572ec9 100644
--- a/gst/rtpmanager/gstrtpbin.c
+++ b/gst/rtpmanager/gstrtpbin.c
@@ -272,6 +272,9 @@ enum
SIGNAL_REQUEST_AUX_SENDER,
SIGNAL_REQUEST_AUX_RECEIVER,
+ SIGNAL_ON_NEW_SENDER_SSRC,
+ SIGNAL_ON_SENDER_SSRC_ACTIVE,
+
LAST_SIGNAL
};
@@ -565,6 +568,21 @@ on_npt_stop (GstElement * jbuf, GstRtpBinStream * stream)
stream->session->id, stream->ssrc);
}
+static void
+on_new_sender_ssrc (GstElement * session, guint32 ssrc, GstRtpBinSession * sess)
+{
+ g_signal_emit (sess->bin, gst_rtp_bin_signals[SIGNAL_ON_NEW_SENDER_SSRC], 0,
+ sess->id, ssrc);
+}
+
+static void
+on_sender_ssrc_active (GstElement * session, guint32 ssrc,
+ GstRtpBinSession * sess)
+{
+ g_signal_emit (sess->bin, gst_rtp_bin_signals[SIGNAL_ON_SENDER_SSRC_ACTIVE],
+ 0, sess->id, ssrc);
+}
+
/* must be called with the SESSION lock */
static GstRtpBinStream *
find_stream_by_ssrc (GstRtpBinSession * session, guint32 ssrc)
@@ -659,6 +677,10 @@ create_session (GstRtpBin * rtpbin, gint id)
g_signal_connect (sess->session, "on-timeout", (GCallback) on_timeout, sess);
g_signal_connect (sess->session, "on-sender-timeout",
(GCallback) on_sender_timeout, sess);
+ g_signal_connect (sess->session, "on-new-sender-ssrc",
+ (GCallback) on_new_sender_ssrc, sess);
+ g_signal_connect (sess->session, "on-sender-ssrc-active",
+ (GCallback) on_sender_ssrc_active, sess);
gst_bin_add (GST_BIN_CAST (rtpbin), session);
gst_bin_add (GST_BIN_CAST (rtpbin), demux);
@@ -2070,6 +2092,36 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass,
request_aux_receiver), _gst_element_accumulator, NULL,
g_cclosure_marshal_generic, GST_TYPE_ELEMENT, 1, G_TYPE_UINT);
+ /**
+ * GstRtpBin::on-new-sender-ssrc:
+ * @rtpbin: the object which received the signal
+ * @session: the session
+ * @ssrc: the sender SSRC
+ *
+ * Since: 1.8
+ *
+ * Notify of a new sender SSRC that entered @session.
+ */
+ gst_rtp_bin_signals[SIGNAL_ON_NEW_SENDER_SSRC] =
+ g_signal_new ("on-new-sender-ssrc", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass, on_new_sender_ssrc),
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 2, G_TYPE_UINT,
+ G_TYPE_UINT);
+ /**
+ * GstRtpBin::on-ssrc-active:
+ * @rtpbin: the object which received the signal
+ * @session: the session
+ * @ssrc: the sender SSRC
+ *
+ * Since: 1.8
+ *
+ * Notify of a sender SSRC that is active, i.e., sending RTCP.
+ */
+ gst_rtp_bin_signals[SIGNAL_ON_SENDER_SSRC_ACTIVE] =
+ g_signal_new ("on-sender-ssrc-active", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass,
+ on_sender_ssrc_active), NULL, NULL, g_cclosure_marshal_generic,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
g_object_class_install_property (gobject_class, PROP_SDES,
g_param_spec_boxed ("sdes", "SDES",
diff --git a/gst/rtpmanager/gstrtpbin.h b/gst/rtpmanager/gstrtpbin.h
index b8cfee289..20dab2bb4 100644
--- a/gst/rtpmanager/gstrtpbin.h
+++ b/gst/rtpmanager/gstrtpbin.h
@@ -119,6 +119,9 @@ struct _GstRtpBinClass {
GstElement* (*request_aux_sender) (GstRtpBin *rtpbin, guint session);
GstElement* (*request_aux_receiver) (GstRtpBin *rtpbin, guint session);
+
+ void (*on_new_sender_ssrc) (GstRtpBin *rtpbin, guint session, guint32 ssrc);
+ void (*on_sender_ssrc_active) (GstRtpBin *rtpbin, guint session, guint32 ssrc);
};
GType gst_rtp_bin_get_type (void);
diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c
index d3352fcb1..5d3e7a38a 100644
--- a/gst/rtpmanager/gstrtpsession.c
+++ b/gst/rtpmanager/gstrtpsession.c
@@ -208,6 +208,8 @@ enum
SIGNAL_ON_BYE_TIMEOUT,
SIGNAL_ON_TIMEOUT,
SIGNAL_ON_SENDER_TIMEOUT,
+ SIGNAL_ON_NEW_SENDER_SSRC,
+ SIGNAL_ON_SENDER_SSRC_ACTIVE,
LAST_SIGNAL
};
@@ -444,6 +446,21 @@ on_sender_timeout (RTPSession * session, RTPSource * src, GstRtpSession * sess)
src->ssrc);
}
+static void
+on_new_sender_ssrc (RTPSession * session, RTPSource * src, GstRtpSession * sess)
+{
+ g_signal_emit (sess, gst_rtp_session_signals[SIGNAL_ON_NEW_SENDER_SSRC], 0,
+ src->ssrc);
+}
+
+static void
+on_sender_ssrc_active (RTPSession * session, RTPSource * src,
+ GstRtpSession * sess)
+{
+ g_signal_emit (sess, gst_rtp_session_signals[SIGNAL_ON_SENDER_SSRC_ACTIVE], 0,
+ src->ssrc);
+}
+
#define gst_rtp_session_parent_class parent_class
G_DEFINE_TYPE (GstRtpSession, gst_rtp_session, GST_TYPE_ELEMENT);
@@ -520,7 +537,7 @@ gst_rtp_session_class_init (GstRtpSessionClass * klass)
on_ssrc_validated), NULL, NULL, g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE, 1, G_TYPE_UINT);
/**
- * GstRtpSession::on-ssrc_active:
+ * GstRtpSession::on-ssrc-active:
* @sess: the object which received the signal
* @ssrc: the SSRC
*
@@ -589,6 +606,35 @@ gst_rtp_session_class_init (GstRtpSessionClass * klass)
on_sender_timeout), NULL, NULL, g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE, 1, G_TYPE_UINT);
+ /**
+ * GstRtpSession::on-new-sender-ssrc:
+ * @sess: the object which received the signal
+ * @ssrc: the sender SSRC
+ *
+ * Since: 1.8
+ *
+ * Notify of a new sender SSRC that entered @session.
+ */
+ gst_rtp_session_signals[SIGNAL_ON_NEW_SENDER_SSRC] =
+ g_signal_new ("on-new-sender-ssrc", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpSessionClass, on_new_ssrc),
+ NULL, NULL, g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
+
+ /**
+ * GstRtpSession::on-sender-ssrc-active:
+ * @sess: the object which received the signal
+ * @ssrc: the sender SSRC
+ *
+ * Since: 1.8
+ *
+ * Notify of a sender SSRC that is active, i.e., sending RTCP.
+ */
+ gst_rtp_session_signals[SIGNAL_ON_SENDER_SSRC_ACTIVE] =
+ g_signal_new ("on-sender-ssrc-active", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpSessionClass,
+ on_ssrc_active), NULL, NULL, g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE, 1, G_TYPE_UINT);
+
g_object_class_install_property (gobject_class, PROP_BANDWIDTH,
g_param_spec_double ("bandwidth", "Bandwidth",
"The bandwidth of the session in bytes per second (0 for auto-discover)",
@@ -759,6 +805,10 @@ gst_rtp_session_init (GstRtpSession * rtpsession)
(GCallback) on_timeout, rtpsession);
g_signal_connect (rtpsession->priv->session, "on-sender-timeout",
(GCallback) on_sender_timeout, rtpsession);
+ g_signal_connect (rtpsession->priv->session, "on-new-sender-ssrc",
+ (GCallback) on_new_sender_ssrc, rtpsession);
+ g_signal_connect (rtpsession->priv->session, "on-sender-ssrc-active",
+ (GCallback) on_sender_ssrc_active, rtpsession);
rtpsession->priv->ptmap = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) gst_caps_unref);
diff --git a/gst/rtpmanager/gstrtpsession.h b/gst/rtpmanager/gstrtpsession.h
index a144c28ca..1c1c1094b 100644
--- a/gst/rtpmanager/gstrtpsession.h
+++ b/gst/rtpmanager/gstrtpsession.h
@@ -72,6 +72,8 @@ struct _GstRtpSessionClass {
void (*on_bye_timeout) (GstRtpSession *sess, guint32 ssrc);
void (*on_timeout) (GstRtpSession *sess, guint32 ssrc);
void (*on_sender_timeout) (GstRtpSession *sess, guint32 ssrc);
+ void (*on_new_sender_ssrc) (GstRtpSession *sess, guint32 ssrc);
+ void (*on_sender_ssrc_active) (GstRtpSession *sess, guint32 ssrc);
};
GType gst_rtp_session_get_type (void);
diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c
index 879b1deea..71eaaeb89 100644
--- a/gst/rtpmanager/rtpsession.c
+++ b/gst/rtpmanager/rtpsession.c
@@ -51,6 +51,8 @@ enum
SIGNAL_SEND_RTCP,
SIGNAL_SEND_RTCP_FULL,
SIGNAL_ON_RECEIVING_RTCP,
+ SIGNAL_ON_NEW_SENDER_SSRC,
+ SIGNAL_ON_SENDER_SSRC_ACTIVE,
LAST_SIGNAL
};
@@ -362,6 +364,36 @@ rtp_session_class_init (RTPSessionClass * klass)
NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1,
GST_TYPE_BUFFER | G_SIGNAL_TYPE_STATIC_SCOPE);
+ /**
+ * RTPSession::on-new-sender-ssrc:
+ * @session: the object which received the signal
+ * @src: the new sender RTPSource
+ *
+ * Notify of a new sender SSRC that entered @session.
+ *
+ * Since: 1.8
+ */
+ rtp_session_signals[SIGNAL_ON_NEW_SENDER_SSRC] =
+ g_signal_new ("on-new-sender-ssrc", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (RTPSessionClass, on_new_sender_ssrc),
+ NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
+ RTP_TYPE_SOURCE);
+
+ /**
+ * RTPSession::on-sender-ssrc-active:
+ * @session: the object which received the signal
+ * @src: the active sender RTPSource
+ *
+ * Notify of a sender SSRC that is active, i.e., sending RTCP.
+ *
+ * Since: 1.8
+ */
+ rtp_session_signals[SIGNAL_ON_SENDER_SSRC_ACTIVE] =
+ g_signal_new ("on-sender-ssrc-active", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (RTPSessionClass,
+ on_sender_ssrc_active), NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, RTP_TYPE_SOURCE);
+
g_object_class_install_property (gobject_class, PROP_INTERNAL_SSRC,
g_param_spec_uint ("internal-ssrc", "Internal SSRC",
"The internal SSRC used for the session (deprecated)",
@@ -898,6 +930,28 @@ on_sender_timeout (RTPSession * sess, RTPSource * source)
g_object_unref (source);
}
+static void
+on_new_sender_ssrc (RTPSession * sess, RTPSource * source)
+{
+ g_object_ref (source);
+ RTP_SESSION_UNLOCK (sess);
+ g_signal_emit (sess, rtp_session_signals[SIGNAL_ON_NEW_SENDER_SSRC], 0,
+ source);
+ RTP_SESSION_LOCK (sess);
+ g_object_unref (source);
+}
+
+static void
+on_sender_ssrc_active (RTPSession * sess, RTPSource * source)
+{
+ g_object_ref (source);
+ RTP_SESSION_UNLOCK (sess);
+ g_signal_emit (sess, rtp_session_signals[SIGNAL_ON_SENDER_SSRC_ACTIVE], 0,
+ source);
+ RTP_SESSION_LOCK (sess);
+ g_object_unref (source);
+}
+
/**
* rtp_session_new:
*
@@ -2754,6 +2808,10 @@ rtp_session_update_send_caps (RTPSession * sess, GstCaps * caps)
sess->internal_ssrc_from_caps_or_property = TRUE;
if (source) {
rtp_source_update_caps (source, caps);
+
+ if (created)
+ on_new_sender_ssrc (sess, source);
+
g_object_unref (source);
}
@@ -2806,6 +2864,8 @@ rtp_session_send_rtp (RTPSession * sess, gpointer data, gboolean is_list,
goto invalid_packet;
source = obtain_internal_source (sess, pinfo.ssrc, &created, current_time);
+ if (created)
+ on_new_sender_ssrc (sess, source);
prevsender = RTP_SOURCE_IS_SENDER (source);
oldrate = source->bitrate;
@@ -3817,6 +3877,10 @@ rtp_session_on_timeout (RTPSession * sess, GstClockTime current_time,
source = obtain_internal_source (sess, sess->suggested_ssrc, &created,
current_time);
sess->internal_ssrc_set = TRUE;
+
+ if (created)
+ on_new_sender_ssrc (sess, source);
+
g_object_unref (source);
}
@@ -3903,6 +3967,10 @@ done:
sess->callbacks.send_rtcp (sess, source, buffer, output->is_bye,
sess->send_rtcp_user_data);
sess->stats.nacks_sent += data.nacked_seqnums;
+
+ RTP_SESSION_LOCK (sess);
+ on_sender_ssrc_active (sess, source);
+ RTP_SESSION_UNLOCK (sess);
} else {
GST_DEBUG ("freeing packet callback: %p"
" do_not_suppress: %d may_suppress: %d", sess->callbacks.send_rtcp,
diff --git a/gst/rtpmanager/rtpsession.h b/gst/rtpmanager/rtpsession.h
index 5af74b89b..30ce32af6 100644
--- a/gst/rtpmanager/rtpsession.h
+++ b/gst/rtpmanager/rtpsession.h
@@ -309,6 +309,8 @@ struct _RTPSessionClass {
guint sender_ssrc, guint media_ssrc, GstBuffer *fci);
gboolean (*send_rtcp) (RTPSession *sess, GstClockTime max_delay);
void (*on_receiving_rtcp) (RTPSession *sess, GstBuffer *buffer);
+ void (*on_new_sender_ssrc) (RTPSession *sess, RTPSource *source);
+ void (*on_sender_ssrc_active) (RTPSession *sess, RTPSource *source);
};
GType rtp_session_get_type (void);