PVR_ERROR CHTSPData::GetChannelGroupMembers(PVR_HANDLE handle, const PVR_CHANNEL_GROUP &group) { XBMC->Log(LOG_DEBUG, "%s - group '%s'", __FUNCTION__, group.strGroupName); for(unsigned int iTagPtr = 0; iTagPtr < m_tags.size(); iTagPtr++) { if (m_tags[iTagPtr].name != group.strGroupName) continue; SChannels channels = GetChannels(m_tags[iTagPtr].id); for(SChannels::iterator it = channels.begin(); it != channels.end(); ++it) { SChannel& channel = it->second; if (channel.radio != group.bIsRadio) continue; PVR_CHANNEL_GROUP_MEMBER tag; memset(&tag,0 , sizeof(PVR_CHANNEL_GROUP_MEMBER)); tag.strGroupName = group.strGroupName; tag.iChannelUniqueId = channel.id; tag.iChannelNumber = channel.num; XBMC->Log(LOG_DEBUG, "%s - add channel %s (%d) to group '%s' channel number %d", __FUNCTION__, channel.name.c_str(), tag.iChannelUniqueId, group.strGroupName, channel.num); PVR->TransferChannelGroupMember(handle, &tag); } } return PVR_ERROR_NO_ERROR; }
bool CHTSPDirectory::GetChannels( const CURL &base , CFileItemList &items , SChannels channels , int tag) { CURL url(base); SEvent event; for(SChannels::iterator it = channels.begin(); it != channels.end(); it++) { if(!m_session->GetEvent(event, it->second.event)) event.Clear(); CFileItemPtr item(new CFileItem("", true)); url.SetFileName(""); item->SetPath(url.Get()); CHTSPSession::ParseItem(it->second, tag, event, *item); item->m_bIsFolder = false; item->SetLabel(item->m_strTitle); item->m_strTitle = StringUtils::Format("%d", it->second.num); items.Add(item); } items.AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS("%K[ - %B]", "%Z", "%L", "")); items.AddSortMethod(SortByAlbum, 558, LABEL_MASKS("%B", "%Z", "%L", ""), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); items.AddSortMethod(SortByLabel, 551, LABEL_MASKS("%Z", "%B", "%L", ""), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); items.SetContent("livetv"); return !channels.empty(); }
PVR_ERROR CHTSPData::GetChannels(PVR_HANDLE handle, bool bRadio) { SChannels channels = GetChannels(); for(SChannels::iterator it = channels.begin(); it != channels.end(); ++it) { SChannel& channel = it->second; if(bRadio != channel.radio) continue; PVR_CHANNEL tag; memset(&tag, 0 , sizeof(PVR_CHANNEL)); tag.iUniqueId = channel.id; tag.bIsRadio = channel.radio; tag.iChannelNumber = channel.num; tag.strChannelName = channel.name.c_str(); tag.strInputFormat = ""; // unused tag.strStreamURL = ""; // unused tag.iEncryptionSystem = channel.caid; tag.strIconPath = channel.icon.c_str(); tag.bIsHidden = false; PVR->TransferChannelEntry(handle, &tag); } return PVR_ERROR_NO_ERROR; }
PVR_ERROR CHTSPData::GetEpg(ADDON_HANDLE handle, const PVR_CHANNEL &channel, time_t iStart, time_t iEnd) { PVR_ERROR retVal = PVR_ERROR_NO_ERROR; SChannels channels = GetChannels(); if (channels.find(channel.iUniqueId) != channels.end()) { /* Full channel update */ if (GetProtocol() >= 6) { retVal = GetEvents(handle, channel.iUniqueId, iEnd); } /* Event at a time */ else { uint32_t eventId = channels[channel.iUniqueId].event; if (eventId != 0) { do { retVal = GetEvent(handle, &eventId, iEnd); } while(eventId && retVal == PVR_ERROR_NO_ERROR); } } } return retVal; }
PVR_ERROR cHTSPData::RequestChannelList(PVRHANDLE handle, int radio) { if (!CheckConnection()) return PVR_ERROR_SERVER_ERROR; SChannels channels = GetChannels(); for(SChannels::iterator it = channels.begin(); it != channels.end(); ++it) { SChannel& channel = it->second; PVR_CHANNEL tag; memset(&tag, 0 , sizeof(tag)); tag.uid = channel.id; tag.number = channel.id; tag.name = channel.name.c_str(); tag.callsign = channel.name.c_str(); tag.radio = channel.radio; tag.encryption = channel.caid; tag.input_format = ""; tag.stream_url = ""; tag.bouquet = 0; if(((bool)radio) == tag.radio) { PVR->TransferChannelEntry(handle, &tag); } } return PVR_ERROR_NO_ERROR; }
PVR_ERROR cHTSPData::GetEpg(PVR_HANDLE handle, const PVR_CHANNEL &channel, time_t iStart, time_t iEnd) { if (!CheckConnection()) return PVR_ERROR_SERVER_ERROR; SChannels channels = GetChannels(); if (channels.find(channel.iUniqueId) != channels.end()) { time_t stop; SEvent event; event.id = channels[channel.iUniqueId].event; if (event.id == 0) return PVR_ERROR_NO_ERROR; do { bool success = GetEvent(event, event.id); if (success) { EPG_TAG broadcast; memset(&broadcast, 0, sizeof(EPG_TAG)); broadcast.iUniqueBroadcastId = event.id; broadcast.strTitle = event.title.c_str(); broadcast.iChannelNumber = event.chan_id >= 0 ? event.chan_id : channel.iUniqueId; broadcast.startTime = event.start; broadcast.endTime = event.stop; broadcast.strPlotOutline = ""; // unused broadcast.strPlot = event.descs.c_str(); broadcast.strIconPath = ""; // unused broadcast.iGenreType = (event.content & 0x0F) << 4; broadcast.iGenreSubType = event.content & 0xF0; broadcast.firstAired = 0; // unused broadcast.iParentalRating = 0; // unused broadcast.iStarRating = 0; // unused broadcast.bNotify = false; broadcast.iSeriesNumber = 0; // unused broadcast.iEpisodeNumber = 0; // unused broadcast.iEpisodePartNumber = 0; // unused broadcast.strEpisodeName = ""; // unused PVR->TransferEpgEntry(handle, &broadcast); event.id = event.next; stop = event.stop; } else break; } while(iEnd > stop); return PVR_ERROR_NO_ERROR; } return PVR_ERROR_NO_ERROR; }
bool CHTSPDirectory::GetTag(const CURL &base, CFileItemList &items) { CURL url(base); int id = atoi(url.GetFileName().substr(5).c_str()); SChannels channels = m_session->GetChannels(id); if(channels.empty()) return false; return GetChannels(base, items, channels, id); }
PVR_ERROR cHTSPData::RequestEPGForChannel(PVRHANDLE handle, const PVR_CHANNEL &channel, time_t start, time_t end) { if (!CheckConnection()) return PVR_ERROR_SERVER_ERROR; SChannels channels = GetChannels(); if (channels.find(channel.uid) != channels.end()) { time_t stop; SEvent event; event.id = channels[channel.uid].event; if (event.id == 0) return PVR_ERROR_NO_ERROR; do { bool success = GetEvent(event, event.id); if (success) { PVR_PROGINFO broadcast; memset(&broadcast, 0, sizeof(PVR_PROGINFO)); broadcast.channum = event.chan_id >= 0 ? event.chan_id : channel.number; broadcast.uid = event.id; broadcast.title = event.title.c_str(); broadcast.subtitle = event.title.c_str(); broadcast.description = event.descs.c_str(); broadcast.starttime = event.start; broadcast.endtime = event.stop; broadcast.genre_type = (event.content & 0x0F) << 4; broadcast.genre_sub_type = event.content & 0xF0; PVR->TransferEpgEntry(handle, &broadcast); event.id = event.next; stop = event.stop; } else break; } while(end > stop); return PVR_ERROR_NO_ERROR; } return PVR_ERROR_NO_ERROR; }
bool CHTSPDirectory::GetChannels( const CURL &base , CFileItemList &items , SChannels channels , int tag) { CURL url(base); SEvent event; for(SChannels::iterator it = channels.begin(); it != channels.end(); it++) { if(!m_session->GetEvent(event, it->second.event)) event.Clear(); CFileItemPtr item(new CFileItem("", true)); url.SetFileName(""); item->SetPath(url.Get()); CHTSPSession::ParseItem(it->second, tag, event, *item); item->m_bIsFolder = false; item->SetLabel(item->m_strTitle); item->m_strTitle.Format("%d", it->second.num); items.Add(item); } items.AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS("%K[ - %B]", "%Z", "%L", "")); if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) items.AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B", "%Z", "%L", "")); else items.AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B", "%Z", "%L", "")); if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%Z", "%B", "%L", "")); else items.AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%Z", "%B", "%L", "")); items.SetContent("livetv"); return !channels.empty(); }
PVR_ERROR CHTSPData::GetEpg(PVR_HANDLE handle, const PVR_CHANNEL &channel, time_t iStart, time_t iEnd) { PVR_ERROR retVal = PVR_ERROR_NO_ERROR; SChannels channels = GetChannels(); if (channels.find(channel.iUniqueId) != channels.end()) { time_t stop; SEvent ev; ev.id = channels[channel.iUniqueId].event; if (ev.id == 0) return retVal; do { PVR_ERROR result = GetEvent(ev, ev.id); if (result == PVR_ERROR_NO_ERROR) { EPG_TAG broadcast; memset(&broadcast, 0, sizeof(EPG_TAG)); broadcast.iUniqueBroadcastId = ev.id; broadcast.strTitle = ev.title.c_str(); broadcast.iChannelNumber = ev.chan_id >= 0 ? ev.chan_id : channel.iUniqueId; broadcast.startTime = ev.start; broadcast.endTime = ev.stop; broadcast.strPlotOutline = ""; // unused broadcast.strPlot = ev.descs.c_str(); broadcast.strIconPath = ""; // unused broadcast.iGenreType = (ev.content & 0x0F) << 4; broadcast.iGenreSubType = ev.content & 0xF0; broadcast.strGenreDescription = ""; broadcast.firstAired = 0; // unused broadcast.iParentalRating = 0; // unused broadcast.iStarRating = 0; // unused broadcast.bNotify = false; broadcast.iSeriesNumber = 0; // unused broadcast.iEpisodeNumber = 0; // unused broadcast.iEpisodePartNumber = 0; // unused broadcast.strEpisodeName = ""; // unused PVR->TransferEpgEntry(handle, &broadcast); ev.id = ev.next; stop = ev.stop; } else { retVal = result; break; } } while(iEnd > stop && ev.id != 0); } else { retVal = PVR_ERROR_UNKNOWN; } return retVal; }