int ARSTREAM_ReaderTb_StartStreamTest (ARNETWORK_Manager_t *manager, const char *outPath)
{
    int retVal = 0;

    uint8_t *firstFrame;
    uint32_t firstFrameSize;
    eARSTREAM_ERROR err;
    if (NULL != outPath)
    {
        outFile = fopen (outPath, "wb");
    }
    else
    {
        outFile = NULL;
    }
    ARSTREAM_ReaderTb_initMultiBuffers (FRAME_MAX_SIZE);
    ARSAL_Sem_Init (&closeSem, 0, 0);
    firstFrame = ARSTREAM_ReaderTb_GetNextFreeBuffer (&firstFrameSize, 0);
    g_Reader = ARSTREAM_Reader_New (manager, DATA_BUFFER_ID, ACK_BUFFER_ID, ARSTREAM_ReaderTb_FrameCompleteCallback, firstFrame, firstFrameSize, ARSTREAM_TB_FRAG_SIZE, 0, NULL, &err);
    if (g_Reader == NULL)
    {
        ARSAL_PRINT (ARSAL_PRINT_ERROR, __TAG__, "Error during ARSTREAM_Reader_New call : %s", ARSTREAM_Error_ToString(err));
        return 1;
    }

    pthread_t streamsend, streamread;
    pthread_create (&streamsend, NULL, ARSTREAM_Reader_RunDataThread, g_Reader);
    pthread_create (&streamread, NULL, ARSTREAM_Reader_RunAckThread, g_Reader);

    /* USER CODE */

    running = 1;
    ARSAL_Sem_Wait (&closeSem);
    running = 0;

    /* END OF USER CODE */

    ARSTREAM_Reader_StopReader (g_Reader);

    pthread_join (streamread, NULL);
    pthread_join (streamsend, NULL);

    ARSTREAM_Reader_Delete (&g_Reader);

    ARSAL_Sem_Destroy (&closeSem);

    return retVal;
}
Пример #2
0
JNIEXPORT jboolean JNICALL
Java_com_parrot_arsdk_arstream_ARStreamReader_nativeDispose (JNIEnv *env, jobject thizz, jlong cReader)
{
    jboolean retVal = JNI_TRUE;
    ARSTREAM_Reader_t *reader = (ARSTREAM_Reader_t *)(intptr_t)cReader;
    void *ref = ARSTREAM_Reader_GetCustom(reader);
    eARSTREAM_ERROR err = ARSTREAM_Reader_Delete (&reader);
    if (err != ARSTREAM_OK)
    {
        ARSAL_PRINT (ARSAL_PRINT_ERROR, JNI_READER_TAG, "Unable to delete reader : %s", ARSTREAM_Error_ToString (err));
        retVal = JNI_FALSE;
    }
    if (retVal == JNI_TRUE && ref != NULL)
    {
        (*env)->DeleteGlobalRef(env, (jobject)ref);
	if ((*env)->ExceptionOccurred(env) != NULL)
	{
	    (*env)->ExceptionDescribe(env);
	}
    }
    return retVal;
}