media-factory: add property to configure the buffer-size
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 31 Jan 2011 16:37:02 +0000 (17:37 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 31 Jan 2011 16:37:45 +0000 (17:37 +0100)
Add a property to configure the kernel UDP buffer size.

gst/rtsp-server/rtsp-media-factory.c
gst/rtsp-server/rtsp-media-factory.h

index f4045e8..70e6c25 100644 (file)
@@ -22,6 +22,7 @@
 #define DEFAULT_LAUNCH         NULL
 #define DEFAULT_SHARED         FALSE
 #define DEFAULT_EOS_SHUTDOWN   FALSE
+#define DEFAULT_BUFFER_SIZE    0x800000
 
 enum
 {
@@ -29,6 +30,7 @@ enum
   PROP_LAUNCH,
   PROP_SHARED,
   PROP_EOS_SHUTDOWN,
+  PROP_BUFFER_SIZE,
   PROP_LAST
 };
 
@@ -96,6 +98,11 @@ gst_rtsp_media_factory_class_init (GstRTSPMediaFactoryClass * klass)
           "Send EOS down the pipeline before shutting down",
           DEFAULT_EOS_SHUTDOWN, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  g_object_class_install_property (gobject_class, PROP_BUFFER_SIZE,
+      g_param_spec_uint ("buffer-size", "Buffer Size",
+          "The kernel UDP buffer size to use", 0, G_MAXUINT,
+          DEFAULT_BUFFER_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
   klass->gen_key = default_gen_key;
   klass->get_element = default_get_element;
   klass->construct = default_construct;
@@ -112,6 +119,7 @@ gst_rtsp_media_factory_init (GstRTSPMediaFactory * factory)
   factory->launch = g_strdup (DEFAULT_LAUNCH);
   factory->shared = DEFAULT_SHARED;
   factory->eos_shutdown = DEFAULT_EOS_SHUTDOWN;
+  factory->buffer_size = DEFAULT_BUFFER_SIZE;
 
   factory->lock = g_mutex_new ();
   factory->medias_lock = g_mutex_new ();
@@ -151,6 +159,10 @@ gst_rtsp_media_factory_get_property (GObject * object, guint propid,
       g_value_set_boolean (value,
           gst_rtsp_media_factory_is_eos_shutdown (factory));
       break;
+    case PROP_BUFFER_SIZE:
+      g_value_set_uint (value,
+          gst_rtsp_media_factory_get_buffer_size (factory));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
   }
@@ -173,6 +185,10 @@ gst_rtsp_media_factory_set_property (GObject * object, guint propid,
       gst_rtsp_media_factory_set_eos_shutdown (factory,
           g_value_get_boolean (value));
       break;
+    case PROP_BUFFER_SIZE:
+      gst_rtsp_media_factory_set_buffer_size (factory,
+          g_value_get_uint (value));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
   }
@@ -330,6 +346,46 @@ gst_rtsp_media_factory_is_eos_shutdown (GstRTSPMediaFactory * factory)
 }
 
 /**
+ * gst_rtsp_media_factory_set_buffer_size:
+ * @factory: a #GstRTSPMedia
+ * @size: the new value
+ *
+ * Set the kernel UDP buffer size.
+ */
+void
+gst_rtsp_media_factory_set_buffer_size (GstRTSPMediaFactory * factory,
+    guint size)
+{
+  g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
+
+  GST_RTSP_MEDIA_FACTORY_LOCK (factory);
+  factory->buffer_size = size;
+  GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
+}
+
+/**
+ * gst_rtsp_media_factory_get_buffer_size:
+ * @factory: a #GstRTSPMedia
+ *
+ * Get the kernel UDP buffer size.
+ *
+ * Returns: the kernel UDP buffer size.
+ */
+guint
+gst_rtsp_media_factory_get_buffer_size (GstRTSPMediaFactory * factory)
+{
+  guint result;
+
+  g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), 0);
+
+  GST_RTSP_MEDIA_FACTORY_LOCK (factory);
+  result = factory->buffer_size;
+  GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
+
+  return result;
+}
+
+/**
  * gst_rtsp_media_factory_set_auth:
  * @factory: a #GstRTSPMediaFactory
  * @auth: a #GstRTSPAuth
@@ -659,16 +715,19 @@ static void
 default_configure (GstRTSPMediaFactory * factory, GstRTSPMedia * media)
 {
   gboolean shared, eos_shutdown;
+  guint size;
   GstRTSPAuth *auth;
 
   /* configure the sharedness */
   GST_RTSP_MEDIA_FACTORY_LOCK (factory);
   shared = factory->shared;
   eos_shutdown = factory->eos_shutdown;
+  size = factory->buffer_size;
   GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
 
   gst_rtsp_media_set_shared (media, shared);
   gst_rtsp_media_set_eos_shutdown (media, eos_shutdown);
+  gst_rtsp_media_set_buffer_size (media, size);
 
   if ((auth = gst_rtsp_media_factory_get_auth (factory))) {
     gst_rtsp_media_set_auth (media, auth);
index a06a48d..9e8c23f 100644 (file)
@@ -64,6 +64,7 @@ struct _GstRTSPMediaFactory {
   gboolean      shared;
   gboolean      eos_shutdown;
   GstRTSPAuth  *auth;
+  guint         buffer_size;
 
   GMutex       *medias_lock;
   GHashTable   *medias;
@@ -121,6 +122,9 @@ gboolean              gst_rtsp_media_factory_is_eos_shutdown    (GstRTSPMediaFac
 void                  gst_rtsp_media_factory_set_auth     (GstRTSPMediaFactory *factory, GstRTSPAuth *auth);
 GstRTSPAuth *         gst_rtsp_media_factory_get_auth     (GstRTSPMediaFactory *factory);
 
+void                  gst_rtsp_media_factory_set_buffer_size    (GstRTSPMediaFactory * factory, guint size);
+guint                 gst_rtsp_media_factory_get_buffer_size    (GstRTSPMediaFactory * factory);
+
 
 /* creating the media from the factory and a url */
 GstRTSPMedia *        gst_rtsp_media_factory_construct    (GstRTSPMediaFactory *factory,