/* 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 u_evctx_isdb_eng.h 
 *  $RCSfile: $
 *  $Revision: #1 $
 *  $Date: 2015/11/10 $
 *  $Author: dtvbm11 $
 *
 *  @par Description:
 *         This header file contains exported definitions and delcarations of
 *         Event Context ISDB engine.
 */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*! @defgroup groupMW_EVCTX_EVCTX_ISDB_ENG EVCTX ISDB Engine
 *  @ingroup groupMW_EVCTX
 *  @brief Provides events operate function for ISDB
 *  %This module is Event Context ISDB instance.
 *  @see groupMW_EVCTX
 *  @{ 
 */
/*----------------------------------------------------------------------------*/ 
#ifndef _U_EVCTX_ISDB_ENG_H_
#define _U_EVCTX_ISDB_ENG_H_

/*-----------------------------------------------------------------------------
                    include files
 ----------------------------------------------------------------------------*/
#include "u_common.h"
 

/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
 ----------------------------------------------------------------------------*/
typedef UINT32      EVCTX_ISDB_CONFIG_T;    /**< EVCTX DVB Engine config type       */

#define EVCTX_ISDB_CONFIG_PARSE_EXTEND_ITEMS                         (MAKE_BIT_MASK_32(0))    /**< Config of parse extended event items*/
#define EVCTX_ISDB_CONFIG_USE_MAX_EVENT_NAME                         (MAKE_BIT_MASK_32(1))    /**< Config of use max length retrive content*/
#define EVCTX_ISDB_CONFIG_NO_FAKE_AVAIL                              (MAKE_BIT_MASK_32(2))    /**< Config of no fake avail*/


/*------------------------------------------------------------------*/
/*! @enum EVCTX_ISDB_KEY_TYPE_T
 *  @brief key type struture
 *  @code
 *  typedef enum _EVCTX_ISDB_KEY_TYPE_T
 *  {
 *      EVCTX_ISDB_KEY_TYPE_UNKNOWN = 0,
 *      EVCTX_ISDB_KEY_TYPE_TOTAL_AVAIL_TIME,   
 *      EVCTX_ISDB_KEY_TYPE_TOTAL_NUMBER
 *  } EVCTX_ISDB_KEY_TYPE_T;
 *  @endcode
 *  @li@c  EVCTX_ISDB_KEY_TYPE_UNKNOWN                        - unknow key type
 *  @li@c  EVCTX_ISDB_KEY_TYPE_TOTAL_AVAIL_TIME               - key type for total available time
 *  @li@c  EVCTX_ISDB_KEY_TYPE_TOTAL_NUMBER                   - key type for totla number
 */
/*------------------------------------------------------------------*/
typedef enum _EVCTX_ISDB_KEY_TYPE_T
{
    EVCTX_ISDB_KEY_TYPE_UNKNOWN = 0,
    EVCTX_ISDB_KEY_TYPE_TOTAL_AVAIL_TIME,   /* UINT16 type. In hours. */
    EVCTX_ISDB_KEY_TYPE_TOTAL_NUMBER
} EVCTX_ISDB_KEY_TYPE_T;


/*------------------------------------------------------------------*/
/*! @struct EVCTX_ISDB_KEY_INFO_T
 *  @brief key info struture
 *  @code
 *  typedef struct _EVCTX_ISDB_KEY_INFO_T
 *  {
 *      EVCTX_ISDB_KEY_TYPE_T    e_isdb_key_type;
 *      VOID*                   pv_isdb_key_info;
 *  } EVCTX_ISDB_KEY_INFO_T;
 *  @endcode
 *  @li@c  e_isdb_key_type                                    - reference EVCTX_ISDB_KEY_TYPE_T
 *  @li@c  pv_isdb_key_info                                   - key information
 */
/*------------------------------------------------------------------*/
typedef struct _EVCTX_ISDB_KEY_INFO_T
{
    EVCTX_ISDB_KEY_TYPE_T    e_isdb_key_type;
    VOID*                   pv_isdb_key_info;
} EVCTX_ISDB_KEY_INFO_T;


/*------------------------------------------------------------------*/
/*! @struct EVCTX_ISDB_RATING_T
 *  @brief ISDB rating structure
 *  @code
 *  typedef struct _EVCTX_ISDB_RATING_T
 *  {
 *      UINT16      ui2_dimension;
 *      UINT16      ui2_rating_value;
 *  } EVCTX_ISDB_RATING_T;
 *  @endcode
 *  @li@c  ui2_dimension                                     - ratine dimension 
 *  @li@c  ui2_rating_value                                  - rating value
 */
/*------------------------------------------------------------------*/
typedef struct _EVCTX_ISDB_RATING_T
{
    UINT16      ui2_dimension;
    UINT16      ui2_rating_value;
} EVCTX_ISDB_RATING_T;

/*
*            ui2_rating_region           <---
*            ui2_rated_dimensions            |
*     ------ ps_rating_description           | sizeof(EVCTX_DVB_RATING_LIST_T)
*    |  ---- pt_ratings                      |
*    |  |    pt_next -> NULL (for compatible with generic rating structure)
*    |  |                                    |
*    |  -----> pt_ratings[0]                 |
*     -----> "GBR"                       <---  (ISO_3166_COUNT_LEN)
*/

    
/*------------------------------------------------------------------*/
/*! @struct EVCTX_ISDB_RATING_LIST_T
 *  
 *    @brief
 *         The field ui2_rated_dimensions is used to backward compatible with 
 *    EVCTX_ATSC_RATING_LIST_T, but always set to 1.
 *    
 *    The following is an illustration of the layout, which a real instance
 *    of EVCTX_ISDB_RATING_LIST_T may be.
 *        
 *    Arrows in the right side shows how to calculate the total size of
 *    an instance of EVCTX_ISDB_RATING_LIST_T data.
 *    
 *  @code
 *  typedef struct _EVCTX_ISDB_RATING_LIST_T
 *  {
 *      UINT16                  ui2_rating_region;
 *      UINT16                  ui2_rated_dimensions;
 *      CHAR*                   ps_country_code;
 *      EVCTX_ISDB_RATING_T*     pt_ratings;
 *      struct _EVCTX_ISDB_RATING_LIST_T*  pt_next;
 *      EVCTX_ISDB_RATING_T      t_rating;
 *      ISO_3166_COUNT_T        t_country_code;
 *  } EVCTX_ISDB_RATING_LIST_T;
 *  @endcode
 *  @li@c  ui2_rating_region                                 - ratine region
 *  @li@c  ui2_rated_dimensions                              - ratine dimensions
 *  @li@c  ps_country_code                                   - country code
 *  @li@c  pt_ratings                                        - ratings 
 *  @li@c  pt_next                                           - point to next
 *  @li@c  t_rating                                          - structure of EVCTX_ISDB_RATING_T
 *  @li@c  t_country_code                                    - structure of ISO_3166_COUNT_T
*/
/*------------------------------------------------------------------*/
typedef struct _EVCTX_ISDB_RATING_LIST_T
{
    UINT16                  ui2_rating_region;
    UINT16                  ui2_rated_dimensions;
    CHAR*                   ps_country_code;
    EVCTX_ISDB_RATING_T*     pt_ratings;

    struct _EVCTX_ISDB_RATING_LIST_T*  pt_next;

    EVCTX_ISDB_RATING_T      t_rating;
    ISO_3166_COUNT_T        t_country_code;
} EVCTX_ISDB_RATING_LIST_T;


/*------------------------------------------------------------------*/
/*! @struct EVCTX_ISDB_TIME_SHIFTED_EVT_T
 *  @brief for time shift used
 *  @code
 *  typedef struct _EVCTX_ISDB_TIME_SHIFTED_EVT_T
 *  {
 *      UINT16                  ui2_ref_svc_id;
 *      UINT16                  ui2_ref_evt_id;
 *  } EVCTX_ISDB_TIME_SHIFTED_EVT_T;
 *  @endcode
 *  @li@c  ui2_ref_svc_id                                    - reference service id
 *  @li@c  ui2_ref_evt_id                                    - reference event id
 */
/*------------------------------------------------------------------*/
typedef struct _EVCTX_ISDB_TIME_SHIFTED_EVT_T
{
    UINT16                  ui2_ref_svc_id;
    UINT16                  ui2_ref_evt_id;
} EVCTX_ISDB_TIME_SHIFTED_EVT_T;

#endif /* _U_EVCTX_ISDB_ENG_H_ */

/*----------------------------------------------------------------------------*/
/*! @} */                                 /* end of groupMW_CONN_MNGR_BRDCST */
/*----------------------------------------------------------------------------*/

