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;
}
Example #2
0
JNIEXPORT void JNICALL
Java_com_parrot_arsdk_arstream_ARStreamReader_nativeStop (JNIEnv *env, jobject thizz, jlong cReader)
{
    ARSTREAM_Reader_StopReader ((ARSTREAM_Reader_t *)(intptr_t)cReader);
}