Exemplo n.º 1
0
void eDVBServicePMTHandler::PATready(int)
{
	eDebug("PATready");
	ePtr<eTable<ProgramAssociationSection> > ptr;
	if (!m_PAT.getCurrent(ptr))
	{
		int service_id_single = -1;
		int pmtpid_single = -1;
		int pmtpid = -1;
		int cnt=0;
		int tsid=-1;
		std::vector<ProgramAssociationSection*>::const_iterator i = ptr->getSections().begin();
		tsid = (*i)->getTableIdExtension(); // in PAT this is the transport stream id
		eDebug("PAT TSID: 0x%04x (%d)", tsid, tsid);
		for (i = ptr->getSections().begin(); pmtpid == -1 && i != ptr->getSections().end(); ++i)
		{
			const ProgramAssociationSection &pat = **i;
			ProgramAssociationConstIterator program;
			for (program = pat.getPrograms()->begin(); pmtpid == -1 && program != pat.getPrograms()->end(); ++program)
			{
				if (eServiceID((*program)->getProgramNumber()) == m_reference.getServiceID())
					pmtpid = (*program)->getProgramMapPid();
				if (++cnt == 1 && pmtpid_single == -1 && pmtpid == -1)
				{
					pmtpid_single = (*program)->getProgramMapPid();
					service_id_single = (*program)->getProgramNumber();
				}
				else
					pmtpid_single = service_id_single = -1;
			}
		}
		if (pmtpid_single != -1) // only one PAT entry .. and not valid pmtpid found
		{
			eDebug("use single pat entry!");
			m_reference.setServiceID(eServiceID(service_id_single));
			pmtpid = pmtpid_single;
		}
		if (pmtpid == -1) {
			eDebug("no PAT entry found.. start delay");
			m_no_pat_entry_delay->start(1000, true);
		}
		else {
			eDebug("use pmtpid %04x for service_id %04x", pmtpid, m_reference.getServiceID().get());
			m_no_pat_entry_delay->stop();
			m_PMT.begin(eApp, eDVBPMTSpec(pmtpid, m_reference.getServiceID().get()), m_demux);
		}
	} else
		serviceEvent(eventNoPAT);
}
Exemplo n.º 2
0
RESULT eServiceEvent::getLinkageService(eServiceReference &service, eServiceReference &parent, 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;
		eServiceReferenceDVB &subservice = (eServiceReferenceDVB&) service;
		eServiceReferenceDVB &current = (eServiceReferenceDVB&) parent;
		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;
	}
	service.type = eServiceReference::idInvalid;
	return -1;
}
Exemplo n.º 3
0
void eDVBServiceController::FillPIDsFromFile(eService *sp)
{
	if (service.path)
	{
		eDebug("fill PIDs for %s", service.path.c_str());
		int fd=open(service.path.c_str(), O_RDONLY|O_LARGEFILE);
		if (fd >= 0)
		{
			__u8 packet[188];
			do
			{
				if (::read(fd, packet, 188) != 188)
					break;
				// i know that THIS is not really a SIT parser :)
				if ((packet[0] != 0x47) || (packet[1] != 0x40) || (packet[2] != 0x1f) || (packet[3] != 0x10))
					break;
				int nameoffset = 6;
				if (memcmp(packet+0x15, "ENIGMA", 6))
				{
					//failed so check another
					if (!memcmp(packet+0x15, "NEUTRINONG", 10))
						nameoffset = 10;
					else
						break;
				}
				// we found our private descriptor:
				__u8 *descriptor=packet+0x13;
				int len=descriptor[1];
				sp->dvb->service_id = eServiceID((packet[0xf]<<8)|packet[0x10]);
				len-=nameoffset;
				descriptor+=2+nameoffset; // skip tag, len, ENIGMA or NEUTRINONG
				for (int i=0; i<len; i+=descriptor[i+1]+2)
				{
					int tag=descriptor[i];
					switch (tag)
					{
						case eServiceDVB::cVPID:
							sp->dvb->set(eServiceDVB::cVPID, (descriptor[i+2]<<8)|(descriptor[i+3]));
							break;
						case eServiceDVB::cAPID:
							if (descriptor[i+4] == 0)
								sp->dvb->set(eServiceDVB::cAPID, (descriptor[i+2]<<8)|(descriptor[i+3]));
							else
								sp->dvb->set(eServiceDVB::cAC3PID, (descriptor[i+2]<<8)|(descriptor[i+3]));
							break;
						case eServiceDVB::cTPID:
							sp->dvb->set(eServiceDVB::cTPID, (descriptor[i+2]<<8)|(descriptor[i+3]));
							break;
						case eServiceDVB::cPCRPID:
							sp->dvb->set(eServiceDVB::cPCRPID, (descriptor[i+2]<<8)|(descriptor[i+3]));
							break;
					}
				}
			} while (0);
			close(fd);
		}
	}
}
Exemplo n.º 4
0
void eEventDisplay::setEPGSearchEvent(eServiceReferenceDVB &Ref, EITEvent *event, eString Service)
{
	ref = Ref;
	service = Service;
	time_t time = event->start_time+event->duration/2;

	EITEvent *tmp = event->event_id != -1 ? eEPGCache::getInstance()->lookupEvent( ref, event->event_id ) : 0;
	if ( !tmp )
		tmp = eEPGCache::getInstance()->lookupEvent( ref, time );
	evt = tmp;
	valid=0;
	long_description->hide();
	long_description->move( ePoint(0,0) );
	if (evt)
	{
		eString _title=0, _long_description="";
		eString _eventDate="";
		eString _eventTime="";
		tm *begin=event->start_time!=-1?localtime(&event->start_time):0;
		if (begin)
		{
			valid |= 1;
			_eventTime.sprintf("%02d:%02d", begin->tm_hour, begin->tm_min);
			_eventDate=eString().sprintf("%02d.%02d.%4d", begin->tm_mday, begin->tm_mon+1, begin->tm_year+1900);
		}
		time_t endtime=event->start_time+event->duration;
		tm *end=event->start_time!=-1?localtime(&endtime):0;
		if (end)
		{
			valid |= 2;
			_eventTime+=eString().sprintf(" - %02d:%02d", end->tm_hour, end->tm_min);
		}
		for (ePtrList<Descriptor>::iterator d(evt->descriptor); d != evt->descriptor.end(); ++d)
		{
			if (d->Tag()==DESCR_SHORT_EVENT)
			{
				ShortEventDescriptor *s=(ShortEventDescriptor*)*d;
				valid |= 4;
				_title=s->event_name;
#ifndef DISABLE_LCD
				if (LCDElement)
				LCDElement->setText(s->text);
#endif
				if ((s->text.length() > 0) && (s->text!=_title))
				{
					valid |= 8;
					_long_description+=s->text;
					_long_description+="\n\n";
				}
			}
			else if (d->Tag()==DESCR_EXTENDED_EVENT)
			{
				ExtendedEventDescriptor *ss=(ExtendedEventDescriptor*)*d;
				valid |= 16;
				_long_description+=ss->text;
			}
			else if (d->Tag() == DESCR_LINKAGE)
			{
				if ( !ref.path )
				{
					LinkageDescriptor *ld=(LinkageDescriptor*)*d;
					if (ld->linkage_type==0xB0)
					{
						eServiceReferenceDVB MySubService(ref.getDVBNamespace(),
							eTransportStreamID(ld->transport_stream_id),
							eOriginalNetworkID(ld->original_network_id),
							eServiceID(ld->service_id), 7);
						ref = MySubService;
					}
				}
			}
		}
		if (!_title)
			_title = _("no information is available");
		if ( !ref.path )
			channel->setText(service);
		eventTime->setText(_eventTime);
		eventDate->setText(_eventDate);
		setText(_title);
		if (!_long_description)
			long_description->setText(_("no description is available"));
		else
			long_description->setText(_long_description);
		checkTimerIcon(evt);
	}
	else
	{
		setText(service);
		long_description->setText(_("no description is available"));
	}
	updateScrollbar();
	long_description->show();
}
Exemplo n.º 5
0
std::string eRTSPStreamClient::searchServiceRef(int sys, int freq, int pol, int orbital_position, int sid)
{
	eDebug("start %s", __FUNCTION__);
	eDVBFrontendParametersSatellite sat1;
	eDVBFrontendParametersTerrestrial ter1;
	eDVBFrontendParametersCable cab1;
	int found = 0;
	memset(&sat, 0, sizeof(sat));
	memset(&ter, 0, sizeof(ter));
	memset(&cab, 0, sizeof(cab));
	const eServiceReferenceDVB *srvc = NULL;
	for (std::map<eServiceReferenceDVB, ePtr<eDVBService>>::iterator i(m_dvbdb->m_services.begin());
		 i != m_dvbdb->m_services.end(); ++i)
	{
		found = 0;
		unsigned int flags = 0;
		eDVBChannelID chid;
		ePtr<iDVBFrontendParameters> p;
		const eServiceReferenceDVB &s = i->first;
		s.getChannelID(chid);
		m_dvbdb->getChannelFrontendData(chid, p);
		flags = i->second->m_flags;
		if (!p)
			continue;
		if (!p->getDVBS(sat1) && ((sys == SYS_DVBS) || (sys == SYS_DVBS2)))
		{
			//			eDebug("freq = %d, sat.freq %d, OP %d, SOP %d, pol %d pol %d", freq, sat1.frequency, orbital_position, sat1.orbital_position, pol, sat1.polarisation);
			if ((absdiff(sat1.frequency, freq) < 2000) && sat1.polarisation == pol && orbital_position == sat1.orbital_position)
			{
				sat = sat1;
				eDebug("Adding %s to the list for frequency %d (%s) f:%x", s.toString().c_str(), sat.frequency, i->second->m_service_name.c_str(), flags);
				srvc = &i->first;
				found = 1;
			}
		}

		if (!p->getDVBT(ter1) && ((sys == SYS_DVBT) || (sys == SYS_DVBT2)))
		{
			if ((absdiff(ter1.frequency / 1000, freq) < 2000))
			{
				ter = ter1;
				eDebug("Adding %s to the list (%s) f:%x", s.toString().c_str(), i->second->m_service_name.c_str(), flags);
				srvc = &i->first;
				found = 1;
			}
		}
#ifdef SYS_DVBC_ANNEX_A
		if (!p->getDVBC(cab1) && ((sys == SYS_DVBC_ANNEX_A) || (sys == SYS_DVBC2)))
#else
		if (!p->getDVBC(cab1) && ((sys == SYS_DVBC_ANNEX_AC) || (sys == SYS_DVBC2)))
#endif
		{
			if ((absdiff(cab1.frequency, freq) < 2000))
			{
				cab = cab1;
				eDebug("Adding %s to the list (%s) f:%x", s.toString().c_str(), i->second->m_service_name.c_str(), flags);
				srvc = &i->first;
				found = 1;
			}
		}

		std::set<eServiceReferenceDVB>::iterator it = processed_sr.find(s);
		int not_available = (it == processed_sr.end());
		if (found)
		{
			if (addCachedPids(i->second, s))
			{
				if (not_available)
				{
					eDebug("SR %s does not have cached pids", s.toString().c_str());
					not_cached_sr.insert(s);
				}
				else
					eDebug("SR %s was already attempted and does not have cached pids, not adding", s.toString().c_str());
			}
		}
	}
	if (srvc)
	{
		//		return srvc->toString();
		const eServiceReferenceDVB srv(srvc->getDVBNamespace(), srvc->getTransportStreamID(), srvc->getOriginalNetworkID(), eServiceID(sid), srvc->getServiceType(), srvc->getSourceID());
		return srv.toString();
	}
	eDebug("end %s", __FUNCTION__);
	return "";
}
Exemplo n.º 6
0
static eServiceReferenceDVB getServiceByID(const char *id)
{
	eTransponderList *tl=eDVB::getInstance()->settings->getTransponders();
	if (!tl)
		return eServiceReferenceDVB();
	int dvb_namespace, original_network_id, transport_stream_id, service_id, service_type;
	if (sscanf(id, "S:%x:%x:%x:%x:%x", &dvb_namespace, &original_network_id, &transport_stream_id, &service_id, &service_type)!=4)
		if (sscanf(id, "E:%x:%x:%x:%x:%x", &dvb_namespace, &original_network_id, &transport_stream_id, &service_id, &service_type)!=4)
			return eServiceReferenceDVB();

	return eServiceReferenceDVB(eDVBNamespace(dvb_namespace), eTransportStreamID(transport_stream_id), eOriginalNetworkID(original_network_id), eServiceID(service_id), service_type);
}
Exemplo n.º 7
0
eService *eServiceHandlerDVB::createService(const eServiceReference &node)
{
#ifndef DISABLE_FILE
	if (node.data[0]>=0)
	{
		eString l=node.path.mid(node.path.rfind('/')+1);
		if (!isUTF8(l))
			l=convertLatin1UTF8(l);
		if (node.descr)
			l=node.descr;
/* moved to dvbservice.cpp, function eDVBServiceController::FillPIDsFromFile
		int fd=open(node.path.c_str(), O_RDONLY|O_LARGEFILE);
		if (fd < 0)
			return 0;
		__u8 packet[188];
		eServiceDVB *dvb=0;
		do
		{
			if (::read(fd, packet, 188) != 188)
				break;
				// i know that THIS is not really a SIT parser :)
			if ((packet[0] != 0x47) || (packet[1] != 0x40) || (packet[2] != 0x1f) || (packet[3] != 0x10))
				break;
			int nameoffset = 6;
			if (memcmp(packet+0x15, "ENIGMA", 6))
			{
				//failed so check another
				if (!memcmp(packet+0x15, "NEUTRINONG", 10))
					nameoffset = 10;
				else
					break;
			}
			// we found our private descriptor:
			__u8 *descriptor=packet+0x13;
			int len=descriptor[1];
			dvb=new eServiceDVB(eServiceID((packet[0xf]<<8)|packet[0x10]), l.c_str());
			len-=nameoffset;
			descriptor+=2+nameoffset; // skip tag, len, ENIGMA or NEUTRINONG
			for (int i=0; i<len; i+=descriptor[i+1]+2)
			{
				int tag=descriptor[i];
				switch (tag)
				{
				case eServiceDVB::cVPID:
					dvb->set(eServiceDVB::cVPID, (descriptor[i+2]<<8)|(descriptor[i+3]));
					break;
				case eServiceDVB::cAPID:
					if (descriptor[i+4] == 0)
						dvb->set(eServiceDVB::cAPID, (descriptor[i+2]<<8)|(descriptor[i+3]));
					else
						dvb->set(eServiceDVB::cAC3PID, (descriptor[i+2]<<8)|(descriptor[i+3]));
					break;
				case eServiceDVB::cTPID:
					dvb->set(eServiceDVB::cTPID, (descriptor[i+2]<<8)|(descriptor[i+3]));
					break;
				case eServiceDVB::cPCRPID:
					dvb->set(eServiceDVB::cPCRPID, (descriptor[i+2]<<8)|(descriptor[i+3]));
					break;
				}
			}
		} while (0);
		close(fd);
		if (!dvb)
			return new eService(l);
		return dvb;
*/
		return new eServiceDVB(eServiceID(), l.c_str());
	}
#endif // DISABLE_FILE
	switch (node.data[0])
	{
	case -1: // for satellites...
	{
	    eSatellite *sat = eTransponderList::getInstance()->findSatellite(node.data[2] >> 16 );
	    if (!sat)
			return 0;
		else
			return new eService( eString().sprintf("%s - %s",sat->getDescription().c_str(),_("Providers")));
	}
	case -2: // for satellites...
	{
	    eSatellite *sat = eTransponderList::getInstance()->findSatellite(node.data[2] >> 16 );
	    if (!sat)
			return 0;
		else
			return new eService( eString().sprintf("%s - %s",sat->getDescription().c_str(),_("Services")));
	}
	case -5: // for satellites...
	{
	    eSatellite *sat = eTransponderList::getInstance()->findSatellite(node.data[2] >> 16 );
	    if (!sat)
			return 0;
		else
			return new eService( eString().sprintf("%s - %s",sat->getDescription().c_str(),_("new found")));
	}
	case -6: 
	{
		return new eService( _("current transponder"));
	}
	case -3:
	{
		eBouquet *b=eDVB::getInstance()->settings->getBouquet(node.data[2]);
		if (!b)
			return 0;
		return new eService(b->bouquet_name.c_str());
	}
	}
	return 0;
}