📄 vid_msg_handler.c
字号:
}
eFSALRet = FSAL_Open_WithHandle(&mp4_files.MEDIA_META_FILE, (void*)vid_context_p->file_handle);
if (eFSALRet == FSAL_OK)
{
return MED_RES_OK;
}
FSAL_Close(&mp4_files.MEDIA_VIDEO_FILE);
return MED_RES_OPEN_FILE_FAIL;
}
else
{
if (FSAL_GetLastError(&mp4_files.MEDIA_META_FILE) == FS_WRITE_PROTECTION)
{
return MED_RES_WRITE_PROTECTION;
}
else
{
return MED_RES_OPEN_FILE_FAIL;
}
}
}
/*****************************************************************************
* FUNCTION
* vid_close_visual_file_for_record
* DESCRIPTION
* This function is to close visual files for recording including dump data to file.
* PARAMETERS
* void
* RETURNS
* kal_int16
*****************************************************************************/
kal_int16 vid_close_visual_file_for_record(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int32 result = MED_RES_OK;
FSAL_Status eFSALRet;
kal_uint32 residual_size;
kal_uint32 increase_size;
MEDIA_STATUS_CODE status;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
residual_size = vid_file_meta_residual_size();
/* Store META file */
status = meta_enc_buffer_store_file(residual_size, &increase_size);
VID_VALUE_TRACE(residual_size, increase_size, __LINE__);
if (status != MEDIA_STATUS_OK)
{
result = vid_get_result_from_media_status(status);
vid_context_p->error_code = result;
}
/* Close meta file */
eFSALRet = FSAL_Close(&mp4_files.MEDIA_META_FILE);
if (eFSALRet != FSAL_OK && result == MED_RES_OK)
{
VID_FSAL_ERROR_TRACE(eFSALRet, __LINE__);
result = MED_RES_OPEN_FILE_FAIL;
vid_context_p->error_code = result;
}
vid_context_p->file_size = vid_get_current_file_size();
/* Store VIDEO file */
if (residual_size > increase_size)
{
residual_size = residual_size - increase_size;
}
else
{
residual_size = 0;
}
status = video_enc_buffer_dump_to_file(residual_size, &increase_size);
VID_VALUE_TRACE(residual_size, increase_size, __LINE__);
vid_context_p->file_size_info.video_bitstream_size += increase_size;
vid_context_p->file_size_info.video_rm_size = video_evaluate_real_meta_file_size(vid_context_p->file_size_info.short_header_mode);
vid_context_p->file_size = vid_get_current_file_size();
VID_VALUE_TRACE(vid_context_p->file_size, vid_context_p->file_size_info.video_bitstream_size, vid_context_p->file_size_info.video_rm_size);
if (status != MEDIA_STATUS_OK && result == MED_RES_OK)
{
result = vid_get_result_from_media_status(status);
vid_context_p->error_code = result;
}
/* Close video file */
eFSALRet = FSAL_Close(&mp4_files.MEDIA_VIDEO_FILE);
if (eFSALRet != FSAL_OK && result == MED_RES_OK)
{
VID_FSAL_ERROR_TRACE(eFSALRet, __LINE__);
result = MED_RES_OPEN_FILE_FAIL;
vid_context_p->error_code = result;
}
return result;
}
/*****************************************************************************
* FUNCTION
* vid_close_audio_file_for_record
* DESCRIPTION
* This function is to close audio file for recording including dump data to file.
* PARAMETERS
* void
* RETURNS
* kal_int16
*****************************************************************************/
kal_int16 vid_close_audio_file_for_record(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int32 result = MED_RES_OK;
kal_uint16 *pwBuf;
kal_uint32 uBufLen;
FSAL_Status eFSALRet;
kal_uint32 residual_size;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
residual_size = vid_file_audio_residual_size();
Media_GetReadBuffer(&pwBuf, &uBufLen);
if (residual_size < uBufLen * 2)
{
uBufLen = (residual_size >> 1);
}
if (uBufLen > 0)
{
eFSALRet = FSAL_Write(&fsalAudioFile, (kal_uint8*) pwBuf, uBufLen * 2);
if (eFSALRet != FSAL_OK)
{
VID_FSAL_ERROR_TRACE(eFSALRet, __LINE__);
result = MED_RES_FSAL_ERROR;
vid_context_p->error_code = result;
}
Media_ReadDataDone(uBufLen);
}
vid_context_p->file_size = vid_get_current_file_size();
/* Close audio file */
eFSALRet = FSAL_Close(&fsalAudioFile);
if (eFSALRet != FSAL_OK && result == MED_RES_OK)
{
VID_FSAL_ERROR_TRACE(eFSALRet, __LINE__);
result = MED_RES_OPEN_FILE_FAIL;
vid_context_p->error_code = result;
}
return result;
}
/*****************************************************************************
* FUNCTION
* vid_preview_req_hdlr
* DESCRIPTION
* This function is to handle video preview request.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void vid_preview_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
media_vid_preview_req_struct *req_p;
MEDIA_STATUS_CODE status;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (aud_context_p->access_mod != ilm_ptr->src_mod_id)
{
vid_set_result(MED_RES_BLOCKED);
VID_SET_EVENT(VID_EVT_PREVIEW);
return;
}
vid_context_p->src_mod = ilm_ptr->src_mod_id;
if (CAM_IN_STATE(CAM_READY))
{
req_p = (media_vid_preview_req_struct*) ilm_ptr->local_para_ptr;
mp4_encode.intmem_start_address = vid_context_p->intmem_start_address =
(kal_uint32) med_alloc_int_mem(vid_record_mem[0]);
mp4_encode.intmem_size = vid_context_p->intmem_size = vid_record_mem[0];
mp4_encode.extmem_start_address = vid_context_p->extmem_start_address =
(kal_uint32) med_alloc_ext_mem(vid_record_mem[1]);
mp4_encode.extmem_size = vid_context_p->extmem_size = vid_record_mem[1];
if(mp4_encode.extmem_start_address==NULL)
{
ASSERT(mp4_encode.extmem_start_address!=0);
vid_release_memory();
vid_set_result(MED_RES_MEM_INSUFFICIENT);
VID_SET_EVENT(VID_EVT_PREVIEW);
return;
}
mp4_encode.mpeg4_image_width = req_p->image_width;
mp4_encode.mpeg4_image_height = req_p->image_height;
/* 64000,128000,256000 */
vid_context_p->encode_quality = req_p->encode_quality;
/* for engineering mode */
if (vid_context_p->em_mode == VID_EM_MODE_ULTRA_HIGH_BITRATE)
{
mp4_encode.encode_bit_rate = 1000000;
mp4_encode.skip_frame_count = 0;
}
else
{
vid_convert_quality_to_bitrate(
mp4_encode.mpeg4_image_width,
mp4_encode.mpeg4_image_height,
req_p->encode_quality,
&mp4_encode.encode_bit_rate,
&mp4_encode.skip_frame_count);
}
vid_context_p->bit_stream_type = req_p->bit_stream_type;
if (vid_context_p->bit_stream_type == VID_3GP_BIT_STREAM)
{
mp4_encode.short_header_mode = KAL_TRUE;
}
else
{
mp4_encode.short_header_mode = KAL_FALSE;
}
mp4_encode.image_target_width = req_p->preview_width;
mp4_encode.image_target_height = req_p->preview_height;
mp4_encode.lcd_id = req_p->lcd_id;
mp4_encode.lcm_start_x = req_p->lcd_start_x;
mp4_encode.lcm_start_y = req_p->lcd_start_y;
mp4_encode.lcm_end_x = req_p->lcd_end_x;
mp4_encode.lcm_end_y = req_p->lcd_end_y;
mp4_encode.roi_offset_x = req_p->roi_offset_x;
mp4_encode.roi_offset_y = req_p->roi_offset_y;
mp4_encode.update_layer = req_p->update_layer;
mp4_encode.hw_update_layer = req_p->hw_update_layer;
mp4_encode.lcd_update = req_p->lcd_update;
mp4_encode.frame_buffer_address = (kal_uint32) req_p->image_buffer_p;
mp4_encode.frame_buffer_size = req_p->image_buffer_size;
mp4_encode.mpeg4_offset_x = req_p->preview_offset_x;
mp4_encode.mpeg4_offset_y = req_p->preview_offset_y;
mp4_encode.resume_enable = KAL_FALSE;
mp4_encode.rotate_value = (kal_uint8) req_p->lcd_rotate;
mp4_encode.image_mirror = cam_rotate_map[req_p->rotate];
mp4_encode.frame_rate = 15;
mp4_encode.zoom_factor = (kal_uint8) req_p->zoom_factor;
mp4_encode.ev_value = req_p->exposure;
mp4_encode.wb_mode = req_p->WB;
mp4_encode.contrast_level = req_p->contrast;
mp4_encode.brightness_level = req_p->brightness;
mp4_encode.saturation_value = req_p->saturation;
mp4_encode.image_effect = req_p->effect;
mp4_encode.night_mode = req_p->night_mode;
mp4_encode.banding_freq = req_p->banding_freq;
mp4_encode.encode_event_cb = vis_send_encode_visual_data_ind;
mp4_encode.cam_encode_cb = cam_preview_callback;
#if MT6228_SERIES
/* IPP Setting */
mp4_encode.overlay_frame_mode = req_p->overlay_frame_mode;
mp4_encode.overlay_color_depth = req_p->overlay_color_depth;
mp4_encode.overlay_frame_source_key = req_p->overlay_frame_source_key;
mp4_encode.overlay_frame_width = req_p->overlay_frame_width;
mp4_encode.overlay_frame_height = req_p->overlay_frame_height;
mp4_encode.overlay_frame_buffer_address = req_p->overlay_frame_buffer_address;
mp4_encode.image_pitch_mode = req_p->image_pitch_mode;
mp4_encode.image_data_format = req_p->image_data_format;
mp4_encode.image_pitch_bytes = req_p->image_pitch_bytes;
/* TV Setting */
#ifdef __MED_TVO_MOD__
mp4_encode.tv_output = req_p->tv_output;
mp4_encode.tv_output_width = req_p->tv_output_width;
mp4_encode.tv_output_height = req_p->tv_output_height;
mp4_encode.tv_output_offset_x = req_p->tv_output_offset_x;
mp4_encode.tv_output_offset_y = req_p->tv_output_offset_y;
mp4_encode.tv_output_buffer1_address = req_p->tv_output_buffer1_address;
mp4_encode.tv_output_buffer2_address = req_p->tv_output_buffer2_address;
mp4_encode.tv_output_buffer_size = req_p->tv_output_buffer_size;
#endif /* __MED_TVO_MOD__ */
/* LCD Setting */
mp4_encode.roi_background_color = req_p->roi_background_color;
#endif /* MT6228_SERIES */
status = (MEDIA_STATUS_CODE) mpeg4_encode_process(&mp4_encode);
if (status != MEDIA_STATUS_OK)
{
vid_set_result(vid_get_result_from_media_status(status));
}
else
{
vid_set_result(MED_RES_OK);
VID_ENTER_STATE(VID_PREVIEW);
}
}
else
{
vid_set_result(MED_RES_BUSY);
}
VID_SET_EVENT(VID_EVT_PREVIEW);
}
/*****************************************************************************
* FUNCTION
* vid_record_req_hdlr
* DESCRIPTION
* This function is to handle video record request
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void vid_record_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
media_vid_record_req_struct *req_p;
kal_wchar drive[4] = L" :\\";
FS_DiskInfo disc_info;
kal_int32 result;
MEDIA_STATUS_CODE status;
Media_Status aud_status;
kal_bool video_file_open = KAL_FALSE;
kal_bool audio_file_open = KAL_FALSE;
kal_uint32 cluster_size;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (aud_context_p->access_mod != ilm_ptr->src_mod_id)
{
vid_set_result(MED_RES_BLOCKED);
VID_SET_EVENT(VID_EVT_RECORD);
return;
}
vid_context_p->src_mod = ilm_ptr->src_mod_id;
req_p = (media_vid_record_req_struct*) ilm_ptr->local_para_ptr;
vid_stop_unfinished_audio();
vid_context_p->seq_num = req_p->seq_num;
if (VID_IN_STATE(VID_PREVIEW))
{
kal_uint32 file_margin, min_file_size;
/* stop unfinished audio task */
aud_stop_unfinished_process();
/* clean temp files in case of abort shut down when last file merge process */
kal_mem_cpy(vid_context_p->storing_path, req_p->data, MAX_FILE_NAME_LEN * ENCODE_BYTE);
med_remove_file_name(vid_context_p->storing_path);
kal_wstrcat(vid_context_p->storing_path, VID_AUDIO_FILE);
FS_Delete(vid_context_p->storing_path);
med_remove_file_name(vid_context_p->storing_path);
kal_wstrcat(vid_context_p->storing_path, VID_AUDIO_SAMPLE_FILE);
FS_Delete(vid_context_p->storing_path);
med_remove_file_name(vid_context_p->storing_path);
kal_wstrcat(vid_context_p->storing_path, VID_VISUAL_FILE);
FS_Delete(vid_context_p->storing_path);
med_remove_file_name(vid_context_p->storing_path);
kal_wstrcat(vid_context_p->storing_path, VID_VISUAL_META_FILE);
FS_Delete(vid_context_p->storing_path);
med_remove_file_name(vid_context_p->storing_path);
kal_wstrcat(vid_context_p->storing_path, VID_VISUAL_REAL_META_FILE);
FS_Delete(vid_context_p->storing_path);
/* reset the error code */
vid_context_p->error_code = MED_RES_OK;
/* init file info */
kal_mem_set(&(vid_context_p->file_size_info), 0, sizeof(video_file_info_struct));
/* check disc space before stop preview to prevent the preview screen from pausing */
result = vid_get_disc_free_space((kal_wchar*) req_p->data, &vid_context_p->file_size_info.file_size_limit);
vid_context_p->free_disc_space = vid_context_p->file_size_info.file_size_limit;
/* Get disc info, free space, cluster size */
drive[0] = vid_context_p->storing_path[0];
vid_context_p->file_size_info.video_bitstream_size = 0x20;
vid_context_p->file_size_inf
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -