Example #1
0
std::vector<std::shared_ptr<CPVREpgInfoTag>> CPVRChannelGroup::GetEPGAll(bool bIncludeChannelsWithoutEPG /* = false */) const
{
  std::vector<std::shared_ptr<CPVREpgInfoTag>> tags;

  CPVREpgInfoTagPtr epgTag;
  CPVRChannelPtr channel;
  CSingleLock lock(m_critSection);

  for (PVR_CHANNEL_GROUP_SORTED_MEMBERS::const_iterator it = m_sortedMembers.begin(); it != m_sortedMembers.end(); ++it)
  {
    channel = (*it).channel;
    if (!channel->IsHidden())
    {
      bool bEmpty = false;

      CPVREpgPtr epg = channel->GetEPG();
      if (epg)
      {
        const std::vector<std::shared_ptr<CPVREpgInfoTag>> epgTags = epg->GetTags();
        bEmpty = epgTags.empty();
        if (!bEmpty)
          tags.insert(tags.end(), epgTags.begin(), epgTags.end());
      }

      if (bIncludeChannelsWithoutEPG && bEmpty)
      {
        // Add dummy EPG tag associated with this channel
        if (epg)
          epgTag = std::make_shared<CPVREpgInfoTag>(epg->GetChannelData(), epg->EpgID());
        else
          epgTag = std::make_shared<CPVREpgInfoTag>(std::make_shared<CPVREpgChannelData>(*channel), -1);

        tags.emplace_back(epgTag);
      }
    }
  }

  return tags;
}