[farsight2/master] Add FsTransmitter and FsStreamTransmitter base classes

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


---
 docs/libs/farsight-libs-docs.sgml             |    7 +-
 docs/libs/farsight-libs-sections.txt          |   38 +++-
 docs/libs/farsight-libs.types                 |    4 +
 gst-libs/gst/farsight/Makefile.am             |    6 +-
 gst-libs/gst/farsight/fs-stream-transmitter.c |  304 +++++++++++++++++++++++++
 gst-libs/gst/farsight/fs-stream-transmitter.h |   90 ++++++++
 gst-libs/gst/farsight/fs-transmitter.c        |  252 ++++++++++++++++++++
 gst-libs/gst/farsight/fs-transmitter.h        |   88 +++++++
 8 files changed, 786 insertions(+), 3 deletions(-)
 create mode 100644 gst-libs/gst/farsight/fs-stream-transmitter.c
 create mode 100644 gst-libs/gst/farsight/fs-stream-transmitter.h
 create mode 100644 gst-libs/gst/farsight/fs-transmitter.c
 create mode 100644 gst-libs/gst/farsight/fs-transmitter.h

diff --git a/docs/libs/farsight-libs-docs.sgml b/docs/libs/farsight-libs-docs.sgml
index 8518a9c..fb9f12f 100644
--- a/docs/libs/farsight-libs-docs.sgml
+++ b/docs/libs/farsight-libs-docs.sgml
@@ -13,7 +13,7 @@
     <xi:include href="xml/fs-session.xml"/>
     <xi:include href="xml/fs-candidate.xml"/>
     <xi:include href="xml/fs-codec.xml"/>
-    <xi:include href="xml/fs-marshal.xml"/>
+    <!-- <xi:include href="xml/fs-marshal.xml"/> -->h
   </chapter>
   <chapter>
     <title>Farsight GStreamer Interfaces</title>
@@ -23,4 +23,9 @@
     <title>Farsight GStreamer Base Implementations</title>
     <xi:include href="xml/fs-base-conference.xml"/>
   </chapter>
+  <chapter>
+    <title>Farsight Transmitter objects</title>
+    <xi:include href="xml/fs-transmitter.xml"/>
+    <xi:include href="xml/fs-stream-transmitter.xml"/>
+  </chapter>
 </book>
diff --git a/docs/libs/farsight-libs-sections.txt b/docs/libs/farsight-libs-sections.txt
index e1ab6a2..f39c988 100644
--- a/docs/libs/farsight-libs-sections.txt
+++ b/docs/libs/farsight-libs-sections.txt
@@ -128,8 +128,44 @@ FsBaseConferencePrivate
 </SECTION>
 
 <SECTION>
+<FILE>fs-transmitter</FILE>
+<TITLE>FsTransmitter</TITLE>
+FsTransmitter
+FsTransmitterClass
+fs_transmitter_new_stream_transmitter
+<SUBSECTION Standard>
+FS_IS_TRANSMITTER
+FS_IS_TRANSMITTER_CLASS
+FS_TRANSMITTER
+FS_TRANSMITTER_CLASS
+FS_TRANSMITTER_GET_CLASS
+FS_TYPE_TRANSMITTER
+FsTransmitterPrivate
+GST_IS_BASE_TRANSFORM
+GST_IS_BASE_TRANSFORM_CLASS
+fs_transmitter_get_type
+</SECTION>
+
+<SECTION>
+<FILE>fs-stream-transmitter</FILE>
+<TITLE>FsStreamTransmitter</TITLE>
+FsStreamTransmitter
+FsStreamTransmitterClass
+fs_stream_transmitter_add_remote_candidate
+<SUBSECTION Standard>
+FS_IS_STREAM_TRANSMITTER
+FS_IS_STREAM_TRANSMITTER_CLASS
+FS_STREAM_TRANSMITTER
+FS_STREAM_TRANSMITTER_CLASS
+FS_STREAM_TRANSMITTER_GET_CLASS
+FS_TYPE_STREAM_TRANSMITTER
+FsStreamTransmitterPrivate
+fs_stream_transmitter_get_type
+</SECTION>
+
+
+<SECTION>
 <FILE>fs-marshal</FILE>
 fs_marshal_VOID__BOXED_BOXED
 fs_marshal_VOID__OBJECT_INT_STRING_STRING
 </SECTION>
-
diff --git a/docs/libs/farsight-libs.types b/docs/libs/farsight-libs.types
index ed41014..e924ef2 100644
--- a/docs/libs/farsight-libs.types
+++ b/docs/libs/farsight-libs.types
@@ -10,8 +10,12 @@
 #include "../../gst-libs/gst/farsight/fs-session.h"
 #include "../../gst-libs/gst/farsight/fs-stream.h"
 #include "../../gst-libs/gst/farsight/fs-base-conference.h"
+#include "../../gst-libs/gst/farsight/fs-transmitter.h"
+#include "../../gst-libs/gst/farsight/fs-stream-transmitter.h"
 
 fs_participant_get_type
 fs_session_get_type
 fs_stream_get_type
 fs_base_conference_get_type
+fs_transmitter_get_type
+fs_stream_transmitter_get_type
diff --git a/gst-libs/gst/farsight/Makefile.am b/gst-libs/gst/farsight/Makefile.am
index 1179d3e..eefed8d 100644
--- a/gst-libs/gst/farsight/Makefile.am
+++ b/gst-libs/gst/farsight/Makefile.am
@@ -8,6 +8,8 @@ libgstfarsightinclude_HEADERS = \
 		fs-session.h \
 		fs-stream.h \
 		fs-conference-iface.h \
+		fs-transmitter.h \
+		fs-stream-transmitter.h \
 		fs-marshal.h
 
 lib_LTLIBRARIES = libgstfarsight- at GST_MAJORMINOR@.la
@@ -24,6 +26,8 @@ libgstfarsight_ at GST_MAJORMINOR@_la_SOURCES = \
 		fs-session.c \
 		fs-stream.c \
 		fs-conference-iface.c \
+		fs-transmitter.c \
+		fs-stream-transmitter.c \
 		fs-marshal.c
 
 EXTRA_libgstfarsight_ at GST_MAJORMINOR@_la_SOURCES = fs-marshal.list
@@ -38,7 +42,7 @@ fs-marshal.c: Makefile fs-marshal.list
 		glib-genmarshal --body --prefix=fs_marshal $(srcdir)/fs-marshal.list >> fs-marshal.c.tmp
 		mv fs-marshal.c.tmp fs-marshal.c
 
-libgstfarsight_ at GST_MAJORMINOR@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
+libgstfarsight_ at GST_MAJORMINOR@_la_CFLAGS = $(FS2_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
 libgstfarsight_ at GST_MAJORMINOR@_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS)
 libgstfarsight_ at GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
 
diff --git a/gst-libs/gst/farsight/fs-stream-transmitter.c b/gst-libs/gst/farsight/fs-stream-transmitter.c
new file mode 100644
index 0000000..204eae3
--- /dev/null
+++ b/gst-libs/gst/farsight/fs-stream-transmitter.c
@@ -0,0 +1,304 @@
+/*
+ * Farsight2 - Farsight Stream Transmitter
+ *
+ * Copyright 2007 Collabora Ltd.
+ *  @author: Olivier Crete <olivier.crete at collabora.co.uk>
+ * Copyright 2007 Nokia Corp.
+ *
+ * fs-stream-transmitter.c - A Farsight Stream Transmitter gobject
+ *
+ * This program 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 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/**
+ * SECTION:fs-stream-transmitter
+ * @short_description: A stream transmitter object used to convey per-stream
+ *   information to a transmitter.
+ *
+ * This object is the base implementation of a Farsight Stream Transmitter.
+ * It needs to be derived and implement by a Farsight transmitter.
+ * A Farsight Stream transmitter is used to convery per-stream information
+ * to a transmitter, this is mostly local and remote candidates
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "fs-marshal.h"
+#include "fs-stream-transmitter.h"
+
+#include <gst/gst.h>
+
+/* Signals */
+enum
+{
+  ERROR,
+  NEW_NATIVE_CANDIDATE,
+  NEW_ACTIVE_CANDIDATE_PAIR,
+  NATIVE_CANDIDATES_PREPARED,
+  LAST_SIGNAL
+};
+
+/* props */
+enum
+{
+  PROP_0,
+  PROP_SENDING,
+};
+
+struct _FsStreamTransmitterPrivate
+{
+  gboolean disposed;
+};
+
+#define FS_STREAM_TRANSMITTER_GET_PRIVATE(o)  \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), FS_TYPE_STREAM_TRANSMITTER, \
+                                FsStreamTransmitterPrivate))
+
+static void fs_stream_transmitter_class_init (FsStreamTransmitterClass *klass);
+static void fs_stream_transmitter_init (FsStreamTransmitter *self);
+static void fs_stream_transmitter_dispose (GObject *object);
+static void fs_stream_transmitter_finalize (GObject *object);
+
+static void fs_stream_transmitter_get_property (GObject *object,
+                                                guint prop_id,
+                                                GValue *value,
+                                                GParamSpec *pspec);
+static void fs_stream_transmitter_set_property (GObject *object,
+                                                guint prop_id,
+                                                const GValue *value,
+                                                GParamSpec *pspec);
+
+static GObjectClass *parent_class = NULL;
+static guint signals[LAST_SIGNAL] = { 0 };
+
+GType
+fs_stream_transmitter_get_type (void)
+{
+  static GType type = 0;
+
+  if (type == 0) {
+    static const GTypeInfo info = {
+      sizeof (FsStreamTransmitterClass),
+      NULL,
+      NULL,
+      (GClassInitFunc) fs_stream_transmitter_class_init,
+      NULL,
+      NULL,
+      sizeof (FsStreamTransmitter),
+      0,
+      (GInstanceInitFunc) fs_stream_transmitter_init
+    };
+
+    type = g_type_register_static (G_TYPE_OBJECT,
+        "FsStreamTransmitter", &info, 0);
+  }
+
+  return type;
+}
+
+static void
+fs_stream_transmitter_class_init (FsStreamTransmitterClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  gobject_class = (GObjectClass *) klass;
+  parent_class = g_type_class_peek_parent (klass);
+
+  gobject_class->set_property = fs_stream_transmitter_set_property;
+  gobject_class->get_property = fs_stream_transmitter_get_property;
+
+
+
+  /**
+   * FsStreamTransmitter:sending:
+   *
+   * A network source #GstElement to be used by the #FsSession
+   *
+   */
+  g_object_class_install_property (gobject_class,
+      PROP_SENDING,
+      g_param_spec_boolean ("sending",
+        "Whether to send from this transmitter",
+        "If set to FALSE, the transmitter will stop sending to this person",
+        TRUE,
+        G_PARAM_READWRITE));
+
+  /**
+   * FsStreamTransmitter::error:
+   * @self: #FsStreamTransmitter that emitted the signal
+   * @errorno: The number of the error
+   * @error_msg: Error message to be displayed to user
+   * @debug_msg: Debugging error message
+   *
+   * This signal is emitted in any error condition
+   *
+   */
+  signals[ERROR] = g_signal_new ("error",
+      G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST,
+      0,
+      NULL,
+      NULL,
+      fs_marshal_VOID__OBJECT_INT_STRING_STRING,
+      G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING);
+
+    /**
+   * FsStreamTransmitter::new-active-candidate-pair:
+   * @self: #FsStream that emitted the signal
+   * @native_candidate: #FsCandidate of the native candidate being used
+   * @remote_candidate: #FsCandidate of the remote candidate being used
+   *
+   * This signal is emitted when there is a new active chandidate pair that has
+   * been established. This is specially useful for ICE where the active
+   * candidate pair can change automatically due to network conditions. The user
+   * must not modify the candidates and must copy them if he wants to use them
+   * outside the callback scope.
+   *
+   */
+  signals[NEW_ACTIVE_CANDIDATE_PAIR] = g_signal_new
+    ("new-active-candidate-pair",
+      G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST,
+      0,
+      NULL,
+      NULL,
+      fs_marshal_VOID__BOXED_BOXED,
+      G_TYPE_NONE, 2, FS_TYPE_CANDIDATE, FS_TYPE_CANDIDATE);
+
+ /**
+   * FsStreamTransmitter::new-native-candidate:
+   * @self: #FsStream that emitted the signal
+   * @native_candidate: #FsCandidate of the native candidate
+   *
+   * This signal is emitted when a new native candidate is discovered.
+   *
+   */
+  signals[NEW_NATIVE_CANDIDATE] = g_signal_new
+    ("new-native-candidate",
+      G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST,
+      0,
+      NULL,
+      NULL,
+      g_cclosure_marshal_VOID__BOXED,
+      G_TYPE_NONE, 1, FS_TYPE_CANDIDATE);
+
+ /**
+   * FsStreamTransmitter::native-candidates-prepared:
+   * @self: #FsStream that emitted the signal
+   *
+   * This signal is emitted when all native candidates have been
+   * prepared, an ICE implementation would send its SDP offer or answer.
+   *
+   */
+  signals[NATIVE_CANDIDATES_PREPARED] = g_signal_new
+    ("native-candidates-prepared",
+      G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST,
+      0,
+      NULL,
+      NULL,
+      g_cclosure_marshal_VOID__VOID,
+      G_TYPE_NONE, 0);
+
+
+
+  gobject_class->dispose = fs_stream_transmitter_dispose;
+  gobject_class->finalize = fs_stream_transmitter_finalize;
+
+  g_type_class_add_private (klass, sizeof (FsStreamTransmitterPrivate));
+}
+
+static void
+fs_stream_transmitter_init (FsStreamTransmitter *self)
+{
+  /* member init */
+  self->priv = FS_STREAM_TRANSMITTER_GET_PRIVATE (self);
+  self->priv->disposed = FALSE;
+}
+
+static void
+fs_stream_transmitter_dispose (GObject *object)
+{
+  FsStreamTransmitter *self = FS_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_stream_transmitter_finalize (GObject *object)
+{
+  parent_class->finalize (object);
+}
+
+static void
+fs_stream_transmitter_get_property (GObject *object,
+                                    guint prop_id,
+                                    GValue *value,
+                                    GParamSpec *pspec)
+{
+}
+
+static void
+fs_stream_transmitter_set_property (GObject *object,
+                                    guint prop_id,
+                                    const GValue *value,
+                                    GParamSpec *pspec)
+{
+}
+
+
+/**
+ * fs_stream_transmitter_add_remote_candidate
+ * @streamtransmitter: a #FsStreamTranmitter
+ * @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)
+ */
+
+gboolean
+fs_stream_transmitter_add_remote_candidate (
+    FsStreamTransmitter *streamtransmitter, FsCandidate *candidate,
+    GError **error)
+{
+  FsStreamTransmitterClass *klass =
+    FS_STREAM_TRANSMITTER_GET_CLASS (streamtransmitter);
+
+  *error = NULL;
+
+  if (klass->add_remote_candidate) {
+    return klass->add_remote_candidate (streamtransmitter, candidate, error);
+  } else {
+    g_warning ("add_remote_candidate not defined in class");
+  }
+
+  return FALSE;
+}
+
diff --git a/gst-libs/gst/farsight/fs-stream-transmitter.h b/gst-libs/gst/farsight/fs-stream-transmitter.h
new file mode 100644
index 0000000..d2d572a
--- /dev/null
+++ b/gst-libs/gst/farsight/fs-stream-transmitter.h
@@ -0,0 +1,90 @@
+/*
+ * Farsight2 - Farsight Stream Transmitter
+ *
+ * Copyright 2007 Collabora Ltd.
+ *  @author: Olivier Crete <olivier.crete at collabora.co.uk>
+ * Copyright 2007 Nokia Corp.
+ *
+ * fs-stream-transmitter.h - A Farsight Stream Transmitter (base implementation)
+ *
+ * This program 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 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __FS_STREAM_TRANSMITTER_H__
+#define __FS_STREAM_TRANSMITTER_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gst/farsight/fs-candidate.h>
+
+G_BEGIN_DECLS
+
+/* TYPE MACROS */
+#define FS_TYPE_STREAM_TRANSMITTER \
+  (fs_stream_transmitter_get_type())
+#define FS_STREAM_TRANSMITTER(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), FS_TYPE_STREAM_TRANSMITTER, \
+                              FsStreamTransmitter))
+#define FS_STREAM_TRANSMITTER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), FS_TYPE_STREAM_TRANSMITTER, \
+                           FsStreamTransmitterClass))
+#define FS_IS_STREAM_TRANSMITTER(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), FS_TYPE_STREAM_TRANSMITTER))
+#define FS_IS_STREAM_TRANSMITTER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), FS_TYPE_STREAM_TRANSMITTER))
+#define FS_STREAM_TRANSMITTER_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), FS_TYPE_STREAM_TRANSMITTER, \
+                              FsStreamTransmitterClass))
+
+typedef struct _FsStreamTransmitter FsStreamTransmitter;
+typedef struct _FsStreamTransmitterClass FsStreamTransmitterClass;
+typedef struct _FsStreamTransmitterPrivate FsStreamTransmitterPrivate;
+
+struct _FsStreamTransmitterClass
+{
+  GObjectClass parent_class;
+
+  /*virtual functions */
+  gboolean (*add_remote_candidate) (FsStreamTransmitter *streamtransmitter,
+                                    FsCandidate *candidate, GError *error);
+
+  /*< private >*/
+  gpointer _padding[8];
+};
+
+/**
+ * FsStreamTransmitter:
+ *
+ */
+struct _FsStreamTransmitter
+{
+  GObject parent;
+
+  /*< private >*/
+  FsStreamTransmitterPrivate *priv;
+  gpointer _padding[8];
+};
+
+GType fs_stream_transmitter_get_type (void);
+
+gboolean fs_stream_transmitter_add_remote_candidate (
+    FsStreamTransmitter *streamtransmitter,
+    FsCandidate *candidate, GError **error);
+
+
+G_END_DECLS
+
+#endif /* __FS_STREAM_TRANSMITTER_H__ */
diff --git a/gst-libs/gst/farsight/fs-transmitter.c b/gst-libs/gst/farsight/fs-transmitter.c
new file mode 100644
index 0000000..107fb96
--- /dev/null
+++ b/gst-libs/gst/farsight/fs-transmitter.c
@@ -0,0 +1,252 @@
+/*
+ * Farsight2 - Farsight Transmitter
+ *
+ * Copyright 2007 Collabora Ltd.
+ *  @author: Olivier Crete <olivier.crete at collabora.co.uk>
+ * Copyright 2007 Nokia Corp.
+ *
+ * fs-transmitter.c - A Farsight Transmitter gobject (base implementation)
+ *
+ * This program 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 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/**
+ * SECTION:fs-transmitter
+ * @short_description: A transmitter object linked to a session
+ *
+ * This object is the base implementation of a Farsight Transmitter.
+ * It needs to be derived and implement by a Farsight transmitter. A
+ * Farsight Transmitter provides a GStreamer network sink and source to be used
+ * for the Farsight Session. It creates #FsStreamTransmitter objects which are
+ * used to set the different per-stream properties
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "fs-marshal.h"
+#include "fs-transmitter.h"
+
+#include <gst/gst.h>
+
+/* Signals */
+enum
+{
+  ERROR,
+  LAST_SIGNAL
+};
+
+/* props */
+enum
+{
+  PROP_0,
+  PROP_GST_SINK,
+  PROP_GST_SRC
+};
+
+struct _FsTransmitterPrivate
+{
+  gboolean disposed;
+};
+
+#define FS_TRANSMITTER_GET_PRIVATE(o)  \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), FS_TYPE_TRANSMITTER, FsTransmitterPrivate))
+
+static void fs_transmitter_class_init (FsTransmitterClass *klass);
+static void fs_transmitter_init (FsTransmitter *self);
+static void fs_transmitter_dispose (GObject *object);
+static void fs_transmitter_finalize (GObject *object);
+
+static void fs_transmitter_get_property (GObject *object,
+                                         guint prop_id,
+                                         GValue *value,
+                                         GParamSpec *pspec);
+static void fs_transmitter_set_property (GObject *object,
+                                         guint prop_id,
+                                         const GValue *value,
+                                         GParamSpec *pspec);
+
+static GObjectClass *parent_class = NULL;
+static guint signals[LAST_SIGNAL] = { 0 };
+
+GType
+fs_transmitter_get_type (void)
+{
+  static GType type = 0;
+
+  if (type == 0) {
+    static const GTypeInfo info = {
+      sizeof (FsTransmitterClass),
+      NULL,
+      NULL,
+      (GClassInitFunc) fs_transmitter_class_init,
+      NULL,
+      NULL,
+      sizeof (FsTransmitter),
+      0,
+      (GInstanceInitFunc) fs_transmitter_init
+    };
+
+    type = g_type_register_static (G_TYPE_OBJECT,
+        "FsTransmitter", &info, 0);
+  }
+
+  return type;
+}
+
+static void
+fs_transmitter_class_init (FsTransmitterClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  gobject_class = (GObjectClass *) klass;
+  parent_class = g_type_class_peek_parent (klass);
+
+  gobject_class->set_property = fs_transmitter_set_property;
+  gobject_class->get_property = fs_transmitter_get_property;
+
+
+
+  /**
+   * FsTransmitter:gst-src:
+   *
+   * A network source #GstElement to be used by the #FsSession
+   *
+   */
+  g_object_class_install_property (gobject_class,
+      PROP_GST_SRC,
+      g_param_spec_object ("gst-src",
+        "The network source",
+        "A source GstElement to be used by a FsSession",
+        GST_TYPE_ELEMENT,
+        G_PARAM_READABLE));
+
+  /**
+   * FsTransmitter:gst-sink:
+   *
+   * A network source #GstElement to be used by the #FsSession
+   *
+   */
+  g_object_class_install_property (gobject_class,
+      PROP_GST_SINK,
+      g_param_spec_object ("gst-sink",
+        "The network source",
+        "A source GstElement to be used by a FsSession",
+        GST_TYPE_ELEMENT,
+        G_PARAM_READABLE));
+
+
+
+  /**
+   * FsTransmitter::error:
+   * @self: #FsTransmitter that emitted the signal
+   * @errorno: The number of the error
+   * @error_msg: Error message to be displayed to user
+   * @debug_msg: Debugging error message
+   *
+   * This signal is emitted in any error condition
+   *
+   */
+  signals[ERROR] = g_signal_new ("error",
+      G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST,
+      0,
+      NULL,
+      NULL,
+      fs_marshal_VOID__OBJECT_INT_STRING_STRING,
+      G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING);
+
+
+  gobject_class->dispose = fs_transmitter_dispose;
+  gobject_class->finalize = fs_transmitter_finalize;
+
+  g_type_class_add_private (klass, sizeof (FsTransmitterPrivate));
+}
+
+static void
+fs_transmitter_init (FsTransmitter *self)
+{
+  /* member init */
+  self->priv = FS_TRANSMITTER_GET_PRIVATE (self);
+  self->priv->disposed = FALSE;
+}
+
+static void
+fs_transmitter_dispose (GObject *object)
+{
+  FsTransmitter *self = FS_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_transmitter_finalize (GObject *object)
+{
+  parent_class->finalize (object);
+}
+
+static void
+fs_transmitter_get_property (GObject *object,
+                             guint prop_id,
+                             GValue *value,
+                             GParamSpec *pspec)
+{
+}
+
+static void
+fs_transmitter_set_property (GObject *object,
+                             guint prop_id,
+                             const GValue *value,
+                             GParamSpec *pspec)
+{
+}
+
+
+/**
+ * fs_transmitter_new_stream_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 #FsTransmitter
+ *
+ * Returns: a new #FsStreamTransmitter
+ */
+
+FsStreamTransmitter *
+fs_transmitter_new_stream_transmitter (FsTransmitter *transmitter,
+                                       FsParticipant *participant)
+{
+  FsTransmitterClass *klass = FS_TRANSMITTER_GET_CLASS (transmitter);
+
+  if (klass->new_stream_transmitter) {
+    return klass->new_stream_transmitter (transmitter, participant);
+  } else {
+    g_warning ("new_stream_transmitter not defined in class");
+  }
+
+  return NULL;
+}
diff --git a/gst-libs/gst/farsight/fs-transmitter.h b/gst-libs/gst/farsight/fs-transmitter.h
new file mode 100644
index 0000000..4c524a3
--- /dev/null
+++ b/gst-libs/gst/farsight/fs-transmitter.h
@@ -0,0 +1,88 @@
+/*
+ * Farsight2 - Farsight Transmitter
+ *
+ * Copyright 2007 Collabora Ltd.
+ *  @author: Olivier Crete <olivier.crete at collabora.co.uk>
+ * Copyright 2007 Nokia Corp.
+ *
+ * fs-transmitter.h - A Farsight Transmitter (base implementation)
+ *
+ * This program 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 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __FS_TRANSMITTER_H__
+#define __FS_TRANSMITTER_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gst/farsight/fs-participant.h>
+#include <gst/farsight/fs-stream-transmitter.h>
+
+G_BEGIN_DECLS
+
+/* TYPE MACROS */
+#define FS_TYPE_TRANSMITTER \
+  (fs_transmitter_get_type())
+#define FS_TRANSMITTER(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), FS_TYPE_TRANSMITTER, FsTransmitter))
+#define FS_TRANSMITTER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), FS_TYPE_TRANSMITTER, FsTransmitterClass))
+#define FS_IS_TRANSMITTER(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), FS_TYPE_TRANSMITTER))
+#define FS_IS_TRANSMITTER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), FS_TYPE_TRANSMITTER))
+#define FS_TRANSMITTER_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), FS_TYPE_TRANSMITTER, FsTransmitterClass))
+
+typedef struct _FsTransmitter FsTransmitter;
+typedef struct _FsTransmitterClass FsTransmitterClass;
+typedef struct _FsTransmitterPrivate FsTransmitterPrivate;
+
+struct _FsTransmitterClass
+{
+  GObjectClass parent_class;
+
+  /*virtual functions */
+  FsStreamTransmitter *(*new_stream_transmitter) (FsTransmitter *transmitter,
+                                                  FsParticipant *participant);
+
+  /*< private >*/
+  gpointer _padding[8];
+};
+
+/**
+ * FsTransmitter:
+ *
+ */
+struct _FsTransmitter
+{
+  GObject parent;
+
+  /*< private >*/
+  FsTransmitterPrivate *priv;
+  gpointer _padding[8];
+};
+
+GType fs_transmitter_get_type (void);
+
+FsStreamTransmitter *fs_transmitter_new_stream_transmitter (
+    FsTransmitter *transmitter,
+    FsParticipant *participant);
+
+
+G_END_DECLS
+
+#endif /* __FS_TRANSMITTER_H__ */
-- 
1.5.6.5




More information about the farsight-commits mailing list