/**
* Copyright(c) 2012 Sunmedia Technologies - All Rights Reserved.
*
* @file 
*
* @brief this file defines closed caption and vchip interface for app layer.
*
* The file supports the closed caption and vchip functions by used for app layer. 
* The datas related closed caption functions include analog and digitial datas and
* the datas related vchip functions include analog datas only.
*/

#ifndef __AL_CC_H__
#define __AL_CC_H__

#include "al_basictypes.h"

#ifdef __cplusplus
	extern "C"{
#endif

/**
* @brief number definition for closed caption service.
* 
* before starting to start closed caption funtion, it needs select closed caption
* service number for gotten source data.
*/
typedef enum
{
	AL_CC_SERV_CC1 = 1,	/**< CC1 service*/
	AL_CC_SERV_CC2,	/**< CC2 service*/
	AL_CC_SERV_CC3,	/**< CC3 service*/
	AL_CC_SERV_CC4,	/**< CC4 service*/
	AL_CC_SERV_TXT1,	/**< TEXT1 service*/
	AL_CC_SERV_TXT2,	/**< TEXT2 service*/
	AL_CC_SERV_TXT3,	/**< TEXT3 service*/
	AL_CC_SERV_TXT4,	/**< TEXT4 service*/
	AL_CC_SERV_CS1,	/**< CS1 service*/
	AL_CC_SERV_CS2,	/**< CS2 service*/
	AL_CC_SERV_CS3,	/**< CS3 service*/
	AL_CC_SERV_CS4,	/**< CS4 service*/
	AL_CC_SERV_CS5,	/**< CS5 service*/
	AL_CC_SERV_CS6,	/**< CS6 service*/
	AL_CC_SERV_MAX		/**< invalid service*/
}AL_CC_Serv_Num_t;

typedef enum
{
	AL_CC_SRC_ATV = 0,
	AL_CC_SRC_DTV,
	AL_CC_SRC_MAX
}AL_CC_Source_Type_t;

/**
* @brief font size definition for closed caption.
*/
typedef enum 
{
	AL_CC_FONT_SIZE_DEFAULT,	/**< default font size*/
	AL_CC_FONT_SIZE_SMALL,	/**< small font size*/
	AL_CC_FONT_SIZE_MEDIUM,	/**< medium font size*/
	AL_CC_FONT_SIZE_LARGE		/**< large font size*/
} AL_CC_Font_Size_t;

/**
* @brief font style definition for closed caption.
*/
typedef enum 
{
	AL_CC_FONT_STYLE_DEFAULT = 0,					/**< default style*/
	AL_CC_FONT_STYLE_MONO_SERIF,				/**< monospaced with serifs style*/
	AL_CC_FONT_STYLE_PROPORTIONAL_SERIF,		/**< proportionally spaced with serifs style*/	
	AL_CC_FONT_STYLE_MONO_SANS_SERIF,		/**< monospaced without serifs style*/
	AL_CC_FONT_STYLE_PROPORTIONAL_SANS_SERIF,/**<proportionally spaced without serifs*/
	AL_CC_FONT_STYLE_CASUAL,					/**< casual font type*/
	AL_CC_FONT_STYLE_CURSIVE,					/**< cursive font type*/
	AL_CC_FONT_STYLE_SMALL_CAPTITALS			/**< small capitals*/
} AL_CC_Font_Style_t;

/**
* @brief color type definition for closed caption.
*/
typedef enum
{
	AL_CC_COLOR_TYPE_DEFAULT,		/**< default color*/
	AL_CC_COLOR_TYPE_BLACK,		/**< black color*/
	AL_CC_COLOR_TYPE_WHITE,		/**< white color*/
	AL_CC_COLOR_TYPE_RED,			/**< red color*/
	AL_CC_COLOR_TYPE_GREEN,		/**< green color*/
	AL_CC_COLOR_TYPE_BLUE,		/**< blue color*/
	AL_CC_COLOR_TYPE_YELLOW,		/**< yellow color*/
	AL_CC_COLOR_TYPE_MAGENTA,		/**< magenta color*/
	AL_CC_COLOR_TYPE_CYAN			/**< cyan color*/
} AL_CC_Color_Type_t;

/**
* @brief opacity type definition for closed caption.
*/
typedef enum 
{
	AL_CC_OPACITY_TYPE_DEFAULT,		/**< default type*/
	AL_CC_OPACITY_TYPE_SOLID,			/**< solid type*/
	AL_CC_OPACITY_TYPE_FLASHING,		/**< flashing type*/
	AL_CC_OPACITY_TYPE_TRANSLUCENT,	/**< translucent type*/
	AL_CC_OPACITY_TYPE_TRANSPARENT	/**< transparent type*/
} AL_CC_Opacity_Type_t;

/**
* @brief border type definition for closed caption.
*/
typedef enum
{
	AL_CC_BORDER_TYPE_DEFAULT,		/**< default type*/
	AL_CC_BORDER_TYPE_RAISED,			/**< raised type*/
	AL_CC_BORDER_TYPE_DEPRESSED,		/**< depressed type*/
	AL_CC_BORDER_TYPE_UNIFORM,		/**< uniform type*/
	AL_CC_BORDER_TYPE_LEFTDROPSHADOW,/**< left drop shadow type*/
	AL_CC_BORDER_TYPE_RIGHTDROPSHADOW/**<  right drop shadow type*/
} AL_CC_Border_Type_t;

/**
* @brief setting closed caption information by user.
*/
typedef struct _AL_CC_Info_t
{
	AL_CC_Serv_Num_t CcServNum;				/**< set closed caption service number*/
	AL_CC_Font_Size_t CcFontSize;			/**< set closed caption font size*/
	AL_CC_Font_Style_t CcFontStyle;		/**< set closed caption font style*/
	AL_CC_Color_Type_t CcFgColor;			/**< set closed caption char fg color*/
	AL_CC_Opacity_Type_t CcFgOpacity;		/**< set closed caption char fg opacity*/
	AL_CC_Color_Type_t CcBgColor;			/**< set closed caption char bg color*/
	AL_CC_Opacity_Type_t CcBgOpacity;		/**< set closed caption char bg opacity*/
	AL_CC_Color_Type_t CcWindowColor;		/**< set closed caption window color*/
	AL_CC_Opacity_Type_t CcWindowOpacity;	/**< set closed caption window opacity*/
	AL_CC_Color_Type_t CcFontEdgeColor;	/**< set closed caption edge color*/
	AL_CC_Border_Type_t	CcFontEdgeType;	/**< set closed caption edge type*/
}AL_CC_Info_t;

/**
* @brief tv rate value definition for vchip us rating region.
*/
typedef enum
{
	AL_VCHIP_TV_RATE_NULL,			/**< none*/
	AL_VCHIP_TV_RATE_G,			/**< general audience*/
	AL_VCHIP_TV_RATE_PG,			/**< parental guidance suggested*/
	AL_VCHIP_TV_RATE_14,			/**< parents strongly cautioned*/
	AL_VCHIP_TV_RATE_MA			/**< mature audience only*/
}AL_VCHIP_US_TV_Rate_t;

/**
* @brief dialog rate value definition for vchip us rating region.
*/
typedef enum
{
	AL_VCHIP_DIALOG_RATE_NULL,		/**< none*/
	AL_VCHIP_DIALOG_RATE_PG,			/**< some suggestive diaglog*/
	AL_VCHIP_DIALOG_RATE_14,			/**< intensely suggestive diaglog*/
}AL_VCHIP_US_Dia_Rate_t;

/**
* @brief language rate value definition for vchip us rating region.
*/
typedef enum
{
	AL_VCHIP_LANGUAGE_RATE_NULL,		/**< none*/
	AL_VCHIP_LANGUAGE_RATE_PG,		/**< infrequent coarse language*/
	AL_VCHIP_LANGUAGE_RATE_14,		/**< strong coarse language*/
	AL_VCHIP_LANGUAGE_RATE_MA			/**< crude indecent language*/
}AL_VCHIP_US_Lan_Rate_t;

/**
* @brief sex rate value definition for vchip us rating region.
*/
typedef enum
{
	AL_VCHIP_SEX_RATE_NULL,			/**< none*/
	AL_VCHIP_SEX_RATE_PG,				/**< some sexual situations*/
	AL_VCHIP_SEX_RATE_14,				/**< intense sexual situations*/
	AL_VCHIP_SEX_RATE_MA				/**< explicit sexual activity*/
}AL_VCHIP_US_Sex_Rate_t;

/**
* @brief violence rate value definition for vchip us rating region.
*/
typedef enum
{
	AL_VCHIP_VIOLENCE_RATE_NULL,		/**< none*/
	AL_VCHIP_VIOLENCE_RATE_PG,		/**< moderate violence*/
	AL_VCHIP_VIOLENCE_RATE_14,		/**< intense violence*/
	AL_VCHIP_VIOLENCE_RATE_MA			/**< graphic violence*/
}AL_VCHIP_US_Vio_Rate_t;

/**
* @brief children rate value definition for vchip us rating region.
*/
typedef enum
{
	AL_VCHIP_CHILD_RATE_NULL,			/**< none*/
	AL_VCHIP_CHILD_RATE_Y,				/**< all children*/
	AL_VCHIP_CHILD_RATE_Y7,			/**< childen age 7 and above*/
	AL_VCHIP_CHILD_RATE_Y7_FV			/**<  fantasy violence for childen age 7 and above*/
}AL_VCHIP_US_Child_Rate_t;

/**
* @brief mpaa rate value definition for vchip us rating region.
*/
typedef enum
{
	AL_VCHIP_MPAA_RATE_NULL,
	AL_VCHIP_MPAA_RATE_NA,				/**< none*/
	AL_VCHIP_MPAA_RATE_G,				/**< suitable for all ages*/
	AL_VCHIP_MPAA_RATE_PG,				/**< parental guidance suggested*/
	AL_VCHIP_MPAA_RATE_PG13,			/**< parental strongly cautioned*/
	AL_VCHIP_MPAA_RATE_R,				/**< restricted, under 17 must be accompanied by adult*/
	AL_VCHIP_MPAA_RATE_NC17,			/**< no one 17 and under admitted*/
	AL_VCHIP_MPAA_RATE_X,				/**< no one 17 and under admitted*/
	AL_VCHIP_MPAA_RATE_NR				/**< not rated by mpaa*/
}AL_VCHIP_MPAA_Rate_t;

/**
* @brief rate value definition for canadian english rating region.
*/
typedef enum
{
	AL_VCHIP_CANADIAN_ENGLISH_NULL = 0x0,
	AL_VCHIP_CANADIAN_ENGLISH_RATE_E = 0x8,/**< exempt*/
	AL_VCHIP_CANADIAN_ENGLISH_RATE_C = 0x1,/**< programming intended for children under age 8*/
	AL_VCHIP_CANADIAN_ENGLISH_RATE_C8 = 0x2,/**< programming generally considered acceptable for children
												8 years and over to watch on their own*/
	AL_VCHIP_CANADIAN_ENGLISH_RATE_G = 0x3,/**< general audience*/
	AL_VCHIP_CANADIAN_ENGLISH_RATE_PG = 0x4,/**< parental guidance*/
	AL_VCHIP_CANADIAN_ENGLISH_RATE_14 = 0x5,/**< programming contains themes or content which may not
												be suitable for viewers under the age of 14*/
	AL_VCHIP_CANADIAN_ENGLISH_RATE_18 = 0x6,/**< adult*/
}AL_VCHIP_CAN_ENG_Rate_t;

/**
* @brief rate value definition for canadian french rating region.
*/
typedef enum
{
	AL_VCHIP_CANADIAN_FRENCH_NULL = 0,
	AL_VCHIP_CANADIAN_FRENCH_RATE_E = 0x8,/**< exempt*/
	AL_VCHIP_CANADIAN_FRENCH_RATE_G = 0x1,/**< general*/
	AL_VCHIP_CANADIAN_FRENCH_RATE_8ANS = 0x2,/**< 8+ general -not recommended for young children*/
	AL_VCHIP_CANADIAN_FRENCH_RATE_13ANS = 0x3,/**< programming may not be suitable for children under the 
												age of 13*/
	AL_VCHIP_CANADIAN_FRENCH_RATE_16ANS = 0x4,/**< programming is not suitable for children under the age of 16*/
	AL_VCHIP_CANADIAN_FRENCH_RATE_18ANS = 0x5,/**< programming restricted to adults*/
}AL_VCHIP_CAN_FRE_Rate_t;

typedef struct _AL_VCHIP_US_Rate_t
{
	AL_VCHIP_US_TV_Rate_t TvRate;			/**< tv rate*/
	AL_VCHIP_US_Dia_Rate_t DiaRate;			/**< dialog rate*/
	AL_VCHIP_US_Lan_Rate_t LanRate;			/**< language rate*/
	AL_VCHIP_US_Sex_Rate_t SexRate;			/**< sex rate*/
	AL_VCHIP_US_Vio_Rate_t VioRate;			/**< violence rate*/
	AL_VCHIP_US_Child_Rate_t ChildRate;		/**< children rate*/
}AL_VCHIP_TVPG_Rate_t;

/**
* @brief us rate information definition.
*/
typedef struct
{
	AL_VCHIP_TVPG_Rate_t TVPGRate;
	AL_VCHIP_MPAA_Rate_t MPAARate;			/**< mpaa rate*/
}AL_VCHIP_US_Rate_t;

/**
* @brief canadian rate information definition.
*/
typedef struct _AL_VCHIP_CAN_Rate_t
{
	AL_VCHIP_CAN_ENG_Rate_t CanEngRate;	/**< canadian english language rate*/
	AL_VCHIP_CAN_FRE_Rate_t CanFreRate;	/**< canadian french language*/
}AL_VCHIP_CAN_Rate_t;

/**
* @brief getting vchip rate region information from flash or eeprom.
*/
typedef struct _AL_CC_VCHIP_Rate_t
{
	AL_VCHIP_US_Rate_t USRateRegion;		/**< us region information*/
	AL_VCHIP_CAN_Rate_t	CANRateRegion;		/**< canadian region information*/
} AL_CC_VCHIP_Rate_Region_t;

/**
* @brief closed caption start function.
*
* The function will start to get cc and xds data from tt slicer and 
* creat decode thread to decode cc and xds data.
*
* @param srctype mid layer need source type to decode cc608 or cc708.
*
* @return AL_SUCCESS if starting is successful, AL_FAILURE
* otherwise.
*/
AL_Return_t AL_CC_Start(AL_CC_Source_Type_t srctype);


/**
* @brief closed caption stop function.
*
* 1.The function will stop to get cc and xds data from tt slicer and 
* stop to decode cc and xds data;
* 2.The function will stop to display cc on the screen.
*
* @param al_void.
*
* @return AL_SUCCESS if starting is successful, AL_FAILURE
* otherwise.
*/
AL_Return_t AL_CC_Stop(al_void);

/**
* @brief closed caption start to display function.
*
* The function will display closed caption on the screen
*
* @param *CCInfo the display information gotten from eeprom/flash if user setting
* the display information on the main menu.
*
* @return AL_SUCCESS if starting is successful, AL_FAILURE
* otherwise.
*/
AL_Return_t AL_CC_View(AL_CC_Info_t *CCInfo);

/**
* @brief closed caption stop to display function.
*
* The function will stop to display closed caption.
*
* @param al_void.
*
* @return AL_SUCCESS if stopping is successful, AL_FAILURE
* otherwise.
*/
AL_Return_t AL_CC_Unview(al_void);

/**
* @brief the function will reset closed caption module, following initialization 
* or a programe change.
* 
* @param al_void.
*
* @return AL_SUCCESS if reseting is successful, AL_FAILURE 
* therwise.
*/
AL_Return_t AL_CC_Reset(al_void);

/**
* @brief the function will get closed caption data being valid or not.
*
* @param *Status gotten the signal status value. if gotten closed caption is
* successful, the gotten signal status is al_true, else the gotten signal status 
* is al_false.
*
* @return AL_SUCCESS if gotten signal is successful, AL_FAILURE 
* therwise.
*/
AL_Return_t AL_CC_GetSignalStatus(al_bool *Status);

#ifdef __cplusplus
}
#endif
#endif
