gst/rtpmanager/gstrtpbin.c: Propagate the do-lost and latency properties to the jitte...
[platform/upstream/gstreamer.git] / gst / rtpmanager / gstrtpbin.c
index 8cfd63c..121e359 100644 (file)
@@ -228,7 +228,7 @@ enum
   LAST_SIGNAL
 };
 
-#define DEFAULT_LATENCY_MS     200
+#define DEFAULT_LATENCY_MS          200
 #define DEFAULT_SDES_CNAME           NULL
 #define DEFAULT_SDES_NAME            NULL
 #define DEFAULT_SDES_EMAIL           NULL
@@ -236,6 +236,7 @@ enum
 #define DEFAULT_SDES_LOCATION        NULL
 #define DEFAULT_SDES_TOOL            NULL
 #define DEFAULT_SDES_NOTE            NULL
+#define DEFAULT_DO_LOST              FALSE
 
 enum
 {
@@ -248,6 +249,7 @@ enum
   PROP_SDES_LOCATION,
   PROP_SDES_TOOL,
   PROP_SDES_NOTE,
+  PROP_DO_LOST,
   PROP_LAST
 };
 
@@ -670,6 +672,27 @@ gst_rtp_bin_clear_pt_map (GstRtpBin * bin)
   GST_RTP_BIN_UNLOCK (bin);
 }
 
+static void
+gst_rtp_bin_propagate_property_to_jitterbuffer (GstRtpBin * bin,
+    const gchar * name, const GValue * value)
+{
+  GSList *sessions, *streams;
+
+  GST_RTP_BIN_LOCK (bin);
+  for (sessions = bin->sessions; sessions; sessions = g_slist_next (sessions)) {
+    GstRtpBinSession *session = (GstRtpBinSession *) sessions->data;
+
+    GST_RTP_SESSION_LOCK (session);
+    for (streams = session->streams; streams; streams = g_slist_next (streams)) {
+      GstRtpBinStream *stream = (GstRtpBinStream *) streams->data;
+
+      g_object_set_property (G_OBJECT (stream->buffer), name, value);
+    }
+    GST_RTP_SESSION_UNLOCK (session);
+  }
+  GST_RTP_BIN_UNLOCK (bin);
+}
+
 /* get a client with the given SDES name. Must be called with RTP_BIN_LOCK */
 static GstRtpBinClient *
 get_client (GstRtpBin * bin, guint8 len, guint8 * data, gboolean * created)
@@ -1018,8 +1041,9 @@ create_stream (GstRtpBinSession * session, guint32 ssrc)
   g_signal_connect (buffer, "request-pt-map",
       (GCallback) pt_map_requested, session);
 
-  /* configure latency */
+  /* configure latency and packet lost */
   g_object_set (buffer, "latency", session->bin->latency, NULL);
+  g_object_set (buffer, "do-lost", session->bin->do_lost, NULL);
 
   gst_bin_add (GST_BIN_CAST (session->bin), buffer);
   gst_element_set_state (buffer, GST_STATE_PLAYING);
@@ -1299,6 +1323,11 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
           "The NOTE to put in SDES messages of this session",
           DEFAULT_SDES_NOTE, G_PARAM_READWRITE));
 
+  g_object_class_install_property (gobject_class, PROP_DO_LOST,
+      g_param_spec_boolean ("do-lost", "Do Lost",
+          "Send an event downstream when a packet is lost", DEFAULT_DO_LOST,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
   gstelement_class->provide_clock =
       GST_DEBUG_FUNCPTR (gst_rtp_bin_provide_clock);
   gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_bin_change_state);
@@ -1321,7 +1350,9 @@ gst_rtp_bin_init (GstRtpBin * rtpbin, GstRtpBinClass * klass)
   rtpbin->priv = GST_RTP_BIN_GET_PRIVATE (rtpbin);
   rtpbin->priv->bin_lock = g_mutex_new ();
   rtpbin->provided_clock = gst_system_clock_obtain ();
+
   rtpbin->latency = DEFAULT_LATENCY_MS;
+  rtpbin->do_lost = DEFAULT_DO_LOST;
 
   /* some default SDES entries */
   str = g_strdup_printf ("%s@%s", g_get_user_name (), g_get_host_name ());
@@ -1451,6 +1482,8 @@ gst_rtp_bin_set_property (GObject * object, guint prop_id,
       GST_RTP_BIN_LOCK (rtpbin);
       rtpbin->latency = g_value_get_uint (value);
       GST_RTP_BIN_UNLOCK (rtpbin);
+      /* propegate the property down to the jitterbuffer */
+      gst_rtp_bin_propagate_property_to_jitterbuffer (rtpbin, "latency", value);
       break;
     case PROP_SDES_CNAME:
       gst_rtp_bin_set_sdes_string (rtpbin, GST_RTCP_SDES_CNAME,
@@ -1480,6 +1513,12 @@ gst_rtp_bin_set_property (GObject * object, guint prop_id,
       gst_rtp_bin_set_sdes_string (rtpbin, GST_RTCP_SDES_NOTE,
           g_value_get_string (value));
       break;
+    case PROP_DO_LOST:
+      GST_RTP_BIN_LOCK (rtpbin);
+      rtpbin->do_lost = g_value_get_boolean (value);
+      GST_RTP_BIN_UNLOCK (rtpbin);
+      gst_rtp_bin_propagate_property_to_jitterbuffer (rtpbin, "do-lost", value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -1528,6 +1567,11 @@ gst_rtp_bin_get_property (GObject * object, guint prop_id,
       g_value_take_string (value, gst_rtp_bin_get_sdes_string (rtpbin,
               GST_RTCP_SDES_NOTE));
       break;
+    case PROP_DO_LOST:
+      GST_RTP_BIN_LOCK (rtpbin);
+      g_value_set_boolean (value, rtpbin->do_lost);
+      GST_RTP_BIN_UNLOCK (rtpbin);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;