Ejemplo n.º 1
0
 // ------------------------------------------------------------------
 bool FileReader::checkEncoding()
 {
     encoding::TextEncoding eEncoding;
     if (! readPreamble(eEncoding))
         return false;
     return setDecoder(encoding::BaseDecoder::getDecoder(eEncoding));
 };
Ejemplo n.º 2
0
TextRepresentation::TextRepresentation(const std::string name) : Representation(name)
{
	SURGSIM_ADD_SERIALIZABLE_PROPERTY(TextRepresentation, std::shared_ptr<SurgSim::Framework::Asset>,
									  Font, getFont, setFont);

	// Enables the alternative use of the font file instead of the actual font object
	DecoderType decoder = std::bind(&TextRepresentation::loadFont, this,
									std::bind(&YAML::Node::as<std::string>, std::placeholders::_1));
	setDecoder("FontFileName", decoder);

	SetterType setter = std::bind(&TextRepresentation::loadFont, this,
								  std::bind(SurgSim::Framework::convert<std::string>, std::placeholders::_1));
	setSetter("FontFileName", setter);

	SURGSIM_ADD_SERIALIZABLE_PROPERTY(TextRepresentation, std::string, Text, getText, setText);

	SURGSIM_ADD_SERIALIZABLE_PROPERTY(TextRepresentation, double, FontSize, getFontSize, setFontSize);

	SURGSIM_ADD_SERIALIZABLE_PROPERTY(TextRepresentation, SurgSim::DataStructures::OptionalValue<double>,
									  MaximumWidth, getOptionalMaximumWidth, setOptionalMaximumWidth);

	SURGSIM_ADD_SERIALIZABLE_PROPERTY(SurgSim::Graphics::TextRepresentation, SurgSim::Math::Vector4d,
									  Color, getColor, setColor);

}
Ejemplo n.º 3
0
 // ---------------------------------------------------------------------
 FileReader::FileReader(FileInputStream *inputStream, encoding::TextEncoding
 decoder, uint32_t sizeBuffer)
         : m_nInputBufferPos(0), m_nInputBufferLength(0)
 {
     setBufferSize(sizeBuffer);
     setDecoder(encoding::BaseDecoder::getDecoder(decoder));
     setInputStream(inputStream);
 }
Ejemplo n.º 4
0
void main()
{
   char s[40];
	int encoder_state;
   word count;

   // Initialize the controller
	brdInit();

   // Configure digital outputs to simulate quadrature encoder output
	setDigOut(LED1, 1);
   setDigOut(LED2, 1);

	// Configure quadrature encoder input
   setDecoder(QUAD_I, QUAD_Q, -1, 0);

   // Configure digital inputs for switches
   setDigIn(SW1);
   setDigIn(SW2);
   setDigIn(SW3);

   // initialize outputs to low
   encoder_state = 0;
	simulate_encoder(encoder_state);

   // reset quadrature decoder counter
   resetCounter(QUAD_I);

	DispStr(2, 1, "<<< Simulating a Quadrature Encoder with button presses >>>");
   DispStr(1, 3, "Press Button SW1 to decrement counter");
   DispStr(1, 4, "Press Button SW2 to increment counter");
   DispStr(1, 5, "Press Button SW3 to reset counter");

	while (1)
	{
   	costate
      {
       	// Display the counter value
         getCounter(QUAD_I, &count);
         sprintf(s, "Quadrature Decoder Count = %6u", count);
         DispStr(1, 7, s);
      }

      costate
      {
      	// decrement counter
			waitfor(!digIn(SW1)); 			// wait for switch 1 to be pressed
			waitfor(DelayMs(50));			// debounce
			if (!digIn(SW1)) {
	         --encoder_state;
	         if (encoder_state < 0)
	         {
	            encoder_state = 3;
	         }
	         simulate_encoder(encoder_state);
				waitfor(DelayMs(150));         // repeat when switch held down
         }
      }

      costate
      {
      	// increment counter
			waitfor(!digIn(SW2)); 			// wait for switch 2 to be pressed
			waitfor(DelayMs(50));			// debounce
			if (!digIn(SW2)) {
	         ++encoder_state;
	         if (encoder_state > 3)
	         {
	            encoder_state = 0;
	         }
	         simulate_encoder(encoder_state);
				waitfor(DelayMs(150));         // repeat when switch held down
         }
      }

      costate
      {
      	// reset counter
			waitfor(!digIn(SW3)); 			// wait for switch 3 to be pressed
			waitfor(DelayMs(50));			// debounce
         if (!digIn(SW3)) {
	         resetCounter(QUAD_I);      // reset quadrature decoder counter
	         waitfor(digIn(SW3));       // wait for switch 3 to be released
         }
      }
	}
}
Ejemplo n.º 5
0
void eDVBServiceController::scanPMT( PMT *pmt )
{
	Decoder::parms.pmtpid=pmt->pid;

	usedCASystems.clear();

	PMTEntry *audio=0, *ac3_audio=0, *video=0, *teletext=0;

	int audiopid=-1, videopid=-1, ac3pid=-1, tpid=-1;

	int sac3default=eAudio::getInstance()->getAC3default();

	if ( Decoder::parms.pcrpid != pmt->PCR_PID && !service.path.size() )
		Decoder::parms.pcrpid = pmt->PCR_PID;

	// get last selected audio / video pid from pid cache
	eService *sp=eServiceInterface::getInstance()->addRef(service);
	if (sp)
	{
		if (sp->dvb)
		{
#ifndef DISABLE_FILE
			FillPIDsFromFile(sp);
#endif
			videopid=sp->dvb->get(eServiceDVB::cVPID);
			audiopid=sp->dvb->get(eServiceDVB::cAPID);
			ac3pid=sp->dvb->get(eServiceDVB::cAC3PID);
			sp->dvb->set(eServiceDVB::cPCRPID, Decoder::parms.pcrpid);
		}
	}

	int isca=checkCA(calist, pmt->program_info, pmt->program_number);

	audioStreams.clear();
	videoStreams.clear();
	subtitleStreams.clear();

	int content_pid=-1;

	ePtrList<PMTEntry>::iterator TTXIt=pmt->streams.end();
	for (ePtrList<PMTEntry>::iterator i(pmt->streams); i != pmt->streams.end(); ++i)
	{
		PMTEntry *pe=*i;
		bool isAudio=false;
		int tmp=0;

		switch (pe->stream_type)
		{
			case 1:	// ISO/IEC 11172 Video
			case 2: // ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 constrained parameter video stream
				if ( (!video) || (pe->elementary_PID == videopid) )
					video=pe;
				isca+=checkCA(calist, pe->ES_info, pmt->program_number);
				videoStreams.push_back(pe);
				break;
			case 3: // ISO/IEC 11172 Audio
			case 4: // ISO/IEC 13818-3 Audio
				isAudio=true;
			case 6:
			{
				isca+=checkCA(calist, pe->ES_info, pmt->program_number);
				audioStream stream(pe);
				for (ePtrList<Descriptor>::iterator ii(pe->ES_info); ii != pe->ES_info.end(); ++ii)
				{
					switch( ii->Tag() )
					{
						case DESCR_AC3:
							stream.isAC3=1;
							break;
						case DESCR_REGISTRATION:
							if (!memcmp(((RegistrationDescriptor*)*ii)->format_identifier, "DTS", 3))
								stream.isDTS=1;
							break;
						case DESCR_TELETEXT:
							if ( (!teletext) || (pe->elementary_PID == tpid) )
							{
								TTXIt = i;
								teletext=pe;
							}
							break;
						case DESCR_SUBTITLING:
							subtitleStreams.push_back(pe);
							break;
						case DESCR_ISO639_LANGUAGE:
							stream.text=getISO639Description(((ISO639LanguageDescriptor*)*ii)->language_code);
							break;
						case DESCR_STREAM_ID:
							stream.component_tag=((StreamIdentifierDescriptor*)*ii)->component_tag;
							break;
						case DESCR_LESRADIOS:
						{
							LesRadiosDescriptor *d = (LesRadiosDescriptor*)*ii;
							if ( (stream.component_tag >= 0 || d->id) && d->name )
								stream.text.sprintf("%d.) %s", d->id, d->name.c_str());
							else
								isAudio=false;
							break;
						}
						default:
							break;
					}
				}

				if (stream.isAC3)
				{
					stream.text+=" (AC3)";
					isAudio=true;
					if ( (!ac3_audio) || (pe->elementary_PID == ac3pid) )
						ac3_audio=pe;
				}
				else if (stream.isDTS)
				{
					stream.text+=" (DTS)";
					isAudio=true;
					if ( (!ac3_audio) || (pe->elementary_PID == ac3pid) )
						ac3_audio=pe;
				}
				else if (isAudio && ( (!audio) || (pe->elementary_PID == audiopid) ) )
					audio=pe;

				if (!stream.text)
					stream.text.sprintf("PID %04x", pe->elementary_PID);

				if (isAudio)
					audioStreams.push_back(stream);
			}
			case 5: // private section
			{
				if ( content_pid != -1)
					continue;
				for (ePtrList<Descriptor>::iterator ii(pe->ES_info); ii != pe->ES_info.end(); ++ii)
				{
					switch( ii->Tag() )
					{
						case DESCR_PRIV_DATA_SPEC:
							if ( ((PrivateDataSpecifierDescriptor*)*ii)->private_data_specifier == 190 )
								tmp |= 1;
							break;
						case 0x90:
						{
							UnknownDescriptor *descr = (UnknownDescriptor*) *ii;
							if ( descr->length() == 4 && !descr->data[0] && !descr->data[1] && descr->data[2] == 0xFF && descr->data[3] == 0xFF )
								tmp |= 2;
						}
						default:
							break;
					}
				}
				if ( tmp == 3 )
					content_pid = pe->elementary_PID;
			}
			default:
				break;
		}
	}

	if ( content_pid != -1 )
		/*emit*/ dvb.gotContentPid(content_pid);

	// get audio priority channel
	audio = priorityAudio(audio);

	ePtrList<PMTEntry>::iterator tmp = pmt->streams.end();
	if (TTXIt != tmp)
	{
		// move teletext to the end of the list
		--tmp;
		if ( tmp != TTXIt )
			std::iter_swap(tmp, TTXIt);
	}

	int needAC3Workaround=0;
	switch (eSystemInfo::getInstance()->getHwType())
	{
		case eSystemInfo::dbox2Nokia:
		case eSystemInfo::dbox2Philips:
		case eSystemInfo::dbox2Sagem:
			needAC3Workaround=1;
		default:
			break;
	}

	if ( !needAC3Workaround && ac3_audio && ( sac3default || (ac3pid != -1) || (!audio) ) )
	{
		audiopid = ac3pid;
		audio = ac3_audio;
	}

	if ( video )
	{
		if ( video->elementary_PID != videopid )
			setPID(video);
	}
	else if (sp && sp->dvb) // handle no more existing vpid
	{
		Decoder::parms.vpid = -1;
		sp->dvb->set(eServiceDVB::cVPID, -1);
	}

	if ( audio )
	{
		if ( audiopid != audio->elementary_PID )
			setPID(audio);
	}
	else if (sp && sp->dvb)  // handle no more existing apid
	{
		Decoder::parms.apid = -1;
		sp->dvb->set(eServiceDVB::cAPID, -1);
		sp->dvb->set(eServiceDVB::cAC3PID, -1);
	}

	if ( teletext )
	{
		if ( tpid != teletext->elementary_PID )
			setPID(teletext);
	}
	else if (sp && sp->dvb)  // handle no more existing tpid
	{
		Decoder::parms.tpid = -1;
		sp->dvb->set(eServiceDVB::cTPID, -1);
	}

	/*emit*/ dvb.scrambled(isca);

	int hideerror=0;
	eConfig::getInstance()->getKey("/elitedvb/extra/hideerror", hideerror);
	if ( hideerror || (dvb.recorder && service.path) )
		;
	else if (isca && !service.path && !calist )
	{
		eDebug("NO CASYS");
		service_state=ENOCASYS;
	}

	if ((Decoder::parms.vpid==-1) && (Decoder::parms.apid==-1))
		service_state=ENOSTREAM;

//	for (ePtrList<CA>::iterator i(calist); i != calist.end(); ++i)
//		eDebug("CA %04x ECMPID %04x", i->casysid, i->ecmpid);

	setDecoder();

	// AC3 DBOX2 Workaround... buggy drivers...
	if ( needAC3Workaround && ac3_audio && ( sac3default || (ac3pid != -1) || (!audio) ) )
	{
		setPID(ac3_audio);
		setDecoder();
	}

	if (sp)
		eServiceInterface::getInstance()->removeRef(service);
}
Ejemplo n.º 6
0
void eDVBServiceController::EITready(int error)
{
	eDebug("EITready (%d)", error);
	bool haveAC3=false, changed=false;
	if (!error)
	{
		EIT *eit=dvb.getEIT();

		for (ePtrList<EITEvent>::iterator e(eit->events); e != eit->events.end(); ++e)
		{
//		eDebug("running_status = %d", e->running_status );
			if ((e->running_status>=2) || (!e->running_status) ) // currently running service
			{
				for (ePtrList<Descriptor>::iterator d(e->descriptor); d != e->descriptor.end(); ++d)
				{
					if (d->Tag()==DESCR_COMPONENT)
					{
						for (std::list<audioStream>::iterator it(audioStreams.begin())
							;it != audioStreams.end(); ++it )
						{
							if (((ComponentDescriptor*)*d)->component_tag == it->component_tag )
							{
								changed=true;
								eString tmp = ((ComponentDescriptor*)*d)->text;
								if (tmp)
								{
									it->text=tmp;
									if ( it->isAC3 )
										it->text+=" (AC3)";
									else if ( it->isDTS )
										it->text+=" (DTS)";
								}
							}
							if ( !haveAC3 && (it->isAC3 || it->isDTS) )
								haveAC3=true;
						}
					}
				}
				break;
			}
		}

		if ( service.getServiceType() == 4 ) // NVOD Service
		{
			delete dvb.parentEIT;
			dvb.parentEIT = new EIT( eit );
			dvb.parentEIT->events.setAutoDelete(true);
			eit->events.setAutoDelete(false);
		}
		/*emit*/ dvb.gotEIT(eit, 0);
		eit->unlock();
	}
	else
		/*emit*/ dvb.gotEIT(0, error);

	if ( changed && !(haveAC3 && eAudio::getInstance()->getAC3default()) )
	{
		PMTEntry *audio = 0;
		audio = priorityAudio(audio);
		if (audio)
		{
			setPID(audio);
			setDecoder();
		}
	}
}