Upgrading to Parrot SDK 2.0.1
Esse commit está contido em:
@@ -13,7 +13,7 @@ else
|
||||
RELEASE_OPT="debug"
|
||||
endif
|
||||
|
||||
FFMPEG_CONFIG=decoder
|
||||
FFMPEG_CONFIG=both
|
||||
|
||||
|
||||
FFMPEG_DIR_EXIST=$(shell bash -c "if [ -d ffmpeg ]; then echo \"YES\"; else echo \"NO\"; fi")
|
||||
|
||||
Arquivo binário não exibido.
@@ -110,8 +110,8 @@ ifdef PC_TARGET
|
||||
|
||||
ifeq ("$(IPHONE_MODE)","yes")
|
||||
SDK_FLAGS+="USE_IPHONE=yes"
|
||||
SDK_FLAGS+="FFMPEG_SUPPORT=no"
|
||||
SDK_FLAGS+="ITTIAM_SUPPORT=yes"
|
||||
SDK_FLAGS+="FFMPEG_SUPPORT=yes"
|
||||
SDK_FLAGS+="ITTIAM_SUPPORT=no"
|
||||
SDK_FLAGS+="USE_VIDEO_TCP=yes"
|
||||
SDK_FLAGS+="USE_VIDEO_HD=no"
|
||||
else
|
||||
@@ -127,10 +127,10 @@ ifdef PC_TARGET
|
||||
|
||||
ifeq ("$(USE_ANDROID)","yes")
|
||||
SDK_FLAGS+="USE_ANDROID=yes"
|
||||
SDK_FLAGS+="TOOLCHAIN_VERSION=arm-linux-androideabi-4.4.3"
|
||||
SDK_FLAGS+="TOOLCHAIN_VERSION=arm-linux-androideabi-4.6"
|
||||
SDK_FLAGS+="NDK_PLATFORM_VERSION=android-8"
|
||||
SDK_FLAGS+="FFMPEG_SUPPORT=yes"
|
||||
SDK_FLAGS+="ITTIAM_SUPPORT=yes"
|
||||
SDK_FLAGS+="ITTIAM_SUPPORT=no"
|
||||
SDK_FLAGS+="USE_VIDEO_TCP=yes"
|
||||
SDK_FLAGS+="USE_VIDEO_HD=no"
|
||||
else
|
||||
|
||||
@@ -14,7 +14,7 @@ ifndef USE_ANDROID
|
||||
USE_ANDROID = no
|
||||
endif
|
||||
ifndef USE_LINUX
|
||||
USE_LINUX = yes
|
||||
USE_LINUX = no
|
||||
endif
|
||||
ifndef PROJECT
|
||||
# set default to ardrone2 for video TCP com.
|
||||
|
||||
@@ -44,6 +44,6 @@ typedef struct _academy_user_t_
|
||||
} academy_user_t;
|
||||
|
||||
typedef void (*academy_callback)(academy_state_t state);
|
||||
typedef void (*academy_download_new_media)(const char *mediaPath);
|
||||
typedef void (*academy_download_new_media)(const char *mediaPath, bool_t addToQueue);
|
||||
|
||||
#endif // _ACADEMY_COMMON_H_
|
||||
|
||||
@@ -359,22 +359,6 @@ typedef enum
|
||||
FLYING_MODE_HOVER_ON_TOP_OF_ORIENTED_ROUNDEL = 1 << 1, /**< Commands are disabled, drones hovers on top of an oriented roundel - oriented roundel detection MUST be activated by the user with 'detect_type' configuration. */
|
||||
} FLYING_MODE;
|
||||
|
||||
/*
|
||||
* @enum TRAVELLING_MODE
|
||||
* @brief Values for the CONTROL:travelling_mode configuration.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
TRAVELLING_MODE_TRANSLATION = 0, /**< Travelling translation mode */
|
||||
TRAVELLING_MODE_CIRCULAR, /**< Travelling circular mode */
|
||||
TRAVELLING_MODE_SWING, /**/
|
||||
TRAVELLING_MODE_WHEEL_FRONT, /**/
|
||||
TRAVELLING_MODE_WHEEL_SIDE, /**/
|
||||
TRAVELLING_MODE_GUSH, /**/
|
||||
TRAVELLING_MODE_PLANAR_WHEEL,/**/
|
||||
TRAVELLING_MODE_NUM,
|
||||
} TRAVELLING_MODE;
|
||||
|
||||
/**
|
||||
* @enum WIFI_MODE
|
||||
* @brief Values for the NETWORK:wifi_mode configuration, who set the wifi mode when drone start
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Automatically generated C config: don't edit
|
||||
* Linux kernel version:
|
||||
* Thu Nov 5 18:06:01 2009
|
||||
*/
|
||||
#define AUTOCONF_INCLUDED
|
||||
#define PAL_TRACE_THREAD_VAL 0
|
||||
#define PAL_ASSERT 1
|
||||
#define MODIF_VERSION_NUMBER 0
|
||||
#define PAL_BUTTON_LONG_PRESS_TIME 2000
|
||||
#define PAL_BUTTON_DRIVER 1
|
||||
#define PAL_I2C_DRIVER 1
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define PAL_TRACE_SEM_VAL 0
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#define PAL_TRACE_SYS_VAL 0
|
||||
#define PAL_SUP_NB_TIMERS 18
|
||||
#define PAL_TRACE_HWALARM_VAL 0
|
||||
#define PAL_PWM_DRIVER 1
|
||||
#define PAL_I2C_DEVICES 1
|
||||
#define EXTENDED_VERSION_INFO RC0
|
||||
#define PAL_SUP_NB_MOD 32
|
||||
#define PAL_TRACE_FLAG_VAL 0
|
||||
#define PAL_TRACE_COND_VAL 0
|
||||
#define PAL_DEBUG_LEVEL 1
|
||||
#define PAL_TRACE_GPIO_VAL 0
|
||||
#define PAL_TRACE_TIME_VAL 0
|
||||
#define PAL_TRACE_MBOX_VAL 0
|
||||
#define PAL_TRACE_UART_VAL 0
|
||||
#define PAL_GPIO_DRIVER 1
|
||||
#define PAL_P6MU_ADC_DEVICE 1
|
||||
#define PAL_P6MU_CODEC_DEVICE 1
|
||||
#define BUILD_PAL 1
|
||||
#define PAL_SUP_PRIO_P1 18
|
||||
#define PAL_SUP_PRIO_P2 20
|
||||
#define PAL_SUP_PRIO_P3 22
|
||||
#define PAL_SUP_PRIO_P4 24
|
||||
#define PAL_SUP_PRIO_P5 26
|
||||
#define PAL_UARTS_COUNT 4
|
||||
#define PAL_LINUX_NOSMP 1
|
||||
#define PAL_TRACE_ALARM_VAL 0
|
||||
#define PAL_SUP_MAX_MES 60
|
||||
#define CONFIG_PAL_USER_ASSERT 1
|
||||
#define TRUC_POURRI_YMM 1
|
||||
#define UNAME_RELEASE 2.6.28-16-generic
|
||||
#define PAL_BUTTON_MAX_HW_DRIVERS 1
|
||||
#define PAL_TRACE_MUTEX_VAL 0
|
||||
#define PAL_BUTTON_MAX_BUTTONS 32
|
||||
#define PAL_STACKSIZE 6144
|
||||
#define PAL_POSIX_MIX_PRIO 1
|
||||
#define PAL_POSIX_RT_PRIO_THRESHOLD 10
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <win32_custom.h>
|
||||
#else
|
||||
#include <generated_custom.h>
|
||||
#include <autoconf.h>
|
||||
#endif
|
||||
|
||||
#undef ARDRONE_PIC_VERSION
|
||||
|
||||
@@ -157,8 +157,6 @@ extern const float32_t default_magneto_radius;
|
||||
|
||||
#define ARDRONE_DEFAULT_DATE "19700101_000000"
|
||||
#define ARDRONE_EMPTY_STRING ""
|
||||
#define ARDRONE_DEFAULT_TRAVELLING_MODE "0,10,1500,0,1000"
|
||||
|
||||
|
||||
#define CUSTOM_CONFIGURATION_DELETE_ALL_CMD "all"
|
||||
|
||||
@@ -283,8 +281,6 @@ ARDRONE_CONFIG_KEY_IMM_a10("control", outdoor_control_yaw, INI_FLOAT,
|
||||
ARDRONE_CONFIG_KEY_IMM_a10("control", flying_mode, INI_INT, int32_t, int32_t*, (K_READ|K_WRITE|K_NOBIND|K_SHALLOW), (K_READ|K_WRITE), 0, flying_mode_config_callback,CAT_SESSION)
|
||||
ARDRONE_CONFIG_KEY_IMM_a10("control", hovering_range, INI_INT, int32_t, int32_t*, (K_READ|K_WRITE|K_NOBIND|K_SHALLOW), (K_READ|K_WRITE), 1000, default_config_callback, CAT_SESSION)
|
||||
ARDRONE_CONFIG_KEY_STR_a10("control", flight_anim, INI_STRING, string_t, char*, (K_READ|K_WRITE|K_NOBIND|K_SHALLOW), 0, "0,0", flight_animation_selection_callback,CAT_COMMON)
|
||||
ARDRONE_CONFIG_KEY_STR_a10("control", travelling_mode, INI_STRING, string_t, char*, (K_READ|K_WRITE), (K_READ|K_WRITE), ARDRONE_DEFAULT_TRAVELLING_MODE, travelling_mode_selection_callback,CAT_USER)
|
||||
ARDRONE_CONFIG_KEY_IMM_a10("control", travelling_enable, INI_BOOLEAN, bool_t, bool_t*, (K_READ|K_WRITE|K_NOBIND|K_SHALLOW), 0, FALSE, travelling_enable_callback, CAT_COMMON)
|
||||
|
||||
ARDRONE_CONFIG_KEY_STR_a10("network", ssid_single_player, INI_STRING, string_t, char*, (K_READ|K_WRITE), 0, WIFI_NETWORK_NAME, default_config_callback, CAT_COMMON)
|
||||
ARDRONE_CONFIG_KEY_STR_a10("network", ssid_multi_player, INI_STRING, string_t, char*, (K_READ|K_WRITE), 0, WIFI_NETWORK_NAME, default_config_callback, CAT_COMMON)
|
||||
|
||||
@@ -72,7 +72,7 @@ typedef enum {
|
||||
CVAR( FLYING_ALT_OUT_ZONE ),
|
||||
CVAR( FLYING_COMBINED_YAW ),
|
||||
CVAR( FLYING_BRAKE ),
|
||||
CVAR( FLYING_NO_VISION )
|
||||
CVAR( FLYING_NO_VISION ),
|
||||
#ifndef CTRL_STATES_STRING
|
||||
} FLYING_STATES;
|
||||
#else
|
||||
|
||||
@@ -210,7 +210,7 @@ static const int32_t MAYDAY_TIMEOUT[ARDRONE_NB_ANIM_MAYDAY] = {
|
||||
|
||||
#define NAVDATA_HEADER 0x55667788
|
||||
|
||||
#define NAVDATA_MAX_SIZE 2048
|
||||
#define NAVDATA_MAX_SIZE 4096
|
||||
#define NAVDATA_MAX_CUSTOM_TIME_SAVE 20
|
||||
|
||||
/* !!! Warning !!! - changing the value below would break compatibility with older applications
|
||||
@@ -355,7 +355,6 @@ typedef struct _navdata_raw_measures_t {
|
||||
uint16_t nb_echo;
|
||||
uint32_t sum_echo;
|
||||
int32_t alt_temp_raw;
|
||||
|
||||
int16_t gradient;
|
||||
}_ATTRIBUTE_PACKED_ navdata_raw_measures_t;
|
||||
|
||||
@@ -395,8 +394,8 @@ typedef struct _navdata_wind_speed_t {
|
||||
uint16_t tag;
|
||||
uint16_t size;
|
||||
|
||||
float32_t wind_speed;
|
||||
float32_t wind_angle;
|
||||
float32_t wind_speed; // estimated wind speed [m/s]
|
||||
float32_t wind_angle; // estimated wind direction in North-East frame [rad] e.g. if wind_angle is pi/4, wind is from South-West to North-East
|
||||
float32_t wind_compensation_theta;
|
||||
float32_t wind_compensation_phi;
|
||||
float32_t state_x1;
|
||||
|
||||
@@ -77,6 +77,10 @@ GENERIC_LIBRARY_SOURCE_FILES+= \
|
||||
$(ARDRONE_TOOL_DIR)/Video/video_stage_decoder.c \
|
||||
$(ARDRONE_TOOL_DIR)/Video/video_recorder_pipeline.c \
|
||||
$(ARDRONE_TOOL_DIR)/Video/video_stage.c
|
||||
ifeq ($(USE_ANDROID),yes)
|
||||
GENERIC_LIBRARY_SOURCE_FILES+= \
|
||||
$(UTILS_DIR)/AR_Ftw.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(CONTROL_DLL),yes)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <VP_Os/vp_os_assert.h>
|
||||
#include <VP_Os/vp_os_print.h>
|
||||
#include <VP_Os/vp_os_malloc.h>
|
||||
|
||||
#include <Maths/matrices.h>
|
||||
@@ -223,12 +224,12 @@ bool_t normalize_vec( vector31_t* v )
|
||||
|
||||
void display_matrix33(matrix33_t *m1)
|
||||
{
|
||||
printf("( %f\t%f\t%f )\n( %f\t%f\t%f )\n( %f\t%f\t%f )\n",m1->m11,m1->m12,m1->m13,m1->m21,m1->m22,m1->m23,m1->m31,m1->m32,m1->m33);
|
||||
PRINT("( %f\t%f\t%f )\n( %f\t%f\t%f )\n( %f\t%f\t%f )\n",m1->m11,m1->m12,m1->m13,m1->m21,m1->m22,m1->m23,m1->m31,m1->m32,m1->m33);
|
||||
}
|
||||
|
||||
void display_vector31(vector31_t *v1)
|
||||
{
|
||||
printf("( %f\t%f\t%f )\n", v1->x ,v1->y, v1->z);
|
||||
PRINT("( %f\t%f\t%f )\n", v1->x ,v1->y, v1->z);
|
||||
}
|
||||
|
||||
// matrix of size 4
|
||||
@@ -408,12 +409,12 @@ void inv_mat44(matrix44_t *out, matrix44_t* m1)
|
||||
|
||||
void display_matrix44(matrix44_t *m1)
|
||||
{
|
||||
printf("( %f\t%f\t%f\t%f )\n( %f\t%f\t%f\t%f )\n( %f\t%f\t%f\t%f )\n( %f\t%f\t%f\t%f )\n",m1->m11,m1->m12,m1->m13,m1->m14,m1->m21,m1->m22,m1->m23,m1->m24,m1->m31,m1->m32,m1->m33,m1->m34,m1->m41,m1->m42,m1->m43,m1->m44);
|
||||
PRINT("( %f\t%f\t%f\t%f )\n( %f\t%f\t%f\t%f )\n( %f\t%f\t%f\t%f )\n( %f\t%f\t%f\t%f )\n",m1->m11,m1->m12,m1->m13,m1->m14,m1->m21,m1->m22,m1->m23,m1->m24,m1->m31,m1->m32,m1->m33,m1->m34,m1->m41,m1->m42,m1->m43,m1->m44);
|
||||
}
|
||||
|
||||
void display_vector41(vector41_t *v1)
|
||||
{
|
||||
printf("( %f\t%f\t%f\t%f )\n", v1->x1 ,v1->x2, v1->x3, v1->x4);
|
||||
PRINT("( %f\t%f\t%f\t%f )\n", v1->x1 ,v1->x2, v1->x3, v1->x4);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ C_RESULT matrix3d_orientation(matrix3d_t* m, const vector31_t* pos, const vector
|
||||
return C_OK;
|
||||
}
|
||||
|
||||
#define MATRIX_EXCHANGE( out, in ) temp = out; out = in; in = out
|
||||
#define MATRIX_EXCHANGE( out, in ) temp = out; out = in; in = temp
|
||||
|
||||
C_RESULT matrix3d_transpose(matrix3d_t* out, matrix3d_t* in)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <VP_Os/vp_os_print.h>
|
||||
#include <ardrone_tool/Com/config_com.h>
|
||||
#include <ardrone_tool/ardrone_tool.h>
|
||||
#include <ardrone_tool/ardrone_version.h>
|
||||
|
||||
//Common
|
||||
#include <ardrone_api.h>
|
||||
@@ -160,6 +161,14 @@ AT_CODEC_ERROR_CODE host_open( void )
|
||||
PRINT ("Error setting SND_BUF for AT socket\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* On android, with IP_TOS set, certain devices can't connect to AR.Drone 1
|
||||
* So we just disable this functionnality to avoid these cases.
|
||||
*/
|
||||
#ifdef USE_ANDROID
|
||||
if (IS_ARDRONE2)
|
||||
{
|
||||
#endif
|
||||
int opt = IPTOS_PREC_NETCONTROL;
|
||||
int res = setsockopt((int)at_socket.priv, IPPROTO_IP, IP_TOS, &opt, (socklen_t)sizeof(opt));
|
||||
if (res)
|
||||
@@ -170,6 +179,9 @@ AT_CODEC_ERROR_CODE host_open( void )
|
||||
{
|
||||
printf ("Set IP_TOS ok\n");
|
||||
}
|
||||
#ifdef USE_ANDROID
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -306,6 +318,7 @@ void ardrone_at_set_flat_trim(void)
|
||||
{
|
||||
if (!at_init)
|
||||
return;
|
||||
|
||||
vp_os_mutex_lock(&at_mutex);
|
||||
ATcodec_Queue_Message_valist( ids.AT_MSG_ATCMD_FTRIM_EXE,
|
||||
++nb_sequence );
|
||||
|
||||
@@ -219,7 +219,7 @@ DEFINE_THREAD_ROUTINE(academy, data)
|
||||
academy.flight_sum = 0;
|
||||
academy.flight_oldest_date[0] = '\0';
|
||||
|
||||
if(!ftw(flight_dir, &academy_compute_memory_used, 1))
|
||||
if(!ftw(flight_dir, &academy_compute_memory_used, ACADEMY_MAX_FD_FOR_FTW))
|
||||
{
|
||||
if(academy.flight_sum > MBYTE_TO_BYTE(academy.flight_max_storing_size))
|
||||
{
|
||||
@@ -229,19 +229,23 @@ DEFINE_THREAD_ROUTINE(academy, data)
|
||||
// remove oldest flight
|
||||
PA_WARNING("Too much memory used %d MB > %d MB, removing oldest flight %s...", BYTE_TO_MBYTE(academy.flight_sum), academy.flight_max_storing_size, remove_dir);
|
||||
|
||||
if(!ftw(remove_dir, &academy_remove, 1))
|
||||
if(!ftw(remove_dir, &academy_remove, ACADEMY_MAX_FD_FOR_FTW))
|
||||
{
|
||||
rmdir(remove_dir);
|
||||
PA_WARNING("OK.\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
needToCheckMemory = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
needToCheckMemory = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
THREAD_RETURN(C_OK);
|
||||
}
|
||||
|
||||
@@ -17,11 +17,17 @@
|
||||
#include <utils/ardrone_ftp.h>
|
||||
#include <VP_Os/vp_os_delay.h>
|
||||
#include <VP_Os/vp_os_thread.h>
|
||||
#include <VP_Os/vp_os_print.h>
|
||||
#include <VP_Os/vp_os_malloc.h>
|
||||
#include <VP_Os/vp_os_signal.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#ifndef USE_ANDROID
|
||||
#include <ftw.h>
|
||||
#else
|
||||
#include <utils/AR_Ftw.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
@@ -40,6 +46,7 @@
|
||||
#define ACADEMY_MAX_LIST 1024
|
||||
#define ACADEMY_MAX_LINE 128
|
||||
#define ACADEMY_MAX_FILENAME 256
|
||||
#define ACADEMY_MAX_FD_FOR_FTW 20
|
||||
|
||||
#define PA_PREFIX "PA : "
|
||||
|
||||
@@ -47,26 +54,26 @@
|
||||
#define PA_DEBUG(...) \
|
||||
do \
|
||||
{ \
|
||||
printf (PA_PREFIX); \
|
||||
printf (__VA_ARGS__); \
|
||||
PRINT (PA_PREFIX); \
|
||||
PRINT (__VA_ARGS__); \
|
||||
} while (0)
|
||||
#define PA_WARNING(...) \
|
||||
do \
|
||||
{ \
|
||||
printf (PA_PREFIX); \
|
||||
printf (__VA_ARGS__); \
|
||||
PRINT (PA_PREFIX); \
|
||||
PRINT (__VA_ARGS__); \
|
||||
} while (0)
|
||||
#else
|
||||
#define PA_DEBUG(...)
|
||||
#define PA_WARNING(...) \
|
||||
do \
|
||||
{ \
|
||||
printf (PA_PREFIX); \
|
||||
printf (__VA_ARGS__); \
|
||||
PRINT (PA_PREFIX); \
|
||||
PRINT (__VA_ARGS__); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define ACADEMY_SERVERNAME ""
|
||||
#define ACADEMY_SERVERNAME "parrot01.nyx.emencia.net"
|
||||
#define ACADEMY_PORT 21
|
||||
#define BYTE_TO_MBYTE(a) (a / 1048576)
|
||||
#define MBYTE_TO_BYTE(a) (a * 1048576)
|
||||
|
||||
@@ -140,7 +140,7 @@ DEFINE_THREAD_ROUTINE(academy_download, data)
|
||||
academy.new_media_callback = (academy_download_new_media)data;
|
||||
academy.callback = academy_download_private_callback;
|
||||
|
||||
printf("Start thread %s \n", __FUNCTION__);
|
||||
PRINT("Start thread %s \n", __FUNCTION__);
|
||||
do
|
||||
{
|
||||
academy_download_resetState(&academy);
|
||||
@@ -148,12 +148,12 @@ DEFINE_THREAD_ROUTINE(academy_download, data)
|
||||
if (TRUE == academy_download_in_pause)
|
||||
{
|
||||
vp_os_mutex_lock (&academy_download_mutex);
|
||||
printf ("Academy download stage paused\n");
|
||||
PRINT ("Academy download stage paused\n");
|
||||
vp_os_cond_wait (&academy_download_cond);
|
||||
vp_os_mutex_unlock (&academy_download_mutex);
|
||||
}
|
||||
academy_download_pause();
|
||||
printf ("Academy download stage resumed\n");
|
||||
PRINT ("Academy download stage resumed\n");
|
||||
academy_download_nextState(&academy);
|
||||
|
||||
while( academy_download_started && !shouldGoInPause)
|
||||
@@ -219,7 +219,7 @@ DEFINE_THREAD_ROUTINE(academy_download, data)
|
||||
{
|
||||
// Transfer was in progress by an other device => Create local directory
|
||||
PA_DEBUG("Transfer was in progress by an other device\n");
|
||||
printf("Creating local directory %s\n", local_dir);
|
||||
PRINT("Creating local directory %s\n", local_dir);
|
||||
if(mkdir(local_dir, 0777) >= 0)
|
||||
{
|
||||
PA_DEBUG("Create local directory %s\n", local_dir);
|
||||
@@ -293,7 +293,7 @@ DEFINE_THREAD_ROUTINE(academy_download, data)
|
||||
}
|
||||
|
||||
snprintf(media_dirname, ACADEMY_MAX_FILENAME, "%s/media_%s", flight_dir, process_dirname + (strlen("downloading_flight_")));
|
||||
//printf("medias directory : %s\n", media_dirname);
|
||||
//PRINT("medias directory : %s\n", media_dirname);
|
||||
next_file = NULL;
|
||||
while(FTP_SUCCEDED(academy_status) && (ptr = academy_get_next_item_with_prefix(fileList, &next_file, "picture_", FALSE)))
|
||||
{
|
||||
@@ -305,7 +305,10 @@ DEFINE_THREAD_ROUTINE(academy_download, data)
|
||||
academy_status = ftpGet (academy_ftp, ptr, local_filename, 1, NULL);
|
||||
if(FTP_SUCCEDED(academy_status))
|
||||
{
|
||||
academy.new_media_callback((const char *)local_filename);
|
||||
if (NULL != academy.new_media_callback)
|
||||
{
|
||||
academy.new_media_callback((const char *)local_filename, TRUE);
|
||||
}
|
||||
PA_DEBUG("OK\n");
|
||||
}
|
||||
else
|
||||
@@ -313,6 +316,10 @@ DEFINE_THREAD_ROUTINE(academy_download, data)
|
||||
PA_DEBUG("ERROR\n");
|
||||
}
|
||||
}
|
||||
if (NULL != academy.new_media_callback)
|
||||
{
|
||||
academy.new_media_callback((const char *)NULL, FALSE);
|
||||
}
|
||||
|
||||
if(FTP_SUCCEDED(academy_status) && !userbox_ready)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
extern char flight_dir[];
|
||||
#endif
|
||||
|
||||
#define ACADEMY_MEDIA_DIRPATH_FORMAT "%s/media_%s"
|
||||
#define ACADEMY_MEDIA_VIDEO_FILEPATH_FORMAT "%s/video_%s.%s"
|
||||
#define ACADEMY_MEDIA_DIR_ACCESS_RIGHT 0777
|
||||
|
||||
static void ardrone_academy_stage_recorder_internal_close(ardrone_academy_stage_recorder_config_t *cfg);
|
||||
|
||||
ardrone_academy_stage_recorder_config_t ardrone_academy_stage_recorder_config;
|
||||
@@ -53,14 +57,15 @@ ardrone_academy_stage_recorder_handle (ardrone_academy_stage_recorder_config_t *
|
||||
char media_dirname[ACADEMY_MAX_FILENAME];
|
||||
struct stat statbuf;
|
||||
|
||||
sprintf(media_dirname, "%s/media_%s", ACADEMY_FILE_DEFAULT_PATH, date);
|
||||
if((stat(media_dirname, &statbuf) != 0) && (mkdir(media_dirname, 0777) >= 0))
|
||||
sprintf(media_dirname, ACADEMY_MEDIA_DIRPATH_FORMAT, ACADEMY_FILE_DEFAULT_PATH, date);
|
||||
if((stat(media_dirname, &statbuf) != 0) && (mkdir(media_dirname, ACADEMY_MEDIA_DIR_ACCESS_RIGHT) >= 0))
|
||||
PA_DEBUG("Create local media directory %s if not exist\n", media_dirname);
|
||||
// NO ELSE, the local directory already exists
|
||||
|
||||
t = time(NULL);
|
||||
ardrone_time2date(t, ARDRONE_FILE_DATE_FORMAT, date);
|
||||
|
||||
sprintf(cfg->video_filename, "%s/video_%s.%s",
|
||||
sprintf(cfg->video_filename, ACADEMY_MEDIA_VIDEO_FILEPATH_FORMAT,
|
||||
media_dirname,
|
||||
date,
|
||||
ACADEMY_RECORD_FILE_EXTENSION);
|
||||
@@ -81,6 +86,7 @@ ardrone_academy_stage_recorder_handle (ardrone_academy_stage_recorder_config_t *
|
||||
printf ("Can't open file %s\n", video_filename);
|
||||
}
|
||||
}
|
||||
// NO ELSE - The record is already started or is starting
|
||||
break;
|
||||
|
||||
case PIPELINE_MSG_STOP:
|
||||
@@ -89,14 +95,16 @@ ardrone_academy_stage_recorder_handle (ardrone_academy_stage_recorder_config_t *
|
||||
cfg->startRec = ACADEMY_RECORD_STOP;
|
||||
printf("Stop recording %s\n", cfg->video_filename);
|
||||
ardrone_academy_stage_recorder_internal_close(cfg);
|
||||
result = C_OK;
|
||||
}
|
||||
// NO ELSE - Record is already stopped.
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return (VP_SUCCESS);
|
||||
return (result);
|
||||
}
|
||||
|
||||
void ardrone_academy_stage_recorder_enable(bool_t enable, uint32_t timestamp)
|
||||
@@ -136,7 +144,7 @@ C_RESULT ardrone_academy_stage_recorder_transform(ardrone_academy_stage_recorder
|
||||
out->indexBuffer = 0;
|
||||
out->lineSize = NULL;
|
||||
}
|
||||
|
||||
// NO ELSE - We need to initialize the number of buffers and the index of buffer in first.
|
||||
out->size = in->size;
|
||||
out->status = in->status;
|
||||
out->buffers = in->buffers;
|
||||
@@ -159,6 +167,11 @@ C_RESULT ardrone_academy_stage_recorder_transform(ardrone_academy_stage_recorder
|
||||
fwrite(&in->size, 1, sizeof(int32_t), cfg->fp);
|
||||
fwrite(in->buffers[in->indexBuffer], 1, in->size, cfg->fp);
|
||||
}
|
||||
// NO ELSE because :
|
||||
// If the descriptor file is NULL, we can't to write data.
|
||||
// If data size to write is 0, we don't have data to write.
|
||||
// If the status is not processing, it means the record is stopping.
|
||||
// If startRec is not start, it means the record is stopping or is starting.
|
||||
|
||||
vp_os_mutex_unlock( &out->lock );
|
||||
#endif
|
||||
@@ -171,5 +184,8 @@ C_RESULT ardrone_academy_stage_recorder_close(ardrone_academy_stage_recorder_con
|
||||
{
|
||||
ardrone_academy_stage_recorder_internal_close(cfg);
|
||||
}
|
||||
// NO ELSE because :
|
||||
// If the descriptor file is NULL, we can't to write data.
|
||||
|
||||
return C_OK;
|
||||
}
|
||||
|
||||
@@ -117,18 +117,9 @@ static void academy_upload_private_callback(academy_state_t state)
|
||||
|
||||
case ACADEMY_RESULT_OK:
|
||||
strcat(msg, "OK");
|
||||
// time_to_process += state.time_in_ms;
|
||||
// if(state.state == ACADEMY_STATE_DRONE_DISCONNECTION)
|
||||
// {
|
||||
// sprintf(msg, "%s in %d ms\n", msg, time_to_process);
|
||||
// time_to_process = 0;
|
||||
// }
|
||||
break;
|
||||
|
||||
case ACADEMY_RESULT_FAILED:
|
||||
// if(state.state == ACADEMY_STATE_DRONE_PREPARE_DOWNLOAD)
|
||||
// time_to_process = 0;
|
||||
|
||||
strcat(msg, "FAILED");
|
||||
break;
|
||||
}
|
||||
@@ -231,7 +222,6 @@ DEFINE_THREAD_ROUTINE(academy_upload, data)
|
||||
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)
|
||||
{
|
||||
@@ -350,7 +340,7 @@ DEFINE_THREAD_ROUTINE(academy_upload, data)
|
||||
// Penser à supprimer le fichier local
|
||||
academy_status = FTP_FAIL;
|
||||
sprintf(local_dir, "%s/%s", flight_dir, dirname);
|
||||
if(!ftw(local_dir, &academy_remove, 1))
|
||||
if(!ftw(local_dir, &academy_remove, ACADEMY_MAX_FD_FOR_FTW))
|
||||
{
|
||||
rmdir(local_dir);
|
||||
academy_status = FTP_SUCCESS;
|
||||
|
||||
@@ -60,11 +60,6 @@ C_RESULT ardrone_control_shutdown(void)
|
||||
/*BUG FIX : Dont destroy the mutexes here,
|
||||
they are still being used by the ardrone_control thread,
|
||||
while this function is called by another thread.*/
|
||||
#ifdef THIS_IS_A_BUG
|
||||
vp_os_mutex_destroy(&event_queue_mutex);
|
||||
vp_os_cond_destroy(&control_cond);
|
||||
vp_os_mutex_destroy(&control_mutex);*/
|
||||
#endif
|
||||
|
||||
bContinue = FALSE;
|
||||
|
||||
@@ -90,11 +85,11 @@ C_RESULT ardrone_control_connect_to_drone()
|
||||
setsockopt((int32_t)control_socket.priv,
|
||||
SOL_SOCKET,
|
||||
SO_RCVTIMEO,
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
(const char*)&timeout_windows, sizeof(timeout_windows)
|
||||
#else
|
||||
#else
|
||||
(const char*)&tv, sizeof(tv)
|
||||
#endif
|
||||
#endif
|
||||
);
|
||||
|
||||
control_socket.is_disable = FALSE;
|
||||
@@ -303,7 +298,7 @@ DEFINE_THREAD_ROUTINE( ardrone_control, nomParams )
|
||||
}
|
||||
}// while
|
||||
|
||||
/* Stephane : Bug fix - mutexes were previously detroyed by another thread,
|
||||
/*Bug fix - mutexes were previously detroyed by another thread,
|
||||
which made ardrone_control crash.*/
|
||||
vp_os_mutex_destroy(&event_queue_mutex);
|
||||
vp_os_cond_destroy(&control_cond);
|
||||
|
||||
@@ -97,7 +97,7 @@ bool_t ardrone_academy_navdata_takeoff(void)
|
||||
bool_t shouldNotDo = (TRUE == isBatteryLow && FALSE == navdata_state.isTakeOff) ? TRUE : FALSE;
|
||||
if(navdata_state.takeoff_state == TAKEOFF_STATE_IDLE &&
|
||||
FALSE == shouldNotDo)
|
||||
{
|
||||
{
|
||||
LOCK_ND_MUTEX ();
|
||||
navdata_state.takeoff_state = TAKEOFF_STATE_NEEDED;
|
||||
navdata_state.takeoff_time = time (NULL);
|
||||
@@ -170,12 +170,12 @@ bool_t ardrone_academy_navdata_get_record_ready(void)
|
||||
#if defined (RECORD_ENCODED_VIDEO)
|
||||
result = (video_stage_encoded_recorder_state() || navdata_state.usbRecordInProgress);
|
||||
#else
|
||||
printf("ARDRONE VERSION 2 NEEDS RECORD_ENCODED_VIDEO MACRO!!!\n");
|
||||
PRINT("ARDRONE VERSION 2 NEEDS RECORD_ENCODED_VIDEO MACRO!!!\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("ARDRONE VERSION NOT INITIALIZED !!!\n");
|
||||
PRINT("ARDRONE VERSION NOT INITIALIZED !!!\n");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -196,12 +196,12 @@ bool_t ardrone_academy_navdata_get_record_state(void)
|
||||
( VIDEO_ENCODED_STOPPED != recState &&
|
||||
VIDEO_ENCODED_WAITING_STREAM_END != recState);
|
||||
#else
|
||||
printf("ARDRONE VERSION 2 NEEDS RECORD_ENCODED_VIDEO MACRO!!!\n");
|
||||
PRINT("ARDRONE VERSION 2 NEEDS RECORD_ENCODED_VIDEO MACRO!!!\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("ARDRONE VERSION NOT INITIALIZED !!!\n");
|
||||
PRINT("ARDRONE VERSION NOT INITIALIZED !!!\n");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -254,12 +254,12 @@ void ardrone_academy_navdata_recorder_enable(bool_t enable, uint32_t timestamp)
|
||||
video_stage_encoded_recorder_enable(enable, timestamp);
|
||||
}
|
||||
#else
|
||||
printf("ARDRONE VERSION 2 NEEDS RECORD_ENCODED_VIDEO MACRO!!!\n");
|
||||
PRINT("ARDRONE VERSION 2 NEEDS RECORD_ENCODED_VIDEO MACRO!!!\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("ARDRONE VERSION NOT INITIALIZED !!!\n");
|
||||
PRINT("ARDRONE VERSION NOT INITIALIZED !!!\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ void ardrone_academy_navdata_userbox_cb(bool_t result)
|
||||
LOCK_ND_MUTEX ();
|
||||
if(navdata_state.userbox_state == USERBOX_STATE_STARTING)
|
||||
{
|
||||
printf("Userbox started\n");
|
||||
PRINT("Userbox started\n");
|
||||
navdata_state.userbox_state = USERBOX_STATE_STARTED;
|
||||
|
||||
switch (navdata_state.takeoff_state)
|
||||
@@ -328,7 +328,7 @@ void ardrone_academy_navdata_userbox_cb(bool_t result)
|
||||
}
|
||||
else if(navdata_state.userbox_state == USERBOX_STATE_STOPPING)
|
||||
{
|
||||
printf("Userbox stopped\n");
|
||||
PRINT("Userbox stopped\n");
|
||||
academy_download_resume ();
|
||||
if(navdata_state.takeoff_state == TAKEOFF_STATE_WAIT_USERBOX ||
|
||||
TAKEOFF_STATE_CANCELLING == navdata_state.takeoff_state)
|
||||
@@ -508,7 +508,7 @@ C_RESULT ardrone_academy_navdata_process( const navdata_unpacked_t* const pnd )
|
||||
|
||||
if(!navdata_state.internalRecordInProgress && !navdata_state.usbRecordInProgress && (navdata_state.userbox_state == USERBOX_STATE_STARTED))
|
||||
{
|
||||
printf("Emergency !! Stopping userbox...\n");
|
||||
PRINT("Emergency !! Stopping userbox...\n");
|
||||
ardrone_academy_navdata_userbox_switch();
|
||||
}
|
||||
|
||||
@@ -559,19 +559,19 @@ C_RESULT ardrone_academy_navdata_process( const navdata_unpacked_t* const pnd )
|
||||
oldCodec = ardrone_application_default_config.video_codec;
|
||||
cancelCodec = oldCodec;
|
||||
ardrone_control_config.video_codec = (TRUE == usbRecordEnable) ? usbRecordCodec : deviceWifiRecordCodec;
|
||||
printf ("Set codec %d -> %d\n", oldCodec, ardrone_control_config.video_codec);
|
||||
PRINT ("Set codec %d -> %d\n", oldCodec, ardrone_control_config.video_codec);
|
||||
nextInternalRecordState = TRUE;
|
||||
}
|
||||
else // We want to disable recording
|
||||
{
|
||||
cancelCodec = ardrone_control_config.video_codec;
|
||||
ardrone_control_config.video_codec = oldCodec;
|
||||
printf ("Reset codec %d -> %d\n", cancelCodec, oldCodec);
|
||||
PRINT ("Reset codec %d -> %d\n", cancelCodec, oldCodec);
|
||||
}
|
||||
bool_t addEventSucceeded = ARDRONE_TOOL_CONFIGURATION_ADDEVENT (video_codec, &ardrone_control_config.video_codec, NULL);
|
||||
if (FALSE == addEventSucceeded)
|
||||
{
|
||||
printf ("Unable to send codec switch ... retry later\n");
|
||||
PRINT ("Unable to send codec switch ... retry later\n");
|
||||
ardrone_control_config.video_codec = cancelCodec;
|
||||
continueRecord = FALSE;
|
||||
}
|
||||
@@ -596,13 +596,13 @@ C_RESULT ardrone_academy_navdata_process( const navdata_unpacked_t* const pnd )
|
||||
{
|
||||
if(! recordIsReady)
|
||||
{
|
||||
printf("Userbox is started and record is started => Stop record\n");
|
||||
PRINT("Userbox is started and record is started => Stop record\n");
|
||||
ardrone_academy_navdata_recorder_enable(FALSE, navdata_state.userbox_time);
|
||||
navdata_state.usbRecordInProgress = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Userbox is started and record is stopped => Start record\n");
|
||||
PRINT("Userbox is started and record is stopped => Start record\n");
|
||||
if (FALSE == usbRecordEnable)
|
||||
{
|
||||
// Only activate the local recorder if we don't record on USB
|
||||
@@ -647,13 +647,13 @@ C_RESULT ardrone_academy_navdata_process( const navdata_unpacked_t* const pnd )
|
||||
|
||||
if((navdata_state.screenshot_state == SCREENSHOT_STATE_NEEDED) && navdata_state.cameraIsReady)
|
||||
{
|
||||
char param[ARDRONE_DATE_MAXSIZE + 64];
|
||||
char date[ARDRONE_DATE_MAXSIZE];
|
||||
static char param[ARDRONE_DATE_MAXSIZE + 64];
|
||||
static char date[ARDRONE_DATE_MAXSIZE];
|
||||
time_t t = time(NULL);
|
||||
ardrone_time2date(t, ARDRONE_FILE_DATE_FORMAT, date);
|
||||
navdata_state.screenshot_state = SCREENSHOT_STATE_INPROGRESS;
|
||||
sprintf(param, "%d,%d,%d,%s", USERBOX_CMD_SCREENSHOT, 0, 0, date);
|
||||
ARDRONE_TOOL_CONFIGURATION_ADDEVENT(userbox_cmd, (char*)param, ardrone_academy_navdata_screenshot_cb);
|
||||
ARDRONE_TOOL_CONFIGURATION_ADDEVENT(userbox_cmd, param, ardrone_academy_navdata_screenshot_cb);
|
||||
}
|
||||
|
||||
// USB management
|
||||
|
||||
@@ -153,9 +153,18 @@ C_RESULT ardrone_general_navdata_process( const navdata_unpacked_t* const pnd )
|
||||
}
|
||||
|
||||
if (current_navdata_state == NAVDATA_BOOTSTRAP && configState == MULTICONFIG_IDLE && navdataState == NAVDATA_REQUEST_IDLE)
|
||||
{
|
||||
if ((0 != strncmp(ardrone_control_config.application_id, app_id, APPLI_NAME_SIZE)) ||
|
||||
(0 != strncmp(ardrone_control_config.profile_id, usr_id, USER_NAME_SIZE)) ||
|
||||
(0 != strncmp(ardrone_control_config.session_id, ses_id, SESSION_NAME_SIZE)))
|
||||
{
|
||||
configState = MULTICONFIG_NEEDED;
|
||||
}
|
||||
else
|
||||
{
|
||||
navdataState = NAVDATA_REQUEST_NEEDED;
|
||||
}
|
||||
}
|
||||
|
||||
/* Multiconfig settings */
|
||||
int configIndex, userNeedInit, appNeedInit;
|
||||
@@ -318,7 +327,7 @@ C_RESULT ardrone_general_navdata_process( const navdata_unpacked_t* const pnd )
|
||||
navdataState = NAVDATA_REQUEST_IN_PROGRESS;
|
||||
switchToSession(); // Resend session id when reconnecting.
|
||||
sendInitConfigurations();
|
||||
ARDRONE_TOOL_CONFIGURATION_ADDEVENT(navdata_demo, &ardrone_application_default_config.navdata_demo, NULL);
|
||||
ARDRONE_TOOL_CONFIGURATION_ADDEVENT (navdata_demo, &ardrone_application_default_config.navdata_demo, NULL);
|
||||
ARDRONE_TOOL_CONFIGURATION_ADDEVENT (navdata_options, &ardrone_application_default_config.navdata_options, navdataCallback);
|
||||
break;
|
||||
case NAVDATA_REQUEST_DONE:
|
||||
@@ -421,6 +430,7 @@ ardrone_users_t *ardrone_get_user_list(void)
|
||||
if (NULL == retVal->userList)
|
||||
{
|
||||
vp_os_free (retVal);
|
||||
retVal = NULL;
|
||||
return NULL;
|
||||
}
|
||||
strncpy (retVal->userList[validUserCount-1].ident, available_configurations[CAT_USER].list[configIndex].id, MULTICONFIG_ID_SIZE);
|
||||
@@ -438,6 +448,7 @@ void ardrone_free_user_list (ardrone_users_t **users)
|
||||
if (NULL != (*users)->userList)
|
||||
{
|
||||
vp_os_free ((*users)->userList);
|
||||
(*users)->userList = NULL;
|
||||
}
|
||||
vp_os_free (*users);
|
||||
*users = NULL;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#define END_NAVDATA_HANDLER_TABLE \
|
||||
{ NULL, NULL, NULL, NULL } \
|
||||
};
|
||||
};
|
||||
|
||||
#define NAVDATA_HANDLER_TABLE_ENTRY( init, process, release, init_data_ptr ) \
|
||||
{ (ardrone_navdata_handler_init_t)init, process, release, init_data_ptr },
|
||||
|
||||
@@ -49,6 +49,11 @@ navdata_option_t* ardrone_navdata_search_option( navdata_option_t* navdata_optio
|
||||
{
|
||||
ptr = (uint8_t*) navdata_options_ptr;
|
||||
ptr += navdata_options_ptr->size;
|
||||
if (0 == navdata_options_ptr->size)
|
||||
{
|
||||
navdata_options_ptr = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
navdata_options_ptr = (navdata_option_t*) ptr;
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ typedef int socklen_t;
|
||||
#define PDBG(...) \
|
||||
do \
|
||||
{ \
|
||||
printf ("V_COM_STAGE: %s:%d : ", __FUNCTION__, __LINE__); \
|
||||
printf (__VA_ARGS__); \
|
||||
printf ("\n"); \
|
||||
PRINT ("V_COM_STAGE: %s:%d : ", __FUNCTION__, __LINE__); \
|
||||
PRINT (__VA_ARGS__); \
|
||||
PRINT ("\n"); \
|
||||
} while (0)
|
||||
#else
|
||||
#define PDBG(...)
|
||||
@@ -116,20 +116,20 @@ C_RESULT video_com_stage_connect (video_com_config_t *cfg)
|
||||
|
||||
if( cfg->protocol == VP_COM_PROBE)
|
||||
{
|
||||
printf("\n\nPROBING\n");
|
||||
PRINT("\n\nPROBING\n");
|
||||
|
||||
cfg->socket.protocol = VP_COM_TCP;
|
||||
res = vp_com_open(cfg->com, &cfg->socket, &cfg->read, &cfg->write);
|
||||
|
||||
if( VP_SUCCEEDED(res) )
|
||||
{
|
||||
printf("\n\nTCP\n");
|
||||
PRINT("\n\nTCP\n");
|
||||
vp_com_close (cfg->com, &cfg->socket);
|
||||
cfg->protocol = VP_COM_TCP;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\n\nUDP\n");
|
||||
PRINT("\n\nUDP\n");
|
||||
cfg->protocol = VP_COM_UDP;
|
||||
}
|
||||
}
|
||||
@@ -230,11 +230,11 @@ C_RESULT video_com_multisocket_stage_open(video_com_multisocket_config_t *cfg)
|
||||
cfg->configs[i]->mustReconnect = 0;
|
||||
}
|
||||
|
||||
printf("Video multisocket : init %i sockets\n",cfg->nb_sockets);
|
||||
PRINT("Video multisocket : init %i sockets\n",cfg->nb_sockets);
|
||||
|
||||
for(i=0;i<cfg->nb_sockets;i++)
|
||||
{
|
||||
printf("Video multisocket : connecting socket %d on port %d %s\n",
|
||||
PRINT("Video multisocket : connecting socket %d on port %d %s\n",
|
||||
i,
|
||||
cfg->configs[i]->socket.port,
|
||||
(cfg->configs[i]->protocol==VP_COM_TCP)?"TCP":"UDP");
|
||||
@@ -242,7 +242,7 @@ C_RESULT video_com_multisocket_stage_open(video_com_multisocket_config_t *cfg)
|
||||
cfg->configs[i]->connected = FALSE;
|
||||
res = video_com_stage_connect(cfg->configs[i]);
|
||||
if (!VP_SUCCEEDED(res)) {
|
||||
printf(" - Connection failed\n");
|
||||
PRINT(" - Connection failed\n");
|
||||
nb_failed_connections++;
|
||||
|
||||
}
|
||||
@@ -266,9 +266,9 @@ C_RESULT video_com_stage_transform(video_com_config_t *cfg, vp_api_io_data_t *in
|
||||
if (1 == cfg->mustReconnect)
|
||||
{
|
||||
PDBG ("Will call connect");
|
||||
printf ("Reconnecting ... ");
|
||||
PRINT ("Reconnecting ... ");
|
||||
res = video_com_stage_connect (cfg);
|
||||
printf ("%s\n", (VP_FAILED (res) ? "FAIL" : "OK"));
|
||||
PRINT ("%s\n", (VP_FAILED (res) ? "FAIL" : "OK"));
|
||||
cfg->mustReconnect = 0;
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ C_RESULT video_com_stage_transform(video_com_config_t *cfg, vp_api_io_data_t *in
|
||||
|
||||
C_RESULT video_com_multisocket_stage_transform(video_com_multisocket_config_t *cfg, vp_api_io_data_t *in, vp_api_io_data_t *out)
|
||||
{
|
||||
C_RESULT res,res2;
|
||||
C_RESULT res;
|
||||
fd_set rfds;
|
||||
int retval;
|
||||
int fs,maxfs;
|
||||
@@ -394,10 +394,10 @@ C_RESULT video_com_multisocket_stage_transform(video_com_multisocket_config_t *c
|
||||
if (1 == cfg->configs[i]->mustReconnect)
|
||||
{
|
||||
PDBG ("Will call connect");
|
||||
printf ("Reconnecting ... ");
|
||||
PRINT ("Reconnecting ... ");
|
||||
res = C_FAIL;
|
||||
res = video_com_stage_connect (cfg->configs[i]);
|
||||
printf ("%s\n", (VP_FAILED (res) ? "FAIL" : "OK"));
|
||||
PRINT ("%s\n", (VP_FAILED (res) ? "FAIL" : "OK"));
|
||||
cfg->configs[i]->mustReconnect = 0;
|
||||
}
|
||||
}
|
||||
@@ -480,20 +480,20 @@ C_RESULT video_com_multisocket_stage_transform(video_com_multisocket_config_t *c
|
||||
|
||||
if(i == cfg->nb_sockets)
|
||||
{
|
||||
printf("%s:%d BUG !!!!!", __FUNCTION__, __LINE__);
|
||||
PRINT("%s:%d BUG !!!!!", __FUNCTION__, __LINE__);
|
||||
selectTimeout = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINT_SDK("%s\n",(retval==0) ? "timeout" : "error");
|
||||
DEBUG_PRINT_SDK("%s\n",(retval==0)?"timeout":"error");
|
||||
selectTimeout = TRUE;
|
||||
}
|
||||
|
||||
if (FALSE == selectTimeout)
|
||||
{
|
||||
DEBUG_PRINT_SDK ("Will read on socket %d\n", i);
|
||||
// DEBUG_PRINT_SDK ("Will read on socket %d\n", i);
|
||||
// Actual first time read
|
||||
res = cfg->configs[i]->read(&cfg->configs[i]->socket, out->buffers[0], &out->size);
|
||||
if (VP_FAILED (res))
|
||||
@@ -512,7 +512,7 @@ C_RESULT video_com_multisocket_stage_transform(video_com_multisocket_config_t *c
|
||||
int32_t readSize = cfg->configs[i]->buffer_size - out->size;
|
||||
while (TRUE == bContinue)
|
||||
{
|
||||
DEBUG_PRINT_SDK ("Will read %d octets from socket %d\n", readSize, i);
|
||||
// DEBUG_PRINT_SDK ("Will read %d octets from socket %d\n", readSize, i);
|
||||
res = cfg->configs[i]->read(&cfg->configs[i]->socket, &(out->buffers[0][out->size]), &readSize);
|
||||
if (VP_FAILED (res))
|
||||
{
|
||||
@@ -551,7 +551,7 @@ C_RESULT video_com_multisocket_stage_transform(video_com_multisocket_config_t *c
|
||||
DEBUG_PRINT_SDK("Video multisocket : sending connection byte on port %s %d\n",
|
||||
(cfg->configs[i]->socket.protocol==VP_COM_TCP)?"TCP":"UDP",cfg->configs[i]->socket.port);
|
||||
|
||||
res2 = cfg->configs[i]->write(&cfg->configs[i]->socket, (uint8_t*) &flag, &len);
|
||||
cfg->configs[i]->write(&cfg->configs[i]->socket, (uint8_t*) &flag, &len);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -566,7 +566,7 @@ C_RESULT video_com_multisocket_stage_transform(video_com_multisocket_config_t *c
|
||||
|
||||
if((selectTimeout == TRUE) && cfg->forceNonBlocking && *(cfg->forceNonBlocking)==TRUE)
|
||||
{
|
||||
//printf("Debug %s:%d\n",__FUNCTION__,__LINE__);
|
||||
//PRINT("Debug %s:%d\n",__FUNCTION__,__LINE__);
|
||||
|
||||
/* No data are available here, but some are available in the next stage */
|
||||
/* out->size=0 would restart the pipeline */
|
||||
|
||||
@@ -197,14 +197,21 @@ DEFINE_THREAD_ROUTINE(video_stage, data) {
|
||||
}
|
||||
|
||||
vp_os_free(params->pre_processing_stages_list->stages_list);
|
||||
params->pre_processing_stages_list->stages_list = NULL;
|
||||
vp_os_free(params->post_processing_stages_list->stages_list);
|
||||
params->post_processing_stages_list->stages_list = NULL;
|
||||
vp_os_free(params->pre_processing_stages_list);
|
||||
params->pre_processing_stages_list = NULL;
|
||||
vp_os_free(params->post_processing_stages_list);
|
||||
params->post_processing_stages_list = NULL;
|
||||
|
||||
vp_os_free(params->in_pic);
|
||||
params->in_pic = NULL;
|
||||
vp_os_free(params->out_pic);
|
||||
params->out_pic = NULL;
|
||||
|
||||
vp_os_free(params);
|
||||
params = NULL;
|
||||
|
||||
vp_api_close(&pipeline, &video_pipeline_handle);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <ardrone_tool/Video/video_stage_decoder.h>
|
||||
#include <video_encapsulation.h>
|
||||
#include <VP_Os/vp_os_malloc.h>
|
||||
#include <VP_Os/vp_os_print.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef USE_ANDROID
|
||||
@@ -18,19 +19,22 @@
|
||||
# define mp4h264_open ittiam_stage_decoding_open
|
||||
# define mp4h264_transform ittiam_stage_decoding_transform
|
||||
# define mp4h264_close ittiam_stage_decoding_close
|
||||
static const int resetDecoderOnStreamChange = 1;
|
||||
# else // FFMPEG
|
||||
# define mp4h264_open ffmpeg_stage_decoding_open
|
||||
# define mp4h264_transform ffmpeg_stage_decoding_transform
|
||||
# define mp4h264_close ffmpeg_stage_decoding_close
|
||||
static const int resetDecoderOnStreamChange = 0;
|
||||
# endif
|
||||
#else
|
||||
#else // ANDROID
|
||||
typedef enum {
|
||||
NEON_SUPPORT_UNKNOWN = 0,
|
||||
NEON_SUPPORT_OK,
|
||||
NEON_SUPPORT_FAIL,
|
||||
} neon_status_t;
|
||||
|
||||
static neon_status_t neonStatus = NEON_SUPPORT_UNKNOWN;
|
||||
static neon_status_t neonStatus = NEON_SUPPORT_FAIL; // <<< FORCE FFMPEG <<<
|
||||
static int resetDecoderOnStreamChange = 0; // NON CONST as it will be set at runtime
|
||||
|
||||
C_RESULT mp4h264_open (mp4h264_config_t *cfg);
|
||||
C_RESULT mp4h264_transform (mp4h264_config_t *cfg, vp_api_io_data_t *in, vp_api_io_data_t *out);
|
||||
@@ -169,9 +173,9 @@ C_RESULT video_stage_decoder_transform (video_decoder_config_t *cfg, vp_api_io_d
|
||||
|
||||
video_stage_decoder_lastDetectedCodec = PaVE->video_codec;
|
||||
|
||||
if (lastDecodedStreamID!=-1 && lastDecodedStreamID!=PaVE->stream_id)
|
||||
if (lastDecodedStreamID!=-1 && lastDecodedStreamID!=PaVE->stream_id && 1 == resetDecoderOnStreamChange)
|
||||
{
|
||||
printf("Resetting the video decoder.\n");
|
||||
PRINT("Resetting the video decoder.\n");
|
||||
video_stage_decoder_close(cfg);
|
||||
video_stage_decoder_open(cfg);
|
||||
}
|
||||
@@ -311,6 +315,7 @@ C_RESULT video_stage_decoder_close (video_decoder_config_t *cfg)
|
||||
void checkNeonSupport ()
|
||||
{
|
||||
neon_status_t loc_neonStat = NEON_SUPPORT_FAIL;
|
||||
resetDecoderOnStreamChange = 0;
|
||||
FILE *cpuInfo = fopen ("/proc/cpuinfo", "r");
|
||||
if (NULL == cpuInfo)
|
||||
{
|
||||
@@ -330,11 +335,13 @@ void checkNeonSupport ()
|
||||
if (NULL != supportTest)
|
||||
{
|
||||
loc_neonStat = NEON_SUPPORT_OK;
|
||||
resetDecoderOnStreamChange = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vp_os_free (neonCheckStrBuf);
|
||||
neonCheckStrBuf = NULL;
|
||||
fclose (cpuInfo);
|
||||
|
||||
neonStatus = loc_neonStat;
|
||||
@@ -342,31 +349,37 @@ void checkNeonSupport ()
|
||||
|
||||
C_RESULT mp4h264_open (mp4h264_config_t *cfg)
|
||||
{
|
||||
#if ITTIAM_SUPPORT
|
||||
if (NEON_SUPPORT_UNKNOWN == neonStatus)
|
||||
checkNeonSupport ();
|
||||
if (NEON_SUPPORT_OK == neonStatus)
|
||||
return ittiam_stage_decoding_open (cfg);
|
||||
return ittiam_stage_decoding_open ((ittiam_stage_decoding_config_t *)cfg);
|
||||
else
|
||||
#endif
|
||||
return ffmpeg_stage_decoding_open (cfg);
|
||||
}
|
||||
|
||||
C_RESULT mp4h264_transform (mp4h264_config_t *cfg, vp_api_io_data_t *in, vp_api_io_data_t *out)
|
||||
{
|
||||
#if ITTIAM_SUPPORT
|
||||
if (NEON_SUPPORT_UNKNOWN == neonStatus)
|
||||
checkNeonSupport ();
|
||||
if (NEON_SUPPORT_OK == neonStatus)
|
||||
return ittiam_stage_decoding_transform (cfg, in, out);
|
||||
return ittiam_stage_decoding_transform ((ittiam_stage_decoding_config_t *)cfg, in, out);
|
||||
else
|
||||
#endif
|
||||
return ffmpeg_stage_decoding_transform (cfg, in, out);
|
||||
}
|
||||
|
||||
C_RESULT mp4h264_close (mp4h264_config_t *cfg)
|
||||
{
|
||||
#if ITTIAM_SUPPORT
|
||||
if (NEON_SUPPORT_UNKNOWN == neonStatus)
|
||||
checkNeonSupport ();
|
||||
if (NEON_SUPPORT_OK == neonStatus)
|
||||
return ittiam_stage_decoding_close (cfg);
|
||||
return ittiam_stage_decoding_close ((ittiam_stage_decoding_config_t *)cfg);
|
||||
else
|
||||
#endif
|
||||
return ffmpeg_stage_decoding_close (cfg);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,18 +11,17 @@
|
||||
#ifndef __VIDEO_STAGE_DECODER_H__
|
||||
#define __VIDEO_STAGE_DECODER_H__
|
||||
|
||||
#ifndef TARGET_OS_ANDROID
|
||||
# ifdef ITTIAM_SUPPORT
|
||||
#ifdef FFMPEG_SUPPORT
|
||||
# define mp4h264_config_t ffmpeg_stage_decoding_config_t
|
||||
#elif defined (ITTIAM_SUPPORT)
|
||||
# define mp4h264_config_t ittiam_stage_decoding_config_t
|
||||
# include <ardrone_tool/Video/video_stage_ittiam_decoder.h>
|
||||
# else // FFMPEG
|
||||
# define mp4h264_config_t ffmpeg_stage_decoding_config_t
|
||||
# endif
|
||||
#else
|
||||
# define mp4h264_config_t ffmpeg_stage_decoding_config_t
|
||||
# include <ardrone_tool/Video/video_stage_ittiam_decoder.h>
|
||||
# error Either FFMPEG_SUPPORT or ITTIAM_SUPPORT must be defined
|
||||
#endif
|
||||
|
||||
#ifdef ITTIAM_SUPPORT
|
||||
# include <ardrone_tool/Video/video_stage_ittiam_decoder.h>
|
||||
#endif
|
||||
|
||||
#ifdef FFMPEG_SUPPORT
|
||||
# include <ardrone_tool/Video/video_stage_ffmpeg_decoder.h>
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
|
||||
#include <ardrone_tool/Video/video_navdata_handler.h>
|
||||
|
||||
#ifdef USE_ELINUX
|
||||
#define VIDEO_ENCODED_FILE_DEFAULT_PATH "/data/video/usb/"
|
||||
#endif
|
||||
|
||||
#define VIDEO_ENCODED_RECORDER_VERBOSE (1)
|
||||
|
||||
#if defined(DEBUG) || VIDEO_ENCODED_RECORDER_VERBOSE
|
||||
@@ -67,86 +63,14 @@ const vp_api_stage_funcs_t video_encoded_recorder_funcs = {
|
||||
video_stage_encoded_recorder_config_t video_stage_encoded_recorder_config;
|
||||
|
||||
|
||||
#ifdef USE_ELINUX
|
||||
DEFINE_THREAD_ROUTINE_STACK(video_stage_encoded_recorder,param,VIDEO_STAGE_ENCODED_RECORDER_STACK_SIZE)
|
||||
{
|
||||
int res;
|
||||
video_stage_encoded_recorder_config_t *cfg = (video_stage_encoded_recorder_config_t *)param;
|
||||
video_stage_encoded_recorder_msg_t msg;
|
||||
char errBuf [50] = {0};
|
||||
ardrone_video_error_t vError = ARDRONE_VIDEO_NO_ERROR;
|
||||
parrot_video_encapsulation_t *PaVE;
|
||||
//int counter = 0;
|
||||
|
||||
/* TODO : check if mutual exclusion with the main thread is needed */
|
||||
|
||||
while(1)
|
||||
{
|
||||
/* Read the address of a new slice to write in the video file */
|
||||
res = read(cfg->com_pipe[0],&msg,sizeof(msg));
|
||||
|
||||
if (res!=sizeof(msg)) { sleep(1); continue; }
|
||||
|
||||
//printf("----> Reading %p %d bytes\n",msg.slice,msg.sliceSize);
|
||||
PaVE = (parrot_video_encapsulation_t *) msg.slice;
|
||||
|
||||
if (msg.slice!=NULL)
|
||||
{
|
||||
/* Create a new MP4 file if necessary */
|
||||
if (NULL==cfg->video)
|
||||
{
|
||||
cfg->video = ardrone_video_start (cfg->video_filename, cfg->fps, VIDEO_FORMAT, &vError);
|
||||
if (ARDRONE_VIDEO_SUCCEEDED (vError) && NULL != cfg->video)
|
||||
{
|
||||
cfg->currentStreamId = PaVE->stream_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
VER_PRINT ("An error occured when creating video");
|
||||
cfg->startRec=VIDEO_ENCODED_STOPPED;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL!=cfg->video)
|
||||
{
|
||||
ardrone_video_error_t vError = ardrone_video_addSlice (cfg->video, msg.slice);
|
||||
|
||||
if (ARDRONE_VIDEO_FAILED (vError))
|
||||
{
|
||||
ardrone_video_error_string (vError, errBuf, 50);
|
||||
VER_PRINT ("Error while recording frame : %s", errBuf);
|
||||
ardrone_video_cleanup (&(cfg->video));
|
||||
cfg->startRec = VIDEO_ENCODED_STOPPED;
|
||||
}
|
||||
if (1 == frameIsLastFrame(msg.slice))
|
||||
{
|
||||
VER_PRINT ("Received last frame for current stream, finishing video\n");
|
||||
video_stage_encoded_recorder_finish (cfg);
|
||||
}
|
||||
|
||||
//counter++; if (counter%16) { sync(); }
|
||||
}
|
||||
|
||||
/* Free the data bloc which was just written */
|
||||
vp_os_free(msg.slice);
|
||||
}
|
||||
else /* the data pointer is NULL to signal the end of the recording */
|
||||
{
|
||||
video_stage_encoded_recorder_finish (cfg);
|
||||
}
|
||||
|
||||
}/*while 1*/
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
C_RESULT video_stage_encoded_recorder_finish (video_stage_encoded_recorder_config_t *cfg)
|
||||
{
|
||||
C_RESULT retVal = C_OK;
|
||||
|
||||
#ifndef USE_ELINUX
|
||||
endRetreiving ();
|
||||
#endif
|
||||
|
||||
cfg->lastStreamId = cfg->currentStreamId;
|
||||
ardrone_video_error_t vError = ardrone_video_finish (&(cfg->video));
|
||||
@@ -154,7 +78,7 @@ C_RESULT video_stage_encoded_recorder_finish (video_stage_encoded_recorder_confi
|
||||
{
|
||||
VER_PRINT ("Video %s successfully written", cfg->video_filename);
|
||||
if(cfg->finish_callback != NULL)
|
||||
cfg->finish_callback((const char *)cfg->video_filename);
|
||||
cfg->finish_callback((const char *)cfg->video_filename, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -165,24 +89,12 @@ C_RESULT video_stage_encoded_recorder_finish (video_stage_encoded_recorder_confi
|
||||
vp_os_memset (cfg->video_filename, 0x0, VIDEO_ENCODED_FILENAME_LENGTH);
|
||||
cfg->startRec = VIDEO_ENCODED_STOPPED;
|
||||
|
||||
#ifdef USE_ELINUX
|
||||
ardrone_video_system_cleanup();
|
||||
#endif
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
C_RESULT video_stage_encoded_recorder_handle (video_stage_encoded_recorder_config_t * cfg, PIPELINE_MSG msg_id, void *callback, void *param)
|
||||
{
|
||||
#ifdef USE_ELINUX
|
||||
/* Handling the asynchronous mode */
|
||||
video_stage_encoded_recorder_msg_t asyn_msg;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef USE_ELINUX
|
||||
vp_os_mutex_lock (&cfg->videoMutex);
|
||||
#endif
|
||||
|
||||
void (*recorder_callback)(video_stage_encoded_recorder_config_t*) = callback;
|
||||
|
||||
@@ -191,6 +103,7 @@ C_RESULT video_stage_encoded_recorder_handle (video_stage_encoded_recorder_confi
|
||||
case PIPELINE_MSG_START: // video start
|
||||
if(cfg->startRec==VIDEO_ENCODED_STOPPED)
|
||||
{
|
||||
cfg->startRec = VIDEO_ENCODED_START_RECORD;
|
||||
time_t t;
|
||||
char date[ARDRONE_DATE_MAXSIZE];
|
||||
ardrone_time2date(*((uint32_t*)param), ARDRONE_FILE_DATE_FORMAT, date);
|
||||
@@ -211,7 +124,6 @@ C_RESULT video_stage_encoded_recorder_handle (video_stage_encoded_recorder_confi
|
||||
date,
|
||||
MOVIE_FILE_EXTENSION);
|
||||
|
||||
cfg->startRec = VIDEO_ENCODED_START_RECORD;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -223,9 +135,7 @@ C_RESULT video_stage_encoded_recorder_handle (video_stage_encoded_recorder_confi
|
||||
else if (cfg->startRec==VIDEO_ENCODED_RECORDING)
|
||||
{
|
||||
cfg->startRec = VIDEO_ENCODED_WAITING_STREAM_END;
|
||||
#ifndef USE_ELINUX
|
||||
startRetreiving ();
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -237,23 +147,7 @@ C_RESULT video_stage_encoded_recorder_handle (video_stage_encoded_recorder_confi
|
||||
else if (cfg->startRec==VIDEO_ENCODED_RECORDING ||
|
||||
cfg->startRec==VIDEO_ENCODED_WAITING_STREAM_END)
|
||||
{
|
||||
#ifdef USE_ELINUX
|
||||
if (cfg->use_asynchronous_mode)
|
||||
{
|
||||
/* Send an empty slice to the asynchronous thread */
|
||||
asyn_msg.sliceSize = 0;
|
||||
asyn_msg.slice = NULL;
|
||||
write(cfg->com_pipe[1],&asyn_msg,sizeof(asyn_msg));
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
video_stage_encoded_recorder_finish (cfg);
|
||||
|
||||
#ifdef USE_ELINUX
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -264,9 +158,7 @@ C_RESULT video_stage_encoded_recorder_handle (video_stage_encoded_recorder_confi
|
||||
recorder_callback(cfg);
|
||||
}
|
||||
|
||||
#ifndef USE_ELINUX
|
||||
vp_os_mutex_unlock (&cfg->videoMutex);
|
||||
#endif
|
||||
|
||||
return (VP_SUCCESS);
|
||||
}
|
||||
@@ -314,27 +206,9 @@ C_RESULT video_stage_encoded_recorder_open(video_stage_encoded_recorder_config_t
|
||||
|
||||
cfg->video = NULL;
|
||||
|
||||
#ifndef USE_ELINUX
|
||||
|
||||
vp_os_mutex_init (&cfg->videoMutex);
|
||||
ardrone_video_remove_all (VIDEO_ENCODED_FILE_DEFAULT_PATH);
|
||||
#endif
|
||||
|
||||
#ifdef USE_ELINUX
|
||||
if (cfg->use_asynchronous_mode){
|
||||
/* Create a pipe to send video slices to the recording thread */
|
||||
pipe((int*)(&cfg->com_pipe));
|
||||
|
||||
/* Create the above-mentioned thread */
|
||||
vp_os_thread_create(thread_video_stage_encoded_recorder,
|
||||
(void*)cfg,
|
||||
&cfg->thread_handle,
|
||||
cfg->thread_priority,
|
||||
"VideoFlashRec",
|
||||
(void*)stack_video_stage_encoded_recorder,
|
||||
sizeof(stack_video_stage_encoded_recorder),
|
||||
&cfg->thread );
|
||||
}
|
||||
#endif
|
||||
|
||||
return C_OK;
|
||||
}
|
||||
@@ -353,22 +227,11 @@ int frameIsLastFrame (uint8_t *data)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
#ifdef USE_ELINUX
|
||||
int ardrone_video_usb_key_get_free_space(void);
|
||||
#endif
|
||||
|
||||
C_RESULT video_stage_encoded_recorder_transform(video_stage_encoded_recorder_config_t *cfg, vp_api_io_data_t *in, vp_api_io_data_t *out)
|
||||
{
|
||||
#ifdef USE_ELINUX
|
||||
/* Handling the asynchronous mode */
|
||||
video_stage_encoded_recorder_msg_t asyn_msg;
|
||||
#endif
|
||||
|
||||
vp_os_mutex_lock (&out->lock);
|
||||
|
||||
#ifndef USE_ELINUX
|
||||
vp_os_mutex_lock (&cfg->videoMutex);
|
||||
#endif
|
||||
|
||||
// Copy in to out
|
||||
if (NULL != in && NULL != out)
|
||||
@@ -382,11 +245,6 @@ C_RESULT video_stage_encoded_recorder_transform(video_stage_encoded_recorder_con
|
||||
out->status = VP_API_STATUS_PROCESSING;
|
||||
}
|
||||
|
||||
#ifdef USE_ELINUX
|
||||
/* The drone pipeline may call the recorder with an empty input */
|
||||
|
||||
if (NULL==in || NULL==in->buffers || in->size<1) { vp_os_mutex_unlock (&out->lock); return C_OK; }
|
||||
#endif
|
||||
|
||||
uint8_t *slice = in->buffers[in->indexBuffer];
|
||||
parrot_video_encapsulation_t *PaVE = (parrot_video_encapsulation_t *)slice;
|
||||
@@ -394,9 +252,7 @@ C_RESULT video_stage_encoded_recorder_transform(video_stage_encoded_recorder_con
|
||||
if (cfg->lastStreamId == PaVE->stream_id)
|
||||
{
|
||||
VER_PRINT ("Got a video slice from an old stream, skipping\n");
|
||||
#ifndef USE_ELINUX
|
||||
vp_os_mutex_unlock (&cfg->videoMutex);
|
||||
#endif
|
||||
vp_os_mutex_unlock (&out->lock);
|
||||
return C_OK;
|
||||
}
|
||||
@@ -405,20 +261,6 @@ C_RESULT video_stage_encoded_recorder_transform(video_stage_encoded_recorder_con
|
||||
{
|
||||
ardrone_video_error_t vError = ARDRONE_VIDEO_NO_ERROR;
|
||||
|
||||
#ifdef USE_ELINUX
|
||||
/* Determine the amount of video data we can store */
|
||||
cfg->quota = ardrone_video_usb_key_get_free_space() /* kbytes */ - ( 100 * 1024 ); /* Keep 100 megabytes free */
|
||||
if(cfg->quota<0) { cfg->quota = 0; }
|
||||
printf("Flash video recording : available space : %dkb (time est. %d\'%d\") - (keeping a 100Mb margin on %s)\n",
|
||||
cfg->quota,(cfg->quota>>10)/60,(cfg->quota>>10)%60,
|
||||
VIDEO_ENCODED_FILE_DEFAULT_PATH);
|
||||
|
||||
if (cfg->use_asynchronous_mode)
|
||||
{
|
||||
cfg->startRec=VIDEO_ENCODED_RECORDING;
|
||||
}
|
||||
else{
|
||||
#endif
|
||||
|
||||
cfg->video = ardrone_video_start (cfg->video_filename, cfg->fps, VIDEO_FORMAT, &vError);
|
||||
if (ARDRONE_VIDEO_SUCCEEDED (vError) && NULL != cfg->video)
|
||||
@@ -431,11 +273,6 @@ C_RESULT video_stage_encoded_recorder_transform(video_stage_encoded_recorder_con
|
||||
VER_PRINT ("An error occured when creating video");
|
||||
cfg->startRec=VIDEO_ENCODED_STOPPED;
|
||||
}
|
||||
|
||||
#ifdef USE_ELINUX
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if((cfg->startRec == VIDEO_ENCODED_RECORDING) ||
|
||||
@@ -453,40 +290,6 @@ C_RESULT video_stage_encoded_recorder_transform(video_stage_encoded_recorder_con
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_ELINUX
|
||||
if (( ( in->size /*bytes*/ ) >>10 ) > cfg->quota )
|
||||
{
|
||||
printf("Flash video recording : out of disk space.\n");
|
||||
cfg->startRec=VIDEO_ENCODED_STOPPED;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg->quota /*kbytes*/ -= ( ( in->size /*bytes*/ ) >>10 );
|
||||
navdata_set_hdvideo_usbkey_freespace(cfg->quota);
|
||||
|
||||
if (cfg->use_asynchronous_mode)
|
||||
{
|
||||
/* Create a RAM buffer to hold a temporary copy of the slice to write */
|
||||
asyn_msg.sliceSize = in->size;
|
||||
asyn_msg.slice = vp_os_malloc(asyn_msg.sliceSize);
|
||||
if (asyn_msg.slice){
|
||||
vp_os_memcpy(asyn_msg.slice,slice,asyn_msg.sliceSize);
|
||||
/* Send the copy to thread which does the actual writing */
|
||||
//printf("----> Writing %p %d bytes\n",asyn_msg.slice,asyn_msg.sliceSize);
|
||||
write(cfg->com_pipe[1],&asyn_msg,sizeof(asyn_msg));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Flash video recording : out of RAM - dropping frame.\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
ardrone_video_error_t vError = ardrone_video_addSlice (cfg->video, slice);
|
||||
if (ARDRONE_VIDEO_FAILED (vError))
|
||||
{
|
||||
@@ -503,14 +306,8 @@ C_RESULT video_stage_encoded_recorder_transform(video_stage_encoded_recorder_con
|
||||
video_stage_encoded_recorder_finish (cfg);
|
||||
}
|
||||
|
||||
#ifdef USE_ELINUX
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifndef USE_ELINUX
|
||||
vp_os_mutex_unlock (&cfg->videoMutex);
|
||||
#endif
|
||||
vp_os_mutex_unlock (&out->lock);
|
||||
return C_OK;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ typedef enum
|
||||
} video_encoded_record_state;
|
||||
#endif
|
||||
|
||||
typedef void (*video_stage_encoded_recorder_callback)(const char *mediaPath);
|
||||
typedef void (*video_stage_encoded_recorder_callback)(const char *mediaPath, bool_t addToQueue);
|
||||
|
||||
typedef struct _video_stage_encoded_recorder_config_t
|
||||
{
|
||||
|
||||
@@ -214,6 +214,7 @@ void ffmpeg_decoder_dumpPave (parrot_video_encapsulation_t *PaVE)
|
||||
|
||||
static inline bool_t check_and_copy_PaVE (parrot_video_encapsulation_t *PaVE, vp_api_io_data_t *data, parrot_video_encapsulation_t *prevPaVE, bool_t *dimChanged)
|
||||
{
|
||||
|
||||
parrot_video_encapsulation_t *localPaVE = (parrot_video_encapsulation_t *)data->buffers[data->indexBuffer];
|
||||
if (localPaVE->signature[0] == 'P' &&
|
||||
localPaVE->signature[1] == 'a' &&
|
||||
@@ -225,8 +226,6 @@ static inline bool_t check_and_copy_PaVE (parrot_video_encapsulation_t *PaVE, vp
|
||||
|
||||
vp_os_memcpy (PaVE, localPaVE, sizeof (parrot_video_encapsulation_t)); // Copy PaVE to our local one
|
||||
|
||||
|
||||
|
||||
#if __FFMPEG_DEBUG_ENABLED
|
||||
printf ("------------------------------------\n");
|
||||
printf ("PREV : ");
|
||||
@@ -291,7 +290,8 @@ C_RESULT ffmpeg_stage_decoding_transform(ffmpeg_stage_decoding_config_t *cfg, vp
|
||||
int frameFinished = 0;
|
||||
|
||||
bool_t frameDimChanged = FALSE;
|
||||
static parrot_video_encapsulation_t PaVE, prevPaVE;
|
||||
static parrot_video_encapsulation_t __attribute__ ((aligned (4))) PaVE;
|
||||
static parrot_video_encapsulation_t __attribute__ ((aligned (4))) prevPaVE;
|
||||
|
||||
#if WAIT_FOR_I_FRAME
|
||||
static bool_t waitForIFrame = TRUE;
|
||||
@@ -387,6 +387,7 @@ C_RESULT ffmpeg_stage_decoding_transform(ffmpeg_stage_decoding_config_t *cfg, vp
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if(out->status == VP_API_STATUS_PROCESSING && (!waitForIFrame || (PaVE.frame_type == FRAME_TYPE_IDR_FRAME) || (PaVE.frame_type == FRAME_TYPE_I_FRAME))) // Processing code
|
||||
{
|
||||
waitForIFrame = FALSE;
|
||||
@@ -399,6 +400,7 @@ C_RESULT ffmpeg_stage_decoding_transform(ffmpeg_stage_decoding_config_t *cfg, vp
|
||||
packet.size = in->size;
|
||||
FFMPEG_DEBUG("Size : %d", packet.size);
|
||||
|
||||
|
||||
#ifdef NUM_SAMPLES
|
||||
struct timeval end_time;
|
||||
static float32_t frame_decoded_time = 0;
|
||||
@@ -443,6 +445,11 @@ C_RESULT ffmpeg_stage_decoding_transform(ffmpeg_stage_decoding_config_t *cfg, vp
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Skip frames are usually 7 bytes long
|
||||
* and make FFMPEG return an error. It is however normal to get
|
||||
* skip frames from the drone.
|
||||
*/
|
||||
if (7!=PaVE.payload_size)
|
||||
printf ("Decoding failed for a %s\n", (PaVE.frame_type == FRAME_TYPE_P_FRAME) ? "P Frame" : "I Frame");
|
||||
}
|
||||
|
||||
|
||||
@@ -795,7 +795,9 @@ C_RESULT ittiam_stage_decoding_close(ittiam_stage_decoding_config_t *cfg) {
|
||||
}
|
||||
|
||||
vp_os_free(h264_mem_rec);
|
||||
h264_mem_rec = NULL;
|
||||
vp_os_free(h264_ps_it_mem);
|
||||
h264_ps_it_mem = NULL;
|
||||
|
||||
} else if (current_PaVE.video_codec == CODEC_MPEG4_VISUAL) {
|
||||
//MPEG4
|
||||
@@ -820,7 +822,9 @@ C_RESULT ittiam_stage_decoding_close(ittiam_stage_decoding_config_t *cfg) {
|
||||
}
|
||||
|
||||
vp_os_free(mpeg4_mem_rec);
|
||||
mpeg4_mem_rec = NULL;
|
||||
vp_os_free(mpeg4_ps_it_mem);
|
||||
mpeg4_ps_it_mem = NULL;
|
||||
}
|
||||
old_num_frame = cfg->num_picture_decoded;
|
||||
ITTIAM_DEBUG_PRINT("ITTIAM CLEAN");
|
||||
|
||||
@@ -404,7 +404,10 @@ C_RESULT video_stage_tcp_transform(video_stage_tcp_config_t *cfg, vp_api_io_data
|
||||
C_RESULT video_stage_tcp_close(video_stage_tcp_config_t *cfg)
|
||||
{
|
||||
vp_os_free (cfg->bufferPointer);
|
||||
cfg->bufferPointer = NULL;
|
||||
vp_os_free (cfg->globalBuffer);
|
||||
cfg->globalBuffer = NULL;
|
||||
vp_os_free (cfg->frameBuffer);
|
||||
cfg->frameBuffer = NULL;
|
||||
return C_OK;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ C_RESULT vlib_stage_decoding_open(vlib_stage_decoding_config_t *cfg)
|
||||
video_controller_set_format( &cfg->controller, ACQ_WIDTH, ACQ_HEIGHT );
|
||||
|
||||
vp_os_free( cfg->controller.in_stream.bytes );
|
||||
cfg->controller.in_stream.bytes = NULL;
|
||||
|
||||
return C_OK;
|
||||
}
|
||||
|
||||
@@ -332,14 +332,11 @@ int ardrone_tool_main(int argc, char **argv)
|
||||
argc--; argv++;
|
||||
}
|
||||
|
||||
// Making the driver ROS compatible
|
||||
/*
|
||||
if( show_usage || (argc != 0) )
|
||||
{
|
||||
ardrone_tool_usage( appname );
|
||||
exit(-1);
|
||||
}
|
||||
*/
|
||||
|
||||
/* After a first analysis, the arguments are restored so they can be passed to the user-defined functions */
|
||||
argc=argc_backup;
|
||||
@@ -351,7 +348,6 @@ int ardrone_tool_main(int argc, char **argv)
|
||||
{
|
||||
PRINT("You have to install new locales in your dev environment! (avoid the need of conv_coma_to_dot)\n");
|
||||
PRINT("As root, do a \"dpkg-reconfigure locales\" and add en_GB.UTF8 to your locale settings\n");
|
||||
PRINT("If you have any problem, feel free to contact Pierre Eline (pierre.eline@parrot.com)\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -407,10 +403,12 @@ int ardrone_tool_main(int argc, char **argv)
|
||||
appname = &argv[0][lastSlashPos+1];
|
||||
ardrone_gen_appid (appname, __SDK_VERSION__, app_id, app_name, sizeof (app_name));
|
||||
res = ardrone_tool_init(wifi_ardrone_ip, strlen(wifi_ardrone_ip), NULL, appname, NULL, NULL, NULL, MAX_FLIGHT_STORING_SIZE, NULL);
|
||||
|
||||
while( SUCCEED(res) && ardrone_tool_exit() == FALSE )
|
||||
{
|
||||
res = ardrone_tool_update();
|
||||
}
|
||||
|
||||
res = ardrone_tool_shutdown();
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ C_RESULT ardrone_tool_shutdown(void);
|
||||
|
||||
void ardrone_tool_init_timers_and_mutex();
|
||||
void ardrone_tool_send_com_watchdog(void); // To send it only once
|
||||
//int main();
|
||||
int main();
|
||||
|
||||
// There because not defined in embedded
|
||||
void api_configuration_get_ctrl_mode(void);
|
||||
|
||||
@@ -226,9 +226,15 @@ static void ardrone_tool_configuration_event_configure_end(struct _ardrone_contr
|
||||
}
|
||||
|
||||
if (NULL!=ardrone_tool_configuration_data[ardrone_tool_configuration_current_index].value)
|
||||
{
|
||||
vp_os_free(ardrone_tool_configuration_data[ardrone_tool_configuration_current_index].value);
|
||||
ardrone_tool_configuration_data[ardrone_tool_configuration_current_index].value = NULL;
|
||||
}
|
||||
if (NULL!=ardrone_tool_configuration_data[ardrone_tool_configuration_current_index].event)
|
||||
{
|
||||
vp_os_free(ardrone_tool_configuration_data[ardrone_tool_configuration_current_index].event);
|
||||
ardrone_tool_configuration_data[ardrone_tool_configuration_current_index].event = NULL;
|
||||
}
|
||||
ardrone_tool_configuration_data[ardrone_tool_configuration_current_index].event = NULL;
|
||||
ardrone_tool_configuration_data[ardrone_tool_configuration_current_index].value = NULL;
|
||||
ardrone_tool_configuration_current_index = (ardrone_tool_configuration_current_index + 1) % ARDRONE_TOOL_CONFIGURATION_MAX_EVENT;
|
||||
@@ -269,7 +275,9 @@ static void ardrone_tool_configuration_event_configure(void)
|
||||
ardrone_control_ack_event_t *event = NULL;
|
||||
|
||||
if (ardrone_tool_configuration_data[ardrone_tool_configuration_current_index].callback)
|
||||
{
|
||||
ardrone_tool_configuration_data[ardrone_tool_configuration_current_index].callback(ardrone_tool_configuration_data[ardrone_tool_configuration_current_index].value, ses_id, usr_id, app_id);
|
||||
}
|
||||
|
||||
if(ardrone_tool_configuration_data[ardrone_tool_configuration_current_index].event == NULL)
|
||||
ardrone_tool_configuration_data[ardrone_tool_configuration_current_index].event = vp_os_malloc(sizeof(ardrone_control_ack_event_t));
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifndef USE_ELINUX
|
||||
|
||||
int
|
||||
compareVersions (ardrone_version_t *v1, ardrone_version_t *v2)
|
||||
{
|
||||
@@ -53,6 +55,7 @@ getDroneVersion (const char *tempPath, const char *droneIp, ardrone_version_t *v
|
||||
if (FTP_FAILED (status))
|
||||
{
|
||||
vp_os_free (localName);
|
||||
localName = NULL;
|
||||
ftpClose (&ftp);
|
||||
return -1;
|
||||
}
|
||||
@@ -64,6 +67,7 @@ getDroneVersion (const char *tempPath, const char *droneIp, ardrone_version_t *v
|
||||
{
|
||||
remove (localName);
|
||||
vp_os_free (localName);
|
||||
localName = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -73,12 +77,14 @@ getDroneVersion (const char *tempPath, const char *droneIp, ardrone_version_t *v
|
||||
fclose (versionFile);
|
||||
remove (localName);
|
||||
vp_os_free (localName);
|
||||
localName = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
fclose (versionFile);
|
||||
remove (localName);
|
||||
vp_os_free (localName);
|
||||
localName = NULL;
|
||||
|
||||
version->majorVersion = maj;
|
||||
version->minorVersion = min;
|
||||
@@ -86,3 +92,5 @@ getDroneVersion (const char *tempPath, const char *droneIp, ardrone_version_t *v
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -59,6 +59,8 @@ int getDroneVersion (const char *tempPath, const char *droneIp, ardrone_version_
|
||||
# define ARDRONE_VERSION() 1
|
||||
# endif
|
||||
|
||||
#define getDroneVersion(...) ARDRONE_VERSION()
|
||||
|
||||
#endif
|
||||
|
||||
#define IS_ARDRONE1 (1 == ARDRONE_VERSION()) // Drone 1
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <VP_Os/vp_os_print.h>
|
||||
|
||||
/* CONFIGURATION */
|
||||
|
||||
// All following macros MUST be defined !
|
||||
@@ -28,7 +30,7 @@
|
||||
// To deactivate, define to (0)
|
||||
|
||||
#ifdef DEBUG // Debug options
|
||||
#define _FTP_DEBUG (1) // Common debug informations
|
||||
#define _FTP_DEBUG (0) // Common debug informations
|
||||
#define _FTP_VERBOSE (0) // Extended debug information (many outputs on ftpList)
|
||||
#define _FTP_ERRORS_PRINT (1) // Display of error messages
|
||||
#else // Release options
|
||||
@@ -45,8 +47,8 @@
|
||||
#define FTP_ERROR(...) \
|
||||
do \
|
||||
{ \
|
||||
fprintf (stderr, "Error in function %s at line %d : ", __FUNCTION__, __LINE__); \
|
||||
fprintf (stderr, __VA_ARGS__); \
|
||||
PRINT ("Error in function %s at line %d : ", __FUNCTION__, __LINE__); \
|
||||
PRINT (__VA_ARGS__); \
|
||||
char *errorBuffer = vp_os_calloc (COMMAND_BUFFER_SIZE, 1); \
|
||||
if (NULL != errorBuffer) \
|
||||
{ \
|
||||
@@ -83,8 +85,8 @@
|
||||
#define FTP_DEBUG(...) \
|
||||
do \
|
||||
{ \
|
||||
printf ("Debug from function %s at line %d : ", __FUNCTION__, __LINE__); \
|
||||
printf (__VA_ARGS__); \
|
||||
PRINT ("Debug from function %s at line %d : ", __FUNCTION__, __LINE__); \
|
||||
PRINT (__VA_ARGS__); \
|
||||
} while (0)
|
||||
#else
|
||||
#define FTP_DEBUG(...)
|
||||
@@ -94,8 +96,8 @@
|
||||
#define FTP_PRINT(...) \
|
||||
do \
|
||||
{ \
|
||||
printf (FTP_PREFIX); \
|
||||
printf (__VA_ARGS__); \
|
||||
PRINT (FTP_PREFIX); \
|
||||
PRINT (__VA_ARGS__); \
|
||||
} while (0)
|
||||
#else
|
||||
#define FTP_PRINT(...)
|
||||
@@ -116,7 +118,7 @@
|
||||
/* TIMEOUT MACROS */
|
||||
|
||||
/* Total socket timeout : SOCK_TO_SEC + SOCK_TO_USEC */
|
||||
#define SOCK_TO_SEC 1 // Socket timeout (seconds)
|
||||
#define SOCK_TO_SEC 3 // Socket timeout (seconds)
|
||||
#define SOCK_TO_USEC 0 // Socket timeout (useconds)
|
||||
|
||||
/* GLOBAL ERROR MESSAGE STRING */
|
||||
@@ -158,6 +160,7 @@ struct _ftp_list_param_s
|
||||
};
|
||||
|
||||
/* LOCAL FUNCTIONS PROTOTYPES */
|
||||
int isLANIp (const char *ip);
|
||||
void emptyCallback (_ftp_status status, void *arg, _ftp_t *callingFtp);
|
||||
_ftp_status waitFor226Answer (_ftp_t *ftp);
|
||||
int setSockTimeout (int socket, int timeoutSec, int timeoutUsec);
|
||||
@@ -166,7 +169,7 @@ void flushFtp (_ftp_t *ftp);
|
||||
int getFileSize (_ftp_t *ftp, const char *distPath);
|
||||
int getLocalFileSize (const char *localPath);
|
||||
int getResponseCode (const char *response);
|
||||
_ftp_status getPassiveIpAndPort (const char *response, char *ip, int *port, int ipLen);
|
||||
_ftp_status getPassiveIpAndPort (_ftp_t *ftp, const char *response, char *ip, int *port, int ipLen);
|
||||
_ftp_status ftpTransfert (_ftp_t *ftp, const char *message, char *answer, int answSize);
|
||||
_ftp_status ftpSend (_ftp_t *ftp, const char *message);
|
||||
_ftp_status ftpRecv (_ftp_t *ftp, char *answer, int answSize);
|
||||
@@ -175,6 +178,42 @@ DEFINE_THREAD_ROUTINE (ftpPut, param);
|
||||
DEFINE_THREAD_ROUTINE (ftpList, param);
|
||||
|
||||
/* FUNCTIONS IMPLEMENTATION */
|
||||
int
|
||||
isLANIp (const char *ip)
|
||||
{
|
||||
int retVal = -1;
|
||||
uint32_t ip0, ip1, ip2, ip3;
|
||||
if (4 == sscanf (ip, "%u.%u.%u.%u", &ip0, &ip1, &ip2, &ip3))
|
||||
{
|
||||
/* LAN address classes :
|
||||
* 127.x.x.x
|
||||
* 10.x.x.x
|
||||
* 192.168.x.x
|
||||
* 169.254.x.x
|
||||
* 172.[16-31].x.x
|
||||
*
|
||||
* Test IP is :
|
||||
* ip0.ip1.ip2.ip3
|
||||
*/
|
||||
if (((127 == ip0)) ||
|
||||
((10 == ip0)) ||
|
||||
((192 == ip0) && (168 == ip1)) ||
|
||||
((169 == ip0) && (254 == ip1)) ||
|
||||
((172 == ip0) && (16 <= ip1) && (31 >= ip1)))
|
||||
{
|
||||
retVal = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FTP_ERROR ("String %s does not represent a valid ipv4 address\n", ip);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void
|
||||
emptyCallback (_ftp_status status, void *arg, _ftp_t *callingFtp)
|
||||
@@ -348,7 +387,7 @@ getResponseCode (const char *response)
|
||||
}
|
||||
|
||||
_ftp_status
|
||||
getPassiveIpAndPort (const char *response, char *ip, int *port, int ipLen)
|
||||
getPassiveIpAndPort (_ftp_t *ftp, const char *response, char *ip, int *port, int ipLen)
|
||||
{
|
||||
int ip1, ip2, ip3, ip4, port1, port2;
|
||||
int indexOfFirstIpField = 0;
|
||||
@@ -370,6 +409,20 @@ getPassiveIpAndPort (const char *response, char *ip, int *port, int ipLen)
|
||||
{
|
||||
result = FTP_FAIL;
|
||||
}
|
||||
int pasvIsLan = isLANIp (ip);
|
||||
int servIsLan = isLANIp (ftp->socket->serverHost);
|
||||
if (-1 == pasvIsLan || -1 == servIsLan)
|
||||
{
|
||||
// Error while parsing IP ...
|
||||
result = FTP_FAIL;
|
||||
}
|
||||
else if (1 == pasvIsLan && 0 == servIsLan)
|
||||
{
|
||||
FTP_DEBUG ("pasv ip is a LAN ip (not routable), but server ip is not a LAN ip. We'll use the server ip (%s) instead of the pasv ip (%s)\n", ftp->socket->serverHost, ip);
|
||||
strncpy (ip, ftp->socket->serverHost, ipLen);
|
||||
}
|
||||
// No else : if pasv addr is routable or if both address are LAN address, keep pasv ip.
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -635,6 +688,7 @@ ftpConnect (const char *ip, int port, const char *username, const char *password
|
||||
retFtp->connected = 1;
|
||||
retFtp->opInProgress = 0;
|
||||
retFtp->abortCurrentOp = 0;
|
||||
retFtp->tag = NULL;
|
||||
vp_os_free (srvMsg);
|
||||
vp_os_free (buffer);
|
||||
return retFtp;
|
||||
@@ -739,7 +793,7 @@ DEFINE_THREAD_ROUTINE (ftpList, param)
|
||||
|
||||
char dataIp [IP_STRING_SIZE] = {0};
|
||||
int dataPort = 0;
|
||||
getPassiveIpAndPort (srvMsg, dataIp, &dataPort, IP_STRING_SIZE);
|
||||
getPassiveIpAndPort (params->ftp, srvMsg, dataIp, &dataPort, IP_STRING_SIZE);
|
||||
|
||||
FTP_DEBUG ("Thread will connect to %s:%d\n", dataIp, dataPort);
|
||||
dataSocket = vp_os_malloc (sizeof (vp_com_socket_t));
|
||||
@@ -920,7 +974,7 @@ DEFINE_THREAD_ROUTINE (ftpGet, param)
|
||||
|
||||
char dataIp [IP_STRING_SIZE] = {0};
|
||||
int dataPort = 0;
|
||||
getPassiveIpAndPort (srvMsg, dataIp, &dataPort, IP_STRING_SIZE);
|
||||
getPassiveIpAndPort (params->ftp, srvMsg, dataIp, &dataPort, IP_STRING_SIZE);
|
||||
|
||||
ftp_result = goToBinaryMode (params->ftp);
|
||||
if (FTP_FAILED (ftp_result))
|
||||
@@ -930,7 +984,7 @@ DEFINE_THREAD_ROUTINE (ftpGet, param)
|
||||
}
|
||||
|
||||
int fileSize = getFileSize (params->ftp, params->remoteName);
|
||||
if (0 >= fileSize)
|
||||
if (0 > fileSize)
|
||||
{
|
||||
FTP_ERROR ("File %s does not exist on server\n", params->remoteName);
|
||||
CLEAN_PARAMS (FTP_FAIL);
|
||||
@@ -939,6 +993,18 @@ DEFINE_THREAD_ROUTINE (ftpGet, param)
|
||||
int localFileSize = getLocalFileSize (params->localName);
|
||||
int appendToFile = params->useResume;
|
||||
int appendOffset = 0;
|
||||
if (-1 == localFileSize && 0 == fileSize)
|
||||
{
|
||||
// Zero byte file on server
|
||||
FTP_DEBUG ("Zero byte file on server, create empty file locally\n");
|
||||
FILE *fdesc = fopen (params->localName, "ab");
|
||||
if (NULL != fdesc)
|
||||
{
|
||||
fclose (fdesc);
|
||||
}
|
||||
CLEAN_PARAMS (FTP_SUCCESS);
|
||||
}
|
||||
|
||||
if (-1 == localFileSize && 1 == params->useResume)
|
||||
{
|
||||
FTP_DEBUG ("File does not exist ... full download\n");
|
||||
@@ -1128,7 +1194,7 @@ DEFINE_THREAD_ROUTINE (ftpPut, param)
|
||||
|
||||
char dataIp [IP_STRING_SIZE] = {0};
|
||||
int dataPort = 0;
|
||||
getPassiveIpAndPort (srvMsg, dataIp, &dataPort, IP_STRING_SIZE);
|
||||
getPassiveIpAndPort (params->ftp, srvMsg, dataIp, &dataPort, IP_STRING_SIZE);
|
||||
|
||||
ftp_result = goToBinaryMode (params->ftp);
|
||||
if (FTP_FAILED (ftp_result))
|
||||
|
||||
@@ -61,6 +61,7 @@ typedef struct _ftp_s
|
||||
int abortCurrentOp;
|
||||
_ftp_status lastStatus;
|
||||
char *lastFileList;
|
||||
void * tag; // Allows to put any pointer to some useful data that is associated with this ftp connectionS
|
||||
} _ftp_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
#include <utils/ardrone_time.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <sys/timeb.h>
|
||||
#include <sys/timeb.h>
|
||||
|
||||
static int _gettimeofday (struct timeval *tp, void *tz)
|
||||
{
|
||||
static int _gettimeofday (struct timeval *tp, void *tz)
|
||||
{
|
||||
struct _timeb timebuffer;
|
||||
_ftime (&timebuffer);
|
||||
tp->tv_sec = (long)timebuffer.time;
|
||||
tp->tv_usec = (long)timebuffer.millitm * 1000;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#elif defined(TARGET_OS_IPHONE) || defined(TARGET_OS_SIMULATOR)
|
||||
#include <mach/mach_time.h>
|
||||
static int _gettimeofday (struct timeval *tp, void *tz)
|
||||
@@ -69,7 +69,7 @@ C_RESULT ardrone_timer_update(ardrone_timer_t* timer)
|
||||
}
|
||||
timer->tv.tv_sec -= timer->tv_init.tv_sec;
|
||||
|
||||
return C_OK;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
uint64_t ardrone_timer_elapsed_ms(ardrone_timer_t* timer)
|
||||
@@ -127,7 +127,7 @@ uint64_t ardrone_timer_delta_us(ardrone_timer_t* timer)
|
||||
if (C_OK == ardrone_timer_update(&timer_current))
|
||||
{
|
||||
retVal = ardrone_timer_elapsed_us(&timer_current) - ardrone_timer_elapsed_us(timer);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
#include <VP_Os/vp_os_types.h>
|
||||
|
||||
#define ARDRONE_TIME_SEC_TO_MSEC(x) ((x)*1000.f)
|
||||
#define ARDRONE_TIME_MSEC_TO_SEC(x) ((x)/1000.f)
|
||||
|
||||
typedef struct _ardrone_timer_t
|
||||
{
|
||||
bool_t init;
|
||||
|
||||
@@ -99,6 +99,7 @@ movie_atom_t *atomFromData (uint32_t data_size, const char *_tag, const uint8_t
|
||||
if (NULL == retAtom->data)
|
||||
{
|
||||
ATOM_FREE (retAtom);
|
||||
retAtom = NULL;
|
||||
return NULL;
|
||||
}
|
||||
ATOM_MEMCOPY (retAtom->data, _data, data_size);
|
||||
@@ -125,6 +126,7 @@ void insertAtomIntoAtom (movie_atom_t *container, movie_atom_t **leaf)
|
||||
container->size = new_container_size + 8;
|
||||
}
|
||||
ATOM_FREE ((*leaf)->data);
|
||||
(*leaf)->data = NULL;
|
||||
ATOM_FREE (*leaf);
|
||||
*leaf = NULL;
|
||||
}
|
||||
@@ -162,12 +164,27 @@ int writeAtomToFile (movie_atom_t **_atom, FILE *file)
|
||||
}
|
||||
|
||||
ATOM_FREE ((*_atom)->data);
|
||||
(*_atom)->data = NULL;
|
||||
ATOM_FREE (*_atom);
|
||||
*_atom = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void freeAtom (movie_atom_t **_atom)
|
||||
{
|
||||
if ((NULL != _atom) &&
|
||||
(NULL != *_atom))
|
||||
{
|
||||
if (NULL != (*_atom)->data)
|
||||
{
|
||||
ATOM_FREE ((*_atom)->data);
|
||||
}
|
||||
ATOM_FREE (*_atom);
|
||||
*_atom = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
movie_atom_t *ftypAtomForFormatAndCodecWithOffset (ardrone_video_type_t format, parrot_video_encapsulation_codecs_t codec, uint32_t *offset, movie_atom_t **wideAtom)
|
||||
{
|
||||
if (NULL == offset || NULL == wideAtom)
|
||||
@@ -280,6 +297,7 @@ movie_atom_t *mvhdAtomFromFpsNumFramesAndDate (uint32_t fps, uint32_t nbFrames,
|
||||
|
||||
movie_atom_t *retAtom = atomFromData (100, "mvhd", data);
|
||||
ATOM_FREE (data);
|
||||
data = NULL;
|
||||
return retAtom;
|
||||
}
|
||||
|
||||
@@ -321,6 +339,7 @@ movie_atom_t *tkhdAtomWithResolutionNumFramesFpsAndDate (uint32_t w, uint32_t h,
|
||||
|
||||
movie_atom_t *retAtom = atomFromData (84, "tkhd", data);
|
||||
ATOM_FREE (data);
|
||||
data = NULL;
|
||||
return retAtom;
|
||||
}
|
||||
|
||||
@@ -343,6 +362,7 @@ movie_atom_t *mdhdAtomFromFpsNumFramesAndDate (uint32_t fps, uint32_t nbFrames,
|
||||
|
||||
movie_atom_t *retAtom = atomFromData (24, "mdhd", data);
|
||||
ATOM_FREE (data);
|
||||
data = NULL;
|
||||
return retAtom;
|
||||
}
|
||||
|
||||
@@ -557,6 +577,7 @@ movie_atom_t *stsdAtomWithResolutionCodecSpsAndPps (uint32_t w, uint32_t h, parr
|
||||
|
||||
movie_atom_t *retAtom = atomFromData (dataSize, "stsd", data);
|
||||
ATOM_FREE (data);
|
||||
data = NULL;
|
||||
return retAtom;
|
||||
}
|
||||
|
||||
@@ -612,6 +633,7 @@ movie_atom_t *metadataAtomFromTagAndValue (const char *tag, const char *value)
|
||||
ATOM_WRITE_BYTES (value, valLen); /* Actual value */
|
||||
retAtom = atomFromData (dataSize, locTag, data);
|
||||
ATOM_FREE (data);
|
||||
data = NULL;
|
||||
}
|
||||
}
|
||||
return retAtom;
|
||||
@@ -647,6 +669,7 @@ movie_atom_t *ardtAtomFromPathAndDroneVersion(const char *path, uint8_t droneVer
|
||||
}
|
||||
retAtom = atomFromData (dataSize, "ardt", data);
|
||||
ATOM_FREE (data);
|
||||
data = NULL;
|
||||
}
|
||||
// NO ELSE - malloc failed
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ ardt -> specific
|
||||
movie_atom_t *atomFromData (uint32_t data_size, const char *_tag, const uint8_t *_data);
|
||||
void insertAtomIntoAtom (movie_atom_t *container, movie_atom_t **leaf); // will free leaf
|
||||
int writeAtomToFile (movie_atom_t **_atom, FILE *file); // Will free _atom
|
||||
void freeAtom (movie_atom_t **_atom);
|
||||
|
||||
/* SPECIFIC */
|
||||
movie_atom_t *ftypAtomForFormatAndCodecWithOffset (ardrone_video_type_t format, parrot_video_encapsulation_codecs_t codec, uint32_t *offset, movie_atom_t **freeAtom);
|
||||
|
||||
@@ -28,10 +28,15 @@
|
||||
#include <Winsock2.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#ifndef USE_ANDROID
|
||||
#include <ftw.h> // For file cleanup in subdirs
|
||||
#else
|
||||
#include <utils/AR_Ftw.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define ENCAPSULER_SMALL_STRING_SIZE (30)
|
||||
#define ENCAPSULER_INFODATA_MAX_SIZE (256)
|
||||
|
||||
/* The structure is initialised to an invalid value
|
||||
so we won't set any position in videos unless we got a
|
||||
@@ -141,6 +146,7 @@ ardrone_video_t *ardrone_video_start (const char *videoPath, int fps, ardrone_vi
|
||||
*error = ARDRONE_VIDEO_GENERIC_ERROR;
|
||||
vp_os_mutex_unlock(&retVideo->mutex);
|
||||
vp_os_free (retVideo);
|
||||
retVideo = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -160,6 +166,7 @@ ardrone_video_t *ardrone_video_start (const char *videoPath, int fps, ardrone_vi
|
||||
fclose (retVideo->infoFile);
|
||||
vp_os_mutex_unlock(&retVideo->mutex);
|
||||
vp_os_free (retVideo);
|
||||
retVideo = NULL;
|
||||
return NULL;
|
||||
}
|
||||
retVideo->framesCount = 0;
|
||||
@@ -270,8 +277,16 @@ ardrone_video_error_t ardrone_video_addFrame (ardrone_video_t *video, uint8_t *f
|
||||
if (NULL == video->sps || NULL == video->pps)
|
||||
{
|
||||
ENCAPSULER_ERROR ("Unable to allocate SPS/PPS buffers");
|
||||
if (NULL != video->sps) vp_os_free (video->sps);
|
||||
if (NULL != video->pps) vp_os_free (video->pps);
|
||||
if (NULL != video->sps)
|
||||
{
|
||||
vp_os_free (video->sps);
|
||||
video->sps = NULL;
|
||||
}
|
||||
if (NULL != video->pps)
|
||||
{
|
||||
vp_os_free (video->pps);
|
||||
video->pps = NULL;
|
||||
}
|
||||
vp_os_mutex_unlock(&video->mutex);
|
||||
return ARDRONE_VIDEO_GENERIC_ERROR;
|
||||
}
|
||||
@@ -290,6 +305,7 @@ ardrone_video_error_t ardrone_video_addFrame (ardrone_video_t *video, uint8_t *f
|
||||
if (NULL != freeAtomIfNeeded)
|
||||
{
|
||||
vp_os_free (freeAtomIfNeeded);
|
||||
freeAtomIfNeeded = NULL;
|
||||
}
|
||||
return ARDRONE_VIDEO_GENERIC_ERROR;
|
||||
}
|
||||
@@ -300,6 +316,7 @@ ardrone_video_error_t ardrone_video_addFrame (ardrone_video_t *video, uint8_t *f
|
||||
if (NULL != freeAtomIfNeeded)
|
||||
{
|
||||
vp_os_free (freeAtomIfNeeded);
|
||||
freeAtomIfNeeded = NULL;
|
||||
}
|
||||
return ARDRONE_VIDEO_FILE_ERROR;
|
||||
}
|
||||
@@ -356,7 +373,7 @@ ardrone_video_error_t ardrone_video_addFrame (ardrone_video_t *video, uint8_t *f
|
||||
}
|
||||
}
|
||||
|
||||
// Normal operation : file pointer is at end of file
|
||||
// Normal operation : file pointer is at end of file
|
||||
if (video->videoCodec != PaVE->video_codec ||
|
||||
video->width != PaVE->display_width ||
|
||||
video->height != PaVE->display_height)
|
||||
@@ -386,7 +403,7 @@ ardrone_video_error_t ardrone_video_addFrame (ardrone_video_t *video, uint8_t *f
|
||||
return ARDRONE_VIDEO_GENERIC_ERROR;
|
||||
}
|
||||
vp_os_memcpy (myData, data, frameSize);
|
||||
// Modify frames before writing
|
||||
// Modify frames before writing
|
||||
if (FRAME_TYPE_I_FRAME != PaVE->frame_type &&
|
||||
FRAME_TYPE_IDR_FRAME != PaVE->frame_type)
|
||||
{
|
||||
@@ -418,6 +435,7 @@ ardrone_video_error_t ardrone_video_addFrame (ardrone_video_t *video, uint8_t *f
|
||||
if (frameSize != fwrite (myData, 1, frameSize, video->outFile))
|
||||
{
|
||||
vp_os_free (myData);
|
||||
myData = NULL;
|
||||
ENCAPSULER_ERROR ("Unable to write frame into data file");
|
||||
vp_os_mutex_unlock(&video->mutex);
|
||||
return ARDRONE_VIDEO_FILE_ERROR;
|
||||
@@ -427,15 +445,16 @@ ardrone_video_error_t ardrone_video_addFrame (ardrone_video_t *video, uint8_t *f
|
||||
ENCAPSULER_FFLUSH (video->outFile);
|
||||
}
|
||||
vp_os_free (myData);
|
||||
myData = NULL;
|
||||
|
||||
char infoData [50] = {0};
|
||||
char infoData [ENCAPSULER_INFODATA_MAX_SIZE] = {0};
|
||||
char fTypeChar = 'p';
|
||||
if (FRAME_TYPE_I_FRAME == PaVE->frame_type ||
|
||||
FRAME_TYPE_IDR_FRAME == PaVE->frame_type)
|
||||
{
|
||||
fTypeChar = 'i';
|
||||
}
|
||||
snprintf (infoData, 50, ARDRONE_VIDEO_INFO_PATTERN, frameSize, fTypeChar);
|
||||
snprintf (infoData, ENCAPSULER_INFODATA_MAX_SIZE, ARDRONE_VIDEO_INFO_PATTERN, frameSize, fTypeChar);
|
||||
uint32_t infoLen = strlen (infoData);
|
||||
if (infoLen != fwrite (infoData, 1, infoLen, video->infoFile))
|
||||
{
|
||||
@@ -552,8 +571,17 @@ ardrone_video_error_t ardrone_video_addSlice (ardrone_video_t *video, uint8_t *s
|
||||
if (NULL == video->sps || NULL == video->pps)
|
||||
{
|
||||
ENCAPSULER_ERROR ("Unable to allocate SPS/PPS buffers");
|
||||
if (NULL != video->sps) vp_os_free (video->sps);
|
||||
if (NULL != video->pps) vp_os_free (video->pps);
|
||||
if (NULL != video->sps)
|
||||
{
|
||||
vp_os_free (video->sps);
|
||||
video->sps = NULL;
|
||||
}
|
||||
|
||||
if (NULL != video->pps)
|
||||
{
|
||||
vp_os_free (video->pps);
|
||||
video->pps = NULL;
|
||||
}
|
||||
vp_os_mutex_unlock(&video->mutex);
|
||||
return ARDRONE_VIDEO_GENERIC_ERROR;
|
||||
}
|
||||
@@ -572,6 +600,7 @@ ardrone_video_error_t ardrone_video_addSlice (ardrone_video_t *video, uint8_t *s
|
||||
if (NULL != freeAtomIfNeeded)
|
||||
{
|
||||
vp_os_free (freeAtomIfNeeded);
|
||||
freeAtomIfNeeded = NULL;
|
||||
}
|
||||
return ARDRONE_VIDEO_GENERIC_ERROR;
|
||||
}
|
||||
@@ -582,6 +611,7 @@ ardrone_video_error_t ardrone_video_addSlice (ardrone_video_t *video, uint8_t *s
|
||||
if (NULL != freeAtomIfNeeded)
|
||||
{
|
||||
vp_os_free (freeAtomIfNeeded);
|
||||
freeAtomIfNeeded = NULL;
|
||||
}
|
||||
return ARDRONE_VIDEO_FILE_ERROR;
|
||||
}
|
||||
@@ -655,14 +685,14 @@ ardrone_video_error_t ardrone_video_addSlice (ardrone_video_t *video, uint8_t *s
|
||||
{
|
||||
if (FRAME_TYPE_UNKNNOWN != video->lastFrameType)
|
||||
{
|
||||
char infoData [50] = {0};
|
||||
char infoData [ENCAPSULER_INFODATA_MAX_SIZE] = {0};
|
||||
char fTypeChar = 'p';
|
||||
if (FRAME_TYPE_I_FRAME == video->lastFrameType ||
|
||||
FRAME_TYPE_IDR_FRAME == video->lastFrameType)
|
||||
{
|
||||
fTypeChar = 'i';
|
||||
}
|
||||
snprintf (infoData, 50, ARDRONE_VIDEO_INFO_PATTERN, video->currentFrameSize, fTypeChar);
|
||||
snprintf (infoData, ENCAPSULER_INFODATA_MAX_SIZE, ARDRONE_VIDEO_INFO_PATTERN, video->currentFrameSize, fTypeChar);
|
||||
uint32_t infoLen = strlen (infoData);
|
||||
if (infoLen != fwrite (infoData, 1, infoLen, video->infoFile))
|
||||
{
|
||||
@@ -788,6 +818,7 @@ ardrone_video_error_t ardrone_video_finish (ardrone_video_t **video)
|
||||
if (0 == myVideo->width)
|
||||
{
|
||||
// Video was not initialized
|
||||
ENCAPSULER_ERROR ("video was not initialized");
|
||||
localError = ARDRONE_VIDEO_BAD_ARGS;
|
||||
} // No else
|
||||
}
|
||||
@@ -799,14 +830,14 @@ ardrone_video_error_t ardrone_video_finish (ardrone_video_t **video)
|
||||
{
|
||||
if (FRAME_TYPE_UNKNNOWN != myVideo->lastFrameType)
|
||||
{
|
||||
char infoData [50] = {0};
|
||||
char infoData [ENCAPSULER_INFODATA_MAX_SIZE] = {0};
|
||||
char fTypeChar = 'p';
|
||||
if (FRAME_TYPE_I_FRAME == myVideo->lastFrameType ||
|
||||
FRAME_TYPE_IDR_FRAME == myVideo->lastFrameType)
|
||||
{
|
||||
fTypeChar = 'i';
|
||||
}
|
||||
snprintf (infoData, 50, ARDRONE_VIDEO_INFO_PATTERN, myVideo->currentFrameSize, fTypeChar);
|
||||
snprintf (infoData, ENCAPSULER_INFODATA_MAX_SIZE, ARDRONE_VIDEO_INFO_PATTERN, myVideo->currentFrameSize, fTypeChar);
|
||||
|
||||
uint32_t infoLen = strlen (infoData);
|
||||
if (infoLen != fwrite (infoData, 1, infoLen, myVideo->infoFile))
|
||||
@@ -847,10 +878,15 @@ ardrone_video_error_t ardrone_video_finish (ardrone_video_t **video)
|
||||
{
|
||||
ENCAPSULER_ERROR ("Unable to allocate buffers for video finish");
|
||||
vp_os_free (frameSizeBuffer);
|
||||
frameSizeBuffer = NULL;
|
||||
vp_os_free (frameSizeBufferNE);
|
||||
frameSizeBufferNE = NULL;
|
||||
vp_os_free (frameOffsetBuffer);
|
||||
frameOffsetBuffer = NULL;
|
||||
vp_os_free (iFrameIndexBuffer);
|
||||
iFrameIndexBuffer = NULL;
|
||||
vp_os_free (frameIsIFrame);
|
||||
frameIsIFrame = NULL;
|
||||
vp_os_mutex_unlock(&myVideo->mutex);
|
||||
localError = ARDRONE_VIDEO_GENERIC_ERROR;
|
||||
}
|
||||
@@ -877,7 +913,7 @@ ardrone_video_error_t ardrone_video_finish (ardrone_video_t **video)
|
||||
{
|
||||
fseek (myVideo->infoFile, descriptorSize, SEEK_CUR);
|
||||
}
|
||||
while (! feof (myVideo->infoFile) && nbFrames <= myVideo->framesCount)
|
||||
while (! feof (myVideo->infoFile) && nbFrames < myVideo->framesCount)
|
||||
{
|
||||
uint32_t fSize = -1;
|
||||
char fType = 'a';
|
||||
@@ -901,12 +937,13 @@ ardrone_video_error_t ardrone_video_finish (ardrone_video_t **video)
|
||||
// create atoms
|
||||
// Generating Atoms
|
||||
tzset ();
|
||||
struct tm *nowTm = localtime (&myVideo->creationTime);
|
||||
EMPTY_ATOM(moov);
|
||||
movie_atom_t *mvhdAtom = mvhdAtomFromFpsNumFramesAndDate (myVideo->fps, nbFrames, myVideo->creationTime - timezone);
|
||||
movie_atom_t *mvhdAtom = mvhdAtomFromFpsNumFramesAndDate (myVideo->fps, nbFrames, myVideo->creationTime - timezone + (3600 * nowTm->tm_isdst));
|
||||
EMPTY_ATOM(trak);
|
||||
movie_atom_t *tkhdAtom = tkhdAtomWithResolutionNumFramesFpsAndDate (myVideo->width, myVideo->height, nbFrames, myVideo->fps, myVideo->creationTime - timezone);
|
||||
movie_atom_t *tkhdAtom = tkhdAtomWithResolutionNumFramesFpsAndDate (myVideo->width, myVideo->height, nbFrames, myVideo->fps, myVideo->creationTime - timezone + (3600 * nowTm->tm_isdst));
|
||||
EMPTY_ATOM(mdia);
|
||||
movie_atom_t *mdhdAtom = mdhdAtomFromFpsNumFramesAndDate (myVideo->fps, nbFrames, myVideo->creationTime - timezone);
|
||||
movie_atom_t *mdhdAtom = mdhdAtomFromFpsNumFramesAndDate (myVideo->fps, nbFrames, myVideo->creationTime - timezone + (3600 * nowTm->tm_isdst));
|
||||
movie_atom_t *hdlrAtom = hdlrAtomForMdia ();
|
||||
EMPTY_ATOM(minf);
|
||||
movie_atom_t *vmhdAtom = vmhdAtomGen ();
|
||||
@@ -925,6 +962,7 @@ ardrone_video_error_t ardrone_video_finish (ardrone_video_t **video)
|
||||
memcpy (&stssBuffer[8], iFrameIndexBuffer, nbIFrames * sizeof (uint32_t));
|
||||
movie_atom_t *stssAtom = atomFromData (stssDataLen, "stss", stssBuffer);
|
||||
vp_os_free (stssBuffer);
|
||||
stssBuffer = NULL;
|
||||
|
||||
movie_atom_t *stscAtom = stscAtomGen ();
|
||||
|
||||
@@ -936,6 +974,7 @@ ardrone_video_error_t ardrone_video_finish (ardrone_video_t **video)
|
||||
memcpy (&stszBuffer[12], frameSizeBufferNE, nbFrames * sizeof (uint32_t));
|
||||
movie_atom_t *stszAtom = atomFromData (stszDataLen, "stsz", stszBuffer);
|
||||
vp_os_free (stszBuffer);
|
||||
stszBuffer = NULL;
|
||||
|
||||
// Generate stco atom from frameOffsetBuffer and nbFrames
|
||||
uint32_t stcoDataLen = (8 + (nbFrames * sizeof (uint32_t)));
|
||||
@@ -944,12 +983,12 @@ ardrone_video_error_t ardrone_video_finish (ardrone_video_t **video)
|
||||
memcpy (&stcoBuffer[8], frameOffsetBuffer, nbFrames * sizeof (uint32_t));
|
||||
movie_atom_t *stcoAtom = atomFromData (stcoDataLen, "stco", stcoBuffer);
|
||||
vp_os_free (stcoBuffer);
|
||||
stcoBuffer = NULL;
|
||||
|
||||
EMPTY_ATOM (udta);
|
||||
movie_atom_t *swrAtom = metadataAtomFromTagAndValue ("swr", "AR.Drone 2.0");
|
||||
|
||||
char dateInfoString[ENCAPSULER_SMALL_STRING_SIZE] = {0};
|
||||
struct tm *nowTm = localtime (&myVideo->creationTime);
|
||||
snprintf (dateInfoString, ENCAPSULER_SMALL_STRING_SIZE, "%04d-%02d-%02dT%02d:%02d:%02d%+03d%02d",
|
||||
nowTm->tm_year + 1900,
|
||||
nowTm->tm_mon + 1,
|
||||
@@ -957,7 +996,7 @@ ardrone_video_error_t ardrone_video_finish (ardrone_video_t **video)
|
||||
nowTm->tm_hour,
|
||||
nowTm->tm_min,
|
||||
nowTm->tm_sec,
|
||||
(int)(-timezone / 3600),
|
||||
(int)(-timezone / 3600) + nowTm->tm_isdst,
|
||||
(int)((-timezone % 3600) / 60));
|
||||
movie_atom_t *dayAtom = metadataAtomFromTagAndValue ("day", dateInfoString);
|
||||
|
||||
@@ -965,10 +1004,17 @@ ardrone_video_error_t ardrone_video_finish (ardrone_video_t **video)
|
||||
int gpsIsValid = generateGpsString (gpsInfoString, ENCAPSULER_SMALL_STRING_SIZE);
|
||||
ENCAPSULER_DEBUG ("Valid : %d, Gps info string : %s\n", gpsIsValid, gpsInfoString);
|
||||
movie_atom_t *xyzAtom = NULL;
|
||||
|
||||
/**
|
||||
* Android 4.0.3 and later don't support the (c)xyz atom in the videos
|
||||
* We won't generate it for any android versions
|
||||
*/
|
||||
#ifndef USE_ANDROID
|
||||
if (1 == gpsIsValid)
|
||||
{
|
||||
xyzAtom = metadataAtomFromTagAndValue ("xyz", gpsInfoString);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Create atom tree
|
||||
insertAtomIntoAtom (udtaAtom, &swrAtom);
|
||||
@@ -1043,6 +1089,7 @@ ardrone_video_error_t ardrone_video_finish (ardrone_video_t **video)
|
||||
localError = ARDRONE_VIDEO_FILE_ERROR;
|
||||
}
|
||||
vp_os_free (mediaPath);
|
||||
mediaPath = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1084,21 +1131,32 @@ ardrone_video_error_t ardrone_video_finish (ardrone_video_t **video)
|
||||
|
||||
vp_os_mutex_unlock(&myVideo->mutex);
|
||||
vp_os_free (myVideo);
|
||||
myVideo = NULL;
|
||||
*video = NULL;
|
||||
|
||||
vp_os_free (frameSizeBuffer);
|
||||
frameSizeBuffer = NULL;
|
||||
vp_os_free (frameSizeBufferNE);
|
||||
frameSizeBufferNE = NULL;
|
||||
vp_os_free (frameOffsetBuffer);
|
||||
frameOffsetBuffer = NULL;
|
||||
vp_os_free (iFrameIndexBuffer);
|
||||
iFrameIndexBuffer = NULL;
|
||||
vp_os_free (frameIsIFrame);
|
||||
frameIsIFrame = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
vp_os_free (frameSizeBuffer);
|
||||
frameSizeBuffer = NULL;
|
||||
vp_os_free (frameSizeBufferNE);
|
||||
frameSizeBufferNE = NULL;
|
||||
vp_os_free (frameOffsetBuffer);
|
||||
frameOffsetBuffer = NULL;
|
||||
vp_os_free (iFrameIndexBuffer);
|
||||
iFrameIndexBuffer = NULL;
|
||||
vp_os_free (frameIsIFrame);
|
||||
frameIsIFrame = NULL;
|
||||
vp_os_mutex_unlock(&myVideo->mutex);
|
||||
ardrone_video_cleanup (video);
|
||||
}
|
||||
@@ -1494,10 +1552,13 @@ bool_t ardrone_video_try_fix (const char *infoFilePath)
|
||||
{
|
||||
ENCAPSULER_DEBUG ("Freeing local copies");
|
||||
ENCAPSULER_CLEANUP (vp_os_free, video->sps);
|
||||
video->sps = NULL;
|
||||
ENCAPSULER_CLEANUP (vp_os_free, video->pps);
|
||||
video->pps = NULL;
|
||||
ENCAPSULER_CLEANUP (fclose, video->infoFile);
|
||||
ENCAPSULER_CLEANUP (fclose, video->outFile);
|
||||
ENCAPSULER_CLEANUP (vp_os_free ,video);
|
||||
video = NULL;
|
||||
}
|
||||
|
||||
if (NULL != infoFile)
|
||||
|
||||
@@ -187,6 +187,7 @@ void ardrone_video_set_gps_infos (double latitude, double longitude, double alti
|
||||
/**
|
||||
* Try fo fix an MP4 infovid file.
|
||||
* @param infoFilePath Full path to the .infovid file.
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*/
|
||||
bool_t ardrone_video_try_fix (const char *infoFilePath);
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ void p263_codec_free( video_controller_t* controller )
|
||||
p263_codec_t* p263_codec = (p263_codec_t*) controller->video_codec;
|
||||
|
||||
vp_os_free( p263_codec );
|
||||
controller->video_codec = NULL;
|
||||
|
||||
}
|
||||
|
||||
static INLINE video_macroblock_t* p263_unquantize_idct( video_controller_t* controller, video_macroblock_t* mb, int32_t num_macro_blocks )
|
||||
|
||||
@@ -94,9 +94,16 @@ void p264_codec_free( video_controller_t* controller )
|
||||
if( p264_codec != NULL )
|
||||
{
|
||||
if (p264_codec->ref_picture.y_buf != NULL)
|
||||
{
|
||||
vp_os_free(p264_codec->ref_picture.y_buf);
|
||||
p264_codec->ref_picture.y_buf = NULL;
|
||||
}
|
||||
if (p264_codec->decoded_picture.y_buf != NULL)
|
||||
{
|
||||
vp_os_free(p264_codec->decoded_picture.y_buf);
|
||||
p264_codec->decoded_picture.y_buf = NULL;
|
||||
}
|
||||
|
||||
vp_os_free( p264_codec );
|
||||
controller->video_codec = NULL;
|
||||
}
|
||||
|
||||
@@ -2,13 +2,6 @@
|
||||
|
||||
#ifdef HAS_UVLC_WRITE_BLOCK
|
||||
|
||||
#ifdef _ECOS
|
||||
#include "config-tcm.h"
|
||||
|
||||
.section ".text.itcm","ax"
|
||||
#endif // ! _ECOS
|
||||
|
||||
|
||||
.global uvlc_write_block
|
||||
.type uvlc_write_block, %function
|
||||
|
||||
|
||||
@@ -2,12 +2,6 @@
|
||||
|
||||
#ifdef HAS_DO_QUANTIZE_INTRA_MB
|
||||
|
||||
#ifdef _ECOS
|
||||
#include "config-tcm.h"
|
||||
|
||||
.section ".text.itcm","ax"
|
||||
#endif // ! _ECOS
|
||||
|
||||
.global do_quantize_intra_mb
|
||||
.type do_quantize_intra_mb, %function
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ C_RESULT video_decode_blockline( video_controller_t* controller, vp_api_picture_
|
||||
NULL != controller->video_codec)
|
||||
{
|
||||
return controller->video_codec->decode_blockline( controller, blockline, got_image );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return C_FAIL;
|
||||
|
||||
@@ -123,6 +123,7 @@ C_RESULT video_controller_cleanup( video_controller_t* controller )
|
||||
{
|
||||
gob = &controller->gobs[0];
|
||||
vp_os_free(gob->macroblocks);
|
||||
gob->macroblocks = NULL;
|
||||
vp_os_free( controller->gobs );
|
||||
controller->gobs = NULL;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ huffman_tree_t* huffman_alloc( int32_t num_max_codes, int32_t max_code_length )
|
||||
void huffman_free( huffman_tree_t* tree )
|
||||
{
|
||||
vp_os_free( tree );
|
||||
tree = NULL;
|
||||
}
|
||||
|
||||
C_RESULT huffman_add_codes( huffman_tree_t* tree, huffman_code_t* codes, int32_t num_codes )
|
||||
|
||||
@@ -702,7 +702,7 @@ ATcodec_Send_Messages()
|
||||
|
||||
vp_os_mutex_lock(&ATcodec_cond_mutex);
|
||||
if(ATcodec_Message_len > INTERNAL_BUFFER_SIZE)
|
||||
printf("ATcodec_Send_Messages : buf=%s, len=%d\n", &ATcodec_Message_Buffer[0], ATcodec_Message_len);
|
||||
PRINT("ATcodec_Send_Messages : buf=%s, len=%d\n", &ATcodec_Message_Buffer[0], ATcodec_Message_len);
|
||||
|
||||
if(ATcodec_Message_len && func_ptrs.write((uint8_t*)&ATcodec_Message_Buffer[0], (int32_t*)&ATcodec_Message_len) != AT_CODEC_WRITE_OK)
|
||||
res = ATCODEC_FALSE;
|
||||
|
||||
@@ -83,7 +83,7 @@ before_check:
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------------------------------------------------
|
||||
TARGETS=vlib parrotOS_core parrotOS_utils parrotOS_drivers parrotOS_devs parrotOS_codec libplf sdk lib app
|
||||
TARGETS=vlib libplf sdk lib app
|
||||
|
||||
# When building on Ubuntu, only the final application (USE_APP) depends on the above-mentioned libraries.
|
||||
# The iPhone applications do not use USE_APP; the above-mentioned libraries must therefore be built
|
||||
@@ -105,9 +105,6 @@ define ADD_RULE_TEMPLATE
|
||||
ifeq ($(USE_ANDROID),yes)
|
||||
build_lib: build_$(1)
|
||||
endif
|
||||
ifeq ($(USE_LINUX), yes)
|
||||
build_lib: build_$(1)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -19,47 +19,10 @@ USE_VLIB=yes
|
||||
SWING_VERSION=head
|
||||
|
||||
# Check validity of script usage.
|
||||
if [ $1 ] && [ $1 = ecos ] ; then
|
||||
if [ ! $QUIET_BUILD = yes ] ; then
|
||||
echo ; echo "BUILD FOR ECOS" ; echo
|
||||
fi
|
||||
USE_ECOS=yes
|
||||
USE_LINUX=no
|
||||
USE_ELINUX=no
|
||||
USE_NDS=no
|
||||
USE_IPHONE=no
|
||||
# head ecos-stable-2006-11-21 ecos-stable-2007-07-23 CK5300_Version_20070928_Beta5
|
||||
ECOS_VERSION=Mykonos_Version_20090212
|
||||
PROJECT=mykonos_p5p
|
||||
MODE_TARGET=rls_ram_wifi_ap
|
||||
CUSTOM_PRIORITIES=$ALL_SOURCES/video/$SDK_VERSION/Video/VP_SDK/VP_Os/ecos/task_priorities.h
|
||||
# gnutools_2008_03_28 gnutools_2007_02_07 gnutools_2005_05_20
|
||||
GNUTOOLS_VERSION=gnutools_2008_03_28
|
||||
USE_ECOS_RELEASE=no
|
||||
NO_COM=no
|
||||
USE_BONJOUR=no
|
||||
USE_BLUES32=no
|
||||
# Stable_20070307 Stable_20060922 Stable_20061129_Blues_3_6_4 Version_KEA_1_00_RC5_200701131
|
||||
BLUES32_VERSION=Stable_20060922
|
||||
COMMONSOFT_VERSION=head
|
||||
USE_PVSP=yes
|
||||
USE_SOUL=no
|
||||
SOUL_VERSION=Stable_20070307
|
||||
USE_TANGO=no
|
||||
# Stable_20061222 Stable_20070509
|
||||
TANGO_VERSION=Stable_20070509
|
||||
DONT_USE_TTS=yes
|
||||
USE_CK5050=no
|
||||
CK5050_VERSION=head
|
||||
USE_BLUEZ=no
|
||||
# P5 Intel smdk2412
|
||||
FF_ARCH=P5
|
||||
USE_PARROTOS_CORE=no
|
||||
elif [ $1 ] && [ $1 = elinux ] ; then
|
||||
if [ $1 ] && [ $1 = elinux ] ; then
|
||||
if [ ! $QUIET_BUILD = yes ] ; then
|
||||
echo ; echo "BUILD FOR EMBEDDED LINUX" ; echo
|
||||
fi
|
||||
USE_ECOS=no
|
||||
USE_LINUX=no
|
||||
USE_ELINUX=yes
|
||||
USE_NDS=no
|
||||
@@ -80,7 +43,6 @@ elif [ $1 ] && [ $1 = linux ] ; then
|
||||
if [ ! $QUIET_BUILD = yes ] ; then
|
||||
echo ; echo "BUILD FOR LINUX" ; echo
|
||||
fi
|
||||
USE_ECOS=no
|
||||
USE_LINUX=yes
|
||||
USE_ELINUX=no
|
||||
USE_NDS=no
|
||||
@@ -96,7 +58,6 @@ elif [ $1 ] && [ $1 = nds ] ; then
|
||||
if [ ! $QUIET_BUILD = yes ] ; then
|
||||
echo ; echo "BUILD FOR NINTENDO DS" ; echo
|
||||
fi
|
||||
USE_ECOS=no
|
||||
USE_LINUX=no
|
||||
USE_ELINUX=no
|
||||
USE_NDS=yes
|
||||
@@ -112,7 +73,6 @@ elif [ $1 ] && [ ${1:0:6} = iphone ] ; then
|
||||
if [ ! $QUIET_BUILD = yes ] ; then
|
||||
echo ; echo "BUILD FOR IPHONE with platform $1 $IPHONE_SDK_VERSION" ; echo
|
||||
fi
|
||||
USE_ECOS=no
|
||||
USE_LINUX=no
|
||||
USE_ELINUX=no
|
||||
USE_NDS=no
|
||||
@@ -135,7 +95,6 @@ FLAGS="USE_APP=$USE_APP"
|
||||
FLAGS="IPHONE_SDK_VERSION=$IPHONE_SDK_VERSION $FLAGS"
|
||||
FLAGS="NO_EXAMPLES=$NO_EXAMPLES $FLAGS"
|
||||
FLAGS="GNUTOOLS_VERSION=$GNUTOOLS_VERSION $FLAGS"
|
||||
FLAGS="USE_ECOS=$USE_ECOS $FLAGS"
|
||||
FLAGS="USE_LINUX=$USE_LINUX $FLAGS"
|
||||
FLAGS="USE_ELINUX=$USE_ELINUX $FLAGS"
|
||||
FLAGS="USE_NDS=$USE_NDS $FLAGS"
|
||||
@@ -160,8 +119,6 @@ FLAGS="QUIET_BUILD=$QUIET_BUILD $FLAGS"
|
||||
FLAGS="RELEASE_BUILD=$RELEASE_BUILD $FLAGS"
|
||||
FLAGS="SDK_VERSION=$SDK_VERSION $FLAGS"
|
||||
|
||||
FLAGS="USE_ECOS_RELEASE=$USE_ECOS_RELEASE $FLAGS"
|
||||
FLAGS="ECOS_VERSION=$ECOS_VERSION $FLAGS"
|
||||
FLAGS="ELINUX_VERSION=$ELINUX_VERSION $FLAGS"
|
||||
FLAGS="PROJECT=$PROJECT $FLAGS"
|
||||
FLAGS="MODE_TARGET=$MODE_TARGET $FLAGS"
|
||||
@@ -181,17 +138,10 @@ FLAGS="USE_IWLIB=$USE_IWLIB $FLAGS"
|
||||
FLAGS="USE_PARROTOS_CORE=$USE_PARROTOS_CORE $FLAGS"
|
||||
FLAGS="COMMONSOFT_VERSION=$COMMONSOFT_VERSION $FLAGS"
|
||||
|
||||
if [ $USE_ECOS = yes ] ; then
|
||||
FLAGS="CUSTOM_PRIORITIES=$CUSTOM_PRIORITIES $FLAGS"
|
||||
fi
|
||||
|
||||
if [ $USE_ELINUX = yes ] ; then
|
||||
FLAGS="CONFIG_PARROTOS=$CONFIG_PARROTOS $FLAGS"
|
||||
fi
|
||||
|
||||
if [ $USE_ECOS = yes ] && [ $2 ] && ! [ $2 = check ] && ! [ $2 = clean ] || [ $USE_ECOS = yes ] && ! [ $2 ] ; then
|
||||
CHOOSE=yes
|
||||
fi
|
||||
if [ $2 ] && [ $2 = check ] ; then
|
||||
CHECK=yes
|
||||
fi
|
||||
@@ -212,38 +162,3 @@ if [ $CHECK ] && [ $CHECK = yes ] ; then
|
||||
else
|
||||
make -f Makefile $FLAGS $* 2>&1
|
||||
fi
|
||||
|
||||
#####################
|
||||
# Choose example ?
|
||||
#####################
|
||||
|
||||
if [ $CHOOSE ] && [ $CHOOSE = yes ] ; then
|
||||
j=1 ; for i in $( find . -type d -name "*Examples" | grep arm ) ; do j=$( expr $j + 1 ) ; done
|
||||
|
||||
if [ $j = 1 ] ; then
|
||||
echo No example directory found
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! [ $j = 2 ] ; then
|
||||
j=1 ; for i in $( find . -type d -name "*Examples" | grep arm ) ; do echo -e "\t$j\t$i" ; j=$( expr $j + 1 ) ; done
|
||||
echo -n -e "\nChoose directory : "
|
||||
read var
|
||||
j=1 ; for i in $( find . -type d -name "*Examples" | grep arm ) ; do if [ $j = $var ] ; then ex_dir=$i ; fi ; j=$( expr $j + 1 ) ; done
|
||||
else
|
||||
ex_dir=$( find . -type d -name "*Examples" | grep arm )
|
||||
fi
|
||||
|
||||
echo -e "\nDirectory $ex_dir :"
|
||||
|
||||
j=1 ; for i in $( find $ex_dir -type f -exec basename \{\} \; ) ; do echo -e "\t$j\t$i" ; j=$( expr $j + 1 ) ; done
|
||||
echo -n -e "\nChoose example : "
|
||||
read var
|
||||
j=1 ; for i in $( find $ex_dir -type f ) ; do if [ $j = $var ] ; then ex_file=$i ; fi ; j=$( expr $j + 1 ) ; done
|
||||
|
||||
if [ ! -z $ex_file ] && [ -f $ex_file ] ; then
|
||||
cp $ex_file /srv/tftp/program.elf && echo -e "\n$ex_file copied to /srv/tftp/program.elf"
|
||||
else
|
||||
echo -e "\nBad choice !"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -66,7 +66,6 @@ vp_os_cond_wait(vp_os_cond_t *cond)
|
||||
pthread_cond_wait(&cond->cond, (pthread_mutex_t *)cond->mutex);
|
||||
}
|
||||
|
||||
|
||||
C_RESULT
|
||||
vp_os_cond_timed_wait(vp_os_cond_t *cond, uint32_t ms)
|
||||
{
|
||||
|
||||
@@ -86,11 +86,13 @@ vp_os_cond_timed_wait(vp_os_cond_t *cond, uint32_t ms)
|
||||
gettimeofday(&tv, NULL);
|
||||
TIMEVAL_TO_TIMESPEC(&tv, &ts);
|
||||
ts.tv_sec += ms/1000;
|
||||
ts.tv_nsec += (ms%1000)*1000;
|
||||
ts.tv_nsec += (ms%1000)*1000000;
|
||||
if (ts.tv_nsec>1000000000) { ts.tv_sec++, ts.tv_nsec-=1000000000; }
|
||||
return ( pthread_cond_timedwait(&cond->cond, (pthread_mutex_t *)cond->mutex, &ts) == ETIMEDOUT ? FAIL : SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
vp_os_cond_signal(vp_os_cond_t *cond)
|
||||
{
|
||||
|
||||
@@ -23,20 +23,28 @@
|
||||
#endif // __MACOSX__
|
||||
|
||||
#ifdef USE_ANDROID
|
||||
#include <android/log.h>
|
||||
#undef PRINT
|
||||
#define PRINT(_fmt_, args...) \
|
||||
#include <android/log.h>
|
||||
#undef PRINT
|
||||
#ifdef DEBUG_MODE
|
||||
#define PRINT(_fmt_, args...) \
|
||||
__android_log_print(ANDROID_LOG_INFO, "ARDrone", _fmt_, ##args)
|
||||
#else
|
||||
#define PRINT(...)
|
||||
#endif //DEBUG_MODE
|
||||
#endif // USE_ANDROID
|
||||
|
||||
#ifndef PRINT
|
||||
#define PRINT printf
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_MODE
|
||||
#define DEBUG_PRINT_SDK(...) printf(__VA_ARGS__)
|
||||
#define DEBUG_PRINT_SDK(...) PRINT(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_PRINT_SDK(...)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_MODE
|
||||
#define DEBUG_PRINT(...) printf(__VA_ARGS__)
|
||||
#define DEBUG_PRINT(...) PRINT(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_PRINT(...)
|
||||
#endif
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
#include <VP_Stages/vp_stages_frame_pipe.h>
|
||||
#include <VP_Os/vp_os_print.h>
|
||||
|
||||
#ifdef USE_ELINUX
|
||||
#include <VP_Os/elinux/vp_os_ltt.h>
|
||||
#endif
|
||||
// Sender function
|
||||
C_RESULT
|
||||
vp_stages_frame_pipe_sender_open(vp_stages_frame_pipe_config_t *cfg)
|
||||
@@ -185,6 +182,7 @@ C_RESULT
|
||||
vp_stages_frame_pipe_receiver_close(vp_stages_frame_pipe_config_t *cfg)
|
||||
{
|
||||
vp_os_free (cfg->outPicture.raw);
|
||||
cfg->outPicture.raw = NULL;
|
||||
vp_os_cond_destroy (&(cfg->buffer_sent));
|
||||
vp_os_mutex_destroy (&(cfg->pipe_mut));
|
||||
return C_OK;
|
||||
|
||||
@@ -99,7 +99,10 @@ vp_stages_output_buffer_stage_transform(vp_stages_output_buffer_config_t *cfg, v
|
||||
}
|
||||
|
||||
if(in->status == VP_API_STATUS_ENDED)
|
||||
{
|
||||
vp_os_free(out->buffers);
|
||||
out->buffers = NULL;
|
||||
}
|
||||
|
||||
out->status = in->status;
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ vp_stages_input_file_stage_open(vp_stages_input_file_config_t *cfg)
|
||||
cfg->buffers = vp_os_malloc(sizeof(*cfg->buffers)*cfg->nb_buffers);
|
||||
if (cfg->buffers==NULL)
|
||||
{
|
||||
printf("%s:%d - Failed preloading %s : not enough memory for buffer pointers(required %d pointers)\n",
|
||||
PRINT("%s:%d - Failed preloading %s : not enough memory for buffer pointers(required %d pointers)\n",
|
||||
__FUNCTION__,__LINE__,
|
||||
cfg->name,cfg->nb_buffers/(1024*1024));
|
||||
}
|
||||
@@ -113,7 +113,7 @@ vp_stages_input_file_stage_open(vp_stages_input_file_config_t *cfg)
|
||||
#endif
|
||||
if (cfg->data==NULL)
|
||||
{
|
||||
printf("Failed preloading %s : not enough memory (required %d MB)\n",
|
||||
PRINT("Failed preloading %s : not enough memory (required %d MB)\n",
|
||||
cfg->name,cfg->buffer_size*cfg->nb_buffers/(1024*1024));
|
||||
}
|
||||
|
||||
@@ -124,10 +124,12 @@ vp_stages_input_file_stage_open(vp_stages_input_file_config_t *cfg)
|
||||
|
||||
if (cfg->data && cfg->preload!=0)
|
||||
{
|
||||
printf("Preloading file %s to memory ...\n",cfg->name);
|
||||
PRINT("Preloading file %s to memory ...\n",cfg->name);
|
||||
for (i=0;i<cfg->nb_buffers;i++)
|
||||
{
|
||||
printf("."); fflush(stdout);
|
||||
#ifndef USE_ELINUX
|
||||
PRINT("."); fflush(stdout);
|
||||
#endif
|
||||
res = fread(cfg->buffers[i], cfg->buffer_size , 1 , cfg->f);
|
||||
if (res<1)
|
||||
{
|
||||
@@ -135,14 +137,14 @@ vp_stages_input_file_stage_open(vp_stages_input_file_config_t *cfg)
|
||||
cfg->nb_buffers=i; /* Store the number of successfully read frames */
|
||||
}
|
||||
}
|
||||
printf("ok.\n");
|
||||
PRINT("ok.\n");
|
||||
fclose(cfg->f);
|
||||
cfg->f=NULL;
|
||||
}
|
||||
|
||||
cfg->current_buffer=0;
|
||||
|
||||
printf("Using %s input file %s\n resolution %dx%d\n total size : %d MB\n",
|
||||
PRINT("Using %s input file %s\n resolution %dx%d\n total size : %d MB\n",
|
||||
(PIX_FMT_YUV420P==cfg->vp_api_picture.format)?"420P":"422",
|
||||
cfg->name,
|
||||
cfg->width,cfg->height,filesize/(1024*1024));
|
||||
@@ -156,7 +158,7 @@ vp_stages_input_file_stage_transform(vp_stages_input_file_config_t *cfg, vp_api_
|
||||
vp_os_mutex_lock(&out->lock);
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("%s:%d Reading a frame from YUV file %s ...\n",__FUNCTION__,__LINE__,cfg->name);
|
||||
PRINT("%s:%d Reading a frame from YUV file %s ...\n",__FUNCTION__,__LINE__,cfg->name);
|
||||
#endif
|
||||
|
||||
/* Init */
|
||||
@@ -170,7 +172,7 @@ vp_stages_input_file_stage_transform(vp_stages_input_file_config_t *cfg, vp_api_
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("%s:%d Frames stored at address %p.\n",__FUNCTION__,__LINE__,cfg->data);
|
||||
PRINT("%s:%d Frames stored at address %p.\n",__FUNCTION__,__LINE__,cfg->data);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -197,7 +199,7 @@ vp_stages_input_file_stage_transform(vp_stages_input_file_config_t *cfg, vp_api_
|
||||
/* Read a frame from the disk file */
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("%s:%d Requesting %d bytes ...\n",__FUNCTION__,__LINE__,cfg->buffer_size);
|
||||
PRINT("%s:%d Requesting %d bytes ...\n",__FUNCTION__,__LINE__,cfg->buffer_size);
|
||||
#endif
|
||||
|
||||
out->buffers=cfg->buffers;
|
||||
@@ -205,7 +207,7 @@ vp_stages_input_file_stage_transform(vp_stages_input_file_config_t *cfg, vp_api_
|
||||
out->size = fread(out->buffers[0], cfg->buffer_size, 1 , cfg->f);
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("%s:%d Read %d bytes ...\n",__FUNCTION__,__LINE__,out->size);
|
||||
PRINT("%s:%d Read %d bytes ...\n",__FUNCTION__,__LINE__,out->size);
|
||||
#endif
|
||||
|
||||
/* Go back at the beginning of the file if we reached the end of the video */
|
||||
@@ -282,7 +284,7 @@ vp_stages_output_file_stage_open(vp_stages_output_file_config_t *cfg)
|
||||
cfg->f = fopen(cfg->name, "wb");
|
||||
if(NULL == cfg->f)
|
||||
{
|
||||
printf("%s:%d - Error opening file %s\n",__FUNCTION__,__LINE__,cfg->name);perror("");
|
||||
PRINT("%s:%d - Error opening file %s\n",__FUNCTION__,__LINE__,cfg->name);perror("");
|
||||
return VP_FAILURE;
|
||||
}
|
||||
return (VP_SUCCESS);
|
||||
|
||||
@@ -358,6 +358,7 @@ vp_stages_output_sdl_stage_transform(vp_stages_output_sdl_config_t *cfg, vp_api_
|
||||
{
|
||||
pipeline_opened = 0;
|
||||
vp_os_free(out->buffers);
|
||||
out->buffers = NULL;
|
||||
}
|
||||
|
||||
vp_os_mutex_unlock(&out->lock);
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário