summaryrefslogtreecommitdiff
path: root/tvapi/libtv/tv/CTvSubtitle.cpp (plain)
blob: 1442dadbf23bd21e9b93b5be264d47ec1844cbc4
1//
2//
3// amlogic 2013
4//
5// @ Project : tv
6// @ Date : 2013-11
7// @ Author :
8//
9//
10#include "CTvSubtitle.h"
11CTvSubtitle::CTvSubtitle()
12{
13 mpObser = NULL;
14}
15CTvSubtitle::~CTvSubtitle()
16{
17}
18void CTvSubtitle::setObser(IObserver *pObser)
19{
20 mpObser = pObser;
21}
22void CTvSubtitle::stopDecoder()
23{
24}
25/**
26 * 开始字幕信息解析showboz sync
27 */
28void CTvSubtitle::startSub()
29{
30}
31
32/**
33 * 停止图文/字幕信息解析
34 */
35void CTvSubtitle::stop()
36{
37}
38
39/**
40 * 停止图文/字幕信息解析并清除缓存数据
41 */
42void CTvSubtitle::clear()
43{
44
45}
46
47/**
48 * 在图文模式下进入下一页
49 */
50void CTvSubtitle::nextPage()
51{
52
53}
54
55/**
56 * 在图文模式下进入上一页
57 */
58void CTvSubtitle::previousPage()
59{
60
61}
62
63/**
64 * 在图文模式下跳转到指定页
65 * @param page 要跳转到的页号
66 */
67void CTvSubtitle::gotoPage(int page)
68{
69
70}
71
72/**
73 * 在图文模式下跳转到home页
74 */
75void CTvSubtitle::goHome()
76{
77
78}
79
80/**
81 * 在图文模式下根据颜色跳转到指定链接
82 * @param color 颜色,COLOR_RED/COLOR_GREEN/COLOR_YELLOW/COLOR_BLUE
83 */
84void CTvSubtitle::colorLink(int color)
85{
86
87}
88
89/**
90 * 在图文模式下设定搜索字符串
91 * @param pattern 搜索匹配字符串
92 * @param casefold 是否区分大小写
93 */
94void CTvSubtitle::setSearchPattern(char *pattern, bool casefold)
95{
96
97}
98
99/**
100 * 搜索下一页
101 */
102void CTvSubtitle::searchNext()
103{
104}
105
106/**
107 * 搜索上一页
108 */
109void CTvSubtitle::searchPrevious()
110{
111}
112
113int CTvSubtitle::sub_init()
114{
115 return 0;
116}
117
118int CTvSubtitle::sub_destroy()
119{
120 return 0;
121}
122
123int CTvSubtitle::sub_lock()
124{
125 return 0;
126}
127
128int CTvSubtitle::sub_unlock()
129{
130 return 0;
131}
132
133int CTvSubtitle::sub_clear()
134{
135 return 0;
136}
137
138int CTvSubtitle::sub_start_dvb_sub(int dmx_id, int pid, int page_id, int anc_page_id)
139{
140 return 0;
141}
142
143int CTvSubtitle::sub_start_dtv_tt(int dmx_id, int region_id, int pid, int page, int sub_page, bool is_sub)
144{
145 return 0;
146}
147
148int CTvSubtitle::sub_stop_dvb_sub()
149{
150 return 0;
151}
152
153int CTvSubtitle::sub_stop_dtv_tt()
154{
155 return 0;
156}
157
158int CTvSubtitle::sub_tt_goto(int page)
159{
160 return 0;
161}
162
163int CTvSubtitle::sub_tt_color_link(int color)
164{
165 return 0;
166}
167
168int CTvSubtitle::sub_tt_home_link()
169{
170 return 0;
171}
172
173int CTvSubtitle::sub_tt_next(int dir)
174{
175 return 0;
176}
177
178int CTvSubtitle::sub_tt_set_search_pattern(char *pattern, bool casefold)
179{
180 return 0;
181}
182
183int CTvSubtitle::sub_tt_search(int dir)
184{
185 return 0;
186}
187
188/*
189 * 1, Set the country first and parameters should be either USA or KOREA
190#define CMD_SET_COUNTRY_USA 0x5001
191#define CMD_SET_COUNTRY_KOREA 0x5002
192
1932, Set the source type which including
194 a)VBI data(for analog program only)
195 b)USER data(for AIR or Cable service)
196CMD_CC_SET_VBIDATA = 0x7001,
197CMD_CC_SET_USERDATA = 0x7002,
1982.1 If the frontend type is Analog we must set the channel Index
199 with command 'CMD_CC_SET_CHAN_NUM' and the parameter is like 57M
200 we set 0x20000, this should according to USA standard frequency
201 table.
202
2033, Next is to set the CC service type
204
205#define CMD_CC_1 0x3001
206#define CMD_CC_2 0x3002
207#define CMD_CC_3 0x3003
208#define CMD_CC_4 0x3004
209
210//this doesn't support currently
211#define CMD_TT_1 0x3005
212#define CMD_TT_2 0x3006
213#define CMD_TT_3 0x3007
214#define CMD_TT_4 0x3008
215
216#define CMD_SERVICE_1 0x4001
217#define CMD_SERVICE_2 0x4002
218#define CMD_SERVICE_3 0x4003
219#define CMD_SERVICE_4 0x4004
220#define CMD_SERVICE_5 0x4005
221#define CMD_SERVICE_6 0x4006
222
2234, Then set CMD_CC_START to start the CC service, and you needn't to stop
224
225CC service while switching services
226
2275, CMD_CC_STOP should be called in some cases like switch source, change
228
229program, no signal, blocked...*/
230
231//channel_num == 0 ,if frontend is dtv
232//else != 0
233int CTvSubtitle::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)
234{
235 LOGD("----sub_start_atsc_cc-1--- country=%d,src=%d,ctype=%d", country, src_type, caption_type);
236 switch(country) {
237 case CC_PARAM_COUNTRY_USA:
238 AM_CC_Cmd(CMD_SET_COUNTRY_USA);
239 break;
240 case CC_PARAM_COUNTRY_KOREA:
241 AM_CC_Cmd(CMD_SET_COUNTRY_KOREA);
242 break;
243 default:
244 AM_CC_Cmd(CMD_SET_COUNTRY_USA);
245 break;
246 }
247
248 switch(src_type) {
249 case CC_PARAM_SOURCE_VBIDATA:
250 AM_CC_Cmd(CMD_CC_SET_VBIDATA);
251 break;
252 case CC_PARAM_SOURCE_USERDATA:
253 AM_CC_Cmd(CMD_CC_SET_USERDATA);
254 break;
255 default:
256 AM_CC_Cmd(CMD_CC_SET_USERDATA);
257 break;
258 }
259
260 //just for test
261 if(channel_num == 0) {
262 } else {
263 //AM_CC_Cmd(CMD_CC_SET_CHAN_NUM);
264 }
265
266 AM_CLOSECAPTION_cmd_t cc_t_cmd;
267 switch(caption_type) {
268 case CC_PARAM_ANALOG_CAPTION_TYPE_CC1:
269 cc_t_cmd = CMD_CC_1;
270 break;
271 case CC_PARAM_ANALOG_CAPTION_TYPE_CC2:
272 cc_t_cmd = CMD_CC_2;
273 break;
274 case CC_PARAM_ANALOG_CAPTION_TYPE_CC3:
275 cc_t_cmd = CMD_CC_3;
276 break;
277 case CC_PARAM_ANALOG_CAPTION_TYPE_CC4:
278 cc_t_cmd = CMD_CC_4;
279 break;
280 case CC_PARAM_DIGITAL_CAPTION_TYPE_SERVICE1:
281 cc_t_cmd = CMD_SERVICE_1;
282 break;
283 case CC_PARAM_DIGITAL_CAPTION_TYPE_SERVICE2:
284 cc_t_cmd = CMD_SERVICE_2;
285 break;
286 case CC_PARAM_DIGITAL_CAPTION_TYPE_SERVICE3:
287 cc_t_cmd = CMD_SERVICE_3;
288 break;
289 case CC_PARAM_DIGITAL_CAPTION_TYPE_SERVICE4:
290 cc_t_cmd = CMD_SERVICE_4;
291 break;
292 default:
293 cc_t_cmd = CMD_SERVICE_1;
294 break;
295 }
296 AM_CC_Cmd(cc_t_cmd);
297
298 AM_CC_Set_CallBack(close_caption_callback, this);
299 AM_VCHIP_Set_CallBack(atv_vchip_callback, this);
300 //start
301 AM_CC_Cmd(CMD_CC_START);
302 LOGD("----sub_start_atsc_cc-2--- country=%d,src=%d,ctype=%d", country, src_type, caption_type);
303 return 0;
304}
305
306int CTvSubtitle::sub_stop_atsc_cc()
307{
308 LOGD("----sub_stop_atsc_cc----");
309 AM_CC_Cmd(CMD_CC_STOP);
310 return 0;
311}
312int CTvSubtitle::ResetVchipChgStat()
313{
314 avchip_chg = 0;
315 AM_CC_Cmd(CMD_VCHIP_RST_CHGSTAT);
316 return 0;
317}
318int CTvSubtitle::IsVchipChange()
319{
320 return avchip_chg;
321}
322//cnt :data buf len
323//databuf len is max 512
324//cmdbuf len is max 128
325void CTvSubtitle::close_caption_callback(char *str, int cnt, int data_buf[], int cmd_buf[], void *user_data)
326{
327
328 CTvSubtitle *pSub = (CTvSubtitle *)user_data;
329
330 if(pSub == NULL) {
331 LOGD("sub cc callback is null user data for this");
332 return;
333 }
334
335 if(pSub->mpObser == NULL) return;
336
337 pSub->mCurCCEv.mDataBufSize = cnt;
338 pSub->mCurCCEv.mpDataBuffer = data_buf;
339 pSub->mCurCCEv.mCmdBufSize = 128;//max
340 pSub->mCurCCEv.mpCmdBuffer = cmd_buf;
341
342 pSub->mpObser->onEvent(pSub->mCurCCEv);
343}
344void CTvSubtitle::atv_vchip_callback(int Is_chg, void *user_data)
345{
346 CTvSubtitle *pSub = (CTvSubtitle *)user_data;
347 pSub->avchip_chg = Is_chg;
348}
349