blob: 2ff19cd207722cdd840247433c0bcf979338a189 [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
Hongguang600a6ae2021-07-08 18:51:51 -0700225/** Config all the frontends that would be used in the tests */
226inline 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 Fenn282fb372021-09-27 15:14:11 +0100231 .frequency = 578000000,
Hongguang600a6ae2021-07-08 18:51:51 -0700232 .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
262inline 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;
Hongguangce1e30d2021-08-02 21:55:44 -0700269 filterMap[defaultVideoFilterId].type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
270 DemuxTsFilterType::VIDEO);
Hongguang600a6ae2021-07-08 18:51:51 -0700271 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;
Hongguangce1e30d2021-08-02 21:55:44 -0700287 filterMap[defaultAudioFilterId].type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
288 DemuxTsFilterType::AUDIO);
Hongguang600a6ae2021-07-08 18:51:51 -0700289 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 */
307inline void initDvrConfig() {
308 // Read customized config
309 TunerTestingConfigAidlReader1_0::readDvrConfig1_0(dvrMap);
310};
311
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000312inline void initTimeFilterConfig() {
313 // Read customized config
314 TunerTestingConfigAidlReader1_0::readTimeFilterConfig1_0(timeFilterMap);
315};
316
Frankie Lizcanof5352122022-06-29 22:10:16 +0000317inline void initDescramblerConfig() {
318 // Read customized config
319 TunerTestingConfigAidlReader1_0::readDescramblerConfig1_0(descramblerMap);
320}
321
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000322inline void initLnbConfig() {
323 // Read customized config
324 TunerTestingConfigAidlReader1_0::readLnbConfig1_0(lnbMap);
325};
326
327inline void initDiseqcMsgsConfig() {
328 // Read customized config
329 TunerTestingConfigAidlReader1_0::readDiseqcMessages(diseqcMsgMap);
330};
331
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000332inline void determineScan() {
333 if (!frontendMap.empty()) {
334 scan.hasFrontendConnection = true;
335 ALOGD("Can support scan");
336 }
337}
338
339inline void determineTimeFilter() {
340 if (!timeFilterMap.empty()) {
341 timeFilter.support = true;
342 ALOGD("Can support time filter");
343 }
344}
345
346inline void determineDvrPlayback() {
347 if (!playbackDvrIds.empty() && !audioFilterIds.empty() && !videoFilterIds.empty()) {
348 playback.support = true;
349 ALOGD("Can support dvr playback");
350 }
351}
352
353inline 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
361inline 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
369inline 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
381inline 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
397inline 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
Hongguang600a6ae2021-07-08 18:51:51 -0700413/** Read the vendor configurations of which hardware to use for each test cases/data flows */
414inline void connectHardwaresToTestCases() {
415 TunerTestingConfigAidlReader1_0::connectLiveBroadcast(live);
416 TunerTestingConfigAidlReader1_0::connectScan(scan);
417 TunerTestingConfigAidlReader1_0::connectDvrRecord(record);
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000418 TunerTestingConfigAidlReader1_0::connectTimeFilter(timeFilter);
Frankie Lizcanof5352122022-06-29 22:10:16 +0000419 TunerTestingConfigAidlReader1_0::connectDescrambling(descrambling);
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000420 TunerTestingConfigAidlReader1_0::connectLnbRecord(lnbRecord);
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000421 TunerTestingConfigAidlReader1_0::connectLnbLive(lnbLive);
Frankie Lizcano50461932022-06-28 21:36:26 +0000422 TunerTestingConfigAidlReader1_0::connectDvrPlayback(playback);
Hongguang600a6ae2021-07-08 18:51:51 -0700423};
424
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000425inline void determineDataFlows() {
426 determineScan();
427 determineTimeFilter();
428 determineDvrPlayback();
429 determineLnbLive();
430 determineLnbRecord();
431 determineLive();
432 determineDescrambling();
433 determineDvrRecord();
434}
435
Hongguang600a6ae2021-07-08 18:51:51 -0700436inline 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 Fenn9a808452022-03-31 08:40:00 +0100442 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 Lizcanof5352122022-06-29 22:10:16 +0000450 feIsValid &= descrambling.support && descrambling.hasFrontendConnection
451 ? frontendMap.find(descrambling.frontendId) != frontendMap.end()
452 : true;
Hongguang600a6ae2021-07-08 18:51:51 -0700453
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000454 feIsValid &= lnbLive.support ? frontendMap.find(lnbLive.frontendId) != frontendMap.end() : true;
455
456 feIsValid &=
457 lnbRecord.support ? frontendMap.find(lnbRecord.frontendId) != frontendMap.end() : true;
458
Hongguang600a6ae2021-07-08 18:51:51 -0700459 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 Lizcanof5352122022-06-29 22:10:16 +0000479 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 Lizcano647d5aa2022-06-30 20:49:31 +0000489 dvrIsValid &= lnbRecord.support ? dvrMap.find(lnbRecord.dvrRecordId) != dvrMap.end() : true;
490
Frankie Lizcano50461932022-06-28 21:36:26 +0000491 dvrIsValid &= playback.support ? dvrMap.find(playback.dvrId) != dvrMap.end() : true;
492
Hongguang600a6ae2021-07-08 18:51:51 -0700493 if (!dvrIsValid) {
494 ALOGW("[vts config] dynamic config dvr connection is invalid.");
495 return false;
496 }
497
Gareth Fenn9a808452022-03-31 08:40:00 +0100498 bool filterIsValid = (live.hasFrontendConnection)
499 ? filterMap.find(live.audioFilterId) != filterMap.end() &&
500 filterMap.find(live.videoFilterId) != filterMap.end()
501 : true;
Hongguang600a6ae2021-07-08 18:51:51 -0700502 filterIsValid &=
503 record.support ? filterMap.find(record.recordFilterId) != filterMap.end() : true;
504
Frankie Lizcanof5352122022-06-29 22:10:16 +0000505 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 Lizcano647d5aa2022-06-30 20:49:31 +0000514 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 Lizcano50461932022-06-28 21:36:26 +0000530 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
Hongguang600a6ae2021-07-08 18:51:51 -0700543 if (!filterIsValid) {
544 ALOGW("[vts config] dynamic config filter connection is invalid.");
545 return false;
546 }
547
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000548 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 Lizcanof5352122022-06-29 22:10:16 +0000554 }
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 Lizcano1fd52972022-06-30 16:50:21 +0000563 return false;
564 }
565
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000566 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
Hongguang600a6ae2021-07-08 18:51:51 -0700590 return true;
591}