al_subtitle.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /**
  2. * Copyright(c) 2011 Sunmedia Technologies - All Rights Reserved.
  3. *
  4. * @file
  5. *
  6. * @brief this file defines subtitle interface for app layer.
  7. *
  8. * The file supports the subtitle functions by used for app layer. At present, the subtitle
  9. * start/stop function include dvb subtitle and teletext function. When starting subtitle,
  10. * the app layer only need send the index by user seletected on the subtitle menu and
  11. * subtitle type to afw layer. The afw layer need start subtitle function with subtitle type.
  12. * When stopping subtitle, afw layer need stop subtitle function with subtitle type.
  13. */
  14. #ifndef __AL_SUBTITLE_H__
  15. #define __AL_SUBTITLE_H__
  16. #include "al_basictypes.h"
  17. #ifdef __cplusplus
  18. extern "C"{
  19. #endif
  20. /**
  21. * @brief define subtitle descriptor language code size.
  22. */
  23. #define LANG_CODE_SIZE (3)
  24. /**
  25. * @brief structure definition for subtitle descriptor information.
  26. *
  27. * After one subtitle descriptor from the PMT is parsed, the information will
  28. * be stored to subtitle descriptor buffer with the structure. \n
  29. * Parsing descriptor information includes the information:
  30. * @li pid: specify the pid of the transport stream packets which carry the
  31. * associated program element.
  32. * @li composition page id: identify the composition page that conveys
  33. * subtitle elements for one specific subtitle service.
  34. * @li ancillary page id: identify the ancillary page that conveys subtitle elements
  35. * for being shared by multiple subtitle services within a subtitle stream.
  36. * @li language: contain charater language code of language of subtitle.
  37. * @li type: contain the subtitle type.
  38. */
  39. typedef struct _AL_Subtitle_Desc_t
  40. {
  41. al_int id; /**< subtitle id by used when play recorded file*/
  42. al_uint16 Pid; /**< subtitle pid */
  43. al_uint16 CompositionPageId; /**< composition page id */
  44. al_uint16 AncillaryPageId; /**< ancillary page id */
  45. al_uint8 Language[LANG_CODE_SIZE]; /**< subtitle language */
  46. al_uint8 Type; /**< subtitle type */
  47. } AL_Subtitle_Desc_Info_t;
  48. /**
  49. * @brief select the subtitle data type for gotten the subtitle data.
  50. */
  51. typedef enum
  52. {
  53. AL_SUBTITLE_DEMUX_CHAN = 0, /**< data comes from demux channel for TS */
  54. AL_SUBTITLE_PE_CHAN, /**< data comes from PE channel for recorded TS */
  55. AL_SUBTITLE_MAX /**<invalid data source */
  56. }AL_Subtitle_Data_Source_t;
  57. /**
  58. * @brief select subtitle type.
  59. */
  60. typedef enum
  61. {
  62. AL_SUBTITLE_TYPE_DVB_SUBTITLE = 0, /**< dvb subtitle type */
  63. AL_SUBTITLE_TYPE_TTX_SUBTITLE, /**< teletext subtitle type */
  64. AL_SUBTITLE_TYPE_MAX /**< invalid subtitle type */
  65. }AL_Subtitle_Type_t;
  66. /**
  67. * @brief subtitle start function.
  68. *
  69. * If the subtitle type is dvb subtitle, the function will start dvb subtitle function that
  70. * creates decoder task and display task. The subtitle page id and pid will be set middleware
  71. * layer. The subtitle data will be gotten to subtitle buffer by openning channel with
  72. * pid, and the decoder task will parse data. Then display task will start to display subtitle
  73. * on the screen. @n
  74. * If the subtitle type is teletext subtitle, the function will be start teletext function that
  75. * creates decoder task and render task. The subtitle page and magazine number and
  76. * pid will be set middleware layer. The teletext data will be gotten to teletext buffer by
  77. * openning channel with pid, and the decode task will parse data with page and magazine
  78. * number. Then render task will start ti display teletext subtitle on the screen.
  79. *
  80. * @param Index user selects subtitle number on the subtitle menu, and using index, the special
  81. * subtitle descriptor information will be gotten from subtitle descriptor buffer.
  82. *
  83. * @param SubtitleType subtitle type.
  84. *
  85. * @return AL_SUCCESS if starting is successful, AL_FAILURE otherwise.
  86. */
  87. AL_Return_t AL_Subtitle_Start(al_int Index, AL_Subtitle_Type_t SubtitleType);
  88. /**
  89. * @brief subtitle restart function.
  90. *
  91. * Stop and restart subtitle if the selected subtitle is different from the one which is playing.
  92. *
  93. * @param Index user selects subtitle number on the subtitle menu, and using index, the special
  94. * subtitle descriptor information will be gotten from subtitle descriptor buffer.
  95. *
  96. * @param SubtitleType subtitle type.
  97. *
  98. * @return AL_SUCCESS if starting is successful, AL_FAILURE otherwise.
  99. */
  100. AL_Return_t AL_Subtitle_Restart(al_int Index, AL_Subtitle_Type_t SubtitleType);
  101. /**
  102. * @brief subtitle stop function.
  103. *
  104. * If the subtitle type is dvb subtitle, the function will delete decoder task and display task
  105. * free the subtitle buffer. @n
  106. * If the subtitle type is teletext subtitle, the function will suspend teletext decoder thread
  107. * and delete render task.
  108. *
  109. * @param al_void.
  110. *
  111. * @return AL_SUCCESS if stoping is successful, AL_FAILURE otherwise.
  112. */
  113. AL_Return_t AL_Subtitle_Stop(al_void);
  114. /**
  115. * @brief subtitle reset function.
  116. *
  117. * The buffer that stores subtitle descriptor information is static buffer, so
  118. * it needs be reset with following initialization or a programe change.
  119. *
  120. * @param al_void.
  121. *
  122. * @return AL_SUCCESS if reseting is successful, AL_FAILURE otherwise.
  123. */
  124. AL_Return_t AL_Subtitle_Reset(al_void);
  125. /**
  126. * @brief the function can get the valid subtitle descriptor total number.
  127. *
  128. * Before the subtitle module starts to work, it needs get the subtitle descpritor
  129. * total number. if the total number is more than 0, the subtitle module will start
  130. * to work. otherwise stop to work.
  131. *
  132. * @param *GetTotalNum get the dvb subtitle total number.
  133. *
  134. * @return AL_SUCCESS if getting total number is successful, AL_FAILURE otherwise.
  135. */
  136. AL_Return_t AL_Subtitle_GetTotalNum(al_uint32 *GetTotalNum);
  137. /**
  138. * @brief the function can get the parsed subtitle descriptor information.
  139. *
  140. * After creating the subtitle menu with pressing subtitle key, the subtitle menu
  141. * with all subtitle types will be shown on the screen. So when displayed information
  142. * is inited, the parsed subtitle descriptor information will be gotten.
  143. *
  144. * @note Index value is less than the total subtitle descriptor number.
  145. *
  146. * @param Index using the index can get special subtitle descriptor information from
  147. * the buffer.
  148. *
  149. * @param *SubtitleDescInfo it will store the gotten subtitle descriptor information.
  150. *
  151. * @return AL_SUCCESS if getting subtitle descriptor information is successful,
  152. * AL_FAILURE otherwise.
  153. */
  154. AL_Return_t AL_Subtitle_GetDescInfo(al_int Index,
  155. AL_Subtitle_Desc_Info_t *SubtitleDescInfo);
  156. /**
  157. * @brief the function can set subtitle display window freezed or not.
  158. *
  159. * After the video is freezed with pressing freeze key, if the subtitle is
  160. * displaying on the screen, the subtitle needs be freezed. Else the
  161. * video isn't freezed with pressing freeze key again, if the subtitle is
  162. * displaying on the screen, the subtitle needn't be freezed.
  163. *
  164. * @param FreezeStatus if freeze is true, the subtitle needs be freezed.
  165. * Else if freeze is false, the subtitle needn't be freezed.
  166. *
  167. * @return AL_SUCCESS if setting freeze is successful,
  168. * AL_FAILURE otherwise.
  169. */
  170. AL_Return_t AL_Subtitle_SetFreeze(al_bool FreezeStatus);
  171. /**
  172. * @brief the function can get file ts subtitle information from pe module
  173. *
  174. * when play recorded file, if need to display subtitle on the screen, the file ts
  175. *subtitle information need to be gotten from pe module.
  176. *
  177. * @param al_void.
  178. *
  179. * @return AL_SUCCESS if getting file ts subtitle information is successful,
  180. * AL_FAILURE otherwise.
  181. */
  182. AL_Return_t AL_Subtitle_GetFileTsSubInfo(al_void);
  183. /**
  184. * @brief the function can get the subtitle start status.
  185. *
  186. * @param* None.
  187. *
  188. * @return AL_SUCCESS if getting subtitle start flag is true,
  189. * AL_FAILURE otherwise.
  190. */
  191. AL_Return_t AL_Subtitle_GetStartFlag(void);
  192. /**
  193. * @brief the function can parse subtitle descriptor in PMT.
  194. *
  195. * After parsing PMT, PSI listener will start to work. When the stream
  196. * type is private data of PES packet, and the descriptor type is subtitle
  197. * descriptor, the subtitle descriptor will be parsing. When parsing the
  198. * subtitle descriptor, the information: subtitle pid, subtitle language,
  199. * subtitle type, composition page id and ancillary page id will be
  200. * stored to subtitle buffer.
  201. *
  202. * @param *Data subtitle descpriptor data.
  203. *
  204. * @param DataLen the number of bytes of descriptors.
  205. *
  206. * @param Pid subtitle pid.
  207. *
  208. * @return AL_SUCCESS if parsing subtitle descriptor is successful,
  209. * AL_FAILURE otherwise .
  210. */
  211. AL_Return_t AL_Subtitle_ParseDesc(al_uint8 *Data, al_uint16 DataLen, al_uint16 Pid);
  212. #ifdef __cplusplus
  213. }
  214. #endif
  215. #endif