X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/e5f1c45c07b1ff43c0113a51128f60bd3e348aa4..75b5dff4878843dec6913364bc044ab25c3b78a2:/lib/service/servicedvb.cpp diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 871a0b26..24a91966 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -39,6 +39,7 @@ class eStaticServiceDVBInformation: public iStaticServiceInformation public: RESULT getName(const eServiceReference &ref, std::string &name); int getLength(const eServiceReference &ref); + int isPlayable(const eServiceReference &ref, const eServiceReference &ignore); }; DEFINE_REF(eStaticServiceDVBInformation); @@ -90,13 +91,20 @@ int eStaticServiceDVBInformation::getLength(const eServiceReference &ref) return -1; } -class eStaticServiceDVBBouquetInformation: public iStaticServiceInformation +int eStaticServiceDVBInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore) { - DECLARE_REF(eStaticServiceDVBBouquetInformation); -public: - RESULT getName(const eServiceReference &ref, std::string &name); - int getLength(const eServiceReference &ref); -}; + ePtr res_mgr; + if ( eDVBResourceManager::getInstance( res_mgr ) ) + eDebug("isPlayble... no res manager!!"); + else + { + eDVBChannelID chid, chid_ignore; + ((const eServiceReferenceDVB&)ref).getChannelID(chid); + ((const eServiceReferenceDVB&)ignore).getChannelID(chid_ignore); + return res_mgr->canAllocateChannel(chid, chid_ignore); + } + return false; +} DEFINE_REF(eStaticServiceDVBBouquetInformation); @@ -133,11 +141,64 @@ RESULT eStaticServiceDVBBouquetInformation::getName(const eServiceReference &ref return -1; } +int eStaticServiceDVBBouquetInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore) +{ + if (ref.flags & eServiceReference::isGroup) + { + ePtr db; + ePtr res; + + if (eDVBResourceManager::getInstance(res)) + { + eDebug("eStaticServiceDVBBouquetInformation::isPlayable failed.. no resource manager!"); + return 0; + } + + if (res->getChannelList(db)) + { + eDebug("eStaticServiceDVBBouquetInformation::isPlayable failed.. no channel list!"); + return 0; + } + + eBouquet *bouquet=0; + if (db->getBouquet(ref, bouquet)) + { + eDebug("eStaticServiceDVBBouquetInformation::isPlayable failed.. getBouquet failed!"); + return 0; + } + + int cur=0; + eDVBChannelID chid, chid_ignore; + ((const eServiceReferenceDVB&)ignore).getChannelID(chid_ignore); + for (std::list::iterator it(bouquet->m_services.begin()); it != bouquet->m_services.end(); ++it) + { + ((const eServiceReferenceDVB&)*it).getChannelID(chid); + int tmp=res->canAllocateChannel(chid, chid_ignore); + if (tmp > cur) + { + m_playable_service = *it; + cur = tmp; + } + } + if (cur) + return cur; + } + m_playable_service = eServiceReference(); + return 0; +} + int eStaticServiceDVBBouquetInformation::getLength(const eServiceReference &ref) { return -1; } +#include + +RESULT eStaticServiceDVBBouquetInformation::getEvent(const eServiceReference &ref, ePtr &ptr, time_t start_time) +{ + return eEPGCache::getInstance()->lookupEventTime(ref, start_time, ptr); +} + class eStaticServiceDVBPVRInformation: public iStaticServiceInformation { DECLARE_REF(eStaticServiceDVBPVRInformation); @@ -148,7 +209,7 @@ public: RESULT getName(const eServiceReference &ref, std::string &name); int getLength(const eServiceReference &ref); RESULT getEvent(const eServiceReference &ref, ePtr &SWIG_OUTPUT, time_t start_time); - + int isPlayable(const eServiceReference &ref, const eServiceReference &ignore) { return 1; } int getInfo(const eServiceReference &ref, int w); std::string getInfoString(const eServiceReference &ref,int w); }; @@ -491,7 +552,7 @@ RESULT eDVBServiceList::getNext(eServiceReference &ref) RESULT eDVBServiceList::startEdit(ePtr &res) { - if (m_parent.flags & eServiceReference::flagDirectory) // bouquet + if (m_parent.flags & eServiceReference::canDescent) // bouquet { ePtr db; ePtr resm; @@ -585,7 +646,7 @@ RESULT eServiceFactoryDVB::list(const eServiceReference &ref, ePtr &ptr) { /* is a listable service? */ - if ((ref.flags & eServiceReference::flagDirectory) == eServiceReference::flagDirectory) // bouquet + if (ref.flags & eServiceReference::canDescent) // bouquet { if ( !ref.name.empty() ) // satellites or providers list ptr = m_StaticServiceDVBInfo; @@ -653,6 +714,7 @@ RESULT eServiceFactoryDVB::lookupService(ePtr &service, const eServ eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref, eDVBService *service): m_reference(ref), m_dvb_service(service), m_have_video_pid(0), m_is_paused(0) { + memset(&m_videoEventData, 0, sizeof(struct iTSMPEGDecoder::videoEvent)); m_is_primary = 1; m_is_pvr = !m_reference.path.empty(); @@ -668,6 +730,8 @@ eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref, eDVBService *serv m_subtitle_widget = 0; + m_tune_state = -1; + CONNECT(m_subtitle_sync_timer.timeout, eDVBServicePlay::checkSubtitleTiming); } @@ -694,6 +758,8 @@ void eDVBServicePlay::gotNewEvent() void eDVBServicePlay::serviceEvent(int event) { + m_tune_state = event; + switch (event) { case eDVBServicePMTHandler::eventTuned: @@ -713,9 +779,12 @@ void eDVBServicePlay::serviceEvent(int event) } break; } + case eDVBServicePMTHandler::eventNoPAT: + case eDVBServicePMTHandler::eventNoPATEntry: + case eDVBServicePMTHandler::eventNoPMT: case eDVBServicePMTHandler::eventTuneFailed: { - eDebug("DVB service failed to tune"); + eDebug("DVB service failed to tune - error %d", event); m_event((iPlayableService*)this, evTuneFailed); break; } @@ -1149,19 +1218,42 @@ RESULT eDVBServicePlay::getEvent(ePtr &evt, int nownext) int eDVBServicePlay::getInfo(int w) { eDVBServicePMTHandler::program program; - + if (w == sCAIDs) return resIsPyObject; eDVBServicePMTHandler &h = m_timeshift_active ? m_service_handler_timeshift : m_service_handler; + int no_program_info = 0; + if (h.getProgramInfo(program)) - return -1; + no_program_info = 1; switch (w) { +#if HAVE_DVB_API_VERSION >= 3 + case sVideoHeight: + if (m_videoEventData.type != iTSMPEGDecoder::videoEvent::eventUnknown) + return m_videoEventData.height; + return -1; + case sVideoWidth: + if (m_videoEventData.type != iTSMPEGDecoder::videoEvent::eventUnknown) + return m_videoEventData.width; + return -1; +#else +#warning "FIXMEE implement sVideoHeight, sVideoWidth for old DVB API" +#endif case sAspect: - if (!program.videoStreams.empty() && program.videoStreams[0].component_tag != -1) +#if HAVE_DVB_API_VERSION >= 3 + if (m_videoEventData.type != iTSMPEGDecoder::videoEvent::eventUnknown) + return m_videoEventData.aspect == VIDEO_FORMAT_4_3 ? 1 : 3; + else +#else +#warning "FIXMEE implement sAspect for old DVB API" +#endif + if (no_program_info) + return -1; + else if (!program.videoStreams.empty() && program.videoStreams[0].component_tag != -1) { ePtr evt; if (!m_event_handler.getEvent(evt, 0)) @@ -1199,18 +1291,20 @@ int eDVBServicePlay::getInfo(int w) } } return -1; - case sIsCrypted: return program.isCrypted(); - case sVideoPID: if (program.videoStreams.empty()) return -1; return program.videoStreams[0].pid; - case sVideoType: if (program.videoStreams.empty()) return -1; return program.videoStreams[0].type; - case sAudioPID: if (program.audioStreams.empty()) return -1; return program.audioStreams[0].pid; - case sPCRPID: return program.pcrPid; - case sPMTPID: return program.pmtPid; - case sTXTPID: return program.textPid; + case sIsCrypted: if (no_program_info) return -1; return program.isCrypted(); + case sVideoPID: if (no_program_info) return -1; if (program.videoStreams.empty()) return -1; return program.videoStreams[0].pid; + case sVideoType: if (no_program_info) return -1; if (program.videoStreams.empty()) return -1; return program.videoStreams[0].type; + case sAudioPID: if (no_program_info) return -1; if (program.audioStreams.empty()) return -1; return program.audioStreams[0].pid; + case sPCRPID: if (no_program_info) return -1; return program.pcrPid; + case sPMTPID: if (no_program_info) return -1; return program.pmtPid; + case sTXTPID: if (no_program_info) return -1; return program.textPid; case sSID: return ((const eServiceReferenceDVB&)m_reference).getServiceID().get(); case sONID: return ((const eServiceReferenceDVB&)m_reference).getOriginalNetworkID().get(); case sTSID: return ((const eServiceReferenceDVB&)m_reference).getTransportStreamID().get(); case sNamespace: return ((const eServiceReferenceDVB&)m_reference).getDVBNamespace().get(); case sProvider: if (!m_dvb_service) return -1; return -2; + case sServiceref: return resIsString; + case sDVBState: return m_tune_state; default: return -1; } @@ -1223,6 +1317,8 @@ std::string eDVBServicePlay::getInfoString(int w) case sProvider: if (!m_dvb_service) return ""; return m_dvb_service->m_provider_name; + case sServiceref: + return m_reference.toString(); default: break; } @@ -1753,7 +1849,11 @@ void eDVBServicePlay::updateDecoder() { h.getDecodeDemux(m_decode_demux); if (m_decode_demux) + { m_decode_demux->getMPEGDecoder(m_decoder, m_is_primary); + if (m_decoder) + m_decoder->connectVideoEvent(slot(*this, &eDVBServicePlay::video_event), m_video_event_connection); + } if (m_cue) m_cue->setDecodingDemux(m_decode_demux, m_decoder); m_teletext_parser = new eDVBTeletextParser(m_decode_demux); @@ -2333,6 +2433,13 @@ void eDVBServicePlay::setPCMDelay(int delay) m_decoder->setPCMDelay(delay); } +void eDVBServicePlay::video_event(struct iTSMPEGDecoder::videoEvent event) +{ + eDebug("!!!!!!!!!! Video Event type %d, aspect %d, %dx%d", event.type, event.aspect, event.width, event.height); + memcpy(&m_videoEventData, &event, sizeof(iTSMPEGDecoder::videoEvent)); + m_event((iPlayableService*)this, evVideoSizeChanged); +} + DEFINE_REF(eDVBServicePlay) eAutoInitPtr init_eServiceFactoryDVB(eAutoInitNumbers::service+1, "eServiceFactoryDVB");