/**
* Copyright(c) 2011 Sunmedia Technologies - All Rights Reserved.
*
* @file
*
* @brief this file defines teletext interface for afw layer.
*
* The file supports teletext functions by used for afw layer, and the datas related
* teletext functions are "EBU teletext" datas. "EBU teletext" datas include teletext subtitle
* datas. So the function in the file includes teletext subtitle function.
*/

#ifndef __AI_TELETEXT_H__
#define __AI_TELETEXT_H__

#include "al_basictypes.h"
#include "al_teletext.h"
#include "mid_ttx_intf.h"

#ifdef __cplusplus
	extern "C"{
#endif

/**
* @brief teletext init function.
*
* This api is used to create mutex for protecting the shared resource
* and so on.
*
* @param al_void.
*
* @return AL_SUCCESS if initialization is successful, AL_FAILURE
* otherwise.
*/
AL_Return_t AI_TTX_Init(TT_Callback_f TT_CallBack);


/**
* @brief teletext uninit function.
*
* This api is used to delete mutex for protecting the shared resource
* and so on.
*
* @param al_void.
*
* @return AL_SUCCESS if uninitialization is successful, AL_FAILURE
* otherwise.
*/
AL_Return_t AI_TTX_Uninit(al_void);

/**
* @brief the function can parse teletext descriptor in PMT.
*
* After parsing PMT, PSI listener will start to work. When the stream
* type is private data of PES packet, the teletext descriptor will be parsing.
* When parsing the teletext descriptor, the information: teletext pid, teletext
* language, teletext type, teletext magazine number and page number will be
* stored to teletext buffer.
*
* @param *Data teletext descpriptor data.
*
* @param DataLen the number of bytes of descriptors.
*
* @param Pid teletext pid.
*
* @return AL_SUCCESS if parsing teletext descriptor is successful,
* AL_FAILURE otherwise.
*/
AL_Return_t AI_TTX_ParseDesc(al_uint8 *Data, al_uint16 DataLen, al_uint16 Pid);

/**
* @brief the function can set subtitle display window freezed or not.
*
* After the video is freezed with pressing freeze key, if the subtitle is
* displaying on the screen, the subtitle needs be freezed. Else the
* video isn't freezed with pressing freeze key again,  if the subtitle is
* displaying on the screen, the subtitle needn't be freezed.
*
* @param FreezeStatus if freeze is true, the subtitle needs be freezed.
* Else if freeze is false, the subtitle needn't be freezed.
*
* @return al_void.
*/
al_void AI_TTX_SetSubtitleFreeze(al_bool FreezeStatus);

/**
* @brief the function will start subtitle to display.
*
* The function will change teletext mode to subtitle mode, and  start to display
* subtitle on the screen. The function will create teletext decoder thread, and init
* slicer param. The demux channel of teletext channel will be opened with teletext
* pid and the subtitle page number and language will be set to middleware layer,
* and the parsing task will start to decode subtitle page.
*
* @param Index user selects subtitle number on the subtitle menu, and using index, the special
* subtitle descriptor information will be gotten from teletext descriptor buffer.
*
* @return AL_SUCCESS if teletext subtitle starting is successful,
* AL_FAILURE otherwise.
*/
AL_Return_t AI_TTX_StartSubtitle(al_uint8 Index);

/**
* @brief the function will stop subtitle to display.
*
* @param al_void.
*
* @return AL_SUCCESS if teletext subtitle stop is successful,
* AL_FAILURE otherwise.
*/
AL_Return_t AI_TTX_StopSubtitle(al_void);

/**
* @brief the function can get file ts teletext subtitle information from pe module
*
* when play recorded file, if need to display teletext subtitle on the screen, the file ts
* teletext subtitle information need to be gotten from pe module.
*
* @param SubInfo the subtitle information will be getton from PE module.
*
* @return AL_SUCCESS if getting file ts teletext subtitle information is successful,
* AL_FAILURE otherwise.
*/
AL_Return_t AI_TTX_GetFileTsSubInfo(AL_TTX_Desc_Info_t SubInfo);

/**
* @brief get wss data function
*
* This api is used to get wss data from ttdecoder.
*
* @param al_void.
*
* @return wss data.
*/
al_uint16 AI_TTX_GetWSSData(al_void);

#ifdef __cplusplus
}
#endif
#endif

