static eString getXMLCurrentServiceData(eString request, eString dirpath, eString opt, eHTTPConnection *content) { eString now_start, now_date, now_time, now_duration, now_text, now_longtext, next_start, next_date, next_time, next_duration, next_text, next_longtext; eString result = readFile(TEMPLATE_DIR + "XMLCurrentServiceData.tmp"); content->local_header["Content-Type"]="text/xml; charset=utf-8"; eDVBServiceController *sapi=eDVB::getInstance()->getServiceAPI(); if (sapi) { eService *current = eDVB::getInstance()->settings->getTransponders()->searchService(sapi->service); if (current) { eString curService = current->service_name; eString curSubService = getCurrentSubChannel(ref2string(sapi->service)); if (curSubService) { if (curService) curService += ": " + curSubService; else curService = curSubService; } result.strReplace("#NAME#", XMLify(curService, "XML")); result.strReplace("#REFERENCE#", ref2string(sapi->service)); } else { result.strReplace("#NAME#", ""); result.strReplace("#REFERENCE#", ""); } } result = getEITC(result, "XML"); std::stringstream tmp; if (sapi) { std::list<eDVBServiceController::audioStream> &astreams(sapi->audioStreams); for (std::list<eDVBServiceController::audioStream>::iterator it(astreams.begin()) ;it != astreams.end(); ++it) { tmp << "<channel>" << "<pid>" << eString().sprintf("0x%04x", it->pmtentry->elementary_PID) << "</pid>" << "<selected>"; if (it->pmtentry->elementary_PID == Decoder::current.apid) tmp << "1"; else tmp << "0"; tmp << "</selected><name>" << it->text << "</name>"; tmp << "</channel>"; } } result.strReplace("#AUDIOCHANNELS#", tmp.str()); switch (eAVSwitch::getInstance()->getAudioChannel()) { case 0: result.strReplace("#AUDIOTRACK#", "LEFT"); break; case 1: result.strReplace("#AUDIOTRACK#", "STEREO"); break; case 2: result.strReplace("#AUDIOTRACK#", "RIGHT"); break; default: result.strReplace("#AUDIOTRACK#", ""); break; } tmp.clear(); tmp.str(""); eString curServiceRef = ref2string(eServiceInterface::getInstance()->service); if (curServiceRef) { eString s1 = curServiceRef; int pos; eString nspace; for (int i = 0; i < 7 && s1.find(":") != eString::npos; i++) { pos = s1.find(":"); nspace = s1.substr(0, pos); s1 = s1.substr(pos + 1); } EIT *eit = eDVB::getInstance()->getEIT(); if (eit) { int p = 0; for (ePtrList<EITEvent>::iterator i(eit->events); i != eit->events.end(); ++i) { EITEvent *event = *i; if ((event->running_status >= 2) || ((!p) && (!event->running_status))) { for (ePtrList<Descriptor>::iterator d(event->descriptor); d != event->descriptor.end(); ++d) { if (d->Tag() == DESCR_LINKAGE) { LinkageDescriptor *ld = (LinkageDescriptor *)*d; if (ld->linkage_type == 0xB0) //subchannel { eString subService((char *)ld->private_data, ld->priv_len); eString subServiceRef = "1:0:7:" + eString().sprintf("%x", ld->service_id) + ":" + eString().sprintf("%x", ld->transport_stream_id) + ":" + eString().sprintf("%x", ld->original_network_id) + ":" + eString(nspace) + ":0:0:0:"; tmp << "<service>"; tmp << "<reference>" << subServiceRef << "</reference>"; tmp << "<name>" << XMLify(subService, "XML") << "</name>"; if (subServiceRef == curServiceRef) tmp << "<selected>1</selected>"; else tmp << "<selected>0</selected>"; tmp << "</service>"; } } } } ++p; } eit->unlock(); } } result.strReplace("#VIDEOCHANNELS#", tmp.str()); return result; }
eString getEITC(eString result, eString format) { eString now_start, now_date, now_time, now_duration, now_text, now_longtext, next_start, next_date, next_time, next_duration, next_text, next_longtext; EIT *eit = eDVB::getInstance()->getEIT(); if (eit) { int p = 0; for (ePtrList<EITEvent>::iterator event(eit->events); event != eit->events.end(); ++event) { if (*event) { if (p == 0) { if (event->start_time) { now_start = eString().sprintf("%d", (int)event->start_time); tm* t = localtime(&event->start_time); now_time.sprintf("%02d:%02d", t->tm_hour, t->tm_min); now_date.sprintf("%02d.%02d.%04d", t->tm_mday, t->tm_mon + 1, t->tm_year + 1900); now_duration.sprintf("%d", (int)(event->duration / 60)); } } if (p == 1) { if (event->start_time) { next_start = eString().sprintf("%d", (int)event->start_time); tm* t = localtime(&event->start_time); next_time.sprintf("%02d:%02d", t->tm_hour, t->tm_min); next_date.sprintf("%02d.%02d.%04d", t->tm_mday, t->tm_mon + 1, t->tm_year + 1900); next_duration.sprintf("%d", (int)(event->duration / 60)); } } LocalEventData led; switch (p) { case 0: led.getLocalData(event, &now_text, 0, &now_longtext); break; case 1: led.getLocalData(event, &next_text, 0, &next_longtext); break; } p++; } } eit->unlock(); } result.strReplace("#NOWSTART#", now_start); result.strReplace("#NOWT#", now_time); result.strReplace("#NOWDATE#", now_date); result.strReplace("#NOWDURATION#", now_duration); if (now_duration) now_duration = "(" + now_duration + ")"; result.strReplace("#NOWD#", now_duration); result.strReplace("#NOWST#", XMLify(filter_string(now_text.strReplace("\"", "'")), format)); result.strReplace("#NOWLT#", XMLify(filter_string(now_longtext.strReplace("\"", "'")), format)); result.strReplace("#NEXTSTART#", next_start); result.strReplace("#NEXTT#", next_time); result.strReplace("#NEXTDATE#", next_date); result.strReplace("#NEXTDURATION#", next_duration); if (next_duration) next_duration = "(" + next_duration + ")"; result.strReplace("#NEXTD#", next_duration); result.strReplace("#NEXTST#", XMLify(filter_string(next_text.strReplace("\"", "'")), format)); result.strReplace("#NEXTLT#", XMLify(filter_string(next_longtext.strReplace("\"", "'")), format)); eString curService = getCurService(); eString curServiceRef; eDVBServiceController *sapi = eDVB::getInstance()->getServiceAPI(); if (sapi) curServiceRef = ref2string(sapi->service); eString curSubService = getCurrentSubChannel(curServiceRef); if (curSubService) { if (curService) curService += ": " + curSubService; else curService = curSubService; } result.strReplace("#SERVICENAME#", curService); return result; }