PVR_ERROR DVBLinkClient::GetEPGForChannel(ADDON_HANDLE handle, const PVR_CHANNEL& channel, time_t iStart, time_t iEnd) { PVR_ERROR result = PVR_ERROR_FAILED; PLATFORM::CLockObject critsec(m_mutex); Channel * c = m_channelMap[channel.iUniqueId]; EpgSearchResult epgSearchResult; if (DoEPGSearch(epgSearchResult,c->GetID(), iStart, iEnd)) { for (std::vector<ChannelEpgData*>::iterator it = epgSearchResult.begin(); it < epgSearchResult.end(); it++) { ChannelEpgData* channelEpgData = (ChannelEpgData*)*it; EpgData& epgData = channelEpgData->GetEpgData(); for (std::vector<Program*>::iterator pIt = epgData.begin(); pIt < epgData.end(); pIt++) { Program* p = (Program*)*pIt; EPG_TAG broadcast; memset(&broadcast, 0, sizeof(EPG_TAG)); broadcast.iUniqueBroadcastId = p->GetStartTime(); broadcast.strTitle = p->GetTitle().c_str(); broadcast.iChannelNumber = channel.iChannelNumber; broadcast.startTime = p->GetStartTime(); broadcast.endTime = p->GetStartTime() + p->GetDuration(); broadcast.strPlotOutline = p->SubTitle.c_str(); broadcast.strPlot = p->ShortDescription.c_str(); broadcast.strIconPath = p->Image.c_str(); broadcast.iGenreType = 0; broadcast.iGenreSubType = 0; broadcast.strGenreDescription = ""; broadcast.firstAired = 0; broadcast.iParentalRating = 0; broadcast.iStarRating = p->Rating; broadcast.bNotify = false; broadcast.iSeriesNumber = p->SeasonNumber; broadcast.iEpisodeNumber = p->EpisodeNumber; broadcast.iEpisodePartNumber = 0; broadcast.strEpisodeName = p->SubTitle.c_str(); int genre_type, genre_subtype; SetEPGGenre(*p, genre_type, genre_subtype); broadcast.iGenreType = genre_type; if (genre_type == EPG_GENRE_USE_STRING) broadcast.strGenreDescription = p->Keywords.c_str(); else broadcast.iGenreSubType = genre_subtype; PVR->TransferEpgEntry(handle, &broadcast); } } result = PVR_ERROR_NO_ERROR; } else { XBMC->Log(LOG_NOTICE, "Not EPG data found for channel : %s with id : %i", channel.strChannelName, channel.iUniqueId); } return result; }
Channel::Channel(Channel& channel) : m_id(channel.GetID()), m_dvbLinkId(channel.GetDvbLinkID()), m_name(channel.GetName()), m_type(channel.GetChannelType()), Number(channel.Number), SubNumber(channel.SubNumber), ChildLock(channel.ChildLock), m_logo_url(channel.GetLogoUrl()) { }
int DVBLinkClient::GetInternalUniqueIdFromChannelId(const std::string& channelId) { for (std::map<int,Channel*>::iterator it=m_channelMap.begin(); it!=m_channelMap.end(); ++it) { Channel * channel = (*it).second; int id = (*it).first; if (channelId.compare(channel->GetID()) == 0) { return id; } } return 0; }
void Run() { IdleConn conn; uint64 now = get_current_epoch_millis(); while (lru.PeekFront(conn) && (now - conn.ts >= maxIdleTime)) { Channel* ch = serv->GetChannel(conn.conn_id); if (NULL != ch) { DEBUG_LOG("Closed timeout connection:%d.", ch->GetID()); ch->Close(); } lru.PopFront(); } }
DVBLinkClient::DVBLinkClient(CHelper_libXBMC_addon* xbmc, CHelper_libXBMC_pvr* pvr, CHelper_libKODI_guilib* gui, std::string clientname, std::string hostname, long port, bool showinfomsg, std::string username, std::string password, bool add_episode_to_rec_title, bool group_recordings_by_series, bool no_group_single_rec) { PVR = pvr; XBMC = xbmc; GUI = gui; m_clientname = clientname; m_hostname = hostname; m_connected = false; m_currentChannelId = 0; m_showinfomsg = showinfomsg; m_add_episode_to_rec_title = add_episode_to_rec_title; m_group_recordings_by_series = group_recordings_by_series; no_group_single_rec_ = no_group_single_rec; setting_margins_supported_ = false; favorites_supported_ = false; transcoding_supported_ = false; m_httpClient = new HttpPostClient(XBMC,hostname, port, username, password); m_dvblinkRemoteCommunication = DVBLinkRemote::Connect((HttpClient&)*m_httpClient, m_hostname.c_str(), port, username.c_str(), password.c_str()); DVBLinkRemoteStatusCode status; m_timerCount = -1; m_recordingCount = -1; //get server version and build GetServerInfoRequest server_info_request; ServerInfo si; if ((status = m_dvblinkRemoteCommunication->GetServerInfo(server_info_request, si)) == DVBLINK_REMOTE_STATUS_OK) { int server_build = atoi(si.build_.c_str()); //server with build earlier than 11410 does not support setting margins setting_margins_supported_ = (server_build >= 11405); } GetStreamingCapabilitiesRequest streamin_caps_request; StreamingCapabilities streaming_caps; status = m_dvblinkRemoteCommunication->GetStreamingCapabilities(streamin_caps_request, streaming_caps); if (status == DVBLINK_REMOTE_STATUS_OK) transcoding_supported_ = streaming_caps.IsTranscoderSupported(dvblinkremote::StreamingCapabilities::STREAMING_TRANSCODER_H264); GetFavoritesRequest favorites_request; status = m_dvblinkRemoteCommunication->GetFavorites(favorites_request, channel_favorites_); favorites_supported_ = (status == DVBLINK_REMOTE_STATUS_OK); GetChannelsRequest request; m_channels = new ChannelList(); m_stream = new Stream(); m_live_streamer = NULL; if ((status = m_dvblinkRemoteCommunication->GetChannels(request, *m_channels)) == DVBLINK_REMOTE_STATUS_OK) { int iChannelUnique = 0; for (std::vector<Channel*>::iterator it = m_channels->begin(); it < m_channels->end(); it++) { Channel* channel = (*it); int channel_id = ++iChannelUnique; m_channelMap[channel_id] = channel; inverse_channel_map_[channel->GetID()] = channel_id; } m_connected = true; XBMC->Log(LOG_INFO, "Connected to DVBLink Server '%s'", m_hostname.c_str()); if (m_showinfomsg) { XBMC->QueueNotification(QUEUE_INFO, XBMC->GetLocalizedString(32001), m_hostname.c_str()); XBMC->QueueNotification(QUEUE_INFO, XBMC->GetLocalizedString(32002), m_channelMap.size()); } m_recordingsid = GetBuildInRecorderObjectID(); m_recordingsid_by_date = m_recordingsid; m_recordingsid_by_date.append(DVBLINK_RECODINGS_BY_DATA_ID); m_recordingsid_by_series = m_recordingsid; m_recordingsid_by_series.append(DVBLINK_RECODINGS_BY_SERIES_ID); m_updating = true; CreateThread(); } else { XBMC->QueueNotification(QUEUE_ERROR, XBMC->GetLocalizedString(32003), m_hostname.c_str(), (int)status); std::string error; m_dvblinkRemoteCommunication->GetLastError(error); XBMC->Log(LOG_ERROR, "Could not connect to DVBLink Server '%s' on port '%i' with username '%s' (Error code : %d Description : %s)", hostname.c_str(), port, username.c_str(), (int)status,error.c_str()); } }