Hello,

I have been reading the existing elements in fs2 and noticed there are some coding style inconsistencies among them.

It would help new plugin writers and those trying to understand the code if there was one preferred way of doing things. They are mostly equivalent but the slight differences distract the reader especially if new to fs, gstreamer and gobject programming.

I attached the patches created by git-format-patch so they have comments in them.

There's another inconsistency in naming the files and identifiers in them, some are prefixed by gst, others by gst_fs others not at all.

thanks
Jani
>From 314b6163983fef4479fab1d840e89205a22b5640 Mon Sep 17 00:00:00 2001
From: Jani Monoses <[EMAIL PROTECTED]>
Date: Wed, 20 Aug 2008 23:37:19 +0300
Subject: [PATCH] use inline function instead of macro for _do_init to be consistent with the other plugins

---
 gst/funnel/gstfsfunnel.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gst/funnel/gstfsfunnel.c b/gst/funnel/gstfsfunnel.c
index fabf7ee..195db58 100644
--- a/gst/funnel/gstfsfunnel.c
+++ b/gst/funnel/gstfsfunnel.c
@@ -52,9 +52,12 @@ static GstStaticPadTemplate funnel_src_template =
     GST_STATIC_CAPS_ANY);
 
 
-
-#define _do_init(bla) \
-    GST_DEBUG_CATEGORY_INIT (fs_funnel_debug, "fsfunnel", 0, "fsfunnel element");
+static void
+_do_init (GType type)
+{
+  GST_DEBUG_CATEGORY_INIT
+    (fs_funnel_debug, "fsfunnel", 0, "fsfunnel element");
+}
 
 GST_BOILERPLATE_FULL (FsFunnel, fs_funnel, GstElement, GST_TYPE_ELEMENT,
   _do_init);
-- 
1.5.4.3

>From ff21f26dbd51d2c2bfd2d394f780d8ae362d5aed Mon Sep 17 00:00:00 2001
From: Jani Monoses <[EMAIL PROTECTED]>
Date: Wed, 20 Aug 2008 23:55:13 +0300
Subject: [PATCH] use gst_element_class_set_details instead of gst_element_class_set_details_simple

---
 gst/funnel/gstfsfunnel.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/gst/funnel/gstfsfunnel.c b/gst/funnel/gstfsfunnel.c
index 195db58..d7589ab 100644
--- a/gst/funnel/gstfsfunnel.c
+++ b/gst/funnel/gstfsfunnel.c
@@ -38,6 +38,12 @@
 GST_DEBUG_CATEGORY_STATIC (fs_funnel_debug);
 #define GST_CAT_DEFAULT fs_funnel_debug
 
+static const GstElementDetails gst_fsfunnel_details = 
+GST_ELEMENT_DETAILS(
+  "Farsight Funnel pipe fitting",
+  "Generic",
+  "N-to-1 pipe fitting",
+  "Olivier Crete <[EMAIL PROTECTED]>");
 
 static GstStaticPadTemplate funnel_sink_template =
   GST_STATIC_PAD_TEMPLATE ("sink%d",
@@ -84,11 +90,8 @@ fs_funnel_base_init (gpointer g_class)
 {
   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
 
-  gst_element_class_set_details_simple (gstelement_class,
-      "Farsight Funnel pipe fitting",
-      "Generic",
-      "N-to-1 pipe fitting",
-      "Olivier Crete <[EMAIL PROTECTED]>");
+  gst_element_class_set_details (gstelement_class, &gst_fsfunnel_details);
+
   gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&funnel_sink_template));
   gst_element_class_add_pad_template (gstelement_class,
-- 
1.5.4.3

>From 293f6ae85d3470146dcb67077a2ade59b8ed2895 Mon Sep 17 00:00:00 2001
From: Jani Monoses <[EMAIL PROTECTED]>
Date: Wed, 20 Aug 2008 23:57:52 +0300
Subject: [PATCH] move class pad_template and details initialization from _class_init to _base_init as done in the other plugins and recommended in the Gstreamer docs

---
 gst/fsrtpconference/fs-rtp-conference.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-conference.c b/gst/fsrtpconference/fs-rtp-conference.c
index 46b8051..1b0d771 100644
--- a/gst/fsrtpconference/fs-rtp-conference.c
+++ b/gst/fsrtpconference/fs-rtp-conference.c
@@ -245,13 +245,6 @@ fs_rtp_conference_class_init (FsRtpConferenceClass * klass)
   gobject_class->get_property =
     GST_DEBUG_FUNCPTR (fs_rtp_conference_get_property);
 
-  gst_element_class_set_details (gstelement_class, &fs_rtp_conference_details);
-
-  gst_element_class_add_pad_template (gstelement_class,
-            gst_static_pad_template_get (&fs_rtp_conference_sink_template));
-  gst_element_class_add_pad_template (gstelement_class,
-            gst_static_pad_template_get (&fs_rtp_conference_src_template));
-
   g_object_class_install_property (gobject_class, PROP_SDES_CNAME,
       g_param_spec_string ("sdes-cname", "Canonical name",
           "The CNAME for the RTP sessions",
@@ -291,6 +284,14 @@ fs_rtp_conference_class_init (FsRtpConferenceClass * klass)
 static void
 fs_rtp_conference_base_init (gpointer g_class)
 {
+  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
+
+  gst_element_class_add_pad_template (gstelement_class,
+            gst_static_pad_template_get (&fs_rtp_conference_sink_template));
+  gst_element_class_add_pad_template (gstelement_class,
+            gst_static_pad_template_get (&fs_rtp_conference_src_template));
+
+  gst_element_class_set_details (gstelement_class, &fs_rtp_conference_details);
 }
 
 static void
-- 
1.5.4.3

>From 5899eb271a42989b721cb1fd434557645d867c36 Mon Sep 17 00:00:00 2001
From: Jani Monoses <[EMAIL PROTECTED]>
Date: Wed, 20 Aug 2008 23:15:20 +0300
Subject: [PATCH] cleanup unused var

---
 gst/videoanyrate/videoanyrate.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/gst/videoanyrate/videoanyrate.c b/gst/videoanyrate/videoanyrate.c
index 592a267..6c891c9 100644
--- a/gst/videoanyrate/videoanyrate.c
+++ b/gst/videoanyrate/videoanyrate.c
@@ -100,10 +100,8 @@ gst_videoanyrate_base_init (gpointer klass)
 static void
 gst_videoanyrate_class_init (GstVideoanyrateClass *klass)
 {
-  GObjectClass *gobject_class;
   GstBaseTransformClass *gstbasetransform_class;
 
-  gobject_class = (GObjectClass *) klass;
   gstbasetransform_class = (GstBaseTransformClass *) klass;
 
   gstbasetransform_class->transform_caps =
-- 
1.5.4.3

>From da6214546d0b9ab07ac4f727766b91b79ce496fb Mon Sep 17 00:00:00 2001
From: Jani Monoses <[EMAIL PROTECTED]>
Date: Thu, 21 Aug 2008 00:05:34 +0300
Subject: [PATCH] use GST_ELEMENT_DETAILS

---
 gst/fsrtpconference/fs-rtp-conference.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-conference.c b/gst/fsrtpconference/fs-rtp-conference.c
index 1b0d771..56b2c5b 100644
--- a/gst/fsrtpconference/fs-rtp-conference.c
+++ b/gst/fsrtpconference/fs-rtp-conference.c
@@ -66,13 +66,12 @@ enum
 };
 
 
-static GstElementDetails fs_rtp_conference_details = {
+static const GstElementDetails fs_rtp_conference_details =
+GST_ELEMENT_DETAILS (
   "Farsight RTP Conference",
   "Generic/Bin/RTP",
   "A Farsight RTP Conference",
-  "Olivier Crete <[EMAIL PROTECTED]>"
-};
-
+  "Olivier Crete <[EMAIL PROTECTED]>");
 
 
 static GstStaticPadTemplate fs_rtp_conference_sink_template =
-- 
1.5.4.3

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Farsight-devel mailing list
Farsight-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/farsight-devel

Reply via email to