⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webcam_msg_handler.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*******************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2003
*
*******************************************************************************/

/*******************************************************************************
 * Filename:
 * ---------
 *   webcam_msg_handler.c
 *
 * Project:
 * --------
 *   Maui
 *
 * Description:
 * ------------
 *   This file includes message handle functions of webcam module.
 *
 * Author:
 * -------
 * -------
 *
 *==============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
 *------------------------------------------------------------------------------
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
 *==============================================================================
 *******************************************************************************/
#ifndef MED_NOT_PRESENT

/*==== INCLUDES =========*/
/* system includes */
#include "kal_release.h"
#include "kal_trace.h"
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h" /* Task message communiction */
#include "syscomp_config.h"
#include "task_config.h"        /* Task creation */
#include "app_buff_alloc.h"     /* Declaration of buffer management API */
#include "stacklib.h"   /* Basic type for dll, evshed, stacktimer */
#include "event_shed.h" /* Event scheduler */
#include "stack_timer.h"        /* Stack timer */

/* global includes */
#include "l1audio.h"
#include "device.h"
#include "resource_audio.h"
#include "nvram_enums.h"
#include "nvram_struct.h"
#include "nvram_user_defs.h"
#include "nvram_data_items.h"
#include "custom_nvram_editor_data_item.h"

/* local includes */
#include "med_global.h"
#include "med_main.h"
#include "aud_defs.h"
#include "med_struct.h"
#include "med_api.h"
#include "med_context.h"
#include "med_utility.h"
#include "med_smalloc.h"
#include "fat_fs.h"

#ifdef __WEBCAM_TRACE_ON__
#include "med_trc.h"
#endif 

#ifdef __MED_WEBCAM_MOD__
#include "cam_main.h"
#include "usbvideo_if.h"
#include "webcam_main.h"
#include "usbvideo_cam_if.h"

#define WEBCAM_FREE_INT_MEM()       if (webcam_context_p->intmem_start_address)  \
                                             med_free_int_mem((void**)&webcam_context_p->intmem_start_address)

#define WEBCAM_FREE_USB_BUFFER()       if (webcam_context_p->buffer_addr)  \
                                             med_free_ext_mem((void**)&webcam_context_p->buffer_addr)

#if MT6219_SERIES
kal_int32 webcam_preview_mem[2] = {51200, 0};
kal_int32 webcam_capture_mem[2] = {122880, 0};
#else /* MT6219_SERIES */ 
kal_int32 webcam_preview_mem[2] = {45056, 0};
kal_int32 webcam_capture_mem[2] = {104448, 0};
#endif /* MT6219_SERIES */ 

extern kal_uint8 cam_rotate_map[CAM_NO_OF_IMAGE_ROTATE];

usbvideo_camera_process_struct usbvideo_param;

/*==== FUNCTIONS ===========*/


/*****************************************************************************
 * FUNCTION
 *  webcam_start_req_hdlr
 * DESCRIPTION
 *  This function is to start webcam preview and transmit the image to USB.
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void webcam_start_req_hdlr(ilm_struct *ilm_ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    media_webcam_start_req_struct *req_p;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    req_p = (media_webcam_start_req_struct*) ilm_ptr->local_para_ptr;

    webcam_context_p->src_mod = ilm_ptr->src_mod_id;
    webcam_context_p->seq_num = req_p->seq_num;

    if (WEBCAM_IN_STATE(WEBCAM_IDLE))
    {
        usbvideo_video_req_struct start;
        webcam_context_p->banding = req_p->banding;
        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_start_video_req((void*)&start);
            WEBCAM_ENTER_STATE(WEBCAM_START_PREVIEW);
            webcam_set_result(MED_RES_OK);
            WEBCAM_SET_EVENT(WEBCAM_EVT_START);

        }
        else
        {
            webcam_set_result(MED_RES_MEM_INSUFFICIENT);
            WEBCAM_SET_EVENT(WEBCAM_EVT_START);
        }

    }
    else
    {
        webcam_set_result(MED_RES_BUSY);
        WEBCAM_SET_EVENT(WEBCAM_EVT_START);
    }

}


/*****************************************************************************
 * FUNCTION
 *  webcam_start_cnf_hdlr
 * DESCRIPTION
 *  This function is to handle the video start confirm from USB task.
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void webcam_start_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_send_start_cnf(MED_RES_OK);
            WEBCAM_ENTER_STATE(WEBCAM_PREVIEW);
        }
        else
        {
            webcam_send_start_cnf(MED_RES_FAIL);
            WEBCAM_FREE_USB_BUFFER();
            WEBCAM_ENTER_STATE(WEBCAM_IDLE);
        }
    }

}


/*****************************************************************************
 * FUNCTION
 *  webcam_stop_req_hdlr
 * DESCRIPTION
 *  This function is to stop tv output.
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void webcam_stop_req_hdlr(ilm_struct *ilm_ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    media_webcam_stop_req_struct *req_p;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    req_p = (media_webcam_stop_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_stop_video_req(NULL);
        WEBCAM_ENTER_STATE(WEBCAM_STOPPING);

    }
    else if (WEBCAM_IN_STATE(WEBCAM_PREVIEW))
    {
        exit_usbvideo_camera_preview();
        usbvideo_camera_power_off();
        WEBCAM_FREE_INT_MEM();
        webcam_send_usb_stop_video_req(NULL);
        WEBCAM_ENTER_STATE(WEBCAM_STOPPING);

    }
    else if (WEBCAM_IN_STATE(WEBCAM_CAPTURE))
    {
        exit_usbvideo_camera_capture();
        usbvideo_camera_power_off();
        WEBCAM_FREE_INT_MEM();
        webcam_send_usb_stop_video_req(NULL);
        WEBCAM_ENTER_STATE(WEBCAM_STOPPING);
    }
    else if (WEBCAM_IN_STATE(WEBCAM_PAUSED))
    {
        webcam_send_usb_stop_video_req(NULL);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -