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