blob: aa38e4879b5f801fc3e8d885fa98be2a08204ee0 [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
Hongguang600a6ae2021-07-08 18:51:51 -0700251/** Config all the frontends that would be used in the tests */
252inline void initFrontendConfig() {
253 // The test will use the internal default fe when default fe is connected to any data flow
254 // without overriding in the xml config.
255 string defaultFeId = "FE_DEFAULT";
256 FrontendDvbtSettings dvbtSettings{
Gareth Fenn282fb372021-09-27 15:14:11 +0100257 .frequency = 578000000,
Hongguang600a6ae2021-07-08 18:51:51 -0700258 .transmissionMode = FrontendDvbtTransmissionMode::AUTO,
259 .bandwidth = FrontendDvbtBandwidth::BANDWIDTH_8MHZ,
260 .isHighPriority = true,
261 };
262 frontendMap[defaultFeId].type = FrontendType::DVBT;
263 frontendMap[defaultFeId].settings.set<FrontendSettings::Tag::dvbt>(dvbtSettings);
264
265 vector<FrontendStatusType> types;
266 types.push_back(FrontendStatusType::UEC);
267 types.push_back(FrontendStatusType::IS_MISO);
268
269 vector<FrontendStatus> statuses;
270 FrontendStatus status;
271 status.set<FrontendStatus::Tag::uec>(4);
272 statuses.push_back(status);
273 status.set<FrontendStatus::Tag::isMiso>(true);
274 statuses.push_back(status);
275
276 frontendMap[defaultFeId].tuneStatusTypes = types;
277 frontendMap[defaultFeId].expectTuneStatuses = statuses;
278 frontendMap[defaultFeId].isSoftwareFe = true;
279 frontendMap[defaultFeId].canConnectToCiCam = true;
280 frontendMap[defaultFeId].ciCamId = 0;
281 FrontendDvbtSettings dvbt;
282 dvbt.transmissionMode = FrontendDvbtTransmissionMode::MODE_8K_E;
283 frontendMap[defaultFeId].settings.set<FrontendSettings::Tag::dvbt>(dvbt);
284 // Read customized config
285 TunerTestingConfigAidlReader1_0::readFrontendConfig1_0(frontendMap);
286};
287
288inline void initFilterConfig() {
289 // The test will use the internal default filter when default filter is connected to any
290 // data flow without overriding in the xml config.
291 string defaultAudioFilterId = "FILTER_AUDIO_DEFAULT";
292 string defaultVideoFilterId = "FILTER_VIDEO_DEFAULT";
293
294 filterMap[defaultVideoFilterId].type.mainType = DemuxFilterMainType::TS;
Hongguangce1e30d2021-08-02 21:55:44 -0700295 filterMap[defaultVideoFilterId].type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
296 DemuxTsFilterType::VIDEO);
Hongguang600a6ae2021-07-08 18:51:51 -0700297 filterMap[defaultVideoFilterId].bufferSize = FMQ_SIZE_16M;
298 filterMap[defaultVideoFilterId].settings =
299 DemuxFilterSettings::make<DemuxFilterSettings::Tag::ts>();
300 filterMap[defaultVideoFilterId].settings.get<DemuxFilterSettings::Tag::ts>().tpid = 256;
301 DemuxFilterAvSettings video;
302 video.isPassthrough = false;
303 filterMap[defaultVideoFilterId]
304 .settings.get<DemuxFilterSettings::Tag::ts>()
305 .filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(video);
306 filterMap[defaultVideoFilterId].monitorEventTypes =
307 static_cast<int32_t>(DemuxFilterMonitorEventType::SCRAMBLING_STATUS) |
308 static_cast<int32_t>(DemuxFilterMonitorEventType::IP_CID_CHANGE);
309 filterMap[defaultVideoFilterId].streamType.set<AvStreamType::Tag::video>(
310 VideoStreamType::MPEG1);
311
312 filterMap[defaultAudioFilterId].type.mainType = DemuxFilterMainType::TS;
Hongguangce1e30d2021-08-02 21:55:44 -0700313 filterMap[defaultAudioFilterId].type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
314 DemuxTsFilterType::AUDIO);
Hongguang600a6ae2021-07-08 18:51:51 -0700315 filterMap[defaultAudioFilterId].bufferSize = FMQ_SIZE_16M;
316 filterMap[defaultAudioFilterId].settings =
317 DemuxFilterSettings::make<DemuxFilterSettings::Tag::ts>();
318 filterMap[defaultAudioFilterId].settings.get<DemuxFilterSettings::Tag::ts>().tpid = 256;
319 DemuxFilterAvSettings audio;
320 audio.isPassthrough = false;
321 filterMap[defaultAudioFilterId]
322 .settings.get<DemuxFilterSettings::Tag::ts>()
323 .filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(audio);
324 filterMap[defaultAudioFilterId].monitorEventTypes =
325 static_cast<int32_t>(DemuxFilterMonitorEventType::SCRAMBLING_STATUS) |
326 static_cast<int32_t>(DemuxFilterMonitorEventType::IP_CID_CHANGE);
327 filterMap[defaultAudioFilterId].streamType.set<AvStreamType::Tag::audio>(AudioStreamType::MP3);
328 // Read customized config
329 TunerTestingConfigAidlReader1_0::readFilterConfig1_0(filterMap);
330};
331
332/** Config all the dvrs that would be used in the tests */
333inline void initDvrConfig() {
334 // Read customized config
335 TunerTestingConfigAidlReader1_0::readDvrConfig1_0(dvrMap);
336};
337
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000338inline void initTimeFilterConfig() {
339 // Read customized config
340 TunerTestingConfigAidlReader1_0::readTimeFilterConfig1_0(timeFilterMap);
341};
342
Frankie Lizcanof5352122022-06-29 22:10:16 +0000343inline void initDescramblerConfig() {
344 // Read customized config
345 TunerTestingConfigAidlReader1_0::readDescramblerConfig1_0(descramblerMap);
346}
347
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000348inline void initLnbConfig() {
349 // Read customized config
350 TunerTestingConfigAidlReader1_0::readLnbConfig1_0(lnbMap);
351};
352
353inline void initDiseqcMsgsConfig() {
354 // Read customized config
355 TunerTestingConfigAidlReader1_0::readDiseqcMessages(diseqcMsgMap);
356};
357
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000358inline void determineScan() {
359 if (!frontendMap.empty()) {
360 scan.hasFrontendConnection = true;
361 ALOGD("Can support scan");
362 }
363}
364
365inline void determineTimeFilter() {
366 if (!timeFilterMap.empty()) {
367 timeFilter.support = true;
368 ALOGD("Can support time filter");
369 }
370}
371
372inline void determineDvrPlayback() {
373 if (!playbackDvrIds.empty() && !audioFilterIds.empty() && !videoFilterIds.empty()) {
374 playback.support = true;
375 ALOGD("Can support dvr playback");
376 }
377}
378
379inline void determineLnbLive() {
380 if (!audioFilterIds.empty() && !videoFilterIds.empty() && !frontendMap.empty() &&
381 !lnbMap.empty()) {
382 lnbLive.support = true;
383 ALOGD("Can support lnb live");
384 }
385}
386
387inline void determineLnbRecord() {
388 if (!frontendMap.empty() && !recordFilterIds.empty() && !recordDvrIds.empty() &&
389 !lnbMap.empty()) {
390 lnbRecord.support = true;
391 ALOGD("Can support lnb record");
392 }
393}
394
395inline void determineLive() {
396 if (videoFilterIds.empty() || audioFilterIds.empty() || frontendMap.empty()) {
397 return;
398 }
399 if (hasSwFe && !hasHwFe && dvrMap.empty()) {
400 ALOGD("Cannot configure Live. Only software frontends and no dvr connections");
401 return;
402 }
403 ALOGD("Can support live");
404 live.hasFrontendConnection = true;
405}
406
407inline void determineDescrambling() {
408 if (descramblerMap.empty() || audioFilterIds.empty() || videoFilterIds.empty()) {
409 return;
410 }
411 if (frontendMap.empty() && playbackDvrIds.empty()) {
412 ALOGD("Cannot configure descrambling. No frontends or playback dvr's");
413 return;
414 }
415 if (hasSwFe && !hasHwFe && playbackDvrIds.empty()) {
416 ALOGD("cannot configure descrambling. Only SW frontends and no playback dvr's");
417 return;
418 }
419 ALOGD("Can support descrambling");
420 descrambling.support = true;
421}
422
423inline void determineDvrRecord() {
424 if (recordDvrIds.empty() || recordFilterIds.empty()) {
425 return;
426 }
427 if (frontendMap.empty() && playbackDvrIds.empty()) {
428 ALOGD("Cannot support dvr record. No frontends and no playback dvr's");
429 return;
430 }
431 if (hasSwFe && !hasHwFe && playbackDvrIds.empty()) {
432 ALOGD("Cannot support dvr record. Only SW frontends and no playback dvr's");
433 return;
434 }
435 ALOGD("Can support dvr record.");
436 record.support = true;
437}
438
Hongguang600a6ae2021-07-08 18:51:51 -0700439/** Read the vendor configurations of which hardware to use for each test cases/data flows */
440inline void connectHardwaresToTestCases() {
441 TunerTestingConfigAidlReader1_0::connectLiveBroadcast(live);
442 TunerTestingConfigAidlReader1_0::connectScan(scan);
443 TunerTestingConfigAidlReader1_0::connectDvrRecord(record);
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000444 TunerTestingConfigAidlReader1_0::connectTimeFilter(timeFilter);
Frankie Lizcanof5352122022-06-29 22:10:16 +0000445 TunerTestingConfigAidlReader1_0::connectDescrambling(descrambling);
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000446 TunerTestingConfigAidlReader1_0::connectLnbLive(lnbLive);
Frankie Lizcano3138d6b2022-07-11 22:06:45 +0000447 TunerTestingConfigAidlReader1_0::connectLnbRecord(lnbRecord);
Frankie Lizcano50461932022-06-28 21:36:26 +0000448 TunerTestingConfigAidlReader1_0::connectDvrPlayback(playback);
Hongguang600a6ae2021-07-08 18:51:51 -0700449};
450
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000451inline void determineDataFlows() {
452 determineScan();
453 determineTimeFilter();
454 determineDvrPlayback();
455 determineLnbLive();
456 determineLnbRecord();
457 determineLive();
458 determineDescrambling();
459 determineDvrRecord();
460}
461
Hongguang600a6ae2021-07-08 18:51:51 -0700462inline bool validateConnections() {
463 if (record.support && !record.hasFrontendConnection &&
464 record.dvrSourceId.compare(emptyHardwareId) == 0) {
465 ALOGW("[vts config] Record must support either a DVR source or a Frontend source.");
466 return false;
467 }
Gareth Fenn9a808452022-03-31 08:40:00 +0100468 bool feIsValid = live.hasFrontendConnection
469 ? frontendMap.find(live.frontendId) != frontendMap.end()
470 : true;
471 feIsValid &= scan.hasFrontendConnection ? frontendMap.find(scan.frontendId) != frontendMap.end()
472 : true;
473 feIsValid &= record.support && record.hasFrontendConnection
474 ? frontendMap.find(record.frontendId) != frontendMap.end()
475 : true;
Frankie Lizcanof5352122022-06-29 22:10:16 +0000476 feIsValid &= descrambling.support && descrambling.hasFrontendConnection
477 ? frontendMap.find(descrambling.frontendId) != frontendMap.end()
478 : true;
Hongguang600a6ae2021-07-08 18:51:51 -0700479
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000480 feIsValid &= lnbLive.support ? frontendMap.find(lnbLive.frontendId) != frontendMap.end() : true;
481
482 feIsValid &=
483 lnbRecord.support ? frontendMap.find(lnbRecord.frontendId) != frontendMap.end() : true;
484
Hongguang600a6ae2021-07-08 18:51:51 -0700485 if (!feIsValid) {
486 ALOGW("[vts config] dynamic config fe connection is invalid.");
487 return false;
488 }
489
490 bool dvrIsValid = frontendMap[live.frontendId].isSoftwareFe
491 ? dvrMap.find(live.dvrSoftwareFeId) != dvrMap.end()
492 : true;
493
494 if (record.support) {
495 if (record.hasFrontendConnection) {
496 if (frontendMap[record.frontendId].isSoftwareFe) {
497 dvrIsValid &= dvrMap.find(record.dvrSoftwareFeId) != dvrMap.end();
498 }
499 } else {
500 dvrIsValid &= dvrMap.find(record.dvrSourceId) != dvrMap.end();
501 }
502 dvrIsValid &= dvrMap.find(record.dvrRecordId) != dvrMap.end();
503 }
504
Frankie Lizcanof5352122022-06-29 22:10:16 +0000505 if (descrambling.support) {
506 if (descrambling.hasFrontendConnection) {
507 if (frontendMap[descrambling.frontendId].isSoftwareFe) {
508 dvrIsValid &= dvrMap.find(descrambling.dvrSoftwareFeId) != dvrMap.end();
509 }
510 } else {
511 dvrIsValid &= dvrMap.find(descrambling.dvrSourceId) != dvrMap.end();
512 }
513 }
514
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000515 dvrIsValid &= lnbRecord.support ? dvrMap.find(lnbRecord.dvrRecordId) != dvrMap.end() : true;
516
Frankie Lizcano50461932022-06-28 21:36:26 +0000517 dvrIsValid &= playback.support ? dvrMap.find(playback.dvrId) != dvrMap.end() : true;
518
Hongguang600a6ae2021-07-08 18:51:51 -0700519 if (!dvrIsValid) {
520 ALOGW("[vts config] dynamic config dvr connection is invalid.");
521 return false;
522 }
523
Gareth Fenn9a808452022-03-31 08:40:00 +0100524 bool filterIsValid = (live.hasFrontendConnection)
525 ? filterMap.find(live.audioFilterId) != filterMap.end() &&
526 filterMap.find(live.videoFilterId) != filterMap.end()
527 : true;
Hongguang600a6ae2021-07-08 18:51:51 -0700528 filterIsValid &=
529 record.support ? filterMap.find(record.recordFilterId) != filterMap.end() : true;
530
Frankie Lizcanof5352122022-06-29 22:10:16 +0000531 filterIsValid &= descrambling.support
532 ? filterMap.find(descrambling.videoFilterId) != filterMap.end() &&
533 filterMap.find(descrambling.audioFilterId) != filterMap.end()
534 : true;
535
536 for (auto& filterId : descrambling.extraFilters) {
537 filterIsValid &= filterMap.find(filterId) != filterMap.end();
538 }
539
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000540 filterIsValid &= lnbLive.support
541 ? filterMap.find(lnbLive.audioFilterId) != filterMap.end() &&
542 filterMap.find(lnbLive.videoFilterId) != filterMap.end()
543 : true;
544
545 filterIsValid &=
546 lnbRecord.support ? filterMap.find(lnbRecord.recordFilterId) != filterMap.end() : true;
547
548 for (auto& filterId : lnbRecord.extraFilters) {
549 filterIsValid &= filterMap.find(filterId) != filterMap.end();
550 }
551
552 for (auto& filterId : lnbLive.extraFilters) {
553 filterIsValid &= filterMap.find(filterId) != filterMap.end();
554 }
555
Frankie Lizcano50461932022-06-28 21:36:26 +0000556 filterIsValid &= playback.support
557 ? filterMap.find(playback.audioFilterId) != filterMap.end() &&
558 filterMap.find(playback.videoFilterId) != filterMap.end()
559 : true;
560 filterIsValid &= playback.sectionFilterId.compare(emptyHardwareId) == 0
561 ? true
562 : filterMap.find(playback.sectionFilterId) != filterMap.end();
563
564 for (auto& filterId : playback.extraFilters) {
565 filterIsValid &=
566 playback.hasExtraFilters ? filterMap.find(filterId) != filterMap.end() : true;
567 }
568
Hongguang600a6ae2021-07-08 18:51:51 -0700569 if (!filterIsValid) {
570 ALOGW("[vts config] dynamic config filter connection is invalid.");
571 return false;
572 }
573
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000574 bool timeFilterIsValid =
575 timeFilter.support ? timeFilterMap.find(timeFilter.timeFilterId) != timeFilterMap.end()
576 : true;
577
578 if (!timeFilterIsValid) {
579 ALOGW("[vts config] dynamic config time filter connection is invalid.");
Frankie Lizcanof5352122022-06-29 22:10:16 +0000580 }
581
582 bool descramblerIsValid =
583 descrambling.support
584 ? descramblerMap.find(descrambling.descramblerId) != descramblerMap.end()
585 : true;
586
587 if (!descramblerIsValid) {
588 ALOGW("[vts config] dynamic config descrambler connection is invalid.");
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000589 return false;
590 }
591
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000592 bool lnbIsValid = lnbLive.support ? lnbMap.find(lnbLive.lnbId) != lnbMap.end() : true;
593
594 lnbIsValid &= lnbRecord.support ? lnbMap.find(lnbRecord.lnbId) != lnbMap.end() : true;
595
596 if (!lnbIsValid) {
597 ALOGW("[vts config] dynamic config lnb connection is invalid.");
598 return false;
599 }
600
601 bool diseqcMsgsIsValid = true;
602
603 for (auto& msg : lnbRecord.diseqcMsgs) {
604 diseqcMsgsIsValid &= diseqcMsgMap.find(msg) != diseqcMsgMap.end();
605 }
606
607 for (auto& msg : lnbLive.diseqcMsgs) {
608 diseqcMsgsIsValid &= diseqcMsgMap.find(msg) != diseqcMsgMap.end();
609 }
610
611 if (!diseqcMsgsIsValid) {
612 ALOGW("[vts config] dynamic config diseqcMsg is invalid.");
613 return false;
614 }
615
Hongguang600a6ae2021-07-08 18:51:51 -0700616 return true;
617}