[farsight2/master] Document the "farsight-error" bus message and make "error-no" into a FsError

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


---
 gst-libs/gst/farsight/fs-base-conference.c  |    5 ++-
 gst-libs/gst/farsight/fs-conference-iface.c |   16 +++++++
 gst-libs/gst/farsight/fs-conference-iface.h |    1 +
 tests/check/main/rtpconference.c            |   44 ++++++++++++++++----
 tests/check/main/rtpsendcodecs.c            |   59 ++++++++++++++++++++-------
 5 files changed, 101 insertions(+), 24 deletions(-)

diff --git a/gst-libs/gst/farsight/fs-base-conference.c b/gst-libs/gst/farsight/fs-base-conference.c
index bb1e389..b4f8ac6 100644
--- a/gst-libs/gst/farsight/fs-base-conference.c
+++ b/gst-libs/gst/farsight/fs-base-conference.c
@@ -176,9 +176,12 @@ fs_base_conference_error (GObject *signal_src, GObject *error_src,
   GstMessage *gst_msg = NULL;
   GstStructure *error_struct = NULL;
 
+  if (debug_msg == NULL)
+    debug_msg = error_msg;
+
   error_struct = gst_structure_new ("farsight-error",
       "src-object", G_TYPE_OBJECT, error_src,
-      "error-no", G_TYPE_INT, error_no,
+      "error-no", FS_TYPE_ERROR, error_no,
       "error-msg", G_TYPE_STRING, error_msg,
       "debug-msg", G_TYPE_STRING, debug_msg,
       NULL);
diff --git a/gst-libs/gst/farsight/fs-conference-iface.c b/gst-libs/gst/farsight/fs-conference-iface.c
index 6545639..4646497 100644
--- a/gst-libs/gst/farsight/fs-conference-iface.c
+++ b/gst-libs/gst/farsight/fs-conference-iface.c
@@ -40,6 +40,22 @@
  * simply need to derive from the FsBaseConference class and don't need to
  * implement this interface directly.
  *
+ *
+ * This will communicate asynchronous events to the user through #GstMessage
+ * of type #GST_MESSAGE_ELEMENT sent over the #GstBus.
+ * </para>
+ * <refsect2><title>The "<literal>farsight-error</literal>" message</title>
+ * |[
+ * "src-object"       #GObject           The object (#FsConference, #FsSession or #FsStream) that emitted the error
+ * "error-no"         #FsError           The Error number
+ * "error-msg"        #gchar*            The error message
+ * "debug-msg"        #gchar*            The debug string
+ * ]|
+ * <para>
+ * The message is sent on asynchronous errors.
+ * </para>
+ * </refsect2>
+ * <para>
  */
 
 static void fs_conference_iface_init (FsConferenceClass *iface);
diff --git a/gst-libs/gst/farsight/fs-conference-iface.h b/gst-libs/gst/farsight/fs-conference-iface.h
index 2f3d6d5..a1cebf9 100644
--- a/gst-libs/gst/farsight/fs-conference-iface.h
+++ b/gst-libs/gst/farsight/fs-conference-iface.h
@@ -30,6 +30,7 @@
 
 #include <gst/farsight/fs-session.h>
 #include <gst/farsight/fs-codec.h>
+#include <gst/farsight/fs-enum-types.h>
 
 G_BEGIN_DECLS
 
diff --git a/tests/check/main/rtpconference.c b/tests/check/main/rtpconference.c
index be14a74..90d933f 100644
--- a/tests/check/main/rtpconference.c
+++ b/tests/check/main/rtpconference.c
@@ -182,21 +182,34 @@ _bus_callback (GstBus *bus, GstMessage *message, gpointer user_data)
         ts_fail_if (s==NULL, "NULL structure in element message");
         if (gst_structure_has_name (s, "farsight-error"))
         {
-          const GValue *errorvalue, *debugvalue;
-          gint errno;
+          const GValue *value;
+          FsError errorno;
+          const gchar *error, *debug;
 
           ts_fail_unless (
               gst_implements_interface_check (GST_MESSAGE_SRC (message),
                   FS_TYPE_CONFERENCE),
               "Received farsight-error from non-farsight element");
 
-          gst_structure_get_int (s, "error-no", &errno);
-          errorvalue = gst_structure_get_value (s, "error-msg");
-          debugvalue = gst_structure_get_value (s, "debug-msg");
+          ts_fail_unless (
+              gst_structure_has_field_typed (s, "src-object", G_TYPE_OBJECT),
+              "farsight-error structure has no src-object field");
+          ts_fail_unless (
+              gst_structure_has_field_typed (s, "error-no", FS_TYPE_ERROR),
+              "farsight-error structure has no src-object field");
+          ts_fail_unless (
+              gst_structure_has_field_typed (s, "error-msg", G_TYPE_STRING),
+              "farsight-error structure has no src-object field");
+          ts_fail_unless (
+              gst_structure_has_field_typed (s, "debug-msg", G_TYPE_STRING),
+              "farsight-error structure has no src-object field");
+
+          value = gst_structure_get_value (s, "error-no");
+          errorno = g_value_get_enum (value);
+          error = gst_structure_get_string (s, "error-msg");
+          debug = gst_structure_get_string (s, "debug-msg");
 
-          ts_fail ("Error on BUS (%d) %s .. %s", errno,
-              g_value_get_string (errorvalue),
-              g_value_get_string (debugvalue));
+          ts_fail ("Error on BUS (%d) %s .. %s", errorno, error, debug);
         }
         else if (gst_structure_has_name (s, "farsight-new-local-candidate"))
         {
@@ -205,6 +218,11 @@ _bus_callback (GstBus *bus, GstMessage *message, gpointer user_data)
           const GValue *value;
 
           ts_fail_unless (
+              gst_implements_interface_check (GST_MESSAGE_SRC (message),
+                  FS_TYPE_CONFERENCE),
+              "Received farsight-error from non-farsight element");
+
+          ts_fail_unless (
               gst_structure_has_field_typed (s, "stream", FS_TYPE_STREAM),
               "farsight-new-local-candidate structure has no stream field");
           ts_fail_unless (
@@ -230,6 +248,11 @@ _bus_callback (GstBus *bus, GstMessage *message, gpointer user_data)
           const GValue *value;
 
           ts_fail_unless (
+              gst_implements_interface_check (GST_MESSAGE_SRC (message),
+                  FS_TYPE_CONFERENCE),
+              "Received farsight-error from non-farsight element");
+
+          ts_fail_unless (
               gst_structure_has_field_typed (s, "stream", FS_TYPE_STREAM),
               "farsight-new-active-candidate-pair structure"
               " has no stream field");
@@ -264,6 +287,11 @@ _bus_callback (GstBus *bus, GstMessage *message, gpointer user_data)
           const GValue *value;
 
           ts_fail_unless (
+              gst_implements_interface_check (GST_MESSAGE_SRC (message),
+                  FS_TYPE_CONFERENCE),
+              "Received farsight-error from non-farsight element");
+
+          ts_fail_unless (
               gst_structure_has_field_typed (s, "session", FS_TYPE_SESSION),
               "farsight-current-send-codec-changed structure"
               " has no session field");
diff --git a/tests/check/main/rtpsendcodecs.c b/tests/check/main/rtpsendcodecs.c
index 73df5a8..8781865 100644
--- a/tests/check/main/rtpsendcodecs.c
+++ b/tests/check/main/rtpsendcodecs.c
@@ -62,24 +62,53 @@ _bus_callback (GstBus *bus, GstMessage *message, gpointer user_data)
 
   switch (GST_MESSAGE_TYPE (message))
   {
+
     case GST_MESSAGE_ELEMENT:
-      if (gst_implements_interface_check (GST_MESSAGE_SRC (message),
-              FS_TYPE_CONFERENCE) &&
-          gst_structure_has_name (gst_message_get_structure (message),
-              "farsight-error"))
       {
-        const GValue *errorvalue, *debugvalue;
-        gint errno;
-
-        gst_structure_get_int (message->structure, "error-no", &errno);
-        errorvalue = gst_structure_get_value (message->structure, "error-msg");
-        debugvalue = gst_structure_get_value (message->structure, "debug-msg");
-
-        ts_fail ("Error on BUS (%d) %s .. %s", errno,
-            g_value_get_string (errorvalue),
-            g_value_get_string (debugvalue));
+        const GstStructure *s = gst_message_get_structure (message);
+
+        if (gst_implements_interface_check (GST_MESSAGE_SRC (message),
+                FS_TYPE_CONFERENCE) &&
+            gst_structure_has_name (s, "farsight-error"))
+        {
+          const GValue *value;
+          FsError errorno;
+          const gchar *error, *debug;
+          GEnumClass *enumclass = NULL;
+          GEnumValue *enumvalue = NULL;
+
+          ts_fail_unless (
+              gst_implements_interface_check (GST_MESSAGE_SRC (message),
+                  FS_TYPE_CONFERENCE),
+              "Received farsight-error from non-farsight element");
+
+          ts_fail_unless (
+              gst_structure_has_field_typed (s, "src-object", G_TYPE_OBJECT),
+              "farsight-error structure has no src-object field");
+          ts_fail_unless (
+              gst_structure_has_field_typed (s, "error-no", FS_TYPE_ERROR),
+              "farsight-error structure has no src-object field");
+          ts_fail_unless (
+              gst_structure_has_field_typed (s, "error-msg", G_TYPE_STRING),
+              "farsight-error structure has no src-object field");
+          ts_fail_unless (
+              gst_structure_has_field_typed (s, "debug-msg", G_TYPE_STRING),
+              "farsight-error structure has no src-object field");
+
+          value = gst_structure_get_value (s, "error-no");
+          errorno = g_value_get_enum (value);
+          error = gst_structure_get_string (s, "error-msg");
+          debug = gst_structure_get_string (s, "debug-msg");
+
+
+          enumclass = g_type_class_ref (FS_TYPE_ERROR);
+          enumvalue = g_enum_get_value (enumclass, errorno);
+          ts_fail ("Error on BUS %s (%d, %s) %s .. %s",
+              enumvalue->value_name, errorno, enumvalue->value_nick,
+              error, debug);
+          g_type_class_unref (enumclass);
+        }
       }
-
       break;
     case GST_MESSAGE_ERROR:
       {
-- 
1.5.6.5




More information about the farsight-commits mailing list