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