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