blob: e23067cbaec5ec4c2b5ef89dbb93622e4146658e [file] [log] [blame]
Amy Zhange6915052021-03-30 13:44:43 -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 <android-base/logging.h>
18#include <android/hardware/tv/tuner/1.0/types.h>
19#include <android_media_tuner_testing_configuration_V1_0.h>
20#include <android_media_tuner_testing_configuration_V1_0_enums.h>
21#include <binder/MemoryDealer.h>
22#include <hidl/HidlSupport.h>
23#include <hidl/HidlTransportSupport.h>
24#include <hidl/Status.h>
25#include <hidlmemory/FrameworkUtils.h>
26
27using namespace std;
28using namespace android::media::tuner::testing::configuration::V1_0;
29
30using android::hardware::tv::tuner::V1_0::DataFormat;
31using android::hardware::tv::tuner::V1_0::DemuxAlpFilterType;
Amy Zhang2ea2fe22021-04-01 11:55:41 -070032using android::hardware::tv::tuner::V1_0::DemuxFilterAvSettings;
Amy Zhange6915052021-03-30 13:44:43 -070033using android::hardware::tv::tuner::V1_0::DemuxFilterEvent;
34using android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
Amy Zhang2ea2fe22021-04-01 11:55:41 -070035using android::hardware::tv::tuner::V1_0::DemuxFilterRecordSettings;
36using android::hardware::tv::tuner::V1_0::DemuxFilterSectionSettings;
Amy Zhange6915052021-03-30 13:44:43 -070037using android::hardware::tv::tuner::V1_0::DemuxFilterSettings;
38using android::hardware::tv::tuner::V1_0::DemuxFilterType;
Amy Zhang06fa69e2021-04-09 09:56:25 -070039using android::hardware::tv::tuner::V1_0::DemuxIpAddress;
40using android::hardware::tv::tuner::V1_0::DemuxIpFilterSettings;
Amy Zhange6915052021-03-30 13:44:43 -070041using android::hardware::tv::tuner::V1_0::DemuxIpFilterType;
42using android::hardware::tv::tuner::V1_0::DemuxMmtpFilterType;
43using android::hardware::tv::tuner::V1_0::DemuxRecordScIndexType;
44using android::hardware::tv::tuner::V1_0::DemuxTlvFilterType;
45using android::hardware::tv::tuner::V1_0::DemuxTpid;
46using android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
47using android::hardware::tv::tuner::V1_0::DvrSettings;
48using android::hardware::tv::tuner::V1_0::DvrType;
49using android::hardware::tv::tuner::V1_0::FrontendDvbsSettings;
50using android::hardware::tv::tuner::V1_0::FrontendDvbtBandwidth;
51using android::hardware::tv::tuner::V1_0::FrontendDvbtCoderate;
52using android::hardware::tv::tuner::V1_0::FrontendDvbtConstellation;
53using android::hardware::tv::tuner::V1_0::FrontendDvbtGuardInterval;
54using android::hardware::tv::tuner::V1_0::FrontendDvbtHierarchy;
Henry Fang0d591fd2021-05-13 17:30:32 -070055using android::hardware::tv::tuner::V1_0::FrontendDvbtPlpMode;
Amy Zhange6915052021-03-30 13:44:43 -070056using android::hardware::tv::tuner::V1_0::FrontendDvbtSettings;
57using android::hardware::tv::tuner::V1_0::FrontendDvbtStandard;
58using android::hardware::tv::tuner::V1_0::FrontendDvbtTransmissionMode;
Atsushi Iriboshi288de6d2023-10-13 09:47:36 +090059using android::hardware::tv::tuner::V1_0::FrontendIsdbsCoderate;
60using android::hardware::tv::tuner::V1_0::FrontendIsdbsModulation;
61using android::hardware::tv::tuner::V1_0::FrontendIsdbsRolloff;
62using android::hardware::tv::tuner::V1_0::FrontendIsdbsSettings;
63using android::hardware::tv::tuner::V1_0::FrontendIsdbsStreamIdType;
64using android::hardware::tv::tuner::V1_0::FrontendIsdbtBandwidth;
65using android::hardware::tv::tuner::V1_0::FrontendIsdbtCoderate;
66using android::hardware::tv::tuner::V1_0::FrontendIsdbtGuardInterval;
67using android::hardware::tv::tuner::V1_0::FrontendIsdbtMode;
68using android::hardware::tv::tuner::V1_0::FrontendIsdbtModulation;
69using android::hardware::tv::tuner::V1_0::FrontendIsdbtSettings;
Amy Zhange6915052021-03-30 13:44:43 -070070using android::hardware::tv::tuner::V1_0::FrontendSettings;
71using android::hardware::tv::tuner::V1_0::FrontendStatus;
72using android::hardware::tv::tuner::V1_0::FrontendStatusType;
73using android::hardware::tv::tuner::V1_0::FrontendType;
74using android::hardware::tv::tuner::V1_0::LnbPosition;
75using android::hardware::tv::tuner::V1_0::LnbTone;
76using android::hardware::tv::tuner::V1_0::LnbVoltage;
77using android::hardware::tv::tuner::V1_0::PlaybackSettings;
78using android::hardware::tv::tuner::V1_0::RecordSettings;
Weid4dcef22023-03-06 15:30:27 +080079using android::hardware::tv::tuner::V1_0::FrontendAtscSettings;
Amy Zhange6915052021-03-30 13:44:43 -070080
Amy Zhang2ea2fe22021-04-01 11:55:41 -070081const string emptyHardwareId = "";
Amy Zhange6915052021-03-30 13:44:43 -070082
Amy Zhang06fa69e2021-04-09 09:56:25 -070083static string mConfigFilePath;
84
Amy Zhang32b6f9e2021-04-02 15:01:17 -070085#define PROVISION_STR \
86 "{ " \
87 " \"id\": 21140844, " \
88 " \"name\": \"Test Title\", " \
89 " \"lowercase_organization_name\": \"Android\", " \
90 " \"asset_key\": { " \
91 " \"encryption_key\": \"nezAr3CHFrmBR9R8Tedotw==\" " \
92 " }, " \
93 " \"cas_type\": 1, " \
94 " \"track_types\": [ ] " \
95 "} "
96
Amy Zhange6915052021-03-30 13:44:43 -070097struct FrontendConfig {
98 bool isSoftwareFe;
99 FrontendType type;
100 FrontendSettings settings;
101 vector<FrontendStatusType> tuneStatusTypes;
102 vector<FrontendStatus> expectTuneStatuses;
103};
104
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700105struct FilterConfig {
106 uint32_t bufferSize;
107 DemuxFilterType type;
108 DemuxFilterSettings settings;
109 bool getMqDesc;
110
111 bool operator<(const FilterConfig& /*c*/) const { return false; }
112};
113
Amy Zhange50f08d2021-03-30 15:56:02 -0700114struct DvrConfig {
115 DvrType type;
116 uint32_t bufferSize;
117 DvrSettings settings;
118 string playbackInputFile;
119};
120
Amy Zhangc0e9a112021-04-01 19:25:21 -0700121struct LnbConfig {
122 string name;
123 LnbVoltage voltage;
124 LnbTone tone;
125 LnbPosition position;
126};
127
128struct TimeFilterConfig {
129 uint64_t timeStamp;
130};
131
Amy Zhang32b6f9e2021-04-02 15:01:17 -0700132struct DescramblerConfig {
133 uint32_t casSystemId;
134 string provisionStr;
135 vector<uint8_t> hidlPvtData;
136};
137
Amy Zhange6915052021-03-30 13:44:43 -0700138struct LiveBroadcastHardwareConnections {
Amy Zhang160a72c2021-04-24 21:15:26 -0700139 bool hasFrontendConnection;
Amy Zhange6915052021-03-30 13:44:43 -0700140 string frontendId;
Amy Zhange50f08d2021-03-30 15:56:02 -0700141 string dvrSoftwareFeId;
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700142 string audioFilterId;
Amy Zhange6915052021-03-30 13:44:43 -0700143 string videoFilterId;
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700144 string sectionFilterId;
Amy Zhang06fa69e2021-04-09 09:56:25 -0700145 string ipFilterId;
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700146 string pcrFilterId;
147 /* list string of extra filters; */
Amy Zhange6915052021-03-30 13:44:43 -0700148};
149
150struct ScanHardwareConnections {
Amy Zhang160a72c2021-04-24 21:15:26 -0700151 bool hasFrontendConnection;
Amy Zhange6915052021-03-30 13:44:43 -0700152 string frontendId;
153};
154
Amy Zhange50f08d2021-03-30 15:56:02 -0700155struct DvrPlaybackHardwareConnections {
156 bool support;
157 string frontendId;
158 string dvrId;
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700159 string audioFilterId;
Amy Zhange50f08d2021-03-30 15:56:02 -0700160 string videoFilterId;
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700161 string sectionFilterId;
162 /* list string of extra filters; */
Amy Zhange50f08d2021-03-30 15:56:02 -0700163};
164
Amy Zhange6915052021-03-30 13:44:43 -0700165struct DvrRecordHardwareConnections {
166 bool support;
Amy Zhang160a72c2021-04-24 21:15:26 -0700167 bool hasFrontendConnection;
Amy Zhange6915052021-03-30 13:44:43 -0700168 string frontendId;
Amy Zhange50f08d2021-03-30 15:56:02 -0700169 string dvrRecordId;
170 string dvrSoftwareFeId;
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700171 string recordFilterId;
Amy Zhang160a72c2021-04-24 21:15:26 -0700172 string dvrSourceId;
Amy Zhange6915052021-03-30 13:44:43 -0700173};
174
175struct DescramblingHardwareConnections {
176 bool support;
Amy Zhang160a72c2021-04-24 21:15:26 -0700177 bool hasFrontendConnection;
Amy Zhange6915052021-03-30 13:44:43 -0700178 string frontendId;
Amy Zhange50f08d2021-03-30 15:56:02 -0700179 string dvrSoftwareFeId;
Amy Zhange6915052021-03-30 13:44:43 -0700180 string audioFilterId;
181 string videoFilterId;
Amy Zhang32b6f9e2021-04-02 15:01:17 -0700182 string descramblerId;
Amy Zhang160a72c2021-04-24 21:15:26 -0700183 string dvrSourceId;
Amy Zhang32b6f9e2021-04-02 15:01:17 -0700184 /* list string of extra filters; */
Amy Zhange6915052021-03-30 13:44:43 -0700185};
186
187struct LnbLiveHardwareConnections {
188 bool support;
189 string frontendId;
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700190 string audioFilterId;
Amy Zhange6915052021-03-30 13:44:43 -0700191 string videoFilterId;
Amy Zhangc0e9a112021-04-01 19:25:21 -0700192 string lnbId;
193 vector<string> diseqcMsgs;
194 /* list string of extra filters; */
Amy Zhange6915052021-03-30 13:44:43 -0700195};
196
197struct LnbRecordHardwareConnections {
198 bool support;
199 string frontendId;
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700200 string dvrRecordId;
201 string recordFilterId;
Amy Zhangc0e9a112021-04-01 19:25:21 -0700202 string lnbId;
203 vector<string> diseqcMsgs;
204 /* list string of extra filters; */
205};
206
207struct TimeFilterHardwareConnections {
208 bool support;
209 string timeFilterId;
Amy Zhange6915052021-03-30 13:44:43 -0700210};
211
Amy Zhang06fa69e2021-04-09 09:56:25 -0700212struct TunerTestingConfigReader1_0 {
Amy Zhange6915052021-03-30 13:44:43 -0700213 public:
Amy Zhang06fa69e2021-04-09 09:56:25 -0700214 static void setConfigFilePath(string path) { mConfigFilePath = path; }
215
Amy Zhange6915052021-03-30 13:44:43 -0700216 static bool checkConfigFileExists() {
Amy Zhang06fa69e2021-04-09 09:56:25 -0700217 auto res = read(mConfigFilePath.c_str());
Amy Zhange6915052021-03-30 13:44:43 -0700218 if (res == nullopt) {
Amy Zhang06fa69e2021-04-09 09:56:25 -0700219 ALOGW("[ConfigReader] Couldn't read %s."
Amy Zhange6915052021-03-30 13:44:43 -0700220 "Please check tuner_testing_dynamic_configuration.xsd"
Amy Zhang06fa69e2021-04-09 09:56:25 -0700221 "and sample_tuner_vts_config.xml for more details on how to config Tune VTS.",
222 mConfigFilePath.c_str());
Amy Zhange6915052021-03-30 13:44:43 -0700223 }
224 return (res != nullopt);
225 }
226
227 static void readFrontendConfig1_0(map<string, FrontendConfig>& frontendMap) {
228 auto hardwareConfig = getHardwareConfig();
229 if (hardwareConfig.hasFrontends()) {
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700230 // TODO: b/182519645 complete the tune status config
Amy Zhange6915052021-03-30 13:44:43 -0700231 vector<FrontendStatusType> types;
232 types.push_back(FrontendStatusType::DEMOD_LOCK);
233 FrontendStatus status;
234 status.isDemodLocked(true);
235 vector<FrontendStatus> statuses;
236 statuses.push_back(status);
237
238 auto frontends = *hardwareConfig.getFirstFrontends();
239 for (auto feConfig : frontends.getFrontend()) {
240 string id = feConfig.getId();
241 if (id.compare(string("FE_DEFAULT")) == 0) {
242 // overrid default
243 frontendMap.erase(string("FE_DEFAULT"));
244 }
245 FrontendType type;
246 switch (feConfig.getType()) {
247 case FrontendTypeEnum::UNDEFINED:
248 type = FrontendType::UNDEFINED;
249 break;
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700250 // TODO: b/182519645 finish all other frontend settings
Amy Zhange6915052021-03-30 13:44:43 -0700251 case FrontendTypeEnum::ANALOG:
252 type = FrontendType::ANALOG;
253 break;
254 case FrontendTypeEnum::ATSC:
255 type = FrontendType::ATSC;
Weid4dcef22023-03-06 15:30:27 +0800256 frontendMap[id].settings.atsc(readAtscFrontendSettings(feConfig));
Amy Zhange6915052021-03-30 13:44:43 -0700257 break;
258 case FrontendTypeEnum::ATSC3:
259 type = FrontendType::ATSC3;
260 break;
261 case FrontendTypeEnum::DVBC:
262 type = FrontendType::DVBC;
263 break;
264 case FrontendTypeEnum::DVBS:
265 type = FrontendType::DVBS;
266 frontendMap[id].settings.dvbs(readDvbsFrontendSettings(feConfig));
267 break;
268 case FrontendTypeEnum::DVBT: {
269 type = FrontendType::DVBT;
270 frontendMap[id].settings.dvbt(readDvbtFrontendSettings(feConfig));
271 break;
272 }
273 case FrontendTypeEnum::ISDBS:
274 type = FrontendType::ISDBS;
Atsushi Iriboshi288de6d2023-10-13 09:47:36 +0900275 frontendMap[id].settings.isdbs(readIsdbsFrontendSettings(feConfig));
Amy Zhange6915052021-03-30 13:44:43 -0700276 break;
277 case FrontendTypeEnum::ISDBS3:
278 type = FrontendType::ISDBS3;
279 break;
280 case FrontendTypeEnum::ISDBT:
281 type = FrontendType::ISDBT;
Atsushi Iriboshi288de6d2023-10-13 09:47:36 +0900282 frontendMap[id].settings.isdbt(readIsdbtFrontendSettings(feConfig));
Amy Zhange6915052021-03-30 13:44:43 -0700283 break;
284 case FrontendTypeEnum::DTMB:
285 // dtmb will be handled in readFrontendConfig1_1;
286 continue;
287 case FrontendTypeEnum::UNKNOWN:
288 ALOGW("[ConfigReader] invalid frontend type");
289 return;
290 }
291 frontendMap[id].type = type;
292 frontendMap[id].isSoftwareFe = feConfig.getIsSoftwareFrontend();
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700293 // TODO: b/182519645 complete the tune status config
Amy Zhange6915052021-03-30 13:44:43 -0700294 frontendMap[id].tuneStatusTypes = types;
295 frontendMap[id].expectTuneStatuses = statuses;
296 }
297 }
298 }
299
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700300 static void readFilterConfig1_0(map<string, FilterConfig>& filterMap) {
301 auto hardwareConfig = getHardwareConfig();
302 if (hardwareConfig.hasFilters()) {
303 auto filters = *hardwareConfig.getFirstFilters();
304 for (auto filterConfig : filters.getFilter()) {
305 string id = filterConfig.getId();
306 if (id.compare(string("FILTER_AUDIO_DEFAULT")) == 0) {
307 // overrid default
308 filterMap.erase(string("FILTER_AUDIO_DEFAULT"));
309 }
310 if (id.compare(string("FILTER_VIDEO_DEFAULT")) == 0) {
311 // overrid default
312 filterMap.erase(string("FILTER_VIDEO_DEFAULT"));
313 }
314
315 DemuxFilterType type;
316 DemuxFilterSettings settings;
317 if (!readFilterTypeAndSettings(filterConfig, type, settings)) {
318 ALOGW("[ConfigReader] invalid filter type");
319 return;
320 }
321 filterMap[id].type = type;
322 filterMap[id].bufferSize = filterConfig.getBufferSize();
323 filterMap[id].getMqDesc = filterConfig.getUseFMQ();
324 filterMap[id].settings = settings;
325 }
326 }
327 }
328
Amy Zhange50f08d2021-03-30 15:56:02 -0700329 static void readDvrConfig1_0(map<string, DvrConfig>& dvrMap) {
330 auto hardwareConfig = getHardwareConfig();
331 if (hardwareConfig.hasDvrs()) {
332 auto dvrs = *hardwareConfig.getFirstDvrs();
333 for (auto dvrConfig : dvrs.getDvr()) {
334 string id = dvrConfig.getId();
335 DvrType type;
336 switch (dvrConfig.getType()) {
337 case DvrTypeEnum::PLAYBACK:
338 type = DvrType::PLAYBACK;
339 dvrMap[id].settings.playback(readPlaybackSettings(dvrConfig));
340 break;
341 case DvrTypeEnum::RECORD:
342 type = DvrType::RECORD;
343 dvrMap[id].settings.record(readRecordSettings(dvrConfig));
344 break;
345 case DvrTypeEnum::UNKNOWN:
346 ALOGW("[ConfigReader] invalid DVR type");
347 return;
348 }
349 dvrMap[id].type = type;
350 dvrMap[id].bufferSize = static_cast<uint32_t>(dvrConfig.getBufferSize());
351 if (dvrConfig.hasInputFilePath()) {
352 dvrMap[id].playbackInputFile = dvrConfig.getInputFilePath();
353 }
354 }
355 }
356 }
357
Amy Zhangc0e9a112021-04-01 19:25:21 -0700358 static void readLnbConfig1_0(map<string, LnbConfig>& lnbMap) {
359 auto hardwareConfig = getHardwareConfig();
360 if (hardwareConfig.hasLnbs()) {
361 auto lnbs = *hardwareConfig.getFirstLnbs();
362 for (auto lnbConfig : lnbs.getLnb()) {
363 string id = lnbConfig.getId();
364 if (lnbConfig.hasName()) {
365 lnbMap[id].name = lnbConfig.getName();
366 } else {
367 lnbMap[id].name = emptyHardwareId;
368 }
369 lnbMap[id].voltage = static_cast<LnbVoltage>(lnbConfig.getVoltage());
370 lnbMap[id].tone = static_cast<LnbTone>(lnbConfig.getTone());
371 lnbMap[id].position = static_cast<LnbPosition>(lnbConfig.getPosition());
372 }
373 }
374 }
375
Amy Zhang32b6f9e2021-04-02 15:01:17 -0700376 static void readDescramblerConfig1_0(map<string, DescramblerConfig>& descramblerMap) {
377 auto hardwareConfig = getHardwareConfig();
378 if (hardwareConfig.hasDescramblers()) {
379 auto descramblers = *hardwareConfig.getFirstDescramblers();
380 for (auto descramblerConfig : descramblers.getDescrambler()) {
381 string id = descramblerConfig.getId();
382 descramblerMap[id].casSystemId =
383 static_cast<uint32_t>(descramblerConfig.getCasSystemId());
384 if (descramblerConfig.hasProvisionStr()) {
385 descramblerMap[id].provisionStr = descramblerConfig.getProvisionStr();
386 } else {
387 descramblerMap[id].provisionStr = PROVISION_STR;
388 }
389 if (descramblerConfig.hasSesstionPrivatData()) {
390 auto privateData = descramblerConfig.getSesstionPrivatData();
391 int size = privateData.size();
392 descramblerMap[id].hidlPvtData.resize(size);
393 memcpy(descramblerMap[id].hidlPvtData.data(), privateData.data(), size);
394 } else {
395 descramblerMap[id].hidlPvtData.resize(256);
396 }
397 }
398 }
399 }
400
Amy Zhangc0e9a112021-04-01 19:25:21 -0700401 static void readDiseqcMessages(map<string, vector<uint8_t>>& diseqcMsgMap) {
402 auto hardwareConfig = getHardwareConfig();
403 if (hardwareConfig.hasDiseqcMessages()) {
404 auto msgs = *hardwareConfig.getFirstDiseqcMessages();
405 for (auto msgConfig : msgs.getDiseqcMessage()) {
406 string name = msgConfig.getMsgName();
407 for (uint8_t atom : msgConfig.getMsgBody()) {
408 diseqcMsgMap[name].push_back(atom);
409 }
410 }
411 }
412 }
413
414 static void readTimeFilterConfig1_0(map<string, TimeFilterConfig>& timeFilterMap) {
415 auto hardwareConfig = getHardwareConfig();
416 if (hardwareConfig.hasTimeFilters()) {
417 auto timeFilters = *hardwareConfig.getFirstTimeFilters();
418 for (auto timeFilterConfig : timeFilters.getTimeFilter()) {
419 string id = timeFilterConfig.getId();
420 timeFilterMap[id].timeStamp =
421 static_cast<uint64_t>(timeFilterConfig.getTimeStamp());
422 }
423 }
424 }
425
Amy Zhange6915052021-03-30 13:44:43 -0700426 static void connectLiveBroadcast(LiveBroadcastHardwareConnections& live) {
Amy Zhang160a72c2021-04-24 21:15:26 -0700427 auto dataFlow = getDataFlowConfiguration();
428 if (dataFlow.hasClearLiveBroadcast()) {
429 live.hasFrontendConnection = true;
430 } else {
431 live.hasFrontendConnection = false;
432 return;
433 }
434 auto liveConfig = *dataFlow.getFirstClearLiveBroadcast();
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700435 live.frontendId = liveConfig.getFrontendConnection();
436
437 live.audioFilterId = liveConfig.getAudioFilterConnection();
438 live.videoFilterId = liveConfig.getVideoFilterConnection();
439 if (liveConfig.hasPcrFilterConnection()) {
440 live.pcrFilterId = liveConfig.getPcrFilterConnection();
441 } else {
442 live.pcrFilterId = emptyHardwareId;
443 }
444 if (liveConfig.hasSectionFilterConnection()) {
445 live.sectionFilterId = liveConfig.getSectionFilterConnection();
446 } else {
447 live.sectionFilterId = emptyHardwareId;
448 }
449 if (liveConfig.hasDvrSoftwareFeConnection()) {
450 live.dvrSoftwareFeId = liveConfig.getDvrSoftwareFeConnection();
Amy Zhange50f08d2021-03-30 15:56:02 -0700451 }
Amy Zhang06fa69e2021-04-09 09:56:25 -0700452 if (liveConfig.hasIpFilterConnection()) {
453 live.ipFilterId = liveConfig.getIpFilterConnection();
454 } else {
455 live.ipFilterId = emptyHardwareId;
456 }
Amy Zhange6915052021-03-30 13:44:43 -0700457 }
458
459 static void connectScan(ScanHardwareConnections& scan) {
Amy Zhang160a72c2021-04-24 21:15:26 -0700460 auto dataFlow = getDataFlowConfiguration();
461 if (dataFlow.hasScan()) {
462 scan.hasFrontendConnection = true;
463 } else {
464 scan.hasFrontendConnection = false;
465 return;
466 }
467 auto scanConfig = *dataFlow.getFirstScan();
468 scan.frontendId = scanConfig.getFrontendConnection();
Amy Zhange6915052021-03-30 13:44:43 -0700469 }
470
Amy Zhange50f08d2021-03-30 15:56:02 -0700471 static void connectDvrPlayback(DvrPlaybackHardwareConnections& playback) {
472 auto dataFlow = getDataFlowConfiguration();
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700473 if (dataFlow.hasDvrPlayback()) {
474 playback.support = true;
475 } else {
Amy Zhang160a72c2021-04-24 21:15:26 -0700476 playback.support = false;
Amy Zhange50f08d2021-03-30 15:56:02 -0700477 return;
478 }
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700479 auto playbackConfig = *dataFlow.getFirstDvrPlayback();
480 playback.dvrId = playbackConfig.getDvrConnection();
481 playback.audioFilterId = playbackConfig.getAudioFilterConnection();
482 playback.videoFilterId = playbackConfig.getVideoFilterConnection();
483 if (playbackConfig.hasSectionFilterConnection()) {
484 playback.sectionFilterId = playbackConfig.getSectionFilterConnection();
485 } else {
486 playback.sectionFilterId = emptyHardwareId;
487 }
Amy Zhange50f08d2021-03-30 15:56:02 -0700488 }
489
Amy Zhange6915052021-03-30 13:44:43 -0700490 static void connectDvrRecord(DvrRecordHardwareConnections& record) {
491 auto dataFlow = getDataFlowConfiguration();
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700492 if (dataFlow.hasDvrRecord()) {
493 record.support = true;
494 } else {
Amy Zhang160a72c2021-04-24 21:15:26 -0700495 record.support = false;
Amy Zhange6915052021-03-30 13:44:43 -0700496 return;
497 }
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700498 auto recordConfig = *dataFlow.getFirstDvrRecord();
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700499 record.recordFilterId = recordConfig.getRecordFilterConnection();
500 record.dvrRecordId = recordConfig.getDvrRecordConnection();
501 if (recordConfig.hasDvrSoftwareFeConnection()) {
502 record.dvrSoftwareFeId = recordConfig.getDvrSoftwareFeConnection();
Amy Zhange50f08d2021-03-30 15:56:02 -0700503 }
Amy Zhang160a72c2021-04-24 21:15:26 -0700504 if (recordConfig.getHasFrontendConnection()) {
505 record.hasFrontendConnection = true;
506 record.dvrSourceId = emptyHardwareId;
Henry Fang3e1a1d32021-05-04 13:54:47 -0700507 record.frontendId = recordConfig.getFrontendConnection();
Amy Zhang160a72c2021-04-24 21:15:26 -0700508 } else {
509 record.hasFrontendConnection = false;
510 record.dvrSourceId = recordConfig.getDvrSourceConnection();
511 }
Amy Zhange6915052021-03-30 13:44:43 -0700512 }
513
514 static void connectDescrambling(DescramblingHardwareConnections& descrambling) {
515 auto dataFlow = getDataFlowConfiguration();
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700516 if (dataFlow.hasDescrambling()) {
517 descrambling.support = true;
518 } else {
Amy Zhang160a72c2021-04-24 21:15:26 -0700519 descrambling.support = false;
Amy Zhange6915052021-03-30 13:44:43 -0700520 return;
521 }
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700522 auto descConfig = *dataFlow.getFirstDescrambling();
Amy Zhang32b6f9e2021-04-02 15:01:17 -0700523 descrambling.descramblerId = descConfig.getDescramblerConnection();
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700524 descrambling.audioFilterId = descConfig.getAudioFilterConnection();
525 descrambling.videoFilterId = descConfig.getVideoFilterConnection();
526 if (descConfig.hasDvrSoftwareFeConnection()) {
527 descrambling.dvrSoftwareFeId = descConfig.getDvrSoftwareFeConnection();
Amy Zhange50f08d2021-03-30 15:56:02 -0700528 }
Amy Zhang160a72c2021-04-24 21:15:26 -0700529 if (descConfig.getHasFrontendConnection()) {
530 descrambling.hasFrontendConnection = true;
531 descrambling.dvrSourceId = emptyHardwareId;
Henry Fang3e1a1d32021-05-04 13:54:47 -0700532 descrambling.frontendId = descConfig.getFrontendConnection();
Amy Zhang160a72c2021-04-24 21:15:26 -0700533 } else {
534 descrambling.hasFrontendConnection = false;
535 descrambling.dvrSourceId = descConfig.getDvrSourceConnection();
536 }
Amy Zhange6915052021-03-30 13:44:43 -0700537 }
538
539 static void connectLnbLive(LnbLiveHardwareConnections& lnbLive) {
540 auto dataFlow = getDataFlowConfiguration();
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700541 if (dataFlow.hasLnbLive()) {
542 lnbLive.support = true;
543 } else {
Amy Zhang160a72c2021-04-24 21:15:26 -0700544 lnbLive.support = false;
Amy Zhange6915052021-03-30 13:44:43 -0700545 return;
546 }
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700547 auto lnbLiveConfig = *dataFlow.getFirstLnbLive();
548 lnbLive.frontendId = lnbLiveConfig.getFrontendConnection();
549 lnbLive.audioFilterId = lnbLiveConfig.getAudioFilterConnection();
550 lnbLive.videoFilterId = lnbLiveConfig.getVideoFilterConnection();
Amy Zhangc0e9a112021-04-01 19:25:21 -0700551 lnbLive.lnbId = lnbLiveConfig.getLnbConnection();
552 if (lnbLiveConfig.hasDiseqcMsgSender()) {
553 for (auto msgName : lnbLiveConfig.getDiseqcMsgSender()) {
554 lnbLive.diseqcMsgs.push_back(msgName);
555 }
556 }
Amy Zhange6915052021-03-30 13:44:43 -0700557 }
558
559 static void connectLnbRecord(LnbRecordHardwareConnections& lnbRecord) {
560 auto dataFlow = getDataFlowConfiguration();
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700561 if (dataFlow.hasLnbRecord()) {
562 lnbRecord.support = true;
563 } else {
Amy Zhang160a72c2021-04-24 21:15:26 -0700564 lnbRecord.support = false;
Amy Zhange6915052021-03-30 13:44:43 -0700565 return;
566 }
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700567 auto lnbRecordConfig = *dataFlow.getFirstLnbRecord();
568 lnbRecord.frontendId = lnbRecordConfig.getFrontendConnection();
569 lnbRecord.recordFilterId = lnbRecordConfig.getRecordFilterConnection();
570 lnbRecord.dvrRecordId = lnbRecordConfig.getDvrRecordConnection();
Amy Zhangc0e9a112021-04-01 19:25:21 -0700571 lnbRecord.lnbId = lnbRecordConfig.getLnbConnection();
572 if (lnbRecordConfig.hasDiseqcMsgSender()) {
573 for (auto msgName : lnbRecordConfig.getDiseqcMsgSender()) {
574 lnbRecord.diseqcMsgs.push_back(msgName);
575 }
576 }
577 }
578
579 static void connectTimeFilter(TimeFilterHardwareConnections& timeFilter) {
580 auto dataFlow = getDataFlowConfiguration();
581 if (dataFlow.hasTimeFilter()) {
582 timeFilter.support = true;
583 } else {
Amy Zhang160a72c2021-04-24 21:15:26 -0700584 timeFilter.support = false;
Amy Zhangc0e9a112021-04-01 19:25:21 -0700585 return;
586 }
587 auto timeFilterConfig = *dataFlow.getFirstTimeFilter();
588 timeFilter.timeFilterId = timeFilterConfig.getTimeFilterConnection();
Amy Zhange6915052021-03-30 13:44:43 -0700589 }
590
Amy Zhang06fa69e2021-04-09 09:56:25 -0700591 static HardwareConfiguration getHardwareConfig() {
592 return *getTunerConfig().getFirstHardwareConfiguration();
593 }
594
Amy Zhange6915052021-03-30 13:44:43 -0700595 private:
Atsushi Iriboshi288de6d2023-10-13 09:47:36 +0900596 static FrontendIsdbtSettings readIsdbtFrontendSettings(Frontend feConfig) {
597 ALOGW("[ConfigReader] fe type is isdbt");
598 FrontendIsdbtSettings isdbtSettings{
599 .frequency = (uint32_t)feConfig.getFrequency(),
600 };
601 if (!feConfig.hasIsdbtFrontendSettings_optional()) {
602 ALOGW("[ConfigReader] no more isdbt settings");
603 return isdbtSettings;
604 }
605 auto isdbt = feConfig.getFirstIsdbtFrontendSettings_optional();
606 isdbtSettings.modulation = static_cast<FrontendIsdbtModulation>(isdbt->getModulation());
607 isdbtSettings.bandwidth = static_cast<FrontendIsdbtBandwidth>(isdbt->getBandwidth());
608 isdbtSettings.mode = static_cast<FrontendIsdbtMode>(isdbt->getMode());
609 isdbtSettings.coderate = static_cast<FrontendIsdbtCoderate>(isdbt->getCoderate());
610 isdbtSettings.guardInterval =
611 static_cast<FrontendIsdbtGuardInterval>(isdbt->getGuardInterval());
612 isdbtSettings.serviceAreaId = static_cast<uint32_t>(isdbt->getServiceAreaId());
613 return isdbtSettings;
614 }
615
616 static FrontendIsdbsSettings readIsdbsFrontendSettings(Frontend feConfig) {
617 ALOGW("[ConfigReader] fe type is isdbs");
618 FrontendIsdbsSettings isdbsSettings{
619 .frequency = (uint32_t)feConfig.getFrequency(),
620 };
621 if (!feConfig.hasIsdbsFrontendSettings_optional()) {
622 ALOGW("[ConfigReader] no more isdbs settings");
623 return isdbsSettings;
624 }
625 auto isdbs = feConfig.getFirstIsdbsFrontendSettings_optional();
626 isdbsSettings.streamId = static_cast<uint16_t>(isdbs->getStreamId());
627 isdbsSettings.streamIdType =
628 static_cast<FrontendIsdbsStreamIdType>(isdbs->getStreamIdType());
629 isdbsSettings.modulation = static_cast<FrontendIsdbsModulation>(isdbs->getModulation());
630 isdbsSettings.coderate = static_cast<FrontendIsdbsCoderate>(isdbs->getCoderate());
631 isdbsSettings.symbolRate = static_cast<uint32_t>(isdbs->getSymbolRate());
632 isdbsSettings.rolloff = static_cast<FrontendIsdbsRolloff>(isdbs->getRolloff());
633 return isdbsSettings;
634 }
635
Amy Zhange6915052021-03-30 13:44:43 -0700636 static FrontendDvbtSettings readDvbtFrontendSettings(Frontend feConfig) {
Amy Zhange50f08d2021-03-30 15:56:02 -0700637 ALOGW("[ConfigReader] fe type is dvbt");
Amy Zhange6915052021-03-30 13:44:43 -0700638 FrontendDvbtSettings dvbtSettings{
639 .frequency = (uint32_t)feConfig.getFrequency(),
640 };
641 if (!feConfig.hasDvbtFrontendSettings_optional()) {
642 ALOGW("[ConfigReader] no more dvbt settings");
643 return dvbtSettings;
644 }
Amy Zhang06fa69e2021-04-09 09:56:25 -0700645 auto dvbt = feConfig.getFirstDvbtFrontendSettings_optional();
646 uint32_t trans = static_cast<uint32_t>(dvbt->getTransmissionMode());
647 if (trans <= (uint32_t)FrontendDvbtTransmissionMode::MODE_32K) {
648 dvbtSettings.transmissionMode = static_cast<FrontendDvbtTransmissionMode>(trans);
649 }
650 dvbtSettings.bandwidth = static_cast<FrontendDvbtBandwidth>(dvbt->getBandwidth());
651 dvbtSettings.isHighPriority = dvbt->getIsHighPriority();
Henry Fang0d591fd2021-05-13 17:30:32 -0700652 dvbtSettings.hierarchy = static_cast<FrontendDvbtHierarchy>(dvbt->getHierarchy());
653 dvbtSettings.hpCoderate = static_cast<FrontendDvbtCoderate>(dvbt->getHpCoderate());
654 dvbtSettings.lpCoderate = static_cast<FrontendDvbtCoderate>(dvbt->getLpCoderate());
655 dvbtSettings.guardInterval =
656 static_cast<FrontendDvbtGuardInterval>(dvbt->getGuardInterval());
657 dvbtSettings.standard = static_cast<FrontendDvbtStandard>(dvbt->getStandard());
658 dvbtSettings.isMiso = dvbt->getIsMiso();
659 dvbtSettings.plpMode = static_cast<FrontendDvbtPlpMode>(dvbt->getPlpMode());
660 dvbtSettings.plpId = dvbt->getPlpId();
661 dvbtSettings.plpGroupId = dvbt->getPlpGroupId();
Amy Zhang06fa69e2021-04-09 09:56:25 -0700662 if (dvbt->hasConstellation()) {
663 dvbtSettings.constellation =
664 static_cast<FrontendDvbtConstellation>(dvbt->getConstellation());
665 }
Amy Zhange6915052021-03-30 13:44:43 -0700666 return dvbtSettings;
667 }
668
669 static FrontendDvbsSettings readDvbsFrontendSettings(Frontend feConfig) {
Amy Zhange50f08d2021-03-30 15:56:02 -0700670 ALOGW("[ConfigReader] fe type is dvbs");
Amy Zhange6915052021-03-30 13:44:43 -0700671 FrontendDvbsSettings dvbsSettings{
672 .frequency = (uint32_t)feConfig.getFrequency(),
673 };
674 if (!feConfig.hasDvbsFrontendSettings_optional()) {
675 ALOGW("[ConfigReader] no more dvbs settings");
676 return dvbsSettings;
677 }
678 dvbsSettings.symbolRate = static_cast<uint32_t>(
679 feConfig.getFirstDvbsFrontendSettings_optional()->getSymbolRate());
680 dvbsSettings.inputStreamId = static_cast<uint32_t>(
681 feConfig.getFirstDvbsFrontendSettings_optional()->getInputStreamId());
682 return dvbsSettings;
683 }
684
Weid4dcef22023-03-06 15:30:27 +0800685 static FrontendAtscSettings readAtscFrontendSettings(Frontend feConfig) {
686 FrontendAtscSettings atscSettings{
687 .frequency = (uint32_t)feConfig.getFrequency(),
688 };
689 return atscSettings;
690 }
691
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700692 static bool readFilterTypeAndSettings(Filter filterConfig, DemuxFilterType& type,
693 DemuxFilterSettings& settings) {
694 auto mainType = filterConfig.getMainType();
695 auto subType = filterConfig.getSubType();
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700696 switch (mainType) {
697 case FilterMainTypeEnum::TS: {
698 ALOGW("[ConfigReader] filter main type is ts");
699 type.mainType = DemuxFilterMainType::TS;
700 switch (subType) {
701 case FilterSubTypeEnum::UNDEFINED:
Amy Zhang06fa69e2021-04-09 09:56:25 -0700702 type.subType.tsFilterType(DemuxTsFilterType::UNDEFINED);
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700703 break;
704 case FilterSubTypeEnum::SECTION:
705 type.subType.tsFilterType(DemuxTsFilterType::SECTION);
706 settings.ts().filterSettings.section(
707 readSectionFilterSettings(filterConfig));
708 break;
709 case FilterSubTypeEnum::PES:
710 // TODO: b/182519645 support all the filter settings
711 /*settings.ts().filterSettings.pesData(
712 getPesFilterSettings(filterConfig));*/
713 type.subType.tsFilterType(DemuxTsFilterType::PES);
714 break;
715 case FilterSubTypeEnum::TS:
716 type.subType.tsFilterType(DemuxTsFilterType::TS);
717 settings.ts().filterSettings.noinit();
718 break;
719 case FilterSubTypeEnum::PCR:
720 type.subType.tsFilterType(DemuxTsFilterType::PCR);
721 settings.ts().filterSettings.noinit();
722 break;
723 case FilterSubTypeEnum::TEMI:
724 type.subType.tsFilterType(DemuxTsFilterType::TEMI);
725 settings.ts().filterSettings.noinit();
726 break;
727 case FilterSubTypeEnum::AUDIO:
728 type.subType.tsFilterType(DemuxTsFilterType::AUDIO);
729 settings.ts().filterSettings.av(readAvFilterSettings(filterConfig));
730 break;
731 case FilterSubTypeEnum::VIDEO:
732 type.subType.tsFilterType(DemuxTsFilterType::VIDEO);
733 settings.ts().filterSettings.av(readAvFilterSettings(filterConfig));
734 break;
735 case FilterSubTypeEnum::RECORD:
736 type.subType.tsFilterType(DemuxTsFilterType::RECORD);
737 settings.ts().filterSettings.record(readRecordFilterSettings(filterConfig));
738 break;
739 default:
740 ALOGW("[ConfigReader] ts subtype is not supported");
741 return false;
742 }
Amy Zhang06fa69e2021-04-09 09:56:25 -0700743 if (filterConfig.hasPid()) {
744 settings.ts().tpid = static_cast<uint32_t>(filterConfig.getPid());
745 }
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700746 break;
747 }
748 case FilterMainTypeEnum::MMTP: {
749 ALOGW("[ConfigReader] filter main type is mmtp");
750 type.mainType = DemuxFilterMainType::MMTP;
751 switch (subType) {
752 case FilterSubTypeEnum::UNDEFINED:
Amy Zhang06fa69e2021-04-09 09:56:25 -0700753 type.subType.mmtpFilterType(DemuxMmtpFilterType::UNDEFINED);
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700754 break;
755 case FilterSubTypeEnum::SECTION:
756 type.subType.mmtpFilterType(DemuxMmtpFilterType::SECTION);
757 settings.mmtp().filterSettings.section(
758 readSectionFilterSettings(filterConfig));
759 break;
760 case FilterSubTypeEnum::PES:
761 type.subType.mmtpFilterType(DemuxMmtpFilterType::PES);
762 // TODO: b/182519645 support all the filter settings
763 /*settings.mmtp().filterSettings.pesData(
764 getPesFilterSettings(filterConfig));*/
765 break;
766 case FilterSubTypeEnum::MMTP:
767 type.subType.mmtpFilterType(DemuxMmtpFilterType::MMTP);
768 settings.mmtp().filterSettings.noinit();
769 break;
770 case FilterSubTypeEnum::AUDIO:
771 type.subType.mmtpFilterType(DemuxMmtpFilterType::AUDIO);
772 settings.mmtp().filterSettings.av(readAvFilterSettings(filterConfig));
773 break;
774 case FilterSubTypeEnum::VIDEO:
775 settings.mmtp().filterSettings.av(readAvFilterSettings(filterConfig));
776 break;
777 case FilterSubTypeEnum::RECORD:
778 type.subType.mmtpFilterType(DemuxMmtpFilterType::RECORD);
779 settings.mmtp().filterSettings.record(
780 readRecordFilterSettings(filterConfig));
781 break;
782 case FilterSubTypeEnum::DOWNLOAD:
783 type.subType.mmtpFilterType(DemuxMmtpFilterType::DOWNLOAD);
784 // TODO: b/182519645 support all the filter settings
785 /*settings.mmtp().filterSettings.download(
786 getDownloadFilterSettings(filterConfig));*/
787 break;
788 default:
789 ALOGW("[ConfigReader] mmtp subtype is not supported");
790 return false;
791 }
Amy Zhang06fa69e2021-04-09 09:56:25 -0700792 if (filterConfig.hasPid()) {
793 settings.mmtp().mmtpPid = static_cast<uint32_t>(filterConfig.getPid());
794 }
795 break;
796 }
797 case FilterMainTypeEnum::IP: {
798 ALOGW("[ConfigReader] filter main type is ip");
799 type.mainType = DemuxFilterMainType::IP;
800 switch (subType) {
801 case FilterSubTypeEnum::UNDEFINED:
802 type.subType.ipFilterType(DemuxIpFilterType::UNDEFINED);
803 break;
804 case FilterSubTypeEnum::SECTION:
805 type.subType.ipFilterType(DemuxIpFilterType::SECTION);
806 settings.ip().filterSettings.section(
807 readSectionFilterSettings(filterConfig));
808 break;
809 case FilterSubTypeEnum::NTP:
810 type.subType.ipFilterType(DemuxIpFilterType::NTP);
811 settings.ip().filterSettings.noinit();
812 break;
813 case FilterSubTypeEnum::IP: {
814 DemuxIpFilterSettings ip{
815 .ipAddr = readIpAddress(filterConfig),
816 };
817 ip.filterSettings.bPassthrough(readPassthroughSettings(filterConfig));
818 settings.ip(ip);
819 break;
820 }
821 case FilterSubTypeEnum::IP_PAYLOAD:
822 type.subType.ipFilterType(DemuxIpFilterType::IP_PAYLOAD);
823 settings.ip().filterSettings.noinit();
824 break;
825 case FilterSubTypeEnum::PAYLOAD_THROUGH:
826 type.subType.ipFilterType(DemuxIpFilterType::PAYLOAD_THROUGH);
827 settings.ip().filterSettings.noinit();
828 break;
829 default:
830 ALOGW("[ConfigReader] mmtp subtype is not supported");
831 return false;
832 }
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700833 break;
834 }
835 default:
836 // TODO: b/182519645 support all the filter configs
837 ALOGW("[ConfigReader] filter main type is not supported in dynamic config");
838 return false;
839 }
840 return true;
841 }
842
Amy Zhang06fa69e2021-04-09 09:56:25 -0700843 static DemuxIpAddress readIpAddress(Filter filterConfig) {
844 DemuxIpAddress ipAddress;
845 if (!filterConfig.hasIpFilterConfig_optional()) {
846 return ipAddress;
847 }
848 auto ipFilterConfig = filterConfig.getFirstIpFilterConfig_optional();
849 if (ipFilterConfig->hasSrcPort()) {
850 ipAddress.srcPort = ipFilterConfig->getSrcPort();
851 }
852 if (ipFilterConfig->hasDestPort()) {
853 ipAddress.dstPort = ipFilterConfig->getDestPort();
854 }
855 if (ipFilterConfig->getFirstSrcIpAddress()->getIsIpV4()) {
856 memcpy(ipAddress.srcIpAddress.v4().data(),
857 ipFilterConfig->getFirstSrcIpAddress()->getIp().data(), 4);
858 } else {
859 memcpy(ipAddress.srcIpAddress.v6().data(),
860 ipFilterConfig->getFirstSrcIpAddress()->getIp().data(), 6);
861 }
862 if (ipFilterConfig->getFirstDestIpAddress()->getIsIpV4()) {
863 memcpy(ipAddress.dstIpAddress.v4().data(),
864 ipFilterConfig->getFirstDestIpAddress()->getIp().data(), 4);
865 } else {
866 memcpy(ipAddress.dstIpAddress.v6().data(),
867 ipFilterConfig->getFirstDestIpAddress()->getIp().data(), 6);
868 }
869 return ipAddress;
870 }
871
872 static bool readPassthroughSettings(Filter filterConfig) {
873 if (!filterConfig.hasIpFilterConfig_optional()) {
874 return false;
875 }
876 auto ipFilterConfig = filterConfig.getFirstIpFilterConfig_optional();
877 if (ipFilterConfig->hasDataPassthrough()) {
878 return ipFilterConfig->getDataPassthrough();
879 }
880 return false;
881 }
882
Amy Zhang2ea2fe22021-04-01 11:55:41 -0700883 static DemuxFilterSectionSettings readSectionFilterSettings(Filter filterConfig) {
884 DemuxFilterSectionSettings settings;
885 if (!filterConfig.hasSectionFilterSettings_optional()) {
886 return settings;
887 }
888 auto section = filterConfig.getFirstSectionFilterSettings_optional();
889 settings.isCheckCrc = section->getIsCheckCrc();
890 settings.isRepeat = section->getIsRepeat();
891 settings.isRaw = section->getIsRaw();
892 return settings;
893 }
894
895 static DemuxFilterAvSettings readAvFilterSettings(Filter filterConfig) {
896 DemuxFilterAvSettings settings;
897 if (!filterConfig.hasAvFilterSettings_optional()) {
898 return settings;
899 }
900 auto av = filterConfig.getFirstAvFilterSettings_optional();
901 settings.isPassthrough = av->getIsPassthrough();
902 return settings;
903 }
904
905 static DemuxFilterRecordSettings readRecordFilterSettings(Filter filterConfig) {
906 DemuxFilterRecordSettings settings;
907 if (!filterConfig.hasRecordFilterSettings_optional()) {
908 return settings;
909 }
910 auto record = filterConfig.getFirstRecordFilterSettings_optional();
911 settings.tsIndexMask = static_cast<uint32_t>(record->getTsIndexMask());
912 settings.scIndexType = static_cast<DemuxRecordScIndexType>(record->getScIndexType());
913 return settings;
914 }
915
Amy Zhange50f08d2021-03-30 15:56:02 -0700916 static PlaybackSettings readPlaybackSettings(Dvr dvrConfig) {
917 ALOGW("[ConfigReader] dvr type is playback");
918 PlaybackSettings playbackSettings{
919 .statusMask = static_cast<uint8_t>(dvrConfig.getStatusMask()),
920 .lowThreshold = static_cast<uint32_t>(dvrConfig.getLowThreshold()),
921 .highThreshold = static_cast<uint32_t>(dvrConfig.getHighThreshold()),
922 .dataFormat = static_cast<DataFormat>(dvrConfig.getDataFormat()),
923 .packetSize = static_cast<uint8_t>(dvrConfig.getPacketSize()),
924 };
925 return playbackSettings;
926 }
927
928 static RecordSettings readRecordSettings(Dvr dvrConfig) {
929 ALOGW("[ConfigReader] dvr type is record");
930 RecordSettings recordSettings{
931 .statusMask = static_cast<uint8_t>(dvrConfig.getStatusMask()),
932 .lowThreshold = static_cast<uint32_t>(dvrConfig.getLowThreshold()),
933 .highThreshold = static_cast<uint32_t>(dvrConfig.getHighThreshold()),
934 .dataFormat = static_cast<DataFormat>(dvrConfig.getDataFormat()),
935 .packetSize = static_cast<uint8_t>(dvrConfig.getPacketSize()),
936 };
937 return recordSettings;
938 }
939
Amy Zhang06fa69e2021-04-09 09:56:25 -0700940 static TunerConfiguration getTunerConfig() { return *read(mConfigFilePath.c_str()); }
Amy Zhange6915052021-03-30 13:44:43 -0700941
942 static DataFlowConfiguration getDataFlowConfiguration() {
943 return *getTunerConfig().getFirstDataFlowConfiguration();
944 }
945};