C_RESULT vp_stages_frame_pipe_receiver_transform(vp_stages_frame_pipe_config_t *cfg, vp_api_io_data_t *in, vp_api_io_data_t *out) { vp_os_mutex_lock(&out->lock); if(out->status == VP_API_STATUS_INIT) { out->numBuffers = 1; out->indexBuffer = 0; out->status = VP_API_STATUS_PROCESSING; } if( out->status == VP_API_STATUS_PROCESSING ) { vp_os_mutex_lock(&(cfg->pipe_mut)); { if (cfg->pipe_state != SENDER_ERROR) { if (cfg->pipe_state == FETCH_PAUSE) { // a frame has alerady been fetched by a fetch stage cfg->pipe_state = PAUSE; } else { // no fetch stage was executed, ask for a frame transfer cfg->pipe_state = WAIT_RECEPTION; vp_os_cond_wait (&(cfg->buffer_sent)); } if (cfg->mode == FAST && cfg->pipe_state != SENDER_ERROR) { // at this point a new frame is available in the copy buffer // swap the two output buffer to make new picture available in outPicture vp_api_picture_t temp = cfg->outPicture; cfg->outPicture = cfg->copyPicture; cfg->copyPicture = temp; // trigger a new frame transfert cfg->pipe_state = FETCH; } // at this point, we are sure that cfg->outPicture was initialized by the sender out->buffers = &(cfg->outPicture.raw); out->size = cfg->frame_size; } } vp_os_mutex_unlock(&(cfg->pipe_mut)); if (cfg->callback != NULL) cfg->callback(); } vp_os_mutex_unlock(&out->lock); return C_OK; }
C_RESULT vp_com_wait_for_server_up(void) { if( server_init_not_finished ) { vp_os_mutex_lock(&server_initialisation_mutex); vp_os_cond_wait(&server_initialisation_wait); vp_os_mutex_unlock(&server_initialisation_mutex); } return C_OK; }
int8_t *videoServer_waitForNewFrame() { /* Wait for a new available frame */ vp_os_mutex_lock(&frameBufferMutex); //C_RESULT res = vp_os_cond_timed_wait(&frameBufferCond, MAX_FRAME_WAIT_SECONDS * 1000); //if (SUCCEED(res) && availVideoBuffer != NULL) vp_os_cond_wait(&frameBufferCond); if (availVideoBuffer != NULL) { ((VideoFrameHeader *)frameBuffer)->videoData.timeCodeH = (unsigned int)(videoServer_lastFrameTimeCode >> 32); ((VideoFrameHeader *)frameBuffer)->videoData.timeCodeL = (unsigned int)(videoServer_lastFrameTimeCode & 0xFFFFFFFF); ((VideoFrameHeader *)frameBuffer)->videoData.encoding = videoServer_frameSourceEncoding; ((VideoFrameHeader *)frameBuffer)->videoData.width = videoServer_frameWidth; ((VideoFrameHeader *)frameBuffer)->videoData.height = videoServer_frameHeight; ((VideoFrameHeader *)frameBuffer)->videoData.dataLength = videoServer_framePacketLength - sizeof(VideoFrameHeader); vp_os_memcpy(&frameBuffer[sizeof(VideoFrameHeader)], availVideoBuffer, videoServer_framePacketLength - sizeof(VideoFrameHeader)); vp_os_mutex_unlock(&frameBufferMutex); availVideoBuffer = NULL; return frameBuffer; }
PROTO_THREAD_ROUTINE(dct, params) { uint32_t i; PRINT("DCT thread start\n"); while(1) { if( current_io_buffer == NULL ) { vp_os_mutex_lock(&dct_start_mutex); vp_os_cond_wait(&dct_start_cond); vp_os_mutex_unlock(&dct_start_mutex); } if( current_io_buffer->dct_mode == DCT_MODE_FDCT ) { for( i = 0; i < current_io_buffer->num_total_blocks; i++ ) { fdct(current_io_buffer->input[i], current_io_buffer->output[i]); } } else if( current_io_buffer->dct_mode == DCT_MODE_IDCT ) { for( i = 0; i < current_io_buffer->num_total_blocks; i++ ) { idct(current_io_buffer->input[i], current_io_buffer->output[i]); } } vp_os_mutex_lock(&critical_section); result_io_buffer = current_io_buffer; current_io_buffer = NULL; vp_os_mutex_unlock(&critical_section); } return 0; }
DEFINE_THREAD_ROUTINE(video_stage, data) { C_RESULT res; vp_api_io_pipeline_t pipeline; vp_api_io_data_t out; vp_api_io_stage_t stages[NB_STAGES]; vp_api_picture_t picture; vlib_stage_decoding_config_t vec; vp_os_memset(&icc, 0, sizeof( icc )); vp_os_memset(&vec, 0, sizeof( vec )); vp_os_memset(&picture, 0, sizeof( picture )); //#ifdef RECORD_VIDEO // video_stage_recorder_config_t vrc; //#endif /// Picture configuration picture.format = /*PIX_FMT_YUV420P */ PIX_FMT_RGB565; picture.width = 512; picture.height = 512; picture.framerate = 15; picture.y_buf = vp_os_malloc( picture.width * picture.height * 2); picture.cr_buf = NULL; picture.cb_buf = NULL; picture.y_line_size = picture.width * 2; picture.cb_line_size = 0; picture.cr_line_size = 0; icc.com = COM_VIDEO(); icc.buffer_size = 100000; icc.protocol = VP_COM_UDP; COM_CONFIG_SOCKET_VIDEO(&icc.socket, VP_COM_CLIENT, VIDEO_PORT, wifi_ardrone_ip); vec.width = 512; vec.height = 512; vec.picture = &picture; vec.luma_only = FALSE; vec.block_mode_enable = TRUE; pipeline.nb_stages = 0; stages[pipeline.nb_stages].type = VP_API_INPUT_SOCKET; stages[pipeline.nb_stages].cfg = (void *)&icc; stages[pipeline.nb_stages].funcs = video_com_funcs; pipeline.nb_stages++; stages[pipeline.nb_stages].type = VP_API_FILTER_DECODER; stages[pipeline.nb_stages].cfg = (void*)&vec; stages[pipeline.nb_stages].funcs = vlib_decoding_funcs; pipeline.nb_stages++; /* #ifdef RECORD_VIDEO stages[pipeline.nb_stages].type = VP_API_FILTER_DECODER; stages[pipeline.nb_stages].cfg = (void*)&vrc; stages[pipeline.nb_stages].funcs = video_recorder_funcs; pipeline.nb_stages++; #endif */ stages[pipeline.nb_stages].type = VP_API_OUTPUT_LCD; stages[pipeline.nb_stages].cfg = (void*)&vec; stages[pipeline.nb_stages].funcs = video_stage_funcs; pipeline.nb_stages++; pipeline.stages = &stages[0]; if( !ardrone_tool_exit() ) { PRINT("\nvideo stage thread initialisation\n\n"); // NICK video_stage_init(); res = vp_api_open(&pipeline, &pipeline_handle); if( VP_SUCCEEDED(res) ) { int loop = VP_SUCCESS; out.status = VP_API_STATUS_PROCESSING; #ifdef RECORD_VIDEO { DEST_HANDLE dest; dest.stage = 2; dest.pipeline = pipeline_handle; vp_api_post_message( dest, PIPELINE_MSG_START, NULL, (void*)NULL); } #endif video_stage_in_pause = FALSE; while( !ardrone_tool_exit() && (loop == VP_SUCCESS) ) { if(video_stage_in_pause) { vp_os_mutex_lock(&video_stage_mutex); icc.num_retries = VIDEO_MAX_RETRIES; vp_os_cond_wait(&video_stage_condition); vp_os_mutex_unlock(&video_stage_mutex); } if( VP_SUCCEEDED(vp_api_run(&pipeline, &out)) ) { if( (out.status == VP_API_STATUS_PROCESSING || out.status == VP_API_STATUS_STILL_RUNNING) ) { loop = VP_SUCCESS; } } else loop = -1; // Finish this thread } vp_api_close(&pipeline, &pipeline_handle); } } PRINT(" video stage thread ended\n\n"); return (THREAD_RET)0; }
DEFINE_THREAD_ROUTINE( navdata_update, nomParams ) { C_RESULT res; int32_t i, size; uint32_t cks, navdata_cks, sequence = NAVDATA_SEQUENCE_DEFAULT-1; struct timeval tv; #ifdef _WIN32 int timeout_for_windows=1000/*milliseconds*/; #endif navdata_t* navdata = (navdata_t*) &navdata_buffer[0]; tv.tv_sec = 1/*second*/; tv.tv_usec = 0; res = C_OK; if( VP_FAILED(vp_com_open(COM_NAVDATA(), &navdata_socket, &navdata_read, &navdata_write)) ) { printf("VP_Com : Failed to open socket for navdata\n"); res = C_FAIL; } if( VP_SUCCEEDED(res) ) { PRINT("Thread navdata_update in progress...\n"); #ifdef _WIN32 setsockopt((int32_t)navdata_socket.priv, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout_for_windows, sizeof(timeout_for_windows)); /* Added by Stephane to force the drone start sending data. */ if(navdata_write) { int sizeinit = 5; navdata_write( (void*)&navdata_socket, (int8_t*)"Init", &sizeinit ); } #else setsockopt((int32_t)navdata_socket.priv, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof(tv)); #endif i = 0; while( ardrone_navdata_handler_table[i].init != NULL ) { // if init failed for an handler we set its process function to null // We keep its release function for cleanup if( VP_FAILED( ardrone_navdata_handler_table[i].init(ardrone_navdata_handler_table[i].data) ) ) ardrone_navdata_handler_table[i].process = NULL; i ++; } navdata_thread_in_pause = FALSE; while( VP_SUCCEEDED(res) && !ardrone_tool_exit() && bContinue ) { if(navdata_thread_in_pause) { vp_os_mutex_lock(&navdata_client_mutex); num_retries = NAVDATA_MAX_RETRIES + 1; vp_os_cond_wait(&navdata_client_condition); vp_os_mutex_unlock(&navdata_client_mutex); } if( navdata_read == NULL ) { res = C_FAIL; continue; } size = NAVDATA_MAX_SIZE; navdata->header = 0; // Soft reset res = navdata_read( (void*)&navdata_socket, (int8_t*)&navdata_buffer[0], &size ); #ifdef _WIN32 if( size <= 0 ) #else if( size == 0 ) #endif { // timeout PRINT("Timeout\n"); ardrone_navdata_open_server(); sequence = NAVDATA_SEQUENCE_DEFAULT-1; num_retries++; } else num_retries = 0; if( VP_SUCCEEDED( res ) ) { if( navdata->header == NAVDATA_HEADER ) { if( ardrone_get_mask_from_state(navdata->ardrone_state, ARDRONE_COM_WATCHDOG_MASK) ) { // reset sequence number because of com watchdog // This code is mandatory because we can have a com watchdog without detecting it on mobile side : // Reconnection is fast enough (less than one second) sequence = NAVDATA_SEQUENCE_DEFAULT-1; if( ardrone_get_mask_from_state(navdata->ardrone_state, ARDRONE_NAVDATA_BOOTSTRAP) == FALSE ) ardrone_tool_send_com_watchdog(); // acknowledge } if( navdata->sequence > sequence ) { i = 0; ardrone_navdata_unpack_all(&navdata_unpacked, navdata, &navdata_cks); cks = ardrone_navdata_compute_cks( &navdata_buffer[0], size - sizeof(navdata_cks_t) ); if( cks == navdata_cks ) { while( ardrone_navdata_handler_table[i].init != NULL ) { if( ardrone_navdata_handler_table[i].process != NULL ) ardrone_navdata_handler_table[i].process( &navdata_unpacked ); i++; } } else { PRINT("[Navdata] Checksum failed : %d (distant) / %d (local)\n", navdata_cks, cks); } } else { PRINT("[Navdata] Sequence pb : %d (distant) / %d (local)\n", navdata->sequence, sequence); } // remaining = sizeof(navdata); sequence = navdata->sequence; } } } // Release resources alllocated by handlers i = 0; while( ardrone_navdata_handler_table[i].init != NULL ) { ardrone_navdata_handler_table[i].release(); i ++; } } vp_com_close(COM_NAVDATA(), &navdata_socket); DEBUG_PRINT_SDK("Thread navdata_update ended\n"); return (THREAD_RET)res; }
DEFINE_THREAD_ROUTINE(main_application_thread, data) { /* Mutexes for synchronisation */ vp_os_mutex_init(&test_mutex); vp_os_cond_init(&test_condition,&test_mutex); vp_os_delay(1000); //fflush(stdin); printf("[IMPORTANT] Please check you deleted all configuration files on the drone before starting.\n"); printf("\n Resetting the drone to the default configuration \n"); /* Switch to the default configuration file */ /* Always start by setting the session, then the application, then the user */ set_string(session_id,"00000000"); set_string(application_id,"00000000"); set_string(profile_id,"00000000"); /* Suppress all other settings. A session and an application were automatically created * at application startup by ARDrone Tool ; we must delete them. * The '-' symbol means 'delete'. * '-all' deletes all the existing configurations. */ set_string(session_id,"-all"); set_string(application_id,"-all"); set_string(profile_id,"-all"); set_int(navdata_demo,1); mypause(); /* Ask the drone configuration and compare it to the expected values */ /* Send time to the drone */ //gettimeofday(&tv,NULL); //set_int(time,(int32_t)tv.tv_sec); title("\nGetting the drone configuration ...\n"); ARDRONE_TOOL_CONFIGURATION_GET(test_callback); vp_os_cond_wait(&test_condition); title("Comparing received values to the config_keys.h defaults ...\n"); #define ARDRONE_CONFIG_KEY_IMM_a9(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK,SCOPE) \ test_float(NAME,DEFAULT); #undef ARDRONE_CONFIG_KEY_REF_a9 #define ARDRONE_CONFIG_KEY_STR_a9(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK,SCOPE) \ test_string(NAME,DEFAULT); #include <config_keys.h> /* Modify one value of each category and see what happens */ /* To test the 'COMMON' category */ set_string(ardrone_name,"TEST_CONFIG"); /* To test the 'APPLIS' category */ test_nint(bitrate_ctrl_mode,1); /* 0 is the default value */ set_int(bitrate_ctrl_mode,1); /* To test the 'PROFILE' (aka. 'USER') category */ test_nfloat(outdoor_euler_angle_max,F1); set_float(outdoor_euler_angle_max,F1); /* To test the 'SESSION' category */ test_string(leds_anim,"0,0,0"); set_string(leds_anim,"1,1,1"); test_string(application_id,"00000000"); test_string(profile_id,"00000000"); test_string(session_id,"00000000"); title("\nGetting the drone configuration ...\n"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG"); /* CAT_COMMON param */ test_int(bitrate_ctrl_mode,1); /* CAT_APPLI param */ test_float(outdoor_euler_angle_max,F1); /* CAT_USER param */ test_string(leds_anim,"1,1,1"); /* CAT_SESSION param */ test_string(application_id,"00000000"); test_string(profile_id,"00000000"); test_string(session_id,"00000000"); test_string(application_desc , DEFAULT_APPLICATION_DESC); test_string(profile_desc, DEFAULT_PROFILE_DESC); test_string(session_desc, DEFAULT_SESSION_DESC); /*---------------------------------------------------------------------------------------------------------*/ /* Create an application configuration file */ title("\nCreating the application ID 11111111 ...\n"); set_string(application_id,"11111111"); set_string(application_desc,APPDESC1); title("\nGetting the drone configuration ...\n"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG"); /* CAT_COMMON param; its value should not be changed by creating an application config. */ test_int(bitrate_ctrl_mode,0); /* 0 is the default value ; default values are affected to newly created configurations */ test_float(outdoor_euler_angle_max,F1); /* CAT_USER param ; its value should not be changed by creating an application config. */ test_int(detect_type,CAD_TYPE_NONE); /* CAT_SESSION param; its value should not be changed by creating an application config. */ test_string(application_id,"11111111"); test_string(profile_id,"00000000"); test_string(session_id,"00000000"); test_string(application_desc,APPDESC1); test_string(profile_desc, DEFAULT_PROFILE_DESC); test_string(session_desc, DEFAULT_SESSION_DESC); set_int(bitrate_ctrl_mode,1); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG"); test_int(bitrate_ctrl_mode,1); set_int(bitrate_ctrl_mode,0); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG"); test_int(bitrate_ctrl_mode,0); mypause(); title("\nGoing back to the default application configuration ...\n"); set_string(application_id,"00000000"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG"); test_int(bitrate_ctrl_mode,1); /* 1 was the value of the config.ini configuration */ test_float(outdoor_euler_angle_max,F1); test_int(detect_type,CAD_TYPE_NONE); test_string(application_id,"00000000"); test_string(profile_id,"00000000"); test_string(session_id,"00000000"); test_string(application_desc,DEFAULT_APPLICATION_DESC); test_string(profile_desc, DEFAULT_PROFILE_DESC); test_string(session_desc, DEFAULT_SESSION_DESC); mypause(); title(" Going back to the newly created application configuration ...\n"); set_string(application_id,"11111111"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG"); test_int(bitrate_ctrl_mode,0); test_float(outdoor_euler_angle_max,F1); test_int(detect_type,CAD_TYPE_NONE); test_string(application_id,"11111111"); test_string(profile_id,"00000000"); test_string(session_id,"00000000"); test_string(application_desc , APPDESC1); test_string(profile_desc, DEFAULT_PROFILE_DESC); test_string(session_desc, DEFAULT_SESSION_DESC); set_string(application_id,"00000000"); mypause(); /*-----------------------------------------------------------------------------------------------*/ /* Create a user profile configuration file */ title("\nCreating the user profile ID 22222222 ...\n"); set_string(profile_id,"22222222"); set_string(profile_desc,PROFDESC2); title("\nGetting the drone configuration ...\n"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG"); test_int(bitrate_ctrl_mode,1); /* 1 was the value of the config.ini configuration */ test_float(outdoor_euler_angle_max,default_outdoor_euler_angle_ref_max); test_int(detect_type,CAD_TYPE_NONE); test_string(application_id,"00000000"); test_string(profile_id,"22222222"); test_string(session_id,"00000000"); test_string(application_desc , DEFAULT_APPLICATION_DESC); test_string(profile_desc, PROFDESC2);//DEFAULT_PROFILE_DESC test_string(session_desc, DEFAULT_SESSION_DESC); set_float(outdoor_euler_angle_max,F2); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} mypause(); title("\nGoing back to the default user profile configuration ...\n"); set_string(profile_id,"00000000"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} /* The default value for this is 1 after the first test */ test_string(ardrone_name,"TEST_CONFIG"); test_int(bitrate_ctrl_mode,1); /* 1 was the value of the config.ini configuration */ test_float(outdoor_euler_angle_max,F1); test_int(detect_type,CAD_TYPE_NONE); test_string(application_id,"00000000"); test_string(profile_id,"00000000"); test_string(session_id,"00000000"); test_string(application_desc , DEFAULT_APPLICATION_DESC); test_string(profile_desc, DEFAULT_PROFILE_DESC); test_string(session_desc, DEFAULT_SESSION_DESC); mypause(); title(" Going back to the newly created user profile configuration ...\n"); set_string(profile_id,"22222222"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG"); test_int(bitrate_ctrl_mode,1); /* 1 was the value of the config.ini configuration */ test_float(outdoor_euler_angle_max,F2); test_int(detect_type,CAD_TYPE_NONE); test_string(ardrone_name,"TEST_CONFIG"); test_string(application_id,"00000000"); test_string(profile_id,"22222222"); test_string(session_id,"00000000"); test_string(application_desc , DEFAULT_APPLICATION_DESC); test_string(profile_desc, PROFDESC2);//DEFAULT_PROFILE_DESC test_string(session_desc, DEFAULT_SESSION_DESC); set_string(profile_id,"00000000"); mypause(); /*-----------------------------------------------------------------------------------------------*/ /* Create a session configuration file */ title("\nCreating the session ID 33333333 ...\n"); set_string(session_id,"33333333"); title("\nGetting the drone configuration ...\n"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG"); /* CAT_COMMON param; its value should not be changed by creating a session */ test_int(bitrate_ctrl_mode,1); /* CAT_APPLI param; its value should not be changed by creating a session */ test_float(outdoor_euler_angle_max,F1); /* value in default config.ini */ test_int(detect_type,CAD_TYPE_NONE); /* CAT_SESSION param; its value should be the default one */ test_string(application_id,"00000000"); test_string(profile_id,"00000000"); test_string(session_id,"33333333"); test_string(application_desc , DEFAULT_APPLICATION_DESC); test_string(profile_desc, DEFAULT_PROFILE_DESC); test_string(session_desc, DEFAULT_SESSION_DESC ); //DEFAULT_SESSION_DESC); /* Test changing a value in the session */ set_int(detect_type,CAD_TYPE_VISION); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_int(detect_type,CAD_TYPE_VISION); mypause(); title("\nGoing back to the default session configuration ...\n"); set_string(session_id,"00000000"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG"); test_int(bitrate_ctrl_mode,1); /* value in default config.ini */ test_float(outdoor_euler_angle_max,F1); /* value in default config.ini */ test_int(detect_type,CAD_TYPE_NONE); test_string(application_id,"00000000"); test_string(profile_id,"00000000"); test_string(session_id,"00000000"); test_string(application_desc , DEFAULT_APPLICATION_DESC); test_string(profile_desc, DEFAULT_PROFILE_DESC); test_string(session_desc, DEFAULT_SESSION_DESC); mypause(); title(" Going back to the newly created session configuration ...\n"); set_string(session_id,"33333333"); set_string(session_desc,SESSDESC3); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG"); test_int(bitrate_ctrl_mode,1); /* value in default config.ini */ test_float(outdoor_euler_angle_max,F1); /* value in default config.ini */ test_int(detect_type,CAD_TYPE_VISION); test_string(ardrone_name,"TEST_CONFIG"); test_string(application_id,"00000000"); test_string(profile_id,"00000000"); test_string(session_id,"33333333"); test_string(application_desc , DEFAULT_APPLICATION_DESC); test_string(profile_desc, DEFAULT_PROFILE_DESC); test_string(session_desc, SESSDESC3 ); //DEFAULT_SESSION_DESC); set_int(detect_type,CAD_TYPE_COCARDE); set_string(session_id,"00000000"); mypause(); /*-----------------------------------------------------------------------------------------------*/ /* Create a session configuration file */ title("\nCreating the session ID 44444444 ...\n"); set_string(session_id,"44444444"); title("\nGetting the drone configuration ...\n"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_int(detect_type,CAD_TYPE_NONE); test_string(ardrone_name,"TEST_CONFIG"); test_int(bitrate_ctrl_mode,1); test_string(application_id,"00000000"); test_string(profile_id,"00000000"); test_string(session_id,"44444444"); test_string(application_desc , DEFAULT_APPLICATION_DESC); test_string(profile_desc, DEFAULT_PROFILE_DESC); test_string(session_desc, DEFAULT_SESSION_DESC ); //FAULT_SESSION_DESC); set_int(detect_type,CAD_TYPE_VISION); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_int(detect_type,CAD_TYPE_VISION); set_string(application_id,"11111111"); set_string(profile_id,"22222222"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG"); set_string(ardrone_name,"TEST_CONFIG2"); test_string(application_id,"11111111"); test_string(profile_id,"22222222"); test_string(session_id,"44444444"); test_string(application_desc , APPDESC1); test_string(profile_desc, PROFDESC2); test_string(session_desc, DEFAULT_SESSION_DESC); mypause(); while(1){ title("\nGoing back to the default session ...\n"); set_string(session_id,"00000000"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG2"); test_int(bitrate_ctrl_mode,1); test_string(application_id,"00000000"); test_string(profile_id,"00000000"); test_string(session_id,"00000000"); test_string(application_desc , DEFAULT_APPLICATION_DESC); test_string(profile_desc, DEFAULT_PROFILE_DESC); test_string(session_desc, DEFAULT_SESSION_DESC); mypause(); title("\nGoing back to the 44444444 session ...\n"); set_string(session_id,"44444444"); set_string(session_desc,SESSDESC4); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG2"); test_int(bitrate_ctrl_mode,0); test_string(application_id,"11111111"); test_string(profile_id,"22222222"); test_string(session_id,"44444444"); test_string(application_desc , APPDESC1); test_string(profile_desc, PROFDESC2); test_string(session_desc, SESSDESC4); mypause(); title("\nGoing back to the default session ...\n"); set_string(session_id,"00000000"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG2"); set_string(ardrone_name,"TEST_CONFIG3"); test_string(application_id,"00000000"); test_string(profile_id,"00000000"); test_string(session_id,"00000000"); test_string(application_desc , DEFAULT_APPLICATION_DESC); test_string(profile_desc, DEFAULT_PROFILE_DESC); test_string(session_desc, DEFAULT_SESSION_DESC); mypause(); title(" Going back to the 33333333 session ...\n"); set_string(session_id,"33333333"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG3"); test_int(bitrate_ctrl_mode,1); /* value in default config.ini */ test_float(outdoor_euler_angle_max,F1); /* value in default config.ini */ test_int(detect_type,CAD_TYPE_COCARDE); test_string(application_id,"00000000"); test_string(profile_id,"00000000"); test_string(session_id,"33333333"); test_string(application_desc , DEFAULT_APPLICATION_DESC); test_string(profile_desc, DEFAULT_PROFILE_DESC); test_string(session_desc, SESSDESC3); mypause(); title("\nGoing back to the 44444444 session ...\n"); set_string(session_id,"44444444"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG3"); set_string(ardrone_name,"TEST_CONFIG4"); test_int(bitrate_ctrl_mode,0); test_float(outdoor_euler_angle_max,F2); test_int(detect_type,CAD_TYPE_VISION); test_string(application_id,"11111111"); test_string(profile_id,"22222222"); test_string(session_id,"44444444"); test_string(application_desc , APPDESC1); test_string(profile_desc, PROFDESC2); test_string(session_desc, SESSDESC4); mypause(); title(" Going back to the 33333333 session ...\n"); set_string(session_id,"33333333"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_int(bitrate_ctrl_mode,1); test_int(detect_type,CAD_TYPE_COCARDE); test_string(ardrone_name,"TEST_CONFIG4"); test_int(bitrate_ctrl_mode,1); test_float(outdoor_euler_angle_max,F1); test_string(application_id,"00000000"); test_string(profile_id,"00000000"); test_string(session_id,"33333333"); test_string(application_desc , DEFAULT_APPLICATION_DESC); test_string(profile_desc, DEFAULT_PROFILE_DESC); test_string(session_desc, SESSDESC3); mypause(); title("\nGoing back to the default session ...\n"); set_string(session_id,"00000000"); {ARDRONE_TOOL_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} test_string(ardrone_name,"TEST_CONFIG4"); /* common parameter whose value should never be reset */ test_int(bitrate_ctrl_mode,1); test_float(outdoor_euler_angle_max,F1); test_int(detect_type,CAD_TYPE_NONE); test_string(application_id,"00000000"); test_string(profile_id,"00000000"); test_string(session_id,"00000000"); test_string(application_desc , DEFAULT_APPLICATION_DESC); test_string(profile_desc, DEFAULT_PROFILE_DESC); test_string(session_desc, DEFAULT_SESSION_DESC); set_string(ardrone_name,"TEST_CONFIG2"); mypause(); /*-----------------------------------------------------------------------------------------------*/ /* Read the list of custom configurations */ title("\nReading the list of custom configuration files ...\n"); {ARDRONE_TOOL_CUSTOM_CONFIGURATION_GET(test_callback);vp_os_cond_wait(&test_condition);} printf("\n\n ====================================== \n\n"); if(available_configurations[CAT_APPLI].nb_configurations!=1) { printf("Bad number of custom applis.\n"); } if(available_configurations[CAT_USER].nb_configurations!=1) { printf("Bad number of custom applis.\n"); } if(available_configurations[CAT_SESSION].nb_configurations!=2) { printf("Bad number of custom applis.\n"); } if (available_configurations[CAT_APPLI].list[0].id==NULL) { printf("Unexpected custom app 0 NULL\n"); } else if (strcmp(available_configurations[CAT_APPLI].list[0].id,"11111111")) { printf("Unexpected custom app : <%s>\n",available_configurations[CAT_APPLI].list[0].id); } if (available_configurations[CAT_USER].list[0].id==NULL) { printf("Unexpected custom user 0 NULL\n"); } else if (strcmp(available_configurations[CAT_USER].list[0].id,"22222222")) { printf("Unexpected custom profile : <%s>\n",available_configurations[CAT_USER].list[0].id); } if (available_configurations[CAT_SESSION].list[0].id==NULL) { printf("Unexpected custom session 0 NULL\n"); } else if (strcmp(available_configurations[CAT_SESSION].list[0].id,"33333333")) { printf("Unexpected custom session 0 : <%s>\n",available_configurations[CAT_SESSION].list[0].id); } if (available_configurations[CAT_SESSION].list[1].id==NULL) { printf("Unexpected custom session 1 NULL\n"); } else if (strcmp(available_configurations[CAT_SESSION].list[1].id,"44444444")) { printf("Unexpected custom session 1 : <%s>\n",available_configurations[CAT_SESSION].list[1].id); } if (available_configurations[CAT_APPLI].list[0].description==NULL) { printf("Unexpected custom appli descrition 0 NULL\n"); } else if (strcmp(available_configurations[CAT_APPLI].list[0].description,APPDESC1)) { printf("Unexpected custom app description : <%s>\n",available_configurations[CAT_APPLI].list[0].description); } if (available_configurations[CAT_USER].list[0].description==NULL) { printf("Unexpected custom user 0 description NULL\n"); } else if (strcmp(available_configurations[CAT_USER].list[0].description,PROFDESC2)) { printf("Unexpected custom profile description : <%s>\n",available_configurations[CAT_USER].list[0].description); } if (available_configurations[CAT_SESSION].list[0].description==NULL) { printf("Unexpected custom session 0 description NULL\n"); } else if (strcmp(available_configurations[CAT_SESSION].list[0].description,SESSDESC3)) { printf("Unexpected custom session 0 description : <%s>\n",available_configurations[CAT_SESSION].list[0].description); } if (available_configurations[CAT_SESSION].list[1].description==NULL) { printf("Unexpected custom session 1 description NULL\n"); } else if (strcmp(available_configurations[CAT_SESSION].list[1].description,SESSDESC4)) { printf("Unexpected custom session 1 description : <%s>\n",available_configurations[CAT_SESSION].list[1].description); } printf(" Custom config list checked.\n"); mypause(); /*-----------------------------------------------------------------------------------------------*/ printf("\n\n ====================================== \n\n"); title("\nEnd of the test.\n"); } }
DEFINE_THREAD_ROUTINE(video_recorder, data) { if (1 >= ARDRONE_VERSION ()) // Run only for ARDrone 2 and upper { return (THREAD_RET)0; } C_RESULT res = C_OK; vp_api_io_pipeline_t pipeline; vp_api_io_data_t out; vp_api_io_stage_t stages[3]; PIPELINE_HANDLE video_recorder_pipeline_handle; video_recorder_thread_param_t *video_recorder_thread_param = (video_recorder_thread_param_t *)data; video_stage_tcp_config_t tcpConf; if(video_recorder_thread_param != NULL) { CHANGE_THREAD_PRIO(video_recorder, video_recorder_thread_param->priority); video_stage_encoded_recorder_config.finish_callback = video_recorder_thread_param->finish_callback; } vp_os_memset (&record_icc, 0x0, sizeof (record_icc)); record_icc.com = COM_VIDEO (); record_icc.buffer_size = (8*1024); record_icc.protocol = VP_COM_TCP; record_icc.forceNonBlocking = &tcpConf.tcpStageHasMoreData; COM_CONFIG_SOCKET_VIDEO (&record_icc.socket, VP_COM_CLIENT, VIDEO_RECORDER_PORT, wifi_ardrone_ip); record_icc.timeoutFunc = &video_stage_encoded_recorder_com_timeout; record_icc.timeoutFuncAfterSec = 10; vp_os_memset (&tcpConf, 0, sizeof (tcpConf)); tcpConf.maxPFramesPerIFrame = 30; tcpConf.frameMeanSize = 160*1024; tcpConf.latencyDrop = 0; pipeline.nb_stages = 0; pipeline.stages = &stages[0]; // Com stages[pipeline.nb_stages].type = VP_API_INPUT_SOCKET; stages[pipeline.nb_stages].cfg = (void *)&record_icc; stages[pipeline.nb_stages++].funcs = video_com_funcs; // TCP stages[pipeline.nb_stages].type = VP_API_FILTER_DECODER; stages[pipeline.nb_stages].cfg = (void *) &tcpConf; stages[pipeline.nb_stages++].funcs = video_stage_tcp_funcs; // Record stages[pipeline.nb_stages].type = VP_API_FILTER_DECODER; stages[pipeline.nb_stages].cfg = (void *) &video_stage_encoded_recorder_config; stages[pipeline.nb_stages++].funcs = video_encoded_recorder_funcs; while (FALSE == isInit) { printf ("Waiting for init\n"); } if (! ardrone_tool_exit ()) { PRINT ("Video recorder thread initialisation\n"); res = vp_api_open (&pipeline, &video_recorder_pipeline_handle); if (SUCCEED (res)) { int loop = SUCCESS; out.status = VP_API_STATUS_PROCESSING; while (! ardrone_tool_exit () && (SUCCESS == loop)) { if (video_recorder_in_pause) { vp_os_mutex_lock (&video_recorder_mutex); record_icc.num_retries = VIDEO_MAX_RETRIES; vp_os_cond_wait (&video_recorder_condition); vp_os_mutex_unlock (&video_recorder_mutex); } if (SUCCEED (vp_api_run (&pipeline, &out))) { if ((VP_API_STATUS_PROCESSING == out.status) || (VP_API_STATUS_STILL_RUNNING == out.status)) { loop = SUCCESS; } else loop = -1; } else loop = -1; } vp_api_close (&pipeline, &video_recorder_pipeline_handle); } } PRINT ("Video recorder thread ended\n"); return (THREAD_RET)res; }
DEFINE_THREAD_ROUTINE(academy_upload, data) { char *directoryList = NULL; char *fileList = NULL; char dirname[ACADEMY_MAX_FILENAME]; _ftp_t *academy_ftp = NULL; _ftp_status academy_status; char *ptr = NULL; academy_upload_t *academy = (academy_upload_t *)data; printf("Start thread %s\n", __FUNCTION__); while( academy_upload_started && !ardrone_tool_exit() ) { vp_os_mutex_lock(&academy->mutex); vp_os_memset(&academy->user, 0, sizeof(academy_user_t)); academy->callback = &academy_upload_private_callback; academy->connected = FALSE; academy_upload_resetState(academy); vp_os_cond_wait(&academy->cond); vp_os_mutex_unlock(&academy->mutex); while(academy_upload_started && academy->connected) { academy_status = FTP_FAIL; academy_upload_nextState(academy); switch(academy->state.state) { case ACADEMY_STATE_CONNECTION: { struct dirent *dirent = NULL; DIR *dir = NULL; academy_status = FTP_FAIL; // Check if flight_* directory exist in local dir if((dir = opendir(flight_dir)) != NULL) { struct stat statbuf; while(FTP_FAILED(academy_status) && (dirent = readdir(dir)) != NULL) { if((strncmp(dirent->d_name, "flight_", strlen("flight_")) == 0)) { char local_dir[ACADEMY_MAX_FILENAME]; sprintf(dirname, "%s", dirent->d_name); sprintf(local_dir, "%s/%s", flight_dir, dirname); if((stat(local_dir, &statbuf) == 0) && S_ISDIR(statbuf.st_mode)) academy_status = FTP_SUCCESS; } } closedir(dir); } if(FTP_SUCCEDED(academy_status)) { if(academy_ftp == NULL) academy_ftp = ftpConnectFromName(ACADEMY_SERVERNAME, ACADEMY_PORT, academy->user.username, academy->user.password, &academy_status); } } break; case ACADEMY_STATE_PREPARE_PROCESS: academy_status = ftpCd(academy_ftp, "/Uploaded"); if(FTP_FAILED(academy_status)) { ftpMkdir(academy_ftp, "/Uploaded"); academy_status = ftpCd(academy_ftp, "/Uploaded"); } if(FTP_SUCCEDED(academy_status)) { academy_status = ftpList(academy_ftp, &directoryList, NULL); if(FTP_SUCCEDED(academy_status)) { bool_t found = FALSE; char *next_dir = NULL; while(!found && (ptr = academy_get_next_item_with_prefix(directoryList, &next_dir, "flight_", TRUE))) { if(strcmp(ptr, dirname) == 0) { found = TRUE; academy_upload_setState(academy, ACADEMY_STATE_FINISH_PROCESS); } } if(directoryList != NULL) { vp_os_free(directoryList); directoryList = NULL; } } } break; case ACADEMY_STATE_PROCESS: academy_status = ftpCd(academy_ftp, "/Uploading"); if(FTP_FAILED(academy_status)) { ftpMkdir(academy_ftp, "/Uploading"); academy_status = ftpCd(academy_ftp, "/Uploading"); } if(FTP_SUCCEDED(academy_status)) { ftpMkdir(academy_ftp, dirname); academy_status = ftpCd(academy_ftp, dirname); if(FTP_SUCCEDED(academy_status)) { char local_dir[ACADEMY_MAX_FILENAME]; struct dirent *dirent = NULL; DIR *dir = NULL; sprintf(local_dir, "%s/%s", flight_dir, dirname); if((dir = opendir(local_dir)) != NULL) { char local_filename[ACADEMY_MAX_FILENAME]; struct stat statbuf; while(FTP_SUCCEDED(academy_status) && ((dirent = readdir(dir)) != NULL)) { if((strncmp(dirent->d_name, "picture_", strlen("picture_")) == 0) || (strncmp(dirent->d_name, "userbox_", strlen("userbox_")) == 0)) { sprintf(local_filename, "%s/%s", local_dir, dirent->d_name); if((stat(local_filename, &statbuf) == 0) && !S_ISDIR(statbuf.st_mode)) { PA_DEBUG("Put %s from local directory to server...", dirent->d_name); academy_status = ftpPut(academy_ftp, local_filename, dirent->d_name, 1, NULL); if(FTP_SUCCEDED(academy_status)) PA_DEBUG("OK\n"); else PA_DEBUG("ERROR\n"); } } } closedir(dir); } } } break; case ACADEMY_STATE_FINISH_PROCESS: { char local_dir[ACADEMY_MAX_FILENAME]; char src[ACADEMY_MAX_FILENAME]; char dest[ACADEMY_MAX_FILENAME]; sprintf(src, "/Uploading/%s", dirname); sprintf(dest, "/Uploaded/%s", dirname); academy_status = ftpRename(academy_ftp, src, dest); // Penser à supprimer le fichier local academy_status = FTP_FAIL; sprintf(local_dir, "%s/%s", flight_dir, dirname); if(!ftw(local_dir, &academy_remove, 1)) { rmdir(local_dir); academy_status = FTP_SUCCESS; } } break; case ACADEMY_STATE_DISCONNECTION: if(academy_ftp != NULL) ftpClose(&academy_ftp); academy_status = FTP_SUCCESS; break; default: // Nothing to do break; } if(FTP_SUCCEDED(academy_status)) { PA_DEBUG("continue state from %d to %d\n", academy->state.state, (academy->state.state + 1) % ACADEMY_STATE_MAX); academy_upload_stateOK(academy); } else { PA_DEBUG("stop\n"); academy_upload_stateERROR(academy); if(fileList != NULL) { vp_os_free(fileList); fileList = NULL; } if(academy_ftp) ftpClose(&academy_ftp); vp_os_delay(1000); } } if(fileList != NULL) { vp_os_free(fileList); fileList = NULL; } if(academy_ftp) ftpClose(&academy_ftp); } // while THREAD_RETURN(C_OK); }
DEFINE_THREAD_ROUTINE(video_stage, data) { C_RESULT res; vp_api_io_pipeline_t pipeline; vp_api_io_data_t out; vp_api_io_stage_t * stages; video_stage_merge_slices_config_t merge_slices_cfg; uint8_t i; specific_parameters_t * params = (specific_parameters_t *)(data); if (1 == params->needSetPriority) { CHANGE_THREAD_PRIO (video_stage, params->priority); } vp_os_memset(&icc_tcp, 0, sizeof ( icc_tcp)); vp_os_memset(&icc_udp, 0, sizeof ( icc_udp)); // Video Communication config icc_tcp.com = COM_VIDEO(); icc_tcp.buffer_size = (1024*1024); icc_tcp.protocol = VP_COM_TCP; COM_CONFIG_SOCKET_VIDEO(&icc_tcp.socket, VP_COM_CLIENT, VIDEO_PORT, wifi_ardrone_ip); // Video Communication config icc_udp.com = COM_VIDEO(); icc_udp.buffer_size = (1024*1024); icc_udp.protocol = VP_COM_UDP; COM_CONFIG_SOCKET_VIDEO(&icc_udp.socket, VP_COM_CLIENT, VIDEO_PORT, wifi_ardrone_ip); icc.nb_sockets = 2; icc.configs = icc_tab; icc.forceNonBlocking = &(tcpConf.tcpStageHasMoreData); icc_tab[1] = &icc_tcp; icc_tab[0] = &icc_udp; icc.buffer_size = (1024*1024); vp_os_memset(&vec, 0, sizeof ( vec)); stages = (vp_api_io_stage_t*) (vp_os_calloc( NB_STAGES + params->pre_processing_stages_list->length + params->post_processing_stages_list->length, sizeof (vp_api_io_stage_t) )); vec.src_picture = params->in_pic; vec.dst_picture = params->out_pic; vp_os_memset(&tcpConf, 0, sizeof ( tcpConf)); tcpConf.maxPFramesPerIFrame = 30; tcpConf.frameMeanSize = 160*1024; tcpConf.tcpStageHasMoreData = FALSE; tcpConf.latencyDrop = 1; pipeline.name = "video_stage_pipeline"; pipeline.nb_stages = 0; pipeline.stages = &stages[0]; //ENCODED FRAME PROCESSING STAGES stages[pipeline.nb_stages].type = VP_API_INPUT_SOCKET; stages[pipeline.nb_stages].cfg = (void *) &icc; stages[pipeline.nb_stages++].funcs = video_com_multisocket_funcs; printf("thread_video_stage: adding multisocket_funcs as %d th stage (input type) to video_pipeline of AR.Drone with version %d.%d.%d\n", pipeline.nb_stages, ardroneVersion.majorVersion, ardroneVersion.minorVersion, ardroneVersion.revision ); stages[pipeline.nb_stages].type = VP_API_FILTER_DECODER; stages[pipeline.nb_stages].cfg = (void *) &tcpConf; stages[pipeline.nb_stages++].funcs = video_stage_tcp_funcs; printf("thread_video_stage: adding tcp_funcs to video_pipeline as %d nd stage (filter type) of AR.Drone\n", pipeline.nb_stages ); // Record Encoded video if(1 == ARDRONE_VERSION()) { ardrone_academy_stage_recorder_config.dest.pipeline = video_pipeline_handle; ardrone_academy_stage_recorder_config.dest.stage = pipeline.nb_stages; stages[pipeline.nb_stages].type = VP_API_FILTER_DECODER; stages[pipeline.nb_stages].cfg = (void*)&ardrone_academy_stage_recorder_config; stages[pipeline.nb_stages++].funcs = ardrone_academy_stage_recorder_funcs; printf("thread_video_stage: adding academy_recorder_funcs to video_pipeline as %d rd stage (filter type) of AR.Drone\n", pipeline.nb_stages ); } else { // Nothing to do for AR.Drone 2 as we have a separated thread for recording } //PRE-DECODING STAGES ==> recording, ... for(i=0;i<params->pre_processing_stages_list->length;i++){ stages[pipeline.nb_stages].type = params->pre_processing_stages_list->stages_list[i].type; stages[pipeline.nb_stages].cfg = params->pre_processing_stages_list->stages_list[i].cfg; stages[pipeline.nb_stages++].funcs = params->pre_processing_stages_list->stages_list[i].funcs; } printf("thread_video_stage: adding pre_processing_stages_list to video_pipeline (now %d stages) of AR.Drone\n", pipeline.nb_stages ); stages[pipeline.nb_stages].type = VP_API_FILTER_DECODER; stages[pipeline.nb_stages].cfg = (void *)&merge_slices_cfg; stages[pipeline.nb_stages++].funcs = video_stage_merge_slices_funcs; printf("thread_video_stage: adding merge_slices_funcs to video_pipeline (now %d stages) of AR.Drone\n", pipeline.nb_stages ); //DECODING STAGES stages[pipeline.nb_stages].type = VP_API_FILTER_DECODER; stages[pipeline.nb_stages].cfg = (void*) &vec; stages[pipeline.nb_stages++].funcs = video_decoding_funcs; printf("thread_video_stage: adding video_decoding_funcs to video_pipeline (now %d stages) of AR.Drone\n", pipeline.nb_stages ); //POST-DECODING STAGES ==> transformation, display, ... for(i=0;i<params->post_processing_stages_list->length;i++){ stages[pipeline.nb_stages].type = params->post_processing_stages_list->stages_list[i].type; stages[pipeline.nb_stages].cfg = params->post_processing_stages_list->stages_list[i].cfg; stages[pipeline.nb_stages++].funcs = params->post_processing_stages_list->stages_list[i].funcs; } printf("thread_video_stage: adding post_processing_stages_list to video_pipeline (now %d stages) of AR.Drone\n", pipeline.nb_stages ); if (!ardrone_tool_exit()) { PRINT("\nvideo stage thread initialisation\n\n"); res = vp_api_open(&pipeline, &video_pipeline_handle); if (SUCCEED(res)) { int loop = SUCCESS; out.status = VP_API_STATUS_PROCESSING; while (!ardrone_tool_exit() && (loop == SUCCESS)) { if (video_stage_in_pause) { vp_os_mutex_lock(&video_stage_mutex); icc.num_retries = VIDEO_MAX_RETRIES; vp_os_cond_wait(&video_stage_condition); vp_os_mutex_unlock(&video_stage_mutex); } if (SUCCEED(vp_api_run(&pipeline, &out))) { if ((out.status == VP_API_STATUS_PROCESSING || out.status == VP_API_STATUS_STILL_RUNNING)) { loop = SUCCESS; } } else loop = -1; // Finish this thread } vp_os_free(params->pre_processing_stages_list->stages_list); vp_os_free(params->post_processing_stages_list->stages_list); vp_os_free(params->pre_processing_stages_list); vp_os_free(params->post_processing_stages_list); vp_os_free(params->in_pic); vp_os_free(params->out_pic); vp_os_free(params); vp_api_close(&pipeline, &video_pipeline_handle); } } PRINT("\nvideo stage thread ended\n\n"); return (THREAD_RET) 0; }