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