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 |
| 134 | * index 2 - video filters |
| 135 | * index 3 - optional section filters |
| 136 | */ |
| 137 | static inline vector<DvrPlaybackHardwareConnections> generatePlaybackCombinations() { |
| 138 | vector<DvrPlaybackHardwareConnections> combinations; |
| 139 | vector<string> sectionFilterIds_optional = sectionFilterIds; |
| 140 | sectionFilterIds_optional.push_back(emptyHardwareId); |
| 141 | vector<vector<string>> deviceIds{playbackDvrIds, audioFilterIds, videoFilterIds, |
| 142 | sectionFilterIds_optional}; |
| 143 | |
| 144 | const int dvrIndex = 0; |
| 145 | const int audioFilterIndex = 1; |
| 146 | const int videoFilterIndex = 2; |
| 147 | const int sectionFilterIndex = 3; |
| 148 | |
| 149 | auto idCombinations = generateIdCombinations(deviceIds); |
| 150 | for (auto& combo : idCombinations) { |
| 151 | DvrPlaybackHardwareConnections mPlayback; |
| 152 | mPlayback.dvrId = combo[dvrIndex]; |
| 153 | mPlayback.audioFilterId = combo[audioFilterIndex]; |
| 154 | mPlayback.videoFilterId = combo[videoFilterIndex]; |
| 155 | mPlayback.sectionFilterId = combo[sectionFilterIndex]; |
| 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 |
| 179 | * index 2 - video filters |
| 180 | * index 3 - lnbs |
| 181 | */ |
| 182 | static inline vector<LnbLiveHardwareConnections> generateLnbLiveCombinations() { |
| 183 | vector<LnbLiveHardwareConnections> combinations; |
| 184 | vector<vector<string>> deviceIds{frontendIds, audioFilterIds, videoFilterIds, lnbIds}; |
| 185 | |
| 186 | const int frontendIndex = 0; |
| 187 | const int audioFilterIndex = 1; |
| 188 | const int videoFilterIndex = 2; |
| 189 | const int lnbIndex = 3; |
| 190 | |
| 191 | // TODO: Find a better way to vary diseqcMsgs, if at all |
| 192 | auto idCombinations = generateIdCombinations(deviceIds); |
| 193 | for (auto& combo : idCombinations) { |
| 194 | const string feId = combo[frontendIndex]; |
| 195 | auto type = frontendMap[feId].type; |
| 196 | if (type == FrontendType::DVBS || type == FrontendType::ISDBS || |
| 197 | type == FrontendType::ISDBS3) { |
| 198 | LnbLiveHardwareConnections mLnbLive; |
| 199 | mLnbLive.frontendId = feId; |
| 200 | mLnbLive.audioFilterId = combo[audioFilterIndex]; |
| 201 | mLnbLive.videoFilterId = combo[videoFilterIndex]; |
| 202 | mLnbLive.lnbId = combo[lnbIndex]; |
| 203 | mLnbLive.diseqcMsgs = diseqcMsgs; |
| 204 | combinations.push_back(mLnbLive); |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | return combinations; |
| 209 | } |
| 210 | |
| 211 | static inline vector<LnbLiveHardwareConnections> generateLnbLiveConfigurations() { |
| 212 | vector<LnbLiveHardwareConnections> lnbLive_configs; |
| 213 | if (configuredLnbLive) { |
| 214 | ALOGD("Using LnbLive configuration provided."); |
| 215 | lnbLive_configs = {lnbLive}; |
| 216 | } else { |
| 217 | ALOGD("LnbLive not provided. Generating possible combinations. Consider adding it to the " |
| 218 | "configuration file."); |
| 219 | lnbLive_configs = generateLnbLiveCombinations(); |
| 220 | } |
| 221 | |
| 222 | return lnbLive_configs; |
| 223 | } |
| 224 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 225 | /** Config all the frontends that would be used in the tests */ |
| 226 | inline void initFrontendConfig() { |
| 227 | // The test will use the internal default fe when default fe is connected to any data flow |
| 228 | // without overriding in the xml config. |
| 229 | string defaultFeId = "FE_DEFAULT"; |
| 230 | FrontendDvbtSettings dvbtSettings{ |
Gareth Fenn | 282fb37 | 2021-09-27 15:14:11 +0100 | [diff] [blame] | 231 | .frequency = 578000000, |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 232 | .transmissionMode = FrontendDvbtTransmissionMode::AUTO, |
| 233 | .bandwidth = FrontendDvbtBandwidth::BANDWIDTH_8MHZ, |
| 234 | .isHighPriority = true, |
| 235 | }; |
| 236 | frontendMap[defaultFeId].type = FrontendType::DVBT; |
| 237 | frontendMap[defaultFeId].settings.set<FrontendSettings::Tag::dvbt>(dvbtSettings); |
| 238 | |
| 239 | vector<FrontendStatusType> types; |
| 240 | types.push_back(FrontendStatusType::UEC); |
| 241 | types.push_back(FrontendStatusType::IS_MISO); |
| 242 | |
| 243 | vector<FrontendStatus> statuses; |
| 244 | FrontendStatus status; |
| 245 | status.set<FrontendStatus::Tag::uec>(4); |
| 246 | statuses.push_back(status); |
| 247 | status.set<FrontendStatus::Tag::isMiso>(true); |
| 248 | statuses.push_back(status); |
| 249 | |
| 250 | frontendMap[defaultFeId].tuneStatusTypes = types; |
| 251 | frontendMap[defaultFeId].expectTuneStatuses = statuses; |
| 252 | frontendMap[defaultFeId].isSoftwareFe = true; |
| 253 | frontendMap[defaultFeId].canConnectToCiCam = true; |
| 254 | frontendMap[defaultFeId].ciCamId = 0; |
| 255 | FrontendDvbtSettings dvbt; |
| 256 | dvbt.transmissionMode = FrontendDvbtTransmissionMode::MODE_8K_E; |
| 257 | frontendMap[defaultFeId].settings.set<FrontendSettings::Tag::dvbt>(dvbt); |
| 258 | // Read customized config |
| 259 | TunerTestingConfigAidlReader1_0::readFrontendConfig1_0(frontendMap); |
| 260 | }; |
| 261 | |
| 262 | inline void initFilterConfig() { |
| 263 | // The test will use the internal default filter when default filter is connected to any |
| 264 | // data flow without overriding in the xml config. |
| 265 | string defaultAudioFilterId = "FILTER_AUDIO_DEFAULT"; |
| 266 | string defaultVideoFilterId = "FILTER_VIDEO_DEFAULT"; |
| 267 | |
| 268 | filterMap[defaultVideoFilterId].type.mainType = DemuxFilterMainType::TS; |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 269 | filterMap[defaultVideoFilterId].type.subType.set<DemuxFilterSubType::Tag::tsFilterType>( |
| 270 | DemuxTsFilterType::VIDEO); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 271 | filterMap[defaultVideoFilterId].bufferSize = FMQ_SIZE_16M; |
| 272 | filterMap[defaultVideoFilterId].settings = |
| 273 | DemuxFilterSettings::make<DemuxFilterSettings::Tag::ts>(); |
| 274 | filterMap[defaultVideoFilterId].settings.get<DemuxFilterSettings::Tag::ts>().tpid = 256; |
| 275 | DemuxFilterAvSettings video; |
| 276 | video.isPassthrough = false; |
| 277 | filterMap[defaultVideoFilterId] |
| 278 | .settings.get<DemuxFilterSettings::Tag::ts>() |
| 279 | .filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(video); |
| 280 | filterMap[defaultVideoFilterId].monitorEventTypes = |
| 281 | static_cast<int32_t>(DemuxFilterMonitorEventType::SCRAMBLING_STATUS) | |
| 282 | static_cast<int32_t>(DemuxFilterMonitorEventType::IP_CID_CHANGE); |
| 283 | filterMap[defaultVideoFilterId].streamType.set<AvStreamType::Tag::video>( |
| 284 | VideoStreamType::MPEG1); |
| 285 | |
| 286 | filterMap[defaultAudioFilterId].type.mainType = DemuxFilterMainType::TS; |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 287 | filterMap[defaultAudioFilterId].type.subType.set<DemuxFilterSubType::Tag::tsFilterType>( |
| 288 | DemuxTsFilterType::AUDIO); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 289 | filterMap[defaultAudioFilterId].bufferSize = FMQ_SIZE_16M; |
| 290 | filterMap[defaultAudioFilterId].settings = |
| 291 | DemuxFilterSettings::make<DemuxFilterSettings::Tag::ts>(); |
| 292 | filterMap[defaultAudioFilterId].settings.get<DemuxFilterSettings::Tag::ts>().tpid = 256; |
| 293 | DemuxFilterAvSettings audio; |
| 294 | audio.isPassthrough = false; |
| 295 | filterMap[defaultAudioFilterId] |
| 296 | .settings.get<DemuxFilterSettings::Tag::ts>() |
| 297 | .filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(audio); |
| 298 | filterMap[defaultAudioFilterId].monitorEventTypes = |
| 299 | static_cast<int32_t>(DemuxFilterMonitorEventType::SCRAMBLING_STATUS) | |
| 300 | static_cast<int32_t>(DemuxFilterMonitorEventType::IP_CID_CHANGE); |
| 301 | filterMap[defaultAudioFilterId].streamType.set<AvStreamType::Tag::audio>(AudioStreamType::MP3); |
| 302 | // Read customized config |
| 303 | TunerTestingConfigAidlReader1_0::readFilterConfig1_0(filterMap); |
| 304 | }; |
| 305 | |
| 306 | /** Config all the dvrs that would be used in the tests */ |
| 307 | inline void initDvrConfig() { |
| 308 | // Read customized config |
| 309 | TunerTestingConfigAidlReader1_0::readDvrConfig1_0(dvrMap); |
| 310 | }; |
| 311 | |
Frankie Lizcano | 1fd5297 | 2022-06-30 16:50:21 +0000 | [diff] [blame] | 312 | inline void initTimeFilterConfig() { |
| 313 | // Read customized config |
| 314 | TunerTestingConfigAidlReader1_0::readTimeFilterConfig1_0(timeFilterMap); |
| 315 | }; |
| 316 | |
Frankie Lizcano | f535212 | 2022-06-29 22:10:16 +0000 | [diff] [blame] | 317 | inline void initDescramblerConfig() { |
| 318 | // Read customized config |
| 319 | TunerTestingConfigAidlReader1_0::readDescramblerConfig1_0(descramblerMap); |
| 320 | } |
| 321 | |
Frankie Lizcano | 647d5aa | 2022-06-30 20:49:31 +0000 | [diff] [blame] | 322 | inline void initLnbConfig() { |
| 323 | // Read customized config |
| 324 | TunerTestingConfigAidlReader1_0::readLnbConfig1_0(lnbMap); |
| 325 | }; |
| 326 | |
| 327 | inline void initDiseqcMsgsConfig() { |
| 328 | // Read customized config |
| 329 | TunerTestingConfigAidlReader1_0::readDiseqcMessages(diseqcMsgMap); |
| 330 | }; |
| 331 | |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 332 | inline void determineScan() { |
| 333 | if (!frontendMap.empty()) { |
| 334 | scan.hasFrontendConnection = true; |
| 335 | ALOGD("Can support scan"); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | inline void determineTimeFilter() { |
| 340 | if (!timeFilterMap.empty()) { |
| 341 | timeFilter.support = true; |
| 342 | ALOGD("Can support time filter"); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | inline void determineDvrPlayback() { |
| 347 | if (!playbackDvrIds.empty() && !audioFilterIds.empty() && !videoFilterIds.empty()) { |
| 348 | playback.support = true; |
| 349 | ALOGD("Can support dvr playback"); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | inline void determineLnbLive() { |
| 354 | if (!audioFilterIds.empty() && !videoFilterIds.empty() && !frontendMap.empty() && |
| 355 | !lnbMap.empty()) { |
| 356 | lnbLive.support = true; |
| 357 | ALOGD("Can support lnb live"); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | inline void determineLnbRecord() { |
| 362 | if (!frontendMap.empty() && !recordFilterIds.empty() && !recordDvrIds.empty() && |
| 363 | !lnbMap.empty()) { |
| 364 | lnbRecord.support = true; |
| 365 | ALOGD("Can support lnb record"); |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | inline void determineLive() { |
| 370 | if (videoFilterIds.empty() || audioFilterIds.empty() || frontendMap.empty()) { |
| 371 | return; |
| 372 | } |
| 373 | if (hasSwFe && !hasHwFe && dvrMap.empty()) { |
| 374 | ALOGD("Cannot configure Live. Only software frontends and no dvr connections"); |
| 375 | return; |
| 376 | } |
| 377 | ALOGD("Can support live"); |
| 378 | live.hasFrontendConnection = true; |
| 379 | } |
| 380 | |
| 381 | inline void determineDescrambling() { |
| 382 | if (descramblerMap.empty() || audioFilterIds.empty() || videoFilterIds.empty()) { |
| 383 | return; |
| 384 | } |
| 385 | if (frontendMap.empty() && playbackDvrIds.empty()) { |
| 386 | ALOGD("Cannot configure descrambling. No frontends or playback dvr's"); |
| 387 | return; |
| 388 | } |
| 389 | if (hasSwFe && !hasHwFe && playbackDvrIds.empty()) { |
| 390 | ALOGD("cannot configure descrambling. Only SW frontends and no playback dvr's"); |
| 391 | return; |
| 392 | } |
| 393 | ALOGD("Can support descrambling"); |
| 394 | descrambling.support = true; |
| 395 | } |
| 396 | |
| 397 | inline void determineDvrRecord() { |
| 398 | if (recordDvrIds.empty() || recordFilterIds.empty()) { |
| 399 | return; |
| 400 | } |
| 401 | if (frontendMap.empty() && playbackDvrIds.empty()) { |
| 402 | ALOGD("Cannot support dvr record. No frontends and no playback dvr's"); |
| 403 | return; |
| 404 | } |
| 405 | if (hasSwFe && !hasHwFe && playbackDvrIds.empty()) { |
| 406 | ALOGD("Cannot support dvr record. Only SW frontends and no playback dvr's"); |
| 407 | return; |
| 408 | } |
| 409 | ALOGD("Can support dvr record."); |
| 410 | record.support = true; |
| 411 | } |
| 412 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 413 | /** Read the vendor configurations of which hardware to use for each test cases/data flows */ |
| 414 | inline void connectHardwaresToTestCases() { |
| 415 | TunerTestingConfigAidlReader1_0::connectLiveBroadcast(live); |
| 416 | TunerTestingConfigAidlReader1_0::connectScan(scan); |
| 417 | TunerTestingConfigAidlReader1_0::connectDvrRecord(record); |
Frankie Lizcano | 1fd5297 | 2022-06-30 16:50:21 +0000 | [diff] [blame] | 418 | TunerTestingConfigAidlReader1_0::connectTimeFilter(timeFilter); |
Frankie Lizcano | f535212 | 2022-06-29 22:10:16 +0000 | [diff] [blame] | 419 | TunerTestingConfigAidlReader1_0::connectDescrambling(descrambling); |
Frankie Lizcano | 647d5aa | 2022-06-30 20:49:31 +0000 | [diff] [blame] | 420 | TunerTestingConfigAidlReader1_0::connectLnbRecord(lnbRecord); |
Frankie Lizcano | 1e283b3 | 2022-07-08 21:07:42 +0000 | [diff] [blame^] | 421 | TunerTestingConfigAidlReader1_0::connectLnbLive(lnbLive); |
Frankie Lizcano | 5046193 | 2022-06-28 21:36:26 +0000 | [diff] [blame] | 422 | TunerTestingConfigAidlReader1_0::connectDvrPlayback(playback); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 423 | }; |
| 424 | |
Frankie Lizcano | 5b29f50 | 2022-07-06 22:09:42 +0000 | [diff] [blame] | 425 | inline void determineDataFlows() { |
| 426 | determineScan(); |
| 427 | determineTimeFilter(); |
| 428 | determineDvrPlayback(); |
| 429 | determineLnbLive(); |
| 430 | determineLnbRecord(); |
| 431 | determineLive(); |
| 432 | determineDescrambling(); |
| 433 | determineDvrRecord(); |
| 434 | } |
| 435 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 436 | inline bool validateConnections() { |
| 437 | if (record.support && !record.hasFrontendConnection && |
| 438 | record.dvrSourceId.compare(emptyHardwareId) == 0) { |
| 439 | ALOGW("[vts config] Record must support either a DVR source or a Frontend source."); |
| 440 | return false; |
| 441 | } |
Gareth Fenn | 9a80845 | 2022-03-31 08:40:00 +0100 | [diff] [blame] | 442 | bool feIsValid = live.hasFrontendConnection |
| 443 | ? frontendMap.find(live.frontendId) != frontendMap.end() |
| 444 | : true; |
| 445 | feIsValid &= scan.hasFrontendConnection ? frontendMap.find(scan.frontendId) != frontendMap.end() |
| 446 | : true; |
| 447 | feIsValid &= record.support && record.hasFrontendConnection |
| 448 | ? frontendMap.find(record.frontendId) != frontendMap.end() |
| 449 | : true; |
Frankie Lizcano | f535212 | 2022-06-29 22:10:16 +0000 | [diff] [blame] | 450 | feIsValid &= descrambling.support && descrambling.hasFrontendConnection |
| 451 | ? frontendMap.find(descrambling.frontendId) != frontendMap.end() |
| 452 | : true; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 453 | |
Frankie Lizcano | 647d5aa | 2022-06-30 20:49:31 +0000 | [diff] [blame] | 454 | feIsValid &= lnbLive.support ? frontendMap.find(lnbLive.frontendId) != frontendMap.end() : true; |
| 455 | |
| 456 | feIsValid &= |
| 457 | lnbRecord.support ? frontendMap.find(lnbRecord.frontendId) != frontendMap.end() : true; |
| 458 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 459 | if (!feIsValid) { |
| 460 | ALOGW("[vts config] dynamic config fe connection is invalid."); |
| 461 | return false; |
| 462 | } |
| 463 | |
| 464 | bool dvrIsValid = frontendMap[live.frontendId].isSoftwareFe |
| 465 | ? dvrMap.find(live.dvrSoftwareFeId) != dvrMap.end() |
| 466 | : true; |
| 467 | |
| 468 | if (record.support) { |
| 469 | if (record.hasFrontendConnection) { |
| 470 | if (frontendMap[record.frontendId].isSoftwareFe) { |
| 471 | dvrIsValid &= dvrMap.find(record.dvrSoftwareFeId) != dvrMap.end(); |
| 472 | } |
| 473 | } else { |
| 474 | dvrIsValid &= dvrMap.find(record.dvrSourceId) != dvrMap.end(); |
| 475 | } |
| 476 | dvrIsValid &= dvrMap.find(record.dvrRecordId) != dvrMap.end(); |
| 477 | } |
| 478 | |
Frankie Lizcano | f535212 | 2022-06-29 22:10:16 +0000 | [diff] [blame] | 479 | if (descrambling.support) { |
| 480 | if (descrambling.hasFrontendConnection) { |
| 481 | if (frontendMap[descrambling.frontendId].isSoftwareFe) { |
| 482 | dvrIsValid &= dvrMap.find(descrambling.dvrSoftwareFeId) != dvrMap.end(); |
| 483 | } |
| 484 | } else { |
| 485 | dvrIsValid &= dvrMap.find(descrambling.dvrSourceId) != dvrMap.end(); |
| 486 | } |
| 487 | } |
| 488 | |
Frankie Lizcano | 647d5aa | 2022-06-30 20:49:31 +0000 | [diff] [blame] | 489 | dvrIsValid &= lnbRecord.support ? dvrMap.find(lnbRecord.dvrRecordId) != dvrMap.end() : true; |
| 490 | |
Frankie Lizcano | 5046193 | 2022-06-28 21:36:26 +0000 | [diff] [blame] | 491 | dvrIsValid &= playback.support ? dvrMap.find(playback.dvrId) != dvrMap.end() : true; |
| 492 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 493 | if (!dvrIsValid) { |
| 494 | ALOGW("[vts config] dynamic config dvr connection is invalid."); |
| 495 | return false; |
| 496 | } |
| 497 | |
Gareth Fenn | 9a80845 | 2022-03-31 08:40:00 +0100 | [diff] [blame] | 498 | bool filterIsValid = (live.hasFrontendConnection) |
| 499 | ? filterMap.find(live.audioFilterId) != filterMap.end() && |
| 500 | filterMap.find(live.videoFilterId) != filterMap.end() |
| 501 | : true; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 502 | filterIsValid &= |
| 503 | record.support ? filterMap.find(record.recordFilterId) != filterMap.end() : true; |
| 504 | |
Frankie Lizcano | f535212 | 2022-06-29 22:10:16 +0000 | [diff] [blame] | 505 | filterIsValid &= descrambling.support |
| 506 | ? filterMap.find(descrambling.videoFilterId) != filterMap.end() && |
| 507 | filterMap.find(descrambling.audioFilterId) != filterMap.end() |
| 508 | : true; |
| 509 | |
| 510 | for (auto& filterId : descrambling.extraFilters) { |
| 511 | filterIsValid &= filterMap.find(filterId) != filterMap.end(); |
| 512 | } |
| 513 | |
Frankie Lizcano | 647d5aa | 2022-06-30 20:49:31 +0000 | [diff] [blame] | 514 | filterIsValid &= lnbLive.support |
| 515 | ? filterMap.find(lnbLive.audioFilterId) != filterMap.end() && |
| 516 | filterMap.find(lnbLive.videoFilterId) != filterMap.end() |
| 517 | : true; |
| 518 | |
| 519 | filterIsValid &= |
| 520 | lnbRecord.support ? filterMap.find(lnbRecord.recordFilterId) != filterMap.end() : true; |
| 521 | |
| 522 | for (auto& filterId : lnbRecord.extraFilters) { |
| 523 | filterIsValid &= filterMap.find(filterId) != filterMap.end(); |
| 524 | } |
| 525 | |
| 526 | for (auto& filterId : lnbLive.extraFilters) { |
| 527 | filterIsValid &= filterMap.find(filterId) != filterMap.end(); |
| 528 | } |
| 529 | |
Frankie Lizcano | 5046193 | 2022-06-28 21:36:26 +0000 | [diff] [blame] | 530 | filterIsValid &= playback.support |
| 531 | ? filterMap.find(playback.audioFilterId) != filterMap.end() && |
| 532 | filterMap.find(playback.videoFilterId) != filterMap.end() |
| 533 | : true; |
| 534 | filterIsValid &= playback.sectionFilterId.compare(emptyHardwareId) == 0 |
| 535 | ? true |
| 536 | : filterMap.find(playback.sectionFilterId) != filterMap.end(); |
| 537 | |
| 538 | for (auto& filterId : playback.extraFilters) { |
| 539 | filterIsValid &= |
| 540 | playback.hasExtraFilters ? filterMap.find(filterId) != filterMap.end() : true; |
| 541 | } |
| 542 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 543 | if (!filterIsValid) { |
| 544 | ALOGW("[vts config] dynamic config filter connection is invalid."); |
| 545 | return false; |
| 546 | } |
| 547 | |
Frankie Lizcano | 1fd5297 | 2022-06-30 16:50:21 +0000 | [diff] [blame] | 548 | bool timeFilterIsValid = |
| 549 | timeFilter.support ? timeFilterMap.find(timeFilter.timeFilterId) != timeFilterMap.end() |
| 550 | : true; |
| 551 | |
| 552 | if (!timeFilterIsValid) { |
| 553 | ALOGW("[vts config] dynamic config time filter connection is invalid."); |
Frankie Lizcano | f535212 | 2022-06-29 22:10:16 +0000 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | bool descramblerIsValid = |
| 557 | descrambling.support |
| 558 | ? descramblerMap.find(descrambling.descramblerId) != descramblerMap.end() |
| 559 | : true; |
| 560 | |
| 561 | if (!descramblerIsValid) { |
| 562 | ALOGW("[vts config] dynamic config descrambler connection is invalid."); |
Frankie Lizcano | 1fd5297 | 2022-06-30 16:50:21 +0000 | [diff] [blame] | 563 | return false; |
| 564 | } |
| 565 | |
Frankie Lizcano | 647d5aa | 2022-06-30 20:49:31 +0000 | [diff] [blame] | 566 | bool lnbIsValid = lnbLive.support ? lnbMap.find(lnbLive.lnbId) != lnbMap.end() : true; |
| 567 | |
| 568 | lnbIsValid &= lnbRecord.support ? lnbMap.find(lnbRecord.lnbId) != lnbMap.end() : true; |
| 569 | |
| 570 | if (!lnbIsValid) { |
| 571 | ALOGW("[vts config] dynamic config lnb connection is invalid."); |
| 572 | return false; |
| 573 | } |
| 574 | |
| 575 | bool diseqcMsgsIsValid = true; |
| 576 | |
| 577 | for (auto& msg : lnbRecord.diseqcMsgs) { |
| 578 | diseqcMsgsIsValid &= diseqcMsgMap.find(msg) != diseqcMsgMap.end(); |
| 579 | } |
| 580 | |
| 581 | for (auto& msg : lnbLive.diseqcMsgs) { |
| 582 | diseqcMsgsIsValid &= diseqcMsgMap.find(msg) != diseqcMsgMap.end(); |
| 583 | } |
| 584 | |
| 585 | if (!diseqcMsgsIsValid) { |
| 586 | ALOGW("[vts config] dynamic config diseqcMsg is invalid."); |
| 587 | return false; |
| 588 | } |
| 589 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 590 | return true; |
| 591 | } |