/* 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 c_mheg5.h 
 *  $RCSfile: $
 *  $Revision: #3 $
 *  $Date: 2015/08/19 $
 *  $Author: cancan.zhang $
 *  
 *  @par Description: This header file declares MHEG5 exported APIs.
 */
/*----------------------------------------------------------------------------*/
#ifndef _C_MHEG5_H_
#define _C_MHEG5_H_
/*-----------------------------------------------------------------------------
                    include files
-----------------------------------------------------------------------------*/
#include "u_common.h"
#include "u_mheg5.h"
#include "u_scc.h"
#include "u_wgl.h"

/*!
 * @defgroup    groupMW_MHEG5 MHEG5
 * @ingroup     groupMW
 * @brief    This header file declares MHEG5 exported APIs.
 * 
 * @see groupMW
 *
 * @{
 * */

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

/*-----------------------------------------------------------------------------
                    functions declarations
-----------------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/*! @brief  Freeze video display.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal MHEG5 component error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_adjust_freeze_mode(UINT32 ui4_eng_code);

/*------------------------------------------------------------------*/
/*! @brief  Insert MHEG5 main UI frame before/after the reference widget along the z-axis.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in]  h_ref_widget    -   Handle of the reference widget.
 *  @param [in]  e_insert        -   Indicates the insert mode.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_adjust_order(
    UINT32                      ui4_eng_code,
    HANDLE_T                    h_ref_widget,
    WGL_INSERT_MODE_T           e_insert);

/*------------------------------------------------------------------*/
/*! @brief  Re-evaluate the audio and video when service changed.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_evaluate_stream(UINT32 ui4_eng_code);

/*------------------------------------------------------------------*/
/*! @brief Calculate the source region and display region.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in]  ui1_afd    -   Indicates current AFD value.
 *  @param [in]  e_src_aspect_ratio    -   Indicates the aspect ratio of the source.
 *  @param [out] pt_src_region  -   Source region calculated.
 *  @param [out] pt_dst_region  -   Destination display region calculated.
 *  @return Return the error code.
 *  @retval     MHEG5R_OK               -   Success.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_get_display_adjustment(
    UINT32                      ui4_eng_code,
    VSH_REGION_INFO_T*          pt_src_region, 
    VSH_REGION_INFO_T*          pt_dst_region,
    UINT8                       ui1_afd,
    MHEG5_ASPECT_RATIO_T        e_src_aspect_ratio);

/*------------------------------------------------------------------*/
/*! @brief  Retrieve the engine code of specific engine.
 *  @param [in]  ps_eng_name     -   Specific engine name.
 *  @param [out] pui4_eng_code   -   Pointer to retrieved engine code.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INV_STATE        -   MHEG5 MW module is not inited.
 *  @retval MHEG5R_INV_ARG          -   ps_eng_name or pui4_eng_code is NULL.
 *  @retval MHEG5R_ENG_NOT_FOUND    -   Not found the specific engine.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_get_eng_code(
    const CHAR* ps_eng_name,
    UINT32*     pui4_eng_code);

/*------------------------------------------------------------------*/
/*! @brief  Get the auto screen mode.
 *  @param [in] None.
 *  @param [out] None.
 *  @return Screen mode Retrieved.
 *  @retval      - Screent mode retrieved.
 */
/*------------------------------------------------------------------*/
extern SCC_VID_SCREEN_MODE_T c_mheg5_get_screen_auto_mode_enum(VOID);

/*------------------------------------------------------------------*/
/*! @brief  Initialise OSD for MHEG5 UI. 
 *  @param [in]  ui4_eng_code   -   Indicates special MHEG5 engine.
 *  @param [in]  h_mheg5_canvas -   mheg5's UI Canvas handle, used to create the main frame.
 *  @param [in]  h_sbtl_canvas  -   subtitle's Canvas handle, used to control subtitle's visibilaty by MHEG5 engine.
 *  @param [in]  h_palette      -   Palette handle, could be NULL_HANDLE.
 *  @param [in]  pt_color_key   -   Background color.
 *  @param [in]  pf_state_nfy   -   Callback user to notify key event and render status.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_init_osd(
    UINT32                      ui4_eng_code,
    HANDLE_T                    h_mheg5_canvas,
    HANDLE_T                    h_sbtl_canvas,
    GL_HPALETTE_T               h_palette,
    const GL_COLOR_T*           pt_color_key);


extern INT32 c_mheg5_reg_eng_state_nfy(
    UINT32                      ui4_eng_code,
    x_mheg5_eng_state_nfy_fct   pf_state_nfy,
    VOID*                       pv_tag);

/*------------------------------------------------------------------*/
/*! @brief  Load SI table.
 *  @param [in] ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in] h_svctx         -   SVCTX handle.
 *  @param [in] ui2_svl_id      -   SVL ID.
 *  @param [in] ui2_svl_rec_id  -   SVL record ID.
 *  @param [in] pf_load_nfy     -   Callback user to notify the status of loading SI table.
 *  @param [in] pv_tag          -   Return to user when callback.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_load_si(
    UINT32                      ui4_eng_code,
    HANDLE_T                    h_svctx,
    UINT16                      ui2_svl_id,
    UINT16                      ui2_svl_rec_id,
    x_mheg5_eng_load_nfy_fct    pf_load_nfy,
    VOID*                       pv_tag);

/*------------------------------------------------------------------*/
/*! @brief  Pause MW MHEG5 engine service
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_pause_service(UINT32 ui4_eng_code);

/*------------------------------------------------------------------*/
/*! @brief Query the PID and PCR's PID of the audio/video stream
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in] pt_strm_desc    -   Stream descriptor to be queried.
 *  @param [in] pf_resolve_nfy   -   The async call back to inform the PID/PCR's PID queried.
 *  @param [in] pv_tag              -   Caller's tag, which will returned in the callback.
 *  @param [out] pt_pid            -    The PID queried.
 *  @param [out] pt_pcr_pid      -    The PCR's PID queried.
 *  @note This function could be synchronous or asynchronous, which could be indicated by 
 *             the return value.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR               -   Internal error.
 *  @retval MHEG5R_ASYNC_RESPONSE   -   The result will be notified in asynchronous callback.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_resolve(
    UINT32                  ui4_eng_code,
    MHEG5_STREAM_DESC_T*    pt_strm_desc,
    x_mheg5_resolve_nfy     pf_resolve_nfy,
    VOID*                   pv_tag,
    STREAM_PID_INFO_T*      pt_pid_info);

/*------------------------------------------------------------------*/
/*! @brief  Resume MW MHEG5 engine service
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_resume_service(UINT32 ui4_eng_code);

/*------------------------------------------------------------------*/
/*! @brief  Adjust the OSD region and position.
 *  @param [in]  ui4_eng_code   -   Indicates special MHEG5 engine.
 *  @param [in]  e_decfc         -   Indicates the decfc value.
 *  @param [in]  e_wss      -   Indicates the wss value.
 *  @param [in]  e_display_ar      -   Indicates the display aspect ratio.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_adjust_osd(
    UINT32                          ui4_eng_code,
    MHEG5_DECFC_T                   e_decfc,
    MHEG5_WSS_T                     e_wss,
    MHEG5_DISPLAY_ASPECT_RATIO_T    e_display_ar);


/*------------------------------------------------------------------*/
/*! @brief  Set GUI language.
 *  @param [in]  ui4_eng_code   -   Indicates special MHEG5 engine.
 *  @param [in]  s639_lang      -   Specific language.
 *  @param [out] None
 *  @return Return the error code.
 *  @retval MHEG5R_OK           -   Success.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_set_gui_lang(
    UINT32          ui4_eng_code,
    ISO_639_LANG_T  s639_lang);

/*------------------------------------------------------------------*/
/*! @brief  Set default audio language.
 *  @param [in]  ui4_eng_code   -   Indicates special MHEG5 engine.
 *  @param [in]  s639_lang      -   Specific language.
 *  @param [out] None
 *  @return Return the error code.
 *  @retval MHEG5R_OK           -   Success.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_set_default_lang(
    UINT32          ui4_eng_code,
    ISO_639_LANG_T  s639_lang);

/*------------------------------------------------------------------*/
/*! @brief  Set the auto screen mode.
 *  @param [in] e_auto_mode -   Screen mode to be set.
 *  @param [out] None.
 *  @return VOID.
 */
/*------------------------------------------------------------------*/
extern VOID c_mheg5_set_screen_auto_mode_enum(SCC_VID_SCREEN_MODE_T e_auto_mode);

/*------------------------------------------------------------------*/
/*! @brief  Show MHEG5 UI.
 *  @param [in]  ui4_eng_code   -   Indicates special MHEG5 engine.
 *  @param [in]  e_display         -   MHEG5 UI display mode.
 *  @param [in]  b_get_focus    -   Indicates if try to get focus.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_show(
    UINT32                      ui4_eng_code,
    MHEG5_COEXIST_DISPLAY_T     e_display,
    BOOL                        b_get_focus);

/*------------------------------------------------------------------*/
/*! @brief  Start MW MHEG5 engine service
 *  @param [in] ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in] h_svctx         -   SVCTX handle.
 *  @param [in] ui2_svl_id      -   SVL ID.
 *  @param [in] ui2_svl_rec_id  -   SVL record ID.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_start_service(
    UINT32                      ui4_eng_code,
    HANDLE_T                    h_svctx,
    UINT16                      ui2_svl_id,
    UINT16                      ui2_svl_rec_id);

/*------------------------------------------------------------------*/
/*! @brief  Stop MW MHEG5 engine service
 *  @param [in] ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in] pt_param        -   Pointer to MHEG5_STOP_SVC_PARAM_T.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_stop_service(UINT32 ui4_eng_code, MHEG5_STOP_SVC_PARAM_T *pt_param);

/*------------------------------------------------------------------*/
/*! @brief This API is used to force the engine do nothing in some case.
 *  @param [in] b_force - A boolean value set to MW engine.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_strm_force_no_act(BOOL b_force);

/*------------------------------------------------------------------*/
/*! @brief  Free saved SI tables, and other related resources.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_unload_si(
    UINT32      ui4_eng_code);

/*------------------------------------------------------------------*/
/*! @brief  Set original screen mode.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in]  e_screen_mode   -   Screen mode to be set.
 *  @param [out] None.
 *  @note
 *  @see
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_update_screen_mode(
    UINT32                  ui4_eng_code,
    SCC_VID_SCREEN_MODE_T   e_screen_mode);

/*------------------------------------------------------------------*/
/*! @brief  Query if MHEG5 use internal screen mode.
 *  @param [in]  None.
 *  @param [out] None.
 *  @return A boolean value indicates if MHEG5 uses internal screen mode.
 *  @retval      -
 */
/*------------------------------------------------------------------*/
extern BOOL c_mheg5_with_internal_screen_mode(VOID);

/*------------------------------------------------------------------*/
/*! @brief  Query if MHEG5 is auto screen mode.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [out] None.
 *  @return A boolean value indicates if MHEG5 is auto screen mode.
 *  @retval      -
 */
/*------------------------------------------------------------------*/
extern BOOL c_mheg5_query_display_is_auto_mode(
    UINT32                          ui4_eng_code);

/*------------------------------------------------------------------*/
/*! @brief  Set user's default DVB locator
 *  @param [in] ui2_on_id   -   Original network ID
 *  @param [in] ui2_ts_id   -   Transport stream ID
 *  @param [in] ui2_svc_id  -   Service ID
 *  @param [out] None
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_set_dvb_locator(UINT16 ui2_on_id, UINT16 ui2_ts_id, UINT16 ui2_svc_id);

/*------------------------------------------------------------------*/
/*! @brief  Set video plane mode.
 *  @param [in] ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in] e_mode          -   Video plane mode to be set.
 *  @param [in] b_resume        -   Indicates if this API is called when resume service.
 *  @param [out]None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_set_vdp_mode(
    UINT32          ui4_eng_code,
    SCC_VID_MODE_T  e_mode,
    BOOL            b_resume);

/*------------------------------------------------------------------*/
/*! @brief This API is used to indicate the engine to reset video info.
 *  @param [in] ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [out]
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_set_video_info(
    UINT32          ui4_eng_code);

/*------------------------------------------------------------------*/
/*! @brief  Register video update notification funtion
 *  @param [in]  pf_func    -   Function to be registered.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_reg_video_update_nfy(
    UINT32                   ui4_eng_code,
    x_mheg5_video_update_nfy pf_nfy,
    VOID*                    pv_tag);

/*------------------------------------------------------------------*/
/*! @brief  Register subtitle visibility notification funtion
 *  @param [in]  pf_func    -   Function to be registered.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_reg_sbtl_visibility_nfy(
    UINT32                       ui4_eng_code,
    x_mheg5_sbtl_visibility_nfy  pf_nfy,
    VOID*                        pv_tag);


extern INT32 c_mheg5_set_subtitle_info(
    UINT32                 ui4_eng_code,
    MHEG5_SUBTITLE_CFG_T*  pt_cfg);

extern INT32 c_mheg5_set_comp_info(
    UINT32                 ui4_eng_code,
    MHEG5_COMP_INFO_T*     pt_info);

/*------------------------------------------------------------------*/
/*! @brief  Set MHEG5 UI visibility.
 *  @param [in]  ui4_eng_code   -   Indicates special MHEG5 engine.
 *  @param [in]  e_sw_cmd       -   Widget visibility flag.
 *  @param [out] None.
 *  @note
 *  @see
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_set_visibility(
    UINT32          ui4_eng_code,
    WGL_SW_CMD_T    e_sw_cmd);

/*------------------------------------------------------------------*/
/*! @brief Set the system default overscan to engine.
 *  @param [in] pt_clipper - The overscan clipper.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_set_default_overscan(SCC_VID_OVER_SCAN_CLIPPER_T *pt_clipper);

/*------------------------------------------------------------------*/
/*! @brief  Initialise MHEG-5 component instance.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in]  pt_setup        -   Pointer to a MHEG5 component instance setup structure.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INV_ARG          -   Invalid parameter.
 *  @retval MHEG5R_OUT_OF_MEMORY    -   Unable to allocate memory for MHEG5 component memory region.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal MHEG5 component error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_open(
    UINT32 ui4_eng_code,
    MHEG5_SETUP_T* pt_setup);


extern INT32 c_mheg5_reg_tune_method_update_nfy(
    UINT32                         ui4_eng_code,
    x_mheg5_tune_method_update_nfy pf_tune_method_update_nfy,
    VOID*                          pv_tag);

extern INT32 c_mheg5_reg_tune_svc_cb_fct(
    UINT32               ui4_eng_code,
    x_mheg5_tune_svc_fct pf_tune_svc_fct,
    VOID*                pv_tag);


/*------------------------------------------------------------------*/
/*! @brief  Free allocated MHEG5 component memory region, and any other related resources.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal MHEG5 component error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_close(
    UINT32 ui4_eng_code);

/*------------------------------------------------------------------*/
/*! @brief  Handle the user key press event.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in]  ui4_key_code    -   Pressed key code.
 *  @param [in]  b_process       -   Indicates whether send the key to engine if this key is
 *                                   included in current function group.
 *  @param [out] pb_in_func_grp  -   Indicates if the key is included in current function group.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INV_ARG          -   Invalid parameter.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal MHEG5 component error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_key_press(
    UINT32 ui4_eng_code,
    UINT32 ui4_key_code,
    BOOL*  pb_in_func_grp,
    BOOL   b_process);
    
/*------------------------------------------------------------------*/
/*! @brief  Start the MHEG5 component instance.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in]  pt_start_exec   -   Pointer to a MHEG5 component instance start structure.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INV_ARG          -   Invalid parameter.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal MHEG5 component error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_start_execution(
    UINT32 ui4_eng_code,
    MHEG5_START_EXEC_T* pt_start_exec);

/*------------------------------------------------------------------*/
/*! @brief  Stop the MHEG5 instance.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in]  pt_stop_exec    -   Pointer to a MHEG5 component instance stop structure.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INV_ARG          -   Invalid parameter.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal MHEG5 component error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_stop_execution(
    UINT32 ui4_eng_code,
    MHEG5_STOP_EXEC_T* pt_stop_exec);
    
/*------------------------------------------------------------------*/
/*! @brief  Pause or resume the MHEG5 engine instance.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in]  pt_pause_exec   -   Pointer to a MHEG5 component instance pause structure.
 *  @param [out] None.
 *  @note  The active state is specified in pt_pause_exec.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INV_ARG          -   Invalid parameter.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal MHEG5 component error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_pause_execution(
    UINT32 ui4_eng_code,
    MHEG5_PAUSE_EXEC_T* pt_pause_exec);

extern INT32 c_mheg5_query_current_mode(
    UINT32        ui4_eng_code,
    MHEG5_MODE_T* pt_mode);

extern INT32 c_mheg5_reg_select_stream_cb_fct(
    UINT32                          ui4_eng_code,
    x_mheg5_select_stream_fct       pf_select_stream_fct,
    VOID*                           pv_tag);


/*------------------------------------------------------------------*/
/*! @brief  Register the callback function for CI plus.
 *  @param [in]  pf_func   -   Callback function pointer.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INV_ARG          -   Invalid parameter.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal MHEG5 component error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_reg_ci_nfy(
    UINT32            ui4_eng_code,
    x_mheg5_ci_nfy    pf_func,
    VOID*             pv_tag);

/*------------------------------------------------------------------*/
/*! @brief  Register the callback function for engine.
 *  @param [in]  pf_func   -   Callback function pointer.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INV_ARG          -   Invalid parameter.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal MHEG5 component error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_reg_eng_nfy(
    UINT32            ui4_eng_code,
    x_mheg5_eng_nfy   pf_func,
    VOID*             pv_tag);

/*------------------------------------------------------------------*/
/*! @brief  Start a CI application.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in]  pt_start_ci_app   -  Parameters for starting special CI application.
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INV_ARG          -   Invalid parameter.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal MHEG5 component error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_start_ci_application(
    UINT32            ui4_eng_code,
    MHEG5_CI_START_APP_T* pt_start_ci_app);

/*------------------------------------------------------------------*/
/*! @brief  Stop the CI applications
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in]  pt_stop_ci_apps   -   Parameters for stopping special CI application.
 *  @param [out] None.
 *  @note  The active state is specified in pt_pause_exec.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INV_ARG          -   Invalid parameter.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal MHEG5 component error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_stop_ci_applications(
    UINT32            ui4_eng_code,
    MHEG5_CI_STOP_APPS_T*  pt_stop_ci_apps);

/*------------------------------------------------------------------*/
/*! @brief  Apply the supported MHEG5 profile.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in]  s3166_country   -   Country code.
 *  @param [in]  b_apply    -   Indicates if need to apply the profile if we have the 
 *                      supported profile for this country.
 *  @param [out] pe_profile_id - Return the supported profile.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INV_ARG          -   Invalid parameter.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal MHEG5 component error.
 */
/*------------------------------------------------------------------*/
extern INT32 c_mheg5_apply_supported_profile(
    UINT32              ui4_eng_code,
    ISO_3166_COUNT_T    s3166_country,
    MHEG5_PROFILE_ID_T* pe_profile_id,
    BOOL                b_apply);


/*------------------------------------------------------------------*/
/*! @brief  Initialise MHEG-5 component instance extension.
 *  @param [in]  ui4_eng_code    -   Indicates special MHEG5 engine.
 *  @param [in]  pt_setup        -   Pointer to a MHEG5 component instance setup structure.
 *  @param [in]  b_ics_enable     -   enable/disable MHEG5 ICS
 *  @param [out] None.
 *  @return Return the error code.
 *  @retval MHEG5R_OK               -   Success.
 *  @retval MHEG5R_INV_ARG          -   Invalid parameter.
 *  @retval MHEG5R_OUT_OF_MEMORY    -   Unable to allocate memory for MHEG5 component memory region.
 *  @retval MHEG5R_INTERNAL_ERROR   -   Internal MHEG5 component error.
 */
/*------------------------------------------------------------------*/

extern INT32 c_mheg5_open_ics(
    UINT32            ui4_eng_code,
    MHEG5_SETUP_T*    pt_setup,
    BOOL              b_ics_enable);

extern INT32 c_mheg5_set_ic_status(
    UINT32            ui4_eng_code,
    MHEG5_IC_STATE_T  e_new_ic_status);

extern INT32 c_mheg5_reg_ics_guid_visibility_nfy(
    UINT32                           ui4_eng_code,
    x_mheg5_ics_guid_visibility_nfy  pf_nfy,
    VOID*                            pv_tag);

extern INT32 c_mheg5_get_ics_guid_info_len(
    UINT32            ui4_eng_code,
    UINT32*           pui4_len);

extern INT32 c_mheg5_get_ics_guid_info(
    UINT32            ui4_eng_code,
    CHAR*             ps_str,
    UINT32*           pui4_len);

extern INT32 c_mheg5_set_ics_guid_result(
    UINT32          ui4_eng_code,
    BOOL            b_result);

extern INT32 c_mheg5_ics_get_proper_lang_info(
                    UINT32                       ui4_eng_code,
                    STREAM_TYPE_T                e_strm_type,
                    x_mheg5_ics_lang_filter      pf_filter,
                    VOID*                        pv_tag );

extern INT32 c_mheg5_reg_pin_support_cb_fct(
    UINT32                  ui4_eng_code,
    x_mheg5_pin_support_fct pf_pin_support_fct,
    VOID*                   pv_tag);

extern INT32 c_mheg5_notify_audio_desc_pref_changed(UINT32 ui4_eng_code);

extern INT32 c_mheg5_reg_audio_desc_cb_fct(
    UINT32               ui4_eng_code,
    x_mheg5_ad_fct       pf_ad_fct,
    VOID*                pv_tag);

extern INT32 c_mheg5_reg_ics_audio_lang_nfy(      
    UINT32                           ui4_eng_code,
    x_mheg5_ics_audio_lang_nfy       pf_ics_aud_lang_nfy,
    VOID*                            pv_tag);


extern INT32 c_mheg5_init_tps(
    const CHAR* ps_tps_dev
);

extern INT32 c_mheg5_clear_tps(VOID);


extern INT32 c_mheg5_reg_vid_info_update_nfy(
    UINT32                        ui4_eng_code,
    x_mheg5_vid_info_update_nfy   pf_func,
    VOID*                         pv_tag);

extern INT32 c_mheg5_get_vid_info(
        UINT32                  ui4_eng_code,
        MHEG5_VID_INFO_T*       pt_vid_info);

extern INT32 c_mheg5_reg_graphics_suppressed_nfy(
    UINT32                          ui4_eng_code,
    x_mheg5_graphics_suppressed_nfy pf_func,
    VOID*                           pv_tag);

extern INT32 c_mheg5_reg_set_key_input_mask_fun(
    UINT32                          ui4_eng_code,
    x_mheg5_set_key_input_mask      pf_func,
    VOID*                           pv_tag);

extern INT32 c_mheg5_reg_audio_switch_fun(
    UINT32                          ui4_eng_code,
    x_mheg5_audio_switch_fun        pf_func,
    VOID*                           pv_tag);
/*! @}  */
extern INT32 c_mheg5_reg_can_launch_hbbtv_nfy (
    UINT32                              ui4_eng_code,
    x_mheg5_can_lanuch_hbbtv_nfy_fct    pf_can_launch_hbbtv_nfy_fct,
    VOID*                               pv_tag );

extern INT32 c_mheg5_reg_launch_hbbtv_nfy (
    UINT32                              ui4_eng_code,
    x_mheg5_lanuch_hbbtv_nfy_fct        pf_launch_hbbtv_nfy_fct,
    VOID*                               pv_tag );

extern INT32 c_mheg5_reg_is_mime_type_support_fct (
    UINT32                              ui4_eng_code,
    x_mheg5_is_mime_type_support_fct    pf_is_mime_type_support_fct,
    VOID*                               pv_tag );

extern INT32 c_mheg5_set_hbbtv_status (
    UINT32                              ui4_eng_code,
    BOOL                                b_success);

#endif /* _C_MHEG5_H_ */

