blob: 3009c4a28d08434009f092ff9bdc0bbe01aebbf3 [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;
266 break;
267 case FrontendTypeEnum::ATSC3:
268 type = FrontendType::ATSC3;
269 break;
270 case FrontendTypeEnum::DVBC:
271 type = FrontendType::DVBC;
272 break;
273 case FrontendTypeEnum::DVBS:
274 type = FrontendType::DVBS;
275 frontendMap[id].settings.set<FrontendSettings::Tag::dvbs>(
276 readDvbsFrontendSettings(feConfig));
277 break;
278 case FrontendTypeEnum::DVBT: {
279 type = FrontendType::DVBT;
280 frontendMap[id].settings.set<FrontendSettings::Tag::dvbt>(
281 readDvbtFrontendSettings(feConfig));
282 break;
283 }
284 case FrontendTypeEnum::ISDBS:
285 type = FrontendType::ISDBS;
286 break;
287 case FrontendTypeEnum::ISDBS3:
288 type = FrontendType::ISDBS3;
289 break;
290 case FrontendTypeEnum::ISDBT:
291 type = FrontendType::ISDBT;
292 break;
293 case FrontendTypeEnum::DTMB:
294 type = FrontendType::DTMB;
295 break;
296 case FrontendTypeEnum::UNKNOWN:
297 ALOGW("[ConfigReader] invalid frontend type");
298 return;
299 default:
300 ALOGW("[ConfigReader] fe already handled in 1_0 reader.");
301 break;
302 }
303 frontendMap[id].type = type;
304 frontendMap[id].isSoftwareFe = feConfig.getIsSoftwareFrontend();
305 // TODO: b/182519645 complete the tune status config
306 frontendMap[id].tuneStatusTypes = types;
307 frontendMap[id].expectTuneStatuses = statuses;
Hongguange106f472022-01-11 12:09:22 -0800308 getCiCamInfo(feConfig, frontendMap[id].canConnectToCiCam, frontendMap[id].ciCamId,
309 frontendMap[id].removePid);
Hongguang600a6ae2021-07-08 18:51:51 -0700310 }
311 }
312 }
313
314 static void readFilterConfig1_0(map<string, FilterConfig>& filterMap) {
315 auto hardwareConfig = getHardwareConfig();
316 if (hardwareConfig.hasFilters()) {
317 auto filters = *hardwareConfig.getFirstFilters();
318 for (auto filterConfig : filters.getFilter()) {
319 string id = filterConfig.getId();
320 if (id.compare(string("FILTER_AUDIO_DEFAULT")) == 0) {
321 // overrid default
322 filterMap.erase(string("FILTER_AUDIO_DEFAULT"));
323 }
324 if (id.compare(string("FILTER_VIDEO_DEFAULT")) == 0) {
325 // overrid default
326 filterMap.erase(string("FILTER_VIDEO_DEFAULT"));
327 }
328
329 DemuxFilterType type;
330 DemuxFilterSettings settings;
331 if (!readFilterTypeAndSettings(filterConfig, type, settings)) {
332 ALOGW("[ConfigReader] invalid filter type");
333 return;
334 }
335 filterMap[id].type = type;
336 filterMap[id].bufferSize = filterConfig.getBufferSize();
337 filterMap[id].getMqDesc = filterConfig.getUseFMQ();
338 filterMap[id].settings = settings;
339
340 if (filterConfig.hasMonitorEventTypes()) {
Hongguang11da2cb2021-08-05 19:05:12 -0700341 filterMap[id].monitorEventTypes = (int32_t)filterConfig.getMonitorEventTypes();
Hongguang600a6ae2021-07-08 18:51:51 -0700342 }
Patrick Rohr1586d212021-11-23 00:40:56 +0100343 if (filterConfig.hasTimeDelayInMs()) {
344 filterMap[id].timeDelayInMs = filterConfig.getTimeDelayInMs();
345 }
346 if (filterConfig.hasDataDelayInBytes()) {
347 filterMap[id].dataDelayInBytes = filterConfig.getDataDelayInBytes();
348 }
Hongguang600a6ae2021-07-08 18:51:51 -0700349 if (filterConfig.hasAvFilterSettings_optional()) {
350 auto av = filterConfig.getFirstAvFilterSettings_optional();
351 if (av->hasAudioStreamType_optional()) {
352 filterMap[id].streamType.set<AvStreamType::Tag::audio>(
353 static_cast<AudioStreamType>(av->getAudioStreamType_optional()));
354 }
355 if (av->hasVideoStreamType_optional()) {
356 filterMap[id].streamType.set<AvStreamType::Tag::video>(
357 static_cast<VideoStreamType>(av->getVideoStreamType_optional()));
358 }
359 }
360 if (filterConfig.hasIpFilterConfig_optional()) {
361 auto ip = filterConfig.getFirstIpFilterConfig_optional();
362 if (ip->hasIpCid()) {
363 filterMap[id].ipCid = ip->getIpCid();
364 }
365 }
366 }
367 }
368 }
369
370 static void readDvrConfig1_0(map<string, DvrConfig>& dvrMap) {
371 auto hardwareConfig = getHardwareConfig();
372 if (hardwareConfig.hasDvrs()) {
373 auto dvrs = *hardwareConfig.getFirstDvrs();
374 for (auto dvrConfig : dvrs.getDvr()) {
375 string id = dvrConfig.getId();
376 DvrType type;
377 switch (dvrConfig.getType()) {
378 case DvrTypeEnum::PLAYBACK:
379 type = DvrType::PLAYBACK;
380 dvrMap[id].settings.set<DvrSettings::Tag::playback>(
381 readPlaybackSettings(dvrConfig));
382 break;
383 case DvrTypeEnum::RECORD:
384 type = DvrType::RECORD;
385 dvrMap[id].settings.set<DvrSettings::Tag::record>(
386 readRecordSettings(dvrConfig));
387 break;
388 case DvrTypeEnum::UNKNOWN:
389 ALOGW("[ConfigReader] invalid DVR type");
390 return;
391 }
392 dvrMap[id].type = type;
Hongguang11da2cb2021-08-05 19:05:12 -0700393 dvrMap[id].bufferSize = static_cast<int32_t>(dvrConfig.getBufferSize());
Hongguang600a6ae2021-07-08 18:51:51 -0700394 if (dvrConfig.hasInputFilePath()) {
395 dvrMap[id].playbackInputFile = dvrConfig.getInputFilePath();
396 }
397 }
398 }
399 }
400
401 static void readLnbConfig1_0(map<string, LnbConfig>& lnbMap) {
402 auto hardwareConfig = getHardwareConfig();
403 if (hardwareConfig.hasLnbs()) {
404 auto lnbs = *hardwareConfig.getFirstLnbs();
405 for (auto lnbConfig : lnbs.getLnb()) {
406 string id = lnbConfig.getId();
407 if (lnbConfig.hasName()) {
408 lnbMap[id].name = lnbConfig.getName();
409 } else {
410 lnbMap[id].name = emptyHardwareId;
411 }
412 lnbMap[id].voltage = static_cast<LnbVoltage>(lnbConfig.getVoltage());
413 lnbMap[id].tone = static_cast<LnbTone>(lnbConfig.getTone());
414 lnbMap[id].position = static_cast<LnbPosition>(lnbConfig.getPosition());
415 }
416 }
417 }
418
419 static void readDescramblerConfig1_0(map<string, DescramblerConfig>& descramblerMap) {
420 auto hardwareConfig = getHardwareConfig();
421 if (hardwareConfig.hasDescramblers()) {
422 auto descramblers = *hardwareConfig.getFirstDescramblers();
423 for (auto descramblerConfig : descramblers.getDescrambler()) {
424 string id = descramblerConfig.getId();
425 descramblerMap[id].casSystemId =
Hongguang11da2cb2021-08-05 19:05:12 -0700426 static_cast<int32_t>(descramblerConfig.getCasSystemId());
Hongguang600a6ae2021-07-08 18:51:51 -0700427 if (descramblerConfig.hasProvisionStr()) {
428 descramblerMap[id].provisionStr = descramblerConfig.getProvisionStr();
429 } else {
430 descramblerMap[id].provisionStr = PROVISION_STR;
431 }
432 if (descramblerConfig.hasSesstionPrivatData()) {
433 auto privateData = descramblerConfig.getSesstionPrivatData();
434 int size = privateData.size();
435 descramblerMap[id].hidlPvtData.resize(size);
436 memcpy(descramblerMap[id].hidlPvtData.data(), privateData.data(), size);
437 } else {
438 descramblerMap[id].hidlPvtData.resize(256);
439 }
440 }
441 }
442 }
443
444 static void readDiseqcMessages(map<string, vector<uint8_t>>& diseqcMsgMap) {
445 auto hardwareConfig = getHardwareConfig();
446 if (hardwareConfig.hasDiseqcMessages()) {
447 auto msgs = *hardwareConfig.getFirstDiseqcMessages();
448 for (auto msgConfig : msgs.getDiseqcMessage()) {
449 string name = msgConfig.getMsgName();
450 for (uint8_t atom : msgConfig.getMsgBody()) {
451 diseqcMsgMap[name].push_back(atom);
452 }
453 }
454 }
455 }
456
457 static void readTimeFilterConfig1_0(map<string, TimeFilterConfig>& timeFilterMap) {
458 auto hardwareConfig = getHardwareConfig();
459 if (hardwareConfig.hasTimeFilters()) {
460 auto timeFilters = *hardwareConfig.getFirstTimeFilters();
461 for (auto timeFilterConfig : timeFilters.getTimeFilter()) {
462 string id = timeFilterConfig.getId();
Hongguang11da2cb2021-08-05 19:05:12 -0700463 timeFilterMap[id].timeStamp = static_cast<int64_t>(timeFilterConfig.getTimeStamp());
Hongguang600a6ae2021-07-08 18:51:51 -0700464 }
465 }
466 }
467
468 static void connectLiveBroadcast(LiveBroadcastHardwareConnections& live) {
469 auto dataFlow = getDataFlowConfiguration();
470 if (dataFlow.hasClearLiveBroadcast()) {
471 live.hasFrontendConnection = true;
472 } else {
473 live.hasFrontendConnection = false;
474 return;
475 }
476 auto liveConfig = *dataFlow.getFirstClearLiveBroadcast();
477 live.frontendId = liveConfig.getFrontendConnection();
478
479 live.audioFilterId = liveConfig.getAudioFilterConnection();
480 live.videoFilterId = liveConfig.getVideoFilterConnection();
481 if (liveConfig.hasPcrFilterConnection()) {
482 live.pcrFilterId = liveConfig.getPcrFilterConnection();
483 } else {
484 live.pcrFilterId = emptyHardwareId;
485 }
486 if (liveConfig.hasSectionFilterConnection()) {
487 live.sectionFilterId = liveConfig.getSectionFilterConnection();
488 } else {
489 live.sectionFilterId = emptyHardwareId;
490 }
491 if (liveConfig.hasDvrSoftwareFeConnection()) {
492 live.dvrSoftwareFeId = liveConfig.getDvrSoftwareFeConnection();
493 }
494 if (liveConfig.hasIpFilterConnection()) {
495 live.ipFilterId = liveConfig.getIpFilterConnection();
496 } else {
497 live.ipFilterId = emptyHardwareId;
498 }
499 }
500
501 static void connectScan(ScanHardwareConnections& scan) {
502 auto dataFlow = getDataFlowConfiguration();
503 if (dataFlow.hasScan()) {
504 scan.hasFrontendConnection = true;
505 } else {
506 scan.hasFrontendConnection = false;
507 return;
508 }
509 auto scanConfig = *dataFlow.getFirstScan();
510 scan.frontendId = scanConfig.getFrontendConnection();
511 }
512
513 static void connectDvrPlayback(DvrPlaybackHardwareConnections& playback) {
514 auto dataFlow = getDataFlowConfiguration();
515 if (dataFlow.hasDvrPlayback()) {
516 playback.support = true;
517 } else {
518 playback.support = false;
519 return;
520 }
521 auto playbackConfig = *dataFlow.getFirstDvrPlayback();
522 playback.dvrId = playbackConfig.getDvrConnection();
523 playback.audioFilterId = playbackConfig.getAudioFilterConnection();
524 playback.videoFilterId = playbackConfig.getVideoFilterConnection();
525 if (playbackConfig.hasSectionFilterConnection()) {
526 playback.sectionFilterId = playbackConfig.getSectionFilterConnection();
527 } else {
528 playback.sectionFilterId = emptyHardwareId;
529 }
530 }
531
532 static void connectDvrRecord(DvrRecordHardwareConnections& record) {
533 auto dataFlow = getDataFlowConfiguration();
534 if (dataFlow.hasDvrRecord()) {
535 record.support = true;
536 } else {
537 record.support = false;
538 return;
539 }
540 auto recordConfig = *dataFlow.getFirstDvrRecord();
541 record.recordFilterId = recordConfig.getRecordFilterConnection();
542 record.dvrRecordId = recordConfig.getDvrRecordConnection();
543 if (recordConfig.hasDvrSoftwareFeConnection()) {
544 record.dvrSoftwareFeId = recordConfig.getDvrSoftwareFeConnection();
545 }
546 if (recordConfig.getHasFrontendConnection()) {
547 record.hasFrontendConnection = true;
548 record.dvrSourceId = emptyHardwareId;
549 record.frontendId = recordConfig.getFrontendConnection();
550 } else {
551 record.hasFrontendConnection = false;
552 record.dvrSourceId = recordConfig.getDvrSourceConnection();
553 }
554 }
555
556 static void connectDescrambling(DescramblingHardwareConnections& descrambling) {
557 auto dataFlow = getDataFlowConfiguration();
558 if (dataFlow.hasDescrambling()) {
559 descrambling.support = true;
560 } else {
561 descrambling.support = false;
562 return;
563 }
564 auto descConfig = *dataFlow.getFirstDescrambling();
565 descrambling.descramblerId = descConfig.getDescramblerConnection();
566 descrambling.audioFilterId = descConfig.getAudioFilterConnection();
567 descrambling.videoFilterId = descConfig.getVideoFilterConnection();
568 if (descConfig.hasDvrSoftwareFeConnection()) {
569 descrambling.dvrSoftwareFeId = descConfig.getDvrSoftwareFeConnection();
570 }
571 if (descConfig.getHasFrontendConnection()) {
572 descrambling.hasFrontendConnection = true;
573 descrambling.dvrSourceId = emptyHardwareId;
574 descrambling.frontendId = descConfig.getFrontendConnection();
575 } else {
576 descrambling.hasFrontendConnection = false;
577 descrambling.dvrSourceId = descConfig.getDvrSourceConnection();
578 }
579 }
580
581 static void connectLnbLive(LnbLiveHardwareConnections& lnbLive) {
582 auto dataFlow = getDataFlowConfiguration();
583 if (dataFlow.hasLnbLive()) {
584 lnbLive.support = true;
585 } else {
586 lnbLive.support = false;
587 return;
588 }
589 auto lnbLiveConfig = *dataFlow.getFirstLnbLive();
590 lnbLive.frontendId = lnbLiveConfig.getFrontendConnection();
591 lnbLive.audioFilterId = lnbLiveConfig.getAudioFilterConnection();
592 lnbLive.videoFilterId = lnbLiveConfig.getVideoFilterConnection();
593 lnbLive.lnbId = lnbLiveConfig.getLnbConnection();
594 if (lnbLiveConfig.hasDiseqcMsgSender()) {
595 for (auto msgName : lnbLiveConfig.getDiseqcMsgSender()) {
596 lnbLive.diseqcMsgs.push_back(msgName);
597 }
598 }
599 }
600
601 static void connectLnbRecord(LnbRecordHardwareConnections& lnbRecord) {
602 auto dataFlow = getDataFlowConfiguration();
603 if (dataFlow.hasLnbRecord()) {
604 lnbRecord.support = true;
605 } else {
606 lnbRecord.support = false;
607 return;
608 }
609 auto lnbRecordConfig = *dataFlow.getFirstLnbRecord();
610 lnbRecord.frontendId = lnbRecordConfig.getFrontendConnection();
611 lnbRecord.recordFilterId = lnbRecordConfig.getRecordFilterConnection();
612 lnbRecord.dvrRecordId = lnbRecordConfig.getDvrRecordConnection();
613 lnbRecord.lnbId = lnbRecordConfig.getLnbConnection();
614 if (lnbRecordConfig.hasDiseqcMsgSender()) {
615 for (auto msgName : lnbRecordConfig.getDiseqcMsgSender()) {
616 lnbRecord.diseqcMsgs.push_back(msgName);
617 }
618 }
619 }
620
621 static void connectTimeFilter(TimeFilterHardwareConnections& timeFilter) {
622 auto dataFlow = getDataFlowConfiguration();
623 if (dataFlow.hasTimeFilter()) {
624 timeFilter.support = true;
625 } else {
626 timeFilter.support = false;
627 return;
628 }
629 auto timeFilterConfig = *dataFlow.getFirstTimeFilter();
630 timeFilter.timeFilterId = timeFilterConfig.getTimeFilterConnection();
631 }
632
633 private:
634 static FrontendDvbtSettings readDvbtFrontendSettings(Frontend feConfig) {
635 ALOGW("[ConfigReader] fe type is dvbt");
636 FrontendDvbtSettings dvbtSettings{
Hongguang11da2cb2021-08-05 19:05:12 -0700637 .frequency = (int64_t)feConfig.getFrequency(),
Hongguang600a6ae2021-07-08 18:51:51 -0700638 };
Hongguang11da2cb2021-08-05 19:05:12 -0700639 if (feConfig.hasEndFrequency()) {
640 dvbtSettings.endFrequency = (int64_t)feConfig.getEndFrequency();
641 }
Hongguang600a6ae2021-07-08 18:51:51 -0700642 if (!feConfig.hasDvbtFrontendSettings_optional()) {
643 ALOGW("[ConfigReader] no more dvbt settings");
644 return dvbtSettings;
645 }
646 auto dvbt = feConfig.getFirstDvbtFrontendSettings_optional();
Hongguang11da2cb2021-08-05 19:05:12 -0700647 int32_t trans = static_cast<int32_t>(dvbt->getTransmissionMode());
Hongguang600a6ae2021-07-08 18:51:51 -0700648 dvbtSettings.transmissionMode = static_cast<FrontendDvbtTransmissionMode>(trans);
649 dvbtSettings.bandwidth = static_cast<FrontendDvbtBandwidth>(dvbt->getBandwidth());
650 dvbtSettings.isHighPriority = dvbt->getIsHighPriority();
651 dvbtSettings.hierarchy = static_cast<FrontendDvbtHierarchy>(dvbt->getHierarchy());
652 dvbtSettings.hpCoderate = static_cast<FrontendDvbtCoderate>(dvbt->getHpCoderate());
653 dvbtSettings.lpCoderate = static_cast<FrontendDvbtCoderate>(dvbt->getLpCoderate());
654 dvbtSettings.guardInterval =
655 static_cast<FrontendDvbtGuardInterval>(dvbt->getGuardInterval());
656 dvbtSettings.standard = static_cast<FrontendDvbtStandard>(dvbt->getStandard());
657 dvbtSettings.isMiso = dvbt->getIsMiso();
658 dvbtSettings.plpMode = static_cast<FrontendDvbtPlpMode>(dvbt->getPlpMode());
659 dvbtSettings.plpId = dvbt->getPlpId();
660 dvbtSettings.plpGroupId = dvbt->getPlpGroupId();
661 if (dvbt->hasConstellation()) {
662 dvbtSettings.constellation =
663 static_cast<FrontendDvbtConstellation>(dvbt->getConstellation());
664 }
665 return dvbtSettings;
666 }
667
668 static FrontendDvbsSettings readDvbsFrontendSettings(Frontend feConfig) {
669 ALOGW("[ConfigReader] fe type is dvbs");
670 FrontendDvbsSettings dvbsSettings{
Hongguang11da2cb2021-08-05 19:05:12 -0700671 .frequency = (int64_t)feConfig.getFrequency(),
Hongguang600a6ae2021-07-08 18:51:51 -0700672 };
Hongguang11da2cb2021-08-05 19:05:12 -0700673 if (feConfig.hasEndFrequency()) {
674 dvbsSettings.endFrequency = (int64_t)feConfig.getEndFrequency();
675 }
Hongguang600a6ae2021-07-08 18:51:51 -0700676 if (!feConfig.hasDvbsFrontendSettings_optional()) {
677 ALOGW("[ConfigReader] no more dvbs settings");
678 return dvbsSettings;
679 }
Hongguang11da2cb2021-08-05 19:05:12 -0700680 dvbsSettings.symbolRate = static_cast<int32_t>(
Hongguang600a6ae2021-07-08 18:51:51 -0700681 feConfig.getFirstDvbsFrontendSettings_optional()->getSymbolRate());
Hongguang11da2cb2021-08-05 19:05:12 -0700682 dvbsSettings.inputStreamId = static_cast<int32_t>(
Hongguang600a6ae2021-07-08 18:51:51 -0700683 feConfig.getFirstDvbsFrontendSettings_optional()->getInputStreamId());
684 auto dvbs = feConfig.getFirstDvbsFrontendSettings_optional();
685 if (dvbs->hasScanType()) {
686 dvbsSettings.scanType = static_cast<FrontendDvbsScanType>(dvbs->getScanType());
687 }
688 if (dvbs->hasIsDiseqcRxMessage()) {
689 dvbsSettings.isDiseqcRxMessage = dvbs->getIsDiseqcRxMessage();
690 }
691 return dvbsSettings;
692 }
693
694 static bool readFilterTypeAndSettings(Filter filterConfig, DemuxFilterType& type,
695 DemuxFilterSettings& settings) {
696 auto mainType = filterConfig.getMainType();
697 auto subType = filterConfig.getSubType();
698
699 switch (mainType) {
700 case FilterMainTypeEnum::TS: {
701 ALOGW("[ConfigReader] filter main type is ts");
702 type.mainType = DemuxFilterMainType::TS;
703 DemuxTsFilterSettings ts;
704 bool isTsSet = false;
705 switch (subType) {
706 case FilterSubTypeEnum::UNDEFINED:
Hongguangce1e30d2021-08-02 21:55:44 -0700707 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700708 DemuxTsFilterType::UNDEFINED);
709 break;
710 case FilterSubTypeEnum::SECTION:
Hongguangce1e30d2021-08-02 21:55:44 -0700711 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700712 DemuxTsFilterType::SECTION);
713 ts.filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::section>(
714 readSectionFilterSettings(filterConfig));
715 isTsSet = true;
716 break;
717 case FilterSubTypeEnum::PES:
718 // TODO: b/182519645 support all the filter settings
Hongguangce1e30d2021-08-02 21:55:44 -0700719 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700720 DemuxTsFilterType::PES);
721 break;
722 case FilterSubTypeEnum::TS:
Hongguangce1e30d2021-08-02 21:55:44 -0700723 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700724 DemuxTsFilterType::TS);
725 ts.filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::noinit>(
726 true);
727 isTsSet = true;
728 break;
729 case FilterSubTypeEnum::PCR:
Hongguangce1e30d2021-08-02 21:55:44 -0700730 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700731 DemuxTsFilterType::PCR);
732 ts.filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::noinit>(
733 true);
734 isTsSet = true;
735 break;
736 case FilterSubTypeEnum::TEMI:
Hongguangce1e30d2021-08-02 21:55:44 -0700737 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700738 DemuxTsFilterType::TEMI);
739 ts.filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::noinit>(
740 true);
741 isTsSet = true;
742 break;
743 case FilterSubTypeEnum::AUDIO:
Hongguangce1e30d2021-08-02 21:55:44 -0700744 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700745 DemuxTsFilterType::AUDIO);
746 ts.filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(
747 readAvFilterSettings(filterConfig));
748 isTsSet = true;
749 break;
750 case FilterSubTypeEnum::VIDEO:
Hongguangce1e30d2021-08-02 21:55:44 -0700751 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700752 DemuxTsFilterType::VIDEO);
753 ts.filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(
754 readAvFilterSettings(filterConfig));
755 isTsSet = true;
756 break;
757 case FilterSubTypeEnum::RECORD:
Hongguangce1e30d2021-08-02 21:55:44 -0700758 type.subType.set<DemuxFilterSubType::Tag::tsFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700759 DemuxTsFilterType::RECORD);
760 ts.filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::record>(
761 readRecordFilterSettings(filterConfig));
762 isTsSet = true;
763 break;
764 default:
765 ALOGW("[ConfigReader] ts subtype is not supported");
766 return false;
767 }
768 if (filterConfig.hasPid()) {
769 ts.tpid = static_cast<int32_t>(filterConfig.getPid());
770 isTsSet = true;
771 }
772 if (isTsSet) {
773 settings.set<DemuxFilterSettings::Tag::ts>(ts);
774 }
775 break;
776 }
777 case FilterMainTypeEnum::MMTP: {
778 ALOGW("[ConfigReader] filter main type is mmtp");
779 type.mainType = DemuxFilterMainType::MMTP;
780 DemuxMmtpFilterSettings mmtp;
781 bool isMmtpSet = false;
782 switch (subType) {
783 case FilterSubTypeEnum::UNDEFINED:
Hongguangce1e30d2021-08-02 21:55:44 -0700784 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700785 DemuxMmtpFilterType::UNDEFINED);
786 break;
787 case FilterSubTypeEnum::SECTION:
Hongguangce1e30d2021-08-02 21:55:44 -0700788 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700789 DemuxMmtpFilterType::SECTION);
790 mmtp.filterSettings
791 .set<DemuxMmtpFilterSettingsFilterSettings::Tag::section>(
792 readSectionFilterSettings(filterConfig));
793 isMmtpSet = true;
794 break;
795 case FilterSubTypeEnum::PES:
Hongguangce1e30d2021-08-02 21:55:44 -0700796 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700797 DemuxMmtpFilterType::PES);
798 // TODO: b/182519645 support all the filter settings
799 break;
800 case FilterSubTypeEnum::MMTP:
Hongguangce1e30d2021-08-02 21:55:44 -0700801 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700802 DemuxMmtpFilterType::MMTP);
803 mmtp.filterSettings.set<DemuxMmtpFilterSettingsFilterSettings::Tag::noinit>(
804 true);
805 isMmtpSet = true;
806 break;
807 case FilterSubTypeEnum::AUDIO:
Hongguangce1e30d2021-08-02 21:55:44 -0700808 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700809 DemuxMmtpFilterType::AUDIO);
810 mmtp.filterSettings.set<DemuxMmtpFilterSettingsFilterSettings::Tag::av>(
811 readAvFilterSettings(filterConfig));
812 isMmtpSet = true;
813 break;
814 case FilterSubTypeEnum::VIDEO:
Hongguangce1e30d2021-08-02 21:55:44 -0700815 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700816 DemuxMmtpFilterType::VIDEO);
817 mmtp.filterSettings.set<DemuxMmtpFilterSettingsFilterSettings::Tag::av>(
818 readAvFilterSettings(filterConfig));
819 isMmtpSet = true;
820 break;
821 case FilterSubTypeEnum::RECORD:
Hongguangce1e30d2021-08-02 21:55:44 -0700822 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700823 DemuxMmtpFilterType::RECORD);
824 mmtp.filterSettings.set<DemuxMmtpFilterSettingsFilterSettings::Tag::record>(
825 readRecordFilterSettings(filterConfig));
826 isMmtpSet = true;
827 break;
828 case FilterSubTypeEnum::DOWNLOAD:
Hongguangce1e30d2021-08-02 21:55:44 -0700829 type.subType.set<DemuxFilterSubType::Tag::mmtpFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700830 DemuxMmtpFilterType::DOWNLOAD);
831 // TODO: b/182519645 support all the filter settings
832 break;
833 default:
834 ALOGW("[ConfigReader] mmtp subtype is not supported");
835 return false;
836 }
837 if (filterConfig.hasPid()) {
838 mmtp.mmtpPid = static_cast<int32_t>(filterConfig.getPid());
839 isMmtpSet = true;
840 }
841 if (isMmtpSet) {
842 settings.set<DemuxFilterSettings::Tag::mmtp>(mmtp);
843 }
844 break;
845 }
846 case FilterMainTypeEnum::IP: {
847 ALOGW("[ConfigReader] filter main type is ip");
848 type.mainType = DemuxFilterMainType::IP;
849 DemuxIpFilterSettings ip;
850 switch (subType) {
851 case FilterSubTypeEnum::UNDEFINED:
Hongguangce1e30d2021-08-02 21:55:44 -0700852 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700853 DemuxIpFilterType::UNDEFINED);
854 break;
855 case FilterSubTypeEnum::SECTION:
Hongguangce1e30d2021-08-02 21:55:44 -0700856 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700857 DemuxIpFilterType::SECTION);
858 ip.filterSettings.set<DemuxIpFilterSettingsFilterSettings::Tag::section>(
859 readSectionFilterSettings(filterConfig));
860 settings.set<DemuxFilterSettings::Tag::ip>(ip);
861 break;
862 case FilterSubTypeEnum::NTP:
Hongguangce1e30d2021-08-02 21:55:44 -0700863 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700864 DemuxIpFilterType::NTP);
865 ip.filterSettings.set<DemuxIpFilterSettingsFilterSettings::Tag::noinit>(
866 true);
867 settings.set<DemuxFilterSettings::Tag::ip>(ip);
868 break;
869 case FilterSubTypeEnum::IP: {
870 ip.ipAddr = readIpAddress(filterConfig),
871 ip.filterSettings
872 .set<DemuxIpFilterSettingsFilterSettings::Tag::bPassthrough>(
873 readPassthroughSettings(filterConfig));
874 settings.set<DemuxFilterSettings::Tag::ip>(ip);
875 break;
876 }
877 case FilterSubTypeEnum::IP_PAYLOAD:
Hongguangce1e30d2021-08-02 21:55:44 -0700878 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700879 DemuxIpFilterType::IP_PAYLOAD);
880 ip.filterSettings.set<DemuxIpFilterSettingsFilterSettings::Tag::noinit>(
881 true);
882 settings.set<DemuxFilterSettings::Tag::ip>(ip);
883 break;
884 case FilterSubTypeEnum::PAYLOAD_THROUGH:
Hongguangce1e30d2021-08-02 21:55:44 -0700885 type.subType.set<DemuxFilterSubType::Tag::ipFilterType>(
Hongguang600a6ae2021-07-08 18:51:51 -0700886 DemuxIpFilterType::PAYLOAD_THROUGH);
887 ip.filterSettings.set<DemuxIpFilterSettingsFilterSettings::Tag::noinit>(
888 true);
889 settings.set<DemuxFilterSettings::Tag::ip>(ip);
890 break;
891 default:
892 ALOGW("[ConfigReader] mmtp subtype is not supported");
893 return false;
894 }
895 break;
896 }
897 default:
898 // TODO: b/182519645 support all the filter configs
899 ALOGW("[ConfigReader] filter main type is not supported in dynamic config");
900 return false;
901 }
902 return true;
903 }
904
905 static DemuxIpAddress readIpAddress(Filter filterConfig) {
906 DemuxIpAddress ipAddress;
907 vector<uint8_t> data;
908 if (!filterConfig.hasIpFilterConfig_optional()) {
909 return ipAddress;
910 }
911 auto ipFilterConfig = filterConfig.getFirstIpFilterConfig_optional();
912 if (ipFilterConfig->hasSrcPort()) {
913 ipAddress.srcPort = ipFilterConfig->getSrcPort();
914 }
915 if (ipFilterConfig->hasDestPort()) {
916 ipAddress.dstPort = ipFilterConfig->getDestPort();
917 }
918 if (ipFilterConfig->getFirstSrcIpAddress()->getIsIpV4()) {
919 data.resize(4);
920 memcpy(data.data(), ipFilterConfig->getFirstSrcIpAddress()->getIp().data(), 4);
921 ipAddress.srcIpAddress.set<DemuxIpAddressIpAddress::Tag::v4>(data);
922 } else {
923 data.resize(6);
924 memcpy(data.data(), ipFilterConfig->getFirstSrcIpAddress()->getIp().data(), 6);
925 ipAddress.srcIpAddress.set<DemuxIpAddressIpAddress::Tag::v6>(data);
926 }
927 if (ipFilterConfig->getFirstDestIpAddress()->getIsIpV4()) {
928 data.resize(4);
929 memcpy(data.data(), ipFilterConfig->getFirstDestIpAddress()->getIp().data(), 4);
930 ipAddress.dstIpAddress.set<DemuxIpAddressIpAddress::Tag::v4>(data);
931 } else {
932 data.resize(6);
933 memcpy(data.data(), ipFilterConfig->getFirstDestIpAddress()->getIp().data(), 6);
934 ipAddress.dstIpAddress.set<DemuxIpAddressIpAddress::Tag::v6>(data);
935 }
936 return ipAddress;
937 }
938
939 static bool readPassthroughSettings(Filter filterConfig) {
940 if (!filterConfig.hasIpFilterConfig_optional()) {
941 return false;
942 }
943 auto ipFilterConfig = filterConfig.getFirstIpFilterConfig_optional();
944 if (ipFilterConfig->hasDataPassthrough()) {
945 return ipFilterConfig->getDataPassthrough();
946 }
947 return false;
948 }
949
950 static DemuxFilterSectionSettings readSectionFilterSettings(Filter filterConfig) {
951 DemuxFilterSectionSettings settings;
952 if (!filterConfig.hasSectionFilterSettings_optional()) {
953 return settings;
954 }
955 auto section = filterConfig.getFirstSectionFilterSettings_optional();
956 settings.isCheckCrc = section->getIsCheckCrc();
957 settings.isRepeat = section->getIsRepeat();
958 settings.isRaw = section->getIsRaw();
Hongguang494ba662022-01-05 22:08:10 -0800959 settings.bitWidthOfLengthField = section->getBitWidthOfLengthField();
Hongguang600a6ae2021-07-08 18:51:51 -0700960 return settings;
961 }
962
963 static DemuxFilterAvSettings readAvFilterSettings(Filter filterConfig) {
964 DemuxFilterAvSettings settings;
965 if (!filterConfig.hasAvFilterSettings_optional()) {
966 return settings;
967 }
968 auto av = filterConfig.getFirstAvFilterSettings_optional();
969 settings.isPassthrough = av->getIsPassthrough();
Hongguang16dacc12021-11-01 15:51:52 -0700970 settings.isSecureMemory = av->getIsSecureMemory();
Hongguang600a6ae2021-07-08 18:51:51 -0700971 return settings;
972 }
973
974 static DemuxFilterRecordSettings readRecordFilterSettings(Filter filterConfig) {
975 DemuxFilterRecordSettings settings;
976 if (!filterConfig.hasRecordFilterSettings_optional()) {
977 return settings;
978 }
979 auto record = filterConfig.getFirstRecordFilterSettings_optional();
980 settings.tsIndexMask = record->getTsIndexMask();
981 settings.scIndexType = static_cast<DemuxRecordScIndexType>(record->getScIndexType());
982 return settings;
983 }
984
985 static PlaybackSettings readPlaybackSettings(Dvr dvrConfig) {
986 ALOGW("[ConfigReader] dvr type is playback");
987 PlaybackSettings playbackSettings{
Hongguang11da2cb2021-08-05 19:05:12 -0700988 .statusMask = static_cast<int8_t>(dvrConfig.getStatusMask()),
989 .lowThreshold = static_cast<int64_t>(dvrConfig.getLowThreshold()),
990 .highThreshold = static_cast<int64_t>(dvrConfig.getHighThreshold()),
Hongguang600a6ae2021-07-08 18:51:51 -0700991 .dataFormat = static_cast<DataFormat>(dvrConfig.getDataFormat()),
Hongguang11da2cb2021-08-05 19:05:12 -0700992 .packetSize = static_cast<int64_t>(dvrConfig.getPacketSize()),
Hongguang600a6ae2021-07-08 18:51:51 -0700993 };
994 return playbackSettings;
995 }
996
997 static RecordSettings readRecordSettings(Dvr dvrConfig) {
998 ALOGW("[ConfigReader] dvr type is record");
999 RecordSettings recordSettings{
Hongguang11da2cb2021-08-05 19:05:12 -07001000 .statusMask = static_cast<int8_t>(dvrConfig.getStatusMask()),
1001 .lowThreshold = static_cast<int64_t>(dvrConfig.getLowThreshold()),
1002 .highThreshold = static_cast<int64_t>(dvrConfig.getHighThreshold()),
Hongguang600a6ae2021-07-08 18:51:51 -07001003 .dataFormat = static_cast<DataFormat>(dvrConfig.getDataFormat()),
Hongguang11da2cb2021-08-05 19:05:12 -07001004 .packetSize = static_cast<int64_t>(dvrConfig.getPacketSize()),
Hongguang600a6ae2021-07-08 18:51:51 -07001005 };
1006 return recordSettings;
1007 }
1008
Hongguange106f472022-01-11 12:09:22 -08001009 static void getCiCamInfo(Frontend feConfig, bool& canConnectToCiCam, int32_t& ciCamId,
1010 int32_t& removePid) {
Hongguang600a6ae2021-07-08 18:51:51 -07001011 if (!feConfig.hasConnectToCicamId()) {
1012 canConnectToCiCam = false;
1013 ciCamId = -1;
Hongguange106f472022-01-11 12:09:22 -08001014 removePid = -1;
Gareth Fenn53ae3832021-10-15 17:19:00 +01001015 return;
Hongguang600a6ae2021-07-08 18:51:51 -07001016 }
1017 canConnectToCiCam = true;
1018 ciCamId = static_cast<int32_t>(feConfig.getConnectToCicamId());
Hongguange106f472022-01-11 12:09:22 -08001019 removePid = static_cast<int32_t>(feConfig.getRemoveOutputPid());
Hongguang600a6ae2021-07-08 18:51:51 -07001020 }
1021};