[farsight2/master] Add empty implementation of the nice transmitter

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:26:11 PST 2008


---
 transmitters/nice/fs-nice-stream-transmitter.c |  278 ++++++++++++++
 transmitters/nice/fs-nice-stream-transmitter.h |   97 +++++
 transmitters/nice/fs-nice-transmitter.c        |  464 +++++++++++++++++++++++-
 transmitters/nice/fs-nice-transmitter.h        |   89 +++++
 4 files changed, 927 insertions(+), 1 deletions(-)

diff --git a/transmitters/nice/fs-nice-stream-transmitter.c b/transmitters/nice/fs-nice-stream-transmitter.c
index e69de29..e191663 100644
--- a/transmitters/nice/fs-nice-stream-transmitter.c
+++ b/transmitters/nice/fs-nice-stream-transmitter.c
@@ -0,0 +1,278 @@
+/*
+ * Farsight2 - Farsight libnice Stream Transmitter
+ *
+ * Copyright 2007 Collabora Ltd.
+ *  @author: Olivier Crete <olivier.crete at collabora.co.uk>
+ * Copyright 2007 Nokia Corp.
+ *
+ * fs-nice-stream-transmitter.c - A Farsight libnice stream transmitter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+
+/**
+ * SECTION:fs-nice-stream-transmitter
+ * @short_description: A stream transmitter object for ICE using libnice
+ * @see_also: fs-rawudp-stream-transmitter
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "fs-nice-stream-transmitter.h"
+#include "fs-nice-transmitter.h"
+
+#include <gst/farsight/fs-candidate.h>
+#include <gst/farsight/fs-conference-iface.h>
+
+#include <gst/gst.h>
+
+#include <string.h>
+#include <sys/types.h>
+
+GST_DEBUG_CATEGORY_EXTERN (fs_nice_transmitter_debug);
+#define GST_CAT_DEFAULT fs_nice_transmitter_debug
+
+/* Signals */
+enum
+{
+  LAST_SIGNAL
+};
+
+/* props */
+enum
+{
+  PROP_0,
+  PROP_SENDING
+};
+
+struct _FsNiceStreamTransmitterPrivate
+{
+  gboolean disposed;
+
+  /* We don't actually hold a ref to this,
+   * But since our parent FsStream can not exist without its parent
+   * FsSession, we should be safe
+   */
+  FsNiceTransmitter *transmitter;
+
+  gboolean sending;
+};
+
+#define FS_NICE_STREAM_TRANSMITTER_GET_PRIVATE(o)  \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), FS_TYPE_NICE_STREAM_TRANSMITTER, \
+                                FsNiceStreamTransmitterPrivate))
+
+static void fs_nice_stream_transmitter_class_init (FsNiceStreamTransmitterClass *klass);
+static void fs_nice_stream_transmitter_init (FsNiceStreamTransmitter *self);
+static void fs_nice_stream_transmitter_dispose (GObject *object);
+static void fs_nice_stream_transmitter_finalize (GObject *object);
+
+static void fs_nice_stream_transmitter_get_property (GObject *object,
+                                                guint prop_id,
+                                                GValue *value,
+                                                GParamSpec *pspec);
+static void fs_nice_stream_transmitter_set_property (GObject *object,
+                                                guint prop_id,
+                                                const GValue *value,
+                                                GParamSpec *pspec);
+
+static gboolean fs_nice_stream_transmitter_add_remote_candidate (
+    FsStreamTransmitter *streamtransmitter, FsCandidate *candidate,
+    GError **error);
+
+
+static GObjectClass *parent_class = NULL;
+// static guint signals[LAST_SIGNAL] = { 0 };
+
+static GType type = 0;
+
+GType
+fs_nice_stream_transmitter_get_type (void)
+{
+  return type;
+}
+
+GType
+fs_nice_stream_transmitter_register_type (FsPlugin *module)
+{
+  static const GTypeInfo info = {
+    sizeof (FsNiceStreamTransmitterClass),
+    NULL,
+    NULL,
+    (GClassInitFunc) fs_nice_stream_transmitter_class_init,
+    NULL,
+    NULL,
+    sizeof (FsNiceStreamTransmitter),
+    0,
+    (GInstanceInitFunc) fs_nice_stream_transmitter_init
+  };
+
+  type = g_type_module_register_type (G_TYPE_MODULE (module),
+    FS_TYPE_STREAM_TRANSMITTER, "FsNiceStreamTransmitter", &info, 0);
+
+  return type;
+}
+
+static void
+fs_nice_stream_transmitter_class_init (FsNiceStreamTransmitterClass *klass)
+{
+  GObjectClass *gobject_class = (GObjectClass *) klass;
+  FsStreamTransmitterClass *streamtransmitterclass =
+    FS_STREAM_TRANSMITTER_CLASS (klass);
+
+  parent_class = g_type_class_peek_parent (klass);
+
+  gobject_class->set_property = fs_nice_stream_transmitter_set_property;
+  gobject_class->get_property = fs_nice_stream_transmitter_get_property;
+
+  streamtransmitterclass->add_remote_candidate =
+    fs_nice_stream_transmitter_add_remote_candidate;
+
+  g_object_class_override_property (gobject_class, PROP_SENDING, "sending");
+
+  gobject_class->dispose = fs_nice_stream_transmitter_dispose;
+  gobject_class->finalize = fs_nice_stream_transmitter_finalize;
+
+  g_type_class_add_private (klass, sizeof (FsNiceStreamTransmitterPrivate));
+}
+
+static void
+fs_nice_stream_transmitter_init (FsNiceStreamTransmitter *self)
+{
+  /* member init */
+  self->priv = FS_NICE_STREAM_TRANSMITTER_GET_PRIVATE (self);
+  self->priv->disposed = FALSE;
+
+  self->priv->sending = TRUE;
+}
+
+static void
+fs_nice_stream_transmitter_dispose (GObject *object)
+{
+  FsNiceStreamTransmitter *self = FS_NICE_STREAM_TRANSMITTER (object);
+
+  if (self->priv->disposed)
+    /* If dispose did already run, return. */
+    return;
+
+  /* Make sure dispose does not run twice. */
+  self->priv->disposed = TRUE;
+
+  parent_class->dispose (object);
+}
+
+static void
+fs_nice_stream_transmitter_finalize (GObject *object)
+{
+  // FsNiceStreamTransmitter *self = FS_NICE_STREAM_TRANSMITTER (object);
+
+
+  parent_class->finalize (object);
+}
+
+static void
+fs_nice_stream_transmitter_get_property (GObject *object,
+                                           guint prop_id,
+                                           GValue *value,
+                                           GParamSpec *pspec)
+{
+  FsNiceStreamTransmitter *self = FS_NICE_STREAM_TRANSMITTER (object);
+
+  switch (prop_id)
+  {
+    case PROP_SENDING:
+      g_value_set_boolean (value, self->priv->sending);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+fs_nice_stream_transmitter_set_property (GObject *object,
+                                           guint prop_id,
+                                           const GValue *value,
+                                           GParamSpec *pspec)
+{
+  FsNiceStreamTransmitter *self = FS_NICE_STREAM_TRANSMITTER (object);
+
+  switch (prop_id) {
+    case PROP_SENDING:
+      self->priv->sending = g_value_get_boolean (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static gboolean
+fs_nice_stream_transmitter_build (FsNiceStreamTransmitter *self,
+  GError **error)
+{
+
+  return TRUE;
+}
+
+/**
+ * fs_nice_stream_transmitter_add_remote_candidate
+ * @streamtransmitter: a #FsStreamTransmitter
+ * @candidate: a remote #FsCandidate to add
+ * @error: location of a #GError, or NULL if no error occured
+ *
+ * This function is used to add remote candidates to the transmitter
+ *
+ * Returns: TRUE of the candidate could be added, FALSE if it couldnt
+ *   (and the #GError will be set)
+ */
+
+static gboolean
+fs_nice_stream_transmitter_add_remote_candidate (
+    FsStreamTransmitter *streamtransmitter, FsCandidate *candidate,
+    GError **error)
+{
+  return FALSE;
+}
+
+
+FsNiceStreamTransmitter *
+fs_nice_stream_transmitter_newv (FsNiceTransmitter *transmitter,
+  guint n_parameters, GParameter *parameters, GError **error)
+{
+  FsNiceStreamTransmitter *streamtransmitter = NULL;
+
+  streamtransmitter = g_object_newv (FS_TYPE_NICE_STREAM_TRANSMITTER,
+    n_parameters, parameters);
+
+  if (!streamtransmitter) {
+    g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
+      "Could not build the stream transmitter");
+    return NULL;
+  }
+
+  streamtransmitter->priv->transmitter = transmitter;
+
+  if (!fs_nice_stream_transmitter_build (streamtransmitter, error)) {
+    g_object_unref (streamtransmitter);
+    return NULL;
+  }
+
+  return streamtransmitter;
+}
diff --git a/transmitters/nice/fs-nice-stream-transmitter.h b/transmitters/nice/fs-nice-stream-transmitter.h
index e69de29..5bc0ceb 100644
--- a/transmitters/nice/fs-nice-stream-transmitter.h
+++ b/transmitters/nice/fs-nice-stream-transmitter.h
@@ -0,0 +1,97 @@
+/*
+ * Farsight2 - Farsight libnice Stream Transmitter
+ *
+ * Copyright 2007-2008 Collabora Ltd.
+ *  @author: Olivier Crete <olivier.crete at collabora.co.uk>
+ * Copyright 2007-2008 Nokia Corp.
+ *
+ * fs-nice-stream-transmitter.h - A Farsight libnice based stream transmitter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef __FS_NICE_STREAM_TRANSMITTER_H__
+#define __FS_NICE_STREAM_TRANSMITTER_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gst/farsight/fs-stream-transmitter.h>
+#include <gst/farsight/fs-plugin.h>
+#include "fs-nice-transmitter.h"
+
+G_BEGIN_DECLS
+
+/* TYPE MACROS */
+#define FS_TYPE_NICE_STREAM_TRANSMITTER \
+  (fs_nice_stream_transmitter_get_type ())
+#define FS_NICE_STREAM_TRANSMITTER(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), FS_TYPE_NICE_STREAM_TRANSMITTER, \
+                              FsNiceStreamTransmitter))
+#define FS_NICE_STREAM_TRANSMITTER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), FS_TYPE_NICE_STREAM_TRANSMITTER, \
+                           FsNiceStreamTransmitterClass))
+#define FS_IS_NICE_STREAM_TRANSMITTER(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), FS_TYPE_NICE_STREAM_TRANSMITTER))
+#define FS_IS_NICE_STREAM_TRANSMITTER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), FS_TYPE_NICE_STREAM_TRANSMITTER))
+#define FS_NICE_STREAM_TRANSMITTER_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), FS_TYPE_NICE_STREAM_TRANSMITTER, \
+                              FsNiceStreamTransmitterClass))
+#define FS_NICE_STREAM_TRANSMITTER_CAST(obj) ((FsNiceStreamTransmitter *) (obj))
+
+typedef struct _FsNiceStreamTransmitter FsNiceStreamTransmitter;
+typedef struct _FsNiceStreamTransmitterClass FsNiceStreamTransmitterClass;
+typedef struct _FsNiceStreamTransmitterPrivate FsNiceStreamTransmitterPrivate;
+
+/**
+ * FsNiceStreamTransmitterClass:
+ * @parent_class: Our parent
+ *
+ * The Raw UDP stream transmitter class
+ */
+
+struct _FsNiceStreamTransmitterClass
+{
+  FsStreamTransmitterClass parent_class;
+
+  /*virtual functions */
+  /*< private >*/
+};
+
+/**
+ * FsNiceStreamTransmitter:
+ *
+ * All members are private, access them using methods and properties
+ */
+struct _FsNiceStreamTransmitter
+{
+  FsStreamTransmitter parent;
+
+  /*< private >*/
+  FsNiceStreamTransmitterPrivate *priv;
+};
+
+GType fs_nice_stream_transmitter_register_type (FsPlugin *module);
+
+GType fs_nice_stream_transmitter_get_type (void);
+
+FsNiceStreamTransmitter *
+fs_nice_stream_transmitter_newv (FsNiceTransmitter *transmitter,
+  guint n_parameters, GParameter *parameters, GError **error);
+
+G_END_DECLS
+
+#endif /* __FS_NICE_STREAM_TRANSMITTER_H__ */
diff --git a/transmitters/nice/fs-nice-transmitter.c b/transmitters/nice/fs-nice-transmitter.c
index 3de6988..4ca1ba9 100644
--- a/transmitters/nice/fs-nice-transmitter.c
+++ b/transmitters/nice/fs-nice-transmitter.c
@@ -1,3 +1,465 @@
-void fs_init_plugin (void *aa)
+/*
+ * Farsight2 - Farsight libnice Transmitter
+ *
+ * Copyright 2007-2008 Collabora Ltd.
+ *  @author: Olivier Crete <olivier.crete at collabora.co.uk>
+ * Copyright 2007-2008 Nokia Corp.
+ *
+ * fs-nice-transmitter.c - A Farsight libnice transmitter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+/**
+ * SECTION:fs-nice-transmitter
+ * @short_description: A transmitter for ICE using libnice
+ *
+ * The transmitter provides ICE (Interactive Connection Establishment) using
+ * libnice.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "fs-nice-transmitter.h"
+#include "fs-nice-stream-transmitter.h"
+
+#include <gst/farsight/fs-conference-iface.h>
+#include <gst/farsight/fs-plugin.h>
+
+#include <string.h>
+#include <sys/types.h>
+
+GST_DEBUG_CATEGORY (fs_nice_transmitter_debug);
+#define GST_CAT_DEFAULT fs_nice_transmitter_debug
+
+/* Signals */
+enum
 {
+  LAST_SIGNAL
+};
+
+/* props */
+enum
+{
+  PROP_0,
+  PROP_GST_SINK,
+  PROP_GST_SRC,
+  PROP_COMPONENTS
+};
+
+struct _FsNiceTransmitterPrivate
+{
+  /* We hold references to this element */
+  GstElement *gst_sink;
+  GstElement *gst_src;
+
+  /* We don't hold a reference to these elements, they are owned
+     by the bins */
+  /* They are tables of pointers, one per component */
+  GstElement **udpsrc_funnels;
+  GstElement **udpsink_tees;
+
+  gboolean disposed;
+};
+
+#define FS_NICE_TRANSMITTER_GET_PRIVATE(o)  \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), FS_TYPE_NICE_TRANSMITTER, \
+    FsNiceTransmitterPrivate))
+
+static void fs_nice_transmitter_class_init (
+    FsNiceTransmitterClass *klass);
+static void fs_nice_transmitter_init (FsNiceTransmitter *self);
+static void fs_nice_transmitter_constructed (GObject *object);
+static void fs_nice_transmitter_dispose (GObject *object);
+static void fs_nice_transmitter_finalize (GObject *object);
+
+static void fs_nice_transmitter_get_property (GObject *object,
+                                                guint prop_id,
+                                                GValue *value,
+                                                GParamSpec *pspec);
+static void fs_nice_transmitter_set_property (GObject *object,
+                                                guint prop_id,
+                                                const GValue *value,
+                                                GParamSpec *pspec);
+
+static FsStreamTransmitter *fs_nice_transmitter_new_stream_transmitter (
+    FsTransmitter *transmitter, FsParticipant *participant,
+    guint n_parameters, GParameter *parameters, GError **error);
+static GType fs_nice_transmitter_get_stream_transmitter_type (
+    FsTransmitter *transmitter,
+    GError **error);
+
+static GObjectClass *parent_class = NULL;
+//static guint signals[LAST_SIGNAL] = { 0 };
+
+
+/*
+ * Lets register the plugin
+ */
+
+static GType type = 0;
+
+GType
+fs_nice_transmitter_get_type (void)
+{
+  g_assert (type);
+  return type;
+}
+
+static GType
+fs_nice_transmitter_register_type (FsPlugin *module)
+{
+  static const GTypeInfo info = {
+    sizeof (FsNiceTransmitterClass),
+    NULL,
+    NULL,
+    (GClassInitFunc) fs_nice_transmitter_class_init,
+    NULL,
+    NULL,
+    sizeof (FsNiceTransmitter),
+    0,
+    (GInstanceInitFunc) fs_nice_transmitter_init
+  };
+
+  if (fs_nice_transmitter_debug == NULL)
+    GST_DEBUG_CATEGORY_INIT (fs_nice_transmitter_debug,
+        "fsnicetransmitter", 0,
+        "Farsight libnice transmitter");
+
+  fs_nice_stream_transmitter_register_type (module);
+
+  type = g_type_module_register_type (G_TYPE_MODULE (module),
+    FS_TYPE_TRANSMITTER, "FsNiceTransmitter", &info, 0);
+
+  return type;
+}
+
+static void
+fs_nice_transmitter_unload (FsPlugin *plugin)
+{
+  if (fs_nice_transmitter_debug)
+  {
+    gst_debug_category_free (fs_nice_transmitter_debug);
+    fs_nice_transmitter_debug = NULL;
+  }
+}
+
+FS_INIT_PLUGIN (fs_nice_transmitter_register_type,
+    fs_nice_transmitter_unload)
+
+static void
+fs_nice_transmitter_class_init (FsNiceTransmitterClass *klass)
+{
+  GObjectClass *gobject_class = (GObjectClass *) klass;
+  FsTransmitterClass *transmitter_class = FS_TRANSMITTER_CLASS (klass);
+
+  parent_class = g_type_class_peek_parent (klass);
+
+  gobject_class->set_property = fs_nice_transmitter_set_property;
+  gobject_class->get_property = fs_nice_transmitter_get_property;
+
+  gobject_class->constructed = fs_nice_transmitter_constructed;
+
+  g_object_class_override_property (gobject_class, PROP_GST_SRC, "gst-src");
+  g_object_class_override_property (gobject_class, PROP_GST_SINK, "gst-sink");
+  g_object_class_override_property (gobject_class, PROP_COMPONENTS,
+    "components");
+
+  transmitter_class->new_stream_transmitter =
+    fs_nice_transmitter_new_stream_transmitter;
+  transmitter_class->get_stream_transmitter_type =
+    fs_nice_transmitter_get_stream_transmitter_type;
+
+  gobject_class->dispose = fs_nice_transmitter_dispose;
+  gobject_class->finalize = fs_nice_transmitter_finalize;
+
+  g_type_class_add_private (klass, sizeof (FsNiceTransmitterPrivate));
+}
+
+static void
+fs_nice_transmitter_init (FsNiceTransmitter *self)
+{
+
+  /* member init */
+  self->priv = FS_NICE_TRANSMITTER_GET_PRIVATE (self);
+  self->priv->disposed = FALSE;
+
+  self->components = 2;
+}
+
+static void
+fs_nice_transmitter_constructed (GObject *object)
+{
+  FsNiceTransmitter *self = FS_NICE_TRANSMITTER_CAST (object);
+  FsTransmitter *trans = FS_TRANSMITTER_CAST (self);
+  GstPad *pad = NULL, *pad2 = NULL;
+  GstPad *ghostpad = NULL;
+  gchar *padname;
+  GstPadLinkReturn ret;
+  int c; /* component_id */
+
+
+  /* We waste one space in order to have the index be the component_id */
+  self->priv->udpsrc_funnels = g_new0 (GstElement *, self->components+1);
+  self->priv->udpsink_tees = g_new0 (GstElement *, self->components+1);
+
+  /* First we need the src elemnet */
+
+  self->priv->gst_src = gst_bin_new (NULL);
+
+  if (!self->priv->gst_src) {
+    trans->construction_error = g_error_new (FS_ERROR,
+      FS_ERROR_CONSTRUCTION,
+      "Could not build the transmitter src bin");
+    return;
+  }
+
+  gst_object_ref (self->priv->gst_src);
+
+
+  /* Second, we do the sink element */
+
+  self->priv->gst_sink = gst_bin_new (NULL);
+
+  if (!self->priv->gst_sink) {
+    trans->construction_error = g_error_new (FS_ERROR,
+      FS_ERROR_CONSTRUCTION,
+      "Could not build the transmitter sink bin");
+    return;
+  }
+
+  g_object_set (G_OBJECT (self->priv->gst_sink),
+      "async-handling", TRUE,
+      NULL);
+
+  gst_object_ref (self->priv->gst_sink);
+
+  for (c = 1; c <= self->components; c++) {
+    GstElement *fakesink = NULL;
+
+    /* Lets create the RTP source funnel */
+
+    self->priv->udpsrc_funnels[c] = gst_element_factory_make ("fsfunnel", NULL);
+
+    if (!self->priv->udpsrc_funnels[c]) {
+      trans->construction_error = g_error_new (FS_ERROR,
+        FS_ERROR_CONSTRUCTION,
+        "Could not make the fsfunnel element");
+      return;
+    }
+
+    if (!gst_bin_add (GST_BIN (self->priv->gst_src),
+        self->priv->udpsrc_funnels[c])) {
+      trans->construction_error = g_error_new (FS_ERROR,
+        FS_ERROR_CONSTRUCTION,
+        "Could not add the fsfunnel element to the transmitter src bin");
+    }
+
+    pad = gst_element_get_static_pad (self->priv->udpsrc_funnels[c], "src");
+    padname = g_strdup_printf ("src%d", c);
+    ghostpad = gst_ghost_pad_new (padname, pad);
+    g_free (padname);
+    gst_object_unref (pad);
+
+    gst_pad_set_active (ghostpad, TRUE);
+    gst_element_add_pad (self->priv->gst_src, ghostpad);
+
+
+    /* Lets create the RTP sink tee */
+
+    self->priv->udpsink_tees[c] = gst_element_factory_make ("tee", NULL);
+
+    if (!self->priv->udpsink_tees[c]) {
+      trans->construction_error = g_error_new (FS_ERROR,
+        FS_ERROR_CONSTRUCTION,
+        "Could not make the tee element");
+      return;
+    }
+
+    if (!gst_bin_add (GST_BIN (self->priv->gst_sink),
+        self->priv->udpsink_tees[c])) {
+      trans->construction_error = g_error_new (FS_ERROR,
+        FS_ERROR_CONSTRUCTION,
+        "Could not add the tee element to the transmitter sink bin");
+    }
+
+    pad = gst_element_get_static_pad (self->priv->udpsink_tees[c], "sink");
+    padname = g_strdup_printf ("sink%d", c);
+    ghostpad = gst_ghost_pad_new (padname, pad);
+    g_free (padname);
+    gst_object_unref (pad);
+
+    gst_pad_set_active (ghostpad, TRUE);
+    gst_element_add_pad (self->priv->gst_sink, ghostpad);
+
+    fakesink = gst_element_factory_make ("fakesink", NULL);
+
+    if (!fakesink) {
+      trans->construction_error = g_error_new (FS_ERROR,
+        FS_ERROR_CONSTRUCTION,
+        "Could not make the fakesink element");
+      return;
+    }
+
+    if (!gst_bin_add (GST_BIN (self->priv->gst_sink), fakesink))
+    {
+      gst_object_unref (fakesink);
+      trans->construction_error = g_error_new (FS_ERROR,
+          FS_ERROR_CONSTRUCTION,
+          "Could not add the fakesink element to the transmitter sink bin");
+      return;
+    }
+
+    g_object_set (fakesink,
+        "async", FALSE,
+        "sync" , FALSE,
+        NULL);
+
+    pad = gst_element_get_request_pad (self->priv->udpsink_tees[c], "src%d");
+    pad2 = gst_element_get_static_pad (fakesink, "sink");
+
+    ret = gst_pad_link (pad, pad2);
+
+    gst_object_unref (pad2);
+    gst_object_unref (pad);
+
+    if (GST_PAD_LINK_FAILED(ret)) {
+      trans->construction_error = g_error_new (FS_ERROR,
+          FS_ERROR_CONSTRUCTION,
+          "Could not link the tee to the fakesink");
+      return;
+    }
+  }
+
+  GST_CALL_PARENT (G_OBJECT_CLASS, constructed, (object));
+}
+
+static void
+fs_nice_transmitter_dispose (GObject *object)
+{
+  FsNiceTransmitter *self = FS_NICE_TRANSMITTER (object);
+
+  if (self->priv->disposed) {
+    /* If dispose did already run, return. */
+    return;
+  }
+
+  if (self->priv->gst_src) {
+    gst_object_unref (self->priv->gst_src);
+    self->priv->gst_src = NULL;
+  }
+
+  if (self->priv->gst_sink) {
+    gst_object_unref (self->priv->gst_sink);
+    self->priv->gst_sink = NULL;
+  }
+
+  /* Make sure dispose does not run twice. */
+  self->priv->disposed = TRUE;
+
+  parent_class->dispose (object);
+}
+
+static void
+fs_nice_transmitter_finalize (GObject *object)
+{
+  FsNiceTransmitter *self = FS_NICE_TRANSMITTER (object);
+
+  if (self->priv->udpsrc_funnels) {
+    g_free (self->priv->udpsrc_funnels);
+    self->priv->udpsrc_funnels = NULL;
+  }
+
+  if (self->priv->udpsink_tees) {
+    g_free (self->priv->udpsink_tees);
+    self->priv->udpsink_tees = NULL;
+  }
+
+  parent_class->finalize (object);
+}
+
+static void
+fs_nice_transmitter_get_property (GObject *object,
+                             guint prop_id,
+                             GValue *value,
+                             GParamSpec *pspec)
+{
+  FsNiceTransmitter *self = FS_NICE_TRANSMITTER (object);
+
+  switch (prop_id) {
+    case PROP_GST_SINK:
+      g_value_set_object (value, self->priv->gst_sink);
+      break;
+    case PROP_GST_SRC:
+      g_value_set_object (value, self->priv->gst_src);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+fs_nice_transmitter_set_property (GObject *object,
+                                    guint prop_id,
+                                    const GValue *value,
+                                    GParamSpec *pspec)
+{
+  FsNiceTransmitter *self = FS_NICE_TRANSMITTER (object);
+
+  switch (prop_id) {
+    case PROP_COMPONENTS:
+      self->components = g_value_get_uint (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+
+/**
+ * fs_nice_transmitter_new_stream_nice_transmitter:
+ * @transmitter: a #FsTranmitter
+ * @participant: the #FsParticipant for which the #FsStream using this
+ * new #FsStreamTransmitter is created
+ *
+ * This function will create a new #FsStreamTransmitter element for a
+ * specific participant for this #FsNiceTransmitter
+ *
+ * Returns: a new #FsStreamTransmitter
+ */
+
+static FsStreamTransmitter *
+fs_nice_transmitter_new_stream_transmitter (FsTransmitter *transmitter,
+  FsParticipant *participant, guint n_parameters, GParameter *parameters,
+  GError **error)
+{
+  FsNiceTransmitter *self = FS_NICE_TRANSMITTER (transmitter);
+
+  return FS_STREAM_TRANSMITTER (fs_nice_stream_transmitter_newv (
+        self, n_parameters, parameters, error));
+}
+
+static GType
+fs_nice_transmitter_get_stream_transmitter_type (
+    FsTransmitter *transmitter,
+    GError **error)
+{
+  return FS_TYPE_NICE_STREAM_TRANSMITTER;
 }
diff --git a/transmitters/nice/fs-nice-transmitter.h b/transmitters/nice/fs-nice-transmitter.h
index e69de29..8d8ee05 100644
--- a/transmitters/nice/fs-nice-transmitter.h
+++ b/transmitters/nice/fs-nice-transmitter.h
@@ -0,0 +1,89 @@
+/*
+ * Farsight2 - Farsight libnice Transmitter
+ *
+ * Copyright 2007-2008 Collabora Ltd.
+ *  @author: Olivier Crete <olivier.crete at collabora.co.uk>
+ * Copyright 2007-2008 Nokia Corp.
+ *
+ * fs-nice-transmitter.h - A Farsight libnice transmitter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef __FS_NICE_TRANSMITTER_H__
+#define __FS_NICE_TRANSMITTER_H__
+
+#include <gst/farsight/fs-transmitter.h>
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+/* TYPE MACROS */
+#define FS_TYPE_NICE_TRANSMITTER \
+  (fs_nice_transmitter_get_type ())
+#define FS_NICE_TRANSMITTER(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), FS_TYPE_NICE_TRANSMITTER, \
+    FsNiceTransmitter))
+#define FS_NICE_TRANSMITTER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), FS_TYPE_NICE_TRANSMITTER, \
+    FsNiceTransmitterClass))
+#define FS_IS_NICE_TRANSMITTER(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), FS_TYPE_NICE_TRANSMITTER))
+#define FS_IS_NICE_TRANSMITTER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), FS_TYPE_NICE_TRANSMITTER))
+#define FS_NICE_TRANSMITTER_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), FS_TYPE_NICE_TRANSMITTER, \
+    FsNiceTransmitterClass))
+#define FS_NICE_TRANSMITTER_CAST(obj) ((FsNiceTransmitter *) (obj))
+
+typedef struct _FsNiceTransmitter FsNiceTransmitter;
+typedef struct _FsNiceTransmitterClass FsNiceTransmitterClass;
+typedef struct _FsNiceTransmitterPrivate FsNiceTransmitterPrivate;
+
+/**
+ * FsNiceTransmitterClass:
+ * @parent_class: Our parent
+ *
+ * The Nice UDP transmitter class
+ */
+
+struct _FsNiceTransmitterClass
+{
+  FsTransmitterClass parent_class;
+};
+
+/**
+ * FsNiceTransmitter:
+ *
+ * All members are private, access them using methods and properties
+ */
+struct _FsNiceTransmitter
+{
+  FsTransmitter parent;
+
+  /* The number of components (READONLY)*/
+  gint components;
+
+  /*< private >*/
+  FsNiceTransmitterPrivate *priv;
+};
+
+
+GType fs_nice_transmitter_get_type (void);
+
+G_END_DECLS
+
+#endif /* __FS_NICE_TRANSMITTER_H__ */
-- 
1.5.6.5




More information about the farsight-commits mailing list