📄 webcam_msg_handler.c
字号:
/* Code Body */
/*----------------------------------------------------------------*/
msg_p = (usbvideo_result_struct*) ilm_ptr->local_para_ptr;
if (WEBCAM_IN_STATE(WEBCAM_PREVIEW) || WEBCAM_IN_STATE(WEBCAM_CAPTURE))
{
if (msg_p->result)
{
webcam_set_result(MED_RES_OK);
}
else
{
webcam_set_result(MED_RES_FAIL);
}
}
WEBCAM_SET_EVENT(WEBCAM_EVT_CAPTURE);
}
/*****************************************************************************
* FUNCTION
* webcam_rotate_req_hdlr
* DESCRIPTION
* This function is to rotate webcam.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void webcam_rotate_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
media_webcam_rotate_req_struct *req_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
req_p = (media_webcam_rotate_req_struct*) ilm_ptr->local_para_ptr;
if (WEBCAM_IN_STATE(WEBCAM_PREVIEW))
{
webcam_context_p->image_mirror = cam_rotate_map[req_p->rotate];
/* 1. stop camera preview */
exit_usbvideo_camera_preview();
/* 2. change the rotate value */
usbvideo_param.image_mirror = webcam_context_p->image_mirror;
/* 3. restart the preview */
usbvideo_camera_preview(&usbvideo_param);
webcam_set_result(MED_RES_OK);
WEBCAM_SET_EVENT(WEBCAM_EVT_ROTATE);
}
else if (WEBCAM_IN_STATE(WEBCAM_CAPTURE) || WEBCAM_IN_STATE(WEBCAM_START_PREVIEW))
{
webcam_context_p->image_mirror = cam_rotate_map[req_p->rotate];
webcam_set_result(MED_RES_OK);
WEBCAM_SET_EVENT(WEBCAM_EVT_ROTATE);
}
else
{
webcam_set_result(MED_RES_BUSY);
WEBCAM_SET_EVENT(WEBCAM_EVT_ROTATE);
}
}
/*****************************************************************************
* FUNCTION
* webcam_set_camera_attr_req_hdlr
* DESCRIPTION
* This function is to handle set camera attributes from USB.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void webcam_set_camera_attr_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
usbvideo_attr_msg_struct *req_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
req_p = (usbvideo_attr_msg_struct*) ilm_ptr->local_para_ptr;
/* set camera to camera driver */
usbvideo_camera_set_attr(&(req_p->attr_value));
/* send confirm msg to USB task */
webcam_send_usb_set_camera_attr_cnf((void*)req_p);
}
/*****************************************************************************
* FUNCTION
* webcam_start_still_ind_hdlr
* DESCRIPTION
* This function is to handle start still capture indication from USB.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void webcam_start_still_ind_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
usbvideo_still_size_struct *msg_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
msg_p = (usbvideo_still_size_struct*) ilm_ptr->local_para_ptr;
if (WEBCAM_IN_STATE(WEBCAM_PREVIEW))
{
/* stop camera preview */
exit_usbvideo_camera_preview();
WEBCAM_FREE_INT_MEM();
/* start camera still capture */
webcam_context_p->intmem_start_address = (kal_uint32) med_alloc_int_mem(webcam_capture_mem[0]);
webcam_context_p->intmem_size = (kal_uint32) webcam_capture_mem[0];
usbvideo_param.intmem_start_address = webcam_context_p->intmem_start_address;
usbvideo_param.intmem_size = webcam_context_p->intmem_size;
usbvideo_param.image_mirror = webcam_context_p->image_mirror;
usbvideo_param.target_size_enum = msg_p->still_size_type;
usbvideo_param.target_comp_enum = msg_p->still_compression_type;
usbvideo_param.usbvideo_cam_preview_cb = cam_preview_callback;
usbvideo_camera_capture(&usbvideo_param);
WEBCAM_ENTER_STATE(WEBCAM_CAPTURE);
}
else if (WEBCAM_IN_STATE(WEBCAM_CAPTURE))
{
/* stop camera capture */
exit_usbvideo_camera_capture();
WEBCAM_FREE_INT_MEM();
/* start camera still capture */
webcam_context_p->intmem_start_address = (kal_uint32) med_alloc_int_mem(webcam_capture_mem[0]);
webcam_context_p->intmem_size = (kal_uint32) webcam_capture_mem[0];
usbvideo_param.intmem_start_address = webcam_context_p->intmem_start_address;
usbvideo_param.intmem_size = webcam_context_p->intmem_size;
usbvideo_param.image_mirror = webcam_context_p->image_mirror;
usbvideo_param.target_size_enum = msg_p->still_size_type;
usbvideo_param.target_comp_enum = msg_p->still_compression_type;
usbvideo_param.usbvideo_cam_preview_cb = cam_preview_callback;
usbvideo_camera_capture(&usbvideo_param);
WEBCAM_ENTER_STATE(WEBCAM_CAPTURE);
}
else if (WEBCAM_IN_STATE(WEBCAM_PAUSING))
{
/* already send pause command to usb driver, ingore this action */
}
else
{
ASSERT(WEBCAM_IN_STATE(WEBCAM_PREVIEW));
}
}
/*****************************************************************************
* FUNCTION
* webcam_start_video_ind_hdlr
* DESCRIPTION
* This function is to handle start video indication from USB.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void webcam_start_video_ind_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
usbvideo_video_size_struct *msg_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
msg_p = (usbvideo_video_size_struct*) ilm_ptr->local_para_ptr;
if (WEBCAM_IN_STATE(WEBCAM_CAPTURE))
{
if (msg_p->result)
{
/* stop camera still capture */
exit_usbvideo_camera_capture();
WEBCAM_FREE_INT_MEM();
/* start camera preview */
webcam_context_p->intmem_start_address = (kal_uint32) med_alloc_int_mem(webcam_preview_mem[0]);
webcam_context_p->intmem_size = (kal_uint32) webcam_preview_mem[0];
usbvideo_param.intmem_start_address = webcam_context_p->intmem_start_address;
usbvideo_param.intmem_size = webcam_context_p->intmem_size;
usbvideo_param.image_mirror = webcam_context_p->image_mirror;
usbvideo_param.target_size_enum = msg_p->video_size_type;
usbvideo_param.target_comp_enum = msg_p->video_compression_type;
usbvideo_param.usbvideo_cam_preview_cb = cam_preview_callback;
usbvideo_camera_preview(&usbvideo_param);
WEBCAM_ENTER_STATE(WEBCAM_PREVIEW);
}
else
{
ASSERT(msg_p->result);
}
}
else
{
ASSERT(WEBCAM_IN_STATE(WEBCAM_CAPTURE));
}
}
/*****************************************************************************
* FUNCTION
* webcam_change_video_ind_hdlr
* DESCRIPTION
* This function is to handle change video size indication from USB.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void webcam_change_video_ind_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
usbvideo_video_size_struct *msg_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
msg_p = (usbvideo_video_size_struct*) ilm_ptr->local_para_ptr;
if (WEBCAM_IN_STATE(WEBCAM_PREVIEW))
{
if (msg_p->result)
{
/* stop camera a preview */
exit_usbvideo_camera_preview();
WEBCAM_FREE_INT_MEM();
/* start camera preview */
webcam_context_p->intmem_start_address = (kal_uint32) med_alloc_int_mem(webcam_preview_mem[0]);
webcam_context_p->intmem_size = (kal_uint32) webcam_preview_mem[0];
usbvideo_param.intmem_start_address = webcam_context_p->intmem_start_address;
usbvideo_param.intmem_size = webcam_context_p->intmem_size;
usbvideo_param.image_mirror = webcam_context_p->image_mirror;
usbvideo_param.target_size_enum = msg_p->video_size_type;
usbvideo_param.target_comp_enum = msg_p->video_compression_type;
usbvideo_param.usbvideo_cam_preview_cb = cam_preview_callback;
usbvideo_camera_preview(&usbvideo_param);
WEBCAM_ENTER_STATE(WEBCAM_PREVIEW);
}
else
{
ASSERT(msg_p->result);
}
}
else
{
ASSERT(WEBCAM_IN_STATE(WEBCAM_PREVIEW));
}
}
/*****************************************************************************
* FUNCTION
* webcam_drv_abort_ind_hdlr
* DESCRIPTION
* This function is to handle drvier aboart, but the cable didnt plugout.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void webcam_drv_abort_ind_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (!WEBCAM_IN_STATE(WEBCAM_IDLE))
{
webcam_send_abort_ind();
}
}
#endif /* __MED_WEBCAM_MOD__ */
#endif /* MED_NOT_PRESENT */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -