示例#1
0
static int unbase64(eString &dst, const eString string)
{
	dst="";
	char c[4];
	int pos=0;
	unsigned int i=0;

	while (1)
	{
		if (i == string.size())
			break;
		char *ch=strchr(_base64, string[i++]);
		if (!ch)
		{
			i++;
			continue;
		}
		c[pos++]=ch-_base64;
		if (pos == 4)
		{
			char d[3];
			d[0]=c[0]<<2;
			d[0]|=c[1]>>4;
			d[1]=c[1]<<4;
			d[1]|=c[2]>>2;
			d[2]=c[2]<<6;
			d[2]|=c[3];

			dst+=d[0];
			if (c[2] != 64)
				dst+=d[1];
			if (c[3] != 64)
				dst+=d[2];
			pos=0;
		}
	}
示例#2
0
int eMoviePlayer::playStream(eString mrl)
{
	int apid = -1, vpid = -1, ac3 = -1;
	
	// receive video stream from VLC on PC
	eDebug("[MOVIEPLAYER] start playing stream...");

	status.BUFFERFILLED = false;
	pthread_mutex_lock(&mutex);
	tsBuffer.clear();
	pthread_mutex_unlock(&mutex);

	if (requestStream() < 0)
	{
		eDebug("[MOVIEPLAYER] requesting stream failed...");
		close(fd);
		return -1;
	}
	int ibuff;
	if(status.PLG)
		ibuff = initialBuffer;
	else
		ibuff = INITIALBUFFER;
	
	if (bufferStream(fd, ibuff) == 0)
	{
		eDebug("[MOVIEPLAYER] buffer is empty.");
		close(fd);
		if (cancelBuffering > 0)
			return 0;
		else
			return -4;
	}
	
	status.BUFFERFILLED = true;
	
	find_avpids(&tsBuffer, &vpid, &apid, &ac3);
	if (vpid == -1 || apid == -1)
	{
		if(status.NSF ) // plugin can playback file without A or V too
		{
			eDebug("[MOVIEPLAYER] both AV pids not found: vpid %d apid %d, but play.",vpid,apid);
		}
		else
		{
			eDebug("[MOVIEPLAYER] no AV pids found.");
			close(fd);
			return -5;
		}
	}
	status.NSF=false;

	status.AVPIDS_FOUND = true;

	if(!status.DVB)
		stopDVB();

	Decoder::setMpegDevice(-1);
	// set pids
	Decoder::parms.vpid = vpid;
	Decoder::parms.apid = apid;
	Decoder::parms.audio_type = DECODE_AUDIO_MPEG;
	
	int ac3default = 0;
	eConfig::getInstance()->getKey("/elitedvb/audio/ac3default", ac3default);
	if (ac3 && ac3default)
	{
		if (mrl.right(3) == "vob" || mrl.left(3) == "dvd")
			Decoder::parms.audio_type = DECODE_AUDIO_AC3_VOB;
		else
			Decoder::parms.audio_type = DECODE_AUDIO_AC3;
	}

	eZapMain::getInstance()->hideInfobar();
	usleep(100000);
	Decoder::SetStreamType(TYPE_PES);
	Decoder::Set();

#ifndef DISABLE_LCD
	unsigned int pos = mrl.find_last_of('/');
	eZapLCD::getInstance()->lcdMain->ServiceName->setText(mrl.right(mrl.size() - pos - 1));
#endif

	createThreads();
	
	status.ACTIVE = true;
	
	return 0;
}