added nav core
[openblackhole/openblackhole-enigma2.git] / main / enigma.cpp
1 #include <stdio.h>
2 #include <libsig_comp.h>
3 #include <lib/base/ebase.h>
4 #include <lib/base/eerror.h>
5 #include <lib/base/init.h>
6 #include <lib/base/init_num.h>
7
8 #include <lib/dvb/dvb.h>
9 #include <lib/dvb/db.h>
10 #include <lib/dvb/isection.h>
11 #include <lib/dvb/esection.h>
12 #include <lib/dvb_si/pmt.h>
13 #include <lib/dvb/scan.h>
14 #include <unistd.h>
15
16 #include <lib/service/iservice.h>
17 #include <lib/nav/core.h>
18
19 class eMain: public eApplication, public Object
20 {
21         eInit init;
22         
23         ePtr<eDVBResourceManager> m_mgr;
24         ePtr<iDVBChannel> m_channel;
25         ePtr<eDVBDB> m_dvbdb;
26
27         ePtr<iPlayableService> m_playservice;
28         ePtr<eNavigation> m_nav;
29         ePtr<eConnection> m_conn_event;
30 public:
31         eMain()
32         {
33                 init.setRunlevel(eAutoInitNumbers::main);
34                 m_dvbdb = new eDVBDB();
35                 m_mgr = new eDVBResourceManager();
36                 m_mgr->setChannelList(m_dvbdb);
37                 
38                 ePtr<eServiceCenter> service_center;
39                 eServiceCenter::getInstance(service_center);
40
41                 m_nav = new eNavigation(service_center);
42 #if 1
43                 if (service_center)
44                 {
45                         eServiceReference ref("2:0:1:0:0:0:0:0:0:0:/");
46                         ePtr<iListableService> lst;
47                         if (service_center->list(ref, lst))
48                                 eDebug("no list available!");
49                         else
50                         {
51                                 std::list<eServiceReference> list;
52                                 if (lst->getContent(list))
53                                         eDebug("list itself SUCKED AROUND!!!");
54                                 else
55                                         for (std::list<eServiceReference>::const_iterator i(list.begin());
56                                                 i != list.end(); ++i)
57                                                 eDebug("%s", i->toString().c_str());
58                         }
59                 }
60 #endif          
61                 m_nav->connectEvent(slot(*this, &eMain::event), m_conn_event);
62                 
63 //              eServiceReference ref("1:0:1:6de2:44d:1:c00000:0:0:0:");
64                 eServiceReference ref("4097:47:0:0:0:0:0:0:0:0:/sine_60s_100.mp3");
65                 eServiceReference ref1("4097:47:0:0:0:0:0:0:0:0:/sine_60s_100.mp31");
66                 eServiceReference ref2("4097:47:0:0:0:0:0:0:0:0:/sine_60s_100.mp32");
67                 
68                 if (m_nav->enqueueService(ref))
69                         eDebug("play sucked around!");
70                 else
71                         eDebug("play r00lz!");
72
73                 m_nav->enqueueService(ref1);
74                 m_nav->enqueueService(ref2);
75                 m_nav->enqueueService(ref1);
76         }
77         
78         void event(eNavigation *nav, int ev)
79         {
80                 switch (ev)
81                 {
82                 case eNavigation::evNewService:
83                 {
84                         ePtr<iPlayableService> service;
85                         nav->getCurrentService(service);
86                         if (!service)
87                         {
88                                 eDebug("no running service!");
89                                 break;
90                         }
91                         ePtr<iServiceInformation> s;
92                         if (service->getIServiceInformation(s))
93                         {
94                                 eDebug("failed to get iserviceinformation");
95                                 break;
96                         }
97                         eString name;
98                         s->getName(name);
99                         eDebug("NEW running service: %s", name.c_str());
100                         break;
101                 }
102                 case eNavigation::evPlayFailed:
103                         eDebug("play failed!");
104                         break;
105                 case eNavigation::evPlaylistDone:
106                         eDebug("playlist done");
107                         break;
108                 default:
109                         eDebug("Navigation event %d", ev);
110                         break;
111                 }
112         }
113         
114         ~eMain()
115         {
116                 
117         }
118 };
119
120 #ifdef OBJECT_DEBUG
121 int object_total_remaining;
122
123 void object_dump()
124 {
125         printf("%d items left\n", object_total_remaining);
126 }
127 #endif
128
129 int main()
130 {       
131 #ifdef OBJECT_DEBUG
132         atexit(object_dump);
133 #endif
134         eMain app;
135         return app.exec();
136 }