Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <binder/MemoryDealer.h> |
| 18 | |
| 19 | #include "../../../config/TunerTestingConfigAidlReaderV1_0.h" |
| 20 | |
| 21 | #include <aidl/android/hardware/tv/tuner/DataFormat.h> |
| 22 | #include <aidl/android/hardware/tv/tuner/DemuxAlpFilterType.h> |
| 23 | #include <aidl/android/hardware/tv/tuner/DemuxFilterMainType.h> |
| 24 | #include <aidl/android/hardware/tv/tuner/DemuxFilterMonitorEventType.h> |
| 25 | #include <aidl/android/hardware/tv/tuner/DemuxFilterSettings.h> |
| 26 | #include <aidl/android/hardware/tv/tuner/DemuxFilterType.h> |
| 27 | #include <aidl/android/hardware/tv/tuner/DemuxIpAddress.h> |
| 28 | #include <aidl/android/hardware/tv/tuner/DemuxIpFilterSettings.h> |
| 29 | #include <aidl/android/hardware/tv/tuner/DemuxIpFilterType.h> |
| 30 | #include <aidl/android/hardware/tv/tuner/DemuxMmtpFilterType.h> |
| 31 | #include <aidl/android/hardware/tv/tuner/DemuxRecordScIndexType.h> |
| 32 | #include <aidl/android/hardware/tv/tuner/DemuxTsFilterType.h> |
| 33 | #include <aidl/android/hardware/tv/tuner/DvrSettings.h> |
| 34 | #include <aidl/android/hardware/tv/tuner/DvrType.h> |
| 35 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtBandwidth.h> |
| 36 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtCoderate.h> |
| 37 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtConstellation.h> |
| 38 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtGuardInterval.h> |
| 39 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtHierarchy.h> |
| 40 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtSettings.h> |
| 41 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtStandard.h> |
| 42 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtTransmissionMode.h> |
| 43 | #include <aidl/android/hardware/tv/tuner/FrontendSettings.h> |
| 44 | #include <aidl/android/hardware/tv/tuner/FrontendType.h> |
| 45 | #include <aidl/android/hardware/tv/tuner/PlaybackSettings.h> |
| 46 | #include <aidl/android/hardware/tv/tuner/RecordSettings.h> |
| 47 | |
| 48 | using namespace std; |
| 49 | using namespace aidl::android::hardware::tv::tuner; |
| 50 | using namespace android::media::tuner::testing::configuration::V1_0; |
| 51 | |
| 52 | const int32_t FMQ_SIZE_4M = 0x400000; |
| 53 | const int32_t FMQ_SIZE_16M = 0x1000000; |
| 54 | |
Hongguang | 16dacc1 | 2021-11-01 15:51:52 -0700 | [diff] [blame] | 55 | const string configFilePath = "/vendor/etc/tuner_vts_config_aidl_V1.xml"; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 56 | |
| 57 | #define FILTER_MAIN_TYPE_BIT_COUNT 5 |
| 58 | |
| 59 | // Hardware configs |
| 60 | static map<string, FrontendConfig> frontendMap; |
| 61 | static map<string, FilterConfig> filterMap; |
| 62 | static map<string, DvrConfig> dvrMap; |
| 63 | static map<string, LnbConfig> lnbMap; |
| 64 | static map<string, TimeFilterConfig> timeFilterMap; |
| 65 | static map<string, vector<uint8_t>> diseqcMsgMap; |
| 66 | static map<string, DescramblerConfig> descramblerMap; |
| 67 | |
| 68 | // Hardware and test cases connections |
| 69 | static LiveBroadcastHardwareConnections live; |
| 70 | static ScanHardwareConnections scan; |
| 71 | static DvrPlaybackHardwareConnections playback; |
| 72 | static DvrRecordHardwareConnections record; |
| 73 | static DescramblingHardwareConnections descrambling; |
| 74 | static LnbLiveHardwareConnections lnbLive; |
| 75 | static LnbRecordHardwareConnections lnbRecord; |
| 76 | static TimeFilterHardwareConnections timeFilter; |
| 77 | |
Frankie Lizcano | a53f554 | 2022-07-07 17:32:06 +0000 | [diff] [blame] | 78 | /* |
| 79 | * This function takes in a 2d vector of device Id's |
| 80 | * The n vectors correlate to the ids for n different devices (eg frontends, filters) |
| 81 | * The resultant 2d vector is every combination of id's with 1 id from each vector |
| 82 | */ |
| 83 | inline vector<vector<string>> generateIdCombinations(vector<vector<string>>& ids) { |
| 84 | vector<vector<string>> combinations; |
| 85 | |
| 86 | // The index of each vector in ids that will be used in the next combination |
| 87 | // EG {0, 2} means combo {ids[0][0] ids[1][2]} will be next |
| 88 | const int size = static_cast<int>(ids.size()); |
| 89 | vector<int> indexes_used_in_combination(size, 0); |
| 90 | |
| 91 | // The vector number from ids whose elements we will cycle through to make combinations. |
| 92 | // First, start at the right most vector |
| 93 | int cycled_vector = size - 1; |
| 94 | |
| 95 | while (cycled_vector >= 0) { |
| 96 | // Make a combination (one at a time) |
| 97 | vector<string> combo; |
| 98 | for (size_t i = 0; i < indexes_used_in_combination.size(); ++i) { |
| 99 | const int combo_index = indexes_used_in_combination[i]; |
| 100 | combo.push_back(ids[i][combo_index]); |
| 101 | } |
| 102 | combinations.push_back(combo); |
| 103 | |
| 104 | // Find the right most vector that still has space [elements left] to cycle through and |
| 105 | // create a combination |
| 106 | while (cycled_vector >= 0 && |
| 107 | indexes_used_in_combination[cycled_vector] == ids[cycled_vector].size() - 1) { |
| 108 | cycled_vector--; |
| 109 | } |
| 110 | |
| 111 | // Use this check to avoid segmentation faults |
| 112 | if (cycled_vector >= 0) { |
| 113 | // Once found, we have a vector we can cycle through, so increase to its next element |
| 114 | indexes_used_in_combination[cycled_vector]++; |
| 115 | |
| 116 | // Reset the other vectors to the right to their first element so we can cycle through |
| 117 | // them again with the new element from cycled vector |
| 118 | for (size_t i = cycled_vector + 1; i < indexes_used_in_combination.size(); ++i) { |
| 119 | indexes_used_in_combination[i] = 0; |
| 120 | } |
| 121 | |
| 122 | // all the vectors to the right were reset, so we can cycle through them again |
| 123 | // Start at the furthest right vector |
| 124 | cycled_vector = size - 1; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | return combinations; |
| 129 | } |
| 130 | |
| 131 | /* |
| 132 | * index 0 - playback dvr |
| 133 | * index 1 - audio filters |
Frankie Lizcano | 14aa848 | 2022-07-26 16:50:35 +0000 | [diff] [blame] | 134 | * index 2 - optional section filters |
Frankie Lizcano | a53f554 | 2022-07-07 17:32:06 +0000 | [diff] [blame] | 135 | */ |
| 136 | static inline vector<DvrPlaybackHardwareConnections> generatePlaybackCombinations() { |
| 137 | vector<DvrPlaybackHardwareConnections> combinations; |
| 138 | vector<string> sectionFilterIds_optional = sectionFilterIds; |
| 139 | sectionFilterIds_optional.push_back(emptyHardwareId); |
Frankie Lizcano | 14aa848 | 2022-07-26 16:50:35 +0000 | [diff] [blame] | 140 | vector<vector<string>> deviceIds{playbackDvrIds, audioFilterIds, sectionFilterIds_optional}; |
Frankie Lizcano | a53f554 | 2022-07-07 17:32:06 +0000 | [diff] [blame] | 141 | |
| 142 | const int dvrIndex = 0; |
| 143 | const int audioFilterIndex = 1; |
Frankie Lizcano | 14aa848 | 2022-07-26 16:50:35 +0000 | [diff] [blame] | 144 | const int sectionFilterIndex = 2; |
Frankie Lizcano | a53f554 | 2022-07-07 17:32:06 +0000 | [diff] [blame] | 145 | |
| 146 | auto idCombinations = generateIdCombinations(deviceIds); |
| 147 | for (auto& combo : idCombinations) { |
| 148 | DvrPlaybackHardwareConnections mPlayback; |
| 149 | mPlayback.dvrId = combo[dvrIndex]; |
| 150 | mPlayback.audioFilterId = combo[audioFilterIndex]; |
Frankie Lizcano | a53f554 | 2022-07-07 17:32:06 +0000 | [diff] [blame] | 151 | mPlayback.sectionFilterId = combo[sectionFilterIndex]; |
Frankie Lizcano | 14aa848 | 2022-07-26 16:50:35 +0000 | [diff] [blame] | 152 | const int videoFilterIndex = |
| 153 | find(audioFilterIds.begin(), audioFilterIds.end(), mPlayback.audioFilterId) - |
| 154 | audioFilterIds.begin(); |
| 155 | mPlayback.videoFilterId = videoFilterIds[videoFilterIndex]; |
Frankie Lizcano | a53f554 | 2022-07-07 17:32:06 +0000 | [diff] [blame] | 156 | combinations.push_back(mPlayback); |
| 157 | } |
| 158 | |
| 159 | return combinations; |
| 160 | } |
| 161 | |
| 162 | static inline vector<DvrPlaybackHardwareConnections> generatePlaybackConfigs() { |
| 163 | vector<DvrPlaybackHardwareConnections> playback_configs; |
| 164 | if (configuredPlayback) { |
| 165 | ALOGD("Using DVR playback configuration provided."); |
| 166 | playback_configs = {playback}; |
| 167 | } else { |
| 168 | ALOGD("Dvr playback not provided. Generating possible combinations. Consider adding it to " |
| 169 | "the configuration file."); |
| 170 | playback_configs = generatePlaybackCombinations(); |
| 171 | } |
| 172 | |
| 173 | return playback_configs; |
| 174 | } |
| 175 | |
Frankie Lizcano | 1e283b3 | 2022-07-08 21:07:42 +0000 | [diff] [blame] | 176 | /* |
| 177 | * index 0 - frontends |
| 178 | * index 1 - audio filters |
Frankie Lizcano | 14aa848 | 2022-07-26 16:50:35 +0000 | [diff] [blame] | 179 | * index 2 - lnbs |
Frankie Lizcano | 1e283b3 | 2022-07-08 21:07:42 +0000 | [diff] [blame] | 180 | */ |
| 181 | static inline vector<LnbLiveHardwareConnections> generateLnbLiveCombinations() { |
| 182 | vector<LnbLiveHardwareConnections> combinations; |
Frankie Lizcano | 14aa848 | 2022-07-26 16:50:35 +0000 | [diff] [blame] | 183 | vector<vector<string>> deviceIds{frontendIds, audioFilterIds, lnbIds}; |
Frankie Lizcano | 1e283b3 | 2022-07-08 21:07:42 +0000 | [diff] [blame] | 184 | |
| 185 | const int frontendIndex = 0; |
| 186 | const int audioFilterIndex = 1; |
Frankie Lizcano | 14aa848 | 2022-07-26 16:50:35 +0000 | [diff] [blame] | 187 | const int lnbIndex = 2; |
Frankie Lizcano | 1e283b3 | 2022-07-08 21:07:42 +0000 | [diff] [blame] | 188 | |
| 189 | // TODO: Find a better way to vary diseqcMsgs, if at all |
| 190 | auto idCombinations = generateIdCombinations(deviceIds); |
| 191 | for (auto& combo : idCombinations) { |
| 192 | const string feId = combo[frontendIndex]; |
| 193 | auto type = frontendMap[feId].type; |
| 194 | if (type == FrontendType::DVBS || type == FrontendType::ISDBS || |
| 195 | type == FrontendType::ISDBS3) { |
| 196 | LnbLiveHardwareConnections mLnbLive; |
| 197 | mLnbLive.frontendId = feId; |
| 198 | mLnbLive.audioFilterId = combo[audioFilterIndex]; |
Frankie Lizcano | 14aa848 | 2022-07-26 16:50:35 +0000 | [diff] [blame] | 199 | const int videoFilterIndex = |
| 200 | find(audioFilterIds.begin(), audioFilterIds.end(), mLnbLive.audioFilterId) - |
| 201 | audioFilterIds.begin(); |
| 202 | mLnbLive.videoFilterId = videoFilterIds[videoFilterIndex]; |
Frankie Lizcano | 1e283b3 | 2022-07-08 21:07:42 +0000 | [diff] [blame] | 203 | mLnbLive.lnbId = combo[lnbIndex]; |
| 204 | mLnbLive.diseqcMsgs = diseqcMsgs; |
| 205 | combinations.push_back(mLnbLive); |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | return combinations; |
| 210 | } |
| 211 | |
| 212 | static inline vector<LnbLiveHardwareConnections> generateLnbLiveConfigurations() { |
| 213 | vector<LnbLiveHardwareConnections> lnbLive_configs; |
| 214 | if (configuredLnbLive) { |
| 215 | ALOGD("Using LnbLive configuration provided."); |
| 216 | lnbLive_configs = {lnbLive}; |
| 217 | } else { |
| 218 | ALOGD("LnbLive not provided. Generating possible combinations. Consider adding it to the " |
| 219 | "configuration file."); |
| 220 | lnbLive_configs = generateLnbLiveCombinations(); |
| 221 | } |
| 222 | |
| 223 | return lnbLive_configs; |
| 224 | } |
| 225 | |
Frankie Lizcano | 3138d6b | 2022-07-11 22:06:45 +0000 | [diff] [blame] | 226 | static inline vector<ScanHardwareConnections> generateScanCombinations() { |
| 227 | vector<ScanHardwareConnections> combinations; |
| 228 | |
| 229 | for (auto& id : frontendIds) { |
| 230 | ScanHardwareConnections mScan; |
| 231 | mScan.frontendId = id; |
| 232 | combinations.push_back(mScan); |
| 233 | } |
| 234 | |
| 235 | return combinations; |
| 236 | } |
| 237 | |
| 238 | static inline vector<ScanHardwareConnections> generateScanConfigurations() { |
| 239 | vector<ScanHardwareConnections> scan_configs; |
| 240 | if (configuredScan) { |
| 241 | ALOGD("Using scan configuration provided."); |
| 242 | scan_configs = {scan}; |
| 243 | } else { |
| 244 | ALOGD("Scan not provided. Generating possible combinations. Consider adding it to " |
| 245 | "the configuration file."); |
| 246 | scan_configs = generateScanCombinations(); |
| 247 | } |
| 248 | |
| 249 | return scan_configs; |
| 250 | } |
| 251 | |
Frankie Lizcano | ecba02a | 2022-07-12 17:56:54 +0000 | [diff] [blame] | 252 | /* |
| 253 | * index 0 - frontends |
| 254 | * index 1 - record filter |
| 255 | * index 2 - Record Dvr |
| 256 | * index 3 - Lnb |
| 257 | */ |
| 258 | static inline vector<LnbRecordHardwareConnections> generateLnbRecordCombinations() { |
| 259 | vector<LnbRecordHardwareConnections> combinations; |
| 260 | vector<vector<string>> deviceIds{frontendIds, recordFilterIds, recordDvrIds, lnbIds}; |
| 261 | |
| 262 | const int frontendIndex = 0; |
| 263 | const int recordFilterIndex = 1; |
| 264 | const int dvrIndex = 2; |
| 265 | const int lnbIndex = 3; |
| 266 | |
| 267 | auto idCombinations = generateIdCombinations(deviceIds); |
| 268 | // TODO : Find a better way to vary diseqcMsgs, if at all |
| 269 | for (auto& combo : idCombinations) { |
| 270 | const string feId = combo[frontendIndex]; |
| 271 | auto type = frontendMap[feId].type; |
| 272 | if (type == FrontendType::DVBS || type == FrontendType::ISDBS || |
| 273 | type == FrontendType::ISDBS3) { |
| 274 | LnbRecordHardwareConnections mLnbRecord; |
| 275 | mLnbRecord.frontendId = feId; |
| 276 | mLnbRecord.recordFilterId = combo[recordFilterIndex]; |
| 277 | mLnbRecord.dvrRecordId = combo[dvrIndex]; |
| 278 | mLnbRecord.lnbId = combo[lnbIndex]; |
| 279 | mLnbRecord.diseqcMsgs = diseqcMsgs; |
| 280 | combinations.push_back(mLnbRecord); |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | return combinations; |
| 285 | } |
| 286 | |
| 287 | static inline vector<LnbRecordHardwareConnections> generateLnbRecordConfigurations() { |
| 288 | vector<LnbRecordHardwareConnections> lnbRecord_configs; |
| 289 | if (configuredLnbRecord) { |
| 290 | ALOGD("Using LnbRecord configuration provided."); |
| 291 | lnbRecord_configs = {lnbRecord}; |
| 292 | } else { |
| 293 | ALOGD("LnbRecord not provided. Generating possible combinations. Consider adding it to " |
| 294 | "the configuration file."); |
| 295 | lnbRecord_configs = generateLnbRecordCombinations(); |
| 296 | } |
| 297 | |
| 298 | return lnbRecord_configs; |
| 299 | } |
| 300 | |
Frankie Lizcano | f4e0796 | 2022-07-13 20:54:34 +0000 | [diff] [blame] | 301 | /* |
| 302 | * index 0 - decramblers |
| 303 | * index 1 - frontends |
| 304 | * index 2 - audio filters |
Frankie Lizcano | 14aa848 | 2022-07-26 16:50:35 +0000 | [diff] [blame] | 305 | * index 3 - Dvr SW Fe Connections |
| 306 | * index 4 - DVR Source Connections |
Frankie Lizcano | f4e0796 | 2022-07-13 20:54:34 +0000 | [diff] [blame] | 307 | */ |
| 308 | static inline vector<DescramblingHardwareConnections> generateDescramblingCombinations() { |
| 309 | vector<DescramblingHardwareConnections> combinations; |
| 310 | vector<string> mfrontendIds = frontendIds; |
| 311 | vector<string> mDvrFeConnectionIds = playbackDvrIds; |
| 312 | vector<string> mDvrSourceConnectionIds = playbackDvrIds; |
| 313 | |
| 314 | // Add the empty hardware id to each vector to include combinations where these 3 fields might |
| 315 | // be optional |
| 316 | mfrontendIds.push_back(emptyHardwareId); |
| 317 | mDvrFeConnectionIds.push_back(emptyHardwareId); |
| 318 | mDvrSourceConnectionIds.push_back(emptyHardwareId); |
| 319 | |
| 320 | const int descramblerIndex = 0; |
| 321 | const int frontendIndex = 1; |
| 322 | const int audioFilterIndex = 2; |
Frankie Lizcano | 14aa848 | 2022-07-26 16:50:35 +0000 | [diff] [blame] | 323 | const int dvrFeIdIndex = 3; |
| 324 | const int dvrSourceIdIndex = 4; |
Frankie Lizcano | f4e0796 | 2022-07-13 20:54:34 +0000 | [diff] [blame] | 325 | |
Frankie Lizcano | 14aa848 | 2022-07-26 16:50:35 +0000 | [diff] [blame] | 326 | vector<vector<string>> deviceIds{descramblerIds, mfrontendIds, audioFilterIds, |
| 327 | mDvrFeConnectionIds, mDvrSourceConnectionIds}; |
Frankie Lizcano | f4e0796 | 2022-07-13 20:54:34 +0000 | [diff] [blame] | 328 | auto idCombinations = generateIdCombinations(deviceIds); |
| 329 | for (auto& combo : idCombinations) { |
| 330 | DescramblingHardwareConnections mDescrambling; |
| 331 | const string feId = combo[frontendIndex]; |
| 332 | const string dvrSwFeId = combo[dvrFeIdIndex]; |
| 333 | const string dvrSourceId = combo[dvrSourceIdIndex]; |
| 334 | mDescrambling.hasFrontendConnection = feId.compare(emptyHardwareId) == 0 ? false : true; |
| 335 | if (!mDescrambling.hasFrontendConnection) { |
| 336 | if (dvrSourceId.compare(emptyHardwareId) == 0) { |
| 337 | // If combination does not have a frontend or dvr source connection, do not include |
| 338 | // it |
| 339 | continue; |
| 340 | } |
| 341 | } else { |
| 342 | if (frontendMap[feId].isSoftwareFe && dvrSwFeId.compare(emptyHardwareId) == 0) { |
| 343 | // If combination has a software frontend and no dvr->software frontend connection, |
| 344 | // do not include it |
| 345 | continue; |
| 346 | } |
| 347 | } |
| 348 | if (dvrSwFeId.compare(dvrSourceId) == 0) { |
| 349 | // If dvr->software frontend connection is the same as dvr source input to tuner, do not |
| 350 | // include it. |
| 351 | continue; |
| 352 | } |
| 353 | mDescrambling.frontendId = feId; |
| 354 | mDescrambling.audioFilterId = combo[audioFilterIndex]; |
Frankie Lizcano | 14aa848 | 2022-07-26 16:50:35 +0000 | [diff] [blame] | 355 | const int videoFilterIndex = |
| 356 | find(audioFilterIds.begin(), audioFilterIds.end(), mDescrambling.audioFilterId) - |
| 357 | audioFilterIds.begin(); |
| 358 | mDescrambling.videoFilterId = videoFilterIds[videoFilterIndex]; |
Frankie Lizcano | f4e0796 | 2022-07-13 20:54:34 +0000 | [diff] [blame] | 359 | mDescrambling.dvrSoftwareFeId = dvrSwFeId; |
| 360 | mDescrambling.dvrSourceId = dvrSourceId; |
| 361 | mDescrambling.descramblerId = combo[descramblerIndex]; |
| 362 | combinations.push_back(mDescrambling); |
| 363 | } |
| 364 | |
| 365 | return combinations; |
| 366 | } |
| 367 | |
| 368 | static inline vector<DescramblingHardwareConnections> generateDescramblingConfigurations() { |
| 369 | vector<DescramblingHardwareConnections> descrambling_configs; |
| 370 | if (configuredDescrambling) { |
| 371 | ALOGD("Using Descrambling configuration provided."); |
| 372 | descrambling_configs = {descrambling}; |
| 373 | } else { |
| 374 | ALOGD("Descrambling not provided. Generating possible combinations. Consider adding it to " |
| 375 | "the " |
| 376 | "configuration file."); |
| 377 | descrambling_configs = generateDescramblingCombinations(); |
| 378 | } |
| 379 | |
| 380 | return descrambling_configs; |
| 381 | } |
| 382 | |
Frankie Lizcano | 0c06953 | 2022-07-14 20:20:46 +0000 | [diff] [blame] | 383 | static inline vector<TimeFilterHardwareConnections> generateTimeFilterCombinations() { |
| 384 | vector<TimeFilterHardwareConnections> combinations; |
| 385 | |
| 386 | for (auto& id : timeFilterIds) { |
| 387 | TimeFilterHardwareConnections mTimeFilter; |
| 388 | mTimeFilter.timeFilterId = id; |
| 389 | combinations.push_back(mTimeFilter); |
| 390 | } |
| 391 | |
| 392 | return combinations; |
| 393 | } |
| 394 | |
| 395 | static inline vector<TimeFilterHardwareConnections> generateTimeFilterConfigurations() { |
| 396 | vector<TimeFilterHardwareConnections> timeFilter_configs; |
| 397 | if (configuredTimeFilter) { |
| 398 | ALOGD("Using TimeFilter configuration provided."); |
| 399 | timeFilter_configs = {timeFilter}; |
| 400 | } else { |
| 401 | ALOGD("TimeFilter not provided. Generating possible combinations. Consider adding it to " |
| 402 | "the " |
| 403 | "configuration file."); |
| 404 | timeFilter_configs = generateTimeFilterCombinations(); |
| 405 | } |
| 406 | |
| 407 | return timeFilter_configs; |
| 408 | } |
| 409 | |
Frankie Lizcano | 9c464f7 | 2022-07-18 17:56:52 +0000 | [diff] [blame] | 410 | /* |
| 411 | * index 0 - frontends |
| 412 | * index 1 - record dvrs |
| 413 | * index 2 - record filters |
| 414 | */ |
| 415 | static inline vector<DvrRecordHardwareConnections> generateRecordCombinations() { |
| 416 | vector<DvrRecordHardwareConnections> combinations; |
| 417 | |
| 418 | const int frontendIdIndex = 0; |
| 419 | const int recordDvrIndex = 1; |
| 420 | const int recordFilterIndex = 2; |
| 421 | |
| 422 | vector<vector<string>> deviceIds{frontendIds, recordDvrIds, recordFilterIds}; |
| 423 | |
| 424 | auto idCombinations = generateIdCombinations(deviceIds); |
| 425 | for (auto& combo : idCombinations) { |
| 426 | DvrRecordHardwareConnections mRecord; |
| 427 | const string feId = combo[frontendIdIndex]; |
| 428 | mRecord.hasFrontendConnection = true; |
| 429 | if (frontendMap[feId].isSoftwareFe) { |
| 430 | // If we have a software frontend, do not include configuration for testing. |
| 431 | continue; |
| 432 | } |
| 433 | mRecord.frontendId = feId; |
| 434 | mRecord.support = true; |
| 435 | mRecord.dvrSourceId = emptyHardwareId; |
| 436 | mRecord.dvrSoftwareFeId = emptyHardwareId; |
| 437 | mRecord.recordFilterId = combo[recordFilterIndex]; |
| 438 | mRecord.dvrRecordId = combo[recordDvrIndex]; |
| 439 | combinations.push_back(mRecord); |
| 440 | } |
| 441 | |
| 442 | return combinations; |
| 443 | } |
| 444 | |
| 445 | static inline vector<DvrRecordHardwareConnections> generateRecordConfigurations() { |
| 446 | vector<DvrRecordHardwareConnections> record_configs; |
| 447 | if (configuredRecord) { |
| 448 | ALOGD("Using Record configuration provided."); |
| 449 | record_configs = {record}; |
| 450 | } else { |
| 451 | ALOGD("Record not provided. Generating possible combinations. Consider adding it to " |
| 452 | "the " |
| 453 | "configuration file."); |
| 454 | record_configs = generateRecordCombinations(); |
| 455 | } |
| 456 | |
| 457 | return record_configs; |
| 458 | } |
| 459 | |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame^] | 460 | /* |
| 461 | * index 0 - frontends |
| 462 | * index 1 - audio filters |
| 463 | * index 2 - playback dvrs |
| 464 | * index 3 - section Filters |
| 465 | */ |
| 466 | static inline vector<LiveBroadcastHardwareConnections> generateLiveCombinations() { |
| 467 | vector<LiveBroadcastHardwareConnections> combinations; |
| 468 | vector<string> mSectionFilterIds = sectionFilterIds; |
| 469 | vector<string> mDvrSwConnectionIds = playbackDvrIds; |
| 470 | |
| 471 | // Adding the empty hardware id to cover cases where fields are optional |
| 472 | mSectionFilterIds.push_back(emptyHardwareId); |
| 473 | mDvrSwConnectionIds.push_back(emptyHardwareId); |
| 474 | |
| 475 | const int frontendIdIndex = 0; |
| 476 | const int audioFilterIdIndex = 1; |
| 477 | const int dvrSwConnectionIdIndex = 2; |
| 478 | const int sectionFilterIdIndex = 3; |
| 479 | |
| 480 | vector<vector<string>> deviceIds{frontendIds, audioFilterIds, mDvrSwConnectionIds, |
| 481 | mSectionFilterIds}; |
| 482 | |
| 483 | auto idCombinations = generateIdCombinations(deviceIds); |
| 484 | for (auto& combo : idCombinations) { |
| 485 | LiveBroadcastHardwareConnections mLive; |
| 486 | const string feId = combo[frontendIdIndex]; |
| 487 | const string dvrSwConnectionId = combo[dvrSwConnectionIdIndex]; |
| 488 | mLive.hasFrontendConnection = true; |
| 489 | |
| 490 | if (frontendMap[feId].isSoftwareFe && dvrSwConnectionId.compare(emptyHardwareId) == 0) { |
| 491 | // If the frontend is a software frontend and there is no dvr playback connected, do not |
| 492 | // include configuration |
| 493 | continue; |
| 494 | } |
| 495 | mLive.frontendId = feId; |
| 496 | mLive.dvrSoftwareFeId = dvrSwConnectionId; |
| 497 | mLive.audioFilterId = combo[audioFilterIdIndex]; |
| 498 | const int videoFilterIdIndex = |
| 499 | find(audioFilterIds.begin(), audioFilterIds.end(), mLive.audioFilterId) - |
| 500 | audioFilterIds.begin(); |
| 501 | mLive.videoFilterId = videoFilterIds[videoFilterIdIndex]; |
| 502 | mLive.sectionFilterId = combo[sectionFilterIdIndex]; |
| 503 | |
| 504 | if (pcrFilterIds.empty()) { |
| 505 | // If pcr Filters have not been provided, set it to empty hardware id |
| 506 | mLive.pcrFilterId = emptyHardwareId; |
| 507 | } else { |
| 508 | // If pcr Filters have been provided, use the first index if there is only 1, or choose |
| 509 | // the filter that corresponds to the correct audio and video filter pair |
| 510 | const int pcrFilterIdIndex = pcrFilterIds.size() == 1 ? 0 : videoFilterIdIndex; |
| 511 | mLive.pcrFilterId = pcrFilterIds[pcrFilterIdIndex]; |
| 512 | } |
| 513 | |
| 514 | combinations.push_back(mLive); |
| 515 | } |
| 516 | |
| 517 | return combinations; |
| 518 | } |
| 519 | |
| 520 | static inline vector<LiveBroadcastHardwareConnections> generateLiveConfigurations() { |
| 521 | vector<LiveBroadcastHardwareConnections> live_configs; |
| 522 | if (configuredLive) { |
| 523 | ALOGD("Using Live configuration provided."); |
| 524 | live_configs = {live}; |
| 525 | } else { |
| 526 | ALOGD("Live not provided. Generating possible combinations. Consider adding it to " |
| 527 | "the " |
| 528 | "configuration file."); |
| 529 | live_configs = generateLiveCombinations(); |
| 530 | } |
| 531 | |
| 532 | return live_configs; |
| 533 | } |
| 534 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 535 | /** Config all the frontends that would be used in the tests */ |
| 536 | inline void initFrontendConfig() { |
| 537 | // The test will use the internal default fe when default fe is connected to any data flow |
| 538 | // without overriding in the xml config. |
| 539 | string defaultFeId = "FE_DEFAULT"; |
| 540 | FrontendDvbtSettings dvbtSettings{ |
Gareth Fenn | 282fb37 | 2021-09-27 15:14:11 +0100 | [diff] [blame] | 541 | .frequency = 578000000, |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 542 | .transmissionMode = FrontendDvbtTransmissionMode::AUTO, |
| 543 | .bandwidth = FrontendDvbtBandwidth::BANDWIDTH_8MHZ, |
| 544 | .isHighPriority = true, |
| 545 | }; |
| 546 | frontendMap[defaultFeId].type = FrontendType::DVBT; |
| 547 | frontendMap[defaultFeId].settings.set<FrontendSettings::Tag::dvbt>(dvbtSettings); |
| 548 | |
| 549 | vector<FrontendStatusType> types; |
| 550 | types.push_back(FrontendStatusType::UEC); |
| 551 | types.push_back(FrontendStatusType::IS_MISO); |
| 552 | |
| 553 | vector<FrontendStatus> statuses; |
| 554 | FrontendStatus status; |
| 555 | status.set<FrontendStatus::Tag::uec>(4); |
| 556 | statuses.push_back(status); |
| 557 | status.set<FrontendStatus::Tag::isMiso>(true); |
| 558 | statuses.push_back(status); |
| 559 | |
| 560 | frontendMap[defaultFeId].tuneStatusTypes = types; |
| 561 | frontendMap[defaultFeId].expectTuneStatuses = statuses; |
| 562 | frontendMap[defaultFeId].isSoftwareFe = true; |
| 563 | frontendMap[defaultFeId].canConnectToCiCam = true; |
| 564 | frontendMap[defaultFeId].ciCamId = 0; |
| 565 | FrontendDvbtSettings dvbt; |
| 566 | dvbt.transmissionMode = FrontendDvbtTransmissionMode::MODE_8K_E; |
| 567 | frontendMap[defaultFeId].settings.set<FrontendSettings::Tag::dvbt>(dvbt); |
| 568 | // Read customized config |
| 569 | TunerTestingConfigAidlReader1_0::readFrontendConfig1_0(frontendMap); |
| 570 | }; |
| 571 | |
| 572 | inline void initFilterConfig() { |
| 573 | // The test will use the internal default filter when default filter is connected to any |
| 574 | // data flow without overriding in the xml config. |
| 575 | string defaultAudioFilterId = "FILTER_AUDIO_DEFAULT"; |
| 576 | string defaultVideoFilterId = "FILTER_VIDEO_DEFAULT"; |
| 577 | |
| 578 | filterMap[defaultVideoFilterId].type.mainType = DemuxFilterMainType::TS; |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 579 | filterMap[defaultVideoFilterId].type.subType.set<DemuxFilterSubType::Tag::tsFilterType>( |
| 580 | DemuxTsFilterType::VIDEO); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 581 | filterMap[defaultVideoFilterId].bufferSize = FMQ_SIZE_16M; |
| 582 | filterMap[defaultVideoFilterId].settings = |
| 583 | DemuxFilterSettings::make<DemuxFilterSettings::Tag::ts>(); |
| 584 | filterMap[defaultVideoFilterId].settings.get<DemuxFilterSettings::Tag::ts>().tpid = 256; |
| 585 | DemuxFilterAvSettings video; |
| 586 | video.isPassthrough = false; |
| 587 | filterMap[defaultVideoFilterId] |
| 588 | .settings.get<DemuxFilterSettings::Tag::ts>() |
| 589 | .filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(video); |
| 590 | filterMap[defaultVideoFilterId].monitorEventTypes = |
| 591 | static_cast<int32_t>(DemuxFilterMonitorEventType::SCRAMBLING_STATUS) | |
| 592 | static_cast<int32_t>(DemuxFilterMonitorEventType::IP_CID_CHANGE); |
| 593 | filterMap[defaultVideoFilterId].streamType.set<AvStreamType::Tag::video>( |
| 594 | VideoStreamType::MPEG1); |
| 595 | |
| 596 | filterMap[defaultAudioFilterId].type.mainType = DemuxFilterMainType::TS; |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 597 | filterMap[defaultAudioFilterId].type.subType.set<DemuxFilterSubType::Tag::tsFilterType>( |
| 598 | DemuxTsFilterType::AUDIO); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 599 | filterMap[defaultAudioFilterId].bufferSize = FMQ_SIZE_16M; |
| 600 | filterMap[defaultAudioFilterId].settings = |
| 601 | DemuxFilterSettings::make<DemuxFilterSettings::Tag::ts>(); |
| 602 | filterMap[defaultAudioFilterId].settings.get<DemuxFilterSettings::Tag::ts>().tpid = 256; |
| 603 | DemuxFilterAvSettings audio; |
| 604 | audio.isPassthrough = false; |
| 605 | filterMap[defaultAudioFilterId] |
| 606 | .settings.get<DemuxFilterSettings::Tag::ts>() |
| 607 | .filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(audio); |
| 608 | filterMap[defaultAudioFilterId].monitorEventTypes = |
| 609 | static_cast<int32_t>(DemuxFilterMonitorEventType::SCRAMBLING_STATUS) | |
| 610 | static_cast<int32_t>(DemuxFilterMonitorEventType::IP_CID_CHANGE); |
| 611 | filterMap[defaultAudioFilterId].streamType.set<AvStreamType::Tag::audio>(AudioStreamType::MP3); |
| 612 | // Read customized config |
| 613 | TunerTestingConfigAidlReader1_0::readFilterConfig1_0(filterMap); |
| 614 | }; |
| 615 | |
| 616 | /** Config all the dvrs that would be used in the tests */ |
| 617 | inline void initDvrConfig() { |
| 618 | // Read customized config |
| 619 | TunerTestingConfigAidlReader1_0::readDvrConfig1_0(dvrMap); |
| 620 | }; |
| 621 | |
Frankie Lizcano | 1fd5297 | 2022-06-30 16:50:21 +0000 | [diff] [blame] | 622 | inline void initTimeFilterConfig() { |
| 623 | // Read customized config |
| 624 | TunerTestingConfigAidlReader1_0::readTimeFilterConfig1_0(timeFilterMap); |
| 625 | }; |
| 626 | |
Frankie Lizcano | f535212 | 2022-06-29 22:10:16 +0000 | [diff] [blame] | 627 | inline void initDescramblerConfig() { |
| 628 | // Read customized config |
| 629 | TunerTestingConfigAidlReader1_0::readDescramblerConfig1_0(descramblerMap); |
| 630 | } |
| 631 | |
Frankie Lizcano | 647d5aa | 2022-06-30 20:49:31 +0000 | [diff] [blame] | 632 | inline void initLnbConfig() { |
| 633 | // Read customized config |
| 634 | TunerTestingConfigAidlReader1_0::readLnbConfig1_0(lnbMap); |
| 635 | }; |
| 636 | |
| 637 | inline void initDiseqcMsgsConfig() { |
| 638 | // Read customized config |
| 639 | TunerTestingConfigAidlReader1_0::readDiseqcMessages(diseqcMsgMap); |
| 640 | }; |
| 641 | |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 642 | inline void determineScan() { |
| 643 | if (!frontendMap.empty()) { |
| 644 | scan.hasFrontendConnection = true; |
| 645 | ALOGD("Can support scan"); |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | inline void determineTimeFilter() { |
| 650 | if (!timeFilterMap.empty()) { |
| 651 | timeFilter.support = true; |
| 652 | ALOGD("Can support time filter"); |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | inline void determineDvrPlayback() { |
| 657 | if (!playbackDvrIds.empty() && !audioFilterIds.empty() && !videoFilterIds.empty()) { |
| 658 | playback.support = true; |
| 659 | ALOGD("Can support dvr playback"); |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | inline void determineLnbLive() { |
| 664 | if (!audioFilterIds.empty() && !videoFilterIds.empty() && !frontendMap.empty() && |
| 665 | !lnbMap.empty()) { |
| 666 | lnbLive.support = true; |
| 667 | ALOGD("Can support lnb live"); |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | inline void determineLnbRecord() { |
| 672 | if (!frontendMap.empty() && !recordFilterIds.empty() && !recordDvrIds.empty() && |
| 673 | !lnbMap.empty()) { |
| 674 | lnbRecord.support = true; |
| 675 | ALOGD("Can support lnb record"); |
| 676 | } |
| 677 | } |
| 678 | |
| 679 | inline void determineLive() { |
| 680 | if (videoFilterIds.empty() || audioFilterIds.empty() || frontendMap.empty()) { |
| 681 | return; |
| 682 | } |
| 683 | if (hasSwFe && !hasHwFe && dvrMap.empty()) { |
| 684 | ALOGD("Cannot configure Live. Only software frontends and no dvr connections"); |
| 685 | return; |
| 686 | } |
| 687 | ALOGD("Can support live"); |
| 688 | live.hasFrontendConnection = true; |
| 689 | } |
| 690 | |
| 691 | inline void determineDescrambling() { |
| 692 | if (descramblerMap.empty() || audioFilterIds.empty() || videoFilterIds.empty()) { |
| 693 | return; |
| 694 | } |
| 695 | if (frontendMap.empty() && playbackDvrIds.empty()) { |
| 696 | ALOGD("Cannot configure descrambling. No frontends or playback dvr's"); |
| 697 | return; |
| 698 | } |
| 699 | if (hasSwFe && !hasHwFe && playbackDvrIds.empty()) { |
| 700 | ALOGD("cannot configure descrambling. Only SW frontends and no playback dvr's"); |
| 701 | return; |
| 702 | } |
| 703 | ALOGD("Can support descrambling"); |
| 704 | descrambling.support = true; |
| 705 | } |
| 706 | |
| 707 | inline void determineDvrRecord() { |
| 708 | if (recordDvrIds.empty() || recordFilterIds.empty()) { |
| 709 | return; |
| 710 | } |
| 711 | if (frontendMap.empty() && playbackDvrIds.empty()) { |
Frankie Lizcano | ecba02a | 2022-07-12 17:56:54 +0000 | [diff] [blame] | 712 | ALOGD("Cannot support dvr record. No frontends and no playback dvr's"); |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 713 | return; |
| 714 | } |
| 715 | if (hasSwFe && !hasHwFe && playbackDvrIds.empty()) { |
| 716 | ALOGD("Cannot support dvr record. Only SW frontends and no playback dvr's"); |
| 717 | return; |
| 718 | } |
| 719 | ALOGD("Can support dvr record."); |
| 720 | record.support = true; |
| 721 | } |
| 722 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 723 | /** Read the vendor configurations of which hardware to use for each test cases/data flows */ |
| 724 | inline void connectHardwaresToTestCases() { |
| 725 | TunerTestingConfigAidlReader1_0::connectLiveBroadcast(live); |
| 726 | TunerTestingConfigAidlReader1_0::connectScan(scan); |
| 727 | TunerTestingConfigAidlReader1_0::connectDvrRecord(record); |
Frankie Lizcano | 1fd5297 | 2022-06-30 16:50:21 +0000 | [diff] [blame] | 728 | TunerTestingConfigAidlReader1_0::connectTimeFilter(timeFilter); |
Frankie Lizcano | f535212 | 2022-06-29 22:10:16 +0000 | [diff] [blame] | 729 | TunerTestingConfigAidlReader1_0::connectDescrambling(descrambling); |
Frankie Lizcano | 1e283b3 | 2022-07-08 21:07:42 +0000 | [diff] [blame] | 730 | TunerTestingConfigAidlReader1_0::connectLnbLive(lnbLive); |
Frankie Lizcano | 3138d6b | 2022-07-11 22:06:45 +0000 | [diff] [blame] | 731 | TunerTestingConfigAidlReader1_0::connectLnbRecord(lnbRecord); |
Frankie Lizcano | 5046193 | 2022-06-28 21:36:26 +0000 | [diff] [blame] | 732 | TunerTestingConfigAidlReader1_0::connectDvrPlayback(playback); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 733 | }; |
| 734 | |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 735 | inline void determineDataFlows() { |
| 736 | determineScan(); |
| 737 | determineTimeFilter(); |
| 738 | determineDvrPlayback(); |
| 739 | determineLnbLive(); |
| 740 | determineLnbRecord(); |
| 741 | determineLive(); |
| 742 | determineDescrambling(); |
| 743 | determineDvrRecord(); |
| 744 | } |
| 745 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 746 | inline bool validateConnections() { |
| 747 | if (record.support && !record.hasFrontendConnection && |
| 748 | record.dvrSourceId.compare(emptyHardwareId) == 0) { |
| 749 | ALOGW("[vts config] Record must support either a DVR source or a Frontend source."); |
| 750 | return false; |
| 751 | } |
Gareth Fenn | 9a80845 | 2022-03-31 08:40:00 +0100 | [diff] [blame] | 752 | bool feIsValid = live.hasFrontendConnection |
| 753 | ? frontendMap.find(live.frontendId) != frontendMap.end() |
| 754 | : true; |
| 755 | feIsValid &= scan.hasFrontendConnection ? frontendMap.find(scan.frontendId) != frontendMap.end() |
| 756 | : true; |
| 757 | feIsValid &= record.support && record.hasFrontendConnection |
| 758 | ? frontendMap.find(record.frontendId) != frontendMap.end() |
| 759 | : true; |
Frankie Lizcano | f535212 | 2022-06-29 22:10:16 +0000 | [diff] [blame] | 760 | feIsValid &= descrambling.support && descrambling.hasFrontendConnection |
| 761 | ? frontendMap.find(descrambling.frontendId) != frontendMap.end() |
| 762 | : true; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 763 | |
Frankie Lizcano | 647d5aa | 2022-06-30 20:49:31 +0000 | [diff] [blame] | 764 | feIsValid &= lnbLive.support ? frontendMap.find(lnbLive.frontendId) != frontendMap.end() : true; |
| 765 | |
| 766 | feIsValid &= |
| 767 | lnbRecord.support ? frontendMap.find(lnbRecord.frontendId) != frontendMap.end() : true; |
| 768 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 769 | if (!feIsValid) { |
| 770 | ALOGW("[vts config] dynamic config fe connection is invalid."); |
| 771 | return false; |
| 772 | } |
| 773 | |
| 774 | bool dvrIsValid = frontendMap[live.frontendId].isSoftwareFe |
| 775 | ? dvrMap.find(live.dvrSoftwareFeId) != dvrMap.end() |
| 776 | : true; |
| 777 | |
| 778 | if (record.support) { |
| 779 | if (record.hasFrontendConnection) { |
| 780 | if (frontendMap[record.frontendId].isSoftwareFe) { |
| 781 | dvrIsValid &= dvrMap.find(record.dvrSoftwareFeId) != dvrMap.end(); |
| 782 | } |
| 783 | } else { |
| 784 | dvrIsValid &= dvrMap.find(record.dvrSourceId) != dvrMap.end(); |
| 785 | } |
| 786 | dvrIsValid &= dvrMap.find(record.dvrRecordId) != dvrMap.end(); |
| 787 | } |
| 788 | |
Frankie Lizcano | f535212 | 2022-06-29 22:10:16 +0000 | [diff] [blame] | 789 | if (descrambling.support) { |
| 790 | if (descrambling.hasFrontendConnection) { |
| 791 | if (frontendMap[descrambling.frontendId].isSoftwareFe) { |
| 792 | dvrIsValid &= dvrMap.find(descrambling.dvrSoftwareFeId) != dvrMap.end(); |
| 793 | } |
| 794 | } else { |
| 795 | dvrIsValid &= dvrMap.find(descrambling.dvrSourceId) != dvrMap.end(); |
| 796 | } |
| 797 | } |
| 798 | |
Frankie Lizcano | 647d5aa | 2022-06-30 20:49:31 +0000 | [diff] [blame] | 799 | dvrIsValid &= lnbRecord.support ? dvrMap.find(lnbRecord.dvrRecordId) != dvrMap.end() : true; |
| 800 | |
Frankie Lizcano | 5046193 | 2022-06-28 21:36:26 +0000 | [diff] [blame] | 801 | dvrIsValid &= playback.support ? dvrMap.find(playback.dvrId) != dvrMap.end() : true; |
| 802 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 803 | if (!dvrIsValid) { |
| 804 | ALOGW("[vts config] dynamic config dvr connection is invalid."); |
| 805 | return false; |
| 806 | } |
| 807 | |
Gareth Fenn | 9a80845 | 2022-03-31 08:40:00 +0100 | [diff] [blame] | 808 | bool filterIsValid = (live.hasFrontendConnection) |
| 809 | ? filterMap.find(live.audioFilterId) != filterMap.end() && |
| 810 | filterMap.find(live.videoFilterId) != filterMap.end() |
| 811 | : true; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 812 | filterIsValid &= |
| 813 | record.support ? filterMap.find(record.recordFilterId) != filterMap.end() : true; |
| 814 | |
Frankie Lizcano | f535212 | 2022-06-29 22:10:16 +0000 | [diff] [blame] | 815 | filterIsValid &= descrambling.support |
| 816 | ? filterMap.find(descrambling.videoFilterId) != filterMap.end() && |
| 817 | filterMap.find(descrambling.audioFilterId) != filterMap.end() |
| 818 | : true; |
| 819 | |
| 820 | for (auto& filterId : descrambling.extraFilters) { |
| 821 | filterIsValid &= filterMap.find(filterId) != filterMap.end(); |
| 822 | } |
| 823 | |
Frankie Lizcano | 647d5aa | 2022-06-30 20:49:31 +0000 | [diff] [blame] | 824 | filterIsValid &= lnbLive.support |
| 825 | ? filterMap.find(lnbLive.audioFilterId) != filterMap.end() && |
| 826 | filterMap.find(lnbLive.videoFilterId) != filterMap.end() |
| 827 | : true; |
| 828 | |
| 829 | filterIsValid &= |
| 830 | lnbRecord.support ? filterMap.find(lnbRecord.recordFilterId) != filterMap.end() : true; |
| 831 | |
| 832 | for (auto& filterId : lnbRecord.extraFilters) { |
| 833 | filterIsValid &= filterMap.find(filterId) != filterMap.end(); |
| 834 | } |
| 835 | |
| 836 | for (auto& filterId : lnbLive.extraFilters) { |
| 837 | filterIsValid &= filterMap.find(filterId) != filterMap.end(); |
| 838 | } |
| 839 | |
Frankie Lizcano | 5046193 | 2022-06-28 21:36:26 +0000 | [diff] [blame] | 840 | filterIsValid &= playback.support |
| 841 | ? filterMap.find(playback.audioFilterId) != filterMap.end() && |
| 842 | filterMap.find(playback.videoFilterId) != filterMap.end() |
| 843 | : true; |
| 844 | filterIsValid &= playback.sectionFilterId.compare(emptyHardwareId) == 0 |
| 845 | ? true |
| 846 | : filterMap.find(playback.sectionFilterId) != filterMap.end(); |
| 847 | |
| 848 | for (auto& filterId : playback.extraFilters) { |
| 849 | filterIsValid &= |
| 850 | playback.hasExtraFilters ? filterMap.find(filterId) != filterMap.end() : true; |
| 851 | } |
| 852 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 853 | if (!filterIsValid) { |
| 854 | ALOGW("[vts config] dynamic config filter connection is invalid."); |
| 855 | return false; |
| 856 | } |
| 857 | |
Frankie Lizcano | 14aa848 | 2022-07-26 16:50:35 +0000 | [diff] [blame] | 858 | if (audioFilterIds.size() != videoFilterIds.size()) { |
| 859 | ALOGW("[vts config] the number of audio and video filters should be equal"); |
| 860 | return false; |
| 861 | } |
| 862 | |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame^] | 863 | if (!pcrFilterIds.empty() && pcrFilterIds.size() != 1 && |
| 864 | pcrFilterIds.size() != audioFilterIds.size()) { |
| 865 | ALOGW("[vts config] When more than 1 pcr filter is configured, the number of pcr filters " |
| 866 | "must equal the number of audio and video filters."); |
| 867 | return false; |
| 868 | } |
| 869 | |
Frankie Lizcano | 1fd5297 | 2022-06-30 16:50:21 +0000 | [diff] [blame] | 870 | bool timeFilterIsValid = |
| 871 | timeFilter.support ? timeFilterMap.find(timeFilter.timeFilterId) != timeFilterMap.end() |
| 872 | : true; |
| 873 | |
| 874 | if (!timeFilterIsValid) { |
| 875 | ALOGW("[vts config] dynamic config time filter connection is invalid."); |
Frankie Lizcano | f535212 | 2022-06-29 22:10:16 +0000 | [diff] [blame] | 876 | } |
| 877 | |
| 878 | bool descramblerIsValid = |
| 879 | descrambling.support |
| 880 | ? descramblerMap.find(descrambling.descramblerId) != descramblerMap.end() |
| 881 | : true; |
| 882 | |
| 883 | if (!descramblerIsValid) { |
| 884 | ALOGW("[vts config] dynamic config descrambler connection is invalid."); |
Frankie Lizcano | 1fd5297 | 2022-06-30 16:50:21 +0000 | [diff] [blame] | 885 | return false; |
| 886 | } |
| 887 | |
Frankie Lizcano | 647d5aa | 2022-06-30 20:49:31 +0000 | [diff] [blame] | 888 | bool lnbIsValid = lnbLive.support ? lnbMap.find(lnbLive.lnbId) != lnbMap.end() : true; |
| 889 | |
| 890 | lnbIsValid &= lnbRecord.support ? lnbMap.find(lnbRecord.lnbId) != lnbMap.end() : true; |
| 891 | |
| 892 | if (!lnbIsValid) { |
| 893 | ALOGW("[vts config] dynamic config lnb connection is invalid."); |
| 894 | return false; |
| 895 | } |
| 896 | |
| 897 | bool diseqcMsgsIsValid = true; |
| 898 | |
| 899 | for (auto& msg : lnbRecord.diseqcMsgs) { |
| 900 | diseqcMsgsIsValid &= diseqcMsgMap.find(msg) != diseqcMsgMap.end(); |
| 901 | } |
| 902 | |
| 903 | for (auto& msg : lnbLive.diseqcMsgs) { |
| 904 | diseqcMsgsIsValid &= diseqcMsgMap.find(msg) != diseqcMsgMap.end(); |
| 905 | } |
| 906 | |
| 907 | if (!diseqcMsgsIsValid) { |
| 908 | ALOGW("[vts config] dynamic config diseqcMsg is invalid."); |
| 909 | return false; |
| 910 | } |
| 911 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 912 | return true; |
| 913 | } |