Don't understand error
Chris Tapp
opensource at keylevel.com
Fri Mar 28 10:39:16 PDT 2014
On 28 Mar 2014, at 17:04, Tim Müller <tim at centricular.com> wrote:
> 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".
This bit does that:
const char *temp = (*env)->GetStringUTFChars(env, ipAddress, 0);
serverIpAddress = temp;
(*env)->ReleaseStringUTFChars(env, ipAddress, temp);
But:
1) That puts UTF8 into char with the risk that the encoding might not be compatible (probably ok here);
2) But... Doesn't ReleaseStringUTFChars then release the string before it gets used?
>
>> // .....
>>
>> /* 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
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Chris Tapp
opensource at keylevel.com
www.keylevel.com
More information about the gstreamer-devel
mailing list