Add media factory to map urls to media pipeline objects.
authorWim Taymans <wim.taymans@collabora.co.uk>
Tue, 20 Jan 2009 18:44:45 +0000 (19:44 +0100)
committerWim Taymans <wim@wtay.(none)>
Tue, 20 Jan 2009 18:44:45 +0000 (19:44 +0100)
gst/rtsp-server/rtsp-media-factory.c [new file with mode: 0644]
gst/rtsp-server/rtsp-media-factory.h [new file with mode: 0644]

diff --git a/gst/rtsp-server/rtsp-media-factory.c b/gst/rtsp-server/rtsp-media-factory.c
new file mode 100644 (file)
index 0000000..d402bad
--- /dev/null
@@ -0,0 +1,97 @@
+/* GStreamer
+ * Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "rtsp-media-factory.h"
+
+G_DEFINE_TYPE (GstRTSPMediaFactory, gst_rtsp_media_factory, G_TYPE_OBJECT);
+
+static void gst_rtsp_media_factory_finalize (GObject * obj);
+
+static GstRTSPMedia * create_media (GstRTSPMediaFactory *factory, const gchar *url);
+
+static void
+gst_rtsp_media_factory_class_init (GstRTSPMediaFactoryClass * klass)
+{
+  GObjectClass *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize = gst_rtsp_media_factory_finalize;
+
+  klass->create_media = create_media;
+}
+
+static void
+gst_rtsp_media_factory_init (GstRTSPMediaFactory * factory)
+{
+}
+
+static void
+gst_rtsp_media_factory_finalize (GObject * obj)
+{
+  G_OBJECT_CLASS (gst_rtsp_media_factory_parent_class)->finalize (obj);
+}
+
+GstRTSPMediaFactory *
+gst_rtsp_media_factory_new (void)
+{
+  GstRTSPMediaFactory *result;
+
+  result = g_object_new (GST_TYPE_RTSP_MEDIA_FACTORY, NULL);
+
+  return result;
+}
+
+static GstRTSPMedia *
+create_media (GstRTSPMediaFactory *factory, const gchar *url)
+{
+  GstRTSPMedia *result;
+
+  result = gst_rtsp_media_new (url);
+
+  return result;
+}
+
+GstRTSPMedia *
+gst_rtsp_media_factory_create (GstRTSPMediaFactory *factory, const gchar *url)
+{
+  GstRTSPMedia *result = NULL;
+  GstRTSPMediaFactoryClass *klass;
+
+  klass = GST_RTSP_MEDIA_FACTORY_GET_CLASS (factory);
+
+  if (klass->create_media)
+    result = klass->create_media (factory, url);
+
+  return result;
+}
+
+void
+gst_rtsp_media_factory_add (GstRTSPMediaFactory *factory, const gchar *path,
+    GType type)
+{
+  g_warning ("gst_rtsp_media_factory_add: not implemented");
+}
+void
+gst_rtsp_media_factory_remove (GstRTSPMediaFactory *factory, const gchar *path,
+    GType type)
+{
+  g_warning ("gst_rtsp_media_factory_remove: not implemented");
+}
+
diff --git a/gst/rtsp-server/rtsp-media-factory.h b/gst/rtsp-server/rtsp-media-factory.h
new file mode 100644 (file)
index 0000000..1399649
--- /dev/null
@@ -0,0 +1,75 @@
+/* GStreamer
+ * Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gst/gst.h>
+
+#include <gst/rtsp/gstrtspurl.h>
+
+#include "rtsp-media.h"
+
+#ifndef __GST_RTSP_MEDIA_FACTORY_H__
+#define __GST_RTSP_MEDIA_FACTORY_H__
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_RTSP_MEDIA_FACTORY              (gst_rtsp_media_get_type ())
+#define GST_IS_RTSP_MEDIA_FACTORY(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_MEDIA_FACTORY))
+#define GST_IS_RTSP_MEDIA_FACTORY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_MEDIA_FACTORY))
+#define GST_RTSP_MEDIA_FACTORY_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_MEDIA_FACTORY, GstRTSPMediaFactoryClass))
+#define GST_RTSP_MEDIA_FACTORY(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_MEDIA_FACTORY, GstRTSPMediaFactory))
+#define GST_RTSP_MEDIA_FACTORY_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_MEDIA_FACTORY, GstRTSPMediaFactoryClass))
+#define GST_RTSP_MEDIA_FACTORY_CAST(obj)         ((GstRTSPMediaFactory*)(obj))
+#define GST_RTSP_MEDIA_FACTORY_CLASS_CAST(klass) ((GstRTSPMediaFactoryClass*)(klass))
+
+typedef struct _GstRTSPMediaFactory GstRTSPMediaFactory;
+typedef struct _GstRTSPMediaFactoryClass GstRTSPMediaFactoryClass;
+
+/**
+ * GstRTSPMediaFactory:
+ *
+ * Creates a #GstRTSPMedia object for a given url.
+ */
+struct _GstRTSPMediaFactory {
+  GObject       parent;
+};
+
+struct _GstRTSPMediaFactoryClass {
+  GObjectClass  parent_class;
+
+  GstRTSPMedia * (*create_media)  (GstRTSPMediaFactory *factory, const gchar *url);
+};
+
+GType                 gst_rtsp_media_factory_get_type     (void);
+
+/* creating a factory */
+GstRTSPMediaFactory * gst_rtsp_media_factory_new          (void);
+
+/* creating a media */
+GstRTSPMedia *        gst_rtsp_media_factory_create       (GstRTSPMediaFactory *factory, const gchar *url);
+
+
+/* managing media GTypes to a path */
+void                  gst_rtsp_media_factory_add          (GstRTSPMediaFactory *factory, const gchar *path,
+                                                           GType type);
+void                  gst_rtsp_media_factory_remove       (GstRTSPMediaFactory *factory, const gchar *path,
+                                                           GType type);
+
+G_END_DECLS
+
+#endif /* __GST_RTSP_MEDIA_FACTORY_H__ */