summaryrefslogtreecommitdiff
path: root/tvapi/libtv/tvdb/CTvProgram.h (plain)
blob: 8abf94fa1edeeb19d91555adf23672cf0191dd08
1//
2//
3// amlogic 2013
4//
5// @ Project : tv
6// @ File Name : CTvProgram.h
7// @ Date : 2013-11
8// @ Author :
9//
10//
11
12
13#if !defined(_CTVPROGRAM_H)
14#define _CTVPROGRAM_H
15
16#include "CTvDatabase.h"
17#include "CTvChannel.h"
18#include <utils/String8.h>
19#include <utils/RefBase.h>
20#include <stdlib.h>
21#include "CTvLog.h"
22using namespace android;
23// Program对应ATV中的一个频道,DTV中的一个service
24class CTvEvent;
25class CTvProgram : public LightRefBase<CTvProgram>
26{
27public:
28 /*this type value is link to enum AM_SCAN_ServiceType in am_scan.h
29 * enum AM_SCAN_ServiceType
30 {
31 AM_SCAN_SRV_UNKNOWN = 0, < 未知类型
32 AM_SCAN_SRV_DTV = 1, < 数字电视类型
33 AM_SCAN_SRV_DRADIO = 2, < 数字广播类型
34 AM_SCAN_SRV_ATV = 3, < 模拟电视类型
35 };
36 * /
37 /**未定义类型*/
38 static const int TYPE_UNKNOWN = 0;
39 /**电视节目*/
40 static const int TYPE_TV = 4;
41 /**广播节目*/
42 static const int TYPE_RADIO = 2;
43 /**模拟节目*/
44 static const int TYPE_ATV = 3;
45 /**数据节目*/
46 static const int TYPE_DATA = 5;
47 /**数字节目*/
48 static const int TYPE_DTV = 1 ;
49 /** PVR/Timeshifting playback program*/
50 static const int TYPE_PLAYBACK = 6;
51
52 static const int PROGRAM_SKIP_NO = 0;
53 static const int PROGRAM_SKIP_YES = 1;
54 static const int PROGRAM_SKIP_UNKOWN = 2;
55
56 /**
57 *Service中的基础元素信息
58 */
59public:
60 class Element
61 {
62 private :
63 int mpid;
64
65 public :
66 Element(int pid)
67 {
68 this->mpid = pid;
69 }
70 /**
71 *取得基础元素的PID
72 *@return 返回PID
73 */
74 int getPID()
75 {
76 return mpid;
77 }
78 };
79
80
81
82 /**
83 *多语言基础元素信息
84 */
85public:
86 class MultiLangElement : public Element
87 {
88 private :
89 String8 mlang;
90
91 public :
92 MultiLangElement(int pid, String8 lang): Element(pid)
93 {
94 this->mlang = lang;
95 }
96
97 /**
98 *取得元素对应的语言
99 *@return 返回3字符语言字符串
100 */
101 String8 getLang()
102 {
103 return mlang;
104 }
105 };
106
107
108
109 /**
110 *视频信息
111 */
112public :
113 class Video : public Element
114 {
115 public:
116 /**MPEG1/2*/
117 static const int FORMAT_MPEG12 = 0;
118 /**MPEG4*/
119 static const int FORMAT_MPEG4 = 1;
120 /**H.264*/
121 static const int FORMAT_H264 = 2;
122 /**MJPEG*/
123 static const int FORMAT_MJPEG = 3;
124 /**Real video*/
125 static const int FORMAT_REAL = 4;
126 /**JPEG*/
127 static const int FORMAT_JPEG = 5;
128 /**Microsoft VC1*/
129 static const int FORMAT_VC1 = 6;
130 /**AVS*/
131 static const int FORMAT_AVS = 7;
132 /**YUV*/
133 static const int FORMAT_YUV = 8;
134 /**H.264 MVC*/
135 static const int FORMAT_H264MVC = 9;
136 /**QJPEG*/
137 static const int FORMAT_QJPEG = 10;
138
139 Video(int pid, int fmt): Element(pid)
140 {
141 this->mformat = fmt;
142 }
143
144 /**
145 *取得视频编码格式
146 *@return 返回视频编码格式
147 */
148 int getFormat()
149 {
150 return mformat;
151 }
152 private :
153 int mformat;
154 };
155
156 /**
157 *音频信息
158 */
159public :
160 class Audio : public MultiLangElement
161 {
162 public :
163 /**MPEG*/
164 static const int FORMAT_MPEG = 0;
165 /**PCM 16位小端*/
166 static const int FORMAT_PCM_S16LE = 1;
167 /**AAC*/
168 static const int FORMAT_AAC = 2;
169 /**AC3*/
170 static const int FORMAT_AC3 = 3;
171 /**ALAW*/
172 static const int FORMAT_ALAW = 4;
173 /**MULAW*/
174 static const int FORMAT_MULAW = 5;
175 /**DTS*/
176 static const int FORMAT_DTS = 6;
177 /**PCM 16位大端*/
178 static const int FORMAT_PCM_S16BE = 7;
179 /**FLAC*/
180 static const int FORMAT_FLAC = 8;
181 /**COOK*/
182 static const int FORMAT_COOK = 9;
183 /**PCM 8位*/
184 static const int FORMAT_PCM_U8 = 10;
185 /**ADPCM*/
186 static const int FORMAT_ADPCM = 11;
187 /**AMR*/
188 static const int FORMAT_AMR = 12;
189 /**RAAC*/
190 static const int FORMAT_RAAC = 13;
191 /**WMA*/
192 static const int FORMAT_WMA = 14;
193 /**WMA Pro*/
194 static const int FORMAT_WMAPRO = 15;
195 /**蓝光PCM*/
196 static const int FORMAT_PCM_BLURAY = 16;
197 /**ALAC*/
198 static const int FORMAT_ALAC = 17;
199 /**Vorbis*/
200 static const int FORMAT_VORBIS = 18;
201 /**AAC latm格式*/
202 static const int FORMAT_AAC_LATM = 19;
203 /**APE*/
204 static const int FORMAT_APE = 20;
205
206
207 Audio(int pid, String8 lang, int fmt): MultiLangElement(pid, lang)
208 {
209 this->mformat = fmt;
210 }
211
212 /**
213 *取得音频编码格式
214 *@return 返回音频编码格式
215 */
216 int getFormat()
217 {
218 return mformat;
219 }
220 private :
221 int mformat;
222 };
223
224 /**
225 *字幕信息
226 */
227public :
228 class Subtitle : public MultiLangElement
229 {
230 public :
231 /**DVB subtitle*/
232 static const int TYPE_DVB_SUBTITLE = 1;
233 /**数字电视Teletext*/
234 static const int TYPE_DTV_TELETEXT = 2;
235 /**模拟电视Teletext*/
236 static const int TYPE_ATV_TELETEXT = 3;
237 /**数字电视Closed caption*/
238 static const int TYPE_DTV_CC = 4;
239 /**模拟电视Closed caption*/
240 static const int TYPE_ATV_CC = 5;
241
242
243
244 Subtitle(int pid, String8 lang, int type, int num1, int num2): MultiLangElement(pid, lang)
245 {
246
247 this->type = type;
248 if (type == TYPE_DVB_SUBTITLE) {
249 compositionPage = num1;
250 ancillaryPage = num2;
251 } else if (type == TYPE_DTV_TELETEXT) {
252 magazineNo = num1;
253 pageNo = num2;
254 }
255 }
256
257 /**
258 *取得字幕类型
259 *@return 返回字幕类型
260 */
261 int getType()
262 {
263 return type;
264 }
265
266 /**
267 *取得DVB subtitle的composition page ID
268 *@return 返回composition page ID
269 */
270 int getCompositionPageID()
271 {
272 return compositionPage;
273 }
274
275 /**
276 *取得DVB subtitle的ancillary page ID
277 *@return 返回ancillary page ID
278 */
279 int getAncillaryPageID()
280 {
281 return ancillaryPage;
282 }
283
284 /**
285 *取得teletext的magazine number
286 *@return 返回magazine number
287 */
288 int getMagazineNumber()
289 {
290 return magazineNo;
291 }
292
293 /**
294 *取得teletext的page number
295 *@return 返回page number
296 */
297 int getPageNumber()
298 {
299 return pageNo;
300 }
301
302 private :
303 int compositionPage;
304 int ancillaryPage;
305 int magazineNo;
306 int pageNo;
307 int type;
308 };
309
310 /**
311 *Teletext信息
312 */
313public :
314 class Teletext : public MultiLangElement
315 {
316 public:
317 Teletext(int pid, String8 lang, int mag, int page): MultiLangElement(pid, lang)
318 {
319 magazineNo = mag;
320 pageNo = page;
321 }
322
323 /**
324 *取得teletext的magazine number
325 *@return 返回magazine number
326 */
327 int getMagazineNumber()
328 {
329 return magazineNo;
330 }
331
332 /**
333 *取得teletext的page number
334 *@return 返回page number
335 */
336 int getPageNumber()
337 {
338 return pageNo;
339 }
340
341 private :
342 int magazineNo;
343 int pageNo;
344 };
345
346 //节目号信息
347public:
348 /**如果没有发现子频道,忽略用户的输入*/
349 static const int MINOR_CHECK_NONE = 0;
350 /**如果没有发现子频道,向上寻找(子频道数字增加),找到子频道号最大的*/
351 static const int MINOR_CHECK_UP = 1;
352 /**如果没有发现子频道,向下寻找(子频道数字减小),找到子频道号最小的*/
353 static const int MINOR_CHECK_DOWN = 2;
354 /*如果没有发现子频道,向上寻找,然后找到向上最近的.*/
355 static const int MINOR_CHECK_NEAREST_UP = 3;
356 /*如果没有发现子频道,向下寻找,然后找到向下最近的.*/
357 static const int MINOR_CHECK_NEAREST_DOWN = 4;
358
359 /**
360 *取得节目号
361 *@return 返回节目号
362 */
363 int getNumber()
364 {
365 return major;
366 }
367
368 /**
369 *取得主节目号(ATSC)
370 *@return 返回节目的主节目号
371 */
372 int getMajor()
373 {
374 return major;
375 }
376
377 /**
378 *取得次节目号(ATSC)
379 *@return 返回节目的次节目号
380 */
381 int getMinor()
382 {
383 return minor;
384 }
385
386 /**
387 *是否为ATSC模式
388 *@return 如果是ATSC模式返回true
389 */
390 bool isATSCMode()
391 {
392 return atscMode;
393 }
394
395 /**
396 *取得子频道号自动查找策略(ATSC)
397 *@return 返回子频道号自动查找策略
398 */
399 int getMinorCheck()
400 {
401 return minorCheck;
402 }
403
404private:
405 int major;
406 int minor;
407 int minorCheck;
408 bool atscMode;
409
410
411public:
412 CTvProgram(CTvDatabase::Cursor &c);
413 CTvProgram(int channelID, int type, int num, int skipFlag);
414 /**
415 *向数据库添加一个Program,atscMode
416 */
417 CTvProgram(int channelID, int type, int major, int minor, int skipFlag);
418 ~CTvProgram();
419 // 创建并向数据库添加一个Program
420 CTvProgram(int channelID, int type);
421
422 CTvProgram();
423
424
425 int getCurrentAudio(String8 defaultLang);
426 Video *getVideo()
427 {
428 return mpVideo;
429 }
430 Audio *getAudio(int id)
431 {
432 if (mvAudios.size() <= 0) return NULL;
433 return mvAudios[id];
434 }
435
436 int getAudioTrackSize()
437 {
438 return mvAudios.size();
439 }
440 static int selectByID(int id, CTvProgram &p);
441 static CTvProgram selectByNumber(int num, int type);
442 int selectByNumber(int type, int major, int minor, CTvProgram &prog, int minor_check = MINOR_CHECK_NONE);
443 int selectByNumber(int type, int num, CTvProgram &prog);
444 static int selectByChannel(int channelID, int type, Vector<sp<CTvProgram> > &out);
445 // 列出全部TVProgram
446 static int selectAll(bool no_skip, Vector<sp<CTvProgram> > &out);
447 static int selectByType(int type, int skip, Vector<sp<CTvProgram> > &out);
448 static int selectByChanID(int type, int skip, Vector<sp<CTvProgram> > &out);
449 static Vector<CTvProgram> selectByChannel(int channelID);
450 // 根据节目名称中的关键字查找指定TVProgram
451 static Vector<CTvProgram> selectByName(int name);
452 void tvProgramDelByChannelID(int channelID);
453 int getID()
454 {
455 return id;
456 };
457 int getSrc()
458 {
459 return src;
460 };
461 int getProgType()
462 {
463 return type;
464 };
465 int getChanOrderNum()
466 {
467 return chanOrderNum;
468 };
469 int getChanVolume()
470 {
471 return volume;
472 };
473 int getSourceId()
474 {
475 return sourceID;
476 };
477 int getServiceId()
478 {
479 return dvbServiceID;
480 };
481 int getProgSkipFlag();
482 void setCurrAudioTrackIndex(int programId, int audioIndex);
483 int getCurrAudioTrackIndex();
484
485 String8 getName();
486 void getCurrentSubtitle();
487 void getCurrentTeletext();
488 int getChannel(CTvChannel &c);
489 int upDateChannel(CTvChannel &c, int std, int freq, int fineFreq);
490 int updateVolComp(int progID, int volValue);
491 void updateProgramName(int progId, String8 strName);
492 void setSkipFlag(int progId, bool bSkipFlag);
493 void setFavoriteFlag(int progId, bool bFavor);
494 int getFavoriteFlag()
495 {
496 return favorite;
497 };
498 void deleteProgram(int progId);
499 static int CleanAllProgramBySrvType(int srvType);
500 void setLockFlag(int progId, bool bLockFlag);
501 bool getLockFlag();
502 void swapChanOrder(int ProgId1, int chanOrderNum1, int ProgId2, int chanOrderNum2);
503 static int deleteChannelsProgram(CTvChannel &c);
504private:
505 int CreateFromCursor(CTvDatabase::Cursor &c);
506 int selectProgramInChannelByNumber(int channelID, int num, CTvDatabase::Cursor &c);
507 int selectProgramInChannelByNumber(int channelID, int major, int minor, CTvDatabase::Cursor &c);
508 CTvChannel channel;
509 int id;
510 int dvbServiceID;
511 int type;
512 String8 name;
513 int channelID;
514 int skip;
515 int favorite;
516 int volume;
517 int sourceID;
518 int pmtPID;
519 int src;
520 int audioTrack;
521 int chanOrderNum;
522 int currAudTrackIndex;
523 bool lock;
524 bool scrambled;
525 // video信息,类型不定
526 Video *mpVideo;
527 // audio信息,类型不定
528 Vector<Audio *> mvAudios;
529 // subtitle信息类型不定
530 Vector<Subtitle *> mvSubtitles;
531 // teletext信息,类型不定
532 Vector<Teletext *> mvTeletexts;
533
534};
535
536#endif //_CTVPROGRAM_H
537