/* 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_dsmcc_eng.h
 *  $RCSfile: $
 *  $Revision: #1 $
 *  $Date: 2015/05/29 $
 *  $Author: brianpc.huang $
 *
 *  @par Description:
 *         This header file contains DSM-CC engine specific definitions, which
 *         are exported.
 */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*! @defgroup groupMW_TBL_MNGR_DSMCC_ENG DSM-CC Engine
 *  @ingroup groupMW_TBL_MNGR
 *  @brief Provides DSM-CC related functions
 *  %This module allows an application to retrieve data from DSM-CC carousels
 *  @see groupMW_TBL_MNGR_DSMCC_DB, groupMW_TBL_MNGR_DSMCC_OC
 *  @{
 */
/*----------------------------------------------------------------------------*/

#ifndef _U_DSMCC_ENG_H_
#define _U_DSMCC_ENG_H_

/*---------------------------------------------------------------------------
                    include files
---------------------------------------------------------------------------*/

#include "u_handle_grp.h"
#include "u_common.h"
#include "u_tm.h"

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

/* Default DSMCC engine name. */
#define DSMCC_DEFAULT_NAME  "dsmcc_engine"    /**< Default DSM-CC engine name */

/* invalid PTS */
#define DSMCC_INVALID_PTS ((PTS_T) (0xffffffffffffffffLL))    /**< DSM-CC invalid TPS define */

/* DSMCC engine handle types. */
#define TMT_DSMCC_DSI      (TMT_DSMCC + ((HANDLE_TYPE_T)  0))    /**< DSM-CC DSI handle type       */
#define TMT_DSMCC_DII      (TMT_DSMCC + ((HANDLE_TYPE_T)  1))    /**< DSM-CC DII handle type       */
#define TMT_DSMCC_DDB      (TMT_DSMCC + ((HANDLE_TYPE_T)  2))    /**< DSM-CC DDB handle type       */
#define TMT_DSMCC_TOP_MON  (TMT_DSMCC + ((HANDLE_TYPE_T)  3))    /**< DSM-CC Monitoring handle type*/
#define TMT_DSMCC_DESC     (TMT_DSMCC + ((HANDLE_TYPE_T)  4))    /**< DSM-CC Desc. handle type     */
#define TMT_DSMCC_DESC_MON (TMT_DSMCC + ((HANDLE_TYPE_T)  5))    /**< DSM-CC Desc. Monitoring handle type     */

/* DSMCC engine get types. */
#define DSMCC_GET_TYPE_DOWNLOAD_LEVEL   (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 0))    /**< To get download level         */
#define DSMCC_GET_TYPE_DSI_INFO         (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 1))    /**< To get DSI information        */
#define DSMCC_GET_TYPE_DII_INFO         (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 2))    /**< To get DII information        */
#define DSMCC_GET_TYPE_DII_MODULE_INFO  (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 3))    /**< To get DII module information */
#define DSMCC_GET_TYPE_DDB_INFO         (TM_GET_TYPE_LAST_ENTRY + ((TM_GET_TYPE_T) 4))    /**< To get DDB information        */

/* DSMCC engine load types. */
#define DSMCC_LOAD_TYPE_PID_TS_DESCR_IDS   (TM_LOAD_TYPE_LAST_ENTRY + ((TM_LOAD_TYPE_T) 0))    /**< Load by PID, TS descriptor and some other ID */
#define DSMCC_LOAD_TYPE_PID_TS_ID_IDS     ((TM_LOAD_TYPE_LAST_ENTRY + ((TM_LOAD_TYPE_T) 1)) | TM_LOAD_TYPE_SINGLE_SRC)    /**< Load by PID, TS ID and some other ID */
#define DSMCC_LOAD_TYPE_DII_IDS            (TM_LOAD_TYPE_LAST_ENTRY + ((TM_LOAD_TYPE_T) 2))    /**< Load DDB based on a DII information */
#define DSMCC_LOAD_TYPE_PID_TBL_EXT       ((TM_LOAD_TYPE_LAST_ENTRY + ((TM_LOAD_TYPE_T) 3)) | TM_LOAD_TYPE_SINGLE_SRC)

/* DSMCC engine parse types. */
#define DSMCC_PARSE_TYPE_DSI_PVT_DATA     (TM_PARSE_TYPE_LAST_ENTRY + ((TM_PARSE_TYPE_T) 0))    /**< Parse type for DSI private data */
#define DSMCC_PARSE_TYPE_DII_COMP_DESCR   (TM_PARSE_TYPE_LAST_ENTRY + ((TM_PARSE_TYPE_T) 1))    /**< Parse type for DII compatibility descriptor */
#define DSMCC_PARSE_TYPE_DII_MODULE_INFO  (TM_PARSE_TYPE_LAST_ENTRY + ((TM_PARSE_TYPE_T) 2))    /**< Parse type for DII module information */
#define DSMCC_PARSE_TYPE_DII_PVT_DATA     (TM_PARSE_TYPE_LAST_ENTRY + ((TM_PARSE_TYPE_T) 3))    /**< Parse type for DII private data */
#define DSMCC_PARSE_TYPE_DDB_BLOCK_DATA   (TM_PARSE_TYPE_LAST_ENTRY + ((TM_PARSE_TYPE_T) 4))    /**< Parse type for DDB block data */
#define DSMCC_PARSE_TYPE_DSMCC_DESC_ALL_DESCR (TM_PARSE_TYPE_LAST_ENTRY + ((TM_PARSE_TYPE_T) 5))    /**< Parse type for DSMCC Descriptor section's all descriptors */
#define DSMCC_PARSE_TYPE_DSMCC_DESC_DESCR     (TM_PARSE_TYPE_LAST_ENTRY + ((TM_PARSE_TYPE_T) 6))    /**< Parse type for DSMCC Descriptor section's descriptors */

/* DSMCC descriptor tag values */
#define DSMCC_DESC_TAG_NPT_REFERENCE_DESCRIPTOR  (0x17)    /**< NPT Reference descriptor tag */
#define DSMCC_DESC_TAG_STREAM_EVENT_DESCRIPTOR   (0x1A)    /**< Stream Event descriptor */

/* DSMCC engine monitor types. */
#define DSMCC_MON_TYPE_PID                     \
    (TM_MON_TYPE_LAST_ENTRY + (((TM_MON_TYPE_T)  0) | TM_MON_TYPE_SINGLE_SRC))    /**< Load type for PID       */

/* DSM-CC engine configuration structure */
/*------------------------------------------------------------------*/
/*! @struct DSMCC_CONFIG_T
 *  @brief  DSM-CC engine configuration structure
 *  @code
 *  typedef struct _DSMCC_CONFIG_T
 *  {
 *      UINT8 ui1_num_dsi_filters;
 *      UINT8 ui1_num_dii_filters;
 *      UINT8 ui1_num_ddb_filters;
 *      UINT8 ui1_num_ddl_filters;
 *      SIZE_T  z_dsi_buff_size;
 *      SIZE_T  z_dii_buff_size;
 *      SIZE_T  z_ddb_buff_size;
 *      SIZE_T  z_ddl_buff_size;
 *      UINT16  ui2_num_dsi_tbl_objs;
 *      UINT16  ui2_num_dii_tbl_objs;
 *      UINT16  ui2_num_ddb_tbl_objs;
 *      UINT16  ui2_num_ddl_tbl_objs;
 *      UINT16  ui2_num_mon_tbl_objs;
 *  }   DSMCC_CONFIG_T;
 *  @endcode
 *  @li@c  ui1_num_dsi_filters  - Number of DSI filters.
 *  @li@c  ui1_num_dii_filters  - Number of DII filters.
 *  @li@c  ui1_num_ddb_filters  - Number of DDB filters.
 *  @li@c  ui1_num_ddl_filters  - Number of download filters.
 *  @li@c  z_dsi_buff_size      - DSI buffer size.
 *  @li@c  z_dii_buff_size      - DII buffer size.
 *  @li@c  z_ddb_buff_size      - DDB buffer size.
 *  @li@c  z_ddl_buff_size      - Download buffer size.
 *  @li@c  ui2_num_dsi_tbl_objs - Number of DSI table objects.
 *  @li@c  ui2_num_dii_tbl_objs - Number of DII table objects.
 *  @li@c  ui2_num_ddb_tbl_objs - Number of DDB table objects.
 *  @li@c  ui2_num_ddl_tbl_objs - Number of download table objects.
 *  @li@c  ui2_num_mon_tbl_objs - Number of monitoring table objects.
 */
/*------------------------------------------------------------------*/
typedef struct _DSMCC_CONFIG_T
{
    UINT8 ui1_num_dsi_filters;
    UINT8 ui1_num_dii_filters;
    UINT8 ui1_num_ddb_filters;
    UINT8 ui1_num_ddl_filters;
    UINT8 ui1_num_desc_filters;

    SIZE_T  z_dsi_buff_size;
    SIZE_T  z_dii_buff_size;
    SIZE_T  z_ddb_buff_size;
    SIZE_T  z_ddl_buff_size;
    SIZE_T  z_desc_buf_size;

    UINT16  ui2_num_dsi_tbl_objs;
    UINT16  ui2_num_dii_tbl_objs;
    UINT16  ui2_num_ddb_tbl_objs;
    UINT16  ui2_num_ddl_tbl_objs;
    UINT16  ui2_num_mon_tbl_objs;  /* dsi or top-level dii */
    UINT16  ui2_num_desc_tbl_objs;
    UINT16  ui2_num_mon_desc_tbl_objs;
}   DSMCC_CONFIG_T;

/* Definition of the DSMCC server id. */
#define DSMCC_SERVER_ID_MAX_LEN  20    /**< Maximum DSM-CC server ID length */

typedef UINT8 DSMCC_SERVER_ID_T [DSMCC_SERVER_ID_MAX_LEN];    /**< DSM-CC server ID */

/* Transaction ID fields mask */
#define DSMCC_TRANS_ID_UPDATE_FLAG_MASK       (0x00000001) /* 0x00000001 = 0000 0000 0000 0000 0000 0000 0000 0001 */
#define DSMCC_TRANS_ID_IDENTIFICATION_MASK    (0x0000FFFE) /* 0x0000FFFE = 0000 0000 0000 0000 1111 1111 1111 1110 */
#define DSMCC_TRANS_ID_VERSION_MASK           (0x3FFF0000) /* 0x3FFF0000 = 0011 1111 1111 1111 0000 0000 0000 0000 */
#define DSMCC_TRANS_ID_ORIGINATOR_MASK        (0xC0000000) /* 0xC0000000 = 1100 0000 0000 0000 0000 0000 0000 0000 */

#define DSMCC_TRANS_ID_EXTRACT_ID_FIELD_MASK(trans_id)    (trans_id & DSMCC_TRANS_ID_IDENTIFICATION_MASK)
#define DSMCC_TRANS_ID_EXTRACT_VER_FIELD_MASK(trans_id)   (trans_id & DSMCC_TRANS_ID_VERSION_MASK)

#define DSMCCR_INV_HANDLE               ((INT32) -16)    /**<Invalid handle        */
#define DSMCCR_OUT_OF_MEMORY            ((INT32) -15)    /**<Out of memory         */
#define DSMCCR_NOT_INIT                 ((INT32) -14)    /**<Not initialized       */
#define DSMCCR_INTERNAL_ERROR           ((INT32) -13)    /**<Internal error        */
#define DSMCCR_CLI_ERROR                ((INT32) -12)    /**<Cli init error        */
#define DSMCCR_CREATE_TIMER_FAIL        ((INT32) -11)    /**<create timer failed   */
#define DSMCCR_START_TIMER_FAIL         ((INT32) -10)    /**<create timer failed   */
#define DSMCCR_OUT_OF_RESOURCES         ((INT32) -9)    /**<out of resource       */
#define DSMCCR_INV_COND                 ((INT32) -8)    /**<invalid condition     */
#define DSMCCR_SEMAPHORE_FAILED         ((INT32) -7)    /**<lock semaphore failed */
#define DSMCCR_STM_INIT_FAIL		    ((INT32) -6)    /**< State machien initialization failed */
#define DSMCCR_SEND_MSG_FAIL		    ((INT32) -5)    /**< Send message failed */
#define DSMCCR_HANDLE_FAIL		        ((INT32) -4)    /**< Handle allocation failed */
#define DSMCCR_INV_ARG			        ((INT32) -3)    /**< Invalid argument */
#define DSMCCR_FAIL                     ((INT32) -2)    /**< Failed while calling table manager API */
#define DSMCCR_CORE                     ((INT32) -1)    /**< SSU internal error */
#define DSMCCR_OK                       ((INT32)  0)    /**< OK */
/* Structure associated with DSMCC_GET_TYPE_DSI_INFO */
/* Returns the common data of a DSI table.           */
/*------------------------------------------------------------------*/
/*! @struct DSMCC_DSI_INFO_T
 *  @brief  Structure associated with DSMCC_GET_TYPE_DSI_INFO. Returns the common data of a DSI table.
 *  @code
 *  typedef struct _DSMCC_DSI_INFO_T
 *  {
 *      UINT32  ui4_transaction_id;
 *      DSMCC_SERVER_ID_T  t_server_id;
 *  }   DSMCC_DSI_INFO_T;
 *  @endcode
 *  @li@c  ui4_transaction_id - Transaction ID
 *  @li@c  t_server_id        - Server ID
 */
/*------------------------------------------------------------------*/
typedef struct _DSMCC_DSI_INFO_T
{
    UINT32  ui4_transaction_id;

    DSMCC_SERVER_ID_T  t_server_id;
}   DSMCC_DSI_INFO_T;


/* Structure associated with DSMCC_GET_TYPE_DII_INFO */
/* Returns the common data of a DII table.           */
/*------------------------------------------------------------------*/
/*! @struct DSMCC_DII_INFO_T
 *  @brief  Structure associated with DSMCC_GET_TYPE_DII_INFO. Returns the common data of a DII table.
 *  @code
 *  typedef struct _DSMCC_DII_INFO_T
 *  {
 *      UINT32  ui4_download_id;
 *      UINT32  ui4_transaction_id;
 *      UINT32  ui4_download_window;
 *      UINT32  ui4_download_scenario;
 *      UINT16  ui2_block_size;
 *      UINT16  ui2_num_modules;
 *      UINT8  ui1_window_size;
 *      UINT8  ui1_ack_period;
 *  }   DSMCC_DII_INFO_T;
 *  @endcode
 *  @li@c  ui4_download_id       - Download ID
 *  @li@c  ui4_transaction_id    - Transaction ID
 *  @li@c  ui4_download_window   - Download window
 *  @li@c  ui4_download_scenario - Download scenario
 *  @li@c  ui2_block_size        - Block size
 *  @li@c  ui2_num_modules       - Number of modules
 *  @li@c  ui1_window_size       - Window size
 *  @li@c  ui1_ack_period        - Ack period
 */
/*------------------------------------------------------------------*/
typedef struct _DSMCC_DII_INFO_T
{
    UINT32  ui4_download_id;
    UINT32  ui4_transaction_id;
    UINT32  ui4_download_window;
    UINT32  ui4_download_scenario;
    UINT32  ui4_version;

    UINT16  ui2_block_size;
    UINT16  ui2_num_modules;

    UINT8  ui1_window_size;
    UINT8  ui1_ack_period;
}   DSMCC_DII_INFO_T;
typedef enum
{
    DOWNLOAD_FAIL_UNKNOWN = -100,
    DOWNLOAD_FAIL_RESOURCE_NOT_ENOUGH,
    DOWNLOAD_FAIL_BUF_SIZE_NOT_ENOUGH = -1,
    DOWNLOAD_OK = 0,
    DOWNLOAD_PROGRESS,
    DOWNLOAD_COMPLETE
} SSU_DOWNLOAD_COND_T;

typedef INT32 (*x_dsmcc_download_progress_fct)(                                                    
                                                    SSU_DOWNLOAD_COND_T     e_cond,
                                                    VOID *    pv_data,
                                                    UINT32 ui4_data_len,
                                                    VOID * tag);
typedef enum{
  NOT_AVAIL,
  EMPTY,
  FILLING,
  VERYFYING,
  FULL
} BUFF_STATUS_T;

typedef enum{
  BUF_FRM_FBM,
  BUF_FRM_MAL
} BUFF_TYPE_T;

typedef struct _DSMCC_DLD_CTRL_BUF_T
{
    UINT8*  pui1_buf;
    BUFF_TYPE_T e_type;
    UINT32  ui4_buf_size;
    UINT32  ui4_curr_offset;
    UINT32  ui4_total_sec_num;
    UINT32  ui4_wr_len;       //from the beginning to start_offset; if no start_offeset, ui4_wr_len is the data len that need to written.
    UINT32  ui4_offset_in_file;
    BUFF_STATUS_T e_status;     
    
    BOOL    b_ctn_file_start;
    UINT32  ui4_file_start_offset;
    UINT32  ui4_file_start_len;
    UINT32  ui4_sec_num;
}  DSMCC_DLD_CTRL_BUF_T;


/* Structure associated with DSMCC_GET_TYPE_DII_MODULE_INFO */
/* Returns the common module data of a DII table.           */
/*------------------------------------------------------------------*/
/*! @struct DSMCC_DII_MODULE_INFO_T
 *  @brief  Structure associated with DSMCC_GET_TYPE_DII_MODULE_INFO. Returns the common module data of a DII table.
 *  @code
 *  typedef struct _DSMCC_DII_MODULE_INFO_T
 *  {
 *      UINT32  ui4_module_size;
 *      UINT16  ui2_module_id;
 *      UINT8  ui1_module_version;
 *  }   DSMCC_DII_MODULE_INFO_T;
 *  @endcode
 *  @li@c  ui4_module_size    - DII module size.
 *  @li@c  ui2_module_id      - DII module ID.
 *  @li@c  ui1_module_version - DII module version.
 */
/*------------------------------------------------------------------*/
typedef struct _DSMCC_DII_MODULE_INFO_T
{
    UINT32  ui4_module_size;

    UINT16  ui2_module_id;

    UINT8  ui1_module_version;

    /* Compressed module descriptor */
    UINT8  ui1_compression_method;
    UINT32 ui4_original_size;

    /* Caching priority descriptor */
    UINT8  ui1_caching_priority;
    UINT8  ui1_transparency_level;
}   DSMCC_DII_MODULE_INFO_T;

/* Structure associated with DSMCC_GET_TYPE_DDB_INFO */
/* Returns the common data of a DDB table.           */
/*------------------------------------------------------------------*/
/*! @struct DSMCC_DDB_INFO_T
 *  @brief  Structure associated with DSMCC_GET_TYPE_DDB_INFO. Returns the common data of a DDB table.
 *  @code
 *  typedef struct _DSMCC_DDB_INFO_T
 *  {
 *      UINT32  ui4_download_id;
 *      UINT16  ui2_module_id;
 *      UINT16  ui2_block_num;
 *      UINT8   ui1_version;
 *  }   DSMCC_DDB_INFO_T;
 *  @endcode
 *  @li@c  ui4_download_id - DDB Download ID
 *  @li@c  ui2_module_id   - DDB Module ID
 *  @li@c  ui2_block_num   - DDB Block number.
 *  @li@c  ui1_version     - DDB Version.
 */
/*------------------------------------------------------------------*/
typedef struct _DSMCC_DDB_INFO_T
{
    UINT32  ui4_download_id;

    UINT16  ui2_module_id;
    UINT16  ui2_block_num;

    UINT8   ui1_version;
}   DSMCC_DDB_INFO_T;


/* Structure used to load specific DSI, DII and / or DDB tables. */
#define DSMCC_IDS_FLAG_DOWNLOAD_ID_VALID                 ((UINT8) 0x01)    /**< Indicates that Download ID flag is valid. */
#define DSMCC_IDS_FLAG_TRANSACTION_ID_VALID              ((UINT8) 0x02)    /**< Indicates that Transaction ID is valid. */
#define DSMCC_IDS_FLAG_MODULE_ID_VALID                   ((UINT8) 0x04)    /**< Indicates that Module ID is valid. */
#define DSMCC_IDS_FLAG_BLOCK_NUM_VALID                   ((UINT8) 0x08)    /**< Indicates that Block number is valid. */
#define DSMCC_IDS_FLAG_VERSION_VALID                     ((UINT8) 0x10)    /**< Indicates that Version is valid. */
#define DSMCC_IDS_FLAG_CHK_DDB_SET_BEFORE_CPY            ((UINT8) 0x20)    /**< Indicates that ddb copy or not */
#define DSMCC_IDS_FLAG_NFY_ALL_BLOCKS_WITHOUT_CHECKING   ((UINT8) 0x40)    /**< Indicates that all ddb's need to be notified (mainly for ssu download) */

/*------------------------------------------------------------------*/
/*! @struct DSMCC_IDS_T
 *  @brief  Structure to contain various ID's, and flags to indicate which ID's are valid.
 *  @code
 *  typedef struct _DSMCC_IDS_T
 *  {
 *      UINT32  ui4_download_id;
 *      UINT32  ui4_transaction_id;
 *      UINT16  ui2_module_id;
 *      UINT16  ui2_first_block_num;
 *      UINT16  ui2_last_block_num;
 *      UINT8  ui1_version;
 *      UINT8  ui1_flags;
 *  }   DSMCC_IDS_T;
 *  @endcode
 *  @li@c  ui4_download_id     - Download ID.
 *  @li@c  ui4_transaction_id  - Transaction ID.
 *  @li@c  ui2_module_id       - Module ID.
 *  @li@c  ui2_first_block_num - First block number.
 *  @li@c  ui2_last_block_num  - Last block number.
 *  @li@c  ui1_version         - Version.
 *  @li@c  ui1_flags           - Flags to indicate which ID's are valid.
 */
/*------------------------------------------------------------------*/
typedef struct _DSMCC_IDS_T
{
    UINT32  ui4_download_id;
    UINT32  ui4_transaction_id;

    UINT16  ui2_module_id;
    UINT16  ui2_first_block_num;
    UINT16  ui2_last_block_num;

    UINT8  ui1_version;
    UINT8  ui1_flags;
    HANDLE_T h_dld;
}   DSMCC_IDS_T;


/* Structure associated with DSMCC_LOAD_TYPE_PID_TS_DESCR_IDS and */
/* will load specific DSI, DII and / or DDB table based on DSMCC  */
/* id's, PID value and TS id.                                     */
/*------------------------------------------------------------------*/
/*! @struct DSMCC_PID_TS_DESCR_IDS_T
 *  @brief  Structure associated with DSMCC_LOAD_TYPE_PID_TS_DESCR_IDS
 *          and will load specific DSI, DII and / or DDB table based on
 *          DSMCC id's, PID value and TS id.
 *  @code
 *  typedef struct _DSMCC_PID_TS_DESCR_IDS_T
 *  {
 *      DSMCC_IDS_T  t_dsmcc_ids;
 *      TS_DESCR_T    t_ts_descr;
 *      MPEG_2_PID_T  t_pid;
 *  }   DSMCC_PID_TS_DESCR_IDS_T;
 *  @endcode
 *  @li@c  t_dsmcc_ids - DSM-CC ID's
 *  @li@c  t_ts_descr  - TS descriptor
 *  @li@c  t_pid       - PID
 */
/*------------------------------------------------------------------*/
typedef struct _DSMCC_PID_TS_DESCR_IDS_T
{
    DSMCC_IDS_T  t_dsmcc_ids;

    TS_DESCR_T    t_ts_descr;

    MPEG_2_PID_T  t_pid;
}   DSMCC_PID_TS_DESCR_IDS_T;

/* Structure associated with DSMCC_LOAD_TYPE_PID_TS_ID_IDS and */
/* will load specific DSI, DII and / or DDB table based on     */
/* DSMCC id's, PID value and TS id.                            */
/*------------------------------------------------------------------*/
/*! @struct DSMCC_PID_TS_ID_IDS_T
 *  @brief  Structure associated with DSMCC_LOAD_TYPE_PID_TS_ID_IDS
 *          and will load specific DSI, DII and / or DDB table based on
 *          DSMCC id's, PID value and TS id.
 *  @code
 *  typedef struct _DSMCC_PID_TS_ID_IDS_T
 *  {
 *      DSMCC_IDS_T  t_dsmcc_ids;
 *      MPEG_2_PID_T  t_pid;
 *      UINT16  ui2_ts_id;
 *  }   DSMCC_PID_TS_ID_IDS_T;
 *  @endcode
 *  @li@c  t_dsmcc_ids - DSM-CC ID's
 *  @li@c  t_pid       - PID
 *  @li@c  ui2_ts_id   - TS ID
 */
/*------------------------------------------------------------------*/
typedef struct _DSMCC_PID_TS_ID_IDS_T
{
    DSMCC_IDS_T  t_dsmcc_ids;

    MPEG_2_PID_T  t_pid;

    UINT16  ui2_ts_id;
}   DSMCC_PID_TS_ID_IDS_T;


/* Structure associated with TM_LOAD_TYPE_TS_DESCR. */
/*------------------------------------------------------------------*/
/*! @struct DSMCC_PID_TS_DESCR_T
 *  @brief  Structure associated with TM_LOAD_TYPE_TS_DESCR.
 *  @code
 *  typedef struct _DSMCC_PID_TS_DESCR_T
 *  {
 *      TS_DESCR_T  t_ts_descr;
 *      MPEG_2_PID_T  t_pid;
 *  }   DSMCC_PID_TS_DESCR_T;
 *  @endcode
 *  @li@c  t_ts_descr - TS descriptor.
 *  @li@c  t_pid      - PID.
 */
/*------------------------------------------------------------------*/
typedef struct _DSMCC_PID_TS_DESCR_T
{
    TS_DESCR_T  t_ts_descr;

    MPEG_2_PID_T  t_pid;
}   DSMCC_PID_TS_DESCR_T;

/* Structure associated with TM_LOAD_TYPE_TS_ID. */
/*------------------------------------------------------------------*/
/*! @struct DSMCC_PID_TS_ID_T
 *  @brief  Structure associated with TM_LOAD_TYPE_TS_ID.
 *  @code
 *  typedef struct _DSMCC_PID_TS_ID_T
 *  {
 *      MPEG_2_PID_T  t_pid;
 *      UINT16  ui2_ts_id;
 *  }   DSMCC_PID_TS_ID_T;
 *  @endcode
 *  @li@c  t_pid     - PID.
 *  @li@c  ui2_ts_id - TS ID.
 */
/*------------------------------------------------------------------*/
typedef struct _DSMCC_PID_TS_ID_T
{
    MPEG_2_PID_T  t_pid;

    UINT16  ui2_ts_id;
}   DSMCC_PID_TS_ID_T;


/*------------------------------------------------------------------*/
/*! @struct DSMCC_PID_TS_ID_EVT_ID_T
 *  @brief This structure contains PID, TSID, and Table extension information
 *  @code
 *  typedef struct _DSMCC_PID_TS_ID_EVT_ID_T
 *  {
 *      MPEG_2_PID_T        t_pid;
 *      UINT16              ui2_ts_id;
 *      UINT16              ui2_evt_id;
 *  }   DSMCC_PID_TS_ID_EVT_ID_T;
 *  @endcode
 *  @li@c  t_pid                                           -pid
 *  @li@c  ui2_ts_id                                       -TS ID
 *  @li@c  ui2_evt_id                                      -Event id
 */
/*------------------------------------------------------------------*/
typedef struct _DSMCC_PID_TS_ID_EVT_ID_T
{
    MPEG_2_PID_T  t_pid;

    UINT16  ui2_ts_id;

    UINT16  ui2_evt_id;
}   DSMCC_PID_TS_ID_EVT_ID_T;


/*------------------------------------------------------------------*/
/*! @enum  DSMCC_DOWNLOAD_TYPE_T
 *  @brief Download level
 *  @code
 *  typedef enum {invalid_level, one_level, two_level} DSMCC_DOWNLOAD_TYPE_T;
 *  @endcode
 */
/*------------------------------------------------------------------*/
typedef enum {invalid_level, one_level, two_level} DSMCC_DOWNLOAD_TYPE_T;


#endif /* _U_DSMCC_ENG_H_ */

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


