nhttpd EPG details in bouquetlist for iOS-JSON-Calls

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@1679 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
yjogol
2011-09-09 06:17:54 +00:00
parent fd66792efe
commit 50c6361b5e
2 changed files with 77 additions and 36 deletions

View File

@@ -873,35 +873,68 @@ void CControlAPI::ChannellistCGI(CyhookHandler *hh)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// get actual and next event data for given channel
//-----------------------------------------------------------------------------
std::string CControlAPI::_GetBouquetActualEPGItem(CyhookHandler *hh, CZapitChannel * channel) {
std::string result, firstEPG, secondEPG = "";
t_channel_id current_channel = live_channel_id;
int percentage;
std::string timestr;
// NeutrinoAPI->GetChannelEvents();
CSectionsdClient::responseGetCurrentNextInfoChannelID currentNextInfo;
CChannelEvent *event;
event = NeutrinoAPI->ChannelListEvents[channel->channel_id];
/* timer slider */
if (event && event->duration > 0)
percentage = 100 * (time(NULL) - event->startTime) / event->duration;
else
percentage = 100;
if ((event = NeutrinoAPI->ChannelListEvents[channel->channel_id])) {
sectionsd_getCurrentNextServiceKey(channel->channel_id & 0xFFFFFFFFFFFFULL, currentNextInfo);
timestr = timeString(event->startTime);
firstEPG += hh->outPair("startTime", timestr, true);
firstEPG += hh->outPair("description", hh->outValue(event->description), true);
firstEPG += hh->outPair("timeElapsed", string_printf("%d", (time(NULL) - event->startTime) / 60), true);
firstEPG += hh->outPair("timeTotal", string_printf("%d", event->duration / 60), true);
firstEPG += hh->outPair("percentage", string_printf("%d", percentage), false);
if (currentNextInfo.flags & CSectionsdClient::epgflags::has_next) {
timestr = timeString(currentNextInfo.next_zeit.startzeit);
secondEPG += hh->outPair("startTime", timestr, true);
secondEPG += hh->outPair("description", hh->outValue(currentNextInfo.next_name), false);
}
}
result += hh->outPair("isActiveChannel", (channel->channel_id == current_channel) ? "true" : "false", (firstEPG != ""));
if(firstEPG != "") {
result += hh->outCollection("firstEPG", firstEPG);
}
if(secondEPG != "") {
result += hh->outNext();
result += hh->outCollection("secondEPG", secondEPG);
}
return result;
}
//-----------------------------------------------------------------------------
// produce data (collection) for given channel
std::string CControlAPI::_GetBouquetWriteItem(CyhookHandler *hh, CZapitChannel * channel, int bouquetNr, int nr) { std::string CControlAPI::_GetBouquetWriteItem(CyhookHandler *hh, CZapitChannel * channel, int bouquetNr, int nr) {
std::string result = ""; std::string result = "";
if (hh->ParamList["format"] == "json") { bool isEPGdetails = !(hh->ParamList["epg"].empty());
result += string_printf("\t\t{\"number\": \"%u\", \"id\": \"" if (hh->outType == json || hh->outType == xml) {
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS result += hh->outPair("number", string_printf("%u", nr), true);
"\", \"short_id\": \"" result += hh->outPair("id", string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel->channel_id), true);
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS result += hh->outPair("short_id", string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel->channel_id&0xFFFFFFFFFFFFULL), true);
"\", \"name\": \"%s\", \"logo\": \"%s\", \"bouquetnr\": \"%d\"}", result += hh->outPair("name", channel->getName(), true);
nr, result += hh->outPair("logo", hh->outValue(NeutrinoAPI->getLogoFile(hh->WebserverConfigList["Tuxbox.LogosURL"], channel->channel_id)), true);
channel->channel_id, result += hh->outPair("bouquetnr", string_printf("%d", bouquetNr), isEPGdetails);
channel->channel_id&0xFFFFFFFFFFFFULL, if(isEPGdetails)
channel->getName().c_str(), result += _GetBouquetActualEPGItem(hh, channel);
NeutrinoAPI->getLogoFile(hh->WebserverConfigList["Tuxbox.LogosURL"], channel->channel_id).c_str(), result = hh->outArrayItem("channel", result, false);
bouquetNr
);
}
else if((hh->ParamList["format"] == "xml") || !(hh->ParamList["xml"].empty()) ) {
result += string_printf("<channel>\n\t<number>%u</number>\n\t<bouquet>%d</bouquet>\n\t<id>"
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
"</id>\n\t<short_id>"
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
"</short_id>\n\t<name><![CDATA[%s]]></name>\n<logo><![CDATA[%s]]></logo>\n</channel>\n",
nr,
bouquetNr,
channel->channel_id,
channel->channel_id&0xFFFFFFFFFFFFULL,
channel->getName().c_str(),
NeutrinoAPI->getLogoFile(hh->WebserverConfigList["Tuxbox.LogosURL"], channel->channel_id).c_str()
);
} }
else { else {
result += string_printf("%u " result += string_printf("%u "
@@ -919,8 +952,9 @@ std::string CControlAPI::_GetBouquetWriteItem(CyhookHandler *hh, CZapitChannel *
* *
* @par nhttpd-usage * @par nhttpd-usage
* Get bouquet list (all) oder filtered to a given bouquet number * Get bouquet list (all) oder filtered to a given bouquet number
* Option epg=true for actual and next epg data for each channel
* @code * @code
* /control/getbouquet?[bouquet=<bouquet number>][&mode=TV|RADIO] * /control/getbouquet?[bouquet=<bouquet number>][&mode=TV|RADIO][&epg=true]
* @endcode * @endcode
* Get the actual used bouquet number * Get the actual used bouquet number
* @code * @code
@@ -1005,12 +1039,18 @@ void CControlAPI::GetBouquetCGI(CyhookHandler *hh) {
} }
else { else {
ZapitChannelList channels; ZapitChannelList channels;
int BouquetNr = -1; // -1 = all bouquets
int startBouquet = 0;
int bsize = (int) g_bouquetManager->Bouquets.size();
if (hh->ParamList["bouquet"] != "") { if (hh->ParamList["bouquet"] != "") {
// list for given bouquet // list for given bouquet
int BouquetNr = atoi(hh->ParamList["bouquet"].c_str()); BouquetNr = atoi(hh->ParamList["bouquet"].c_str());
if (BouquetNr > 0) if (BouquetNr > 0)
BouquetNr--; BouquetNr--;
channels = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->Bouquets[BouquetNr]->radioChannels : g_bouquetManager->Bouquets[BouquetNr]->tvChannels; startBouquet = BouquetNr;
bsize = BouquetNr+1;
}
/* channels = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->Bouquets[BouquetNr]->radioChannels : g_bouquetManager->Bouquets[BouquetNr]->tvChannels;
int num = 1 + (mode == CZapitClient::MODE_RADIO ? g_bouquetManager->radioChannelsBegin().getNrofFirstChannelofBouquet(BouquetNr) int num = 1 + (mode == CZapitClient::MODE_RADIO ? g_bouquetManager->radioChannelsBegin().getNrofFirstChannelofBouquet(BouquetNr)
: g_bouquetManager->tvChannelsBegin().getNrofFirstChannelofBouquet(BouquetNr)); : g_bouquetManager->tvChannelsBegin().getNrofFirstChannelofBouquet(BouquetNr));
for (int j = 0, size = (int) (channels.size()); j < size; j++) { for (int j = 0, size = (int) (channels.size()); j < size; j++) {
@@ -1022,8 +1062,8 @@ void CControlAPI::GetBouquetCGI(CyhookHandler *hh) {
} }
} }
else { else {
// list all */ // list all
for (int i = 0, bsize = (int) g_bouquetManager->Bouquets.size(); i < bsize; i++) { for (int i = startBouquet; i < bsize; i++) {
channels = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->Bouquets[i]->radioChannels : g_bouquetManager->Bouquets[i]->tvChannels; channels = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->Bouquets[i]->radioChannels : g_bouquetManager->Bouquets[i]->tvChannels;
int num = 1 + (mode == CZapitClient::MODE_RADIO ? g_bouquetManager->radioChannelsBegin().getNrofFirstChannelofBouquet(i) int num = 1 + (mode == CZapitClient::MODE_RADIO ? g_bouquetManager->radioChannelsBegin().getNrofFirstChannelofBouquet(i)
: g_bouquetManager->tvChannelsBegin().getNrofFirstChannelofBouquet(i)); : g_bouquetManager->tvChannelsBegin().getNrofFirstChannelofBouquet(i));
@@ -1039,7 +1079,7 @@ void CControlAPI::GetBouquetCGI(CyhookHandler *hh) {
result += ",\n"; result += ",\n";
} }
} }
} // }
result = hh->outArray("channels", result); result = hh->outArray("channels", result);
// write footer // write footer
if (outType == json) { if (outType == json) {
@@ -1210,10 +1250,10 @@ std::string CControlAPI::channelEPGformated(CyhookHandler *hh, int bouquetnr, t_
return result; return result;
} }
//-----------------------------------------------------------------------------
// Detailed EPG list in XML or JSON // Detailed EPG list in XML or JSON
//-----------------------------------------------------------------------------
void CControlAPI::epgDetailList(CyhookHandler *hh) { void CControlAPI::epgDetailList(CyhookHandler *hh) {
// ------ get parameters ------- // ------ get parameters -------
// max = maximal output items // max = maximal output items

View File

@@ -48,6 +48,7 @@ private:
void _SendTime(CyhookHandler *hh, struct tm *Time, int digits); void _SendTime(CyhookHandler *hh, struct tm *Time, int digits);
std::string _GetBouquetWriteItem(CyhookHandler *hh, CZapitChannel * channel, int bouquetNr, int nr); std::string _GetBouquetWriteItem(CyhookHandler *hh, CZapitChannel * channel, int bouquetNr, int nr);
std::string channelEPGformated(CyhookHandler *hh, int bouquetnr, t_channel_id channel_id, int max, long stoptime); std::string channelEPGformated(CyhookHandler *hh, int bouquetnr, t_channel_id channel_id, int max, long stoptime);
std::string _GetBouquetActualEPGItem(CyhookHandler *hh, CZapitChannel * channel);
//yweb //yweb
void YWeb_SendVideoStreamingPids(CyhookHandler *hh, int apid_no); void YWeb_SendVideoStreamingPids(CyhookHandler *hh, int apid_no);