Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <binder/MemoryDealer.h> |
| 18 | |
| 19 | #include "../../../config/TunerTestingConfigAidlReaderV1_0.h" |
| 20 | |
| 21 | #include <aidl/android/hardware/tv/tuner/DataFormat.h> |
| 22 | #include <aidl/android/hardware/tv/tuner/DemuxAlpFilterType.h> |
| 23 | #include <aidl/android/hardware/tv/tuner/DemuxFilterMainType.h> |
| 24 | #include <aidl/android/hardware/tv/tuner/DemuxFilterMonitorEventType.h> |
| 25 | #include <aidl/android/hardware/tv/tuner/DemuxFilterSettings.h> |
| 26 | #include <aidl/android/hardware/tv/tuner/DemuxFilterType.h> |
| 27 | #include <aidl/android/hardware/tv/tuner/DemuxIpAddress.h> |
| 28 | #include <aidl/android/hardware/tv/tuner/DemuxIpFilterSettings.h> |
| 29 | #include <aidl/android/hardware/tv/tuner/DemuxIpFilterType.h> |
| 30 | #include <aidl/android/hardware/tv/tuner/DemuxMmtpFilterType.h> |
| 31 | #include <aidl/android/hardware/tv/tuner/DemuxRecordScIndexType.h> |
| 32 | #include <aidl/android/hardware/tv/tuner/DemuxTsFilterType.h> |
| 33 | #include <aidl/android/hardware/tv/tuner/DvrSettings.h> |
| 34 | #include <aidl/android/hardware/tv/tuner/DvrType.h> |
| 35 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtBandwidth.h> |
| 36 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtCoderate.h> |
| 37 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtConstellation.h> |
| 38 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtGuardInterval.h> |
| 39 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtHierarchy.h> |
| 40 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtSettings.h> |
| 41 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtStandard.h> |
| 42 | #include <aidl/android/hardware/tv/tuner/FrontendDvbtTransmissionMode.h> |
| 43 | #include <aidl/android/hardware/tv/tuner/FrontendSettings.h> |
| 44 | #include <aidl/android/hardware/tv/tuner/FrontendType.h> |
| 45 | #include <aidl/android/hardware/tv/tuner/PlaybackSettings.h> |
| 46 | #include <aidl/android/hardware/tv/tuner/RecordSettings.h> |
| 47 | |
| 48 | using namespace std; |
| 49 | using namespace aidl::android::hardware::tv::tuner; |
| 50 | using namespace android::media::tuner::testing::configuration::V1_0; |
| 51 | |
| 52 | const int32_t FMQ_SIZE_4M = 0x400000; |
| 53 | const int32_t FMQ_SIZE_16M = 0x1000000; |
| 54 | |
Hongguang | 16dacc1 | 2021-11-01 15:51:52 -0700 | [diff] [blame] | 55 | const string configFilePath = "/vendor/etc/tuner_vts_config_aidl_V1.xml"; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 56 | |
| 57 | #define FILTER_MAIN_TYPE_BIT_COUNT 5 |
| 58 | |
| 59 | // Hardware configs |
| 60 | static map<string, FrontendConfig> frontendMap; |
| 61 | static map<string, FilterConfig> filterMap; |
| 62 | static map<string, DvrConfig> dvrMap; |
| 63 | static map<string, LnbConfig> lnbMap; |
| 64 | static map<string, TimeFilterConfig> timeFilterMap; |
| 65 | static map<string, vector<uint8_t>> diseqcMsgMap; |
| 66 | static map<string, DescramblerConfig> descramblerMap; |
| 67 | |
| 68 | // Hardware and test cases connections |
| 69 | static LiveBroadcastHardwareConnections live; |
| 70 | static ScanHardwareConnections scan; |
| 71 | static DvrPlaybackHardwareConnections playback; |
| 72 | static DvrRecordHardwareConnections record; |
| 73 | static DescramblingHardwareConnections descrambling; |
| 74 | static LnbLiveHardwareConnections lnbLive; |
| 75 | static LnbRecordHardwareConnections lnbRecord; |
| 76 | static TimeFilterHardwareConnections timeFilter; |
| 77 | |
| 78 | /** Config all the frontends that would be used in the tests */ |
| 79 | inline void initFrontendConfig() { |
| 80 | // The test will use the internal default fe when default fe is connected to any data flow |
| 81 | // without overriding in the xml config. |
| 82 | string defaultFeId = "FE_DEFAULT"; |
| 83 | FrontendDvbtSettings dvbtSettings{ |
Gareth Fenn | 282fb37 | 2021-09-27 15:14:11 +0100 | [diff] [blame] | 84 | .frequency = 578000000, |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 85 | .transmissionMode = FrontendDvbtTransmissionMode::AUTO, |
| 86 | .bandwidth = FrontendDvbtBandwidth::BANDWIDTH_8MHZ, |
| 87 | .isHighPriority = true, |
| 88 | }; |
| 89 | frontendMap[defaultFeId].type = FrontendType::DVBT; |
| 90 | frontendMap[defaultFeId].settings.set<FrontendSettings::Tag::dvbt>(dvbtSettings); |
| 91 | |
| 92 | vector<FrontendStatusType> types; |
| 93 | types.push_back(FrontendStatusType::UEC); |
| 94 | types.push_back(FrontendStatusType::IS_MISO); |
| 95 | |
| 96 | vector<FrontendStatus> statuses; |
| 97 | FrontendStatus status; |
| 98 | status.set<FrontendStatus::Tag::uec>(4); |
| 99 | statuses.push_back(status); |
| 100 | status.set<FrontendStatus::Tag::isMiso>(true); |
| 101 | statuses.push_back(status); |
| 102 | |
| 103 | frontendMap[defaultFeId].tuneStatusTypes = types; |
| 104 | frontendMap[defaultFeId].expectTuneStatuses = statuses; |
| 105 | frontendMap[defaultFeId].isSoftwareFe = true; |
| 106 | frontendMap[defaultFeId].canConnectToCiCam = true; |
| 107 | frontendMap[defaultFeId].ciCamId = 0; |
| 108 | FrontendDvbtSettings dvbt; |
| 109 | dvbt.transmissionMode = FrontendDvbtTransmissionMode::MODE_8K_E; |
| 110 | frontendMap[defaultFeId].settings.set<FrontendSettings::Tag::dvbt>(dvbt); |
| 111 | // Read customized config |
| 112 | TunerTestingConfigAidlReader1_0::readFrontendConfig1_0(frontendMap); |
| 113 | }; |
| 114 | |
| 115 | inline void initFilterConfig() { |
| 116 | // The test will use the internal default filter when default filter is connected to any |
| 117 | // data flow without overriding in the xml config. |
| 118 | string defaultAudioFilterId = "FILTER_AUDIO_DEFAULT"; |
| 119 | string defaultVideoFilterId = "FILTER_VIDEO_DEFAULT"; |
| 120 | |
| 121 | filterMap[defaultVideoFilterId].type.mainType = DemuxFilterMainType::TS; |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 122 | filterMap[defaultVideoFilterId].type.subType.set<DemuxFilterSubType::Tag::tsFilterType>( |
| 123 | DemuxTsFilterType::VIDEO); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 124 | filterMap[defaultVideoFilterId].bufferSize = FMQ_SIZE_16M; |
| 125 | filterMap[defaultVideoFilterId].settings = |
| 126 | DemuxFilterSettings::make<DemuxFilterSettings::Tag::ts>(); |
| 127 | filterMap[defaultVideoFilterId].settings.get<DemuxFilterSettings::Tag::ts>().tpid = 256; |
| 128 | DemuxFilterAvSettings video; |
| 129 | video.isPassthrough = false; |
| 130 | filterMap[defaultVideoFilterId] |
| 131 | .settings.get<DemuxFilterSettings::Tag::ts>() |
| 132 | .filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(video); |
| 133 | filterMap[defaultVideoFilterId].monitorEventTypes = |
| 134 | static_cast<int32_t>(DemuxFilterMonitorEventType::SCRAMBLING_STATUS) | |
| 135 | static_cast<int32_t>(DemuxFilterMonitorEventType::IP_CID_CHANGE); |
| 136 | filterMap[defaultVideoFilterId].streamType.set<AvStreamType::Tag::video>( |
| 137 | VideoStreamType::MPEG1); |
| 138 | |
| 139 | filterMap[defaultAudioFilterId].type.mainType = DemuxFilterMainType::TS; |
Hongguang | ce1e30d | 2021-08-02 21:55:44 -0700 | [diff] [blame] | 140 | filterMap[defaultAudioFilterId].type.subType.set<DemuxFilterSubType::Tag::tsFilterType>( |
| 141 | DemuxTsFilterType::AUDIO); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 142 | filterMap[defaultAudioFilterId].bufferSize = FMQ_SIZE_16M; |
| 143 | filterMap[defaultAudioFilterId].settings = |
| 144 | DemuxFilterSettings::make<DemuxFilterSettings::Tag::ts>(); |
| 145 | filterMap[defaultAudioFilterId].settings.get<DemuxFilterSettings::Tag::ts>().tpid = 256; |
| 146 | DemuxFilterAvSettings audio; |
| 147 | audio.isPassthrough = false; |
| 148 | filterMap[defaultAudioFilterId] |
| 149 | .settings.get<DemuxFilterSettings::Tag::ts>() |
| 150 | .filterSettings.set<DemuxTsFilterSettingsFilterSettings::Tag::av>(audio); |
| 151 | filterMap[defaultAudioFilterId].monitorEventTypes = |
| 152 | static_cast<int32_t>(DemuxFilterMonitorEventType::SCRAMBLING_STATUS) | |
| 153 | static_cast<int32_t>(DemuxFilterMonitorEventType::IP_CID_CHANGE); |
| 154 | filterMap[defaultAudioFilterId].streamType.set<AvStreamType::Tag::audio>(AudioStreamType::MP3); |
| 155 | // Read customized config |
| 156 | TunerTestingConfigAidlReader1_0::readFilterConfig1_0(filterMap); |
| 157 | }; |
| 158 | |
| 159 | /** Config all the dvrs that would be used in the tests */ |
| 160 | inline void initDvrConfig() { |
| 161 | // Read customized config |
| 162 | TunerTestingConfigAidlReader1_0::readDvrConfig1_0(dvrMap); |
| 163 | }; |
| 164 | |
Frankie Lizcano | 1fd5297 | 2022-06-30 16:50:21 +0000 | [diff] [blame^] | 165 | inline void initTimeFilterConfig() { |
| 166 | // Read customized config |
| 167 | TunerTestingConfigAidlReader1_0::readTimeFilterConfig1_0(timeFilterMap); |
| 168 | }; |
| 169 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 170 | /** Read the vendor configurations of which hardware to use for each test cases/data flows */ |
| 171 | inline void connectHardwaresToTestCases() { |
| 172 | TunerTestingConfigAidlReader1_0::connectLiveBroadcast(live); |
| 173 | TunerTestingConfigAidlReader1_0::connectScan(scan); |
| 174 | TunerTestingConfigAidlReader1_0::connectDvrRecord(record); |
Frankie Lizcano | 1fd5297 | 2022-06-30 16:50:21 +0000 | [diff] [blame^] | 175 | TunerTestingConfigAidlReader1_0::connectTimeFilter(timeFilter); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 176 | }; |
| 177 | |
| 178 | inline bool validateConnections() { |
| 179 | if (record.support && !record.hasFrontendConnection && |
| 180 | record.dvrSourceId.compare(emptyHardwareId) == 0) { |
| 181 | ALOGW("[vts config] Record must support either a DVR source or a Frontend source."); |
| 182 | return false; |
| 183 | } |
Gareth Fenn | 9a80845 | 2022-03-31 08:40:00 +0100 | [diff] [blame] | 184 | bool feIsValid = live.hasFrontendConnection |
| 185 | ? frontendMap.find(live.frontendId) != frontendMap.end() |
| 186 | : true; |
| 187 | feIsValid &= scan.hasFrontendConnection ? frontendMap.find(scan.frontendId) != frontendMap.end() |
| 188 | : true; |
| 189 | feIsValid &= record.support && record.hasFrontendConnection |
| 190 | ? frontendMap.find(record.frontendId) != frontendMap.end() |
| 191 | : true; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 192 | |
| 193 | if (!feIsValid) { |
| 194 | ALOGW("[vts config] dynamic config fe connection is invalid."); |
| 195 | return false; |
| 196 | } |
| 197 | |
| 198 | bool dvrIsValid = frontendMap[live.frontendId].isSoftwareFe |
| 199 | ? dvrMap.find(live.dvrSoftwareFeId) != dvrMap.end() |
| 200 | : true; |
| 201 | |
| 202 | if (record.support) { |
| 203 | if (record.hasFrontendConnection) { |
| 204 | if (frontendMap[record.frontendId].isSoftwareFe) { |
| 205 | dvrIsValid &= dvrMap.find(record.dvrSoftwareFeId) != dvrMap.end(); |
| 206 | } |
| 207 | } else { |
| 208 | dvrIsValid &= dvrMap.find(record.dvrSourceId) != dvrMap.end(); |
| 209 | } |
| 210 | dvrIsValid &= dvrMap.find(record.dvrRecordId) != dvrMap.end(); |
| 211 | } |
| 212 | |
| 213 | if (!dvrIsValid) { |
| 214 | ALOGW("[vts config] dynamic config dvr connection is invalid."); |
| 215 | return false; |
| 216 | } |
| 217 | |
Gareth Fenn | 9a80845 | 2022-03-31 08:40:00 +0100 | [diff] [blame] | 218 | bool filterIsValid = (live.hasFrontendConnection) |
| 219 | ? filterMap.find(live.audioFilterId) != filterMap.end() && |
| 220 | filterMap.find(live.videoFilterId) != filterMap.end() |
| 221 | : true; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 222 | filterIsValid &= |
| 223 | record.support ? filterMap.find(record.recordFilterId) != filterMap.end() : true; |
| 224 | |
| 225 | if (!filterIsValid) { |
| 226 | ALOGW("[vts config] dynamic config filter connection is invalid."); |
| 227 | return false; |
| 228 | } |
| 229 | |
Frankie Lizcano | 1fd5297 | 2022-06-30 16:50:21 +0000 | [diff] [blame^] | 230 | bool timeFilterIsValid = |
| 231 | timeFilter.support ? timeFilterMap.find(timeFilter.timeFilterId) != timeFilterMap.end() |
| 232 | : true; |
| 233 | |
| 234 | if (!timeFilterIsValid) { |
| 235 | ALOGW("[vts config] dynamic config time filter connection is invalid."); |
| 236 | return false; |
| 237 | } |
| 238 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 239 | return true; |
| 240 | } |