summaryrefslogtreecommitdiff
path: root/tvapi/libtv/tv/CTvSubtitle.h (plain)
blob: dcf2211111edd04a130b811a6d0c9160a2f08fc3
1//
2//
3// amlogic 2013
4//
5// @ Project : tv
6// @ File Name : CTvSubtitle.h
7// @ Date : 2013-11
8// @ Author :
9//
10//
11#if !defined(_CTVSUBTITLE_H)
12#define _CTVSUBTITLE_H
13#include <stdlib.h>
14#include "CTvLog.h"
15using namespace android;
16#include "am_cc.h"
17#include "CTvEv.h"
18#define LOG_TAG "CTvSubtitle"
19
20
21typedef enum cc_param_country {
22 CC_PARAM_COUNTRY_USA = 0,
23 CC_PARAM_COUNTRY_KOREA,
24};
25
26typedef enum cc_param_source_type {
27 CC_PARAM_SOURCE_VBIDATA = 0,
28 CC_PARAM_SOURCE_USERDATA,
29};
30
31typedef enum cc_param_caption_type {
32 CC_PARAM_ANALOG_CAPTION_TYPE_CC1 = 0,
33 CC_PARAM_ANALOG_CAPTION_TYPE_CC2,
34 CC_PARAM_ANALOG_CAPTION_TYPE_CC3,
35 CC_PARAM_ANALOG_CAPTION_TYPE_CC4,
36 CC_PARAM_ANALOG_CAPTION_TYPE_TEXT1,
37 CC_PARAM_ANALOG_CAPTION_TYPE_TEXT2,
38 CC_PARAM_ANALOG_CAPTION_TYPE_TEXT3,
39 CC_PARAM_ANALOG_CAPTION_TYPE_TEXT4,
40 //
41 CC_PARAM_DIGITAL_CAPTION_TYPE_SERVICE1,
42 CC_PARAM_DIGITAL_CAPTION_TYPE_SERVICE2,
43 CC_PARAM_DIGITAL_CAPTION_TYPE_SERVICE3,
44 CC_PARAM_DIGITAL_CAPTION_TYPE_SERVICE4,
45 CC_PARAM_DIGITAL_CAPTION_TYPE_SERVICE5,
46 CC_PARAM_DIGITAL_CAPTION_TYPE_SERVICE6,
47};
48class CTvSubtitle
49{
50public:
51 CTvSubtitle();
52 ~CTvSubtitle();
53
54 class CloseCaptionEvent: public CTvEv
55 {
56 public:
57 //static const int CC_CMD_LEN = 128;
58 //static const int CC_DATA_LEN = 512;
59 CloseCaptionEvent(): CTvEv(CTvEv::TV_EVENT_CC)
60 {
61 }
62 ~CloseCaptionEvent()
63 {
64 }
65 public:
66 int mCmdBufSize;
67 int *mpCmdBuffer;
68 int mDataBufSize;
69 int *mpDataBuffer;
70 };
71
72 class IObserver
73 {
74 public:
75 IObserver() {};
76 virtual ~IObserver() {};
77 virtual void onEvent(const CloseCaptionEvent &ev) = 0;
78 };
79
80 void setObser(IObserver *pObser);
81 void stopDecoder();
82 /**
83 * 开始字幕信息解析showboz sync
84 */
85 void startSub();
86 /**
87 * 停止图文/字幕信息解析
88 */
89 void stop();
90
91 /**
92 * 停止图文/字幕信息解析并清除缓存数据
93 */
94 void clear();
95 /**
96 * 在图文模式下进入下一页
97 */
98 void nextPage();
99 /**
100 * 在图文模式下进入上一页
101 */
102 void previousPage();
103 /**
104 * 在图文模式下跳转到指定页
105 * @param page 要跳转到的页号
106 */
107 void gotoPage(int page);
108
109 /**
110 * 在图文模式下跳转到home页
111 */
112 void goHome();
113 /**
114 * 在图文模式下根据颜色跳转到指定链接
115 * @param color 颜色,COLOR_RED/COLOR_GREEN/COLOR_YELLOW/COLOR_BLUE
116 */
117 void colorLink(int color);
118
119 /**
120 * 在图文模式下设定搜索字符串
121 * @param pattern 搜索匹配字符串
122 * @param casefold 是否区分大小写
123 */
124 void setSearchPattern(char *pattern, bool casefold);
125 /**
126 * 搜索下一页
127 */
128 void searchNext();
129 /**
130 * 搜索上一页
131 */
132 void searchPrevious();
133
134 int sub_init();
135 //
136 int sub_destroy();
137 //
138 int sub_lock();
139 //
140 int sub_unlock();
141 //
142 int sub_clear();
143 //
144 int sub_start_dvb_sub(int dmx_id, int pid, int page_id, int anc_page_id);
145 //
146 int sub_start_dtv_tt(int dmx_id, int region_id, int pid, int page, int sub_page, bool is_sub);
147 //
148 int sub_stop_dvb_sub();
149 //
150 int sub_stop_dtv_tt();
151 //
152 int sub_tt_goto(int page);
153 //
154 int sub_tt_color_link(int color);
155 //
156 int sub_tt_home_link();
157 //
158 int sub_tt_next(int dir);
159 //
160 int sub_tt_set_search_pattern(char *pattern, bool casefold);
161 //
162 int sub_tt_search(int dir);
163 //
164 int sub_start_atsc_cc(enum cc_param_country country, enum cc_param_source_type src_type, int channel_num, enum cc_param_caption_type caption_type);
165 //
166 int sub_stop_atsc_cc();
167 static void close_caption_callback(char *str, int cnt, int data_buf[], int cmd_buf[], void *user_data);
168 static void atv_vchip_callback(int Is_chg, void *user_data);
169 int IsVchipChange();
170 int ResetVchipChgStat();
171private:
172
173 /**
174 * DVB subtitle 参数
175 */
176 struct DVBSubParams {
177 int mDmx_id;
178 int mPid;
179 int mComposition_page_id;
180 int mAncillary_page_id;
181
182 /**
183 * 创建DVB subtitle参数
184 * @param dmx_id 接收使用demux设备的ID
185 * @param pid subtitle流的PID
186 * @param page_id 字幕的page_id
187 * @param anc_page_id 字幕的ancillary_page_id
188 */
189 DVBSubParams()
190 {
191 }
192 DVBSubParams(int dmx_id, int pid, int page_id, int anc_page_id)
193 {
194 mDmx_id = dmx_id;
195 mPid = pid;
196 mComposition_page_id = page_id;
197 mAncillary_page_id = anc_page_id;
198 }
199 };
200
201 /**
202 * 数字电视teletext图文参数
203 */
204 struct DTVTTParams {
205 int mDmx_id;
206 int mPid;
207 int mPage_no;
208 int mSub_page_no;
209 int mRegion_id;
210
211 DTVTTParams()
212 {
213 }
214 /**
215 * 创建数字电视teletext图文参数
216 * @param dmx_id 接收使用demux设备的ID
217 * @param pid 图文信息流的PID
218 * @param page_no 要显示页号
219 * @param sub_page_no 要显示的子页号
220 */
221 DTVTTParams(int dmx_id, int pid, int page_no, int sub_page_no, int region_id)
222 {
223 mDmx_id = dmx_id;
224 mPid = pid;
225 mPage_no = page_no;
226 mSub_page_no = sub_page_no;
227 mRegion_id = region_id;
228 }
229 };
230
231 int mSubType;
232 CloseCaptionEvent mCurCCEv;
233 IObserver *mpObser;
234 int avchip_chg;
235};
236#endif //_CTVSUBTITLE_H
237