======================================================================= -- Static functions -------------------------------------------------- ======================================================================= Called recursive
| 90 | // ======================================================================= |
| 91 | // Called recursive |
| 92 | static void getAttachedFrontends( |
| 93 | StreamSpVector &streamVector, |
| 94 | const std::string &appDataPath, |
| 95 | decrypt::dvbapi::SpClient decrypt, |
| 96 | const std::string &path, |
| 97 | const std::string &startPath) { |
| 98 | const std::string ADAPTER = startPath + "/adapter%1"; |
| 99 | const std::string DMX = ADAPTER + "/demux%2"; |
| 100 | const std::string DVR = ADAPTER + "/dvr%2"; |
| 101 | const std::string FRONTEND = ADAPTER + "/frontend%2"; |
| 102 | #if SIMU |
| 103 | // unused var |
| 104 | (void)path; |
| 105 | |
| 106 | const std::string fe0 = StringConverter::stringFormat(FRONTEND.c_str(), 0, 0); |
| 107 | const std::string dvr0 = StringConverter::stringFormat(DVR.c_str(), 0, 0); |
| 108 | const std::string dmx0 = StringConverter::stringFormat(DMX.c_str(), 0, 0); |
| 109 | input::dvb::SpFrontend frontend0 = std::make_shared<input::dvb::Frontend>(0, appDataPath, fe0, dvr0, dmx0); |
| 110 | streamVector.push_back(std::make_shared<Stream>(0, frontend0, decrypt)); |
| 111 | |
| 112 | const std::string fe1 = StringConverter::stringFormat(FRONTEND.c_str(), 1, 0); |
| 113 | const std::string dvr1 = StringConverter::stringFormat(DVR.c_str(), 1, 0); |
| 114 | const std::string dmx1 = StringConverter::stringFormat(DMX.c_str(), 1, 0); |
| 115 | input::dvb::SpFrontend frontend1 = std::make_shared<input::dvb::Frontend>(1, appDataPath, fe1, dvr1, dmx1); |
| 116 | streamVector.push_back(std::make_shared<Stream>(1, frontend1, decrypt)); |
| 117 | #else |
| 118 | dirent **file_list; |
| 119 | const int n = scandir(path.c_str(), &file_list, nullptr, alphasort); |
| 120 | if (n > 0) { |
| 121 | for (int i = 0; i < n; ++i) { |
| 122 | const std::string full_path = StringConverter::stringFormat("%1/%2", path, file_list[i]->d_name); |
| 123 | struct stat stat_buf; |
| 124 | if (stat(full_path.c_str(), &stat_buf) == 0) { |
| 125 | switch (stat_buf.st_mode & S_IFMT) { |
| 126 | case S_IFCHR: // character device |
| 127 | if (strstr(file_list[i]->d_name, "frontend") != nullptr) { |
| 128 | int fe_nr; |
| 129 | sscanf(file_list[i]->d_name, "frontend%d", &fe_nr); |
| 130 | int adapt_nr; |
| 131 | const std::string ADAPTER_TMP = startPath + "/adapter%d"; |
| 132 | sscanf(path.c_str(), ADAPTER_TMP.c_str(), &adapt_nr); |
| 133 | |
| 134 | // Make new paths |
| 135 | const std::string fe = StringConverter::stringFormat(FRONTEND.c_str(), adapt_nr, fe_nr); |
| 136 | const std::string dvr = StringConverter::stringFormat(DVR.c_str(), adapt_nr, fe_nr); |
| 137 | const std::string dmx = StringConverter::stringFormat(DMX.c_str(), adapt_nr, fe_nr); |
| 138 | |
| 139 | // Make new frontend here |
| 140 | const StreamSpVector::size_type size = streamVector.size(); |
| 141 | const input::dvb::SpFrontend frontend = std::make_shared<input::dvb::Frontend>(size, appDataPath, fe, dvr, dmx); |
| 142 | streamVector.push_back(std::make_shared<Stream>(size, frontend, decrypt)); |
| 143 | } |
| 144 | break; |
| 145 | case S_IFDIR: |
| 146 | // do not use dir '.' an '..' |
| 147 | if (strcmp(file_list[i]->d_name, ".") != 0 && strcmp(file_list[i]->d_name, "..") != 0) { |
| 148 | getAttachedFrontends(streamVector, appDataPath, decrypt, full_path, startPath); |
| 149 | } |