示例#1
0
void XMLTreeParser::StartElementHandler(const XML_Char *name, const XML_Char **patts)
{
	XMLTreeNode     *n;
	const XML_Char **a=patts;

	n=new XMLTreeNode(current, (char *) name);

	if (a)
	{
		while (*a) {
			n->SetAttribute((char *) a[0], (char *) a[1]);
			a+=2;
		};
	}

	if (current)
	{
		n->SetPDataOff(current->GetDataSize());
		current->AddNode(n, XMLTreeNode::ADD_CHILD);
		current=n;
	}
	else
	{
		root=current=n;
	}
}
示例#2
0
//never used
bool CMovieInfo::parseXmlTree(char */*text*/, MI_MOVIE_INFO * /*movie_info*/)
{
#ifndef XMLTREE_LIB
	return (false);		// no XML lib available return false
#else /* XMLTREE_LIB */

	//int helpIDtoLoad = 80;

	//XMLTreeParser *parser=new XMLTreeParser("ISO-8859-1");
	XMLTreeParser *parser = new XMLTreeParser(NULL);

	if (!parser->Parse(text, strlen(text), 1)) {
		TRACE("parse error: %s at line %d \r\n", parser->ErrorString(parser->GetErrorCode()), parser->GetCurrentLineNumber());
		//fclose(in);
		delete parser;
		return (false);
	}

	XMLTreeNode *root = parser->RootNode();
	if (!root) {
		TRACE(" root error \r\n");
		delete parser;
		return (false);
	}

	if (strcmp(root->GetType(), MI_XML_TAG_NEUTRINO)) {
		TRACE("not neutrino file. %s", root->GetType());
		delete parser;
		return (false);
	}

	XMLTreeNode *node = parser->RootNode();

	for (node = node->GetChild(); node; node = node->GetNext()) {
		if (!strcmp(node->GetType(), MI_XML_TAG_RECORD)) {
			for (XMLTreeNode * xam1 = node->GetChild(); xam1; xam1 = xam1->GetNext()) {
				XML_GET_DATA_STRING(xam1, MI_XML_TAG_CHANNELNAME, movie_info->epgChannel);
				XML_GET_DATA_STRING(xam1, MI_XML_TAG_EPGTITLE, movie_info->epgTitle);
				XML_GET_DATA_LONG(xam1, MI_XML_TAG_ID, movie_info->epgId);
				XML_GET_DATA_STRING(xam1, MI_XML_TAG_INFO1, movie_info->epgInfo1);
				XML_GET_DATA_STRING(xam1, MI_XML_TAG_INFO2, movie_info->epgInfo2);
				XML_GET_DATA_LONG(xam1, MI_XML_TAG_EPGID, movie_info->epgEpgId);	// %llu
				XML_GET_DATA_INT(xam1, MI_XML_TAG_MODE, movie_info->epgMode);	//%d
				XML_GET_DATA_INT(xam1, MI_XML_TAG_VIDEOPID, movie_info->epgVideoPid);	//%u
				XML_GET_DATA_INT(xam1, MI_XML_TAG_VIDEOTYPE, movie_info->VideoType);	//%u
				if (!strcmp(xam1->GetType(), MI_XML_TAG_AUDIOPIDS)) {
					for (XMLTreeNode * xam2 = xam1->GetChild(); xam2; xam2 = xam2->GetNext()) {
						if (!strcmp(xam2->GetType(), MI_XML_TAG_AUDIO)) {
							EPG_AUDIO_PIDS pids;
							pids.epgAudioPid = atoi(xam2->GetAttributeValue(MI_XML_TAG_PID));
							pids.atype = atoi(xam2->GetAttributeValue(MI_XML_TAG_ATYPE));
							pids.selected = atoi(xam2->GetAttributeValue(MI_XML_TAG_SELECTED));
							pids.epgAudioPidName = decodeXmlSpecialChars(xam2->GetAttributeValue(MI_XML_TAG_NAME));
//printf("MOVIE INFO: apid %d type %d name %s selected %d\n", pids.epgAudioPid, pids.atype, pids.epgAudioPidName.c_str(), pids.selected);
							movie_info->audioPids.push_back(pids);
						}
					}
				}
				XML_GET_DATA_INT(xam1, MI_XML_TAG_VTXTPID, movie_info->epgVTXPID);	//%u
				/*****************************************************
				 *	new tags										*/
				XML_GET_DATA_INT(xam1, MI_XML_TAG_GENRE_MAJOR, movie_info->genreMajor);
				XML_GET_DATA_INT(xam1, MI_XML_TAG_GENRE_MINOR, movie_info->genreMinor);
				XML_GET_DATA_STRING(xam1, MI_XML_TAG_SERIE_NAME, movie_info->serieName);
				XML_GET_DATA_INT(xam1, MI_XML_TAG_LENGTH, movie_info->length);
				XML_GET_DATA_STRING(xam1, MI_XML_TAG_PRODUCT_COUNTRY, movie_info->productionCountry);
				//if(!strcmp(xam1->GetType(), MI_XML_TAG_PRODUCT_COUNTRY)) if(xam1->GetData() != NULL)strncpy(movie_info->productionCountry, xam1->GetData(),4);
				XML_GET_DATA_INT(xam1, MI_XML_TAG_PRODUCT_DATE, movie_info->productionDate);
				XML_GET_DATA_INT(xam1, MI_XML_TAG_QUALITIY, movie_info->quality);
				XML_GET_DATA_INT(xam1, MI_XML_TAG_QUALITY, movie_info->quality);
				XML_GET_DATA_INT(xam1, MI_XML_TAG_PARENTAL_LOCKAGE, movie_info->parentalLockAge);
				XML_GET_DATA_INT(xam1, MI_XML_TAG_DATE_OF_LAST_PLAY, movie_info->dateOfLastPlay);

				if (!strcmp(xam1->GetType(), MI_XML_TAG_BOOKMARK)) {
					for (XMLTreeNode * xam2 = xam1->GetChild(); xam2; xam2 = xam2->GetNext()) {
						XML_GET_DATA_INT(xam2, MI_XML_TAG_BOOKMARK_START, movie_info->bookmarks.start);
						XML_GET_DATA_INT(xam2, MI_XML_TAG_BOOKMARK_END, movie_info->bookmarks.end);
						XML_GET_DATA_INT(xam2, MI_XML_TAG_BOOKMARK_LAST, movie_info->bookmarks.lastPlayStop);
					}
				}
				/*****************************************************/
			}
		}
	}

	delete parser;
	if (movie_info->epgInfo2.empty()) {
		movie_info->epgInfo2 = movie_info->epgInfo1;
		//movie_info->epgInfo1 = "";
	}
#endif /* XMLTREE_LIB */
	return (true);
}
示例#3
0
bool eMPConfig::load()
{
	XMLTreeParser parser("ISO-8859-1");

	eString file = CONFFILE1;
	FILE *in = fopen(file.c_str(), "rt");
	if (!in) 
	{
		file = CONFFILE0;
		in = fopen(file.c_str(), "rt");
		if (!in) 
		{
			eDebug("[MPCONFIG] unable to open %s", file.c_str()); 
			return false;
		}
	}

	videoParmList.clear();
	vlcServerList.clear();
	
	bool done = false;
	while (!done)
	{
		char buf[2048]; 
		unsigned int len = fread(buf, 1, sizeof(buf), in);
		done = len < sizeof(buf);
		if (!parser.Parse(buf, len, done))
		{
			eDebug("[MPCONFIG] parsing settings file: %s at line %d>", parser.ErrorString(parser.GetErrorCode()), parser.GetCurrentLineNumber());
			fclose(in);
			return false;
		}
	}

	fclose(in);

	XMLTreeNode *root = parser.RootNode();
	if (!root)
		return false;

	bool first = false;
	for (XMLTreeNode *node = root->GetChild(); node; node = node->GetNext())
	{
		if (!strcmp(node->GetType(), "server"))
		{
			serverConf.serverIP = node->GetAttributeValue("ip");
			serverConf.webifPort = node->GetAttributeValue("webif-port");
			serverConf.streamingPort = node->GetAttributeValue("stream-port");

			serverConf.vlcUser = node->GetAttributeValue("user");
			serverConf.vlcPass = node->GetAttributeValue("pass");
		}
		else 
		if (!strcmp(node->GetType(), "config"))
		{
			serverConf.startDir = node->GetAttributeValue("startdir");
			serverConf.CDDrive  = node->GetAttributeValue("cddrive");
		}
		else 
		if (!strcmp(node->GetType(), "codec"))
		{
			avcodecs.mpeg1 = node->GetAttributeValue("mpeg1");
			avcodecs.mpeg2 = node->GetAttributeValue("mpeg2");
			avcodecs.audio = node->GetAttributeValue("audio");
		}
		else 
		if (!strcmp(node->GetType(), "setup"))
		{
			eString tmpname = node->GetAttributeValue("name");
			eString tmpext = node->GetAttributeValue("ext");
			eString tmpvrate = node->GetAttributeValue("Videorate");
			eString tmpvtrans = node->GetAttributeValue("Videotranscode");
			eString tmpvcodec = node->GetAttributeValue("Videocodec");
			eString tmpvsize = node->GetAttributeValue("Videosize");
			eString tmparate = node->GetAttributeValue("Audiorate");
			eString tmpatrans = node->GetAttributeValue("Audiotranscode");
			eString tmpfps = node->GetAttributeValue("fps");
			eString tmpsoutadd = node->GetAttributeValue("soutadd");

			if (!tmpname || !tmpext || !tmpvrate || !tmpvtrans || !tmpvcodec || !tmpvsize || !tmparate || !tmpatrans || !tmpfps )
			{
				eDebug("[MOVIEPLAYER] parse error in settings file");
				return false;
			}
			else
			{
				struct videoTypeParms a;
				a.name = tmpname;
				a.extension = tmpext;
				a.videoRate = tmpvrate;
				a.transcodeVideo = (tmpvtrans == "1");
				a.videoCodec = tmpvcodec;
				a.videoRatio = tmpvsize;
				a.audioRate = tmparate;
				a.transcodeAudio = (tmpatrans == "1");
				a.fps = tmpfps;
				if(!tmpsoutadd)
				        a.soutadd = false; // compatibility for old .xml files
				else
				        a.soutadd = (tmpsoutadd == "1");

				videoParmList.push_back(a);
			}
		}
		else
		if (!strcmp(node->GetType(), "vlcsrv"))
		{
			struct serverConfig vlc;
			if(!first)// first is always default 
			{
				vlc = serverConf;
				vlcServerList.push_back(vlc);
				first = true;
			}
			vlc.serverIP = node->GetAttributeValue("ip");
			vlc.webifPort = node->GetAttributeValue("webif-port");
			vlc.streamingPort = node->GetAttributeValue("stream-port");
			vlc.vlcUser = node->GetAttributeValue("user");
			vlc.vlcPass = node->GetAttributeValue("pass");
			vlc.startDir = node->GetAttributeValue("startdir");
			vlc.CDDrive  = node->GetAttributeValue("cddrive");
eDebug("mpconfig2 IP=%s wPort=%s sPort=%s U=%s Pass=%s Dir=%s Drive=%s",vlc.serverIP.c_str(),vlc.webifPort.c_str(),vlc.streamingPort.c_str(),vlc.vlcUser.c_str(),vlc.vlcPass.c_str(),vlc.startDir.c_str(),vlc.CDDrive.c_str());
			vlcServerList.push_back(vlc);
		}
	}

	if(!first)	// if no vlcsrv 
		vlcServerList.push_back(serverConf);

	/*eDebug("\nIP:%s",VLCsend::getInstance()->send_parms.IP.c_str());
	eDebug("WEBIF-PORT:%s",VLCsend::getInstance()->send_parms.IF_PORT.c_str());
	eDebug("Stream-PORT:%s\n",VLCsend::getInstance()->send_parms.STREAM_PORT.c_str());

	eDebug("STARTDIR:%s",startdir.c_str());
	eDebug("CDDRIVE:%s\n",cddrive.c_str());

	eDebug("MPEG1:%s",str_mpeg1.c_str());
	eDebug("MPEG2:%s",str_mpeg2.c_str());
	eDebug("Audio:%s\n",str_audio.c_str());

	for(ExtList::iterator p=extList.begin(); p!=extList.end() ;p++)
	{
		eDebug("name=%s ext=%s vrate=%s vcodec=%s vsize=%s arate=%s item=%d", (*p).NAME.c_str(), (*p).EXT.c_str(), (*p).VRATE.c_str(), (*p).VCODEC.c_str(),
		(*p).VSIZE.c_str(), (*p).ARATE.c_str(), (*p).ITEM);
	}*/

	return true;
}
示例#4
0
void cXmlReader::handleEvent(XMLTreeNode *node)
{
    char *tmp;
    string start; 
    string stop; 
    string channelId; 
    time_t startTime;
    time_t stopTime;
    tmp = node->GetAttributeValue("start");
    if (tmp) start = convertUTF8DVB(tmp, codePage);

    tmp = node->GetAttributeValue("stop");
    if (tmp) stop = convertUTF8DVB(tmp, codePage);

    tmp = node->GetAttributeValue("channel");
    if (tmp) channelId = convertUTF8DVB(tmp, codePage);

    //stopTime is implied.... need to read 2 items at least....?? simply reject those files.
    if (channelId.length() > 0 && analyseTime(start, startTime, offset) && analyseTime(stop, stopTime, offset) && stopTime > startTime)
    {
        string title;
        string subtitle;
        string description;
        string category;

        char *tmp;
        for (XMLTreeNode *child = node->GetChild(); child; child = child->GetNext())
        {
            string data;
            string type = child->GetType();
            tmp = child->GetData();
            if (tmp) data = convertUTF8DVB(tmp, codePage);  //convert UTF8 back to DVB stuff...

            if (type == "title")    //required, multiple
            {
                title = data;
            }
            else if (type == "desc")    //multiple
            {
                description = data;
            }
            else if (type == "category")    //multiple
            {
                category = data;
            }
            else if (type == "sub-title")   //multiple
            {
                subtitle = data;
            }
        }
        if (title.length() > 0)
        {
            //get EventID for this channel?
            cEvent *ev = createEvent(title, subtitle, description, category, startTime, stopTime);
            if (ev)
            {
                storeEvent(channelId, ev);
                delete ev;
            }
        }
    }
}