void CBouquetManager::makeRemainingChannelsBouquet(void) { ChannelList unusedChannels; set<t_channel_id> chans_processed; for (vector<CBouquet*>::const_iterator it = Bouquets.begin(); it != Bouquets.end(); ++it) { for (vector<CZapitChannel*>::iterator jt = (*it)->tvChannels.begin(); jt != (*it)->tvChannels.end(); ++jt) chans_processed.insert((*jt)->getChannelID()); for (vector<CZapitChannel*>::iterator jt = (*it) ->radioChannels.begin(); jt != (*it)->radioChannels.end(); ++jt) chans_processed.insert((*jt)->getChannelID()); } // TODO: use locales remainChannels = addBouquet(Bouquets.empty() ? "Alle Kan\xC3\xA4le" : "Andere"); // UTF-8 encoded for (tallchans::iterator it = allchans.begin(); it != allchans.end(); ++it) if (chans_processed.find(it->first) == chans_processed.end()) unusedChannels.push_back(&(it->second)); sort(unusedChannels.begin(), unusedChannels.end(), CmpChannelByChName()); for (ChannelList::const_iterator it = unusedChannels.begin(); it != unusedChannels.end(); ++it) remainChannels->addService(findChannelByChannelID((*it)->getChannelID())); if ((remainChannels->tvChannels.empty()) && (remainChannels->radioChannels.empty())) { deleteBouquet(remainChannels); remainChannels = NULL; } }
LiveTVPlayback::preferredCards_t LiveTVPlayback::FindTunableCardIds(const std::string& chanNum, const ChannelList& channels) { // Make the set of channels matching the desired channel number ChannelList chanset; for (ChannelList::const_iterator it = channels.begin(); it != channels.end(); ++it) { if ((*it)->chanNum == chanNum) chanset.push_back(*it); } // Retrieve unlocked encoders and fill the list of preferred cards. // It is ordered by its key liveTVOrder and contains matching between channels // and card inputs using their respective sourceId and mplexId std::vector<int> ids = GetFreeCardIdList(); preferredCards_t preferredCards; for (std::vector<int>::const_iterator itc = ids.begin(); itc != ids.end(); ++itc) { CardInputListPtr inputs = GetFreeInputs(*itc); for (CardInputList::const_iterator iti = inputs->begin(); iti != inputs->end(); ++iti) { for (ChannelList::const_iterator itchan = chanset.begin(); itchan != chanset.end(); ++itchan) { if ((*itchan)->sourceId == (*iti)->sourceId && ( (*iti)->mplexId == 0 || (*iti)->mplexId == (*itchan)->mplexId )) { preferredCards.insert(std::make_pair((*iti)->liveTVOrder, std::make_pair(*iti, *itchan))); DBG(MYTH_DBG_DEBUG, "%s: [%u] channel=%s(%" PRIu32 ") card=%" PRIu32 " input=%s(%" PRIu32 ") mplex=%" PRIu32 " source=%" PRIu32 "\n", __FUNCTION__, (*iti)->liveTVOrder, (*itchan)->callSign.c_str(), (*itchan)->chanId, (*iti)->cardId, (*iti)->inputName.c_str(), (*iti)->inputId, (*iti)->mplexId, (*iti)->sourceId); break; } } } } return preferredCards; }
void ChannelMgr::RemoveChannel(Channel * chn) { ChannelList::iterator itr; ChannelList * cl = &Channels[chn->m_team]; DBCChannelMap::iterator itr2; DBCChannelMap *dbcchannel = &DBCChannels[chn->m_team]; lock.Acquire(); m_idToChannel.erase(chn->m_channelId); for(itr = cl->begin(); itr != cl->end(); itr++) { if(itr->second == chn) { cl->erase(itr); chn->m_lock.Release(); delete chn; lock.Release(); return; } } for(itr2 = dbcchannel->begin(); itr2 != dbcchannel->end(); itr2++) { if(itr2->second.second == chn) { dbcchannel->erase(itr2); chn->m_lock.Release(); delete chn; lock.Release(); return; } } lock.Release(); }
Channel * ChannelMgr::GetChannel(const char *name, uint32 team) { uint32 rteam = seperatechannels ? team : 0; lock.Acquire(); ChannelList * cl = &Channels[rteam]; for(ChannelList::iterator itr = cl->begin(); itr != cl->end(); itr++) { if(!stricmp(name, itr->first.c_str())) { lock.Release(); return itr->second; } } DBCChannelMap::iterator itr2; DBCChannelMap *dbcchannel = &DBCChannels[rteam]; for(itr2 = dbcchannel->begin(); itr2 != dbcchannel->end(); itr2++) { if(!stricmp(name, itr2->second.first.c_str())) { lock.Release(); return itr2->second.second; } } lock.Release(); return NULL; }
ChannelList channelsInView (const string & viewName, const ChannelList & channelList, const StringVector & multiView) { // // Return a list of all channels belonging to view viewName. // ChannelList q; for (ChannelList::ConstIterator i = channelList.begin(); i != channelList.end(); ++i) { // // Get view name for this channel // string view = viewFromChannelName (i.name(), multiView); // // Insert channel into q if it's a member of view viewName // if (view == viewName) q.insert (i.name(), i.channel()); } return q; }
ChannelList channelInAllViews (const string &channelName, const ChannelList &channelList, const StringVector &multiView) { // // Given the name of a channel, return a // list of the same channel in all views. // ChannelList q; for (ChannelList::ConstIterator i=channelList.begin(); i != channelList.end(); ++i) { if (i.name() == channelName || areCounterparts (i.name(), channelName, multiView)) { q.insert (i.name(), i.channel()); } } return q; }
bool ChannelList::operator == (const ChannelList &other) const { ConstIterator i = begin(); ConstIterator j = other.begin(); while (i != end() && j != other.end()) { if (!(i.channel() == j.channel())) return false; ++i; ++j; } return i == end() && j == other.end(); }
// Utility to fill the given array with the names of all the channels inline void vtkOpenEXR::convertChannelNames(const ChannelList & channels, std::vector<std::string> & result) { typedef ChannelList::ConstIterator CIter; for (CIter it = channels.begin(); it != channels.end(); ++it) { result.push_back(std::string(it.name())); } }
void CBouquet::removeService(CZapitChannel* oldChannel) { if (oldChannel != NULL) { ChannelList* channels = &tvChannels; switch (oldChannel->getServiceType()) { case ST_DIGITAL_TELEVISION_SERVICE: case ST_NVOD_REFERENCE_SERVICE: case ST_NVOD_TIME_SHIFTED_SERVICE: channels = &tvChannels; break; case ST_DIGITAL_RADIO_SOUND_SERVICE: channels = &radioChannels; break; } (*channels).erase(remove(channels->begin(), channels->end(), oldChannel), channels->end()); } }
ChannelInfo ChannelData::FindMatchingChannel(const ChannelInfo &chanInfo, ChannelList existingChannels) const { ChannelList::iterator it; for (it = existingChannels.begin(); it != existingChannels.end(); ++it) { if ((*it).xmltvid == chanInfo.xmltvid) return (*it); } QString searchKey = normalizeChannelKey(chanInfo.name); ChannelInfo existChan = existingChannels.value(searchKey); if (existChan.chanid < 1) { // Check if it is ATSC int chansep = chanInfo.channum.indexOf(QRegExp("\\D")); if (chansep > 0) { // Populate xmltvid for scanned ATSC channels uint major = chanInfo.channum.left(chansep).toInt(); uint minor = chanInfo.channum.right (chanInfo.channum.length() - (chansep + 1)).toInt(); for (it = existingChannels.begin(); it != existingChannels.end(); ++it) { if ((*it).atsc_major_chan == major && (*it).atsc_minor_chan == minor) return (*it); } } } return existChan; }
void printChannelList (const ChannelList &cl) { for (ChannelList::ConstIterator i = cl.begin(); i != cl.end(); ++i) { cout << "\n " << i.name() << ", "; printPixelType (i.channel().type); cout << ", sampling " << i.channel().xSampling << " " << i.channel().ySampling; if (i.channel().pLinear) cout << ", plinear"; } }
Channel * ChannelMgr::GetChannel(const char *name, uint32 team) { ChannelList::iterator itr; ChannelList * cl = &Channels[0]; if(seperatechannels) cl = &Channels[team]; lock.Acquire(); for(itr = cl->begin(); itr != cl->end(); ++itr) { if(!stricmp(name, itr->first.c_str())) { lock.Release(); return itr->second; } } lock.Release(); return NULL; }
Channel * ChannelMgr::GetChannel(const char *name, Player * p) { ChannelList::iterator itr; ChannelList * cl = &Channels[0]; if(seperatechannels && stricmp(name, sWorld.getGmClientChannel().c_str())) cl = &Channels[p->GetTeam()]; lock.Acquire(); for(itr = cl->begin(); itr != cl->end(); ++itr) { if(!stricmp(name, itr->first.c_str())) { lock.Release(); return itr->second; } } lock.Release(); return NULL; }
// Prepares a framebuffer for the requested channels, allocating also the // appropriate Matlab memory void vtkOpenEXR::prepareFrameBuffer(FrameBuffer & fb, const Box2i & dataWindow, const ChannelList & channels, const std::vector<std::string> & requestedChannels, std::vector< Array2D<float> *> & outData) // std::vector<mxArray *> & outMatlabData { assert(!requestedChannels.empty()); const Box2i & dw = dataWindow; const int width = dw.max.x - dw.min.x + 1; const int height = dw.max.y - dw.min.y + 1; // The "weird" strides are because Matlab uses column-major order (check this out later) // const int xStride = height; // for matlab // const int yStride = 1; const int xStride = 1; const int yStride = width; // for c++ // Offset for all the slices const off_t offset = - (dw.min.x * xStride + dw.min.y * yStride); // why negative? for (size_t i = 0; i != requestedChannels.size(); ++i) { // Allocate the memory //mxArray * data = mxCreateNumericMatrix(height, width, mxSINGLE_CLASS, mxREAL); Array2D<float> * data = new Array2D<float>; //Array2D<float> * data(height, width); data->resizeErase(height, width); outData[i] = data; float * ptr = static_cast<float*>(data[0][0]); // check this out // Get the appropriate sampling factors int xSampling = 1, ySampling = 1; ChannelList::ConstIterator cIt = channels.find(requestedChannels[i].c_str()); if (cIt != channels.end()) { xSampling = cIt.channel().xSampling; ySampling = cIt.channel().ySampling; } // Insert the slice in the framebuffer fb.insert(requestedChannels[i].c_str(), Slice(FLOAT, (char*)(ptr + offset), sizeof(float) * xStride, sizeof(float) * yStride, xSampling, ySampling)); } }
void ChannelMgr::RemoveChannel(Channel * chn) { ChannelList::iterator itr; ChannelList * cl = &Channels[0]; if(seperatechannels) cl = &Channels[chn->m_team]; lock.Acquire(); for(itr = cl->begin(); itr != cl->end(); ++itr) { if(itr->second == chn) { cl->erase(itr); delete chn; lock.Release(); return; } } lock.Release(); }
Channel * ChannelMgr::GetCreateChannel(const char *name, Player * p, uint32 type_id) { ChannelList::iterator itr; ChannelList * cl = &Channels[0]; Channel * chn; uint32 cid; if( seperatechannels && p != NULL ) cl = &Channels[p->GetTeam()]; lock.Acquire(); for(itr = cl->begin(); itr != cl->end(); ++itr) { if(!stricmp(name, itr->first.c_str())) { lock.Release(); return itr->second; } } // make sure the name isn't banned m_confSettingLock.Acquire(); for(vector<string>::iterator itr = m_bannedChannels.begin(); itr != m_bannedChannels.end(); ++itr) { if(!strnicmp( name, itr->c_str(), itr->size() ) ) { lock.Release(); m_confSettingLock.Release(); return NULL; } } m_confSettingLock.Release(); cid = ++m_idHigh; chn = new Channel(name, ( seperatechannels && p != NULL ) ? p->GetTeam() : 0, type_id, cid); cl->insert(make_pair(chn->m_name, chn)); m_idToChannel.insert(make_pair(cid, chn)); lock.Release(); return chn; }
string channelInOtherView (const string &channelName, const ChannelList &channelList, const StringVector &multiView, const string &otherViewName) { // // Given the name of a channel in one view, return the // corresponding channel name for view otherViewName. // for (ChannelList::ConstIterator i=channelList.begin(); i != channelList.end(); ++i) { if (viewFromChannelName (i.name(), multiView) == otherViewName && areCounterparts (i.name(), channelName, multiView)) { return i.name(); } } return ""; }
Channel * ChannelMgr::GetChannel(const char *name, Player* p, bool requiresIn) { uint32 rteam = seperatechannels && p != NULL ? p->GetTeam() : 0; ChannelList::iterator itr; ChannelList * cl = &Channels[rteam]; lock.Acquire(); for(itr = cl->begin(); itr != cl->end(); itr++) { if(!stricmp(name, itr->first.c_str())) { if(requiresIn && !itr->second->HasMember(p)) continue; lock.Release(); return itr->second; } } DBCChannelMap::iterator itr2; DBCChannelMap *dbcchannel = &DBCChannels[rteam]; for(itr2 = dbcchannel->begin(); itr2 != dbcchannel->end(); itr2++) { if(!stricmp(name, itr2->second.first.c_str())) { if(requiresIn && !itr2->second.second->HasMember(p)) continue; lock.Release(); return itr2->second.second; } } lock.Release(); return NULL; }
Channel* ChannelMgr::GetCreateChannel(const char* name, Player* p, uint32 type_id) { ChannelList::iterator itr; ChannelList* cl = &Channels[0]; Channel* chn; if(seperatechannels && p != NULL && stricmp(name, sWorld.getGmClientChannel().c_str())) cl = &Channels[p->GetTeam()]; lock.Acquire(); for(itr = cl->begin(); itr != cl->end(); ++itr) { if(!stricmp(name, itr->first.c_str())) { lock.Release(); return itr->second; } } // make sure the name isn't banned m_confSettingLock.Acquire(); for(vector<string>::iterator itr2 = m_bannedChannels.begin(); itr2 != m_bannedChannels.end(); ++itr2) { if(!strnicmp(name, itr2->c_str(), itr2->size())) { lock.Release(); m_confSettingLock.Release(); return NULL; } } chn = new Channel(name, (seperatechannels && p != NULL) ? p->GetTeam() : 0, type_id); m_confSettingLock.Release();//Channel::Channel() reads configs so we release the lock after we create the Channel. cl->insert(make_pair(chn->m_name, chn)); lock.Release(); return chn; }
void writeChannelList(FILE * const bouq_fd, const ChannelList & list, const bool write_names, const char * const channel_printf_string) { for (ChannelList::const_iterator it = list.begin(); it != list.end(); ++it) { const CZapitChannel * c = *it; if (write_names) { fprintf(bouq_fd, channel_printf_string, c->getServiceId(), convert_UTF8_To_UTF8_XML(c->getName().c_str()).c_str(), c->getTransportStreamId(), c->getOriginalNetworkId(), c->getSatellitePosition()); } else { fprintf(bouq_fd, channel_printf_string, c->getServiceId(), c->getTransportStreamId(), c->getOriginalNetworkId(), c->getSatellitePosition()); } } }
void ProtocolManager::parsePacket(NetworkMessage& msg) { if(g_game.getGameState() == GAMESTATE_SHUTDOWN) { getConnection()->close(); return; } uint8_t recvbyte = msg.get<char>(); OutputMessage_ptr output = getOutputBuffer(); if(!output) return; TRACK_MESSAGE(output); switch(m_state) { case NO_LOGGED_IN: { if((time(NULL) - m_startTime) > 30000) { //login timeout getConnection()->close(); addLogLine(LOGTYPE_WARNING, "Login timeout"); return; } if(m_loginTries > 3) { output->put<char>(MP_MSG_ERROR); output->putString("Too many login attempts"); getConnection()->send(output); getConnection()->close(); addLogLine(LOGTYPE_WARNING, "Too many login attempts"); return; } if(recvbyte != MP_MSG_LOGIN) { output->put<char>(MP_MSG_ERROR); output->putString("You are not logged in"); getConnection()->send(output); getConnection()->close(); addLogLine(LOGTYPE_WARNING, "Wrong command while not logged in"); return; } break; } case LOGGED_IN: break; default: { getConnection()->close(); addLogLine(LOGTYPE_ERROR, "No valid connection state"); return; } } m_lastCommand = time(NULL); switch(recvbyte) { case MP_MSG_LOGIN: { if(m_state == NO_LOGGED_IN) { std::string pass = msg.getString(), word = g_config.getString(ConfigManager::MANAGER_PASSWORD); _encrypt(word, false); if(pass == word) { if(!Manager::getInstance()->loginConnection(this)) { output->put<char>(MP_MSG_FAILURE); output->putString("Unknown connection"); getConnection()->send(output); getConnection()->close(); addLogLine(LOGTYPE_ERROR, "Login failed due to unknown connection"); return; } else { m_state = LOGGED_IN; output->put<char>(MP_MSG_USERS); addLogLine(LOGTYPE_EVENT, "Logged in, sending users"); std::map<uint32_t, std::string> users; for(AutoList<Player>::iterator it = Player::autoList.begin(); it != Player::autoList.end(); ++it) { if(!it->second->isRemoved()) users[it->first] = it->second->getName(); } output->put<uint16_t>(users.size()); for(std::map<uint32_t, std::string>::iterator it = users.begin(); it != users.end(); ++it) { output->put<uint32_t>(it->first); output->putString(it->second); } } } else { output->put<char>(MP_MSG_FAILURE); output->putString("Wrong password"); m_loginTries++; addLogLine(LOGTYPE_EVENT, "Login failed due to wrong password (" + pass + ")"); } } else { output->put<char>(MP_MSG_FAILURE); output->putString("Cannot login right now!"); addLogLine(LOGTYPE_ERROR, "Wrong state at login"); } break; } case MP_MSG_LOGOUT: { output->put<char>(MP_MSG_BYE); output->putString("Bye, bye!"); getConnection()->send(output); getConnection()->close(); addLogLine(LOGTYPE_EVENT, "Logout"); return; } case MP_MSG_KEEP_ALIVE: break; case MP_MSG_PING: output->put<char>(MP_MSG_PONG); break; case MP_MSG_LUA: { std::string script = msg.getString(); if(!Manager::getInstance()->execute(script)) { output->put<char>(MP_MSG_FAILURE); output->putString("Unable to reserve enviroment for Lua script"); addLogLine(LOGTYPE_ERROR, "Unable to reserve enviroment for Lua script"); } else { output->put<char>(MP_MSG_SUCCESS); addLogLine(LOGTYPE_EVENT, "Executed Lua script"); } break; } case MP_MSG_USER_INFO: { uint32_t playerId = msg.get<uint32_t>(); if(Player* player = g_game.getPlayerByID(playerId)) { output->put<char>(MP_MSG_USER_DATA); output->put<uint32_t>(playerId); output->put<uint32_t>(player->getGroupId()); output->put<uint32_t>(player->getVocationId()); output->put<uint32_t>(player->getLevel()); output->put<uint32_t>(player->getMagicLevel()); // TODO? } else { output->put<char>(MP_MSG_FAILURE); output->putString("Player not found"); } } case MP_MSG_CHAT_REQUEST: { output->put<char>(MP_MSG_CHAT_LIST); ChannelList list = g_chat.getPublicChannels(); output->put<uint16_t>(list.size()); for(ChannelList::const_iterator it = list.begin(); it != list.end(); ++it) { output->put<uint16_t>((*it)->getId()); output->putString((*it)->getName()); output->put<uint16_t>((*it)->getFlags()); output->put<uint16_t>((*it)->getUsers().size()); } break; } case MP_MSG_CHAT_OPEN: { ChatChannel* channel = NULL; uint16_t channelId = msg.get<uint16_t>(); if((channel = g_chat.getChannelById(channelId)) && g_chat.isPublicChannel(channelId)) { m_channels |= (uint32_t)channelId; output->put<char>(MP_MSG_CHAT_USERS); UsersMap users = channel->getUsers(); output->put<uint16_t>(users.size()); for(UsersMap::const_iterator it = users.begin(); it != users.end(); ++it) output->put<uint32_t>(it->first); } else { output->put<char>(MP_MSG_FAILURE); output->putString("Invalid channel"); } break; } case MP_MSG_CHAT_CLOSE: { uint16_t channelId = msg.get<uint16_t>(); if(g_chat.getChannelById(channelId) && g_chat.isPublicChannel(channelId)) { m_channels &= ~(uint32_t)channelId; output->put<char>(MP_MSG_SUCCESS); } else { output->put<char>(MP_MSG_FAILURE); output->putString("Invalid channel"); } break; } case MP_MSG_CHAT_TALK: { std::string name = msg.getString(); uint16_t channelId = msg.get<uint16_t>(); SpeakClasses type = (SpeakClasses)msg.get<char>(); std::string message = msg.getString(); ChatChannel* channel = NULL; if((channel = g_chat.getChannelById(channelId)) && g_chat.isPublicChannel(channelId)) { if(!channel->talk(name, type, message)) { output->put<char>(MP_MSG_FAILURE); output->putString("Could not talk to channel"); } else output->put<char>(MP_MSG_SUCCESS); } else { output->put<char>(MP_MSG_FAILURE); output->putString("Invalid channel"); } break; } default: { output->put<char>(MP_MSG_ERROR); output->putString("Unknown command"); addLogLine(LOGTYPE_WARNING, "Unknown command"); break; } } }