diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2004-05-23 10:39:21 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2004-05-23 10:39:21 +0000 |
| commit | c0f5089ea04bd04fe25148e712fa62cd49dc17da (patch) | |
| tree | 4459439ba4fd730d69fd0216b43f41b6ebf010c3 /lib/service | |
| parent | 676c3e4b7ba3a01f5d69bed1b5b2c861e84a6211 (diff) | |
| download | enigma2-c0f5089ea04bd04fe25148e712fa62cd49dc17da.tar.gz enigma2-c0f5089ea04bd04fe25148e712fa62cd49dc17da.zip | |
added nav core
Diffstat (limited to 'lib/service')
| -rw-r--r-- | lib/service/iservice.h | 16 | ||||
| -rw-r--r-- | lib/service/servicedvb.cpp | 31 | ||||
| -rw-r--r-- | lib/service/servicedvb.h | 8 | ||||
| -rw-r--r-- | lib/service/servicemp3.cpp | 60 | ||||
| -rw-r--r-- | lib/service/servicemp3.h | 21 |
5 files changed, 103 insertions, 33 deletions
diff --git a/lib/service/iservice.h b/lib/service/iservice.h index bedb0d6f..9eeb07c8 100644 --- a/lib/service/iservice.h +++ b/lib/service/iservice.h @@ -3,6 +3,7 @@ #include <lib/base/object.h> #include <lib/base/estring.h> +#include <connection.h> #include <list> class eServiceReference @@ -133,6 +134,12 @@ public: } }; +class iServiceInformation: public virtual iObject +{ +public: + virtual RESULT getName(eString &name)=0; +}; + class iPauseableService: public virtual iObject { public: @@ -144,9 +151,16 @@ class iPlayableService: public virtual iObject { friend class iServiceHandler; public: - // it's PRIVATE to the class factory + enum + { + evStart, + evEnd + }; + virtual RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)=0; virtual RESULT start()=0; + virtual RESULT stop()=0; virtual RESULT getIPausableService(ePtr<iPauseableService> &ptr)=0; + virtual RESULT getIServiceInformation(ePtr<iServiceInformation> &ptr)=0; }; class iRecordableService: public virtual iObject diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index fc48fa66..62dbee54 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -28,15 +28,8 @@ eServiceFactoryDVB::~eServiceFactoryDVB() RESULT eServiceFactoryDVB::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr) { - RESULT res; // check resources... ptr = new eDVBServicePlay(ref); - res = ptr->start(); - if (res) - { - ptr = 0; - return res; - } return 0; } @@ -138,10 +131,20 @@ void eDVBServicePlay::serviceEvent(int event) RESULT eDVBServicePlay::start() { eDebug("starting DVB service"); - m_serviceHandler.tune((eServiceReferenceDVB&)m_reference); + return m_serviceHandler.tune((eServiceReferenceDVB&)m_reference); +} + +RESULT eDVBServicePlay::stop() +{ + eDebug("stopping.."); return 0; } +RESULT eDVBServicePlay::connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection) +{ + return -1; +} + RESULT eDVBServicePlay::getIPausableService(ePtr<iPauseableService> &ptr) { // not yet possible, maybe later... @@ -149,6 +152,18 @@ RESULT eDVBServicePlay::getIPausableService(ePtr<iPauseableService> &ptr) return -1; } +RESULT eDVBServicePlay::getIServiceInformation(ePtr<iServiceInformation> &ptr) +{ + ptr = this; + return 0; +} + +RESULT eDVBServicePlay::getName(eString &name) +{ + name = "DVB service"; + return 0; +} + DEFINE_REF(eDVBServicePlay) eAutoInitP0<eServiceFactoryDVB> init_eServiceFactoryDVB(eAutoInitNumbers::service+1, "eServiceFactoryDVB"); diff --git a/lib/service/servicedvb.h b/lib/service/servicedvb.h index fac9edf2..1de4586c 100644 --- a/lib/service/servicedvb.h +++ b/lib/service/servicedvb.h @@ -20,7 +20,7 @@ public: RESULT list(const eServiceReference &, ePtr<iListableService> &ptr); }; -class eDVBServicePlay: public virtual iPlayableService, public virtual iObject, public Object +class eDVBServicePlay: public virtual iPlayableService, public virtual iObject, public Object, public virtual iServiceInformation { DECLARE_REF; private: @@ -38,8 +38,14 @@ public: virtual ~eDVBServicePlay(); // iPlayableService + RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection); RESULT start(); + RESULT stop(); RESULT getIPausableService(ePtr<iPauseableService> &ptr); + RESULT getIServiceInformation(ePtr<iServiceInformation> &ptr); + + // iServiceInformation + RESULT getName(eString &name); }; #endif diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index fb5993e4..27ae1147 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -1,5 +1,6 @@ #include <lib/base/eerror.h> #include <lib/base/object.h> +#include <lib/base/ebase.h> #include <string> #include <lib/service/servicemp3.h> #include <lib/service/service.h> @@ -31,15 +32,8 @@ DEFINE_REF(eServiceFactoryMP3) // iServiceHandler RESULT eServiceFactoryMP3::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr) { - RESULT res; // check resources... ptr = new eServiceMP3(ref.path.c_str()); - res = ptr->start(); - if (res) - { - ptr = 0; - return res; - } return 0; } @@ -57,33 +51,65 @@ RESULT eServiceFactoryMP3::list(const eServiceReference &, ePtr<iListableService // eServiceMP3 -eServiceMP3::eServiceMP3(const char *filename): filename(filename), ref(0) + +void eServiceMP3::test_end() { - printf("MP3: %s start\n", filename); + eDebug("end of mp3!"); + stop(); +} + +eServiceMP3::eServiceMP3(const char *filename): ref(0), filename(filename), test(eApp) +{ + m_state = stIdle; } eServiceMP3::~eServiceMP3() { - printf("MP3: %s stop\n", filename.c_str()); + if (m_state == stRunning) + stop(); } - -void eServiceMP3::AddRef() + +DEFINE_REF(eServiceMP3); + +RESULT eServiceMP3::connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection) +{ + connection = new eConnection(m_event.connect(event)); + return 0; +} + +RESULT eServiceMP3::start() { - ++ref; + assert(m_state == stIdle); + + m_state = stRunning; + + printf("mp3 starts\n"); + printf("MP3: %s start\n", filename.c_str()); + test.start(10000, 1); + CONNECT(test.timeout, eServiceMP3::test_end); + m_event(this, evStart); + return 0; } -void eServiceMP3::Release() +RESULT eServiceMP3::stop() { - if (!--ref) - delete this; + assert(m_state != stIdle); + if (m_state == stStopped) + return -1; + test.stop(); + printf("MP3: %s stop\n", filename.c_str()); + m_state = stStopped; + m_event(this, evEnd); + return 0; } -RESULT eServiceMP3::start() { printf("mp3 starts\n"); return 0; } RESULT eServiceMP3::getIPausableService(ePtr<iPauseableService> &ptr) { ptr=this; return 0; } // iPausableService RESULT eServiceMP3::pause() { printf("mp3 pauses!\n"); return 0; } RESULT eServiceMP3::unpause() { printf("mp3 unpauses!\n"); return 0; } +RESULT eServiceMP3::getIServiceInformation(ePtr<iServiceInformation>&) { return -1; } + eAutoInitP0<eServiceFactoryMP3> init_eServiceFactoryMP3(eAutoInitNumbers::service+1, "eServiceFactoryMP3"); diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h index 0f2c074f..b443d6eb 100644 --- a/lib/service/servicemp3.h +++ b/lib/service/servicemp3.h @@ -17,26 +17,35 @@ public: RESULT list(const eServiceReference &, ePtr<iListableService> &ptr); }; -class eServiceMP3: public virtual iPlayableService, public virtual iPauseableService, public virtual iObject +class eServiceMP3: public virtual iPlayableService, public virtual iPauseableService, public virtual iObject, public Object { +DECLARE_REF; +private: friend class eServiceFactoryMP3; std::string filename; eServiceMP3(const char *filename); - int ref; + eTimer test; + void test_end(); + Signal2<void,iPlayableService*,int> m_event; + enum + { + stIdle, stRunning, stStopped, + }; + int m_state; public: virtual ~eServiceMP3(); - // iObject - void AddRef(); - void Release(); - // iPlayableService + RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection); RESULT start(); + RESULT stop(); RESULT getIPausableService(ePtr<iPauseableService> &ptr); // iPausableService RESULT pause(); RESULT unpause(); + + RESULT getIServiceInformation(ePtr<iServiceInformation>&); }; #endif |
