blob: caf631c68dac37054f27633f9bbbf6e10280cb3e [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#pragma once
18
19#include <android-base/logging.h>
20#include <android_media_tuner_testing_configuration_V1_0.h>
21#include <android_media_tuner_testing_configuration_V1_0_enums.h>
22
23#include <aidl/android/hardware/tv/tuner/DataFormat.h>
24#include <aidl/android/hardware/tv/tuner/DemuxAlpFilterType.h>
25#include <aidl/android/hardware/tv/tuner/DemuxFilterAvSettings.h>
26#include <aidl/android/hardware/tv/tuner/DemuxFilterEvent.h>
27#include <aidl/android/hardware/tv/tuner/DemuxFilterMainType.h>
28#include <aidl/android/hardware/tv/tuner/DemuxFilterRecordSettings.h>
29#include <aidl/android/hardware/tv/tuner/DemuxFilterSectionSettings.h>
30#include <aidl/android/hardware/tv/tuner/DemuxFilterSettings.h>
31#include <aidl/android/hardware/tv/tuner/DemuxFilterType.h>
32#include <aidl/android/hardware/tv/tuner/DemuxIpAddress.h>
33#include <aidl/android/hardware/tv/tuner/DemuxIpFilterSettings.h>
34#include <aidl/android/hardware/tv/tuner/DemuxIpFilterType.h>
35#include <aidl/android/hardware/tv/tuner/DemuxMmtpFilterType.h>
36#include <aidl/android/hardware/tv/tuner/DemuxRecordScIndexType.h>
37#include <aidl/android/hardware/tv/tuner/DemuxTlvFilterType.h>
38#include <aidl/android/hardware/tv/tuner/DemuxTsFilterType.h>
39#include <aidl/android/hardware/tv/tuner/DvrSettings.h>
40#include <aidl/android/hardware/tv/tuner/DvrType.h>
41#include <aidl/android/hardware/tv/tuner/FrontendDvbsSettings.h>
42#include <aidl/android/hardware/tv/tuner/FrontendDvbtBandwidth.h>
43#include <aidl/android/hardware/tv/tuner/FrontendDvbtCoderate.h>
44#include <aidl/android/hardware/tv/tuner/FrontendDvbtConstellation.h>
45#include <aidl/android/hardware/tv/tuner/FrontendDvbtGuardInterval.h>
46#include <aidl/android/hardware/tv/tuner/FrontendDvbtHierarchy.h>
47#include <aidl/android/hardware/tv/tuner/FrontendDvbtPlpMode.h>
48#include <aidl/android/hardware/tv/tuner/FrontendDvbtSettings.h>
49#include <aidl/android/hardware/tv/tuner/FrontendDvbtStandard.h>
50#include <aidl/android/hardware/tv/tuner/FrontendDvbtTransmissionMode.h>
51#include <aidl/android/hardware/tv/tuner/FrontendSettings.h>
52#include <aidl/android/hardware/tv/tuner/FrontendStatus.h>
53#include <aidl/android/hardware/tv/tuner/FrontendStatusType.h>
54#include <aidl/android/hardware/tv/tuner/FrontendType.h>
55#include <aidl/android/hardware/tv/tuner/LnbPosition.h>
56#include <aidl/android/hardware/tv/tuner/LnbTone.h>
57#include <aidl/android/hardware/tv/tuner/LnbVoltage.h>
58#include <aidl/android/hardware/tv/tuner/PlaybackSettings.h>
59#include <aidl/android/hardware/tv/tuner/RecordSettings.h>
60
61using namespace std;
62using namespace aidl::android::hardware::tv::tuner;
63using namespace android::media::tuner::testing::configuration::V1_0;
64
65const string emptyHardwareId = "";
66
67static string mConfigFilePath;
68
69#define PROVISION_STR \
70 "{ " \
71 " \"id\": 21140844, " \
72 " \"name\": \"Test Title\", " \
73 " \"lowercase_organization_name\": \"Android\", " \
74 " \"asset_key\": { " \
75 " \"encryption_key\": \"nezAr3CHFrmBR9R8Tedotw==\" " \
76 " }, " \
77 " \"cas_type\": 1, " \
78 " \"track_types\": [ ] " \
79 "} "
80
81struct FrontendConfig {
82 bool isSoftwareFe;
83 FrontendType type;
84 bool canConnectToCiCam;
85 int32_t ciCamId;
Hongguange106f472022-01-11 12:09:22 -080086 int32_t removePid;
Hongguang600a6ae2021-07-08 18:51:51 -070087 FrontendSettings settings;
88 vector<FrontendStatusType> tuneStatusTypes;
89 vector<FrontendStatus> expectTuneStatuses;
90};
91
92struct FilterConfig {
93 int32_t bufferSize;
94 DemuxFilterType type;
95 DemuxFilterSettings settings;
96 bool getMqDesc;
97 AvStreamType streamType;
98 int32_t ipCid;
99 int32_t monitorEventTypes;
Patrick Rohr1586d212021-11-23 00:40:56 +0100100 int timeDelayInMs = 0;
101 int dataDelayInBytes = 0;
Hongguang600a6ae2021-07-08 18:51:51 -0700102
103 bool operator<(const FilterConfig& /*c*/) const { return false; }
104};
105
106struct DvrConfig {
107 DvrType type;
108 int32_t bufferSize;
109 DvrSettings settings;
110 string playbackInputFile;
111};
112
113struct LnbConfig {
114 string name;
115 LnbVoltage voltage;
116 LnbTone tone;
117 LnbPosition position;
118};
119
120struct TimeFilterConfig {
121 int64_t timeStamp;
122};
123
124struct DescramblerConfig {
125 int32_t casSystemId;
126 string provisionStr;
127 vector<uint8_t> hidlPvtData;
128};
129
130struct LiveBroadcastHardwareConnections {
131 bool hasFrontendConnection;
132 string frontendId;
133 string dvrSoftwareFeId;
134 string audioFilterId;
135 string videoFilterId;
136 string sectionFilterId;
137 string ipFilterId;
138 string pcrFilterId;
139 /* list string of extra filters; */
140};
141
142struct ScanHardwareConnections {
143 bool hasFrontendConnection;
144 string frontendId;
145};
146
147struct DvrPlaybackHardwareConnections {
148 bool support;
149 string frontendId;
150 string dvrId;
151 string audioFilterId;
152 string videoFilterId;
153 string sectionFilterId;
154 /* list string of extra filters; */
155};
156
157struct DvrRecordHardwareConnections {
158 bool support;
159 bool hasFrontendConnection;
160 string frontendId;
161 string dvrRecordId;
162 string dvrSoftwareFeId;
163 string recordFilterId;
164 string dvrSourceId;
165};
166
167struct DescramblingHardwareConnections {
168 bool support;
169 bool hasFrontendConnection;
170 string frontendId;
171 string dvrSoftwareFeId;
172 string audioFilterId;
173 string videoFilterId;
174 string descramblerId;
175 string dvrSourceId;
176 /* list string of extra filters; */
177};
178
179struct LnbLiveHardwareConnections {
180 bool support;
181 string frontendId;
182 string audioFilterId;
183 string videoFilterId;
184 string lnbId;
185 vector<string> diseqcMsgs;
186 /* list string of extra filters; */
187};
188
189struct LnbRecordHardwareConnections {
190 bool support;
191 string frontendId;
192 string dvrRecordId;
193 string recordFilterId;
194 string lnbId;
195 vector<string> diseqcMsgs;
196 /* list string of extra filters; */
197};
198
199struct TimeFilterHardwareConnections {
200 bool support;
201 string timeFilterId;
202};
203
204struct TunerTestingConfigAidlReader1_0 {
205 public:
206 static void setConfigFilePath(string path) { mConfigFilePath = path; }
207
208 static bool checkConfigFileExists() {
209 auto res = read(mConfigFilePath.c_str());
210 if (res == nullopt) {
211 ALOGW("[ConfigReader] Couldn't read %s."
212 "Please check tuner_testing_dynamic_configuration.xsd"
213 "and sample_tuner_vts_config.xml for more details on how to config Tune VTS.",
214 mConfigFilePath.c_str());
215 }
216 return (res != nullopt);
217 }
218
219 static TunerConfiguration getTunerConfig() { return *read(mConfigFilePath.c_str()); }
220
221 static DataFlowConfiguration getDataFlowConfiguration() {
222 return *getTunerConfig().getFirstDataFlowConfiguration();
223 }
224
225 static HardwareConfiguration getHardwareConfig() {
226 return *getTunerConfig().getFirstHardwareConfiguration();
227 }
228
229 static void readFrontendConfig1_0(map<string, FrontendConfig>& frontendMap) {
230 auto hardwareConfig = getHardwareConfig();
231 if (hardwareConfig.hasFrontends()) {
232 // TODO: b/182519645 complete the tune status config
233 vector<FrontendStatusType> types;
234 vector<FrontendStatus> statuses;
235
236 types.push_back(FrontendStatusType::DEMOD_LOCK);
237 types.push_back(FrontendStatusType::UEC);
238 types.push_back(FrontendStatusType::IS_MISO);
239
240 FrontendStatus status;
241 status.set<FrontendStatus::Tag::isDemodLocked>(true);
242 statuses.push_back(status);
243 status.set<FrontendStatus::Tag::uec>(4);
244 statuses.push_back(status);
245 status.set<FrontendStatus::Tag::isMiso>(true);
246 statuses.push_back(status);
247
248 auto frontends = *hardwareConfig.getFirstFrontends();
249 for (auto feConfig : frontends.getFrontend()) {
250 string id = feConfig.getId();
251 if (id.compare(string("FE_DEFAULT")) == 0) {
252 // overrid default
253 frontendMap.erase(string("FE_DEFAULT"));
254 }
255 FrontendType type;
256 switch (feConfig.getType()) {
257 case FrontendTypeEnum::UNDEFINED:
258 type = FrontendType::UNDEFINED;
259 break;
260 // TODO: b/182519645 finish all other frontend settings
261 case FrontendTypeEnum::ANALOG:
262 type = FrontendType::ANALOG;
263 break;
264 case FrontendTypeEnum::ATSC:
265 type = FrontendType::ATSC;
Frankie Lizcano3ad735d2022-06-24 19:20:54 +0000266 frontendMap[id].settings.set<
267 FrontendSettings::Tag::atsc>(
268 readAtscFrontendSettings(feConfig));
Hongguang600a6ae2021-07-08 18:51:51 -0700269 break;
270 case FrontendTypeEnum::ATSC3:
271 type = FrontendType::ATSC3;
272 break;
273 case FrontendTypeEnum::DVBC:
274 type = FrontendType::DVBC;
275 break;
276 case FrontendTypeEnum::DVBS:
277 type = FrontendType::DVBS;
278 frontendMap[id].settings.set<FrontendSettings::Tag::dvbs>(
279 readDvbsFrontendSettings(feConfig));
280 break;
281 case FrontendTypeEnum::DVBT: {
282 type = FrontendType::DVBT;
283 frontendMap[id].settings.set<FrontendSettings::Tag::dvbt>(
284 readDvbtFrontendSettings(feConfig));
285 break;
286 }
287 case FrontendTypeEnum::ISDBS:
288 type = FrontendType::ISDBS;
289 break;
290 case FrontendTypeEnum::ISDBS3:
291 type = FrontendType::ISDBS3;
292 break;
293 case FrontendTypeEnum::ISDBT:
294 type = FrontendType::ISDBT;
295 break;
296 case FrontendTypeEnum::DTMB:
297 type = FrontendType::DTMB;
298 break;
299 case FrontendTypeEnum::UNKNOWN:
300 ALOGW("[ConfigReader] invalid frontend type");
301 return;
302 default:
303 ALOGW("[ConfigReader] fe already handled in 1_0 reader.");
304 break;
305 }
306 frontendMap[id].type = type;
307 frontendMap[id].isSoftwareFe = feConfig.getIsSoftwareFrontend();
308 // TODO: b/182519645 complete the tune status config
309 frontendMap[id].tuneStatusTypes = types;
310 frontendMap[id].expectTuneStatuses = statuses;
Hongguange106f472022-01-11 12:09:22 -0800311 getCiCamInfo(feConfig, frontendMap[id].canConnectToCiCam, frontendMap[id].ciCamId,
312 frontendMap[id].removePid);
Hongguang600a6ae2021-07-08 18:51:51 -0700313 }
314 }
315 }
316
317 static void readFilterConfig1_0(map<string, FilterConfig>& filterMap) {
318 auto hardwareConfig = getHardwareConfig();
319 if (hardwareConfig.hasFilters()) {
320 auto filters = *hardwareConfig.getFirstFilters();
321 for (auto filterConfig : filters.getFilter()) {
322 string id = filterConfig.getId();
323 if (id.compare(string("FILTER_AUDIO_DEFAULT")) == 0) {
324 // overrid default
325 filterMap.erase(string("FILTER_AUDIO_DEFAULT"));
326 }
327 if (id.compare(string("FILTER_VIDEO_DEFAULT")) == 0) {
328 // overrid default
329 filterMap.erase(string("FILTER_VIDEO_DEFAULT"));
330 }
331
332 DemuxFilterType type;
333 DemuxFilterSettings settings;
334 if (!readFilterTypeAndSettings(filterConfig, type, settings)) {
335 ALOGW("[ConfigReader] invalid filter type");
336 return;
337 }
338 filterMap[id].type = type;
339 filterMap[id].bufferSize = filterConfig.getBufferSize();
340 filterMap[id].getMqDesc = filterConfig.getUseFMQ();
341 filterMap[id].settings = settings;
342
343 if (filterConfig.hasMonitorEventTypes()) {
Hongguang11da2cb2021-08-05 19:05:12 -0700344 filterMap[id].monitorEventTypes = (int32_t)filterConfig.getMonitorEventTypes();
Hongguang600a6ae2021-07-08 18:51:51 -0700345 }
Patrick Rohr1586d212021-11-23 00:40:56 +0100346 if (filterConfig.hasTimeDelayInMs()) {
347 filterMap[id].timeDelayInMs = filterConfig.getTimeDelayInMs();
348 }
349 if (filterConfig.hasDataDelayInBytes()) {
350 filterMap[id].dataDelayInBytes = filterConfig.getDataDelayInBytes();
351 }
Hongguang600a6ae2021-07-08 18:51:51 -0700352 if (filterConfig.hasAvFilterSettings_optional()) {
353 auto av = filterConfig.getFirstAvFilterSettings_optional();
354 if (av->hasAudioStreamType_optional()) {
355 filterMap[id].streamType.set<AvStreamType::Tag::audio>(
356 static_cast<AudioStreamType>(av->getAudioStreamType_optional()));
357 }
358 if (av->hasVideoStreamType_optional()) {
359 filterMap[id].streamType.set<AvStreamType::Tag::video>(
360 static_cast<VideoStreamType>(av->getVideoStreamType_optional()));
361 }
362 }
363 if (filterConfig.hasIpFilterConfig_optional()) {
364 auto ip = filterConfig.getFirstIpFilterConfig_optional();
365 if (ip->hasIpCid()) {
366 filterMap[id].ipCid = ip->getIpCid();
367 }
368 }
369 }
370 }
371 }
372
373 static void readDvrConfig1_0(map<string, DvrConfig>& dvrMap) {
374 auto hardwareConfig = getHardwareConfig();
375 if (hardwareConfig.hasDvrs()) {
376 auto dvrs = *hardwareConfig.getFirstDvrs();
377 for (auto dvrConfig : dvrs.getDvr()) {
378 string id = dvrConfig.getId();
379 DvrType type;
380 switch (dvrConfig.getType()) {
381 case DvrTypeEnum::PLAYBACK:
382 type = DvrType::PLAYBACK;
383 dvrMap[id].settings.set<DvrSettings::Tag::playback>(
384 readPlaybackSettings(dvrConfig));
385 break;
386 case DvrTypeEnum::RECORD:
387 type = DvrType::RECORD;
388 dvrMap[id].settings.set<DvrSettings::Tag::record>(
389 readRecordSettings(dvrConfig));
390 break;
391 case DvrTypeEnum::UNKNOWN:
392 ALOGW("[ConfigReader] invalid DVR type");
393 return;
394 }
395 dvrMap[id].type = type;
Hongguang11da2cb2021-08-05 19:05:12 -0700396 dvrMap[id].bufferSize = static_cast<int32_t>(dvrConfig.getBufferSize());
Hongguang600a6ae2021-07-08 18:51:51 -0700397 if (dvrConfig.hasInputFilePath()) {
398 dvrMap[id].playbackInputFile = dvrConfig.getInputFilePath();
399 }
400 }
401 }
402 }
403
404 static void readLnbConfig1_0(map<string, LnbConfig>& lnbMap) {
405 auto hardwareConfig = getHardwareConfig();
406 if (hardwareConfig.hasLnbs()) {
407 auto lnbs = *hardwareConfig.getFirstLnbs();
408 for (auto lnbConfig : lnbs.getLnb()) {
409 string id = lnbConfig.getId();
410 if (lnbConfig.hasName()) {
411 lnbMap[id].name = lnbConfig.getName();
412 } else {
413 lnbMap[id].name = emptyHardwareId;
414 }
415 lnbMap[id].voltage = static_cast<LnbVoltage>(lnbConfig.getVoltage());
416 lnbMap[id].tone = static_cast<LnbTone>(lnbConfig.getTone());
417 lnbMap[id].position = static_cast<LnbPosition>(lnbConfig.getPosition());
418 }
419 }
420 }
421
422 static void readDescramblerConfig1_0(map<string, DescramblerConfig>& descramblerMap) {
423 auto hardwareConfig = getHardwareConfig();
424 if (hardwareConfig.hasDescramblers()) {
425 auto descramblers = *hardwareConfig.getFirstDescramblers();
426 for (auto descramblerConfig : descramblers.getDescrambler()) {
427 string id = descramblerConfig.getId();
428 descramblerMap[id].casSystemId =
Hongguang11da2cb2021-08-05 19:05:12 -0700429 static_cast<int32_t>(descramblerConfig.getCasSystemId());
Hongguang600a6ae2021-07-08 18:51:51 -0700430 if (descramblerConfig.hasProvisionStr()) {
431 descramblerMap[id].provisionStr = descramblerConfig.getProvisionStr();
432 } else {
433 descramblerMap[id].provisionStr = PROVISION_STR;
434 }
435 if (descramblerConfig.hasSesstionPrivatData()) {
436 auto privateData = descramblerConfig.getSesstionPrivatData();
437 int size = privateData.size();
438 descramblerMap[id].hidlPvtData.resize(size);
439 memcpy(descramblerMap[id].hidlPvtData.data(), privateData.data(), size);
440 } else {
441 descramblerMap[id].hidlPvtData.resize(256);
442 }
443 }
444 }
445 }
446
447 static void readDiseqcMessages(map<string, vector<uint8_t>>& diseqcMsgMap) {
448 auto hardwareConfig = getHardwareConfig();
449 if (hardwareConfig.hasDiseqcMessages()) {
450 auto msgs = *hardwareConfig.getFirstDiseqcMessages();
451 for (auto msgConfig : msgs.getDiseqcMessage()) {
452 string name = msgConfig.getMsgName();
453 for (uint8_t atom : msgConfig.getMsgBody()) {
454 diseqcMsgMap[name].push_back(atom);
455 }
456 }
457 }
458 }
459
460 static void readTimeFilterConfig1_0(map<string, TimeFilterConfig>& timeFilterMap) {
461 auto hardwareConfig = getHardwareConfig();
462 if (hardwareConfig.hasTimeFilters()) {
463 auto timeFilters = *hardwareConfig.getFirstTimeFilters();
464 for (auto timeFilterConfig : timeFilters.getTimeFilter()) {
465 string id = timeFilterConfig.getId();
Hongguang11da2cb2021-08-05 19:05:12 -0700466 timeFilterMap[id].timeStamp = static_cast<int64_t>(timeFilterConfig.getTimeStamp());
Hongguang600a6ae2021-07-08 18:51:51 -0700467 }
468 }
469 }
470
471 static void connectLiveBroadcast(LiveBroadcastHardwareConnections& live) {
472 auto dataFlow = getDataFlowConfiguration();
473 if (dataFlow.hasClearLiveBroadcast()) {
474 live.hasFrontendConnection = true;
475 } else {
476 live.hasFrontendConnection = false;
477 return;
478 }
479 auto liveConfig = *dataFlow.getFirstClearLiveBroadcast();
480 live.frontendId = liveConfig.getFrontendConnection();
481
482 live.audioFilterId = liveConfig.getAudioFilterConnection();
483 live.videoFilterId = liveConfig.getVideoFilterConnection();
484 if (liveConfig.hasPcrFilterConnection()) {
485 live.pcrFilterId = liveConfig.getPcrFilterConnection();
486 } else {
487 live.pcrFilterId = emptyHardwareId;
488 }
489 if (liveConfig.hasSectionFilterConnection()) {
490 live.sectionFilterId = liveConfig.getSectionFilterConnection();
491 } else {
492 live.sectionFilterId = emptyHardwareId;
493 }
494 if (liveConfig.hasDvrSoftwareFeConnection()) {
495 live.dvrSoftwareFeId = liveConfig.getDvrSoftwareFeConnection();
496 }
497 if (liveConfig.hasIpFilterConnection()) {
498 live.ipFilterId = liveConfig.getIpFilterConnection();
499 } else {
500 live.ipFilterId = emptyHardwareId;
501 }
502 }
503
504 static void connectScan(ScanHardwareConnections& scan) {
505 auto dataFlow = getDataFlowConfiguration();
506 if (dataFlow.hasScan()) {
507 scan.hasFrontendConnection = true;
508 } else {
509 scan.hasFrontendConnection = false;
510 return;
511 }
512 auto scanConfig = *dataFlow.getFirstScan();
513 scan.frontendId = scanConfig.getFrontendConnection();
514 }
515
516 static void connectDvrPlayback(DvrPlaybackHardwareConnections& playback) {
517 auto dataFlow = getDataFlowConfiguration();
518 if (dataFlow.hasDvrPlayback()) {
519 playback.support = true;
520 } else {
521 playback.support = false;
522 return;
523 }
524 auto playbackConfig = *dataFlow.getFirstDvrPlayback();
525 playback.dvrId = playbackConfig.getDvrConnection();
526 playback.audioFilterId = playbackConfig.getAudioFilterConnection();
527 playback.videoFilterId = playbackConfig.getVideoFilterConnection();
528 if (playbackConfig.hasSectionFilterConnection()) {
529 playback.sectionFilterId = playbackConfig.getSectionFilterConnection();
530 } else {
531 playback.sectionFilterId = emptyHardwareId;
532 }
533 }
534
535 static void connectDvrRecord(DvrRecordHardwareConnections& record) {
536 auto dataFlow = getDataFlowConfiguration();
537 if (dataFlow.hasDvrRecord()) {
538 record.support = true;
539 } else {
540 record.support = false;
541 return;
542 }
543 auto recordConfig = *dataFlow.getFirstDvrRecord();
544 record.recordFilterId = recordConfig.getRecordFilterConnection();
545 record.dvrRecordId = recordConfig.getDvrRecordConnection();
546 if (recordConfig.hasDvrSoftwareFeConnection()) {
547 record.dvrSoftwareFeId = recordConfig.getDvrSoftwareFeConnection();
548 }
549 if (recordConfig.getHasFrontendConnection()) {
550 record.hasFrontendConnection = true;
551 record.dvrSourceId = emptyHardwareId;
552 record.frontendId = recordConfig.getFrontendConnection();
553 } else {
554 record.hasFrontendConnection = false;
555 record.dvrSourceId = recordConfig.getDvrSourceConnection();
556 }
557 }
558
559 static void connectDescrambling(DescramblingHardwareConnections& descrambling) {
560 auto dataFlow = getDataFlowConfiguration();
561 if (dataFlow.hasDescrambling()) {
562 descrambling.support = true;
563 } else {
564 descrambling.support = false;
565 return;
566 }
567 auto descConfig = *dataFlow.getFirstDescrambling();
568 descrambling.descramblerId = descConfig.getDescramblerConnection();
569 descrambling.audioFilterId = descConfig.getAudioFilterConnection();
570 descrambling.videoFilterId = descConfig.getVideoFilterConnection();
571 if (descConfig.hasDvrSoftwareFeConnection()) {
572 descrambling.dvrSoftwareFeId = descConfig.getDvrSoftwareFeConnection();
573 }
574 if (descConfig.getHasFrontendConnection()) {
575 descrambling.hasFrontendConnection = true;
576 descrambling.dvrSourceId = emptyHardwareId;
577 descrambling.frontendId = descConfig.getFrontendConnection();
578 } else {
579 descrambling.hasFrontendConnection = false;
580 descrambling.dvrSourceId = descConfig.getDvrSourceConnection();
581 }
582 }
583
584 static void connectLnbLive(LnbLiveHardwareConnections& lnbLive) {
585 auto dataFlow = getDataFlowConfiguration();
586 if (dataFlow.hasLnbLive()) {
587 lnbLive.support = true;
588 } else {
589 lnbLive.support = false;
590 return;
591 }
592 auto lnbLiveConfig = *dataFlow.getFirstLnbLive();
593 lnbLive.frontendId = lnbLiveConfig.getFrontendConnection();
594 lnbLive.audioFilterId = lnbLiveConfig.getAudioFilterConnection();
595 lnbLive.videoFilterId = lnbLiveConfig.getVideoFilterConnection();
596 lnbLive.lnbId = lnbLiveConfig.getLnbConnection();
597 if (lnbLiveConfig.hasDiseqcMsgSender()) {
598 for (auto msgName : lnbLiveConfig.getDiseqcMsgSender()) {
599 lnbLive.diseqcMsgs.push_back(msgName);
600 }
601 }
602 }
603
604 static void connectLnbRecord(LnbRecordHardwareConnections& lnbRecord) {
605 auto dataFlow = getDataFlowConfiguration();
606 if (dataFlow.hasLnbRecord()) {
607 lnbRecord.support = true;
608 } else {
609 lnbRecord.support = false;
610 return;
611 }
612 auto lnbRecordConfig = *dataFlow.getFirstLnbRecord();
613 lnbRecord.frontendId = lnbRecordConfig.getFrontendConnection();
614 lnbRecord.recordFilterId = lnbRecordConfig.getRecordFilterConnection();
615 lnbRecord.dvrRecordId = lnbRecordConfig.getDvrRecordConnection();
616 lnbRecord.lnbId = lnbRecordConfig.getLnbConnection();
617 if (lnbRecordConfig.hasDiseqcMsgSender()) {
618 for (auto msgName : lnbRecordConfig.getDiseqcMsgSender()) {
619 lnbRecord.diseqcMsgs.push_back(msgName);
620 }
621 }
622 }
623
624 static void connectTimeFilter(TimeFilterHardwareConnections& timeFilter) {
625 auto dataFlow = getDataFlowConfiguration();
626 if (dataFlow.hasTimeFilter()) {
627 timeFilter.support = true;
628 } else {
629 timeFilter.support = false;
630 return;
631 }
632 auto timeFilterConfig = *dataFlow.getFirstTimeFilter();
633 timeFilter.timeFilterId = timeFilterConfig.getTimeFilterConnection();
634 }
635
636 private:
637 static FrontendDvbtSettings readDvbtFrontendSettings(Frontend feConfig) {
638 ALOGW("[ConfigReader] fe type is dvbt");
639 FrontendDvbtSettings dvbtSettings{
Hongguang11da2cb2021-08-05 19:05:12 -0700640 .frequency = (int64_t)feConfig.getFrequency(),
Hongguang600a6ae2021-07-08 18:51:51 -0700641 };
Hongguang11da2cb2021-08-05 19:05:12 -0700642 if (feConfig.hasEndFrequency()) {
643 dvbtSettings.endFrequency = (int64_t)feConfig.getEndFrequency();
644 }
Hongguang600a6ae2021-07-08 18:51:51 -0700645 if (!feConfig.hasDvbtFrontendSettings_optional()) {
646 ALOGW("[ConfigReader] no more dvbt settings");
647 return dvbtSettings;
648 }
649 auto dvbt = feConfig.getFirstDvbtFrontendSettings_optional();
Hongguang11da2cb2021-08-05 19:05:12 -0700650 int32_t trans = static_cast<int32_t>(dvbt->getTransmissionMode());
Hongguang600a6ae2021-07-08 18:51:51 -0700651 dvbtSettings.transmissionMode = static_cast<FrontendDvbtTransmissionMode>(trans);
652 dvbtSettings.bandwidth = static_cast<FrontendDvbtBandwidth>(dvbt->getBandwidth());
653 dvbtSettings.isHighPriority = dvbt->getIsHighPriority();
654 dvbtSettings.hierarchy = static_cast<FrontendDvbtHierarchy>(dvbt->getHierarchy());
655 dvbtSettings.hpCoderate = static_cast<FrontendDvbtCoderate>(dvbt->getHpCoderate());
656 dvbtSettings.lpCoderate = static_cast<FrontendDvbtCoderate>(dvbt->getLpCoderate());
657 dvbtSettings.guardInterval =
658 static_cast<FrontendDvbtGuardInterval>(dvbt->getGuardInterval());
659 dvbtSettings.standard = static_cast<FrontendDvbtStandard>(dvbt->getStandard());
660 dvbtSettings.isMiso = dvbt->getIsMiso();
661 dvbtSettings.plpMode = static_cast<FrontendDvbtPlpMode>(dvbt->getPlpMode());
662 dvbtSettings.plpId = dvbt->getPlpId();
663 dvbtSettings.plpGroupId = dvbt->getPlpGroupId();
664 if (dvbt->hasConstellation()) {
665 dvbtSettings.constellation =
666 static_cast<FrontendDvbtConstellation>(dvbt->getConstellation());
667 }
668 return dvbtSettings;
669 }
670
671 static FrontendDvbsSettings readDvbsFrontendSettings(Frontend feConfig) {
672 ALOGW("[ConfigReader] fe type is dvbs");
673 FrontendDvbsSettings dvbsSettings{
Hongguang11da2cb2021-08-05 19:05:12 -0700674 .frequency = (int64_t)feConfig.getFrequency(),
Hongguang600a6ae2021-07-08 18:51:51 -0700675 };
Hongguang11da2cb2021-08-05 19:05:12 -0700676 if (feConfig.hasEndFrequency()) {
677 dvbsSettings.endFrequency = (int64_t)feConfig.getEndFrequency();
678 }
Hongguang600a6ae2021-07-08 18:51:51 -0700679 if (!feConfig.hasDvbsFrontendSettings_optional()) {
680 ALOGW("[ConfigReader] no more dvbs settings");
681 return dvbsSettings;
682 }
Hongguang11da2cb2021-08-05 19:05:12 -0700683 dvbsSettings.symbolRate = static_cast<int32_t>(
Hongguang600a6ae2021-07-08 18:51:51 -0700684 feConfig.getFirstDvbsFrontendSettings_optional()->getSymbolRate());
Hongguang11da2cb2021-08-05 19:05:12 -0700685 dvbsSettings.inputStreamId = static_cast<int32_t>(
Hongguang600a6ae2021-07-08 18:51:51 -0700686 feConfig.getFirstDvbsFrontendSettings_optional()->getInputStreamId());
687 auto dvbs = feConfig.getFirstDvbsFrontendSettings_optional();
688 if (dvbs->hasScanType()) {
689 dvbsSettings.scanType = static_cast<FrontendDvbsScanType>(dvbs->getScanType());
690 }
691 if (dvbs->hasIsDiseqcRxMessage()) {
692 dvbsSettings.isDiseqcRxMessage = dvbs->getIsDiseqcRxMessage();
693 }
694 return dvbsSettings;
695 }
696
Frankie Lizcano3ad735d2022-06-24 19:20:54 +0000697 static FrontendAtscSettings readAtscFrontendSettings(Frontend& feConfig) {
698 ALOGW("[ConfigReader] fe type is atsc");
699 FrontendAtscSettings atscSettings{
700 .frequency = (int64_t)feConfig.getFrequency(),
701 };
702 if (feConfig.hasEndFrequency()) {
703 atscSettings.endFrequency = (int64_t)feConfig.getEndFrequency();
704 }
705 if (!feConfig.hasAtscFrontendSettings_optional()) {
706 ALOGW("[ConfigReader] no more atsc settings");
707 return atscSettings;
708 }
709 auto atsc = feConfig.getFirstAtscFrontendSettings_optional();
710 atscSettings.inversion = static_cast<FrontendSpectralInversion>(
711 atsc->getInversion());
712 atscSettings.modulation = static_cast<FrontendAtscModulation>(
713 atsc->getModulation());
714 return atscSettings;
715 }
716
Hongguang600a6ae2021-07-08 18:51:51 -0700717 static bool readFilterTypeAndSettings(Filter filterConfig, DemuxFilterType& type,
718 DemuxFilterSettings& settings) {
719 auto mainType = filterConfig.getMainType();
720 auto subType = filterConfig.getSubType();
721
722 switch (mainType) {
723 case FilterMainTypeEnum::TS: {
724 ALOGW("[ConfigReader] filter main type is ts");
725 type.mainType = DemuxFilterMainType::TS;
726 DemuxTsFilterSettings ts;
727 bool isTsSet = false;
728 switch (subType) {
729 case FilterSubTypeEnum::UNDEFINED:
Hongguangce1e30d2021-08-02 21:55:44 -0700730 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700731 DemuxTsFilterType::UNDEFINED);
732 break;
733 case FilterSubTypeEnum::SECTION:
Hongguangce1e30d2021-08-02 21:55:44 -0700734 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700735 DemuxTsFilterType::SECTION);
736 ts.filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::section>(
737 readSectionFilterSettings(filterConfig));
738 isTsSet = true;
739 break;
740 case FilterSubTypeEnum::PES:
741 // TODO: b/182519645 support all the filter settings
Hongguangce1e30d2021-08-02 21:55:44 -0700742 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700743 DemuxTsFilterType::PES);
744 break;
745 case FilterSubTypeEnum::TS:
Hongguangce1e30d2021-08-02 21:55:44 -0700746 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700747 DemuxTsFilterType::TS);
748 ts.filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::noinit>(
749 true);
750 isTsSet = true;
751 break;
752 case FilterSubTypeEnum::PCR:
Hongguangce1e30d2021-08-02 21:55:44 -0700753 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700754 DemuxTsFilterType::PCR);
755 ts.filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::noinit>(
756 true);
757 isTsSet = true;
758 break;
759 case FilterSubTypeEnum::TEMI:
Hongguangce1e30d2021-08-02 21:55:44 -0700760 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700761 DemuxTsFilterType::TEMI);
762 ts.filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::noinit>(
763 true);
764 isTsSet = true;
765 break;
766 case FilterSubTypeEnum::AUDIO:
Hongguangce1e30d2021-08-02 21:55:44 -0700767 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700768 DemuxTsFilterType::AUDIO);
769 ts.filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(
770 readAvFilterSettings(filterConfig));
771 isTsSet = true;
772 break;
773 case FilterSubTypeEnum::VIDEO:
Hongguangce1e30d2021-08-02 21:55:44 -0700774 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700775 DemuxTsFilterType::VIDEO);
776 ts.filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(
777 readAvFilterSettings(filterConfig));
778 isTsSet = true;
779 break;
780 case FilterSubTypeEnum::RECORD:
Hongguangce1e30d2021-08-02 21:55:44 -0700781 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700782 DemuxTsFilterType::RECORD);
783 ts.filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::record>(
784 readRecordFilterSettings(filterConfig));
785 isTsSet = true;
786 break;
787 default:
788 ALOGW("[ConfigReader] ts subtype is not supported");
789 return false;
790 }
791 if (filterConfig.hasPid()) {
792 ts.tpid = static_cast<int32_t>(filterConfig.getPid());
793 isTsSet = true;
794 }
795 if (isTsSet) {
796 settings.set<DemuxFilterSettings::Tag::ts>(ts);
797 }
798 break;
799 }
800 case FilterMainTypeEnum::MMTP: {
801 ALOGW("[ConfigReader] filter main type is mmtp");
802 type.mainType = DemuxFilterMainType::MMTP;
803 DemuxMmtpFilterSettings mmtp;
804 bool isMmtpSet = false;
805 switch (subType) {
806 case FilterSubTypeEnum::UNDEFINED:
Hongguangce1e30d2021-08-02 21:55:44 -0700807 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700808 DemuxMmtpFilterType::UNDEFINED);
809 break;
810 case FilterSubTypeEnum::SECTION:
Hongguangce1e30d2021-08-02 21:55:44 -0700811 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700812 DemuxMmtpFilterType::SECTION);
813 mmtp.filterSettings
814 .set<DemuxMmtpFilterSettingsFilterSettings::Tag::section>(
815 readSectionFilterSettings(filterConfig));
816 isMmtpSet = true;
817 break;
818 case FilterSubTypeEnum::PES:
Hongguangce1e30d2021-08-02 21:55:44 -0700819 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700820 DemuxMmtpFilterType::PES);
821 // TODO: b/182519645 support all the filter settings
822 break;
823 case FilterSubTypeEnum::MMTP:
Hongguangce1e30d2021-08-02 21:55:44 -0700824 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700825 DemuxMmtpFilterType::MMTP);
826 mmtp.filterSettings.set<DemuxMmtpFilterSettingsFilterSettings::Tag::noinit>(
827 true);
828 isMmtpSet = true;
829 break;
830 case FilterSubTypeEnum::AUDIO:
Hongguangce1e30d2021-08-02 21:55:44 -0700831 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700832 DemuxMmtpFilterType::AUDIO);
833 mmtp.filterSettings.set<DemuxMmtpFilterSettingsFilterSettings::Tag::av>(
834 readAvFilterSettings(filterConfig));
835 isMmtpSet = true;
836 break;
837 case FilterSubTypeEnum::VIDEO:
Hongguangce1e30d2021-08-02 21:55:44 -0700838 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700839 DemuxMmtpFilterType::VIDEO);
840 mmtp.filterSettings.set<DemuxMmtpFilterSettingsFilterSettings::Tag::av>(
841 readAvFilterSettings(filterConfig));
842 isMmtpSet = true;
843 break;
844 case FilterSubTypeEnum::RECORD:
Hongguangce1e30d2021-08-02 21:55:44 -0700845 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700846 DemuxMmtpFilterType::RECORD);
847 mmtp.filterSettings.set<DemuxMmtpFilterSettingsFilterSettings::Tag::record>(
848 readRecordFilterSettings(filterConfig));
849 isMmtpSet = true;
850 break;
851 case FilterSubTypeEnum::DOWNLOAD:
Hongguangce1e30d2021-08-02 21:55:44 -0700852 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700853 DemuxMmtpFilterType::DOWNLOAD);
854 // TODO: b/182519645 support all the filter settings
855 break;
856 default:
857 ALOGW("[ConfigReader] mmtp subtype is not supported");
858 return false;
859 }
860 if (filterConfig.hasPid()) {
861 mmtp.mmtpPid = static_cast<int32_t>(filterConfig.getPid());
862 isMmtpSet = true;
863 }
864 if (isMmtpSet) {
865 settings.set<DemuxFilterSettings::Tag::mmtp>(mmtp);
866 }
867 break;
868 }
869 case FilterMainTypeEnum::IP: {
870 ALOGW("[ConfigReader] filter main type is ip");
871 type.mainType = DemuxFilterMainType::IP;
872 DemuxIpFilterSettings ip;
873 switch (subType) {
874 case FilterSubTypeEnum::UNDEFINED:
Hongguangce1e30d2021-08-02 21:55:44 -0700875 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700876 DemuxIpFilterType::UNDEFINED);
877 break;
878 case FilterSubTypeEnum::SECTION:
Hongguangce1e30d2021-08-02 21:55:44 -0700879 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700880 DemuxIpFilterType::SECTION);
881 ip.filterSettings.set<DemuxIpFilterSettingsFilterSettings::Tag::section>(
882 readSectionFilterSettings(filterConfig));
883 settings.set<DemuxFilterSettings::Tag::ip>(ip);
884 break;
885 case FilterSubTypeEnum::NTP:
Hongguangce1e30d2021-08-02 21:55:44 -0700886 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700887 DemuxIpFilterType::NTP);
888 ip.filterSettings.set<DemuxIpFilterSettingsFilterSettings::Tag::noinit>(
889 true);
890 settings.set<DemuxFilterSettings::Tag::ip>(ip);
891 break;
892 case FilterSubTypeEnum::IP: {
Gareth Fenn9a808452022-03-31 08:40:00 +0100893 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
894 DemuxIpFilterType::IP);
Hongguang600a6ae2021-07-08 18:51:51 -0700895 ip.ipAddr = readIpAddress(filterConfig),
896 ip.filterSettings
897 .set<DemuxIpFilterSettingsFilterSettings::Tag::bPassthrough>(
898 readPassthroughSettings(filterConfig));
899 settings.set<DemuxFilterSettings::Tag::ip>(ip);
900 break;
901 }
902 case FilterSubTypeEnum::IP_PAYLOAD:
Hongguangce1e30d2021-08-02 21:55:44 -0700903 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700904 DemuxIpFilterType::IP_PAYLOAD);
905 ip.filterSettings.set<DemuxIpFilterSettingsFilterSettings::Tag::noinit>(
906 true);
907 settings.set<DemuxFilterSettings::Tag::ip>(ip);
908 break;
909 case FilterSubTypeEnum::PAYLOAD_THROUGH:
Hongguangce1e30d2021-08-02 21:55:44 -0700910 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700911 DemuxIpFilterType::PAYLOAD_THROUGH);
912 ip.filterSettings.set<DemuxIpFilterSettingsFilterSettings::Tag::noinit>(
913 true);
914 settings.set<DemuxFilterSettings::Tag::ip>(ip);
915 break;
916 default:
917 ALOGW("[ConfigReader] mmtp subtype is not supported");
918 return false;
919 }
920 break;
921 }
922 default:
923 // TODO: b/182519645 support all the filter configs
924 ALOGW("[ConfigReader] filter main type is not supported in dynamic config");
925 return false;
926 }
927 return true;
928 }
929
930 static DemuxIpAddress readIpAddress(Filter filterConfig) {
931 DemuxIpAddress ipAddress;
932 vector<uint8_t> data;
933 if (!filterConfig.hasIpFilterConfig_optional()) {
934 return ipAddress;
935 }
936 auto ipFilterConfig = filterConfig.getFirstIpFilterConfig_optional();
937 if (ipFilterConfig->hasSrcPort()) {
938 ipAddress.srcPort = ipFilterConfig->getSrcPort();
939 }
940 if (ipFilterConfig->hasDestPort()) {
941 ipAddress.dstPort = ipFilterConfig->getDestPort();
942 }
943 if (ipFilterConfig->getFirstSrcIpAddress()->getIsIpV4()) {
944 data.resize(4);
945 memcpy(data.data(), ipFilterConfig->getFirstSrcIpAddress()->getIp().data(), 4);
946 ipAddress.srcIpAddress.set<DemuxIpAddressIpAddress::Tag::v4>(data);
947 } else {
948 data.resize(6);
949 memcpy(data.data(), ipFilterConfig->getFirstSrcIpAddress()->getIp().data(), 6);
950 ipAddress.srcIpAddress.set<DemuxIpAddressIpAddress::Tag::v6>(data);
951 }
952 if (ipFilterConfig->getFirstDestIpAddress()->getIsIpV4()) {
953 data.resize(4);
954 memcpy(data.data(), ipFilterConfig->getFirstDestIpAddress()->getIp().data(), 4);
955 ipAddress.dstIpAddress.set<DemuxIpAddressIpAddress::Tag::v4>(data);
956 } else {
957 data.resize(6);
958 memcpy(data.data(), ipFilterConfig->getFirstDestIpAddress()->getIp().data(), 6);
959 ipAddress.dstIpAddress.set<DemuxIpAddressIpAddress::Tag::v6>(data);
960 }
961 return ipAddress;
962 }
963
964 static bool readPassthroughSettings(Filter filterConfig) {
965 if (!filterConfig.hasIpFilterConfig_optional()) {
966 return false;
967 }
968 auto ipFilterConfig = filterConfig.getFirstIpFilterConfig_optional();
969 if (ipFilterConfig->hasDataPassthrough()) {
970 return ipFilterConfig->getDataPassthrough();
971 }
972 return false;
973 }
974
975 static DemuxFilterSectionSettings readSectionFilterSettings(Filter filterConfig) {
976 DemuxFilterSectionSettings settings;
977 if (!filterConfig.hasSectionFilterSettings_optional()) {
978 return settings;
979 }
980 auto section = filterConfig.getFirstSectionFilterSettings_optional();
981 settings.isCheckCrc = section->getIsCheckCrc();
982 settings.isRepeat = section->getIsRepeat();
983 settings.isRaw = section->getIsRaw();
Hongguang494ba662022-01-05 22:08:10 -0800984 settings.bitWidthOfLengthField = section->getBitWidthOfLengthField();
Hongguang600a6ae2021-07-08 18:51:51 -0700985 return settings;
986 }
987
988 static DemuxFilterAvSettings readAvFilterSettings(Filter filterConfig) {
989 DemuxFilterAvSettings settings;
990 if (!filterConfig.hasAvFilterSettings_optional()) {
991 return settings;
992 }
993 auto av = filterConfig.getFirstAvFilterSettings_optional();
994 settings.isPassthrough = av->getIsPassthrough();
Hongguang16dacc12021-11-01 15:51:52 -0700995 settings.isSecureMemory = av->getIsSecureMemory();
Hongguang600a6ae2021-07-08 18:51:51 -0700996 return settings;
997 }
998
999 static DemuxFilterRecordSettings readRecordFilterSettings(Filter filterConfig) {
1000 DemuxFilterRecordSettings settings;
1001 if (!filterConfig.hasRecordFilterSettings_optional()) {
1002 return settings;
1003 }
1004 auto record = filterConfig.getFirstRecordFilterSettings_optional();
1005 settings.tsIndexMask = record->getTsIndexMask();
1006 settings.scIndexType = static_cast<DemuxRecordScIndexType>(record->getScIndexType());
1007 return settings;
1008 }
1009
1010 static PlaybackSettings readPlaybackSettings(Dvr dvrConfig) {
1011 ALOGW("[ConfigReader] dvr type is playback");
1012 PlaybackSettings playbackSettings{
Hongguang11da2cb2021-08-05 19:05:12 -07001013 .statusMask = static_cast<int8_t>(dvrConfig.getStatusMask()),
1014 .lowThreshold = static_cast<int64_t>(dvrConfig.getLowThreshold()),
1015 .highThreshold = static_cast<int64_t>(dvrConfig.getHighThreshold()),
Hongguang600a6ae2021-07-08 18:51:51 -07001016 .dataFormat = static_cast<DataFormat>(dvrConfig.getDataFormat()),
Hongguang11da2cb2021-08-05 19:05:12 -07001017 .packetSize = static_cast<int64_t>(dvrConfig.getPacketSize()),
Hongguang600a6ae2021-07-08 18:51:51 -07001018 };
1019 return playbackSettings;
1020 }
1021
1022 static RecordSettings readRecordSettings(Dvr dvrConfig) {
1023 ALOGW("[ConfigReader] dvr type is record");
1024 RecordSettings recordSettings{
Hongguang11da2cb2021-08-05 19:05:12 -07001025 .statusMask = static_cast<int8_t>(dvrConfig.getStatusMask()),
1026 .lowThreshold = static_cast<int64_t>(dvrConfig.getLowThreshold()),
1027 .highThreshold = static_cast<int64_t>(dvrConfig.getHighThreshold()),
Hongguang600a6ae2021-07-08 18:51:51 -07001028 .dataFormat = static_cast<DataFormat>(dvrConfig.getDataFormat()),
Hongguang11da2cb2021-08-05 19:05:12 -07001029 .packetSize = static_cast<int64_t>(dvrConfig.getPacketSize()),
Hongguang600a6ae2021-07-08 18:51:51 -07001030 };
1031 return recordSettings;
1032 }
1033
Hongguange106f472022-01-11 12:09:22 -08001034 static void getCiCamInfo(Frontend feConfig, bool& canConnectToCiCam, int32_t& ciCamId,
1035 int32_t& removePid) {
Hongguang600a6ae2021-07-08 18:51:51 -07001036 if (!feConfig.hasConnectToCicamId()) {
1037 canConnectToCiCam = false;
1038 ciCamId = -1;
Hongguange106f472022-01-11 12:09:22 -08001039 removePid = -1;
Gareth Fenn53ae3832021-10-15 17:19:00 +01001040 return;
Hongguang600a6ae2021-07-08 18:51:51 -07001041 }
1042 canConnectToCiCam = true;
1043 ciCamId = static_cast<int32_t>(feConfig.getConnectToCicamId());
Hongguange106f472022-01-11 12:09:22 -08001044 removePid = static_cast<int32_t>(feConfig.getRemoveOutputPid());
Hongguang600a6ae2021-07-08 18:51:51 -07001045 }
1046};