directory tree based gst-rtsp-server app

Gregor Boirie gregor.boirie at parrot.com
Thu Feb 12 10:03:59 PST 2015


On Thu, Feb 12, 2015 at 06:18:16PM +0100, Wim Taymans wrote:
>    1)  gst_rtsp_mount_points_remove_factory() should be changed so that all
>    paths
>    matching with gst_rtsp_mount_points_match() are deleted.
ok.

Would a separate gst_rtsp_mount_points_remove_factory_byprefix() be safer to
avoid breaking existing clients (whatever the name is) ?

Although I would prefer relying upon gst_rtsp_mount_points_match(), it returns a
factory which makes it unsuitable to remove by path.

By the way, should I open a new issue on bugzilla for patch submission (sorry,
I'm completly new to gstreamer and "SubmittingPatches" wiki page is empty) ?

Anyway, here is a proposal for an alternate function (which probably needs some
more comments for data_item_compare_prefix):

diff --git a/gst/rtsp-server/rtsp-mount-points.c b/gst/rtsp-server/rtsp-mount-points.c
index c6a8c06..90ca227 100644
--- a/gst/rtsp-server/rtsp-mount-points.c
+++ b/gst/rtsp-server/rtsp-mount-points.c
@@ -368,3 +369,67 @@ gst_rtsp_mount_points_remove_factory (GstRTSPMountPoints * mounts,
   }
   g_mutex_unlock (&priv->lock);
 }
+
+static gint
+data_item_compare_prefix (gconstpointer a, gconstpointer b, gpointer user_data)
+{
+  const DataItem *item1 = a, *item2 = b;
+  gint res;
+
+  res = g_strcmp0 (item1->path, item2->path);
+  if (! res)
+    res = 1;
+
+  return res;
+}
+
+/**
+ * gst_rtsp_mount_points_remove_factory_byprefix:
+ * @mounts: a #GstRTSPMountPoints
+ * @prefix: a mount point prefix
+ *
+ * Remove all #GstRTSPMediaFactory associated with path begining
+ * with @prefix in @mounts.
+ */
+void
+gst_rtsp_mount_points_remove_factory_byprefix (GstRTSPMountPoints * mounts,
+    const gchar * prefix)
+{
+  GstRTSPMountPointsPrivate *priv;
+  DataItem item;
+  GSequenceIter *iter, *first;
+
+  g_return_if_fail (GST_IS_RTSP_MOUNT_POINTS (mounts));
+  g_return_if_fail (prefix != NULL);
+
+  priv = mounts->priv;
+
+  item.path = (gchar *) prefix;
+
+  GST_INFO ("starting to remove media factories for prefix %s", prefix);
+
+  g_mutex_lock (&priv->lock);
+  if (priv->dirty) {
+    g_sequence_sort (priv->mounts, data_item_compare, mounts);
+    priv->dirty = FALSE;
+  }
+
+  iter = g_sequence_search (priv->mounts, &item, data_item_compare_prefix,
+            mounts);
+  first = iter;
+  while (! g_sequence_iter_is_end (iter)) {
+    const gchar * const path = ((DataItem *) g_sequence_get (iter))->path;
+
+    if (! g_str_has_prefix (path, prefix))
+      break;
+
+    GST_INFO ("removing media factory for path %s", path);
+    iter = g_sequence_iter_next (iter);
+  }
+
+  if (g_sequence_iter_compare (first, iter) < 0) {
+    g_sequence_remove_range (first, iter);
+    priv->dirty = TRUE;
+  }
+  g_mutex_unlock (&priv->lock);
+}
diff --git a/gst/rtsp-server/rtsp-mount-points.h b/gst/rtsp-server/rtsp-mount-points.h
index ed13d59..9c2a5c6 100644
--- a/gst/rtsp-server/rtsp-mount-points.h
+++ b/gst/rtsp-server/rtsp-mount-points.h
@@ -85,6 +85,8 @@ void                  gst_rtsp_mount_points_add_factory    (GstRTSPMountPoints *
                                                             GstRTSPMediaFactory *factory);
 void                  gst_rtsp_mount_points_remove_factory (GstRTSPMountPoints *mounts,
                                                             const gchar *path);
+void                  gst_rtsp_mount_points_remove_factory_byprefix (GstRTSPMountPoints * mounts,
+                                                                     const gchar * prefix);
 
 G_END_DECLS
 
>    2) gst_rtsp_mount_points_add_factory() takes ownership of the object. It
>    is freed when the object is removed from the GSequence. If you need to
>    access the factory after _add_factory() you will need to take an
>    additional ref before calling add_factory(). This is done to make the most
>    common case easier to write in C.
Ok.

Many thanks for lightning answers.
Greg.


More information about the gstreamer-devel mailing list