[farsight2/master] Implement more of the base class
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:21:29 PST 2008
---
gst/fsrtpconference/fs-rtp-special-codec.c | 121 ++++++++++++++++++++++++++-
gst/fsrtpconference/fs-rtp-special-codec.h | 12 +++-
2 files changed, 126 insertions(+), 7 deletions(-)
diff --git a/gst/fsrtpconference/fs-rtp-special-codec.c b/gst/fsrtpconference/fs-rtp-special-codec.c
index 97cc50d..f0cc5b6 100644
--- a/gst/fsrtpconference/fs-rtp-special-codec.c
+++ b/gst/fsrtpconference/fs-rtp-special-codec.c
@@ -59,6 +59,14 @@ G_DEFINE_ABSTRACT_TYPE(FsRtpSpecialCodec, fs_rtp_special_codec, G_TYPE_OBJECT);
static void fs_rtp_special_codec_dispose (GObject *object);
+static FsRtpSpecialCodec *
+fs_rtp_special_codec_new (FsRtpSpecialCodecClass *klass,
+ GList *negotiated_codecs,
+ GError **error);
+static gboolean
+fs_rtp_special_codec_update (FsRtpSpecialCodec *codec,
+ GList *negotiated_codecs);
+
static void
fs_rtp_special_codec_class_init (FsRtpSpecialCodecClass *klass)
{
@@ -96,15 +104,25 @@ fs_rtp_special_codec_dispose (GObject *object)
static GList*
-fs_rtp_special_codec_class_add_blueprint (FsRtpSpecialCodecClass *class,
+fs_rtp_special_codec_class_add_blueprint (FsRtpSpecialCodecClass *klass,
GList *blueprints)
{
- if (class->add_blueprint)
- return class->add_blueprint (blueprints);
+ if (klass->add_blueprint)
+ return klass->add_blueprint (klass, blueprints);
return blueprints;
}
+static gboolean
+fs_rtp_special_codec_class_want_codec (FsRtpSpecialCodecClass *klass,
+ GList *negotiated_codecs)
+{
+ if (klass->want_codec)
+ return klass->want_codec (klass, negotiated_codecs);
+
+ return FALSE;
+}
+
GList *
fs_rtp_special_codecs_add_blueprints (GList *blueprints)
{
@@ -114,9 +132,102 @@ fs_rtp_special_codecs_add_blueprints (GList *blueprints)
item;
item = g_list_next (item))
{
- FsRtpSpecialCodecClass *class = item->data;
- blueprints = fs_rtp_special_codecs_add_blueprint (class, blueprints);
+ FsRtpSpecialCodecClass *klass = item->data;
+ blueprints = fs_rtp_special_codec_class_add_blueprint (klass, blueprints);
}
return blueprints;
}
+
+/**
+ * fs_rtp_special_codecs_update:
+ * @current_extra_codecs: The #GList returned by previous calls to this function
+ * @negotiated_codecs: A #GList of current negotiated #FsCodec
+ * @error: NULL or the local of a #GError
+ *
+ * This function checks which extra codecs are currently being used and
+ * which should be used according to currently negotiated codecs. It then
+ * creates, destroys or modifies the list accordingly
+ *
+ * Returns: A #GList to be passed to other functions in this class
+ */
+
+GList *
+fs_rtp_special_codecs_update (
+ GList *current_extra_codecs,
+ GList *negotiated_codecs,
+ GError **error)
+{
+ GList *klass_item = NULL;
+
+ for (klass_item = g_list_first (classes);
+ klass_item;
+ klass_item = g_list_next (klass_item))
+ {
+ FsRtpSpecialCodecClass *klass = klass_item->data;
+ GList *obj_item;
+ FsRtpSpecialCodec *obj = NULL;
+
+ /* Check if we already have an object for this type */
+ for (obj_item = g_list_first (current_extra_codecs);
+ obj_item;
+ obj_item = g_list_next (obj_item))
+ {
+ obj = obj_item->data;
+ if (G_OBJECT_TYPE(obj) == G_OBJECT_CLASS_TYPE(klass))
+ break;
+ }
+
+ if (obj_item)
+ {
+ if (fs_rtp_special_codec_class_want_codec (klass, negotiated_codecs))
+ {
+ if (!fs_rtp_special_codec_update (obj, negotiated_codecs))
+ {
+ current_extra_codecs = g_list_remove (current_extra_codecs, obj);
+ g_object_unref (obj);
+ obj = fs_rtp_special_codec_new (klass, negotiated_codecs, error);
+ if (!obj)
+ goto error;
+ current_extra_codecs = g_list_prepend (current_extra_codecs, obj);
+ }
+ }
+ else
+ {
+ current_extra_codecs = g_list_remove (current_extra_codecs, obj);
+ g_object_unref (obj);
+ }
+ }
+ else
+ {
+ if (fs_rtp_special_codec_class_want_codec (klass, negotiated_codecs))
+ {
+ obj = fs_rtp_special_codec_new (klass, negotiated_codecs, error);
+ if (!obj)
+ goto error;
+ current_extra_codecs = g_list_prepend (current_extra_codecs, obj);
+ }
+ }
+ }
+
+ error:
+
+ return current_extra_codecs;
+}
+
+
+static FsRtpSpecialCodec *
+fs_rtp_special_codec_new (FsRtpSpecialCodecClass *klass,
+ GList *negotiated_codecs,
+ GError **error)
+{
+ /* STUB */
+ return NULL;
+}
+
+static gboolean
+fs_rtp_special_codec_update (FsRtpSpecialCodec *codec,
+ GList *negotiated_codecs)
+{
+ return FALSE;
+}
diff --git a/gst/fsrtpconference/fs-rtp-special-codec.h b/gst/fsrtpconference/fs-rtp-special-codec.h
index eea10a7..2c9f9b2 100644
--- a/gst/fsrtpconference/fs-rtp-special-codec.h
+++ b/gst/fsrtpconference/fs-rtp-special-codec.h
@@ -56,9 +56,17 @@ struct _FsRtpSpecialCodecClass
{
GObjectClass parent_class;
- gboolean (*want_codec) (GList *negotiated_codecs, GError **error);
+ /* Object methods */
- GList* (*add_blueprint) (GList *blueprints);
+ gboolean (*update) (FsRtpSpecialCodec *codec,
+ GList *negotiated_codecs);
+
+ /* Class methods */
+ gboolean (*want_codec) (FsRtpSpecialCodecClass *klass,
+ GList *negotiated_codecs);
+
+ GList* (*add_blueprint) (FsRtpSpecialCodecClass *klass,
+ GList *blueprints);
};
/**
--
1.5.6.5
More information about the farsight-commits
mailing list