summaryrefslogtreecommitdiff
path: root/tvapi/libtv/tv/CTvEpg.h (plain)
blob: 8242f3ccfe421e3ce5caf6e1644368b97a3084ab
1/*
2 * amlogic 2013
3 *@ Project : tv
4 *@ Date : 2013-12
5 *@ Author :
6*/
7#include <am_debug.h>
8#include <am_scan.h>
9#include <am_epg.h>
10#include <am_mem.h>
11#include <utils/Log.h>
12#include "CTvEv.h"
13#if !defined(_CDTVEPG_H)
14#define _CDTVEPG_H
15class CTvEpg {
16public :
17 static const int MODE_ADD = 0;
18 static const int MODE_REMOVE = 1;
19 static const int MODE_SET = 2;
20
21 static const int SCAN_PAT = 0x01;
22 static const int SCAN_PMT = 0x02;
23 static const int SCAN_CAT = 0x04;
24 static const int SCAN_SDT = 0x08;
25 static const int SCAN_NIT = 0x10;
26 static const int SCAN_TDT = 0x20;
27 static const int SCAN_EIT_PF_ACT = 0x40;
28 static const int SCAN_EIT_PF_OTH = 0x80;
29 static const int SCAN_EIT_SCHE_ACT = 0x100;
30 static const int SCAN_EIT_SCHE_OTH = 0x200;
31 static const int SCAN_MGT = 0x400;
32 static const int SCAN_VCT = 0x800;
33 static const int SCAN_STT = 0x1000;
34 static const int SCAN_RRT = 0x2000;
35 static const int SCAN_PSIP_EIT = 0x4000;
36 static const int SCAN_PSIP_ETT = 0x8000;
37 static const int SCAN_EIT_PF_ALL = SCAN_EIT_PF_ACT | SCAN_EIT_PF_OTH;
38 static const int SCAN_EIT_SCHE_ALL = SCAN_EIT_SCHE_ACT | SCAN_EIT_SCHE_OTH;
39 static const int SCAN_EIT_ALL = SCAN_EIT_PF_ALL | SCAN_EIT_SCHE_ALL;
40 static const int SCAN_ALL = SCAN_PAT | SCAN_PMT | SCAN_CAT | SCAN_SDT | SCAN_NIT | SCAN_TDT | SCAN_EIT_ALL |
41 SCAN_MGT | SCAN_VCT | SCAN_STT | SCAN_RRT | SCAN_PSIP_EIT | SCAN_PSIP_ETT;
42
43 static const int INVALID_ID = -1;
44
45 //egp notify
46 /*static const int EVENT_PF_EIT_END = 1;
47 static const int EVENT_SCH_EIT_END = 2;
48 static const int EVENT_PMT_END = 3;
49 static const int EVENT_SDT_END = 4;
50 static const int EVENT_TDT_END = 5;
51 static const int EVENT_NIT_END = 6;
52 static const int EVENT_PROGRAM_AV_UPDATE = 7;
53 static const int EVENT_PROGRAM_NAME_UPDATE = 8;
54 static const int EVENT_PROGRAM_EVENTS_UPDATE = 9;
55 static const int EVENT_CHANNEL_UPDATE = 10;*/
56 //
57 class EpgEvent : public CTvEv {
58 public:
59 EpgEvent(): CTvEv(CTvEv::TV_EVENT_EPG)
60 {
61
62 };
63 ~EpgEvent()
64 {
65 };
66 static const int EVENT_PF_EIT_END = 1;
67 static const int EVENT_SCH_EIT_END = 2;
68 static const int EVENT_PMT_END = 3;
69 static const int EVENT_SDT_END = 4;
70 static const int EVENT_TDT_END = 5;
71 static const int EVENT_NIT_END = 6;
72 static const int EVENT_PROGRAM_AV_UPDATE = 7;
73 static const int EVENT_PROGRAM_NAME_UPDATE = 8;
74 static const int EVENT_PROGRAM_EVENTS_UPDATE = 9;
75 static const int EVENT_CHANNEL_UPDATE = 10;
76 static const int EVENT_CHANNEL_UPDATE_END = 11;
77
78 int type;
79 int channelID;
80 int programID;
81 int dvbOrigNetID;
82 int dvbTSID;
83 int dvbServiceID;
84 long time;
85 int dvbVersion;
86 };
87
88 class IObserver {
89 public:
90 IObserver() {};
91 virtual ~IObserver() {};
92 virtual void onEvent(const EpgEvent &ev) = 0;
93 };
94 //1 VS n
95 //int addObserver(IObserver* ob);
96 //int removeObserver(IObserver* ob);
97
98 //1 VS 1
99 int setObserver(IObserver *ob)
100 {
101 mpObserver = ob;
102 return 0;
103 }
104
105 CTvEpg()
106 {
107 mCurScanChannelId = INVALID_ID;
108 mCurScanProgramId = INVALID_ID;
109 mEpgScanHandle = NULL;
110 mpObserver = NULL;
111 }
112 void Init(int fend, int dmx, int fend_mod, char *textLanguages, char *dvb_text_coding);
113
114 ~CTvEpg()
115 {
116 epg_destroy();
117 }
118
119 /*Enter a channel.*/
120 void enterChannel(int chan_id);
121 /*Leave the channel.*/
122 void leaveChannel();
123 /*Enter the program.*/
124 void enterProgram(int prog_id);
125 /*Leave the program.*/
126 void leaveProgram();
127
128private:
129 //
130 void epg_create(int fend_id, int dmx_id, int src, char *textLangs);
131 void epg_destroy();
132 void epg_change_mode(int op, int mode);
133 void epg_monitor_service(int srv_id);
134 void epg_set_dvb_text_coding(char *coding);
135
136
137 /*Start scan the sections.*/
138 void startScan(int mode);
139 /*Stop scan the sections.*/
140 void stopScan(int mode);
141
142 static void epg_evt_callback(long dev_no, int event_type, void *param, void *user_data);
143
144 //
145 IObserver *mpObserver;
146
147 //
148 AM_EPG_Handle_t mEpgScanHandle;
149 int mFend_dev_id;
150 int mDmx_dev_id ;
151 int mFend_mod;
152 int mCurScanChannelId ;
153 int mCurScanProgramId ;
154
155 //
156 EpgEvent mCurEpgEv;
157};
158#endif //_CDTVEPG_H
159