diff options
| author | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2005-12-05 19:24:42 +0000 |
|---|---|---|
| committer | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2005-12-05 19:24:42 +0000 |
| commit | 572caca1ba06dd8247724c9f5d6bcad515e2edf4 (patch) | |
| tree | 8525a3017c1d58b03b667cd8d77f942318256ddd /lib/service | |
| parent | 3c2c648735df18576453aa52f0d8441793619dc7 (diff) | |
| download | enigma2-572caca1ba06dd8247724c9f5d6bcad515e2edf4.tar.gz enigma2-572caca1ba06dd8247724c9f5d6bcad515e2edf4.zip | |
add support for Linkage services ( Premiere Subservices )
TODO: show/hide green point depending on avail subservices
Diffstat (limited to 'lib/service')
| -rw-r--r-- | lib/service/event.cpp | 37 | ||||
| -rw-r--r-- | lib/service/event.h | 21 | ||||
| -rw-r--r-- | lib/service/iservice.h | 17 | ||||
| -rw-r--r-- | lib/service/servicedvb.cpp | 106 | ||||
| -rw-r--r-- | lib/service/servicedvb.h | 10 | ||||
| -rw-r--r-- | lib/service/servicemp3.cpp | 29 | ||||
| -rw-r--r-- | lib/service/servicemp3.h | 8 |
7 files changed, 176 insertions, 52 deletions
diff --git a/lib/service/event.cpp b/lib/service/event.cpp index 81a8d4bb..40bc9b51 100644 --- a/lib/service/event.cpp +++ b/lib/service/event.cpp @@ -2,6 +2,7 @@ #include <lib/base/estring.h> #include <lib/base/encoding.h> #include <lib/dvb/dvbtime.h> +#include <lib/dvb/idvb.h> #include <dvbsi++/event_information_section.h> #include <dvbsi++/short_event_descriptor.h> #include <dvbsi++/extended_event_descriptor.h> @@ -119,7 +120,8 @@ bool eServiceEvent::loadLanguage(Event *evt, std::string lang, int tsidonid) data.m_componentType = cp->getComponentType(); data.m_componentTag = cp->getComponentTag(); data.m_iso639LanguageCode = cp->getIso639LanguageCode(); - data.m_text = convertDVBUTF8(cp->getText()); + int table=encodingHandler.getCountryCodeDefaultMapping(data.m_iso639LanguageCode); + data.m_text = convertDVBUTF8(cp->getText(),table,tsidonid); m_component_data.push_back(data); break; } @@ -128,14 +130,16 @@ bool eServiceEvent::loadLanguage(Event *evt, std::string lang, int tsidonid) const LinkageDescriptor *ld = (LinkageDescriptor*)*desc; if ( ld->getLinkageType() == 0xB0 ) { - linkage_service s; - s.m_onid = ld->getOriginalNetworkId(); - s.m_tsid = ld->getTransportStreamId(); - s.m_sid = ld->getServiceId(); - const PrivateDataByteVector *privateData = - ld->getPrivateDataBytes(); - s.m_description.assign((const char*)&((*privateData)[0]), privateData->size()); - m_linkage_services.push_back(s); + eServiceReference ref; + ref.type = eServiceReference::idDVB; + eServiceReferenceDVB &dvb_ref = (eServiceReferenceDVB&) ref; + dvb_ref.setServiceType(1); + dvb_ref.setTransportStreamID(ld->getTransportStreamId()); + dvb_ref.setOriginalNetworkID(ld->getOriginalNetworkId()); + dvb_ref.setServiceID(ld->getServiceId()); + const PrivateDataByteVector *privateData = ld->getPrivateDataBytes(); + dvb_ref.name = convertDVBUTF8((const char*)&((*privateData)[0]), privateData->size(), 0, tsidonid); + m_linkage_services.push_back(ref); } break; } @@ -199,4 +203,19 @@ RESULT eServiceEvent::getComponentData(ePtr<eComponentData> &dest, int tagnum) c return -1; } +RESULT eServiceEvent::getLinkageService(eServiceReference &service, int num) const +{ + std::list<eServiceReference>::const_iterator it = + m_linkage_services.begin(); + while( it != m_linkage_services.end() && num-- ) + ++it; + if ( it != m_linkage_services.end() ) + { + service = *it; + return 0; + } + service.type = eServiceReference::idInvalid; + return -1; +} + DEFINE_REF(eDebugClass); diff --git a/lib/service/event.h b/lib/service/event.h index d224c183..550d9a85 100644 --- a/lib/service/event.h +++ b/lib/service/event.h @@ -4,6 +4,7 @@ #ifndef SWIG #include <time.h> #include <lib/base/object.h> +#include <lib/service/iservice.h> #include <list> #include <string> class Event; @@ -28,28 +29,18 @@ DECLARE_REF(eComponentData); TEMPLATE_TYPEDEF(ePtr<eComponentData>, eComponentDataPtr); -struct linkage_service -{ - uint16_t m_sid; - uint16_t m_onid; - uint16_t m_tsid; - std::string m_description; -}; - class eServiceEvent: public iObject { -DECLARE_REF(eServiceEvent); -#ifndef SWIG + DECLARE_REF(eServiceEvent); bool loadLanguage(Event *event, std::string lang, int tsidonid); std::list<eComponentData> m_component_data; -#endif -public: -#ifndef SWIG - std::list<linkage_service> m_linkage_services; + std::list<eServiceReference> m_linkage_services; time_t m_begin; int m_duration; std::string m_event_name, m_short_description, m_extended_description; // .. additional info +public: +#ifndef SWIG RESULT parseFrom(Event *evt, int tsidonid=0); #endif time_t getBeginTime() const { return m_begin; } @@ -59,6 +50,8 @@ public: std::string getExtendedDescription() const { return m_extended_description; } std::string getBeginTimeString() const; SWIG_VOID(RESULT) getComponentData(ePtr<eComponentData> &SWIG_OUTPUT, int tagnum) const; + int getNumOfLinkageServices() const { return m_linkage_services.size(); } + SWIG_VOID(RESULT) getLinkageService(eServiceReference &SWIG_OUTPUT, int num) const; }; TEMPLATE_TYPEDEF(ePtr<eServiceEvent>, eServiceEventPtr); diff --git a/lib/service/iservice.h b/lib/service/iservice.h index dfd06693..4ec12153 100644 --- a/lib/service/iservice.h +++ b/lib/service/iservice.h @@ -3,11 +3,12 @@ #include <lib/python/swig.h> #include <lib/base/object.h> -#include <lib/service/event.h> #include <string> #include <connection.h> #include <list> +class eServiceEvent; + class eServiceReference { public: @@ -54,8 +55,8 @@ public: eServiceReference() : type(idInvalid), flags(0) { + memset(data, 0, sizeof(data)); } - eServiceReference(int type, int flags) : type(type), flags(flags) { @@ -181,8 +182,6 @@ public: TEMPLATE_TYPEDEF(ePtr<iStaticServiceInformation>, iStaticServiceInformationPtr); -class eServiceEvent; - TEMPLATE_TYPEDEF(ePtr<eServiceEvent>, eServiceEventPtr); class iServiceInformation: public iObject @@ -279,6 +278,15 @@ public: TEMPLATE_TYPEDEF(ePtr<iAudioTrackSelection>, iAudioTrackSelectionPtr); +class iSubserviceList: public iObject +{ +public: + virtual int getNumberOfSubservices()=0; + virtual SWIG_VOID(RESULT) getSubservice(eServiceReference &SWIG_OUTPUT, unsigned int n)=0; +}; + +TEMPLATE_TYPEDEF(ePtr<iSubserviceList>, iSubserviceListPtr); + class iPlayableService: public iObject { friend class iServiceHandler; @@ -300,6 +308,7 @@ public: virtual SWIG_VOID(RESULT) pause(ePtr<iPauseableService> &SWIG_OUTPUT)=0; virtual SWIG_VOID(RESULT) info(ePtr<iServiceInformation> &SWIG_OUTPUT)=0; virtual SWIG_VOID(RESULT) audioTracks(ePtr<iAudioTrackSelection> &SWIG_OUTPUT)=0; + virtual SWIG_VOID(RESULT) subServices(ePtr<iSubserviceList> &SWIG_OUTPUT)=0; virtual SWIG_VOID(RESULT) frontendStatusInfo(ePtr<iFrontendStatusInformation> &SWIG_OUTPUT)=0; }; diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 3cb5387a..307fb9f5 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -25,9 +25,40 @@ DEFINE_REF(eStaticServiceDVBInformation); RESULT eStaticServiceDVBInformation::getName(const eServiceReference &ref, std::string &name) { + eServiceReferenceDVB &service = (eServiceReferenceDVB&)ref; if ( !ref.name.empty() ) { - name = ref.name; + if (service.getParentTransportStreamID().get()) // linkage subservice + { + ePtr<iServiceHandler> service_center; + if (!eServiceCenter::getInstance(service_center)) + { + eServiceReferenceDVB parent = service; + parent.setTransportStreamID( service.getParentTransportStreamID() ); + parent.setServiceID( service.getParentServiceID() ); + parent.setParentTransportStreamID(eTransportStreamID(0)); + parent.setParentServiceID(eServiceID(0)); + parent.name=""; + ePtr<iStaticServiceInformation> service_info; + if (!service_center->info(parent, service_info)) + { + if (!service_info->getName(parent, name)) + { + // just show short name + unsigned int pos = name.find("\xc2\x86"); + if ( pos != std::string::npos ) + name.erase(0, pos+2); + pos = name.find("\xc2\x87"); + if ( pos != std::string::npos ) + name.erase(pos); + name+=" - "; + } + } + } + } + else + name=""; + name += ref.name; return 0; } else @@ -365,24 +396,19 @@ RESULT eServiceFactoryDVB::info(const eServiceReference &ref, ePtr<iStaticServic ptr = new eStaticServiceDVBInformation; else // a dvb bouquet ptr = new eStaticServiceDVBBouquetInformation; - return 0; } else if (!ref.path.empty()) /* do we have a PVR service? */ - { ptr = new eStaticServiceDVBPVRInformation(ref); - return 0; - } else // normal dvb service { ePtr<eDVBService> service; - int r = lookupService(service, ref); - if (r) // no eDVBService avail for this reference ( Linkage Services... ) + if (lookupService(service, ref)) // no eDVBService avail for this reference ( Linkage Services... ) ptr = new eStaticServiceDVBInformation; else /* eDVBService has the iStaticServiceInformation interface, so we pass it here. */ ptr = service; - return 0; } + return 0; } RESULT eServiceFactoryDVB::offlineOperations(const eServiceReference &ref, ePtr<iServiceOfflineOperations> &ptr) @@ -467,10 +493,16 @@ void eDVBServicePlay::serviceEvent(int event) ePtr<iDVBDemux> m_demux; if (!m_service_handler.getDemux(m_demux)) { -// eventStartedEventAcquisition - m_event_handler.start(m_demux, ((eServiceReferenceDVB&)m_reference).getServiceID().get()); + eServiceReferenceDVB &ref = (eServiceReferenceDVB&) m_reference; + int sid = ref.getParentServiceID().get(); + if (!sid) + sid = ref.getServiceID().get(); + if ( ref.getParentTransportStreamID().get() && + ref.getParentTransportStreamID() != ref.getTransportStreamID() ) + m_event_handler.startOther(m_demux, sid); + else + m_event_handler.start(m_demux, sid); } -// eventNoEvent break; } case eDVBServicePMTHandler::eventTuneFailed: @@ -699,6 +731,12 @@ RESULT eDVBServicePlay::audioTracks(ePtr<iAudioTrackSelection> &ptr) return 0; } +RESULT eDVBServicePlay::subServices(ePtr<iSubserviceList> &ptr) +{ + ptr = this; + return 0; +} + RESULT eDVBServicePlay::getName(std::string &name) { if (m_dvb_service) @@ -706,7 +744,10 @@ RESULT eDVBServicePlay::getName(std::string &name) m_dvb_service->getName(m_reference, name); if (name.empty()) name = "(...)"; - } else + } + else if (!m_reference.name.empty()) + eStaticServiceDVBInformation().getName(m_reference, name); + else name = "DVB service"; return 0; } @@ -841,6 +882,47 @@ int eDVBServicePlay::getFrontendInfo(int w) return fe->readFrontendData(w); } +int eDVBServicePlay::getNumberOfSubservices() +{ + ePtr<eServiceEvent> evt; + if (!m_event_handler.getEvent(evt, 0)) + return evt->getNumOfLinkageServices(); + return 0; +} + +RESULT eDVBServicePlay::getSubservice(eServiceReference &sub, unsigned int n) +{ + ePtr<eServiceEvent> evt; + if (!m_event_handler.getEvent(evt, 0)) + { + if (!evt->getLinkageService(sub, n)) + { + eServiceReferenceDVB &subservice = (eServiceReferenceDVB&) sub; + eServiceReferenceDVB ¤t = (eServiceReferenceDVB&) m_reference; + subservice.setDVBNamespace(current.getDVBNamespace()); + if ( current.getParentTransportStreamID().get() ) + { + subservice.setParentTransportStreamID( current.getParentTransportStreamID() ); + subservice.setParentServiceID( current.getParentServiceID() ); + } + else + { + subservice.setParentTransportStreamID( current.getTransportStreamID() ); + subservice.setParentServiceID( current.getServiceID() ); + } + if ( subservice.getParentTransportStreamID() == subservice.getTransportStreamID() && + subservice.getParentServiceID() == subservice.getServiceID() ) + { + subservice.setParentTransportStreamID( eTransportStreamID(0) ); + subservice.setParentServiceID( eServiceID(0) ); + } + return 0; + } + } + sub.type=eServiceReference::idInvalid; + return -1; +} + DEFINE_REF(eDVBServicePlay) eAutoInitPtr<eServiceFactoryDVB> init_eServiceFactoryDVB(eAutoInitNumbers::service+1, "eServiceFactoryDVB"); diff --git a/lib/service/servicedvb.h b/lib/service/servicedvb.h index 4b6ef3e1..5f851357 100644 --- a/lib/service/servicedvb.h +++ b/lib/service/servicedvb.h @@ -54,7 +54,8 @@ private: class eDVBServicePlay: public iPlayableService, public iPauseableService, public iSeekableService, public Object, public iServiceInformation, - public iAudioTrackSelection, public iFrontendStatusInformation + public iAudioTrackSelection, public iFrontendStatusInformation, + public iSubserviceList { DECLARE_REF(eDVBServicePlay); public: @@ -69,7 +70,8 @@ public: RESULT info(ePtr<iServiceInformation> &ptr); RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr); RESULT frontendStatusInfo(ePtr<iFrontendStatusInformation> &ptr); - + RESULT subServices(ePtr<iSubserviceList> &ptr); + // iPauseableService RESULT pause(); RESULT unpause(); @@ -94,6 +96,10 @@ public: // iFrontendStatusInformation int getFrontendInfo(int w); + // iSubserviceList + int getNumberOfSubservices(); + RESULT getSubservice(eServiceReference &subservice, unsigned int n); + private: friend class eServiceFactoryDVB; eServiceReference m_reference; diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 8f999471..7bd4244f 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -146,17 +146,30 @@ RESULT eServiceMP3::stop() return 0; } -RESULT eServiceMP3::pause(ePtr<iPauseableService> &ptr) { ptr=this; return 0; } -RESULT eServiceMP3::seek(ePtr<iSeekableService> &ptr) { ptr = 0; return -1; } - -RESULT eServiceMP3::frontendStatusInfo(ePtr<iFrontendStatusInformation> &ptr) { ptr = 0; return -1; } -RESULT eServiceMP3::audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return -1; }; +RESULT eServiceMP3::pause(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::pause() +{ + printf("mp3 pauses!\n"); + return 0; +} -RESULT eServiceMP3::info(ePtr<iServiceInformation>&i) { i = this; return 0; } +RESULT eServiceMP3::unpause() +{ + printf("mp3 unpauses!\n"); + return 0; +} + +RESULT eServiceMP3::info(ePtr<iServiceInformation>&i) +{ + i = this; + return 0; +} RESULT eServiceMP3::getName(std::string &name) { diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h index 9f1a8e9f..dfdaa44c 100644 --- a/lib/service/servicemp3.h +++ b/lib/service/servicemp3.h @@ -56,9 +56,11 @@ public: RESULT start(); RESULT stop(); RESULT pause(ePtr<iPauseableService> &ptr); - RESULT seek(ePtr<iSeekableService> &ptr); - RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr); - RESULT frontendStatusInfo(ePtr<iFrontendStatusInformation> &ptr); + // not implemented (yet) + RESULT seek(ePtr<iSeekableService> &ptr) { ptr = 0; return -1; } + RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return -1; } + RESULT frontendStatusInfo(ePtr<iFrontendStatusInformation> &ptr) { ptr = 0; return -1; } + RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; } // iPausableService RESULT pause(); |
