Question

On Linux systems I've used 'export GST_DEBUG=<#>' to debug problems with a program's use of GStreamer. I'm now working on Android and would like to do the same - see the GStreamer output included in the logcat output.

I have a Google Nexus 5 phone and I'm using the full_hammerhead_userdebug build. I've seen the following suggested:

Add the following in JNI_OnLoad:
setenv("GST_DEBUG", "*:5", 1);
setenv("GST_DEBUG_NO_COLOR", "1", 1);

Unfortunately I'm trying to debug a C library, so I would prefer to set something in the environment to enable the debug output. I tried to add the following lines to build.prop:

export GST_DEBUG=3
GST_DEBUG=3
log.redirect-stdio=true

That didn't work. Either I'm not enabling GST_DEBUG properly or I'm not redirecting it properly. Or I'm way off track and I should be doing something else. How can I enable GST_DEBUG with Android?

P.S. This question is similar to one, but that one didn't completely answer my question.

Was it helpful?

Solution

I ended up going in another direction to solve this problem. First I created my own GstLogFunction()

void gstAndroidLog(GstDebugCategory * category, 
                   GstDebugLevel      level, 
                   const gchar      * file, 
                   const gchar      * function, 
                   gint               line, 
                   GObject          * object, 
                   GstDebugMessage  * message, 
                   gpointer           data)
{
  if (level <= gst_debug_category_get_threshold (category))
  {
    __android_log_print(ANDROID_LOG_ERROR, "MY_APP", "%s,%s: %s",
                        file, function, gst_debug_message_get(message)); 
  }
} 

Then after gst_init() is called, I set up the log levels. If I want to see everything, I can set:

gst_debug_set_default_threshold( GST_LEVEL_DEBUG );

If I just want to see what is happening in a specific category, I can set:

gst_debug_set_threshold_for_name ("tcpclientsink", GST_LEVEL_LOG);

Then I just need to register the log function I created:

gst_debug_add_log_function(&gstAndroidLog, NULL);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top