blob: bcc8c61e0d899121dd5d3d71011aa19a9378b305 [file] [log] [blame]
Hongguang600a6ae2021-07-08 18:51:51 -07001/*
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
48using namespace std;
49using namespace aidl::android::hardware::tv::tuner;
50using namespace android::media::tuner::testing::configuration::V1_0;
51
52const int32_t FMQ_SIZE_4M = 0x400000;
53const int32_t FMQ_SIZE_16M = 0x1000000;
54
Hongguang16dacc12021-11-01 15:51:52 -070055const string configFilePath = "/vendor/etc/tuner_vts_config_aidl_V1.xml";
Hongguang600a6ae2021-07-08 18:51:51 -070056
57#define FILTER_MAIN_TYPE_BIT_COUNT 5
58
59// Hardware configs
60static map<string, FrontendConfig> frontendMap;
61static map<string, FilterConfig> filterMap;
62static map<string, DvrConfig> dvrMap;
63static map<string, LnbConfig> lnbMap;
64static map<string, TimeFilterConfig> timeFilterMap;
65static map<string, vector<uint8_t>> diseqcMsgMap;
66static map<string, DescramblerConfig> descramblerMap;
67
68// Hardware and test cases connections
69static LiveBroadcastHardwareConnections live;
70static ScanHardwareConnections scan;
71static DvrPlaybackHardwareConnections playback;
72static DvrRecordHardwareConnections record;
73static DescramblingHardwareConnections descrambling;
74static LnbLiveHardwareConnections lnbLive;
75static LnbRecordHardwareConnections lnbRecord;
76static TimeFilterHardwareConnections timeFilter;
77
Frankie Lizcanoa53f5542022-07-07 17:32:06 +000078/*
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 */
83inline 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 */
137static 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
162static 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 Lizcano1e283b32022-07-08 21:07:42 +0000176/*
177 * index 0 - frontends
178 * index 1 - audio filters
179 * index 2 - video filters
180 * index 3 - lnbs
181 */
182static 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
211static 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
Frankie Lizcano3138d6b2022-07-11 22:06:45 +0000225static inline vector<ScanHardwareConnections> generateScanCombinations() {
226 vector<ScanHardwareConnections> combinations;
227
228 for (auto& id : frontendIds) {
229 ScanHardwareConnections mScan;
230 mScan.frontendId = id;
231 combinations.push_back(mScan);
232 }
233
234 return combinations;
235}
236
237static inline vector<ScanHardwareConnections> generateScanConfigurations() {
238 vector<ScanHardwareConnections> scan_configs;
239 if (configuredScan) {
240 ALOGD("Using scan configuration provided.");
241 scan_configs = {scan};
242 } else {
243 ALOGD("Scan not provided. Generating possible combinations. Consider adding it to "
244 "the configuration file.");
245 scan_configs = generateScanCombinations();
246 }
247
248 return scan_configs;
249}
250
Frankie Lizcanoecba02a2022-07-12 17:56:54 +0000251/*
252 * index 0 - frontends
253 * index 1 - record filter
254 * index 2 - Record Dvr
255 * index 3 - Lnb
256 */
257static inline vector<LnbRecordHardwareConnections> generateLnbRecordCombinations() {
258 vector<LnbRecordHardwareConnections> combinations;
259 vector<vector<string>> deviceIds{frontendIds, recordFilterIds, recordDvrIds, lnbIds};
260
261 const int frontendIndex = 0;
262 const int recordFilterIndex = 1;
263 const int dvrIndex = 2;
264 const int lnbIndex = 3;
265
266 auto idCombinations = generateIdCombinations(deviceIds);
267 // TODO : Find a better way to vary diseqcMsgs, if at all
268 for (auto& combo : idCombinations) {
269 const string feId = combo[frontendIndex];
270 auto type = frontendMap[feId].type;
271 if (type == FrontendType::DVBS || type == FrontendType::ISDBS ||
272 type == FrontendType::ISDBS3) {
273 LnbRecordHardwareConnections mLnbRecord;
274 mLnbRecord.frontendId = feId;
275 mLnbRecord.recordFilterId = combo[recordFilterIndex];
276 mLnbRecord.dvrRecordId = combo[dvrIndex];
277 mLnbRecord.lnbId = combo[lnbIndex];
278 mLnbRecord.diseqcMsgs = diseqcMsgs;
279 combinations.push_back(mLnbRecord);
280 }
281 }
282
283 return combinations;
284}
285
286static inline vector<LnbRecordHardwareConnections> generateLnbRecordConfigurations() {
287 vector<LnbRecordHardwareConnections> lnbRecord_configs;
288 if (configuredLnbRecord) {
289 ALOGD("Using LnbRecord configuration provided.");
290 lnbRecord_configs = {lnbRecord};
291 } else {
292 ALOGD("LnbRecord not provided. Generating possible combinations. Consider adding it to "
293 "the configuration file.");
294 lnbRecord_configs = generateLnbRecordCombinations();
295 }
296
297 return lnbRecord_configs;
298}
299
Hongguang600a6ae2021-07-08 18:51:51 -0700300/** Config all the frontends that would be used in the tests */
301inline void initFrontendConfig() {
302 // The test will use the internal default fe when default fe is connected to any data flow
303 // without overriding in the xml config.
304 string defaultFeId = "FE_DEFAULT";
305 FrontendDvbtSettings dvbtSettings{
Gareth Fenn282fb372021-09-27 15:14:11 +0100306 .frequency = 578000000,
Hongguang600a6ae2021-07-08 18:51:51 -0700307 .transmissionMode = FrontendDvbtTransmissionMode::AUTO,
308 .bandwidth = FrontendDvbtBandwidth::BANDWIDTH_8MHZ,
309 .isHighPriority = true,
310 };
311 frontendMap[defaultFeId].type = FrontendType::DVBT;
312 frontendMap[defaultFeId].settings.set<FrontendSettings::Tag::dvbt>(dvbtSettings);
313
314 vector<FrontendStatusType> types;
315 types.push_back(FrontendStatusType::UEC);
316 types.push_back(FrontendStatusType::IS_MISO);
317
318 vector<FrontendStatus> statuses;
319 FrontendStatus status;
320 status.set<FrontendStatus::Tag::uec>(4);
321 statuses.push_back(status);
322 status.set<FrontendStatus::Tag::isMiso>(true);
323 statuses.push_back(status);
324
325 frontendMap[defaultFeId].tuneStatusTypes = types;
326 frontendMap[defaultFeId].expectTuneStatuses = statuses;
327 frontendMap[defaultFeId].isSoftwareFe = true;
328 frontendMap[defaultFeId].canConnectToCiCam = true;
329 frontendMap[defaultFeId].ciCamId = 0;
330 FrontendDvbtSettings dvbt;
331 dvbt.transmissionMode = FrontendDvbtTransmissionMode::MODE_8K_E;
332 frontendMap[defaultFeId].settings.set<FrontendSettings::Tag::dvbt>(dvbt);
333 // Read customized config
334 TunerTestingConfigAidlReader1_0::readFrontendConfig1_0(frontendMap);
335};
336
337inline void initFilterConfig() {
338 // The test will use the internal default filter when default filter is connected to any
339 // data flow without overriding in the xml config.
340 string defaultAudioFilterId = "FILTER_AUDIO_DEFAULT";
341 string defaultVideoFilterId = "FILTER_VIDEO_DEFAULT";
342
343 filterMap[defaultVideoFilterId].type.mainType = DemuxFilterMainType::TS;
Hongguangce1e30d2021-08-02 21:55:44 -0700344 filterMap[defaultVideoFilterId].type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
345 DemuxTsFilterType::VIDEO);
Hongguang600a6ae2021-07-08 18:51:51 -0700346 filterMap[defaultVideoFilterId].bufferSize = FMQ_SIZE_16M;
347 filterMap[defaultVideoFilterId].settings =
348 DemuxFilterSettings::make<DemuxFilterSettings::Tag::ts>();
349 filterMap[defaultVideoFilterId].settings.get<DemuxFilterSettings::Tag::ts>().tpid = 256;
350 DemuxFilterAvSettings video;
351 video.isPassthrough = false;
352 filterMap[defaultVideoFilterId]
353 .settings.get<DemuxFilterSettings::Tag::ts>()
354 .filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(video);
355 filterMap[defaultVideoFilterId].monitorEventTypes =
356 static_cast<int32_t>(DemuxFilterMonitorEventType::SCRAMBLING_STATUS) |
357 static_cast<int32_t>(DemuxFilterMonitorEventType::IP_CID_CHANGE);
358 filterMap[defaultVideoFilterId].streamType.set<AvStreamType::Tag::video>(
359 VideoStreamType::MPEG1);
360
361 filterMap[defaultAudioFilterId].type.mainType = DemuxFilterMainType::TS;
Hongguangce1e30d2021-08-02 21:55:44 -0700362 filterMap[defaultAudioFilterId].type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
363 DemuxTsFilterType::AUDIO);
Hongguang600a6ae2021-07-08 18:51:51 -0700364 filterMap[defaultAudioFilterId].bufferSize = FMQ_SIZE_16M;
365 filterMap[defaultAudioFilterId].settings =
366 DemuxFilterSettings::make<DemuxFilterSettings::Tag::ts>();
367 filterMap[defaultAudioFilterId].settings.get<DemuxFilterSettings::Tag::ts>().tpid = 256;
368 DemuxFilterAvSettings audio;
369 audio.isPassthrough = false;
370 filterMap[defaultAudioFilterId]
371 .settings.get<DemuxFilterSettings::Tag::ts>()
372 .filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(audio);
373 filterMap[defaultAudioFilterId].monitorEventTypes =
374 static_cast<int32_t>(DemuxFilterMonitorEventType::SCRAMBLING_STATUS) |
375 static_cast<int32_t>(DemuxFilterMonitorEventType::IP_CID_CHANGE);
376 filterMap[defaultAudioFilterId].streamType.set<AvStreamType::Tag::audio>(AudioStreamType::MP3);
377 // Read customized config
378 TunerTestingConfigAidlReader1_0::readFilterConfig1_0(filterMap);
379};
380
381/** Config all the dvrs that would be used in the tests */
382inline void initDvrConfig() {
383 // Read customized config
384 TunerTestingConfigAidlReader1_0::readDvrConfig1_0(dvrMap);
385};
386
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000387inline void initTimeFilterConfig() {
388 // Read customized config
389 TunerTestingConfigAidlReader1_0::readTimeFilterConfig1_0(timeFilterMap);
390};
391
Frankie Lizcanof5352122022-06-29 22:10:16 +0000392inline void initDescramblerConfig() {
393 // Read customized config
394 TunerTestingConfigAidlReader1_0::readDescramblerConfig1_0(descramblerMap);
395}
396
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000397inline void initLnbConfig() {
398 // Read customized config
399 TunerTestingConfigAidlReader1_0::readLnbConfig1_0(lnbMap);
400};
401
402inline void initDiseqcMsgsConfig() {
403 // Read customized config
404 TunerTestingConfigAidlReader1_0::readDiseqcMessages(diseqcMsgMap);
405};
406
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000407inline void determineScan() {
408 if (!frontendMap.empty()) {
409 scan.hasFrontendConnection = true;
410 ALOGD("Can support scan");
411 }
412}
413
414inline void determineTimeFilter() {
415 if (!timeFilterMap.empty()) {
416 timeFilter.support = true;
417 ALOGD("Can support time filter");
418 }
419}
420
421inline void determineDvrPlayback() {
422 if (!playbackDvrIds.empty() && !audioFilterIds.empty() && !videoFilterIds.empty()) {
423 playback.support = true;
424 ALOGD("Can support dvr playback");
425 }
426}
427
428inline void determineLnbLive() {
429 if (!audioFilterIds.empty() && !videoFilterIds.empty() && !frontendMap.empty() &&
430 !lnbMap.empty()) {
431 lnbLive.support = true;
432 ALOGD("Can support lnb live");
433 }
434}
435
436inline void determineLnbRecord() {
437 if (!frontendMap.empty() && !recordFilterIds.empty() && !recordDvrIds.empty() &&
438 !lnbMap.empty()) {
439 lnbRecord.support = true;
440 ALOGD("Can support lnb record");
441 }
442}
443
444inline void determineLive() {
445 if (videoFilterIds.empty() || audioFilterIds.empty() || frontendMap.empty()) {
446 return;
447 }
448 if (hasSwFe && !hasHwFe && dvrMap.empty()) {
449 ALOGD("Cannot configure Live. Only software frontends and no dvr connections");
450 return;
451 }
452 ALOGD("Can support live");
453 live.hasFrontendConnection = true;
454}
455
456inline void determineDescrambling() {
457 if (descramblerMap.empty() || audioFilterIds.empty() || videoFilterIds.empty()) {
458 return;
459 }
460 if (frontendMap.empty() && playbackDvrIds.empty()) {
461 ALOGD("Cannot configure descrambling. No frontends or playback dvr's");
462 return;
463 }
464 if (hasSwFe && !hasHwFe && playbackDvrIds.empty()) {
465 ALOGD("cannot configure descrambling. Only SW frontends and no playback dvr's");
466 return;
467 }
468 ALOGD("Can support descrambling");
469 descrambling.support = true;
470}
471
472inline void determineDvrRecord() {
473 if (recordDvrIds.empty() || recordFilterIds.empty()) {
474 return;
475 }
476 if (frontendMap.empty() && playbackDvrIds.empty()) {
Frankie Lizcanoecba02a2022-07-12 17:56:54 +0000477 ALOGD("Cannot support dvr record. No frontends and no playback dvr's");
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000478 return;
479 }
480 if (hasSwFe && !hasHwFe && playbackDvrIds.empty()) {
481 ALOGD("Cannot support dvr record. Only SW frontends and no playback dvr's");
482 return;
483 }
484 ALOGD("Can support dvr record.");
485 record.support = true;
486}
487
Hongguang600a6ae2021-07-08 18:51:51 -0700488/** Read the vendor configurations of which hardware to use for each test cases/data flows */
489inline void connectHardwaresToTestCases() {
490 TunerTestingConfigAidlReader1_0::connectLiveBroadcast(live);
491 TunerTestingConfigAidlReader1_0::connectScan(scan);
492 TunerTestingConfigAidlReader1_0::connectDvrRecord(record);
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000493 TunerTestingConfigAidlReader1_0::connectTimeFilter(timeFilter);
Frankie Lizcanof5352122022-06-29 22:10:16 +0000494 TunerTestingConfigAidlReader1_0::connectDescrambling(descrambling);
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000495 TunerTestingConfigAidlReader1_0::connectLnbLive(lnbLive);
Frankie Lizcano3138d6b2022-07-11 22:06:45 +0000496 TunerTestingConfigAidlReader1_0::connectLnbRecord(lnbRecord);
Frankie Lizcano50461932022-06-28 21:36:26 +0000497 TunerTestingConfigAidlReader1_0::connectDvrPlayback(playback);
Hongguang600a6ae2021-07-08 18:51:51 -0700498};
499
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000500inline void determineDataFlows() {
501 determineScan();
502 determineTimeFilter();
503 determineDvrPlayback();
504 determineLnbLive();
505 determineLnbRecord();
506 determineLive();
507 determineDescrambling();
508 determineDvrRecord();
509}
510
Hongguang600a6ae2021-07-08 18:51:51 -0700511inline bool validateConnections() {
512 if (record.support && !record.hasFrontendConnection &&
513 record.dvrSourceId.compare(emptyHardwareId) == 0) {
514 ALOGW("[vts config] Record must support either a DVR source or a Frontend source.");
515 return false;
516 }
Gareth Fenn9a808452022-03-31 08:40:00 +0100517 bool feIsValid = live.hasFrontendConnection
518 ? frontendMap.find(live.frontendId) != frontendMap.end()
519 : true;
520 feIsValid &= scan.hasFrontendConnection ? frontendMap.find(scan.frontendId) != frontendMap.end()
521 : true;
522 feIsValid &= record.support && record.hasFrontendConnection
523 ? frontendMap.find(record.frontendId) != frontendMap.end()
524 : true;
Frankie Lizcanof5352122022-06-29 22:10:16 +0000525 feIsValid &= descrambling.support && descrambling.hasFrontendConnection
526 ? frontendMap.find(descrambling.frontendId) != frontendMap.end()
527 : true;
Hongguang600a6ae2021-07-08 18:51:51 -0700528
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000529 feIsValid &= lnbLive.support ? frontendMap.find(lnbLive.frontendId) != frontendMap.end() : true;
530
531 feIsValid &=
532 lnbRecord.support ? frontendMap.find(lnbRecord.frontendId) != frontendMap.end() : true;
533
Hongguang600a6ae2021-07-08 18:51:51 -0700534 if (!feIsValid) {
535 ALOGW("[vts config] dynamic config fe connection is invalid.");
536 return false;
537 }
538
539 bool dvrIsValid = frontendMap[live.frontendId].isSoftwareFe
540 ? dvrMap.find(live.dvrSoftwareFeId) != dvrMap.end()
541 : true;
542
543 if (record.support) {
544 if (record.hasFrontendConnection) {
545 if (frontendMap[record.frontendId].isSoftwareFe) {
546 dvrIsValid &= dvrMap.find(record.dvrSoftwareFeId) != dvrMap.end();
547 }
548 } else {
549 dvrIsValid &= dvrMap.find(record.dvrSourceId) != dvrMap.end();
550 }
551 dvrIsValid &= dvrMap.find(record.dvrRecordId) != dvrMap.end();
552 }
553
Frankie Lizcanof5352122022-06-29 22:10:16 +0000554 if (descrambling.support) {
555 if (descrambling.hasFrontendConnection) {
556 if (frontendMap[descrambling.frontendId].isSoftwareFe) {
557 dvrIsValid &= dvrMap.find(descrambling.dvrSoftwareFeId) != dvrMap.end();
558 }
559 } else {
560 dvrIsValid &= dvrMap.find(descrambling.dvrSourceId) != dvrMap.end();
561 }
562 }
563
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000564 dvrIsValid &= lnbRecord.support ? dvrMap.find(lnbRecord.dvrRecordId) != dvrMap.end() : true;
565
Frankie Lizcano50461932022-06-28 21:36:26 +0000566 dvrIsValid &= playback.support ? dvrMap.find(playback.dvrId) != dvrMap.end() : true;
567
Hongguang600a6ae2021-07-08 18:51:51 -0700568 if (!dvrIsValid) {
569 ALOGW("[vts config] dynamic config dvr connection is invalid.");
570 return false;
571 }
572
Gareth Fenn9a808452022-03-31 08:40:00 +0100573 bool filterIsValid = (live.hasFrontendConnection)
574 ? filterMap.find(live.audioFilterId) != filterMap.end() &&
575 filterMap.find(live.videoFilterId) != filterMap.end()
576 : true;
Hongguang600a6ae2021-07-08 18:51:51 -0700577 filterIsValid &=
578 record.support ? filterMap.find(record.recordFilterId) != filterMap.end() : true;
579
Frankie Lizcanof5352122022-06-29 22:10:16 +0000580 filterIsValid &= descrambling.support
581 ? filterMap.find(descrambling.videoFilterId) != filterMap.end() &&
582 filterMap.find(descrambling.audioFilterId) != filterMap.end()
583 : true;
584
585 for (auto& filterId : descrambling.extraFilters) {
586 filterIsValid &= filterMap.find(filterId) != filterMap.end();
587 }
588
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000589 filterIsValid &= lnbLive.support
590 ? filterMap.find(lnbLive.audioFilterId) != filterMap.end() &&
591 filterMap.find(lnbLive.videoFilterId) != filterMap.end()
592 : true;
593
594 filterIsValid &=
595 lnbRecord.support ? filterMap.find(lnbRecord.recordFilterId) != filterMap.end() : true;
596
597 for (auto& filterId : lnbRecord.extraFilters) {
598 filterIsValid &= filterMap.find(filterId) != filterMap.end();
599 }
600
601 for (auto& filterId : lnbLive.extraFilters) {
602 filterIsValid &= filterMap.find(filterId) != filterMap.end();
603 }
604
Frankie Lizcano50461932022-06-28 21:36:26 +0000605 filterIsValid &= playback.support
606 ? filterMap.find(playback.audioFilterId) != filterMap.end() &&
607 filterMap.find(playback.videoFilterId) != filterMap.end()
608 : true;
609 filterIsValid &= playback.sectionFilterId.compare(emptyHardwareId) == 0
610 ? true
611 : filterMap.find(playback.sectionFilterId) != filterMap.end();
612
613 for (auto& filterId : playback.extraFilters) {
614 filterIsValid &=
615 playback.hasExtraFilters ? filterMap.find(filterId) != filterMap.end() : true;
616 }
617
Hongguang600a6ae2021-07-08 18:51:51 -0700618 if (!filterIsValid) {
619 ALOGW("[vts config] dynamic config filter connection is invalid.");
620 return false;
621 }
622
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000623 bool timeFilterIsValid =
624 timeFilter.support ? timeFilterMap.find(timeFilter.timeFilterId) != timeFilterMap.end()
625 : true;
626
627 if (!timeFilterIsValid) {
628 ALOGW("[vts config] dynamic config time filter connection is invalid.");
Frankie Lizcanof5352122022-06-29 22:10:16 +0000629 }
630
631 bool descramblerIsValid =
632 descrambling.support
633 ? descramblerMap.find(descrambling.descramblerId) != descramblerMap.end()
634 : true;
635
636 if (!descramblerIsValid) {
637 ALOGW("[vts config] dynamic config descrambler connection is invalid.");
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000638 return false;
639 }
640
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000641 bool lnbIsValid = lnbLive.support ? lnbMap.find(lnbLive.lnbId) != lnbMap.end() : true;
642
643 lnbIsValid &= lnbRecord.support ? lnbMap.find(lnbRecord.lnbId) != lnbMap.end() : true;
644
645 if (!lnbIsValid) {
646 ALOGW("[vts config] dynamic config lnb connection is invalid.");
647 return false;
648 }
649
650 bool diseqcMsgsIsValid = true;
651
652 for (auto& msg : lnbRecord.diseqcMsgs) {
653 diseqcMsgsIsValid &= diseqcMsgMap.find(msg) != diseqcMsgMap.end();
654 }
655
656 for (auto& msg : lnbLive.diseqcMsgs) {
657 diseqcMsgsIsValid &= diseqcMsgMap.find(msg) != diseqcMsgMap.end();
658 }
659
660 if (!diseqcMsgsIsValid) {
661 ALOGW("[vts config] dynamic config diseqcMsg is invalid.");
662 return false;
663 }
664
Hongguang600a6ae2021-07-08 18:51:51 -0700665 return true;
666}