rtpbin: add "get-session" signal
authorMiguel París Díaz <mparisdiaz@gmail.com>
Thu, 10 Dec 2015 11:15:52 +0000 (12:15 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 16 Feb 2016 11:39:52 +0000 (13:39 +0200)
This gets the GstRTPSession element, as compared to the RTPSession object
that is returned by get-internal-session.

https://bugzilla.gnome.org/show_bug.cgi?id=759293

gst/rtpmanager/gstrtpbin.c
gst/rtpmanager/gstrtpbin.h

index bc7ec6d..227c7d7 100644 (file)
@@ -249,6 +249,7 @@ enum
   SIGNAL_PAYLOAD_TYPE_CHANGE,
   SIGNAL_CLEAR_PT_MAP,
   SIGNAL_RESET_SYNC,
+  SIGNAL_GET_SESSION,
   SIGNAL_GET_INTERNAL_SESSION,
 
   SIGNAL_ON_NEW_SSRC,
@@ -935,6 +936,23 @@ gst_rtp_bin_clear_pt_map (GstRtpBin * bin)
   gst_rtp_bin_reset_sync (bin);
 }
 
+static GstElement *
+gst_rtp_bin_get_session (GstRtpBin * bin, guint session_id)
+{
+  GstRtpBinSession *session;
+  GstElement *ret = NULL;
+
+  GST_RTP_BIN_LOCK (bin);
+  GST_DEBUG_OBJECT (bin, "retrieving GstRtpSession, index: %d", session_id);
+  session = find_session_by_id (bin, (gint) session_id);
+  if (session) {
+    ret = gst_object_ref (session->session);
+  }
+  GST_RTP_BIN_UNLOCK (bin);
+
+  return ret;
+}
+
 static RTPSession *
 gst_rtp_bin_get_internal_session (GstRtpBin * bin, guint session_id)
 {
@@ -1847,6 +1865,21 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
       0, G_TYPE_NONE);
 
   /**
+   * GstRtpBin::get-session:
+   * @rtpbin: the object which received the signal
+   * @id: the session id
+   *
+   * Request the related GstRtpSession as #GstElement related with session @id.
+   *
+   * Since: 1.8
+   */
+  gst_rtp_bin_signals[SIGNAL_GET_SESSION] =
+      g_signal_new ("get-session", G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (GstRtpBinClass,
+          get_session), NULL, NULL, g_cclosure_marshal_generic,
+      GST_TYPE_ELEMENT, 1, G_TYPE_UINT);
+
+  /**
    * GstRtpBin::get-internal-session:
    * @rtpbin: the object which received the signal
    * @id: the session id
@@ -2311,6 +2344,7 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
 
   klass->clear_pt_map = GST_DEBUG_FUNCPTR (gst_rtp_bin_clear_pt_map);
   klass->reset_sync = GST_DEBUG_FUNCPTR (gst_rtp_bin_reset_sync);
+  klass->get_session = GST_DEBUG_FUNCPTR (gst_rtp_bin_get_session);
   klass->get_internal_session =
       GST_DEBUG_FUNCPTR (gst_rtp_bin_get_internal_session);
   klass->request_rtp_encoder = GST_DEBUG_FUNCPTR (gst_rtp_bin_request_encoder);
index e74a718..01539d2 100644 (file)
@@ -100,6 +100,7 @@ struct _GstRtpBinClass {
   /* action signals */
   void        (*clear_pt_map)         (GstRtpBin *rtpbin);
   void        (*reset_sync)           (GstRtpBin *rtpbin);
+  GstElement* (*get_session)          (GstRtpBin *rtpbin, guint session);
   RTPSession* (*get_internal_session) (GstRtpBin *rtpbin, guint session);
 
   /* session manager signals */