/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/

/*----------------------------------------------------------------------------*/
/*! @file x_sm_video_hdlr.h 
 *  $RCSfile: $
 *  $Revision: #1 $
 *  $Date: 2015/05/29 $
 *  $Author: brianpc.huang $
 *  
 *  @par Description:
 *         This header file contains MPEG Video Stream handler specific 
 *         definitions, which are exported.
 */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*! @defgroup groupMW_STRM_MNGR_VIDEO_HDLR Video Handler
 *
 *  @ingroup groupMW_STRM_MNGR
 *  @brief Provides video stream external function .
 *
 *  %MW Application API would be used by TV Application, lot of these APIs would
 *   be wrapped from Exported API
 *
 *  @see groupMW_STRM_MNGR
 *  @{ 
 */
/*----------------------------------------------------------------------------*/
#ifndef _X_SM_VIDEO_HDLR_H_
#define _X_SM_VIDEO_HDLR_H_

/*-----------------------------------------------------------------------------
                    include files
-----------------------------------------------------------------------------*/
#include "u_sm_event.h"
#include "u_sm_video_hdlr.h"

/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
-----------------------------------------------------------------------------*/

#define SM_EVN_VS_GRP_SIZE  ((SM_EVN_TYPE_T) 0x00010000)

#define SM_EVN_VS_GRP_APP   ((SM_EVN_TYPE_T) SM_EVN_GRP_VS + SM_EVN_VS_GRP_SIZE*0 )
#define SM_EVN_VS_GRP_DEC   ((SM_EVN_TYPE_T) SM_EVN_GRP_VS + SM_EVN_VS_GRP_SIZE*1 )
#define SM_EVN_VS_GRP_VP    ((SM_EVN_TYPE_T) SM_EVN_GRP_VS + SM_EVN_VS_GRP_SIZE*2 )
#define SM_EVN_VS_GRP_PMX   ((SM_EVN_TYPE_T) SM_EVN_GRP_VS + SM_EVN_VS_GRP_SIZE*3 )
#define SM_EVN_VS_GRP_TVE   ((SM_EVN_TYPE_T) SM_EVN_GRP_VS + SM_EVN_VS_GRP_SIZE*4 )
#define SM_EVN_VS_GRP_PM    ((SM_EVN_TYPE_T) SM_EVN_GRP_VS + SM_EVN_VS_GRP_SIZE*5 )

#define SM_EVN_CODE_DRV_OPENED       ((SM_EVN_TYPE_T) 0)
#define SM_EVN_CODE_DRV_CLOSED       ((SM_EVN_TYPE_T) 1)
#define SM_EVN_CODE_DRV_CONNECTED    ((SM_EVN_TYPE_T) 2)
#define SM_EVN_CODE_DRV_DISCONNECTED ((SM_EVN_TYPE_T) 3)
#define SM_EVN_CODE_DRV_PLAYED       ((SM_EVN_TYPE_T) 4)
#define SM_EVN_CODE_DRV_STOPPED      ((SM_EVN_TYPE_T) 5)

#define SM_MAKE_DRV_EVN( grp, code ) ((SM_EVN_TYPE_T) grp + code )

#define SM_EVN_VS_DEC_OPENED         SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_DEC, SM_EVN_CODE_DRV_OPENED )
#define SM_EVN_VS_DEC_CLOSED         SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_DEC, SM_EVN_CODE_DRV_CLOSED )
#define SM_EVN_VS_DEC_CONNECTED      SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_DEC, SM_EVN_CODE_DRV_CONNECTED )
#define SM_EVN_VS_DEC_DISCONNECTED   SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_DEC, SM_EVN_CODE_DRV_DISCONNECTED )
#define SM_EVN_VS_DEC_PLAYED         SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_DEC, SM_EVN_CODE_DRV_PLAYED )
#define SM_EVN_VS_DEC_STOPPED        SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_DEC, SM_EVN_CODE_DRV_STOPPED )

#define SM_EVN_VS_VP_OPENED          SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_VP, SM_EVN_CODE_DRV_OPENED )
#define SM_EVN_VS_VP_CLOSED          SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_VP, SM_EVN_CODE_DRV_CLOSED )
#define SM_EVN_VS_VP_CONNECTED       SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_VP, SM_EVN_CODE_DRV_CONNECTED )
#define SM_EVN_VS_VP_DISCONNECTED    SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_VP, SM_EVN_CODE_DRV_DISCONNECTED )
#define SM_EVN_VS_VP_PLAYED          SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_VP, SM_EVN_CODE_DRV_PLAYED )
#define SM_EVN_VS_VP_STOPPED         SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_VP, SM_EVN_CODE_DRV_STOPPED )

#define SM_EVN_VS_PMX_OPENED         SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_PMX, SM_EVN_CODE_DRV_OPENED )
#define SM_EVN_VS_PMX_CLOSED         SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_PMX, SM_EVN_CODE_DRV_CLOSED )
#define SM_EVN_VS_PMX_CONNECTED      SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_PMX, SM_EVN_CODE_DRV_CONNECTED )
#define SM_EVN_VS_PMX_DISCONNECTED   SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_PMX, SM_EVN_CODE_DRV_DISCONNECTED )
#define SM_EVN_VS_PMX_PLAYED         SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_PMX, SM_EVN_CODE_DRV_PLAYED )
#define SM_EVN_VS_PMX_STOPPED        SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_PMX, SM_EVN_CODE_DRV_STOPPED )

#define SM_EVN_VS_TVE_OPENED         SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_TVE, SM_EVN_CODE_DRV_OPENED )
#define SM_EVN_VS_TVE_CLOSED         SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_TVE, SM_EVN_CODE_DRV_CLOSED )
#define SM_EVN_VS_TVE_CONNECTED      SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_TVE, SM_EVN_CODE_DRV_CONNECTED )
#define SM_EVN_VS_TVE_DISCONNECTED   SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_TVE, SM_EVN_CODE_DRV_DISCONNECTED )
#define SM_EVN_VS_TVE_PLAYED         SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_TVE, SM_EVN_CODE_DRV_PLAYED )
#define SM_EVN_VS_TVE_STOPPED        SM_MAKE_DRV_EVN( SM_EVN_VS_GRP_TVE, SM_EVN_CODE_DRV_STOPPED )

#define SM_EVN_VS_PM_COND_CLOSED     ((SM_EVN_TYPE_T) SM_EVN_VS_GRP_PM + 0)
#define SM_EVN_VS_PM_COND_PLAYED     ((SM_EVN_TYPE_T) SM_EVN_VS_GRP_PM + 1)
#define SM_EVN_VS_PM_COND_STOPPED    ((SM_EVN_TYPE_T) SM_EVN_VS_GRP_PM + 2)

typedef UINT32  VSH_VBI_PSR_ID_T;    /**<  define vbi parse id  */

/*------------------------------------------------------------------*/
/*! @brief
 *  @param [in]
 *  @param [out]
 *  @note
 *  @see
 *  @return
 *  @retval      -
 */
/*------------------------------------------------------------------*/
typedef BOOL (*x_sm_vsh_vbi_psr_open_fct)(
    HANDLE_T            h_vs,
    VSH_VBI_PSR_ID_T*   pt_vbi_psr_id );

/*------------------------------------------------------------------*/
/*! @brief
 *  @param [in]
 *  @param [out]
 *  @note
 *  @see
 *  @return
 *  @retval      -
 */
/*------------------------------------------------------------------*/
typedef BOOL (*x_sm_vsh_vbi_parse_fct)(
    VSH_VBI_PSR_ID_T    t_vbi_psr_id,
    UINT8*              pui1_vbi_data,
    SIZE_T              z_vbi_data,
    VOID*               pv_tag );

/*------------------------------------------------------------------*/
/*! @brief
 *  @param [in]
 *  @param [out]
 *  @note
 *  @see
 *  @return
 *  @retval      -
 */
/*------------------------------------------------------------------*/
typedef BOOL (*x_sm_vsh_vbi_get_fct)(
    VSH_VBI_PSR_ID_T    t_vbi_psr_id,
    VOID*               pv_vbi_data,
    SIZE_T*             pz_vbi_data_size );

/*------------------------------------------------------------------*/
/*! @brief
 *  @param [in]
 *  @param [out]
 *  @note
 *  @see
 *  @return
 *  @retval      -
 */
/*------------------------------------------------------------------*/
typedef BOOL (*x_sm_vsh_vbi_psr_close_fct)(
    VSH_VBI_PSR_ID_T    t_vbi_psr_id );

/*-----------------------------------------------------------------------------
                    functions declarations
-----------------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/*! @brief  Register  vbi releated function.
 *  @param [in] e_vbi_type  -vbi type
 *  @param [in] pf_vbi_open  -open function
 *  @param [in] pf_vbi_parse  -parse function
 *  @param [in] pf_vbi_get  -get function
 *  @param [in] pf_vbi_close  -close function
 *  @param [out]
 *  @note
 *  @see
 *  @return  INT32
 *  @retval   SMR_OK  - success.
 *                 SMR_INV_ARG, SMR_ALREADY_INIT - fail.
 */
/*------------------------------------------------------------------*/
extern INT32 x_sm_video_hdlr_reg_vbi_psr(
    SM_VSH_VBI_TYPE_T           e_vbi_type,
    x_sm_vsh_vbi_psr_open_fct   pf_vbi_open,
    x_sm_vsh_vbi_parse_fct      pf_vbi_parse,
    x_sm_vsh_vbi_get_fct        pf_vbi_get,
    x_sm_vsh_vbi_psr_close_fct  pf_vbi_close );

/*------------------------------------------------------------------*/
/*! @brief Notify vbi data.
 *  @param [in] h_vs   - video stream handle.
 *  @param [in] t_vbi_psr_id   - vbi parse id.
 *  @param [in] pv_vbi_data   - vbi data.
 *  @param [in] z_vbi_data_size   - the size of vbi data.
 *  @param [out]
 *  @note
 *  @see
 *  @return  VOID
 *  @retval  -
 */
/*------------------------------------------------------------------*/
extern VOID x_sm_video_hdlr_nfy_vbi_data(
    HANDLE_T                    h_vs,
    VSH_VBI_PSR_ID_T            t_vbi_psr_id,
    VOID*                       pv_vbi_data,
    SIZE_T                      z_vbi_data_size );

#endif /* _X_SM_VIDEO_HDLR_H_ */
/*----------------------------------------------------------------------------*/
/*! @} */   /* end of groupMW_STRM_MNGR_VIDEO_HDLR */
/*----------------------------------------------------------------------------*/

