/* 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_hbbtv.h
 *  $RCSfile: $
 *  $Revision$
 *  $Date$
 *  $Author$
 *
 *  @par Description: This header file declares HBBTV exported APIs.
 */
/*----------------------------------------------------------------------------*/
#ifndef _U_OPERA_HBBTV_COMMON_H_
#define _U_OPERA_HBBTV_COMMON_H_

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

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

typedef UINT32   OPERA_HBBTV_NFY_MASK_T;

#define OPERA_HBBTV_NFY_UNKNOWN             ((UINT32) MAKE_BIT_MASK_32(0))
#define OPERA_HBBTV_NFY_SI_TABLE            ((UINT32) MAKE_BIT_MASK_32(1))
#define OPERA_HBBTV_NFY_VIDEO_BRDCST        ((UINT32) MAKE_BIT_MASK_32(2))
#define OPERA_HBBTV_NFY_CHANNEL_LIST        ((UINT32) MAKE_BIT_MASK_32(3))
#define OPERA_HBBTV_NFY_DSMCC               ((UINT32) MAKE_BIT_MASK_32(4))
#define OPERA_HBBTV_NFY_EVENT               ((UINT32) MAKE_BIT_MASK_32(5))
#define OPERA_HBBTV_NFY_AV_COMP             ((UINT32) MAKE_BIT_MASK_32(6))
#define OPERA_HBBTV_NFY_SYSTEM              ((UINT32) MAKE_BIT_MASK_32(7))
#define OPERA_HBBTV_NFY_CONFIG              ((UINT32) MAKE_BIT_MASK_32(8))

#define OPERA_HBBTV_STM_CLI_START           ((UINT32) 1)
#define OPERA_HBBTV_STM_CLI_PLAY            ((UINT32) 2)
#define OPERA_HBBTV_STM_CLI_PAUSE           ((UINT32) 3)
#define OPERA_HBBTV_STM_CLI_STOP            ((UINT32) 4)
#define OPERA_HBBTV_STM_CLI_RELEASE         ((UINT32) 5)
#define OPERA_HBBTV_STM_CLI_LIST            ((UINT32) 6)

typedef enum{
    OPERA_HBBTV_CHANNEL_LIST_UNKNOWN = 0,
    OPERA_HBBTV_CHANNEL_LIST_CHANGED,
    OPERA_HBBTV_CHANNEL_LIST_UPDATED,
    OPERA_HBBTV_CHANNEL_LIST_PARTIAL_UPDATED
}OPERA_HBBTV_CHANNEL_LIST_EVENT_T;

typedef enum{
    OPERA_HBBTV_VIDEO_BRDCST_UNKNOWN = 0,
    OPERA_HBBTV_VIDEO_BRDCST_BEFORE_SVC_CHANGE,
    OPERA_HBBTV_VIDEO_BRDCST_AFTER_SVC_CHANGE,
    OPERA_HBBTV_VIDEO_BRDCST_TUNE_TO_NULL_SVC,
    OPERA_HBBTV_VIDEO_BRDCST_SVC_STOPPED,
    OPERA_HBBTV_VIDEO_BRDCST_SVC_STOPPED_BY_STREAMING,
    OPERA_HBBTV_VIDEO_BRDCST_CLEAR_SVC,
    OPERA_HBBTV_VIDEO_BRDCST_SCRAMBLE_SVC,
    OPERA_HBBTV_VIDEO_BRDCST_NO_AV_STREAM,
    OPERA_HBBTV_VIDEO_BRDCST_NO_SIGNAL,
    OPERA_HBBTV_VIDEO_BRDCST_TUNE_TO_CURR_CLEAR_SVC,
    OPERA_HBBTV_VIDEO_BRDCST_TUNE_TO_CURR_SCRAMBLE_SVC,
    OPERA_HBBTV_VIDEO_BRDCST_SCDB_UPDATE,

    OPERA_HBBTV_VIDEO_BRDCST_DVB_CTX_CHANGE = 100,
    OPERA_HBBTV_VIDEO_BRDCST_DVB_CTX_INVALID,

}OPERA_HBBTV_VIDEO_BRDCST_EVENT_T;

typedef enum{
    OPERA_HBBTV_SI_LOADER_UNKNOWN = 0,
    OPERA_HBBTV_SI_LOADER_AIT_UPDATE,       //valid ait with section data
    OPERA_HBBTV_SI_LOADER_AIT_INVALIDATE,   //invalid ait
    OPERA_HBBTV_SI_LOADER_AIT_NONE,         //none ait
    OPERA_HBBTV_SI_LOADER_PMT_UPDATE,
    OPERA_HBBTV_SI_LOADER_PMT_OTHER_UPDATE,
    OPERA_HBBTV_SI_LOADER_SI_LOADER_CHANGE,
    OPERA_HBBTV_SI_LOADER_SI_LOADER_INVALID,
}OPERA_HBBTV_SI_LOADER_EVENT_T;

typedef enum{
    OPERA_HBBTV_SYSTEM_EVENT_UNKNOWN = 0,
    OPERA_HBBTV_SYSTEM_TERMINATE_APP,
    OPERA_HBBTV_SYSTEM_START_DIGITAL_TELETEXT,
    OPERA_HBBTV_SYSTEM_RESUME_RUNNING_APP,
    OPERA_HBBTV_SYSTEM_DISABLE_AUTO_START_APP,
    OPERA_HBBTV_SYSTEM_FINALIZE_BROWSER_RES,
    OPERA_HBBTV_SYSTEM_NETWORK_STATUS,
    OPERA_HBBTV_SYSTEM_LOAD_STREAM_PROFILE,

    OPERA_HBBTV_SYSTEM_MEMORY_COST = 100,

}OPERA_HBBTV_SYSTEM_EVENT_T;

typedef enum{
    OPERA_HBBTV_AV_COMP_EVENT_UNKNOWN = 0,
    OPERA_HBBTV_AV_COMP_EVENT_PLAY_DONE,
    OPERA_HBBTV_AV_COMP_EVENT_PLAY_FAILED,
    OPERA_HBBTV_AV_COMP_EVENT_STOP_DONE,
    OPERA_HBBTV_AV_COMP_EVENT_STOP_FAILED,
    OPERA_HBBTV_AV_COMP_EVENT_LIST_UPDATED,
}OPERA_HBBTV_AV_COMP_EVENT_T;

typedef enum{
    OPERA_HBBTV_CONFIG_UNKNOWN = 0,
    OPERA_HBBTV_CONFIG_COUNTRY_ID,
    OPERA_HBBTV_CONFIG_GUI_LANGUAGE,
    OPERA_HBBTV_CONFIG_AUDIO_LANGUAGE,
    OPERA_HBBTV_CONFIG_SUBTITIE_LANGUAGE,
    OPERA_HBBTV_CONFIG_SUBTITIE_ENABLE,
    OPERA_HBBTV_CONFIG_AUD_DESC,
    OPERA_HBBTV_CONFIG_NEXT_AUDIO,
    OPERA_HBBTV_CONFIG_GET_AUDIO_TRACK_NUM,
    OPERA_HBBTV_CONFIG_GET_AUDIO_LANG,
    OPERA_HBBTV_CONFIG_GET_AUDIO_TRACK,
    OPERA_HBBTV_CONFIG_SET_AUDIO_TRACK,
    OPERA_HBBTV_CONFIG_RATING_AGE,
    OPERA_HBBTV_CONFIG_DRM_PRIO,
    OPERA_HBBTV_CONFIG_PRIVACY_DO_NOT_TRACE,
    OPERA_HBBTV_CONFIG_PRIVACY_3RD_PART_COOKIE,
    OPERA_HBBTV_CONFIG_PRIVACY_PERSISTENT_STORAGE,
    OPERA_HBBTV_CONFIG_PRIVACY_BLOCK_TRACK_SITES,
    OPERA_HBBTV_CONFIG_GET_SUBTITLE_LIST,
    OPERA_HBBTV_CONFIG_SET_SUBTITLE_PREFER,
    OPERA_HBBTV_CONFIG_SET_SUBTITLE_ACTIVE,
    OPERA_HBBTV_CONFIG_DEVICE_ID
}OPERA_HBBTV_CONFIG_EVENT_T;

typedef enum{
    OPERA_HBBTV_LOADING_FAIL_UNKNOWN = 0,
    OPERA_HBBTV_LOADING_FAIL_NETWORK_FAILED,
    OPERA_HBBTV_LOADING_FAIL_TIMED_OUT,
    OPERA_HBBTV_LOADING_FAIL_OUT_OF_MEM,
    OPERA_HBBTV_LOADING_FAIL_INTERNET_DISCONNECTED,
    OPERA_HBBTV_LOADING_FAIL_NAME_RESOLUTION_FAILED,
}OPERA_HBBTV_LOADING_FAIL_REASON_T;

typedef INT32   OPERA_HBBTV_MSG_TYPE_T;

#define OPERA_HBBTV_MSG_UNKNOWN             ((OPERA_HBBTV_MSG_TYPE_T)  0)
#define OPERA_HBBTV_MSG_TUNE_REQ            ((OPERA_HBBTV_MSG_TYPE_T)  1)
#define OPERA_HBBTV_MSG_SELECT_SUBTITLE     ((OPERA_HBBTV_MSG_TYPE_T)  2)
#define OPERA_HBBTV_MSG_SET_DISPLAY_REG     ((OPERA_HBBTV_MSG_TYPE_T)  3)
#define OPERA_HBBTV_MSG_KEY_DOWN            ((OPERA_HBBTV_MSG_TYPE_T)  4)
#define OPERA_HBBTV_MSG_KEY_UP              ((OPERA_HBBTV_MSG_TYPE_T)  5)
#define OPERA_HBBTV_MSG_KEY_REPEAT          ((OPERA_HBBTV_MSG_TYPE_T)  6)
#define OPERA_HBBTV_MSG_APP_LOADING         ((OPERA_HBBTV_MSG_TYPE_T)  7)
#define OPERA_HBBTV_MSG_APP_RUNNING         ((OPERA_HBBTV_MSG_TYPE_T)  8)
#define OPERA_HBBTV_MSG_APP_TERMINATED      ((OPERA_HBBTV_MSG_TYPE_T)  9)
#define OPERA_HBBTV_MSG_KEYSET_CHANGED      ((OPERA_HBBTV_MSG_TYPE_T)  10)
#define OPERA_HBBTV_MSG_SYS_INIT_DONE       ((OPERA_HBBTV_MSG_TYPE_T)  11)
#define OPERA_HBBTV_MSG_START_STREAMING     ((OPERA_HBBTV_MSG_TYPE_T)  12)
#define OPERA_HBBTV_MSG_STOP_STREAMING      ((OPERA_HBBTV_MSG_TYPE_T)  13)
#define OPERA_HBBTV_MSG_STOP_BROADCAST      ((OPERA_HBBTV_MSG_TYPE_T)  14)
#define OPERA_HBBTV_MSG_UNSELECT_SUBTITLE   ((OPERA_HBBTV_MSG_TYPE_T)  15)
#define OPERA_HBBTV_MSG_DIGITAL_TELETEX     ((OPERA_HBBTV_MSG_TYPE_T)  16)
#define OPERA_HBBTV_MSG_START_3RD_APP       ((OPERA_HBBTV_MSG_TYPE_T)  17)
#define OPERA_HBBTV_MSG_STOP_AV_STREAM      ((OPERA_HBBTV_MSG_TYPE_T)  18)
#define OPERA_HBBTV_MSG_LOADING_FAILED      ((OPERA_HBBTV_MSG_TYPE_T)  19)
#define OPERA_HBBTV_MSG_CERTIFICATE_ERR     ((OPERA_HBBTV_MSG_TYPE_T)  20)
#define OPERA_HBBTV_MSG_STOP_3RD_APP        ((OPERA_HBBTV_MSG_TYPE_T)  21)
#define OPERA_HBBTV_MSG_APP_WILL_START      ((OPERA_HBBTV_MSG_TYPE_T)  22)
#define OPERA_HBBTV_MSG_BR_STATUS_CHANGE    ((OPERA_HBBTV_MSG_TYPE_T)  23)
#define OPERA_HBBTV_MSG_RESTART             ((OPERA_HBBTV_MSG_TYPE_T)  24)
#define OPERA_HBBTV_MSG_APP_VISIBLE_CHANGE  ((OPERA_HBBTV_MSG_TYPE_T)  25)
#define OPERA_HBBTV_MSG_BROWSER_CRASH       ((OPERA_HBBTV_MSG_TYPE_T)  26)
#define OPERA_HBBTV_MSG_APP_LOADING_BLOCKED ((OPERA_HBBTV_MSG_TYPE_T)  27)
#define OPERA_HBBTV_MSG_KILLAPP             ((OPERA_HBBTV_MSG_TYPE_T)  28)
#define OPERA_HBBTV_MSG_SELECT_AUDIO        ((OPERA_HBBTV_MSG_TYPE_T)  29)
#define OPERA_HBBTV_MSG_UNSELECT_AUDIO      ((OPERA_HBBTV_MSG_TYPE_T)  30)
#define OPERA_HBBTV_MSG_APP_NOT_STARTED     ((OPERA_HBBTV_MSG_TYPE_T)  31)
#define OPERA_HBBTV_MSG_XML_DLD_FAILED      ((OPERA_HBBTV_MSG_TYPE_T)  32)
#define OPERA_HBBTV_MSG_APP_URL_LOAD_REQ    ((OPERA_HBBTV_MSG_TYPE_T)  33)
#define OPERA_HBBTV_MSG_SUBTITLE_LIST_READY ((OPERA_HBBTV_MSG_TYPE_T)  34)

typedef INT32 (*x_opera_hbbtv_dtv_nfy_fct)(
                INT32               i4_nfy_type,
                INT32               i4_nfy_code,
                VOID*               pv_data,
                UINT32              ui4_data_len,
                VOID*               pv_nfy_tag);

typedef INT32 (*x_opera_hbbtv_com_nfy_fct)(
                INT32               i4_msg_type,
                VOID*               pv_data,
                SIZE_T              z_data_len,
                VOID*               pv_nfy_tag);

typedef INT32 (*x_opera_hbbtv_stm_cli_fct)(
                INT32               i4_nfy_type,
                INT32               i4_nfy_code,
                VOID*               pv_data,
                UINT32              ui4_data_len,
                VOID*               pv_nfy_tag);
#endif


