1、摄像头添加SD卡录满处理;
2、修复摄像头、科大讯飞等相关问题;
This commit is contained in:
@@ -478,10 +478,12 @@ static int jlstream_get_cvp_mode(void)
|
||||
{
|
||||
#if TCFG_SIRI_MODE_AEC_BYPASS /*SIRI模式省ram方式*/
|
||||
if (call_ctrl_get_status() != BT_SIRI_STATE) {
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int jlstream_event_notify(enum stream_event event, int arg)
|
||||
|
||||
@@ -10,6 +10,7 @@ struct ui_page_draw {
|
||||
struct rect *rec_gpu_rect;
|
||||
struct rect *rec_lcd_rect;
|
||||
u32 new_list_create;
|
||||
u32 normal_list_flag;
|
||||
u32 list_total;
|
||||
};
|
||||
struct ui_effect_module {
|
||||
|
||||
@@ -112,6 +112,10 @@ extern u8 __bt_movable_region_end[];
|
||||
extern const int support_reusable_special_update;
|
||||
extern void bt_set_support_3M_size(u8 en);
|
||||
|
||||
#if defined USER_SUPPORT_PROFILE_PAN && USER_SUPPORT_PROFILE_PAN
|
||||
static u16 pan_conn_id = 0;
|
||||
#endif
|
||||
|
||||
u8 lmp_get_conn_num(void);
|
||||
void bt_close_bredr();
|
||||
void bt_close_bredr_timeout_start();
|
||||
@@ -413,6 +417,18 @@ static void bt_disconn_func(void(*func)(void))
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined USER_SUPPORT_PROFILE_PAN && USER_SUPPORT_PROFILE_PAN
|
||||
static void pan_conn_handler(void *priv)
|
||||
{
|
||||
extern int user_pan_send_cmd(u8 * addr, u32 cmd, u32 value, u8 * data);
|
||||
user_pan_send_cmd(NULL, 2, 0, NULL);
|
||||
if (pan_conn_id) {
|
||||
sys_timeout_del(pan_conn_id);
|
||||
pan_conn_id = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 对应原来的状态处理函数,连接,电话状态等
|
||||
*/
|
||||
@@ -461,6 +477,12 @@ static int bt_connction_status_event_handler(struct bt_event *bt)
|
||||
chargestore_set_phone_disconnect();
|
||||
#endif
|
||||
bt_close_bredr_timeout_start();
|
||||
#if defined USER_SUPPORT_PROFILE_PAN && USER_SUPPORT_PROFILE_PAN
|
||||
if (pan_conn_id) {
|
||||
sys_timeout_del(pan_conn_id);
|
||||
pan_conn_id = 0;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case BT_STATUS_CONN_A2DP_CH:
|
||||
@@ -489,8 +511,9 @@ static int bt_connction_status_event_handler(struct bt_event *bt)
|
||||
bt_cmd_prepare(USER_CTRL_MAP_READ_TIME, 0, NULL);
|
||||
#endif
|
||||
#if defined USER_SUPPORT_PROFILE_PAN && USER_SUPPORT_PROFILE_PAN
|
||||
extern int user_pan_send_cmd(u8 * addr, u32 cmd, u32 value, u8 * data);
|
||||
user_pan_send_cmd(NULL, 2, 0, NULL);
|
||||
if (!pan_conn_id) { // 延迟500ms再连接pan,避免连接失败
|
||||
pan_conn_id = sys_timeout_add(NULL, pan_conn_handler, 500);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
@@ -1065,6 +1088,7 @@ static int bt_close_bredr_do(int priv)
|
||||
}
|
||||
/* printf("%s",__func__); */
|
||||
g_bt_hdl.bt_close_bredr = 1;
|
||||
UI_MSG_POST("edr_button:button=%4", 0);
|
||||
if (g_bt_hdl.auto_connection_timer) {
|
||||
sys_timeout_del(g_bt_hdl.auto_connection_timer);
|
||||
g_bt_hdl.auto_connection_timer = 0;
|
||||
@@ -1163,6 +1187,7 @@ static int bt_init_bredr_do(int priv)
|
||||
return 0;
|
||||
}
|
||||
g_bt_hdl.bt_close_bredr = 0;
|
||||
UI_MSG_POST("edr_button:button=%4", 1);
|
||||
bt_set_stack_exiting(0);
|
||||
btctrler_task_init_bredr();
|
||||
#if TCFG_EDR_SCAN_CONN_CTRL
|
||||
@@ -1173,7 +1198,7 @@ static int bt_init_bredr_do(int priv)
|
||||
bt_discovery_and_connectable_using_loca_mac_addr(0, 1);
|
||||
} else {
|
||||
if (ble_num > 0) {
|
||||
/*一键连接,ble已经连接了时候,edr状态为可连接可发现*/
|
||||
/*一键连接,ble已经连接了时候,edr状态为可连接*/
|
||||
bt_discovery_and_connectable_using_loca_mac_addr(0, 1);
|
||||
} else {
|
||||
bt_discovery_and_connectable_using_loca_mac_addr(1, 1);
|
||||
|
||||
@@ -209,20 +209,11 @@ static void dual_conn_state_handler()
|
||||
}
|
||||
if (connect_device == 0) {
|
||||
#if TCFG_EDR_SCAN_CONN_CTRL
|
||||
u8 rcsp_get_ble_disconnect_by_app_flag(void);
|
||||
void rcsp_set_ble_disconnect_by_app_flag(u8 flag);
|
||||
u8 ble_disconnect = rcsp_get_ble_disconnect_by_app_flag();
|
||||
u8 bredr_state = is_bredr_close();
|
||||
printf("%s ble_disconnect:%d is_bredr_close:%d", __func__, ble_disconnect, is_bredr_close());
|
||||
printf("%s is_bredr_close:%d", __func__, is_bredr_close());
|
||||
if (is_bredr_close() == 0) {
|
||||
if (ble_disconnect == 1) {
|
||||
/*一键连接时候, 由app发指令断连*/
|
||||
write_scan_conn_enable(0, 1);
|
||||
} else {
|
||||
write_scan_conn_enable(0, 0);
|
||||
}
|
||||
write_scan_conn_enable(0, 1);
|
||||
}
|
||||
rcsp_set_ble_disconnect_by_app_flag(0);
|
||||
#else
|
||||
write_scan_conn_enable(1, 1);
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.section .sys.version, "ax"
|
||||
|
||||
.long 315125570
|
||||
.asciz "-@20251226-$5dad1964"
|
||||
.long 316160896
|
||||
.asciz "-@20260107-$631ed832"
|
||||
|
||||
@@ -56,34 +56,36 @@ REGISTER_UI_STYLE(STYLE_NAME)
|
||||
#define VIDEO_PATH DEV_ROOT VIDEO_DIR VIDEO_NAME "." VIDEO_EXT //视频路径
|
||||
|
||||
#define VIEW_ITEM_NUM 6
|
||||
#define PHOTO_CONTINUE_SAVE 3
|
||||
|
||||
struct brower_set_info {
|
||||
int flist_index; //文件列表首项所指的索引
|
||||
int cur_total; //文件数
|
||||
FILE *file; //文件句柄
|
||||
struct vfscan *fs; //文件系统句柄
|
||||
FS_DIR_INFO *dir_buf; //文件(夹)信息
|
||||
int show_temp; //显示项
|
||||
int flist_index; //文件列表首项所指的索引
|
||||
int cur_total; //文件数
|
||||
FILE *file; //文件句柄
|
||||
struct vfscan *fs; //文件系统句柄
|
||||
FS_DIR_INFO *dir_buf; //文件(夹)信息
|
||||
int show_temp; //显示项
|
||||
#if (TCFG_LFN_EN)
|
||||
u8 lfn_buf[512]; //长文件名
|
||||
#endif//TCFG_LFN_EN
|
||||
|
||||
};
|
||||
#define PHOTO_CONTINUE_SAVE 3
|
||||
|
||||
struct camera_ctrl {
|
||||
u32 layout_curr; //当前布局id
|
||||
u32 video_rec_time; //录像开始时间戳,用于计时
|
||||
u8 view_video; //1 查看录像 0 查看照片
|
||||
u8 video_doing; //录像中状态
|
||||
u16 view_remap[VIEW_ITEM_NUM];
|
||||
u8 view_vaild[VIEW_ITEM_NUM];
|
||||
volatile s8 photo_save_cnt; //
|
||||
struct brower_set_info brower_info; //文件浏览
|
||||
char *sel_path;
|
||||
u32 layout_curr; //当前布局id
|
||||
u32 video_rec_time; //录像开始时间戳,用于计时
|
||||
u8 view_video; //1 查看录像 0 查看照片
|
||||
u8 video_doing; //录像中状态
|
||||
u16 view_remap[VIEW_ITEM_NUM];
|
||||
u8 view_vaild[VIEW_ITEM_NUM];
|
||||
s8 error_status; //
|
||||
volatile s8 photo_save_cnt; //
|
||||
struct brower_set_info brower_info; //文件浏览
|
||||
char *sel_path;
|
||||
} __camera_ctrl;
|
||||
|
||||
#define __this (&__camera_ctrl) //相机句柄
|
||||
|
||||
|
||||
|
||||
static int cam_camera_video_sw();
|
||||
//****************************************************************************************//
|
||||
// 功能接口
|
||||
@@ -93,6 +95,7 @@ static int cam_ctrl_init()
|
||||
__this->layout_curr = CAM_MAIN_LAYOUT;
|
||||
__this->video_rec_time = 0;
|
||||
__this->video_doing = 0;
|
||||
__this->error_status = 0;
|
||||
/* __this->view_video = 1; */
|
||||
return 0;
|
||||
}
|
||||
@@ -105,7 +108,7 @@ static int cam_ctrl_deinit()
|
||||
* @brief camera_dec_reflush_sync相机画面刷新 (外部调用,线程同步)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
static void camera_dec_flush(void)
|
||||
static void camera_dec_flush(void *p)
|
||||
{
|
||||
struct element *elm;
|
||||
elm = ui_core_get_element_by_id(CAM_CAMERA_LAYOUT);
|
||||
@@ -115,8 +118,13 @@ static void camera_dec_flush(void)
|
||||
/* printf("CAM_CAMERA_LAYOUT REDRAW_EXIT"); */
|
||||
}
|
||||
}
|
||||
static void camera_rec_err()
|
||||
static void camera_rec_err(int status)
|
||||
{
|
||||
if (__this) {
|
||||
__this->error_status = status;
|
||||
}
|
||||
|
||||
/* printf("%s status:%d !!\n", __func__, status); */
|
||||
cam_camera_video_sw();
|
||||
ui_show(CAM_WARNING_LAYOUT);
|
||||
}
|
||||
@@ -136,7 +144,8 @@ void camera_dec_reflush_sync(int status)
|
||||
msg[0] = (int) camera_rec_err;
|
||||
}
|
||||
msg[1] = 1;
|
||||
msg[2] = 0;
|
||||
msg[2] = status;
|
||||
|
||||
int ret = os_taskq_post_type("ui", Q_CALLBACK, 3, msg);
|
||||
|
||||
|
||||
@@ -411,6 +420,29 @@ REGISTER_UI_EVENT_HANDLER(CAM_WARNING_LAYOUT)
|
||||
.onkey = NULL,
|
||||
.ontouch = cam_warning_layout_ontouch,
|
||||
};
|
||||
static int cam_warning_text_onchange(void *ctrl, enum element_change_event event, void *arg)
|
||||
{
|
||||
switch (event) {
|
||||
case ON_CHANGE_SHOW_PROBE:
|
||||
int index = 0;
|
||||
if (__this) {
|
||||
index = (__this->error_status < 0) ? -1 * __this->error_status : __this->error_status;
|
||||
index -= 1;
|
||||
}
|
||||
/* printf("%s index:%d err:%d", __func__, index, __this->error_status); */
|
||||
ui_text_set_index((struct ui_text *)ctrl, index);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
REGISTER_UI_EVENT_HANDLER(CAM_WARNING_TEXT)
|
||||
.onchange = cam_warning_text_onchange,
|
||||
.onkey = NULL,
|
||||
.ontouch = NULL,
|
||||
};
|
||||
//****************************************************************************************//
|
||||
// 主页面
|
||||
//****************************************************************************************//
|
||||
@@ -966,7 +998,7 @@ void video_dec_reflush_sync(int status)
|
||||
{
|
||||
void jlui_malloc_ram_info_dump();
|
||||
/* jlui_malloc_ram_info_dump(); */
|
||||
log_debug("%s status:%d !!\n", __func__, status);
|
||||
/* log_debug("%s status:%d !!\n", __func__, status); */
|
||||
|
||||
int msg[3] = {0};
|
||||
|
||||
|
||||
@@ -6594,6 +6594,40 @@ REGISTER_UI_EVENT_HANDLER(SETTING_ANIMATION_PIC11)//通用-垂直列表
|
||||
|
||||
//-----------------------蓝牙设置---------------------------------//
|
||||
#if TCFG_USER_BT_CLASSIC_ENABLE
|
||||
static int ui_edr_button_handler(const char *type, u32 arg)
|
||||
{
|
||||
log_info("%s arg:%d", __func__, arg);
|
||||
ui_pic_show_image_by_id(SETTING_EDR_BUTTON, arg);
|
||||
return true;
|
||||
}
|
||||
|
||||
static int ui_ble_button_handler(const char *type, u32 arg)
|
||||
{
|
||||
log_info("%s arg:%d", __func__, arg);
|
||||
ui_pic_show_image_by_id(SETTING_BLE_BUTTON, arg);
|
||||
return true;
|
||||
}
|
||||
|
||||
static const struct uimsg_handl bt_button_msg_handler[] = {
|
||||
{ "edr_button", ui_edr_button_handler },
|
||||
{ "ble_button", ui_ble_button_handler },
|
||||
{ NULL, NULL}, /* 必须以此结尾! */
|
||||
};
|
||||
|
||||
static int set_edr_layout_onchange(void *ctr, enum element_change_event e, void *arg)
|
||||
{
|
||||
switch (e) {
|
||||
case ON_CHANGE_INIT:
|
||||
ui_register_msg_handler(ID_WINDOW_SETTING, bt_button_msg_handler);
|
||||
break;
|
||||
case ON_CHANGE_RELEASE:
|
||||
ui_register_msg_handler(ID_WINDOW_SETTING, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static int set_edr_layout_ontouch(void *ctr, struct element_touch_event *e)
|
||||
{
|
||||
struct layout *layout = (struct layout *)ctr;
|
||||
@@ -6612,7 +6646,7 @@ static int set_edr_layout_ontouch(void *ctr, struct element_touch_event *e)
|
||||
}
|
||||
|
||||
REGISTER_UI_EVENT_HANDLER(SETTING_EDR_LAYOUT)//通用-垂直列表
|
||||
.onchange = NULL,
|
||||
.onchange = set_edr_layout_onchange,
|
||||
.onkey = NULL,
|
||||
.ontouch = set_edr_layout_ontouch,
|
||||
};
|
||||
|
||||
@@ -118,6 +118,7 @@ int ui_ram_image_attrs_set(struct ui_image_attrs *img, u8 *data, int data_len, i
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void (*jlgpu_create_task_list_by_image_cb_func)(JLGPUTaskParam_t *param);
|
||||
pJLGPUTaskHead_t jlgpu_create_task_list_by_image(pJLGPUTaskHead_t head, struct ui_image_attrs *image_attr, int xoffset, int yoffset)
|
||||
{
|
||||
@@ -382,7 +383,7 @@ int page_mode_mode_cube_filp_effect_draw(pJLGPUMultTaskList_t mult_list, struct
|
||||
if (map_head) {
|
||||
jlgpu_set_task_list_out_format(map_head, out_format);
|
||||
new_head = jlgpu_task_list_copy_create(NULL, map_head, &matrix, 0);
|
||||
jlgpu_task_list_copy_destroy(map_head);
|
||||
jlgpu_delete_task_list_head(map_head);
|
||||
} else {
|
||||
new_head = jlgpu_task_list_copy_create(NULL, jlgpu_mult_task_head_by_index(mult_list, idx), &matrix, 0);
|
||||
}
|
||||
@@ -394,7 +395,7 @@ int page_mode_mode_cube_filp_effect_draw(pJLGPUMultTaskList_t mult_list, struct
|
||||
pJLGPUTaskHead_t map_head = jlgpu_task_list_map_window_id(other_win);
|
||||
if (map_head) {
|
||||
jlgpu_task_list_copy_create(new_head, map_head, &matrix, 1);
|
||||
jlgpu_task_list_copy_destroy(map_head);
|
||||
jlgpu_delete_task_list_head(map_head);
|
||||
} else {
|
||||
jlgpu_task_list_copy_create(new_head, jlgpu_mult_task_head_by_index(mult_list, idx_other), &matrix, 1);
|
||||
}
|
||||
@@ -419,6 +420,7 @@ int page_mode_mode_cube_filp_effect_draw(pJLGPUMultTaskList_t mult_list, struct
|
||||
if (tmp_head) {
|
||||
jlgpu_set_task_list_out_format(tmp_head, out_format);
|
||||
draw->new_list_create |= BIT(set_idx);
|
||||
draw->normal_list_flag |= BIT(set_idx);
|
||||
} else {
|
||||
tmp_head = jlgpu_mult_task_head_by_index(mult_list, idx);
|
||||
if (/*curr_win != DIAL_PAGE_0*/0) {
|
||||
@@ -442,6 +444,7 @@ int page_mode_mode_cube_filp_effect_draw(pJLGPUMultTaskList_t mult_list, struct
|
||||
if (tmp_head) {
|
||||
jlgpu_set_task_list_out_format(tmp_head, out_format);
|
||||
draw->new_list_create |= BIT(set_idx);
|
||||
draw->normal_list_flag |= BIT(set_idx);
|
||||
} else {
|
||||
tmp_head = jlgpu_mult_task_head_by_index(mult_list, idx_other);
|
||||
if (/*other_win != DIAL_PAGE_0*/0) {
|
||||
@@ -531,7 +534,7 @@ int page_mode_mode_drift_filp_effect_draw(pJLGPUMultTaskList_t mult_list, struct
|
||||
if (map_head) {
|
||||
jlgpu_set_task_list_out_format(map_head, out_format);
|
||||
new_head = jlgpu_task_list_copy_create(NULL, map_head, &matrix, 0);
|
||||
jlgpu_task_list_copy_destroy(map_head);
|
||||
jlgpu_delete_task_list_head(map_head);
|
||||
} else {
|
||||
new_head = jlgpu_task_list_copy_create(NULL, jlgpu_mult_task_head_by_index(mult_list, idx), &matrix, 0);
|
||||
}
|
||||
@@ -552,7 +555,7 @@ int page_mode_mode_drift_filp_effect_draw(pJLGPUMultTaskList_t mult_list, struct
|
||||
if (map_head) {
|
||||
jlgpu_set_task_list_out_format(map_head, out_format);
|
||||
new_head = jlgpu_task_list_copy_create(NULL, map_head, &matrix, 0);
|
||||
jlgpu_task_list_copy_destroy(map_head);
|
||||
jlgpu_delete_task_list_head(map_head);
|
||||
} else {
|
||||
new_head = jlgpu_task_list_copy_create(NULL, jlgpu_mult_task_head_by_index(mult_list, idx_other), &matrix, 0);
|
||||
}
|
||||
@@ -574,6 +577,7 @@ int page_mode_mode_drift_filp_effect_draw(pJLGPUMultTaskList_t mult_list, struct
|
||||
if (tmp_head) {
|
||||
jlgpu_set_task_list_out_format(tmp_head, out_format);
|
||||
draw->new_list_create |= BIT(set_idx);
|
||||
draw->normal_list_flag |= BIT(set_idx);
|
||||
} else {
|
||||
tmp_head = jlgpu_mult_task_head_by_index(mult_list, idx);
|
||||
if (/*curr_win != DIAL_PAGE_0*/0) {
|
||||
@@ -596,6 +600,7 @@ int page_mode_mode_drift_filp_effect_draw(pJLGPUMultTaskList_t mult_list, struct
|
||||
if (tmp_head) {
|
||||
jlgpu_set_task_list_out_format(tmp_head, out_format);
|
||||
draw->new_list_create |= BIT(set_idx);
|
||||
draw->normal_list_flag |= BIT(set_idx);
|
||||
} else {
|
||||
tmp_head = jlgpu_mult_task_head_by_index(mult_list, idx_other);
|
||||
if (/*other_win != DIAL_PAGE_0*/0) {
|
||||
@@ -623,7 +628,7 @@ int page_mode_mode_drift_filp_effect_draw(pJLGPUMultTaskList_t mult_list, struct
|
||||
if (map_head) {
|
||||
jlgpu_set_task_list_out_format(map_head, out_format);
|
||||
new_head = jlgpu_task_list_copy_create(NULL, map_head, &matrix, 0);
|
||||
jlgpu_task_list_copy_destroy(map_head);
|
||||
jlgpu_delete_task_list_head(map_head);
|
||||
} else {
|
||||
new_head = jlgpu_task_list_copy_create(NULL, jlgpu_mult_task_head_by_index(mult_list, idx_other), &matrix, 0);
|
||||
}
|
||||
@@ -645,7 +650,7 @@ int page_mode_mode_drift_filp_effect_draw(pJLGPUMultTaskList_t mult_list, struct
|
||||
if (map_head) {
|
||||
jlgpu_set_task_list_out_format(map_head, out_format);
|
||||
new_head = jlgpu_task_list_copy_create(NULL, map_head, &matrix, 0);
|
||||
jlgpu_task_list_copy_destroy(map_head);
|
||||
jlgpu_delete_task_list_head(map_head);
|
||||
} else {
|
||||
new_head = jlgpu_task_list_copy_create(NULL, jlgpu_mult_task_head_by_index(mult_list, idx), &matrix, 0);
|
||||
}
|
||||
@@ -666,6 +671,7 @@ int page_mode_mode_drift_filp_effect_draw(pJLGPUMultTaskList_t mult_list, struct
|
||||
if (tmp_head) {
|
||||
jlgpu_set_task_list_out_format(tmp_head, out_format);
|
||||
draw->new_list_create |= BIT(set_idx);
|
||||
draw->normal_list_flag |= BIT(set_idx);
|
||||
} else {
|
||||
tmp_head = jlgpu_mult_task_head_by_index(mult_list, idx_other);
|
||||
if (/*other_win != DIAL_PAGE_0*/0) {
|
||||
@@ -690,6 +696,7 @@ int page_mode_mode_drift_filp_effect_draw(pJLGPUMultTaskList_t mult_list, struct
|
||||
if (tmp_head) {
|
||||
jlgpu_set_task_list_out_format(tmp_head, out_format);
|
||||
draw->new_list_create |= BIT(set_idx);
|
||||
draw->normal_list_flag |= BIT(set_idx);
|
||||
} else {
|
||||
tmp_head = jlgpu_mult_task_head_by_index(mult_list, idx);
|
||||
if (/*curr_win != DIAL_PAGE_0*/0) {
|
||||
@@ -1638,3 +1645,4 @@ int ui_page_switch_effect_stop()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
//创建另外的文件存储AVI索引, 节约ram内存。在结束录像时合并索引到AVI文件中
|
||||
#define AVI_INDXE_FILE_ENABLE 1
|
||||
|
||||
#define AVI_INDXE_FILE_SAME_NAME 1//使用相同文件名
|
||||
//#include <time.h>
|
||||
#if TCFG_PSRAM_DEV_ENABLE
|
||||
#define malloc(size) malloc_psram(size)
|
||||
@@ -78,6 +78,9 @@ static size_t avi_read(void *fd, char *buf, size_t len)
|
||||
|
||||
static size_t avi_write(void *fd, char *buf, size_t len)
|
||||
{
|
||||
/* u32 rets; */
|
||||
/* __asm__ volatile("%0 = rets":"=r"(rets)); */
|
||||
/* printf("[avi_w]len:%d rets:%x", (u32)len, rets); */
|
||||
size_t n = 0;
|
||||
size_t r = 0;
|
||||
|
||||
@@ -353,10 +356,25 @@ avi_t *AVI_open_output_file(char *filename)
|
||||
strcpy(index_filename, filename);
|
||||
if (dir_path) {
|
||||
dir_path++;
|
||||
#if AVI_INDXE_FILE_SAME_NAME
|
||||
sprintf(index_filename + (dir_path - filename), "IDX.idx");
|
||||
#else
|
||||
sprintf(index_filename + (dir_path - filename), "IDX_****.idx");
|
||||
#endif
|
||||
} else {
|
||||
#if AVI_INDXE_FILE_SAME_NAME
|
||||
sprintf(index_filename, "IDX.idx");
|
||||
#else
|
||||
sprintf(index_filename, "%s.idx", filename);
|
||||
#endif
|
||||
}
|
||||
#if AVI_INDXE_FILE_SAME_NAME
|
||||
FILE *fp_tmp = fopen(index_filename, "r");
|
||||
if (fp_tmp) {
|
||||
fdelete(fp_tmp);
|
||||
fp_tmp = NULL;
|
||||
}
|
||||
#endif
|
||||
/* printf("index :%s \n", index_filename); */
|
||||
AVI->index_fdes = fopen(index_filename, "w+");
|
||||
if (AVI->index_fdes == NULL) {
|
||||
|
||||
@@ -123,9 +123,9 @@ u16 app_video_task_switch_flag_set(u16 flag)
|
||||
|
||||
#define AVI_FILE_COUNT (sizeof(avi_files) / sizeof(avi_files[0]))
|
||||
|
||||
static void parse_list_chunk(FILE *file, long list_end, ChunkCallback callback,
|
||||
void *user_param, long file_size, const char **parent_hierarchy,
|
||||
int parent_level);
|
||||
static int parse_list_chunk(FILE *file, long list_end, ChunkCallback callback,
|
||||
void *user_param, long file_size, const char **parent_hierarchy,
|
||||
int parent_level);
|
||||
typedef void (*DisplayMJpegFunc)(void *player, FILE *file, int data, int chunk_size, int width, int height);
|
||||
typedef void (*PlayPCMFunc)(void *player, FILE *file, int data, int chunk_size);
|
||||
|
||||
@@ -479,6 +479,7 @@ char parse_riff_file(FILE *file, ChunkCallback callback, void *user_param, int
|
||||
log_info("\n\n\n\n\nRIFF chunk_size: %d\n\n\n\n\n", chunk_size);
|
||||
/* 校验块大小合法性 */
|
||||
long current_pos = ftell(file) - __this->file_offset;
|
||||
/* printf("%s 111 chunk:%s current_pos: %d, chunk_size: %d, file_size: %d", __func__, chunk_id, (int)current_pos, chunk_size, (int)file_size); */
|
||||
log_info("\n\n\n\n[%s]current_pos: %d, chunk_size: %d, file_size: %d\n\n\n\n", __func__, (int)current_pos, chunk_size, (int)file_size);
|
||||
if (current_pos + chunk_size > file_size) {
|
||||
log_info("校验块大小合法性 %d %d %d", (int)current_pos, chunk_size, (int)file_size);
|
||||
@@ -507,9 +508,9 @@ char parse_riff_file(FILE *file, ChunkCallback callback, void *user_param, int
|
||||
log_error("Failed to read sub chunk size");
|
||||
return -AVI_READ_SUB_CHUNK_ID_FAIL;
|
||||
}
|
||||
|
||||
/* 校验子块大小 */
|
||||
current_pos = ftell(file) - __this->file_offset;
|
||||
/* printf("%s 222 chunk:%s current_pos: %d, chunk_size: %d, file_size: %d", __func__, sub_chunk_id, (int)current_pos, sub_chunk_size, (int)file_size); */
|
||||
if (current_pos + sub_chunk_size > file_size) {
|
||||
log_info("校验子块大小 %d %d %d", (int)current_pos, sub_chunk_size, (int)file_size);
|
||||
log_error("Sub chunk exceeds file size");
|
||||
@@ -541,9 +542,9 @@ char parse_riff_file(FILE *file, ChunkCallback callback, void *user_param, int
|
||||
fseek(file, current_pos + sub_chunk_size, SEEK_SET);
|
||||
} else {
|
||||
long list_end = ftell(file) - __this->file_offset + sub_chunk_size - 4;
|
||||
parse_list_chunk(file, list_end, callback, user_param, file_size,
|
||||
list_hierarchy, 4);
|
||||
|
||||
int ret = parse_list_chunk(file, list_end, callback, user_param, file_size,
|
||||
list_hierarchy, 4);
|
||||
return ret;
|
||||
fseek(file, current_pos + sub_chunk_size, SEEK_SET); // add
|
||||
}
|
||||
} else {
|
||||
@@ -567,9 +568,9 @@ char parse_riff_file(FILE *file, ChunkCallback callback, void *user_param, int
|
||||
return 0;
|
||||
}
|
||||
/* LIST块解析实现 */
|
||||
static void parse_list_chunk(FILE *file, long list_end, ChunkCallback callback,
|
||||
void *user_param, long file_size, const char **parent_hierarchy,
|
||||
int parent_level)
|
||||
static int parse_list_chunk(FILE *file, long list_end, ChunkCallback callback,
|
||||
void *user_param, long file_size, const char **parent_hierarchy,
|
||||
int parent_level)
|
||||
{
|
||||
while (ftell(file) - __this->file_offset < list_end) {
|
||||
wdt_clear();
|
||||
@@ -580,20 +581,21 @@ static void parse_list_chunk(FILE *file, long list_end, ChunkCallback callback,
|
||||
/* 读取子块头 */
|
||||
if (avi_fread(sub_chunk_id, 1, 4, file) != 4) {
|
||||
log_error("Failed to read sub chunk ID");
|
||||
return;
|
||||
return -AVI_READ_SUB_CHUNK_ID_FAIL;
|
||||
}
|
||||
sub_chunk_id[4] = '\0';
|
||||
|
||||
if (avi_fread(&sub_chunk_size, 4, 1, file) != 1) {
|
||||
log_error("Failed to read sub chunk size");
|
||||
return;
|
||||
return -AVI_READ_SUB_CHUNK_SIZE_FAIL;
|
||||
}
|
||||
|
||||
/* 校验子块大小 */
|
||||
long current_pos = ftell(file) - __this->file_offset;
|
||||
|
||||
/* printf("%s 333 chunk:%s current_pos: %d, chunk_size: %d, file_size: %d", __func__, sub_chunk_id, (int)current_pos, sub_chunk_size, (int)file_size); */
|
||||
if (current_pos + sub_chunk_size > file_size) {
|
||||
log_error("Sub chunk exceeds file size");
|
||||
return;
|
||||
return -AVI_SUB_CHUNK_LEN_ERR;
|
||||
}
|
||||
|
||||
/* 构建层级信息 */
|
||||
@@ -608,7 +610,7 @@ static void parse_list_chunk(FILE *file, long list_end, ChunkCallback callback,
|
||||
if (avi_fread(list_type, 1, 4, file) != 4) {
|
||||
log_error("Failed to read nested LIST type");
|
||||
avi_free(current_hierarchy);
|
||||
return;
|
||||
return -AVI_LIST_TYPE_ERR;
|
||||
}
|
||||
list_type[4] = '\0';
|
||||
|
||||
@@ -654,6 +656,7 @@ static void parse_list_chunk(FILE *file, long list_end, ChunkCallback callback,
|
||||
|
||||
avi_free(current_hierarchy);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 打印流头信息(增强版)
|
||||
|
||||
@@ -28,7 +28,10 @@ extern u16 app_video_task_switch_flag_get();
|
||||
#define MIC_FREMA_SIZE (4*1024)
|
||||
#define MIC_BUFFER_SIZE (MIC_FREMA_SIZE*2+512)
|
||||
#define MIC_SIMPLE_RATE (8000)
|
||||
|
||||
#define VIDEO_REC_START_MIN_SIZE (100)//单位是k
|
||||
#define VIDEO_REC_FILE_MIN_SIZE (20)//单位是k
|
||||
#define AVI_IDX_LEN (16)
|
||||
#define AVI_FRAME_HEAD (8)
|
||||
enum {
|
||||
Q_AVI_TASK_KILL = (Q_USER + 100),
|
||||
Q_AVI_TASK_REC_START,
|
||||
@@ -53,11 +56,13 @@ struct video_rec_handle {
|
||||
void *mic;
|
||||
u8 *mic_frame;
|
||||
char avi_task_name[32];
|
||||
u8 write_error; //写文件异常
|
||||
s8 write_error; //写文件异常 :-1 avilib返回异常,-2 空间不足
|
||||
u8 busy;
|
||||
int aframe_size;
|
||||
int video_rate;
|
||||
int sample_rate;
|
||||
int avi_file_size; //预估文件大小
|
||||
/* int real_file_size; //真实文件大小 */
|
||||
void (*ui_refresh_cb)(int status);
|
||||
int bytes_per_sample;
|
||||
struct fill_frame fill;
|
||||
@@ -228,13 +233,18 @@ static void jljpeg_frame_fill_judge(avi_t *out_fd, u32 frame_cnt)
|
||||
/* printf("avi dup video fps :%d act fps:%d ,ext fps: %d %d\n", __this->fill.cnt_fnum / __this->fill.secs, __this->fill.one_sec_fps, __this->fill.fps,__this->fill.fnum); */
|
||||
__this->fill.one_sec_fps = 0;
|
||||
}
|
||||
|
||||
__again:
|
||||
if (__this->fill.fnum && __this->fill.fill_frame_en) {
|
||||
int ret = AVI_dup_frame(out_fd);
|
||||
if (!ret) {
|
||||
__this->avi_file_size += AVI_IDX_LEN * 2;
|
||||
/* __this->real_file_size += AVI_IDX_LEN; */
|
||||
/* printf("real1 dt:%d", AVI_IDX_LEN); */
|
||||
__this->fill.cnt_fnum++;
|
||||
__this->fill.fnum--;
|
||||
|
||||
if (__this->fill.fnum > __this->fill.fps / 3) {
|
||||
goto __again;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -254,7 +264,7 @@ static int jljpeg_frame_dropping_judge()
|
||||
u32 msecs = jiffies_msec2offset(__this->fill.msecs, jiffies_msec());
|
||||
/* printf("%d %d %d\n",(__this->fill.one_sec_fps+1) , (msecs*__this->fill.fps/1000),msecs); */
|
||||
if ((__this->fill.one_sec_fps) > (msecs * __this->fill.fps / 1000) + 1) {
|
||||
/* printf("fps > %d ,need droping\n",__this->fill.fps); */
|
||||
printf("fps > %d ,need droping\n", __this->fill.fps);
|
||||
if (__this->fill.fnum) {
|
||||
__this->fill.fnum--;
|
||||
return 0;
|
||||
@@ -283,7 +293,7 @@ static void video_show_task(void *priv)
|
||||
|
||||
char *filename = NULL;
|
||||
avi_t *out_fd = NULL;
|
||||
|
||||
u32 free_space = 0;
|
||||
camera_manager_get_dev_width_height(&frame_width, &frame_height);
|
||||
log_info("%s frame[%d x %d] \n", __func__, frame_width, frame_height);
|
||||
|
||||
@@ -325,8 +335,19 @@ static void video_show_task(void *priv)
|
||||
break;
|
||||
} else if (msg[0] == Q_AVI_TASK_REC_START) {
|
||||
filename = (char *)msg[1];
|
||||
|
||||
fget_free_space(filename, &free_space);
|
||||
|
||||
printf("[VDO_DEBUG]free_space:%d \n", free_space);
|
||||
if (free_space <= VIDEO_REC_START_MIN_SIZE) {
|
||||
log_error("avi task rec start not enough space:%dk\n", free_space);
|
||||
__this->write_error = -2;
|
||||
continue;
|
||||
}
|
||||
cyc_time = msg[2];
|
||||
__this->write_error = 0;
|
||||
__this-> avi_file_size = 0;
|
||||
/* __this->real_file_size = 0; */
|
||||
log_debug("avi task rec start <%s> cyc_time:%d !\n", filename, cyc_time);
|
||||
#if MIC_DATA_FORM_PCM_TASK_ENABLE
|
||||
__this->pcm_hdl = pcm_data_init(__this->sample_rate, __this->aframe_size, __this->aframe_size * 10);
|
||||
@@ -373,10 +394,11 @@ static void video_show_task(void *priv)
|
||||
ret = AVI_close(out_fd);
|
||||
if (ret) {
|
||||
log_error("camera devide avi close err :%d \n", ret);
|
||||
__this->write_error = 1;
|
||||
__this->write_error = -1;
|
||||
/* ASSERT(0); */
|
||||
} else {
|
||||
log_debug("avi write success \n");
|
||||
/* printf("real_file_size:%d", __this->real_file_size); */
|
||||
}
|
||||
out_fd = NULL;
|
||||
}
|
||||
@@ -408,14 +430,29 @@ static void video_show_task(void *priv)
|
||||
#if MIC_DATA_FORM_PCM_TASK_ENABLE
|
||||
if (pcm_data_read(__this->pcm_hdl, &pcm_data, &pcm_data_len) == 0) {
|
||||
read_data = 1;
|
||||
__this->write_error = AVI_write_audio(out_fd, (char *)pcm_data, pcm_data_len);
|
||||
ret = AVI_write_audio(out_fd, (char *)pcm_data, pcm_data_len);
|
||||
if (!ret) {
|
||||
__this->avi_file_size += (AVI_IDX_LEN * 2 + AVI_FRAME_HEAD + pcm_data_len);
|
||||
/* __this->real_file_size += (AVI_IDX_LEN + AVI_FRAME_HEAD + pcm_data_len); */
|
||||
/* printf("real2 dt:%d", (AVI_IDX_LEN + AVI_FRAME_HEAD + pcm_data_len)); */
|
||||
} else {
|
||||
__this->write_error = -1;
|
||||
}
|
||||
pcm_data_read_done(__this->pcm_hdl, pcm_data);
|
||||
}
|
||||
#else
|
||||
if (__this->mic && __this->mic_frame) {
|
||||
if (mic_data_read(__this->mic, __this->mic_frame, MIC_FREMA_SIZE)) {
|
||||
read_data = 1;
|
||||
__this->write_error = AVI_write_audio(out_fd, (char *)__this->mic_frame, MIC_FREMA_SIZE);
|
||||
ret = AVI_write_audio(out_fd, (char *)__this->mic_frame, MIC_FREMA_SIZE);
|
||||
if (!ret) {
|
||||
__this->avi_file_size += (AVI_IDX_LEN * 2 + AVI_FRAME_HEAD + MIC_FREMA_SIZE);
|
||||
/* __this->real_file_size += (AVI_IDX_LEN + AVI_FRAME_HEAD + MIC_FREMA_SIZE); */
|
||||
|
||||
/* printf("real3 dt:%d", (AVI_IDX_LEN + AVI_FRAME_HEAD + MIC_FREMA_SIZE)); */
|
||||
} else {
|
||||
__this->write_error = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -456,7 +493,15 @@ static void video_show_task(void *priv)
|
||||
#endif
|
||||
if (out_fd) { //录像输出
|
||||
if (!jljpeg_frame_dropping_judge()) {
|
||||
__this->write_error = AVI_write_frame(out_fd, (char *)jpeg_data, jpeg_data_len, 1);
|
||||
ret = AVI_write_frame(out_fd, (char *)jpeg_data, jpeg_data_len, 1);
|
||||
if (!ret) {
|
||||
__this->avi_file_size += (AVI_IDX_LEN * 2 + AVI_FRAME_HEAD + (jpeg_data_len + 1) / 2 * 2);
|
||||
/* __this->real_file_size += (AVI_IDX_LEN + AVI_FRAME_HEAD + (jpeg_data_len + 1) / 2 * 2); */
|
||||
|
||||
/* printf("real4 dt:%d", (AVI_IDX_LEN + AVI_FRAME_HEAD + jpeg_data_len)); */
|
||||
} else {
|
||||
__this->write_error = -1;
|
||||
}
|
||||
jljpeg_frame_fill_judge(out_fd, 1); //补帧计算
|
||||
} else {
|
||||
jljpeg_frame_fill_judge(out_fd, 0); //补帧计算
|
||||
@@ -506,6 +551,38 @@ static void video_show_task(void *priv)
|
||||
frame_cnt = 0;
|
||||
}
|
||||
}
|
||||
if (out_fd) {
|
||||
/* printf("[video_rec]fsize:%d left:%d dt:%d \n",__this->avi_file_size,free_space*1024,free_space*1024 -__this->avi_file_size); */
|
||||
if ((__this->avi_file_size + VIDEO_REC_FILE_MIN_SIZE * 1024) >= (free_space * 1024)) {
|
||||
ret = AVI_close(out_fd);
|
||||
if (ret) {
|
||||
log_error("camera devide avi close err :%d \n", ret);
|
||||
__this->write_error = -1;
|
||||
/* ASSERT(0); */
|
||||
} else {
|
||||
log_debug("avi write success \n");
|
||||
/* printf(">>>real_file_size:%d", __this->real_file_size); */
|
||||
}
|
||||
out_fd = NULL;
|
||||
#if MIC_DATA_FORM_PCM_TASK_ENABLE
|
||||
if (__this->pcm_hdl) {
|
||||
pcm_data_exit(__this->pcm_hdl);
|
||||
__this->pcm_hdl = NULL;
|
||||
}
|
||||
#else
|
||||
if (__this->mic) {
|
||||
mic_data_close(__this->mic);
|
||||
__this->mic = NULL;
|
||||
}
|
||||
if (__this->mic_frame) {
|
||||
free(__this->mic_frame);
|
||||
__this->mic_frame = NULL;
|
||||
}
|
||||
#endif
|
||||
__this->write_error = -2;
|
||||
/* break; */
|
||||
}
|
||||
}
|
||||
|
||||
//没有读到数据
|
||||
if (!read_data) {
|
||||
|
||||
Reference in New Issue
Block a user