📄 webcam_msg_handler.c
字号:
WEBCAM_ENTER_STATE(WEBCAM_STOPPING);
}
else
{
webcam_set_result(MED_RES_BUSY);
WEBCAM_SET_EVENT(WEBCAM_EVT_STOP);
}
}
/*****************************************************************************
* FUNCTION
* webcam_stop_cnf_hdlr
* DESCRIPTION
* This function is to handle the stop confirm from USB task.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void webcam_stop_cnf_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
usbvideo_result_struct *msg_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
msg_p = (usbvideo_result_struct*) ilm_ptr->local_para_ptr;
if (WEBCAM_IN_STATE(WEBCAM_STOPPING))
{
if (msg_p->result)
{
webcam_set_result(MED_RES_OK);
}
else
{
ASSERT(msg_p->result);
}
WEBCAM_FREE_USB_BUFFER();
WEBCAM_ENTER_STATE(WEBCAM_IDLE);
WEBCAM_SET_EVENT(WEBCAM_EVT_STOP);
}
}
/*****************************************************************************
* FUNCTION
* webcam_pause_req_hdlr
* DESCRIPTION
* This function is to pause webcam.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void webcam_pause_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
media_webcam_pause_req_struct *req_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
req_p = (media_webcam_pause_req_struct*) ilm_ptr->local_para_ptr;
webcam_context_p->src_mod = ilm_ptr->src_mod_id;
if (WEBCAM_IN_STATE(WEBCAM_START_PREVIEW))
{
webcam_send_usb_pause_req(req_p);
WEBCAM_ENTER_STATE(WEBCAM_PAUSING);
}
else if (WEBCAM_IN_STATE(WEBCAM_PREVIEW))
{
exit_usbvideo_camera_preview();
usbvideo_camera_power_off();
WEBCAM_FREE_INT_MEM();
webcam_send_usb_pause_req(req_p);
WEBCAM_ENTER_STATE(WEBCAM_PAUSING);
}
else if (WEBCAM_IN_STATE(WEBCAM_CAPTURE))
{
exit_usbvideo_camera_capture();
usbvideo_camera_power_off();
WEBCAM_FREE_INT_MEM();
webcam_send_usb_pause_req(req_p);
WEBCAM_ENTER_STATE(WEBCAM_PAUSING);
}
else
{
webcam_set_result(MED_RES_BUSY);
WEBCAM_SET_EVENT(WEBCAM_EVT_PAUSE);
}
}
/*****************************************************************************
* FUNCTION
* webcam_pause_cnf_hdlr
* DESCRIPTION
* This function is to handle the pause confirm from USB task.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void webcam_pause_cnf_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
usbvideo_result_struct *msg_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
msg_p = (usbvideo_result_struct*) ilm_ptr->local_para_ptr;
if (WEBCAM_IN_STATE(WEBCAM_PAUSING))
{
if (msg_p->result)
{
webcam_set_result(MED_RES_OK);
WEBCAM_ENTER_STATE(WEBCAM_PAUSED);
}
else
{
webcam_set_result(MED_RES_FAIL);
WEBCAM_ENTER_STATE(WEBCAM_IDLE);
}
WEBCAM_FREE_USB_BUFFER();
WEBCAM_SET_EVENT(WEBCAM_EVT_PAUSE);
}
}
/*****************************************************************************
* FUNCTION
* webcam_resume_req_hdlr
* DESCRIPTION
* This function is to resume webcam.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void webcam_resume_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
media_webcam_resume_req_struct *req_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
req_p = (media_webcam_resume_req_struct*) ilm_ptr->local_para_ptr;
webcam_context_p->src_mod = ilm_ptr->src_mod_id;
if (WEBCAM_IN_STATE(WEBCAM_PAUSED))
{
usbvideo_video_req_struct start;
webcam_context_p->image_mirror = cam_rotate_map[req_p->rotate];
webcam_context_p->buffer_size = MAX_WEBCAM_BUFFER_SIZE;
webcam_context_p->buffer_addr = (kal_uint8*) med_alloc_ext_mem(webcam_context_p->buffer_size);
if (webcam_context_p->buffer_addr)
{
start.buffer_addr = webcam_context_p->buffer_addr;
start.buffer_size = webcam_context_p->buffer_size;
webcam_send_usb_resume_req((void*)&start);
WEBCAM_ENTER_STATE(WEBCAM_START_PREVIEW);
}
else
{
webcam_set_result(MED_RES_MEM_INSUFFICIENT);
WEBCAM_SET_EVENT(WEBCAM_EVT_RESUME);
}
}
else
{
webcam_set_result(MED_RES_BUSY);
WEBCAM_SET_EVENT(WEBCAM_EVT_RESUME);
}
}
/*****************************************************************************
* FUNCTION
* webcam_resume_cnf_hdlr
* DESCRIPTION
* This function is to handle the video resume confirm from USB task.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void webcam_resume_cnf_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_START_PREVIEW))
{
if (msg_p->result)
{
usbvideo_camera_power_on();
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.banding_freq = webcam_context_p->banding;
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);
webcam_set_result(MED_RES_OK);
WEBCAM_SET_EVENT(WEBCAM_EVT_RESUME);
}
else
{
webcam_set_result(MED_RES_FAIL);
WEBCAM_SET_EVENT(WEBCAM_EVT_RESUME);
}
}
}
/*****************************************************************************
* FUNCTION
* webcam_capture_req_hdlr
* DESCRIPTION
* This function is to inform host to start capture.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void webcam_capture_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
media_webcam_capture_req_struct *req_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
req_p = (media_webcam_capture_req_struct*) ilm_ptr->local_para_ptr;
webcam_context_p->src_mod = ilm_ptr->src_mod_id;
if (WEBCAM_IN_STATE(WEBCAM_PREVIEW))
{
webcam_send_usb_still_capture_req(NULL);
}
else
{
webcam_set_result(MED_RES_BUSY);
WEBCAM_SET_EVENT(WEBCAM_EVT_CAPTURE);
}
}
/*****************************************************************************
* FUNCTION
* webcam_capture_cnf_hdlr
* DESCRIPTION
* This function is to handle the video capture confirm from USB task.
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void webcam_capture_cnf_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
usbvideo_result_struct *msg_p;
/*----------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -