[farsight2/master] Use Gstreamer debug message mecanisms for codec discovery and cache

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


---
 gst/fsrtpconference/fs-rtp-codec-cache.c     |   25 ++++--
 gst/fsrtpconference/fs-rtp-conference.c      |   11 ++-
 gst/fsrtpconference/fs-rtp-conference.h      |    3 +
 gst/fsrtpconference/fs-rtp-discover-codecs.c |  102 +++++++++++---------------
 tests/rtp/Makefile.am                        |    3 +-
 5 files changed, 73 insertions(+), 71 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-codec-cache.c b/gst/fsrtpconference/fs-rtp-codec-cache.c
index 73a8bd7..5ea1816 100644
--- a/gst/fsrtpconference/fs-rtp-codec-cache.c
+++ b/gst/fsrtpconference/fs-rtp-codec-cache.c
@@ -35,6 +35,15 @@
 #include <string.h>
 #include <unistd.h>
 
+#ifdef STANDALONE
+# undef GST_WARNING
+# undef GST_DEBUG
+# undef GST_LOG
+# define GST_DEBUG(...) g_debug (__VA_ARGS__)
+#else
+# include "fs-rtp-conference.h"
+# define GST_CAT_DEFAULT fsrtpconference_disco
+#endif
 
 static gboolean codecs_cache_valid(gchar *cache_path) {
   time_t cache_ts = 0;
@@ -214,7 +223,7 @@ load_codec_blueprint (FsMediaType media_type, gchar **in, gsize *size) {
       g_list_append (codec_blueprint->receive_pipeline_factory, tmplist);
   }
 
-  g_debug ("adding codec %s with pt %d, send_pipeline %p, receive_pipeline %p",
+  GST_DEBUG ("adding codec %s with pt %d, send_pipeline %p, receive_pipeline %p",
       codec_blueprint->codec->encoding_name, codec_blueprint->codec->id,
       codec_blueprint->send_pipeline_factory,
       codec_blueprint->receive_pipeline_factory);
@@ -270,16 +279,16 @@ load_codecs_cache (FsMediaType media_type, GError **error)
     return FALSE;
 
   if (!codecs_cache_valid(cache_path)) {
-    g_debug ("Codecs cache %s is outdated or does not exist", cache_path);
+    GST_DEBUG ("Codecs cache %s is outdated or does not exist", cache_path);
     g_free(cache_path);
     return FALSE;
   }
 
-  g_debug ("Loading codecs cache %s", cache_path);
+  GST_DEBUG ("Loading codecs cache %s", cache_path);
 
   mapped = g_mapped_file_new (cache_path, FALSE, &err);
   if (mapped == NULL) {
-    g_debug ("Unable to mmap file %s : %s", cache_path,
+    GST_DEBUG ("Unable to mmap file %s : %s", cache_path,
       err ? err->message: "unknown error");
     g_clear_error (&err);
 
@@ -458,7 +467,7 @@ save_codecs_cache(FsMediaType media_type, GList *blueprints)
     return FALSE;
 
 
-  g_debug ("Saving codecs cache to %s", cache_path);
+  GST_DEBUG ("Saving codecs cache to %s", cache_path);
 
   tmp_path = g_strconcat (cache_path, ".tmpXXXXXX", NULL);
   fd = g_mkstemp (tmp_path);
@@ -476,7 +485,7 @@ save_codecs_cache(FsMediaType media_type, GList *blueprints)
     fd = g_mkstemp (tmp_path);
 
     if (fd == -1) {
-      g_debug ("Unable to save codecs cache. g_mkstemp() failed: %s",
+      GST_DEBUG ("Unable to save codecs cache. g_mkstemp() failed: %s",
           g_strerror (errno));
       g_free (tmp_path);
       g_free (cache_path);
@@ -523,7 +532,7 @@ save_codecs_cache(FsMediaType media_type, GList *blueprints)
 
 
   if (close (fd) < 0) {
-    g_debug ("Can't close codecs cache file : %s", g_strerror (errno));
+    GST_DEBUG ("Can't close codecs cache file : %s", g_strerror (errno));
       g_free (tmp_path);
       g_free (cache_path);
       return FALSE;
@@ -537,6 +546,6 @@ save_codecs_cache(FsMediaType media_type, GList *blueprints)
   }
 
   g_free (tmp_path);
-  g_debug ("Wrote binary codecs cache");
+  GST_DEBUG ("Wrote binary codecs cache");
   return TRUE;
 }
diff --git a/gst/fsrtpconference/fs-rtp-conference.c b/gst/fsrtpconference/fs-rtp-conference.c
index 2211779..529a44c 100644
--- a/gst/fsrtpconference/fs-rtp-conference.c
+++ b/gst/fsrtpconference/fs-rtp-conference.c
@@ -40,8 +40,9 @@
 
 #include <string.h>
 
-GST_DEBUG_CATEGORY_STATIC (fs_rtp_conference_debug);
-#define GST_CAT_DEFAULT fs_rtp_conference_debug
+GST_DEBUG_CATEGORY_STATIC (fsrtpconference_debug);
+GST_DEBUG_CATEGORY (fsrtpconference_disco);
+#define GST_CAT_DEFAULT fsrtpconference_debug
 
 /* Signals */
 enum
@@ -127,8 +128,10 @@ static void _rtpbin_on_new_ssrc_cname_association (GstElement *rtpbin,
 static void
 fs_rtp_conference_do_init (GType type)
 {
-  GST_DEBUG_CATEGORY_INIT (fs_rtp_conference_debug, "fsrtpconference", 0,
-      "farsight rtp conference element");
+  GST_DEBUG_CATEGORY_INIT (fsrtpconference_debug, "fsrtpconference", 0,
+      "Farsight RTP Conference Element");
+  GST_DEBUG_CATEGORY_INIT (fsrtpconference_disco, "fsrtpconference_disco",
+      0, "Farsight RTP Codec Discovery");
 }
 
 static void
diff --git a/gst/fsrtpconference/fs-rtp-conference.h b/gst/fsrtpconference/fs-rtp-conference.h
index 28c30fd..d3e557b 100644
--- a/gst/fsrtpconference/fs-rtp-conference.h
+++ b/gst/fsrtpconference/fs-rtp-conference.h
@@ -66,6 +66,9 @@ struct _FsRtpConferenceClass
 
 GType fs_rtp_conference_get_type(void);
 
+
+GST_DEBUG_CATEGORY_EXTERN (fsrtpconference_disco);
+
 G_END_DECLS
 
 #endif /* __FS_RTP_CONFERENCE_H__ */
diff --git a/gst/fsrtpconference/fs-rtp-discover-codecs.c b/gst/fsrtpconference/fs-rtp-discover-codecs.c
index 722076d..4084c8a 100644
--- a/gst/fsrtpconference/fs-rtp-discover-codecs.c
+++ b/gst/fsrtpconference/fs-rtp-discover-codecs.c
@@ -29,7 +29,7 @@
 
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+# include "config.h"
 #endif
 
 #include "fs-rtp-discover-codecs.h"
@@ -40,8 +40,17 @@
 
 #include <string.h>
 
-#undef ENABLE_DEBUG_CAPS
-
+#ifdef STANDALONE
+# undef GST_WARNING
+# undef GST_DEBUG
+# undef GST_LOG
+# define GST_WARNING(...) g_warning (__VA_ARGS__)
+# define GST_DEBUG(...) g_debug (__VA_ARGS__)
+# define GST_LOG(...) g_debug (__VA_ARGS__)
+#else
+# include "fs-rtp-conference.h"
+# define GST_CAT_DEFAULT fsrtpconference_disco
+#endif
 
 /*
  * Local TYPES
@@ -87,30 +96,27 @@ debug_pipeline (GList *pipeline)
 {
   GList *walk;
 
-  g_debug ("pipeline: ");
+  GST_DEBUG ("pipeline: ");
   for (walk = pipeline; walk; walk = g_list_next (walk))
   {
     GList *walk2;
     for (walk2 = g_list_first (walk->data); walk2; walk2 = g_list_next (walk2))
-      g_debug ("%p:%d:%s ", walk2->data,
+      GST_DEBUG ("%p:%d:%s ", walk2->data,
         GST_OBJECT_REFCOUNT_VALUE(GST_OBJECT (walk2->data)),
         gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (walk2->data)));
-    g_debug ("--");
+    GST_DEBUG ("--");
   }
-  g_debug ("\n");
+  GST_DEBUG ("\n");
 }
 
-#ifdef ENABLE_DEBUG_CAPS
-
 static void
 debug_codec_cap (CodecCap *codec_cap)
 {
   gchar *caps;
   if (codec_cap->caps)
   {
-    g_assert (gst_caps_get_size (codec_cap->caps) == 1);
     caps = gst_caps_to_string (codec_cap->caps);
-    g_debug ("%p:%d:media_caps %s\n", codec_cap->caps,
+    GST_LOG ("%p:%d:media_caps %s\n", codec_cap->caps,
         GST_CAPS_REFCOUNT_VALUE(codec_cap->caps),
         caps);
     g_free (caps);
@@ -118,16 +124,16 @@ debug_codec_cap (CodecCap *codec_cap)
 
   if (codec_cap->rtp_caps)
   {
-    g_assert (gst_caps_get_size (codec_cap->rtp_caps) == 1);
     caps = gst_caps_to_string (codec_cap->rtp_caps);
-    g_debug ("%p:%d:rtp_caps %s\n", codec_cap->rtp_caps,
+    GST_LOG ("%p:%d:rtp_caps %s\n", codec_cap->rtp_caps,
         GST_CAPS_REFCOUNT_VALUE(codec_cap->rtp_caps), caps);
     g_free (caps);
+    g_assert (gst_caps_get_size (codec_cap->rtp_caps) == 1);
   }
 
-  g_debug ("element_list1 -> ");
+  GST_LOG ("element_list1 -> ");
   debug_pipeline (codec_cap->element_list1);
-  g_debug ("element_list2 -> ");
+  GST_LOG ("element_list2 -> ");
   debug_pipeline (codec_cap->element_list2);
 }
 
@@ -135,16 +141,13 @@ static void
 debug_codec_cap_list (GList *codec_cap_list)
 {
   GList *walk;
-  g_debug ("size of codec_cap list is %d", g_list_length (codec_cap_list));
+  GST_LOG ("size of codec_cap list is %d", g_list_length (codec_cap_list));
   for (walk = codec_cap_list; walk; walk = g_list_next (walk))
   {
     debug_codec_cap ((CodecCap *)walk->data);
   }
 }
 
-
-#endif
-
 static void
 codec_cap_free (CodecCap *codec_cap)
 {
@@ -234,7 +237,7 @@ fs_rtp_blueprints_get (FsMediaType media_type, GError **error)
 
   list_codec_blueprints[media_type] = load_codecs_cache(media_type, NULL);
   if (list_codec_blueprints[media_type]) {
-    g_debug("Loaded codec blueprints from cache file");
+    GST_DEBUG("Loaded codec blueprints from cache file");
     return list_codec_blueprints[media_type];
   }
 
@@ -299,19 +302,17 @@ create_codec_lists (FsMediaType media_type,
   duplex_list = codec_cap_list_intersect (recv_list, send_list);
 
   if(!duplex_list) {
-    g_warning ("There are no send/recv codecs");
+    GST_WARNING ("There are no send/recv codecs");
     return FALSE;
   }
 
-#ifdef ENABLE_DEBUG_CAPS
-  g_debug ("*******Intersection of send_list and recv_list");
+  GST_LOG ("*******Intersection of send_list and recv_list");
   debug_codec_cap_list(duplex_list);
-#endif
 
   duplex_list = remove_dynamic_duplicates (duplex_list);
 
   if (!duplex_list) {
-    g_warning ("Dynamic duplicate removal left us with nothing");
+    GST_WARNING ("Dynamic duplicate removal left us with nothing");
     return FALSE;
   }
 
@@ -517,7 +518,7 @@ parse_codec_cap_list (GList *list, FsMediaType media_type)
       const gchar *encoding_name = codec->encoding_name ? codec->encoding_name
         : gst_structure_get_string (caps, "encoding-name");
 
-      g_debug ("skipping codec %s/%s, no encoding name specified"
+      GST_DEBUG ("skipping codec %s/%s, no encoding name specified"
           " (pt: %d clock_rate:%u",
           media_type == FS_MEDIA_TYPE_AUDIO ? "audio" : "video",
           encoding_name ? encoding_name : "unknown", codec->id,
@@ -560,15 +561,15 @@ parse_codec_cap_list (GList *list, FsMediaType media_type)
     /* insert new information into tables */
     list_codec_blueprints[media_type] = g_list_append (
         list_codec_blueprints[media_type], codec_blueprint);
-    g_debug ("adding codec %s with pt %d, send_pipeline %p, receive_pipeline %p",
+    GST_DEBUG ("adding codec %s with pt %d, send_pipeline %p, receive_pipeline %p",
         codec->encoding_name, codec->id,
         codec_blueprint->send_pipeline_factory,
         codec_blueprint->receive_pipeline_factory);
     tmp = gst_caps_to_string (codec_blueprint->media_caps);
-    g_debug ("media_caps: %s", tmp);
+    GST_DEBUG ("media_caps: %s", tmp);
     g_free (tmp);
     tmp = gst_caps_to_string (codec_blueprint->rtp_caps);
-    g_debug ("rtp_caps: %s", tmp);
+    GST_DEBUG ("rtp_caps: %s", tmp);
     g_free (tmp);
     debug_pipeline (codec_blueprint->send_pipeline_factory);
     debug_pipeline (codec_blueprint->receive_pipeline_factory);
@@ -647,30 +648,26 @@ detect_send_codecs (GstCaps *caps)
   /* no payloader found. giving up */
   if (!payloaders)
   {
-    g_warning ("No RTP Payloaders found");
+    GST_WARNING ("No RTP Payloaders found");
     return NULL;
   }
-#ifdef ENABLE_DEBUG_CAPS
   else {
-    g_debug ("**Payloaders");
+    GST_LOG ("**Payloaders");
     debug_codec_cap_list(payloaders);
   }
-#endif
 
   /* find all encoders based on is_encoder filter */
   encoders = get_plugins_filtered_from_caps (is_encoder, NULL, GST_PAD_SRC);
   if (!encoders)
   {
     codec_cap_list_free (payloaders);
-    g_warning ("No encoders found");
+    GST_WARNING ("No encoders found");
     return NULL;
   }
-#ifdef ENABLE_DEBUG_CAPS
   else {
-    g_debug ("**Encoders");
+    GST_LOG ("**Encoders");
     debug_codec_cap_list(encoders);
   }
-#endif
 
   /* create intersection list of codecs common
    * to encoders and payloaders lists */
@@ -678,15 +675,12 @@ detect_send_codecs (GstCaps *caps)
 
   if (!send_list)
   {
-    g_warning ("No compatible encoder/payloader pairs found");
+    GST_WARNING ("No compatible encoder/payloader pairs found");
   }
-#ifdef ENABLE_DEBUG_CAPS
   else {
-    g_debug ("**intersection of payloaders and encoders");
+    GST_LOG ("**intersection of payloaders and encoders");
     debug_codec_cap_list(send_list);
   }
-#endif
-
 
   codec_cap_list_free (payloaders);
   codec_cap_list_free (encoders);
@@ -710,15 +704,13 @@ detect_recv_codecs (GstCaps *caps)
   /* no depayloader found. giving up */
   if (!depayloaders)
   {
-    g_warning ("No RTP Depayloaders found");
+    GST_WARNING ("No RTP Depayloaders found");
     return NULL;
   }
-#ifdef ENABLE_DEBUG_CAPS
   else {
-    g_debug ("**Depayloaders");
+    GST_LOG ("**Depayloaders");
     debug_codec_cap_list(depayloaders);
   }
-#endif
 
   /* find all decoders based on is_decoder filter */
   decoders = get_plugins_filtered_from_caps (is_decoder, NULL, GST_PAD_SINK);
@@ -726,15 +718,13 @@ detect_recv_codecs (GstCaps *caps)
   if (!decoders)
   {
     codec_cap_list_free (depayloaders);
-    g_warning ("No decoders found");
+    GST_WARNING ("No decoders found");
     return NULL;
   }
-#ifdef ENABLE_DEBUG_CAPS
   else {
-    g_debug ("**Decoders");
+    GST_LOG ("**Decoders");
     debug_codec_cap_list(decoders);
   }
-#endif
 
   /* create intersection list of codecs common
    * to decoders and depayloaders lists */
@@ -742,14 +732,12 @@ detect_recv_codecs (GstCaps *caps)
 
   if (!recv_list)
   {
-    g_warning ("No compatible decoder/depayloader pairs found");
+    GST_WARNING ("No compatible decoder/depayloader pairs found");
   }
-#ifdef ENABLE_DEBUG_CAPS
   else {
-    g_debug ("**intersection of depayloaders and decoders");
+    GST_LOG ("**intersection of depayloaders and decoders");
     debug_codec_cap_list(recv_list);
   }
-#endif
 
   codec_cap_list_free (depayloaders);
   codec_cap_list_free (decoders);
@@ -1078,7 +1066,8 @@ create_codec_cap_list (GstElementFactory *factory,
       const gchar *name = gst_structure_get_name (structure);
       if (g_ascii_strcasecmp (name, "application/x-rtp") == 0)
       {
-        g_debug ("skipping %s", gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)));
+        GST_DEBUG ("skipping %s",
+            gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)));
         continue;
       }
 
@@ -1116,9 +1105,6 @@ create_codec_cap_list (GstElementFactory *factory,
       {
         GstCaps *newcaps;
 
-        g_debug ("EXTRA: %s to %s", gst_plugin_feature_get_name (
-              GST_PLUGIN_FEATURE (factory)), gst_caps_to_string (cur_caps));
-
         entry->element_list1->data =
           g_list_append (entry->element_list1->data, factory);
         gst_object_ref (factory);
diff --git a/tests/rtp/Makefile.am b/tests/rtp/Makefile.am
index 40612c8..8e41d18 100644
--- a/tests/rtp/Makefile.am
+++ b/tests/rtp/Makefile.am
@@ -5,6 +5,7 @@ codec_discovery_SOURCES = codec-discovery.c \
 		$(top_srcdir)/gst/fsrtpconference/fs-rtp-discover-codecs.c \
 		$(top_srcdir)/gst/fsrtpconference/fs-rtp-codec-cache.c
 codec_discovery_CFLAGS = -I$(top_srcdir)/gst/fsrtpconference/ \
-	$(FS2_INTERNAL_CFLAGS) $(FS2_CFLAGS) $(GST_CFLAGS)  $(CFLAGS)
+	$(FS2_INTERNAL_CFLAGS) $(FS2_CFLAGS) $(GST_CFLAGS)  $(CFLAGS) \
+	-DSTANDALONE
 LDADD = $(GST_LIBS) $(GST_CHECK_LIBS) \
 	$(top_builddir)/gst-libs/gst/farsight/libgstfarsight-0.10.la
-- 
1.5.6.5




More information about the farsight-commits mailing list