Don't understand error

Tim Müller tim at centricular.com
Fri Mar 28 10:04:02 PDT 2014


On Fri, 2014-03-28 at 09:36 -0700, Kenairod wrote:

Hi,

> Well, here is the C code I'm using to create the Pipeline.
> 
> const gchar * serverIpAddress;

Try initialising it to someting, e.g. "" or "FIXME".

> // .....
> 
> /* Main method for the native code. This is executed on its own thread. */
> static void *app_function (void *userdata) {
> 
> // .....
> 
>   /* Build pipeline */
>   const gchar * part1 = "tcpclientsrc host=";
>   gchar* pipeline_definition;
>   pipeline_definition = malloc(109); //Number of characters in the pipeline
> definition
>   strcpy(pipeline_definition, part1); // copy the part 1 into the new var
>   strcat(pipeline_definition, serverIpAddress); // add the ip address
>   const gchar *  part2 = " port=5000 ! gdpdepay ! rtph264depay ! ffdec_h264
> ! autovideosink sync=false";
>   strcat(pipeline_definition, part2);
> 
>   data->pipeline = gst_parse_launch(pipeline_definition, &error);

May I suggest something like:

   pipeline_definition =
       g_strdup_printf ("tcpclientsrc host=%s port=5000 "
           " ! gdpdepay ! rtph264depay ! ffdec_h264 "
           "! autovideosink sync=false", serverIpAddress);

   data->pipeline = gst_parse_launch (pipeline_definition, &error)

   g_free (pipeline_definition);

But in any case, it seems like the problem is the construction of your
pipeline string. My guess would be that serverIpAddress never gets set
to anything, OR you're setting it to a string that's only valid for a
very short time inside .._nativeSetIpserver(), and you're strcat()ing
garbage or a now-freed string into the pipeline_definition string.
Should be easy to verify with a few printf in strategic places.

> JNIEXPORT void JNICALL
> Java_com_gst_sdk_tutorials_tutorial_3_Tutorial3_nativeSetIpserver(JNIEnv *
> env, jobject obj, jstring ipAddress)
> {
>         const char *temp = (*env)->GetStringUTFChars(env, ipAddress, 0);
>         serverIpAddress = temp;
>         (*env)->ReleaseStringUTFChars(env, ipAddress, temp);

Is this function getting called?

Does   serverIpAddress = g_strdup (temp);   help?

Cheers
 -Tim

-- 
Tim Müller, Centricular Ltd - http://www.centricular.com



More information about the gstreamer-devel mailing list