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