Пример #1
0
RESULT eDVBScan::nextChannel()
{
	ePtr<iDVBFrontend> fe;

	m_SDT = 0; m_PAT = 0; m_BAT = 0; m_NIT = 0, m_PMT = 0;

	m_ready = 0;

	m_pat_tsid = eTransportStreamID();

		/* check what we need */
	m_ready_all = readySDT;

	if (m_flags & scanNetworkSearch)
		m_ready_all |= readyNIT;

	if (m_flags & scanSearchBAT)
		m_ready_all |= readyBAT;

	if (m_usePAT)
		m_ready_all |= readyPAT;

	if (!m_ch_blindscan.empty())
	{
		/* keep iterating with the same 'channel' till we get a tune failure */
		SCAN_eDebug("[eDVBScan] blindscan channel iteration");
		m_ch_current = m_ch_blindscan.front();
	}
	else
	{
		m_ch_blindscan_result = NULL;
		if (m_ch_toScan.empty())
		{
			SCAN_eDebug("[eDVBScan] no channels left: %zd scanned, %zd unavailable, %zd database.",
				m_ch_scanned.size(), m_ch_unavailable.size(), m_new_channels.size());
			m_event(evtFinish);
			return -ENOENT;
		}

		m_ch_current = m_ch_toScan.front();

		m_ch_toScan.pop_front();
	}

	if (m_channel->getFrontend(fe))
	{
		m_event(evtFail);
		return -ENOTSUP;
	}

	m_chid_current = eDVBChannelID();

	m_channel_state = iDVBChannel::state_idle;

	if (fe->tune(*m_ch_current, !m_ch_blindscan.empty()))
		return nextChannel();

	m_event(evtUpdate);
	return 0;
}
Пример #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;
}
Пример #3
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);
}
Пример #4
0
RESULT eDVBScan::nextChannel()
{
	ePtr<iDVBFrontend> fe;

	m_SDT = 0; m_PAT = 0; m_BAT = 0; m_NIT = 0, m_PMT = 0;

	m_ready = 0;

	m_pat_tsid = eTransportStreamID();

		/* check what we need */
	m_ready_all = readySDT;

	if (m_flags & scanNetworkSearch)
		m_ready_all |= readyNIT;

	if (m_flags & scanSearchBAT)
		m_ready_all |= readyBAT;

	if (m_usePAT)
		m_ready_all |= readyPAT;

	if (m_ch_toScan.empty())
	{
		SCAN_eDebug("[eDVBScan] no channels left to scan.");
		SCAN_eDebug("[eDVBScan] %zd channels scanned, %zd were unavailable.",
				m_ch_scanned.size(), m_ch_unavailable.size());
		SCAN_eDebug("[eDVBScan] %zd channels in database.", m_new_channels.size());
		m_event(evtFinish);
		return -ENOENT;
	}

	m_ch_current = m_ch_toScan.front();

	m_ch_toScan.pop_front();

	if (m_channel->getFrontend(fe))
	{
		m_event(evtFail);
		return -ENOTSUP;
	}

	m_chid_current = eDVBChannelID();

	m_channel_state = iDVBChannel::state_idle;

	if (fe->tune(*m_ch_current))
		return nextChannel();

	m_event(evtUpdate);
	return 0;
}
Пример #5
0
RESULT eServiceTS::start()
{
	ePtr<eDVBResourceManager> rmgr;
	eDVBResourceManager::getInstance(rmgr);
	// FIXMEE hardcoded chid... this only works for one eServiceWebTS
	eDVBChannelID chid;
	chid.dvbnamespace = eDVBNamespace(0);
	chid.transport_stream_id = eTransportStreamID(0);
	chid.original_network_id = eOriginalNetworkID(0);
	chid.pvr_source = "/eServiceTS";
	if (rmgr->allocateChannel(chid, m_channel)) {
		eDebug("Cannot allocate pvr channel");
		return -1;
	}
	if (m_channel->getDemux(m_decodedemux, iDVBChannel::capDecode) != 0) {
		eDebug("Cannot allocate decode-demux");
		return -1;
	}
	if (m_decodedemux->getMPEGDecoder(m_decoder, 1) != 0) {
		eDebug("Cannot allocate MPEGDecoder");
		return -1;
	}
	if (m_destfd == -1)
	{
		m_destfd = m_decodedemux->openDVR(O_WRONLY);
		if (m_destfd < 0)
		{
			eDebug("openDVR failed");
			return -1;
		}
	}
	m_decoder->setVideoPID(m_vpid, eDVBVideo::MPEG2);
	m_decoder->setAudioPID(m_apid, eDVBAudio::aMPEG);
	m_streamthread = new eStreamThread();
	CONNECT(m_streamthread->m_event, eServiceTS::recv_event);
	m_decoder->pause();
	if (unpause() != 0) 
		return -1;
	m_event(this, evStart);
	return 0;
}
Пример #6
0
RESULT eDVBScan::startFilter()
{
	bool startSDT=true;
	int system;
	ASSERT(m_demux);

			/* only start required filters filter */

	if (m_ready_all & readyPAT)
		startSDT = m_ready & readyPAT;

	// m_ch_current is not set, when eDVBScan is just used for a SDT update
	if (!m_ch_current)
	{
		unsigned int channelFlags;
		m_channel->getCurrentFrontendParameters(m_ch_current);
		m_ch_current->getFlags(channelFlags);
		if (channelFlags & iDVBFrontendParameters::flagOnlyFree)
			m_flags |= scanOnlyFree;
	}

	m_VCT = 0;
	m_ch_current->getSystem(system);
	if (system == iDVBFrontend::feATSC)
	{
		m_VCT = new eTable<VirtualChannelTableSection>;
		if (m_VCT->start(m_demux, eDVBVCTSpec()))
			return -1;
		CONNECT(m_VCT->tableReady, eDVBScan::VCTready);
		startSDT = false;
	}

	m_SDT = 0;
	if (startSDT && (m_ready_all & readySDT))
	{
		m_SDT = new eTable<ServiceDescriptionSection>;
		int tsid=-1;
		if (m_ready & readyPAT && m_ready & validPAT)
		{
			std::vector<ProgramAssociationSection*>::const_iterator i =
				m_PAT->getSections().begin();
			ASSERT(i != m_PAT->getSections().end());
			tsid = (*i)->getTableIdExtension(); // in PAT this is the transport stream id
			m_pat_tsid = eTransportStreamID(tsid);
			for (; i != m_PAT->getSections().end(); ++i)
			{
				const ProgramAssociationSection &pat = **i;
				ProgramAssociationConstIterator program = pat.getPrograms()->begin();
				for (; program != pat.getPrograms()->end(); ++program)
					m_pmts_to_read.insert(std::pair<unsigned short, service>((*program)->getProgramNumber(), service((*program)->getProgramMapPid())));
			}
			m_PMT = new eTable<ProgramMapSection>;
			CONNECT(m_PMT->tableReady, eDVBScan::PMTready);
			PMTready(-2);
			// KabelBW HACK ... on 618Mhz and 626Mhz the transport stream id in PAT and SDT is different

			{
				int type;
				m_ch_current->getSystem(type);
				if (type == iDVBFrontend::feCable)
				{
					eDVBFrontendParametersCable parm;
					m_ch_current->getDVBC(parm);
					if ((tsid == 0x00d7 && absdiff(parm.frequency, 618000) < 2000) ||
						(tsid == 0x00d8 && absdiff(parm.frequency, 626000) < 2000))
						tsid = -1;
				}
			}
		}
		if (tsid == -1)
		{
			if (m_SDT->start(m_demux, eDVBSDTSpec()))
				return -1;
		}
		else if (m_SDT->start(m_demux, eDVBSDTSpec(tsid, true)))
			return -1;
		CONNECT(m_SDT->tableReady, eDVBScan::SDTready);
	}

	if (!(m_ready & readyPAT))
	{
		m_PAT = 0;
		if (m_ready_all & readyPAT)
		{
			m_PAT = new eTable<ProgramAssociationSection>;
			if (m_PAT->start(m_demux, eDVBPATSpec(4000)))
				return -1;
			CONNECT(m_PAT->tableReady, eDVBScan::PATready);
		}

		m_NIT = 0;
		if (m_ready_all & readyNIT)
		{
			m_NIT = new eTable<NetworkInformationSection>;
			if (m_NIT->start(m_demux, eDVBNITSpec(m_networkid)))
				return -1;
			CONNECT(m_NIT->tableReady, eDVBScan::NITready);
		}

		m_BAT = 0;
		if (m_ready_all & readyBAT)
		{
			m_BAT = new eTable<BouquetAssociationSection>;
			if (m_BAT->start(m_demux, eDVBBATSpec()))
				return -1;
			CONNECT(m_BAT->tableReady, eDVBScan::BATready);
		}
	}
	return 0;
}
Пример #7
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();
}
Пример #8
0
eBitrateCalc::eBitrateCalc(int pid, int dvbnamespace, int tsid, int onid, int refreshintervall, int buffer_size): m_size(0), m_refresh_intervall(refreshintervall)
{
	m_send_data_timer = eTimer::create(eApp);
	CONNECT(m_send_data_timer->timeout, eBitrateCalc::sendDataTimerTimeoutCB);
	eDVBChannelID chid; //(eDVBNamespace(dvbnamespace), eTransportStreamID(tsid), eOriginalNetworkID(onid));  <-- weird, that does not work
	chid.dvbnamespace = eDVBNamespace(dvbnamespace);
	chid.transport_stream_id = eTransportStreamID(tsid);
	chid.original_network_id = eOriginalNetworkID(onid);
	ePtr<eDVBResourceManager> res_mgr;
	eDVBResourceManager::getInstance(res_mgr);
	eUsePtr<iDVBChannel> channel;
	int success = 0;
	m_reader = NULL;
	if (!res_mgr->allocateChannel(chid, channel, false))
	{
		ePtr<iDVBDemux> demux;
		if (!channel->getDemux(demux))
		{
			if (!demux->createPESReader(eApp, m_reader))
			{
				if (!m_reader->connectRead(slot(*this, &eBitrateCalc::dataReady), m_pes_connection))
				{
					channel->connectStateChange(slot(*this, &eBitrateCalc::stateChange), m_channel_connection);
					success = 1;
				}
				else
					eDebug("[eBitrateCalc] connect pes reader failed...");
			}
			else
				eDebug("[eBitrateCalc] create PES reader failed...");
		}
		else 
			eDebug("[eBitrateCalc] getDemux failed...");
	}
	else
	{
		eDebug("[eBitrateCalc] allocate channel failed...trying pvr_allocate_demux");
		ePtr<eDVBAllocatedDemux> pvr_allocated_demux;
		int i = 0;
		if (!res_mgr->allocateDemux(NULL,pvr_allocated_demux,i))
		{
			eDVBDemux &demux = pvr_allocated_demux->get();
			if (!demux.createPESReader(eApp, m_reader))
			{
				if (!m_reader->connectRead(slot(*this, &eBitrateCalc::dataReady), m_pes_connection))
					success = 1;
				else
					eDebug("[eBitrateCalc] connect pes reader failed...");
			}
			else
				eDebug("[eBitrateCalc] create PES reader failed...");
		}
		else
			eDebug("[eBitrateCalc] allocate pvr_allocated_demux failed...");
	}
	if (m_reader && success)
	{
		clock_gettime(CLOCK_MONOTONIC, &m_start);
		m_reader->setBufferSize(buffer_size);
		m_reader->start(pid);
		m_send_data_timer->start(m_refresh_intervall, true);
	}
	else
		sendData(-1,0);
}