blob: 875cf551edeb8bd062c7e318ca5b6854b7ba073c [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
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000134 * index 2 - optional section filters
Frankie Lizcanoa53f5542022-07-07 17:32:06 +0000135 */
136static inline vector<DvrPlaybackHardwareConnections> generatePlaybackCombinations() {
137 vector<DvrPlaybackHardwareConnections> combinations;
138 vector<string> sectionFilterIds_optional = sectionFilterIds;
139 sectionFilterIds_optional.push_back(emptyHardwareId);
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000140 vector<vector<string>> deviceIds{playbackDvrIds, audioFilterIds, sectionFilterIds_optional};
Frankie Lizcanoa53f5542022-07-07 17:32:06 +0000141
142 const int dvrIndex = 0;
143 const int audioFilterIndex = 1;
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000144 const int sectionFilterIndex = 2;
Frankie Lizcanoa53f5542022-07-07 17:32:06 +0000145
146 auto idCombinations = generateIdCombinations(deviceIds);
147 for (auto& combo : idCombinations) {
148 DvrPlaybackHardwareConnections mPlayback;
149 mPlayback.dvrId = combo[dvrIndex];
150 mPlayback.audioFilterId = combo[audioFilterIndex];
Frankie Lizcanoa53f5542022-07-07 17:32:06 +0000151 mPlayback.sectionFilterId = combo[sectionFilterIndex];
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000152 const int videoFilterIndex =
153 find(audioFilterIds.begin(), audioFilterIds.end(), mPlayback.audioFilterId) -
154 audioFilterIds.begin();
155 mPlayback.videoFilterId = videoFilterIds[videoFilterIndex];
Frankie Lizcanoa53f5542022-07-07 17:32:06 +0000156 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
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000179 * index 2 - lnbs
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000180 */
181static inline vector<LnbLiveHardwareConnections> generateLnbLiveCombinations() {
182 vector<LnbLiveHardwareConnections> combinations;
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000183 vector<vector<string>> deviceIds{frontendIds, audioFilterIds, lnbIds};
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000184
185 const int frontendIndex = 0;
186 const int audioFilterIndex = 1;
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000187 const int lnbIndex = 2;
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000188
189 // TODO: Find a better way to vary diseqcMsgs, if at all
190 auto idCombinations = generateIdCombinations(deviceIds);
191 for (auto& combo : idCombinations) {
192 const string feId = combo[frontendIndex];
193 auto type = frontendMap[feId].type;
194 if (type == FrontendType::DVBS || type == FrontendType::ISDBS ||
195 type == FrontendType::ISDBS3) {
196 LnbLiveHardwareConnections mLnbLive;
197 mLnbLive.frontendId = feId;
198 mLnbLive.audioFilterId = combo[audioFilterIndex];
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000199 const int videoFilterIndex =
200 find(audioFilterIds.begin(), audioFilterIds.end(), mLnbLive.audioFilterId) -
201 audioFilterIds.begin();
202 mLnbLive.videoFilterId = videoFilterIds[videoFilterIndex];
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000203 mLnbLive.lnbId = combo[lnbIndex];
204 mLnbLive.diseqcMsgs = diseqcMsgs;
205 combinations.push_back(mLnbLive);
206 }
207 }
208
209 return combinations;
210}
211
212static inline vector<LnbLiveHardwareConnections> generateLnbLiveConfigurations() {
213 vector<LnbLiveHardwareConnections> lnbLive_configs;
214 if (configuredLnbLive) {
215 ALOGD("Using LnbLive configuration provided.");
216 lnbLive_configs = {lnbLive};
217 } else {
218 ALOGD("LnbLive not provided. Generating possible combinations. Consider adding it to the "
219 "configuration file.");
220 lnbLive_configs = generateLnbLiveCombinations();
221 }
222
223 return lnbLive_configs;
224}
225
Frankie Lizcano3138d6b2022-07-11 22:06:45 +0000226static inline vector<ScanHardwareConnections> generateScanCombinations() {
227 vector<ScanHardwareConnections> combinations;
228
229 for (auto& id : frontendIds) {
230 ScanHardwareConnections mScan;
231 mScan.frontendId = id;
232 combinations.push_back(mScan);
233 }
234
235 return combinations;
236}
237
238static inline vector<ScanHardwareConnections> generateScanConfigurations() {
239 vector<ScanHardwareConnections> scan_configs;
240 if (configuredScan) {
241 ALOGD("Using scan configuration provided.");
242 scan_configs = {scan};
243 } else {
244 ALOGD("Scan not provided. Generating possible combinations. Consider adding it to "
245 "the configuration file.");
246 scan_configs = generateScanCombinations();
247 }
248
249 return scan_configs;
250}
251
Frankie Lizcanoecba02a2022-07-12 17:56:54 +0000252/*
253 * index 0 - frontends
254 * index 1 - record filter
255 * index 2 - Record Dvr
256 * index 3 - Lnb
257 */
258static inline vector<LnbRecordHardwareConnections> generateLnbRecordCombinations() {
259 vector<LnbRecordHardwareConnections> combinations;
260 vector<vector<string>> deviceIds{frontendIds, recordFilterIds, recordDvrIds, lnbIds};
261
262 const int frontendIndex = 0;
263 const int recordFilterIndex = 1;
264 const int dvrIndex = 2;
265 const int lnbIndex = 3;
266
267 auto idCombinations = generateIdCombinations(deviceIds);
268 // TODO : Find a better way to vary diseqcMsgs, if at all
269 for (auto& combo : idCombinations) {
270 const string feId = combo[frontendIndex];
271 auto type = frontendMap[feId].type;
272 if (type == FrontendType::DVBS || type == FrontendType::ISDBS ||
273 type == FrontendType::ISDBS3) {
274 LnbRecordHardwareConnections mLnbRecord;
275 mLnbRecord.frontendId = feId;
276 mLnbRecord.recordFilterId = combo[recordFilterIndex];
277 mLnbRecord.dvrRecordId = combo[dvrIndex];
278 mLnbRecord.lnbId = combo[lnbIndex];
279 mLnbRecord.diseqcMsgs = diseqcMsgs;
280 combinations.push_back(mLnbRecord);
281 }
282 }
283
284 return combinations;
285}
286
287static inline vector<LnbRecordHardwareConnections> generateLnbRecordConfigurations() {
288 vector<LnbRecordHardwareConnections> lnbRecord_configs;
289 if (configuredLnbRecord) {
290 ALOGD("Using LnbRecord configuration provided.");
291 lnbRecord_configs = {lnbRecord};
292 } else {
293 ALOGD("LnbRecord not provided. Generating possible combinations. Consider adding it to "
294 "the configuration file.");
295 lnbRecord_configs = generateLnbRecordCombinations();
296 }
297
298 return lnbRecord_configs;
299}
300
Frankie Lizcanof4e07962022-07-13 20:54:34 +0000301/*
302 * index 0 - decramblers
303 * index 1 - frontends
304 * index 2 - audio filters
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000305 * index 3 - Dvr SW Fe Connections
306 * index 4 - DVR Source Connections
Frankie Lizcanof4e07962022-07-13 20:54:34 +0000307 */
308static inline vector<DescramblingHardwareConnections> generateDescramblingCombinations() {
309 vector<DescramblingHardwareConnections> combinations;
310 vector<string> mfrontendIds = frontendIds;
311 vector<string> mDvrFeConnectionIds = playbackDvrIds;
312 vector<string> mDvrSourceConnectionIds = playbackDvrIds;
313
314 // Add the empty hardware id to each vector to include combinations where these 3 fields might
315 // be optional
316 mfrontendIds.push_back(emptyHardwareId);
317 mDvrFeConnectionIds.push_back(emptyHardwareId);
318 mDvrSourceConnectionIds.push_back(emptyHardwareId);
319
320 const int descramblerIndex = 0;
321 const int frontendIndex = 1;
322 const int audioFilterIndex = 2;
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000323 const int dvrFeIdIndex = 3;
324 const int dvrSourceIdIndex = 4;
Frankie Lizcanof4e07962022-07-13 20:54:34 +0000325
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000326 vector<vector<string>> deviceIds{descramblerIds, mfrontendIds, audioFilterIds,
327 mDvrFeConnectionIds, mDvrSourceConnectionIds};
Frankie Lizcanof4e07962022-07-13 20:54:34 +0000328 auto idCombinations = generateIdCombinations(deviceIds);
329 for (auto& combo : idCombinations) {
330 DescramblingHardwareConnections mDescrambling;
331 const string feId = combo[frontendIndex];
332 const string dvrSwFeId = combo[dvrFeIdIndex];
333 const string dvrSourceId = combo[dvrSourceIdIndex];
334 mDescrambling.hasFrontendConnection = feId.compare(emptyHardwareId) == 0 ? false : true;
335 if (!mDescrambling.hasFrontendConnection) {
336 if (dvrSourceId.compare(emptyHardwareId) == 0) {
337 // If combination does not have a frontend or dvr source connection, do not include
338 // it
339 continue;
340 }
341 } else {
342 if (frontendMap[feId].isSoftwareFe && dvrSwFeId.compare(emptyHardwareId) == 0) {
343 // If combination has a software frontend and no dvr->software frontend connection,
344 // do not include it
345 continue;
346 }
347 }
348 if (dvrSwFeId.compare(dvrSourceId) == 0) {
349 // If dvr->software frontend connection is the same as dvr source input to tuner, do not
350 // include it.
351 continue;
352 }
353 mDescrambling.frontendId = feId;
354 mDescrambling.audioFilterId = combo[audioFilterIndex];
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000355 const int videoFilterIndex =
356 find(audioFilterIds.begin(), audioFilterIds.end(), mDescrambling.audioFilterId) -
357 audioFilterIds.begin();
358 mDescrambling.videoFilterId = videoFilterIds[videoFilterIndex];
Frankie Lizcanof4e07962022-07-13 20:54:34 +0000359 mDescrambling.dvrSoftwareFeId = dvrSwFeId;
360 mDescrambling.dvrSourceId = dvrSourceId;
361 mDescrambling.descramblerId = combo[descramblerIndex];
362 combinations.push_back(mDescrambling);
363 }
364
365 return combinations;
366}
367
368static inline vector<DescramblingHardwareConnections> generateDescramblingConfigurations() {
369 vector<DescramblingHardwareConnections> descrambling_configs;
370 if (configuredDescrambling) {
371 ALOGD("Using Descrambling configuration provided.");
372 descrambling_configs = {descrambling};
373 } else {
374 ALOGD("Descrambling not provided. Generating possible combinations. Consider adding it to "
375 "the "
376 "configuration file.");
377 descrambling_configs = generateDescramblingCombinations();
378 }
379
380 return descrambling_configs;
381}
382
Frankie Lizcano0c069532022-07-14 20:20:46 +0000383static inline vector<TimeFilterHardwareConnections> generateTimeFilterCombinations() {
384 vector<TimeFilterHardwareConnections> combinations;
385
386 for (auto& id : timeFilterIds) {
387 TimeFilterHardwareConnections mTimeFilter;
388 mTimeFilter.timeFilterId = id;
389 combinations.push_back(mTimeFilter);
390 }
391
392 return combinations;
393}
394
395static inline vector<TimeFilterHardwareConnections> generateTimeFilterConfigurations() {
396 vector<TimeFilterHardwareConnections> timeFilter_configs;
397 if (configuredTimeFilter) {
398 ALOGD("Using TimeFilter configuration provided.");
399 timeFilter_configs = {timeFilter};
400 } else {
401 ALOGD("TimeFilter not provided. Generating possible combinations. Consider adding it to "
402 "the "
403 "configuration file.");
404 timeFilter_configs = generateTimeFilterCombinations();
405 }
406
407 return timeFilter_configs;
408}
409
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000410/*
411 * index 0 - frontends
412 * index 1 - record dvrs
413 * index 2 - record filters
414 */
415static inline vector<DvrRecordHardwareConnections> generateRecordCombinations() {
416 vector<DvrRecordHardwareConnections> combinations;
417
418 const int frontendIdIndex = 0;
419 const int recordDvrIndex = 1;
420 const int recordFilterIndex = 2;
421
422 vector<vector<string>> deviceIds{frontendIds, recordDvrIds, recordFilterIds};
423
424 auto idCombinations = generateIdCombinations(deviceIds);
425 for (auto& combo : idCombinations) {
426 DvrRecordHardwareConnections mRecord;
427 const string feId = combo[frontendIdIndex];
428 mRecord.hasFrontendConnection = true;
429 if (frontendMap[feId].isSoftwareFe) {
430 // If we have a software frontend, do not include configuration for testing.
431 continue;
432 }
433 mRecord.frontendId = feId;
434 mRecord.support = true;
435 mRecord.dvrSourceId = emptyHardwareId;
436 mRecord.dvrSoftwareFeId = emptyHardwareId;
437 mRecord.recordFilterId = combo[recordFilterIndex];
438 mRecord.dvrRecordId = combo[recordDvrIndex];
439 combinations.push_back(mRecord);
440 }
441
442 return combinations;
443}
444
445static inline vector<DvrRecordHardwareConnections> generateRecordConfigurations() {
446 vector<DvrRecordHardwareConnections> record_configs;
447 if (configuredRecord) {
448 ALOGD("Using Record configuration provided.");
449 record_configs = {record};
450 } else {
451 ALOGD("Record not provided. Generating possible combinations. Consider adding it to "
452 "the "
453 "configuration file.");
454 record_configs = generateRecordCombinations();
455 }
456
457 return record_configs;
458}
459
Hongguang600a6ae2021-07-08 18:51:51 -0700460/** Config all the frontends that would be used in the tests */
461inline void initFrontendConfig() {
462 // The test will use the internal default fe when default fe is connected to any data flow
463 // without overriding in the xml config.
464 string defaultFeId = "FE_DEFAULT";
465 FrontendDvbtSettings dvbtSettings{
Gareth Fenn282fb372021-09-27 15:14:11 +0100466 .frequency = 578000000,
Hongguang600a6ae2021-07-08 18:51:51 -0700467 .transmissionMode = FrontendDvbtTransmissionMode::AUTO,
468 .bandwidth = FrontendDvbtBandwidth::BANDWIDTH_8MHZ,
469 .isHighPriority = true,
470 };
471 frontendMap[defaultFeId].type = FrontendType::DVBT;
472 frontendMap[defaultFeId].settings.set<FrontendSettings::Tag::dvbt>(dvbtSettings);
473
474 vector<FrontendStatusType> types;
475 types.push_back(FrontendStatusType::UEC);
476 types.push_back(FrontendStatusType::IS_MISO);
477
478 vector<FrontendStatus> statuses;
479 FrontendStatus status;
480 status.set<FrontendStatus::Tag::uec>(4);
481 statuses.push_back(status);
482 status.set<FrontendStatus::Tag::isMiso>(true);
483 statuses.push_back(status);
484
485 frontendMap[defaultFeId].tuneStatusTypes = types;
486 frontendMap[defaultFeId].expectTuneStatuses = statuses;
487 frontendMap[defaultFeId].isSoftwareFe = true;
488 frontendMap[defaultFeId].canConnectToCiCam = true;
489 frontendMap[defaultFeId].ciCamId = 0;
490 FrontendDvbtSettings dvbt;
491 dvbt.transmissionMode = FrontendDvbtTransmissionMode::MODE_8K_E;
492 frontendMap[defaultFeId].settings.set<FrontendSettings::Tag::dvbt>(dvbt);
493 // Read customized config
494 TunerTestingConfigAidlReader1_0::readFrontendConfig1_0(frontendMap);
495};
496
497inline void initFilterConfig() {
498 // The test will use the internal default filter when default filter is connected to any
499 // data flow without overriding in the xml config.
500 string defaultAudioFilterId = "FILTER_AUDIO_DEFAULT";
501 string defaultVideoFilterId = "FILTER_VIDEO_DEFAULT";
502
503 filterMap[defaultVideoFilterId].type.mainType = DemuxFilterMainType::TS;
Hongguangce1e30d2021-08-02 21:55:44 -0700504 filterMap[defaultVideoFilterId].type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
505 DemuxTsFilterType::VIDEO);
Hongguang600a6ae2021-07-08 18:51:51 -0700506 filterMap[defaultVideoFilterId].bufferSize = FMQ_SIZE_16M;
507 filterMap[defaultVideoFilterId].settings =
508 DemuxFilterSettings::make<DemuxFilterSettings::Tag::ts>();
509 filterMap[defaultVideoFilterId].settings.get<DemuxFilterSettings::Tag::ts>().tpid = 256;
510 DemuxFilterAvSettings video;
511 video.isPassthrough = false;
512 filterMap[defaultVideoFilterId]
513 .settings.get<DemuxFilterSettings::Tag::ts>()
514 .filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(video);
515 filterMap[defaultVideoFilterId].monitorEventTypes =
516 static_cast<int32_t>(DemuxFilterMonitorEventType::SCRAMBLING_STATUS) |
517 static_cast<int32_t>(DemuxFilterMonitorEventType::IP_CID_CHANGE);
518 filterMap[defaultVideoFilterId].streamType.set<AvStreamType::Tag::video>(
519 VideoStreamType::MPEG1);
520
521 filterMap[defaultAudioFilterId].type.mainType = DemuxFilterMainType::TS;
Hongguangce1e30d2021-08-02 21:55:44 -0700522 filterMap[defaultAudioFilterId].type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
523 DemuxTsFilterType::AUDIO);
Hongguang600a6ae2021-07-08 18:51:51 -0700524 filterMap[defaultAudioFilterId].bufferSize = FMQ_SIZE_16M;
525 filterMap[defaultAudioFilterId].settings =
526 DemuxFilterSettings::make<DemuxFilterSettings::Tag::ts>();
527 filterMap[defaultAudioFilterId].settings.get<DemuxFilterSettings::Tag::ts>().tpid = 256;
528 DemuxFilterAvSettings audio;
529 audio.isPassthrough = false;
530 filterMap[defaultAudioFilterId]
531 .settings.get<DemuxFilterSettings::Tag::ts>()
532 .filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(audio);
533 filterMap[defaultAudioFilterId].monitorEventTypes =
534 static_cast<int32_t>(DemuxFilterMonitorEventType::SCRAMBLING_STATUS) |
535 static_cast<int32_t>(DemuxFilterMonitorEventType::IP_CID_CHANGE);
536 filterMap[defaultAudioFilterId].streamType.set<AvStreamType::Tag::audio>(AudioStreamType::MP3);
537 // Read customized config
538 TunerTestingConfigAidlReader1_0::readFilterConfig1_0(filterMap);
539};
540
541/** Config all the dvrs that would be used in the tests */
542inline void initDvrConfig() {
543 // Read customized config
544 TunerTestingConfigAidlReader1_0::readDvrConfig1_0(dvrMap);
545};
546
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000547inline void initTimeFilterConfig() {
548 // Read customized config
549 TunerTestingConfigAidlReader1_0::readTimeFilterConfig1_0(timeFilterMap);
550};
551
Frankie Lizcanof5352122022-06-29 22:10:16 +0000552inline void initDescramblerConfig() {
553 // Read customized config
554 TunerTestingConfigAidlReader1_0::readDescramblerConfig1_0(descramblerMap);
555}
556
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000557inline void initLnbConfig() {
558 // Read customized config
559 TunerTestingConfigAidlReader1_0::readLnbConfig1_0(lnbMap);
560};
561
562inline void initDiseqcMsgsConfig() {
563 // Read customized config
564 TunerTestingConfigAidlReader1_0::readDiseqcMessages(diseqcMsgMap);
565};
566
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000567inline void determineScan() {
568 if (!frontendMap.empty()) {
569 scan.hasFrontendConnection = true;
570 ALOGD("Can support scan");
571 }
572}
573
574inline void determineTimeFilter() {
575 if (!timeFilterMap.empty()) {
576 timeFilter.support = true;
577 ALOGD("Can support time filter");
578 }
579}
580
581inline void determineDvrPlayback() {
582 if (!playbackDvrIds.empty() && !audioFilterIds.empty() && !videoFilterIds.empty()) {
583 playback.support = true;
584 ALOGD("Can support dvr playback");
585 }
586}
587
588inline void determineLnbLive() {
589 if (!audioFilterIds.empty() && !videoFilterIds.empty() && !frontendMap.empty() &&
590 !lnbMap.empty()) {
591 lnbLive.support = true;
592 ALOGD("Can support lnb live");
593 }
594}
595
596inline void determineLnbRecord() {
597 if (!frontendMap.empty() && !recordFilterIds.empty() && !recordDvrIds.empty() &&
598 !lnbMap.empty()) {
599 lnbRecord.support = true;
600 ALOGD("Can support lnb record");
601 }
602}
603
604inline void determineLive() {
605 if (videoFilterIds.empty() || audioFilterIds.empty() || frontendMap.empty()) {
606 return;
607 }
608 if (hasSwFe && !hasHwFe && dvrMap.empty()) {
609 ALOGD("Cannot configure Live. Only software frontends and no dvr connections");
610 return;
611 }
612 ALOGD("Can support live");
613 live.hasFrontendConnection = true;
614}
615
616inline void determineDescrambling() {
617 if (descramblerMap.empty() || audioFilterIds.empty() || videoFilterIds.empty()) {
618 return;
619 }
620 if (frontendMap.empty() && playbackDvrIds.empty()) {
621 ALOGD("Cannot configure descrambling. No frontends or playback dvr's");
622 return;
623 }
624 if (hasSwFe && !hasHwFe && playbackDvrIds.empty()) {
625 ALOGD("cannot configure descrambling. Only SW frontends and no playback dvr's");
626 return;
627 }
628 ALOGD("Can support descrambling");
629 descrambling.support = true;
630}
631
632inline void determineDvrRecord() {
633 if (recordDvrIds.empty() || recordFilterIds.empty()) {
634 return;
635 }
636 if (frontendMap.empty() && playbackDvrIds.empty()) {
Frankie Lizcanoecba02a2022-07-12 17:56:54 +0000637 ALOGD("Cannot support dvr record. No frontends and no playback dvr's");
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000638 return;
639 }
640 if (hasSwFe && !hasHwFe && playbackDvrIds.empty()) {
641 ALOGD("Cannot support dvr record. Only SW frontends and no playback dvr's");
642 return;
643 }
644 ALOGD("Can support dvr record.");
645 record.support = true;
646}
647
Hongguang600a6ae2021-07-08 18:51:51 -0700648/** Read the vendor configurations of which hardware to use for each test cases/data flows */
649inline void connectHardwaresToTestCases() {
650 TunerTestingConfigAidlReader1_0::connectLiveBroadcast(live);
651 TunerTestingConfigAidlReader1_0::connectScan(scan);
652 TunerTestingConfigAidlReader1_0::connectDvrRecord(record);
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000653 TunerTestingConfigAidlReader1_0::connectTimeFilter(timeFilter);
Frankie Lizcanof5352122022-06-29 22:10:16 +0000654 TunerTestingConfigAidlReader1_0::connectDescrambling(descrambling);
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000655 TunerTestingConfigAidlReader1_0::connectLnbLive(lnbLive);
Frankie Lizcano3138d6b2022-07-11 22:06:45 +0000656 TunerTestingConfigAidlReader1_0::connectLnbRecord(lnbRecord);
Frankie Lizcano50461932022-06-28 21:36:26 +0000657 TunerTestingConfigAidlReader1_0::connectDvrPlayback(playback);
Hongguang600a6ae2021-07-08 18:51:51 -0700658};
659
Frankie Lizcano5b29f502022-07-06 22:09:42 +0000660inline void determineDataFlows() {
661 determineScan();
662 determineTimeFilter();
663 determineDvrPlayback();
664 determineLnbLive();
665 determineLnbRecord();
666 determineLive();
667 determineDescrambling();
668 determineDvrRecord();
669}
670
Hongguang600a6ae2021-07-08 18:51:51 -0700671inline bool validateConnections() {
672 if (record.support && !record.hasFrontendConnection &&
673 record.dvrSourceId.compare(emptyHardwareId) == 0) {
674 ALOGW("[vts config] Record must support either a DVR source or a Frontend source.");
675 return false;
676 }
Gareth Fenn9a808452022-03-31 08:40:00 +0100677 bool feIsValid = live.hasFrontendConnection
678 ? frontendMap.find(live.frontendId) != frontendMap.end()
679 : true;
680 feIsValid &= scan.hasFrontendConnection ? frontendMap.find(scan.frontendId) != frontendMap.end()
681 : true;
682 feIsValid &= record.support && record.hasFrontendConnection
683 ? frontendMap.find(record.frontendId) != frontendMap.end()
684 : true;
Frankie Lizcanof5352122022-06-29 22:10:16 +0000685 feIsValid &= descrambling.support && descrambling.hasFrontendConnection
686 ? frontendMap.find(descrambling.frontendId) != frontendMap.end()
687 : true;
Hongguang600a6ae2021-07-08 18:51:51 -0700688
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000689 feIsValid &= lnbLive.support ? frontendMap.find(lnbLive.frontendId) != frontendMap.end() : true;
690
691 feIsValid &=
692 lnbRecord.support ? frontendMap.find(lnbRecord.frontendId) != frontendMap.end() : true;
693
Hongguang600a6ae2021-07-08 18:51:51 -0700694 if (!feIsValid) {
695 ALOGW("[vts config] dynamic config fe connection is invalid.");
696 return false;
697 }
698
699 bool dvrIsValid = frontendMap[live.frontendId].isSoftwareFe
700 ? dvrMap.find(live.dvrSoftwareFeId) != dvrMap.end()
701 : true;
702
703 if (record.support) {
704 if (record.hasFrontendConnection) {
705 if (frontendMap[record.frontendId].isSoftwareFe) {
706 dvrIsValid &= dvrMap.find(record.dvrSoftwareFeId) != dvrMap.end();
707 }
708 } else {
709 dvrIsValid &= dvrMap.find(record.dvrSourceId) != dvrMap.end();
710 }
711 dvrIsValid &= dvrMap.find(record.dvrRecordId) != dvrMap.end();
712 }
713
Frankie Lizcanof5352122022-06-29 22:10:16 +0000714 if (descrambling.support) {
715 if (descrambling.hasFrontendConnection) {
716 if (frontendMap[descrambling.frontendId].isSoftwareFe) {
717 dvrIsValid &= dvrMap.find(descrambling.dvrSoftwareFeId) != dvrMap.end();
718 }
719 } else {
720 dvrIsValid &= dvrMap.find(descrambling.dvrSourceId) != dvrMap.end();
721 }
722 }
723
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000724 dvrIsValid &= lnbRecord.support ? dvrMap.find(lnbRecord.dvrRecordId) != dvrMap.end() : true;
725
Frankie Lizcano50461932022-06-28 21:36:26 +0000726 dvrIsValid &= playback.support ? dvrMap.find(playback.dvrId) != dvrMap.end() : true;
727
Hongguang600a6ae2021-07-08 18:51:51 -0700728 if (!dvrIsValid) {
729 ALOGW("[vts config] dynamic config dvr connection is invalid.");
730 return false;
731 }
732
Gareth Fenn9a808452022-03-31 08:40:00 +0100733 bool filterIsValid = (live.hasFrontendConnection)
734 ? filterMap.find(live.audioFilterId) != filterMap.end() &&
735 filterMap.find(live.videoFilterId) != filterMap.end()
736 : true;
Hongguang600a6ae2021-07-08 18:51:51 -0700737 filterIsValid &=
738 record.support ? filterMap.find(record.recordFilterId) != filterMap.end() : true;
739
Frankie Lizcanof5352122022-06-29 22:10:16 +0000740 filterIsValid &= descrambling.support
741 ? filterMap.find(descrambling.videoFilterId) != filterMap.end() &&
742 filterMap.find(descrambling.audioFilterId) != filterMap.end()
743 : true;
744
745 for (auto& filterId : descrambling.extraFilters) {
746 filterIsValid &= filterMap.find(filterId) != filterMap.end();
747 }
748
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000749 filterIsValid &= lnbLive.support
750 ? filterMap.find(lnbLive.audioFilterId) != filterMap.end() &&
751 filterMap.find(lnbLive.videoFilterId) != filterMap.end()
752 : true;
753
754 filterIsValid &=
755 lnbRecord.support ? filterMap.find(lnbRecord.recordFilterId) != filterMap.end() : true;
756
757 for (auto& filterId : lnbRecord.extraFilters) {
758 filterIsValid &= filterMap.find(filterId) != filterMap.end();
759 }
760
761 for (auto& filterId : lnbLive.extraFilters) {
762 filterIsValid &= filterMap.find(filterId) != filterMap.end();
763 }
764
Frankie Lizcano50461932022-06-28 21:36:26 +0000765 filterIsValid &= playback.support
766 ? filterMap.find(playback.audioFilterId) != filterMap.end() &&
767 filterMap.find(playback.videoFilterId) != filterMap.end()
768 : true;
769 filterIsValid &= playback.sectionFilterId.compare(emptyHardwareId) == 0
770 ? true
771 : filterMap.find(playback.sectionFilterId) != filterMap.end();
772
773 for (auto& filterId : playback.extraFilters) {
774 filterIsValid &=
775 playback.hasExtraFilters ? filterMap.find(filterId) != filterMap.end() : true;
776 }
777
Hongguang600a6ae2021-07-08 18:51:51 -0700778 if (!filterIsValid) {
779 ALOGW("[vts config] dynamic config filter connection is invalid.");
780 return false;
781 }
782
Frankie Lizcano14aa8482022-07-26 16:50:35 +0000783 if (audioFilterIds.size() != videoFilterIds.size()) {
784 ALOGW("[vts config] the number of audio and video filters should be equal");
785 return false;
786 }
787
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000788 bool timeFilterIsValid =
789 timeFilter.support ? timeFilterMap.find(timeFilter.timeFilterId) != timeFilterMap.end()
790 : true;
791
792 if (!timeFilterIsValid) {
793 ALOGW("[vts config] dynamic config time filter connection is invalid.");
Frankie Lizcanof5352122022-06-29 22:10:16 +0000794 }
795
796 bool descramblerIsValid =
797 descrambling.support
798 ? descramblerMap.find(descrambling.descramblerId) != descramblerMap.end()
799 : true;
800
801 if (!descramblerIsValid) {
802 ALOGW("[vts config] dynamic config descrambler connection is invalid.");
Frankie Lizcano1fd52972022-06-30 16:50:21 +0000803 return false;
804 }
805
Frankie Lizcano647d5aa2022-06-30 20:49:31 +0000806 bool lnbIsValid = lnbLive.support ? lnbMap.find(lnbLive.lnbId) != lnbMap.end() : true;
807
808 lnbIsValid &= lnbRecord.support ? lnbMap.find(lnbRecord.lnbId) != lnbMap.end() : true;
809
810 if (!lnbIsValid) {
811 ALOGW("[vts config] dynamic config lnb connection is invalid.");
812 return false;
813 }
814
815 bool diseqcMsgsIsValid = true;
816
817 for (auto& msg : lnbRecord.diseqcMsgs) {
818 diseqcMsgsIsValid &= diseqcMsgMap.find(msg) != diseqcMsgMap.end();
819 }
820
821 for (auto& msg : lnbLive.diseqcMsgs) {
822 diseqcMsgsIsValid &= diseqcMsgMap.find(msg) != diseqcMsgMap.end();
823 }
824
825 if (!diseqcMsgsIsValid) {
826 ALOGW("[vts config] dynamic config diseqcMsg is invalid.");
827 return false;
828 }
829
Hongguang600a6ae2021-07-08 18:51:51 -0700830 return true;
831}