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 "VtsHalTvTunerTargetTest.h" |
| 18 | |
| 19 | #include <aidl/Gtest.h> |
| 20 | #include <aidl/Vintf.h> |
| 21 | #include <android/binder_manager.h> |
| 22 | #include <android/binder_process.h> |
| 23 | |
| 24 | namespace { |
| 25 | |
| 26 | AssertionResult TunerBroadcastAidlTest::filterDataOutputTest() { |
| 27 | return filterDataOutputTestBase(mFilterTests); |
| 28 | } |
| 29 | |
| 30 | AssertionResult TunerPlaybackAidlTest::filterDataOutputTest() { |
| 31 | return filterDataOutputTestBase(mFilterTests); |
| 32 | } |
| 33 | |
| 34 | AssertionResult TunerDescramblerAidlTest::filterDataOutputTest() { |
| 35 | return filterDataOutputTestBase(mFilterTests); |
| 36 | } |
| 37 | |
| 38 | void TunerFilterAidlTest::configSingleFilterInDemuxTest(FilterConfig filterConf, |
| 39 | FrontendConfig frontendConf) { |
| 40 | int32_t feId; |
| 41 | int32_t demuxId; |
| 42 | std::shared_ptr<IDemux> demux; |
| 43 | int64_t filterId; |
| 44 | |
| 45 | mFrontendTests.getFrontendIdByType(frontendConf.type, feId); |
| 46 | ASSERT_TRUE(feId != INVALID_ID); |
| 47 | ASSERT_TRUE(mFrontendTests.openFrontendById(feId)); |
| 48 | ASSERT_TRUE(mFrontendTests.setFrontendCallback()); |
| 49 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 50 | ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId)); |
sadiqsada | 630a974 | 2023-12-20 22:14:31 +0000 | [diff] [blame] | 51 | mFrontendTests.setDemux(demux); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 52 | mFilterTests.setDemux(demux); |
| 53 | ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize)); |
| 54 | ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId)); |
| 55 | ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId)); |
| 56 | if (filterConf.type.mainType == DemuxFilterMainType::IP) { |
| 57 | ASSERT_TRUE(mFilterTests.configIpFilterCid(filterConf.ipCid, filterId)); |
| 58 | } |
| 59 | if (filterConf.monitorEventTypes > 0) { |
| 60 | ASSERT_TRUE(mFilterTests.configureMonitorEvent(filterId, filterConf.monitorEventTypes)); |
| 61 | } |
| 62 | ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc)); |
| 63 | ASSERT_TRUE(mFilterTests.startFilter(filterId)); |
Eddy-SH Chen | 566240a | 2023-09-13 15:25:24 +0800 | [diff] [blame] | 64 | ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/)); |
| 65 | if (filterConf.monitorEventTypes > 0) { |
| 66 | ASSERT_TRUE(mFilterTests.testMonitorEvent(filterId, filterConf.monitorEventTypes)); |
| 67 | } |
| 68 | ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/)); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 69 | ASSERT_TRUE(mFilterTests.stopFilter(filterId)); |
| 70 | ASSERT_TRUE(mFilterTests.closeFilter(filterId)); |
| 71 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 72 | ASSERT_TRUE(mFrontendTests.closeFrontend()); |
| 73 | } |
| 74 | |
| 75 | void TunerFilterAidlTest::reconfigSingleFilterInDemuxTest(FilterConfig filterConf, |
| 76 | FilterConfig filterReconf, |
| 77 | FrontendConfig frontendConf) { |
| 78 | int32_t feId; |
| 79 | int32_t demuxId; |
| 80 | std::shared_ptr<IDemux> demux; |
| 81 | int64_t filterId; |
| 82 | |
| 83 | mFrontendTests.getFrontendIdByType(frontendConf.type, feId); |
| 84 | ASSERT_TRUE(feId != INVALID_ID); |
| 85 | ASSERT_TRUE(mFrontendTests.openFrontendById(feId)); |
| 86 | ASSERT_TRUE(mFrontendTests.setFrontendCallback()); |
| 87 | if (frontendConf.isSoftwareFe) { |
| 88 | mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[live.dvrSoftwareFeId]); |
| 89 | } |
| 90 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 91 | ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId)); |
| 92 | mFrontendTests.setDemux(demux); |
| 93 | mFilterTests.setDemux(demux); |
| 94 | ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize)); |
| 95 | ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId)); |
| 96 | ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId)); |
| 97 | ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc)); |
| 98 | ASSERT_TRUE(mFilterTests.startFilter(filterId)); |
| 99 | ASSERT_TRUE(mFilterTests.stopFilter(filterId)); |
| 100 | ASSERT_TRUE(mFilterTests.configFilter(filterReconf.settings, filterId)); |
| 101 | ASSERT_TRUE(mFilterTests.startFilter(filterId)); |
| 102 | ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/)); |
Ray Chin | 17a3bf0 | 2024-11-19 20:55:25 +0800 | [diff] [blame] | 103 | if (!isPassthroughFilter(filterReconf)) { |
| 104 | ASSERT_TRUE(mFilterTests.startIdTest(filterId)); |
| 105 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 106 | ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/)); |
| 107 | ASSERT_TRUE(mFilterTests.stopFilter(filterId)); |
| 108 | ASSERT_TRUE(mFilterTests.closeFilter(filterId)); |
| 109 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 110 | ASSERT_TRUE(mFrontendTests.closeFrontend()); |
| 111 | } |
| 112 | |
| 113 | void TunerFilterAidlTest::testTimeFilter(TimeFilterConfig filterConf) { |
| 114 | int32_t demuxId; |
| 115 | std::shared_ptr<IDemux> demux; |
| 116 | DemuxCapabilities caps; |
| 117 | |
| 118 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 119 | ASSERT_TRUE(mDemuxTests.getDemuxCaps(caps)); |
| 120 | ASSERT_TRUE(caps.bTimeFilter); |
| 121 | mFilterTests.setDemux(demux); |
| 122 | ASSERT_TRUE(mFilterTests.openTimeFilterInDemux()); |
| 123 | ASSERT_TRUE(mFilterTests.setTimeStamp(filterConf.timeStamp)); |
| 124 | ASSERT_TRUE(mFilterTests.getTimeStamp()); |
| 125 | ASSERT_TRUE(mFilterTests.clearTimeStamp()); |
| 126 | ASSERT_TRUE(mFilterTests.closeTimeFilter()); |
| 127 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 128 | } |
| 129 | |
| 130 | void TunerBroadcastAidlTest::broadcastSingleFilterTest(FilterConfig filterConf, |
| 131 | FrontendConfig frontendConf) { |
| 132 | int32_t feId; |
| 133 | int32_t demuxId; |
| 134 | std::shared_ptr<IDemux> demux; |
| 135 | int64_t filterId; |
| 136 | |
| 137 | mFrontendTests.getFrontendIdByType(frontendConf.type, feId); |
| 138 | ASSERT_TRUE(mFrontendTests.openFrontendById(feId)); |
| 139 | ASSERT_TRUE(mFrontendTests.setFrontendCallback()); |
Frankie Lizcano | 8742181 | 2022-07-28 17:13:01 +0000 | [diff] [blame] | 140 | if (mLnbId != INVALID_LNB_ID) { |
| 141 | ASSERT_TRUE(mFrontendTests.setLnb(mLnbId)); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 142 | } |
| 143 | if (frontendConf.isSoftwareFe) { |
| 144 | mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[live.dvrSoftwareFeId]); |
| 145 | } |
| 146 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 147 | ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId)); |
| 148 | mFrontendTests.setDemux(demux); |
| 149 | mFilterTests.setDemux(demux); |
| 150 | ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize)); |
| 151 | ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId)); |
| 152 | ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId)); |
| 153 | ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc)); |
| 154 | ASSERT_TRUE(mFilterTests.startFilter(filterId)); |
| 155 | // tune test |
| 156 | ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/)); |
Ray Chin | 17a3bf0 | 2024-11-19 20:55:25 +0800 | [diff] [blame] | 157 | if (!isPassthroughFilter(filterConf)) { |
| 158 | ASSERT_TRUE(filterDataOutputTest()); |
| 159 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 160 | ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/)); |
| 161 | ASSERT_TRUE(mFilterTests.stopFilter(filterId)); |
| 162 | ASSERT_TRUE(mFilterTests.closeFilter(filterId)); |
| 163 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 164 | ASSERT_TRUE(mFrontendTests.closeFrontend()); |
| 165 | } |
| 166 | |
| 167 | void TunerBroadcastAidlTest::broadcastSingleFilterTestWithLnb(FilterConfig filterConf, |
| 168 | FrontendConfig frontendConf, |
| 169 | LnbConfig lnbConf) { |
| 170 | if (lnbConf.name.compare(emptyHardwareId) == 0) { |
| 171 | vector<int32_t> ids; |
| 172 | ASSERT_TRUE(mLnbTests.getLnbIds(ids)); |
| 173 | ASSERT_TRUE(ids.size() > 0); |
| 174 | ASSERT_TRUE(mLnbTests.openLnbById(ids[0])); |
Frankie Lizcano | 8742181 | 2022-07-28 17:13:01 +0000 | [diff] [blame] | 175 | mLnbId = ids[0]; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 176 | } else { |
Frankie Lizcano | 8742181 | 2022-07-28 17:13:01 +0000 | [diff] [blame] | 177 | ASSERT_TRUE(mLnbTests.openLnbByName(lnbConf.name, mLnbId)); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 178 | } |
| 179 | ASSERT_TRUE(mLnbTests.setLnbCallback()); |
| 180 | ASSERT_TRUE(mLnbTests.setVoltage(lnbConf.voltage)); |
| 181 | ASSERT_TRUE(mLnbTests.setTone(lnbConf.tone)); |
| 182 | ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConf.position)); |
Frankie Lizcano | d1f520e | 2022-07-26 20:05:46 +0000 | [diff] [blame] | 183 | if (!frontendConf.isSoftwareFe) { |
| 184 | broadcastSingleFilterTest(filterConf, frontendConf); |
| 185 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 186 | ASSERT_TRUE(mLnbTests.closeLnb()); |
Frankie Lizcano | 8742181 | 2022-07-28 17:13:01 +0000 | [diff] [blame] | 187 | mLnbId = INVALID_LNB_ID; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | void TunerBroadcastAidlTest::mediaFilterUsingSharedMemoryTest(FilterConfig filterConf, |
| 191 | FrontendConfig frontendConf) { |
| 192 | int32_t feId; |
| 193 | int32_t demuxId; |
| 194 | std::shared_ptr<IDemux> demux; |
| 195 | int64_t filterId; |
| 196 | |
| 197 | mFrontendTests.getFrontendIdByType(frontendConf.type, feId); |
| 198 | ASSERT_TRUE(feId != INVALID_ID); |
| 199 | ASSERT_TRUE(mFrontendTests.openFrontendById(feId)); |
| 200 | ASSERT_TRUE(mFrontendTests.setFrontendCallback()); |
| 201 | if (frontendConf.isSoftwareFe) { |
| 202 | mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[live.dvrSoftwareFeId]); |
| 203 | } |
| 204 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 205 | ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId)); |
| 206 | mFrontendTests.setDemux(demux); |
| 207 | mFilterTests.setDemux(demux); |
| 208 | ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize)); |
| 209 | ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId)); |
| 210 | ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId)); |
| 211 | ASSERT_TRUE(mFilterTests.getSharedAvMemoryHandle(filterId)); |
| 212 | ASSERT_TRUE(mFilterTests.configAvFilterStreamType(filterConf.streamType, filterId)); |
| 213 | ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc)); |
| 214 | ASSERT_TRUE(mFilterTests.startFilter(filterId)); |
| 215 | // tune test |
| 216 | ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/)); |
Ray Chin | 967c8e8 | 2024-12-24 12:27:27 +0800 | [diff] [blame] | 217 | ASSERT_TRUE(filterDataOutputTest()); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 218 | ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/)); |
| 219 | ASSERT_TRUE(mFilterTests.stopFilter(filterId)); |
| 220 | ASSERT_TRUE(mFilterTests.releaseShareAvHandle(filterId)); |
| 221 | ASSERT_TRUE(mFilterTests.closeFilter(filterId)); |
| 222 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 223 | ASSERT_TRUE(mFrontendTests.closeFrontend()); |
| 224 | } |
| 225 | |
| 226 | void TunerPlaybackAidlTest::playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf) { |
| 227 | int32_t demuxId; |
| 228 | std::shared_ptr<IDemux> demux; |
| 229 | int64_t filterId; |
| 230 | |
| 231 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 232 | mFilterTests.setDemux(demux); |
| 233 | mDvrTests.setDemux(demux); |
| 234 | ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize)); |
| 235 | ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrConf.settings)); |
| 236 | ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor()); |
| 237 | ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize)); |
| 238 | ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId)); |
| 239 | ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId)); |
| 240 | ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc)); |
| 241 | mDvrTests.startPlaybackInputThread(dvrConf.playbackInputFile, |
| 242 | dvrConf.settings.get<DvrSettings::Tag::playback>()); |
| 243 | ASSERT_TRUE(mDvrTests.startDvrPlayback()); |
| 244 | ASSERT_TRUE(mFilterTests.startFilter(filterId)); |
| 245 | ASSERT_TRUE(filterDataOutputTest()); |
| 246 | mDvrTests.stopPlaybackThread(); |
| 247 | ASSERT_TRUE(mFilterTests.stopFilter(filterId)); |
| 248 | ASSERT_TRUE(mDvrTests.stopDvrPlayback()); |
| 249 | ASSERT_TRUE(mFilterTests.closeFilter(filterId)); |
| 250 | mDvrTests.closeDvrPlayback(); |
| 251 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 252 | } |
| 253 | |
Ray Chin | 62ab6c9 | 2022-09-15 15:07:33 +0800 | [diff] [blame] | 254 | void TunerPlaybackAidlTest::setStatusCheckIntervalHintTest(int64_t statusCheckIntervalHint, |
| 255 | DvrConfig dvrConf) { |
| 256 | int32_t demuxId; |
| 257 | std::shared_ptr<IDemux> demux; |
| 258 | |
| 259 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 260 | mDvrTests.setDemux(demux); |
| 261 | ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize)); |
| 262 | ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrConf.settings)); |
| 263 | ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor()); |
| 264 | |
| 265 | ASSERT_TRUE(mDvrTests.setPlaybackStatusCheckIntervalHint(statusCheckIntervalHint)); |
| 266 | |
| 267 | mDvrTests.startPlaybackInputThread(dvrConf.playbackInputFile, |
| 268 | dvrConf.settings.get<DvrSettings::Tag::playback>()); |
| 269 | ASSERT_TRUE(mDvrTests.startDvrPlayback()); |
| 270 | mDvrTests.stopPlaybackThread(); |
| 271 | ASSERT_TRUE(mDvrTests.stopDvrPlayback()); |
| 272 | mDvrTests.closeDvrPlayback(); |
| 273 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 274 | } |
| 275 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 276 | void TunerRecordAidlTest::recordSingleFilterTestWithLnb(FilterConfig filterConf, |
| 277 | FrontendConfig frontendConf, |
| 278 | DvrConfig dvrConf, LnbConfig lnbConf) { |
| 279 | if (lnbConf.name.compare(emptyHardwareId) == 0) { |
| 280 | vector<int32_t> ids; |
| 281 | ASSERT_TRUE(mLnbTests.getLnbIds(ids)); |
| 282 | ASSERT_TRUE(ids.size() > 0); |
| 283 | ASSERT_TRUE(mLnbTests.openLnbById(ids[0])); |
Frankie Lizcano | 8742181 | 2022-07-28 17:13:01 +0000 | [diff] [blame] | 284 | mLnbId = ids[0]; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 285 | } else { |
Frankie Lizcano | 8742181 | 2022-07-28 17:13:01 +0000 | [diff] [blame] | 286 | ASSERT_TRUE(mLnbTests.openLnbByName(lnbConf.name, mLnbId)); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 287 | } |
| 288 | ASSERT_TRUE(mLnbTests.setLnbCallback()); |
| 289 | ASSERT_TRUE(mLnbTests.setVoltage(lnbConf.voltage)); |
| 290 | ASSERT_TRUE(mLnbTests.setTone(lnbConf.tone)); |
| 291 | ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConf.position)); |
| 292 | for (auto msgName : lnbRecord.diseqcMsgs) { |
| 293 | ASSERT_TRUE(mLnbTests.sendDiseqcMessage(diseqcMsgMap[msgName])); |
| 294 | } |
Frankie Lizcano | 9c464f7 | 2022-07-18 17:56:52 +0000 | [diff] [blame] | 295 | if (!frontendConf.isSoftwareFe) { |
| 296 | recordSingleFilterTest(filterConf, frontendConf, dvrConf, Dataflow_Context::LNBRECORD); |
| 297 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 298 | ASSERT_TRUE(mLnbTests.closeLnb()); |
Frankie Lizcano | 8742181 | 2022-07-28 17:13:01 +0000 | [diff] [blame] | 299 | mLnbId = INVALID_LNB_ID; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | void TunerRecordAidlTest::attachSingleFilterToRecordDvrTest(FilterConfig filterConf, |
| 303 | FrontendConfig frontendConf, |
| 304 | DvrConfig dvrConf) { |
| 305 | int32_t demuxId; |
| 306 | std::shared_ptr<IDemux> demux; |
| 307 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 308 | mDvrTests.setDemux(demux); |
| 309 | |
| 310 | DvrConfig dvrSourceConfig; |
| 311 | if (record.hasFrontendConnection) { |
| 312 | int32_t feId; |
| 313 | mFrontendTests.getFrontendIdByType(frontendConf.type, feId); |
| 314 | ASSERT_TRUE(feId != INVALID_ID); |
| 315 | ASSERT_TRUE(mFrontendTests.openFrontendById(feId)); |
| 316 | ASSERT_TRUE(mFrontendTests.setFrontendCallback()); |
| 317 | ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId)); |
| 318 | } else { |
| 319 | dvrSourceConfig = dvrMap[record.dvrSourceId]; |
| 320 | ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize)); |
| 321 | ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings)); |
| 322 | ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor()); |
| 323 | } |
| 324 | |
| 325 | int64_t filterId; |
| 326 | std::shared_ptr<IFilter> filter; |
| 327 | mFilterTests.setDemux(demux); |
| 328 | |
| 329 | ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize)); |
| 330 | ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings)); |
| 331 | ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor()); |
| 332 | |
| 333 | ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize)); |
| 334 | ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId)); |
| 335 | ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId)); |
| 336 | ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc)); |
| 337 | filter = mFilterTests.getFilterById(filterId); |
| 338 | ASSERT_TRUE(filter != nullptr); |
| 339 | ASSERT_TRUE(mDvrTests.attachFilterToDvr(filter)); |
| 340 | ASSERT_TRUE(mDvrTests.startDvrRecord()); |
| 341 | ASSERT_TRUE(mFilterTests.startFilter(filterId)); |
| 342 | ASSERT_TRUE(mFilterTests.stopFilter(filterId)); |
| 343 | ASSERT_TRUE(mDvrTests.stopDvrRecord()); |
| 344 | ASSERT_TRUE(mDvrTests.detachFilterToDvr(filter)); |
| 345 | ASSERT_TRUE(mFilterTests.closeFilter(filterId)); |
| 346 | mDvrTests.closeDvrRecord(); |
| 347 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 348 | |
| 349 | if (record.hasFrontendConnection) { |
| 350 | ASSERT_TRUE(mFrontendTests.closeFrontend()); |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | void TunerRecordAidlTest::recordSingleFilterTest(FilterConfig filterConf, |
Frankie Lizcano | 9c464f7 | 2022-07-18 17:56:52 +0000 | [diff] [blame] | 355 | FrontendConfig frontendConf, DvrConfig dvrConf, |
| 356 | Dataflow_Context context) { |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 357 | int32_t demuxId; |
| 358 | std::shared_ptr<IDemux> demux; |
| 359 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 360 | mDvrTests.setDemux(demux); |
| 361 | |
| 362 | DvrConfig dvrSourceConfig; |
Frankie Lizcano | 9c464f7 | 2022-07-18 17:56:52 +0000 | [diff] [blame] | 363 | if (context == Dataflow_Context::RECORD) { |
| 364 | if (record.hasFrontendConnection) { |
| 365 | int32_t feId; |
| 366 | mFrontendTests.getFrontendIdByType(frontendConf.type, feId); |
| 367 | ASSERT_TRUE(feId != INVALID_ID); |
| 368 | ASSERT_TRUE(mFrontendTests.openFrontendById(feId)); |
| 369 | ASSERT_TRUE(mFrontendTests.setFrontendCallback()); |
| 370 | if (frontendConf.isSoftwareFe) { |
| 371 | mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[record.dvrSoftwareFeId]); |
| 372 | } |
| 373 | ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId)); |
| 374 | mFrontendTests.setDvrTests(&mDvrTests); |
| 375 | } else { |
| 376 | dvrSourceConfig = dvrMap[record.dvrSourceId]; |
| 377 | ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize)); |
| 378 | ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings)); |
| 379 | ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor()); |
| 380 | } |
| 381 | } else if (context == Dataflow_Context::LNBRECORD) { |
| 382 | // If function arrives here, frontend should not be software, so no need to configure a dvr |
| 383 | // source or dvr fe connection that might be used for recording without an Lnb |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 384 | int32_t feId; |
| 385 | mFrontendTests.getFrontendIdByType(frontendConf.type, feId); |
| 386 | ASSERT_TRUE(feId != INVALID_ID); |
| 387 | ASSERT_TRUE(mFrontendTests.openFrontendById(feId)); |
| 388 | ASSERT_TRUE(mFrontendTests.setFrontendCallback()); |
Frankie Lizcano | 9c464f7 | 2022-07-18 17:56:52 +0000 | [diff] [blame] | 389 | if (mLnbId != INVALID_LNB_ID) { |
| 390 | ASSERT_TRUE(mFrontendTests.setLnb(mLnbId)); |
| 391 | } else { |
| 392 | FAIL(); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 393 | } |
| 394 | ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId)); |
| 395 | mFrontendTests.setDvrTests(&mDvrTests); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | int64_t filterId; |
| 399 | std::shared_ptr<IFilter> filter; |
| 400 | mFilterTests.setDemux(demux); |
| 401 | ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize)); |
| 402 | ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings)); |
| 403 | ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor()); |
| 404 | ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize)); |
| 405 | ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId)); |
| 406 | ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId)); |
| 407 | ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc)); |
| 408 | filter = mFilterTests.getFilterById(filterId); |
| 409 | ASSERT_TRUE(filter != nullptr); |
| 410 | mDvrTests.startRecordOutputThread(dvrConf.settings.get<DvrSettings::Tag::record>()); |
| 411 | ASSERT_TRUE(mDvrTests.attachFilterToDvr(filter)); |
| 412 | ASSERT_TRUE(mDvrTests.startDvrRecord()); |
| 413 | ASSERT_TRUE(mFilterTests.startFilter(filterId)); |
| 414 | |
Frankie Lizcano | 9c464f7 | 2022-07-18 17:56:52 +0000 | [diff] [blame] | 415 | if (context == Dataflow_Context::RECORD) { |
| 416 | if (record.hasFrontendConnection) { |
| 417 | ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/)); |
| 418 | } else { |
| 419 | // Start DVR Source |
| 420 | mDvrTests.startPlaybackInputThread( |
| 421 | dvrSourceConfig.playbackInputFile, |
| 422 | dvrSourceConfig.settings.get<DvrSettings::Tag::playback>()); |
| 423 | ASSERT_TRUE(mDvrTests.startDvrPlayback()); |
| 424 | } |
| 425 | } else if (context == Dataflow_Context::LNBRECORD) { |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 426 | ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/)); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 427 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 428 | mDvrTests.testRecordOutput(); |
| 429 | mDvrTests.stopRecordThread(); |
| 430 | |
Frankie Lizcano | 9c464f7 | 2022-07-18 17:56:52 +0000 | [diff] [blame] | 431 | if (context == Dataflow_Context::RECORD) { |
| 432 | if (record.hasFrontendConnection) { |
| 433 | ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/)); |
| 434 | } else { |
| 435 | mDvrTests.stopPlaybackThread(); |
| 436 | ASSERT_TRUE(mDvrTests.stopDvrPlayback()); |
| 437 | } |
| 438 | } else if (context == Dataflow_Context::LNBRECORD) { |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 439 | ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/)); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | ASSERT_TRUE(mFilterTests.stopFilter(filterId)); |
| 443 | ASSERT_TRUE(mDvrTests.stopDvrRecord()); |
| 444 | ASSERT_TRUE(mDvrTests.detachFilterToDvr(filter)); |
| 445 | ASSERT_TRUE(mFilterTests.closeFilter(filterId)); |
| 446 | mDvrTests.closeDvrRecord(); |
| 447 | |
Frankie Lizcano | 9c464f7 | 2022-07-18 17:56:52 +0000 | [diff] [blame] | 448 | if (context == Dataflow_Context::RECORD) { |
| 449 | if (record.hasFrontendConnection) { |
| 450 | ASSERT_TRUE(mFrontendTests.closeFrontend()); |
| 451 | } else { |
| 452 | mDvrTests.closeDvrPlayback(); |
| 453 | } |
| 454 | } else if (context == Dataflow_Context::LNBRECORD) { |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 455 | ASSERT_TRUE(mFrontendTests.closeFrontend()); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 459 | } |
| 460 | |
Ray Chin | 62ab6c9 | 2022-09-15 15:07:33 +0800 | [diff] [blame] | 461 | void TunerRecordAidlTest::setStatusCheckIntervalHintTest(int64_t statusCheckIntervalHint, |
| 462 | FrontendConfig frontendConf, |
| 463 | DvrConfig dvrConf) { |
| 464 | int32_t demuxId; |
| 465 | std::shared_ptr<IDemux> demux; |
| 466 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 467 | mDvrTests.setDemux(demux); |
| 468 | |
| 469 | DvrConfig dvrSourceConfig; |
| 470 | if (record.hasFrontendConnection) { |
| 471 | int32_t feId; |
| 472 | mFrontendTests.getFrontendIdByType(frontendConf.type, feId); |
| 473 | ASSERT_TRUE(feId != INVALID_ID); |
| 474 | ASSERT_TRUE(mFrontendTests.openFrontendById(feId)); |
| 475 | ASSERT_TRUE(mFrontendTests.setFrontendCallback()); |
| 476 | ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId)); |
| 477 | } else { |
| 478 | dvrSourceConfig = dvrMap[record.dvrSourceId]; |
| 479 | ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize)); |
| 480 | ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings)); |
| 481 | ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor()); |
| 482 | } |
| 483 | |
| 484 | ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize)); |
| 485 | ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings)); |
| 486 | ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor()); |
| 487 | |
| 488 | ASSERT_TRUE(mDvrTests.setRecordStatusCheckIntervalHint(statusCheckIntervalHint)); |
| 489 | |
| 490 | ASSERT_TRUE(mDvrTests.startDvrRecord()); |
| 491 | ASSERT_TRUE(mDvrTests.stopDvrRecord()); |
| 492 | mDvrTests.closeDvrRecord(); |
| 493 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 494 | |
| 495 | if (record.hasFrontendConnection) { |
| 496 | ASSERT_TRUE(mFrontendTests.closeFrontend()); |
| 497 | } |
| 498 | } |
| 499 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 500 | void TunerDescramblerAidlTest::scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs, |
| 501 | FrontendConfig frontendConf, |
Frankie Lizcano | 82101d2 | 2022-07-28 00:12:35 +0000 | [diff] [blame] | 502 | DescramblerConfig descConfig, |
| 503 | Dataflow_Context context) { |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 504 | int32_t demuxId; |
| 505 | std::shared_ptr<IDemux> demux; |
| 506 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 507 | |
| 508 | DvrConfig dvrSourceConfig; |
Frankie Lizcano | 82101d2 | 2022-07-28 00:12:35 +0000 | [diff] [blame] | 509 | if (context == Dataflow_Context::DESCRAMBLING) { |
| 510 | if (descrambling.hasFrontendConnection) { |
| 511 | int32_t feId; |
| 512 | mFrontendTests.getFrontendIdByType(frontendConf.type, feId); |
| 513 | ASSERT_TRUE(mFrontendTests.openFrontendById(feId)); |
| 514 | ASSERT_TRUE(mFrontendTests.setFrontendCallback()); |
| 515 | if (frontendConf.isSoftwareFe) { |
| 516 | mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[descrambling.dvrSoftwareFeId]); |
| 517 | } |
| 518 | ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId)); |
| 519 | mFrontendTests.setDemux(demux); |
| 520 | } else { |
| 521 | dvrSourceConfig = dvrMap[descrambling.dvrSourceId]; |
| 522 | mDvrTests.setDemux(demux); |
| 523 | ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize)); |
| 524 | ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings)); |
| 525 | ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor()); |
| 526 | } |
| 527 | } else if (context == Dataflow_Context::LNBDESCRAMBLING) { |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 528 | int32_t feId; |
| 529 | mFrontendTests.getFrontendIdByType(frontendConf.type, feId); |
| 530 | ASSERT_TRUE(mFrontendTests.openFrontendById(feId)); |
| 531 | ASSERT_TRUE(mFrontendTests.setFrontendCallback()); |
Frankie Lizcano | 82101d2 | 2022-07-28 00:12:35 +0000 | [diff] [blame] | 532 | if (mLnbId != INVALID_LNB_ID) { |
| 533 | ASSERT_TRUE(mFrontendTests.setLnb(mLnbId)); |
| 534 | } else { |
| 535 | // If, for some reason, the test got here without failing. We fail it here. |
| 536 | ALOGD("mLnbId is null. Something went wrong. Exiting ScrambledBroadcastWithLnbId."); |
| 537 | FAIL(); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 538 | } |
| 539 | ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId)); |
| 540 | mFrontendTests.setDemux(demux); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | set<int64_t> filterIds; |
| 544 | int64_t filterId; |
| 545 | set<struct FilterConfig>::iterator config; |
| 546 | set<int64_t>::iterator id; |
| 547 | mFilterTests.setDemux(demux); |
| 548 | for (config = mediaFilterConfs.begin(); config != mediaFilterConfs.end(); config++) { |
| 549 | ASSERT_TRUE(mFilterTests.openFilterInDemux((*config).type, (*config).bufferSize)); |
| 550 | ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId)); |
| 551 | ASSERT_TRUE(mFilterTests.configFilter((*config).settings, filterId)); |
| 552 | filterIds.insert(filterId); |
| 553 | } |
| 554 | ASSERT_TRUE(mDescramblerTests.openDescrambler(demuxId)); |
| 555 | vector<uint8_t> token; |
| 556 | ASSERT_TRUE(mDescramblerTests.getKeyToken(descConfig.casSystemId, descConfig.provisionStr, |
| 557 | descConfig.hidlPvtData, token)); |
| 558 | mDescramblerTests.setKeyToken(token); |
| 559 | vector<DemuxPid> pids; |
| 560 | DemuxPid pid; |
| 561 | for (config = mediaFilterConfs.begin(); config != mediaFilterConfs.end(); config++) { |
| 562 | ASSERT_TRUE(mDescramblerTests.getDemuxPidFromFilterSettings((*config).type, |
| 563 | (*config).settings, pid)); |
| 564 | pids.push_back(pid); |
| 565 | ASSERT_TRUE(mDescramblerTests.addPid(pid, nullptr)); |
| 566 | } |
| 567 | for (id = filterIds.begin(); id != filterIds.end(); id++) { |
| 568 | ASSERT_TRUE(mFilterTests.startFilter(*id)); |
| 569 | } |
| 570 | |
Frankie Lizcano | 82101d2 | 2022-07-28 00:12:35 +0000 | [diff] [blame] | 571 | if (context == Dataflow_Context::DESCRAMBLING) { |
| 572 | if (descrambling.hasFrontendConnection) { |
| 573 | // tune test |
| 574 | ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/)); |
| 575 | } else { |
| 576 | // Start DVR Source |
| 577 | mDvrTests.startPlaybackInputThread( |
| 578 | dvrSourceConfig.playbackInputFile, |
| 579 | dvrSourceConfig.settings.get<DvrSettings::Tag::playback>()); |
| 580 | ASSERT_TRUE(mDvrTests.startDvrPlayback()); |
| 581 | } |
| 582 | } else if (context == Dataflow_Context::LNBDESCRAMBLING) { |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 583 | ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/)); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | ASSERT_TRUE(filterDataOutputTest()); |
| 587 | |
Frankie Lizcano | 82101d2 | 2022-07-28 00:12:35 +0000 | [diff] [blame] | 588 | if (context == Dataflow_Context::DESCRAMBLING) { |
| 589 | if (descrambling.hasFrontendConnection) { |
| 590 | ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/)); |
| 591 | } else { |
| 592 | mDvrTests.stopPlaybackThread(); |
| 593 | ASSERT_TRUE(mDvrTests.stopDvrPlayback()); |
| 594 | } |
| 595 | } else if (context == Dataflow_Context::LNBDESCRAMBLING) { |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 596 | ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/)); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | for (id = filterIds.begin(); id != filterIds.end(); id++) { |
| 600 | ASSERT_TRUE(mFilterTests.stopFilter(*id)); |
| 601 | } |
| 602 | for (auto pid : pids) { |
| 603 | ASSERT_TRUE(mDescramblerTests.removePid(pid, nullptr)); |
| 604 | } |
| 605 | ASSERT_TRUE(mDescramblerTests.closeDescrambler()); |
| 606 | for (id = filterIds.begin(); id != filterIds.end(); id++) { |
| 607 | ASSERT_TRUE(mFilterTests.closeFilter(*id)); |
| 608 | } |
| 609 | |
Frankie Lizcano | 82101d2 | 2022-07-28 00:12:35 +0000 | [diff] [blame] | 610 | if (context == Dataflow_Context::DESCRAMBLING) { |
| 611 | if (descrambling.hasFrontendConnection) { |
| 612 | ASSERT_TRUE(mFrontendTests.closeFrontend()); |
| 613 | } else { |
| 614 | mDvrTests.closeDvrPlayback(); |
| 615 | } |
| 616 | } else if (context == Dataflow_Context::LNBDESCRAMBLING) { |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 617 | ASSERT_TRUE(mFrontendTests.closeFrontend()); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 621 | } |
| 622 | |
Frankie Lizcano | 82101d2 | 2022-07-28 00:12:35 +0000 | [diff] [blame] | 623 | void TunerDescramblerAidlTest::scrambledBroadcastTestWithLnb( |
| 624 | set<struct FilterConfig>& mediaFilterConfs, FrontendConfig& frontendConf, |
| 625 | DescramblerConfig& descConfig, LnbConfig& lnbConfig) { |
| 626 | // We can test the Lnb individually and make sure it functions properly. If the frontend is |
| 627 | // software, we cannot test the whole dataflow. If the frontend is hardware, we can |
| 628 | if (lnbConfig.name.compare(emptyHardwareId) == 0) { |
| 629 | vector<int32_t> ids; |
| 630 | ASSERT_TRUE(mLnbTests.getLnbIds(ids)); |
| 631 | ASSERT_TRUE(ids.size() > 0); |
| 632 | ASSERT_TRUE(mLnbTests.openLnbById(ids[0])); |
| 633 | mLnbId = ids[0]; |
| 634 | } else { |
| 635 | ASSERT_TRUE(mLnbTests.openLnbByName(lnbConfig.name, mLnbId)); |
| 636 | } |
| 637 | // Once Lnb is opened, test some of its basic functionality |
| 638 | ASSERT_TRUE(mLnbTests.setLnbCallback()); |
| 639 | ASSERT_TRUE(mLnbTests.setVoltage(lnbConfig.voltage)); |
| 640 | ASSERT_TRUE(mLnbTests.setTone(lnbConfig.tone)); |
| 641 | ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConfig.position)); |
| 642 | if (!frontendConf.isSoftwareFe) { |
| 643 | ALOGD("Frontend is not software, testing entire dataflow."); |
| 644 | scrambledBroadcastTest(mediaFilterConfs, frontendConf, descConfig, |
| 645 | Dataflow_Context::LNBDESCRAMBLING); |
| 646 | } else { |
| 647 | ALOGD("Frontend is software, did not test the entire dataflow, but tested the Lnb " |
| 648 | "individually."); |
| 649 | } |
| 650 | ASSERT_TRUE(mLnbTests.closeLnb()); |
| 651 | mLnbId = INVALID_LNB_ID; |
| 652 | } |
| 653 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 654 | TEST_P(TunerLnbAidlTest, SendDiseqcMessageToLnb) { |
| 655 | description("Open and configure an Lnb with specific settings then send a diseqc msg to it."); |
| 656 | if (!lnbLive.support) { |
| 657 | return; |
| 658 | } |
Frankie Lizcano | 1e283b3 | 2022-07-08 21:07:42 +0000 | [diff] [blame] | 659 | vector<LnbLiveHardwareConnections> lnbLive_configs = generateLnbLiveConfigurations(); |
| 660 | if (lnbLive_configs.empty()) { |
| 661 | ALOGD("No frontends that support satellites."); |
| 662 | return; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 663 | } |
Frankie Lizcano | 1e283b3 | 2022-07-08 21:07:42 +0000 | [diff] [blame] | 664 | for (auto& combination : lnbLive_configs) { |
| 665 | lnbLive = combination; |
Frankie Lizcano | 1e283b3 | 2022-07-08 21:07:42 +0000 | [diff] [blame] | 666 | if (lnbMap[lnbLive.lnbId].name.compare(emptyHardwareId) == 0) { |
| 667 | vector<int32_t> ids; |
| 668 | ASSERT_TRUE(mLnbTests.getLnbIds(ids)); |
| 669 | ASSERT_TRUE(ids.size() > 0); |
| 670 | ASSERT_TRUE(mLnbTests.openLnbById(ids[0])); |
| 671 | } else { |
| 672 | int32_t id; |
| 673 | ASSERT_TRUE(mLnbTests.openLnbByName(lnbMap[lnbLive.lnbId].name, id)); |
| 674 | } |
| 675 | ASSERT_TRUE(mLnbTests.setLnbCallback()); |
| 676 | ASSERT_TRUE(mLnbTests.setVoltage(lnbMap[lnbLive.lnbId].voltage)); |
| 677 | ASSERT_TRUE(mLnbTests.setTone(lnbMap[lnbLive.lnbId].tone)); |
| 678 | ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbMap[lnbLive.lnbId].position)); |
| 679 | for (auto msgName : lnbLive.diseqcMsgs) { |
| 680 | ASSERT_TRUE(mLnbTests.sendDiseqcMessage(diseqcMsgMap[msgName])); |
| 681 | } |
| 682 | ASSERT_TRUE(mLnbTests.closeLnb()); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 683 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | TEST_P(TunerDemuxAidlTest, openDemux) { |
| 687 | description("Open and close a Demux."); |
| 688 | if (!live.hasFrontendConnection) { |
| 689 | return; |
| 690 | } |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 691 | auto live_configs = generateLiveConfigurations(); |
| 692 | for (auto& configuration : live_configs) { |
| 693 | live = configuration; |
| 694 | int32_t feId; |
| 695 | int32_t demuxId; |
| 696 | std::shared_ptr<IDemux> demux; |
| 697 | mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId); |
| 698 | ASSERT_TRUE(feId != INVALID_ID); |
| 699 | ASSERT_TRUE(mFrontendTests.openFrontendById(feId)); |
| 700 | ASSERT_TRUE(mFrontendTests.setFrontendCallback()); |
| 701 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 702 | ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId)); |
| 703 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 704 | ASSERT_TRUE(mFrontendTests.closeFrontend()); |
| 705 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 706 | } |
| 707 | |
Kensuke Miyagi | 73b18ac | 2022-11-07 10:49:09 -0800 | [diff] [blame] | 708 | TEST_P(TunerDemuxAidlTest, openDemuxById) { |
| 709 | description("Open (with id) and close a Demux."); |
| 710 | std::vector<int32_t> demuxIds; |
| 711 | ASSERT_TRUE(mDemuxTests.getDemuxIds(demuxIds)); |
| 712 | for (int i = 0; i < demuxIds.size(); i++) { |
| 713 | std::shared_ptr<IDemux> demux; |
| 714 | ASSERT_TRUE(mDemuxTests.openDemuxById(demuxIds[i], demux)); |
| 715 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | TEST_P(TunerDemuxAidlTest, getDemuxInfo) { |
| 720 | description("Check getDemuxInfo against demux caps"); |
| 721 | std::vector<int32_t> demuxIds; |
| 722 | ASSERT_TRUE(mDemuxTests.getDemuxIds(demuxIds)); |
| 723 | int32_t combinedFilterTypes = 0; |
| 724 | for (int i = 0; i < demuxIds.size(); i++) { |
| 725 | DemuxInfo demuxInfo; |
| 726 | ASSERT_TRUE(mDemuxTests.getDemuxInfo(demuxIds[i], demuxInfo)); |
| 727 | combinedFilterTypes |= demuxInfo.filterTypes; |
| 728 | } |
| 729 | if (demuxIds.size() > 0) { |
| 730 | DemuxCapabilities demuxCaps; |
| 731 | ASSERT_TRUE(mDemuxTests.getDemuxCaps(demuxCaps)); |
| 732 | ASSERT_TRUE(demuxCaps.filterCaps == combinedFilterTypes); |
| 733 | } |
| 734 | } |
| 735 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 736 | TEST_P(TunerDemuxAidlTest, getAvSyncTime) { |
| 737 | description("Get the A/V sync time from a PCR filter."); |
| 738 | if (!live.hasFrontendConnection) { |
| 739 | return; |
| 740 | } |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 741 | auto live_configs = generateLiveConfigurations(); |
| 742 | for (auto& configuration : live_configs) { |
| 743 | live = configuration; |
| 744 | if (live.pcrFilterId.compare(emptyHardwareId) == 0) { |
| 745 | continue; |
| 746 | } |
| 747 | int32_t feId; |
| 748 | int32_t demuxId; |
| 749 | std::shared_ptr<IDemux> demux; |
| 750 | int64_t mediaFilterId; |
| 751 | int64_t pcrFilterId; |
| 752 | int32_t avSyncHwId; |
| 753 | std::shared_ptr<IFilter> mediaFilter; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 754 | |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 755 | mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId); |
| 756 | ASSERT_TRUE(feId != INVALID_ID); |
| 757 | ASSERT_TRUE(mFrontendTests.openFrontendById(feId)); |
| 758 | ASSERT_TRUE(mFrontendTests.setFrontendCallback()); |
| 759 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 760 | ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId)); |
| 761 | mFilterTests.setDemux(demux); |
| 762 | ASSERT_TRUE(mFilterTests.openFilterInDemux(filterMap[live.videoFilterId].type, |
| 763 | filterMap[live.videoFilterId].bufferSize)); |
| 764 | ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(mediaFilterId)); |
| 765 | ASSERT_TRUE( |
| 766 | mFilterTests.configFilter(filterMap[live.videoFilterId].settings, mediaFilterId)); |
| 767 | mediaFilter = mFilterTests.getFilterById(mediaFilterId); |
| 768 | ASSERT_TRUE(mFilterTests.openFilterInDemux(filterMap[live.pcrFilterId].type, |
| 769 | filterMap[live.pcrFilterId].bufferSize)); |
| 770 | ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(pcrFilterId)); |
| 771 | ASSERT_TRUE(mFilterTests.configFilter(filterMap[live.pcrFilterId].settings, pcrFilterId)); |
| 772 | ASSERT_TRUE(mDemuxTests.getAvSyncId(mediaFilter, avSyncHwId)); |
| 773 | ASSERT_TRUE(pcrFilterId == avSyncHwId); |
| 774 | ASSERT_TRUE(mDemuxTests.getAvSyncTime(pcrFilterId)); |
| 775 | ASSERT_TRUE(mFilterTests.closeFilter(pcrFilterId)); |
| 776 | ASSERT_TRUE(mFilterTests.closeFilter(mediaFilterId)); |
| 777 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 778 | ASSERT_TRUE(mFrontendTests.closeFrontend()); |
| 779 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 780 | } |
| 781 | |
| 782 | TEST_P(TunerFilterAidlTest, StartFilterInDemux) { |
| 783 | description("Open and start a filter in Demux."); |
| 784 | if (!live.hasFrontendConnection) { |
| 785 | return; |
| 786 | } |
| 787 | // TODO use parameterized tests |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 788 | auto live_configs = generateLiveConfigurations(); |
| 789 | for (auto& configuration : live_configs) { |
| 790 | live = configuration; |
| 791 | configSingleFilterInDemuxTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]); |
| 792 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | TEST_P(TunerFilterAidlTest, ConfigIpFilterInDemuxWithCid) { |
| 796 | description("Open and configure an ip filter in Demux."); |
| 797 | // TODO use parameterized tests |
| 798 | if (!live.hasFrontendConnection) { |
| 799 | return; |
| 800 | } |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 801 | auto live_configs = generateLiveConfigurations(); |
| 802 | for (auto& configuration : live_configs) { |
| 803 | live = configuration; |
| 804 | if (live.ipFilterId.compare(emptyHardwareId) == 0) { |
| 805 | continue; |
| 806 | } |
| 807 | configSingleFilterInDemuxTest(filterMap[live.ipFilterId], frontendMap[live.frontendId]); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 808 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 809 | } |
| 810 | |
| 811 | TEST_P(TunerFilterAidlTest, ReconfigFilterToReceiveStartId) { |
| 812 | description("Recofigure and restart a filter to test start id."); |
| 813 | if (!live.hasFrontendConnection) { |
| 814 | return; |
| 815 | } |
| 816 | // TODO use parameterized tests |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 817 | auto live_configs = generateLiveConfigurations(); |
| 818 | for (auto& configuration : live_configs) { |
| 819 | live = configuration; |
| 820 | reconfigSingleFilterInDemuxTest(filterMap[live.videoFilterId], |
| 821 | filterMap[live.videoFilterId], |
| 822 | frontendMap[live.frontendId]); |
| 823 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 824 | } |
| 825 | |
| 826 | TEST_P(TunerFilterAidlTest, SetFilterLinkage) { |
| 827 | description("Pick up all the possible linkages from the demux caps and set them up."); |
| 828 | DemuxCapabilities caps; |
| 829 | int32_t demuxId; |
| 830 | std::shared_ptr<IDemux> demux; |
| 831 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 832 | ASSERT_TRUE(mDemuxTests.getDemuxCaps(caps)); |
| 833 | mFilterTests.setDemux(demux); |
| 834 | for (int i = 0; i < caps.linkCaps.size(); i++) { |
| 835 | uint32_t bitMask = 1; |
| 836 | for (int j = 0; j < FILTER_MAIN_TYPE_BIT_COUNT; j++) { |
| 837 | if (caps.linkCaps[i] & (bitMask << j)) { |
| 838 | int64_t sourceFilterId; |
| 839 | int64_t sinkFilterId; |
| 840 | ASSERT_TRUE(mFilterTests.openFilterInDemux(getLinkageFilterType(i), FMQ_SIZE_16M)); |
| 841 | ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(sourceFilterId)); |
| 842 | ASSERT_TRUE(mFilterTests.openFilterInDemux(getLinkageFilterType(j), FMQ_SIZE_16M)); |
| 843 | ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(sinkFilterId)); |
| 844 | ASSERT_TRUE(mFilterTests.setFilterDataSource(sourceFilterId, sinkFilterId)); |
| 845 | ASSERT_TRUE(mFilterTests.setFilterDataSourceToDemux(sinkFilterId)); |
| 846 | ASSERT_TRUE(mFilterTests.closeFilter(sinkFilterId)); |
| 847 | ASSERT_TRUE(mFilterTests.closeFilter(sourceFilterId)); |
| 848 | } |
| 849 | } |
| 850 | } |
| 851 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 852 | } |
| 853 | |
| 854 | TEST_P(TunerFilterAidlTest, testTimeFilter) { |
| 855 | description("Open a timer filter in Demux and set time stamp."); |
| 856 | if (!timeFilter.support) { |
| 857 | return; |
| 858 | } |
| 859 | // TODO use parameterized tests |
Frankie Lizcano | 0c06953 | 2022-07-14 20:20:46 +0000 | [diff] [blame] | 860 | auto timeFilter_configs = generateTimeFilterConfigurations(); |
| 861 | for (auto& configuration : timeFilter_configs) { |
| 862 | timeFilter = configuration; |
| 863 | testTimeFilter(timeFilterMap[timeFilter.timeFilterId]); |
| 864 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 865 | } |
| 866 | |
Gareth Fenn | 9a80845 | 2022-03-31 08:40:00 +0100 | [diff] [blame] | 867 | static bool isEventProducingFilter(const FilterConfig& filterConfig) { |
| 868 | switch (filterConfig.type.mainType) { |
| 869 | case DemuxFilterMainType::TS: { |
| 870 | auto tsFilterType = |
| 871 | filterConfig.type.subType.get<DemuxFilterSubType::Tag::tsFilterType>(); |
| 872 | return (tsFilterType == DemuxTsFilterType::SECTION || |
| 873 | tsFilterType == DemuxTsFilterType::PES || |
| 874 | tsFilterType == DemuxTsFilterType::AUDIO || |
| 875 | tsFilterType == DemuxTsFilterType::VIDEO || |
| 876 | tsFilterType == DemuxTsFilterType::RECORD || |
| 877 | tsFilterType == DemuxTsFilterType::TEMI); |
| 878 | } |
| 879 | case DemuxFilterMainType::MMTP: { |
| 880 | auto mmtpFilterType = |
| 881 | filterConfig.type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>(); |
| 882 | return (mmtpFilterType == DemuxMmtpFilterType::SECTION || |
| 883 | mmtpFilterType == DemuxMmtpFilterType::PES || |
| 884 | mmtpFilterType == DemuxMmtpFilterType::AUDIO || |
| 885 | mmtpFilterType == DemuxMmtpFilterType::VIDEO || |
| 886 | mmtpFilterType == DemuxMmtpFilterType::RECORD || |
| 887 | mmtpFilterType == DemuxMmtpFilterType::DOWNLOAD); |
| 888 | } |
| 889 | case DemuxFilterMainType::IP: { |
| 890 | auto ipFilterType = |
| 891 | filterConfig.type.subType.get<DemuxFilterSubType::Tag::ipFilterType>(); |
| 892 | return (ipFilterType == DemuxIpFilterType::SECTION); |
| 893 | } |
| 894 | case DemuxFilterMainType::TLV: { |
| 895 | auto tlvFilterType = |
| 896 | filterConfig.type.subType.get<DemuxFilterSubType::Tag::tlvFilterType>(); |
| 897 | return (tlvFilterType == DemuxTlvFilterType::SECTION); |
| 898 | } |
| 899 | case DemuxFilterMainType::ALP: { |
| 900 | auto alpFilterType = |
| 901 | filterConfig.type.subType.get<DemuxFilterSubType::Tag::alpFilterType>(); |
| 902 | return (alpFilterType == DemuxAlpFilterType::SECTION); |
| 903 | } |
| 904 | default: |
| 905 | return false; |
| 906 | } |
| 907 | } |
| 908 | |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 909 | static bool isMediaFilter(const FilterConfig& filterConfig) { |
| 910 | switch (filterConfig.type.mainType) { |
| 911 | case DemuxFilterMainType::TS: { |
| 912 | // TS Audio and Video filters are media filters |
| 913 | auto tsFilterType = |
| 914 | filterConfig.type.subType.get<DemuxFilterSubType::Tag::tsFilterType>(); |
| 915 | return (tsFilterType == DemuxTsFilterType::AUDIO || |
| 916 | tsFilterType == DemuxTsFilterType::VIDEO); |
| 917 | } |
| 918 | case DemuxFilterMainType::MMTP: { |
| 919 | // MMTP Audio and Video filters are media filters |
| 920 | auto mmtpFilterType = |
| 921 | filterConfig.type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>(); |
| 922 | return (mmtpFilterType == DemuxMmtpFilterType::AUDIO || |
| 923 | mmtpFilterType == DemuxMmtpFilterType::VIDEO); |
| 924 | } |
| 925 | default: |
| 926 | return false; |
| 927 | } |
| 928 | } |
Patrick Rohr | 149b087 | 2021-11-20 00:39:37 +0100 | [diff] [blame] | 929 | |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 930 | static int getDemuxFilterEventDataLength(const DemuxFilterEvent& event) { |
| 931 | switch (event.getTag()) { |
| 932 | case DemuxFilterEvent::Tag::section: |
| 933 | return event.get<DemuxFilterEvent::Tag::section>().dataLength; |
| 934 | case DemuxFilterEvent::Tag::media: |
| 935 | return event.get<DemuxFilterEvent::Tag::media>().dataLength; |
| 936 | case DemuxFilterEvent::Tag::pes: |
| 937 | return event.get<DemuxFilterEvent::Tag::pes>().dataLength; |
| 938 | case DemuxFilterEvent::Tag::download: |
| 939 | return event.get<DemuxFilterEvent::Tag::download>().dataLength; |
| 940 | case DemuxFilterEvent::Tag::ipPayload: |
| 941 | return event.get<DemuxFilterEvent::Tag::ipPayload>().dataLength; |
| 942 | |
| 943 | case DemuxFilterEvent::Tag::tsRecord: |
| 944 | case DemuxFilterEvent::Tag::mmtpRecord: |
| 945 | case DemuxFilterEvent::Tag::temi: |
| 946 | case DemuxFilterEvent::Tag::monitorEvent: |
| 947 | case DemuxFilterEvent::Tag::startId: |
| 948 | return 0; |
| 949 | } |
| 950 | } |
| 951 | |
| 952 | // TODO: move boilerplate into text fixture |
| 953 | void TunerFilterAidlTest::testDelayHint(const FilterConfig& filterConf) { |
Gareth Fenn | 9a80845 | 2022-03-31 08:40:00 +0100 | [diff] [blame] | 954 | if (!filterConf.timeDelayInMs && !filterConf.dataDelayInBytes) { |
| 955 | return; |
| 956 | } |
| 957 | if (!isEventProducingFilter(filterConf)) { |
| 958 | return; |
| 959 | } |
Patrick Rohr | 149b087 | 2021-11-20 00:39:37 +0100 | [diff] [blame] | 960 | int32_t feId; |
| 961 | int32_t demuxId; |
| 962 | std::shared_ptr<IDemux> demux; |
| 963 | int64_t filterId; |
| 964 | |
| 965 | mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId); |
| 966 | ASSERT_TRUE(feId != INVALID_ID); |
| 967 | ASSERT_TRUE(mFrontendTests.openFrontendById(feId)); |
| 968 | ASSERT_TRUE(mFrontendTests.setFrontendCallback()); |
| 969 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
| 970 | ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId)); |
| 971 | mFilterTests.setDemux(demux); |
| 972 | |
Patrick Rohr | 149b087 | 2021-11-20 00:39:37 +0100 | [diff] [blame] | 973 | ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize)); |
| 974 | ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId)); |
Patrick Rohr | 149b087 | 2021-11-20 00:39:37 +0100 | [diff] [blame] | 975 | |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 976 | bool mediaFilter = isMediaFilter(filterConf); |
Patrick Rohr | 149b087 | 2021-11-20 00:39:37 +0100 | [diff] [blame] | 977 | auto filter = mFilterTests.getFilterById(filterId); |
| 978 | |
Patrick Rohr | 2b0e9ee | 2021-12-27 13:55:16 +0100 | [diff] [blame] | 979 | // startTime needs to be set before calling setDelayHint. |
| 980 | auto startTime = std::chrono::steady_clock::now(); |
| 981 | |
Gareth Fenn | 9a80845 | 2022-03-31 08:40:00 +0100 | [diff] [blame] | 982 | int timeDelayInMs = filterConf.timeDelayInMs; |
| 983 | if (timeDelayInMs > 0) { |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 984 | FilterDelayHint delayHint; |
| 985 | delayHint.hintType = FilterDelayHintType::TIME_DELAY_IN_MS; |
Gareth Fenn | 9a80845 | 2022-03-31 08:40:00 +0100 | [diff] [blame] | 986 | delayHint.hintValue = timeDelayInMs; |
Patrick Rohr | 149b087 | 2021-11-20 00:39:37 +0100 | [diff] [blame] | 987 | |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 988 | // setDelayHint should fail for media filters. |
| 989 | ASSERT_EQ(filter->setDelayHint(delayHint).isOk(), !mediaFilter); |
| 990 | } |
Patrick Rohr | 149b087 | 2021-11-20 00:39:37 +0100 | [diff] [blame] | 991 | |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 992 | int dataDelayInBytes = filterConf.dataDelayInBytes; |
| 993 | if (dataDelayInBytes > 0) { |
| 994 | FilterDelayHint delayHint; |
| 995 | delayHint.hintType = FilterDelayHintType::DATA_SIZE_DELAY_IN_BYTES; |
| 996 | delayHint.hintValue = dataDelayInBytes; |
Patrick Rohr | 149b087 | 2021-11-20 00:39:37 +0100 | [diff] [blame] | 997 | |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 998 | // setDelayHint should fail for media filters. |
| 999 | ASSERT_EQ(filter->setDelayHint(delayHint).isOk(), !mediaFilter); |
| 1000 | } |
Patrick Rohr | 149b087 | 2021-11-20 00:39:37 +0100 | [diff] [blame] | 1001 | |
Patrick Rohr | 2b0e9ee | 2021-12-27 13:55:16 +0100 | [diff] [blame] | 1002 | // start and stop filter (and wait for first callback) in order to |
| 1003 | // circumvent callback scheduler race conditions after adjusting filter |
| 1004 | // delays. |
| 1005 | auto cb = mFilterTests.getFilterCallbacks().at(filterId); |
| 1006 | auto future = |
| 1007 | cb->verifyFilterCallback([](const std::vector<DemuxFilterEvent>&) { return true; }); |
Gareth Fenn | 9a80845 | 2022-03-31 08:40:00 +0100 | [diff] [blame] | 1008 | |
| 1009 | // The configure stage can also produce events, so we should set the delay |
| 1010 | // hint beforehand. |
| 1011 | ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId)); |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 1012 | mFilterTests.startFilter(filterId); |
Patrick Rohr | 2b0e9ee | 2021-12-27 13:55:16 +0100 | [diff] [blame] | 1013 | |
| 1014 | auto timeout = std::chrono::seconds(30); |
| 1015 | ASSERT_EQ(future.wait_for(timeout), std::future_status::ready); |
| 1016 | |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 1017 | mFilterTests.stopFilter(filterId); |
Patrick Rohr | 149b087 | 2021-11-20 00:39:37 +0100 | [diff] [blame] | 1018 | |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 1019 | if (!mediaFilter) { |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 1020 | int callbackSize = 0; |
Patrick Rohr | 2b0e9ee | 2021-12-27 13:55:16 +0100 | [diff] [blame] | 1021 | future = cb->verifyFilterCallback( |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 1022 | [&callbackSize](const std::vector<DemuxFilterEvent>& events) { |
| 1023 | for (const auto& event : events) { |
| 1024 | callbackSize += getDemuxFilterEventDataLength(event); |
| 1025 | } |
| 1026 | return true; |
| 1027 | }); |
| 1028 | |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 1029 | ASSERT_TRUE(mFilterTests.startFilter(filterId)); |
| 1030 | |
| 1031 | // block and wait for callback to be received. |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 1032 | ASSERT_EQ(future.wait_for(timeout), std::future_status::ready); |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 1033 | |
Gareth Fenn | 9a80845 | 2022-03-31 08:40:00 +0100 | [diff] [blame] | 1034 | auto duration = std::chrono::steady_clock::now() - startTime; |
| 1035 | bool delayHintTest = duration >= std::chrono::milliseconds(timeDelayInMs); |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 1036 | bool dataSizeTest = callbackSize >= dataDelayInBytes; |
| 1037 | |
Gareth Fenn | 9a80845 | 2022-03-31 08:40:00 +0100 | [diff] [blame] | 1038 | if (timeDelayInMs > 0 && dataDelayInBytes > 0) { |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 1039 | ASSERT_TRUE(delayHintTest || dataSizeTest); |
| 1040 | } else { |
| 1041 | // if only one of time delay / data delay is configured, one of them |
| 1042 | // holds true by default, so we want both assertions to be true. |
| 1043 | ASSERT_TRUE(delayHintTest && dataSizeTest); |
| 1044 | } |
| 1045 | |
| 1046 | ASSERT_TRUE(mFilterTests.stopFilter(filterId)); |
| 1047 | } |
| 1048 | |
Patrick Rohr | 149b087 | 2021-11-20 00:39:37 +0100 | [diff] [blame] | 1049 | ASSERT_TRUE(mFilterTests.closeFilter(filterId)); |
| 1050 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 1051 | ASSERT_TRUE(mFrontendTests.closeFrontend()); |
| 1052 | } |
| 1053 | |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 1054 | TEST_P(TunerFilterAidlTest, FilterDelayHintTest) { |
| 1055 | description("Test filter time delay hint."); |
Gareth Fenn | 9a80845 | 2022-03-31 08:40:00 +0100 | [diff] [blame] | 1056 | if (!live.hasFrontendConnection) { |
| 1057 | return; |
| 1058 | } |
Patrick Rohr | 1586d21 | 2021-11-23 00:40:56 +0100 | [diff] [blame] | 1059 | for (const auto& obj : filterMap) { |
| 1060 | testDelayHint(obj.second); |
| 1061 | } |
| 1062 | } |
| 1063 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1064 | TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsSectionFilterTest) { |
| 1065 | description("Feed ts data from playback and configure Ts section filter to get output"); |
Frankie Lizcano | a53f554 | 2022-07-07 17:32:06 +0000 | [diff] [blame] | 1066 | if (!playback.support) { |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1067 | return; |
| 1068 | } |
Frankie Lizcano | a53f554 | 2022-07-07 17:32:06 +0000 | [diff] [blame] | 1069 | vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs(); |
| 1070 | for (auto& configuration : playback_configs) { |
| 1071 | if (configuration.sectionFilterId.compare(emptyHardwareId) != 0) { |
| 1072 | playback = configuration; |
| 1073 | playbackSingleFilterTest(filterMap[playback.sectionFilterId], dvrMap[playback.dvrId]); |
| 1074 | } |
| 1075 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1076 | } |
| 1077 | |
| 1078 | TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsAudioFilterTest) { |
| 1079 | description("Feed ts data from playback and configure Ts audio filter to get output"); |
| 1080 | if (!playback.support) { |
| 1081 | return; |
| 1082 | } |
Frankie Lizcano | a53f554 | 2022-07-07 17:32:06 +0000 | [diff] [blame] | 1083 | vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs(); |
| 1084 | for (auto& configuration : playback_configs) { |
| 1085 | playback = configuration; |
| 1086 | playbackSingleFilterTest(filterMap[playback.audioFilterId], dvrMap[playback.dvrId]); |
| 1087 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1088 | } |
| 1089 | |
| 1090 | TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsVideoFilterTest) { |
| 1091 | description("Feed ts data from playback and configure Ts video filter to get output"); |
| 1092 | if (!playback.support) { |
| 1093 | return; |
| 1094 | } |
Frankie Lizcano | a53f554 | 2022-07-07 17:32:06 +0000 | [diff] [blame] | 1095 | vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs(); |
| 1096 | for (auto& configuration : playback_configs) { |
| 1097 | playback = configuration; |
| 1098 | playbackSingleFilterTest(filterMap[playback.videoFilterId], dvrMap[playback.dvrId]); |
| 1099 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1100 | } |
| 1101 | |
Ray Chin | 62ab6c9 | 2022-09-15 15:07:33 +0800 | [diff] [blame] | 1102 | TEST_P(TunerPlaybackAidlTest, SetStatusCheckIntervalHintToPlaybackTest) { |
| 1103 | description("Set status check interval hint to playback test."); |
| 1104 | if (!playback.support) { |
| 1105 | return; |
| 1106 | } |
| 1107 | vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs(); |
| 1108 | for (auto& configuration : playback_configs) { |
| 1109 | playback = configuration; |
| 1110 | setStatusCheckIntervalHintTest(STATUS_CHECK_INTERVAL_MS, dvrMap[playback.dvrId]); |
| 1111 | } |
| 1112 | } |
| 1113 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1114 | TEST_P(TunerRecordAidlTest, RecordDataFlowWithTsRecordFilterTest) { |
| 1115 | description("Feed ts data from frontend to recording and test with ts record filter"); |
| 1116 | if (!record.support) { |
| 1117 | return; |
| 1118 | } |
sadiqsada | db9c51a | 2024-01-18 13:49:09 -0800 | [diff] [blame] | 1119 | // Recording is not currently supported for IPTV frontend |
sadiqsada | 7a19139 | 2023-11-07 16:09:09 -0800 | [diff] [blame] | 1120 | if (frontendMap[live.frontendId].type == FrontendType::IPTV) { |
| 1121 | return; |
| 1122 | } |
Frankie Lizcano | 9c464f7 | 2022-07-18 17:56:52 +0000 | [diff] [blame] | 1123 | auto record_configs = generateRecordConfigurations(); |
| 1124 | for (auto& configuration : record_configs) { |
| 1125 | record = configuration; |
| 1126 | recordSingleFilterTest(filterMap[record.recordFilterId], frontendMap[record.frontendId], |
| 1127 | dvrMap[record.dvrRecordId], Dataflow_Context::RECORD); |
| 1128 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1129 | } |
| 1130 | |
| 1131 | TEST_P(TunerRecordAidlTest, AttachFiltersToRecordTest) { |
| 1132 | description("Attach a single filter to the record dvr test."); |
| 1133 | // TODO use parameterized tests |
| 1134 | if (!record.support) { |
| 1135 | return; |
| 1136 | } |
sadiqsada | db9c51a | 2024-01-18 13:49:09 -0800 | [diff] [blame] | 1137 | // Recording is not currently supported for IPTV frontend |
sadiqsada | 7a19139 | 2023-11-07 16:09:09 -0800 | [diff] [blame] | 1138 | if (frontendMap[live.frontendId].type == FrontendType::IPTV) { |
| 1139 | return; |
| 1140 | } |
Frankie Lizcano | 9c464f7 | 2022-07-18 17:56:52 +0000 | [diff] [blame] | 1141 | auto record_configs = generateRecordConfigurations(); |
| 1142 | for (auto& configuration : record_configs) { |
| 1143 | record = configuration; |
| 1144 | attachSingleFilterToRecordDvrTest(filterMap[record.recordFilterId], |
| 1145 | frontendMap[record.frontendId], |
| 1146 | dvrMap[record.dvrRecordId]); |
| 1147 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1148 | } |
| 1149 | |
| 1150 | TEST_P(TunerRecordAidlTest, LnbRecordDataFlowWithTsRecordFilterTest) { |
| 1151 | description("Feed ts data from Fe with Lnb to recording and test with ts record filter"); |
| 1152 | if (!lnbRecord.support) { |
| 1153 | return; |
| 1154 | } |
Frankie Lizcano | ecba02a | 2022-07-12 17:56:54 +0000 | [diff] [blame] | 1155 | vector<LnbRecordHardwareConnections> lnbRecord_configs = generateLnbRecordConfigurations(); |
| 1156 | if (lnbRecord_configs.empty()) { |
| 1157 | ALOGD("No frontends that support satellites."); |
| 1158 | return; |
| 1159 | } |
| 1160 | for (auto& configuration : lnbRecord_configs) { |
| 1161 | lnbRecord = configuration; |
| 1162 | recordSingleFilterTestWithLnb(filterMap[lnbRecord.recordFilterId], |
| 1163 | frontendMap[lnbRecord.frontendId], |
| 1164 | dvrMap[lnbRecord.dvrRecordId], lnbMap[lnbRecord.lnbId]); |
| 1165 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1166 | } |
| 1167 | |
Ray Chin | 62ab6c9 | 2022-09-15 15:07:33 +0800 | [diff] [blame] | 1168 | TEST_P(TunerRecordAidlTest, SetStatusCheckIntervalHintToRecordTest) { |
| 1169 | description("Set status check interval hint to record test."); |
| 1170 | if (!record.support) { |
| 1171 | return; |
| 1172 | } |
sadiqsada | db9c51a | 2024-01-18 13:49:09 -0800 | [diff] [blame] | 1173 | // Recording is not currently supported for IPTV frontend |
sadiqsada | 7a19139 | 2023-11-07 16:09:09 -0800 | [diff] [blame] | 1174 | if (frontendMap[live.frontendId].type == FrontendType::IPTV) { |
| 1175 | return; |
| 1176 | } |
Ray Chin | 62ab6c9 | 2022-09-15 15:07:33 +0800 | [diff] [blame] | 1177 | auto record_configs = generateRecordConfigurations(); |
| 1178 | for (auto& configuration : record_configs) { |
| 1179 | record = configuration; |
| 1180 | setStatusCheckIntervalHintTest(STATUS_CHECK_INTERVAL_MS, frontendMap[record.frontendId], |
| 1181 | dvrMap[record.dvrRecordId]); |
| 1182 | } |
| 1183 | } |
| 1184 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1185 | TEST_P(TunerFrontendAidlTest, TuneFrontend) { |
| 1186 | description("Tune one Frontend with specific setting and check Lock event"); |
| 1187 | if (!live.hasFrontendConnection) { |
| 1188 | return; |
| 1189 | } |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 1190 | auto live_configs = generateLiveConfigurations(); |
| 1191 | for (auto& configuration : live_configs) { |
| 1192 | live = configuration; |
| 1193 | mFrontendTests.tuneTest(frontendMap[live.frontendId]); |
| 1194 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1195 | } |
| 1196 | |
| 1197 | TEST_P(TunerFrontendAidlTest, AutoScanFrontend) { |
| 1198 | description("Run an auto frontend scan with specific setting and check lock scanMessage"); |
| 1199 | if (!scan.hasFrontendConnection) { |
| 1200 | return; |
| 1201 | } |
Frankie Lizcano | 3138d6b | 2022-07-11 22:06:45 +0000 | [diff] [blame] | 1202 | vector<ScanHardwareConnections> scan_configs = generateScanConfigurations(); |
| 1203 | for (auto& configuration : scan_configs) { |
| 1204 | scan = configuration; |
| 1205 | mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_AUTO); |
| 1206 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1207 | } |
| 1208 | |
| 1209 | TEST_P(TunerFrontendAidlTest, BlindScanFrontend) { |
| 1210 | description("Run an blind frontend scan with specific setting and check lock scanMessage"); |
| 1211 | if (!scan.hasFrontendConnection) { |
| 1212 | return; |
| 1213 | } |
sadiqsada | 7a19139 | 2023-11-07 16:09:09 -0800 | [diff] [blame] | 1214 | // Blind scan is not applicable for IPTV frontend |
| 1215 | if (frontendMap[live.frontendId].type == FrontendType::IPTV) { |
| 1216 | return; |
| 1217 | } |
Frankie Lizcano | 3138d6b | 2022-07-11 22:06:45 +0000 | [diff] [blame] | 1218 | vector<ScanHardwareConnections> scan_configs = generateScanConfigurations(); |
| 1219 | for (auto& configuration : scan_configs) { |
| 1220 | scan = configuration; |
Ray Chin | 740a0a8 | 2023-12-22 19:10:46 +0800 | [diff] [blame] | 1221 | // Skip test if the frontend implementation doesn't support blind scan |
| 1222 | if (!frontendMap[scan.frontendId].supportBlindScan) { |
| 1223 | continue; |
| 1224 | } |
Frankie Lizcano | 3138d6b | 2022-07-11 22:06:45 +0000 | [diff] [blame] | 1225 | mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_BLIND); |
| 1226 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1227 | } |
| 1228 | |
| 1229 | TEST_P(TunerFrontendAidlTest, TuneFrontendWithFrontendSettings) { |
| 1230 | description("Tune one Frontend with setting and check Lock event"); |
| 1231 | if (!live.hasFrontendConnection) { |
| 1232 | return; |
| 1233 | } |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 1234 | auto live_configs = generateLiveConfigurations(); |
| 1235 | for (auto& configuration : live_configs) { |
| 1236 | live = configuration; |
| 1237 | mFrontendTests.tuneTest(frontendMap[live.frontendId]); |
| 1238 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1239 | } |
| 1240 | |
| 1241 | TEST_P(TunerFrontendAidlTest, BlindScanFrontendWithEndFrequency) { |
| 1242 | description("Run an blind frontend scan with setting and check lock scanMessage"); |
| 1243 | if (!scan.hasFrontendConnection) { |
| 1244 | return; |
| 1245 | } |
sadiqsada | 7a19139 | 2023-11-07 16:09:09 -0800 | [diff] [blame] | 1246 | // Blind scan is not application for IPTV frontend |
| 1247 | if (frontendMap[live.frontendId].type == FrontendType::IPTV) { |
| 1248 | return; |
| 1249 | } |
Frankie Lizcano | 3138d6b | 2022-07-11 22:06:45 +0000 | [diff] [blame] | 1250 | vector<ScanHardwareConnections> scan_configs = generateScanConfigurations(); |
| 1251 | for (auto& configuration : scan_configs) { |
| 1252 | scan = configuration; |
Ray Chin | 740a0a8 | 2023-12-22 19:10:46 +0800 | [diff] [blame] | 1253 | // Skip test if the frontend implementation doesn't support blind scan |
| 1254 | if (!frontendMap[scan.frontendId].supportBlindScan) { |
| 1255 | continue; |
| 1256 | } |
Frankie Lizcano | 3138d6b | 2022-07-11 22:06:45 +0000 | [diff] [blame] | 1257 | mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_BLIND); |
| 1258 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1259 | } |
| 1260 | |
| 1261 | TEST_P(TunerFrontendAidlTest, LinkToCiCam) { |
| 1262 | description("Test Frontend link to CiCam"); |
| 1263 | if (!live.hasFrontendConnection) { |
| 1264 | return; |
| 1265 | } |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 1266 | auto live_configs = generateLiveConfigurations(); |
| 1267 | for (auto& configuration : live_configs) { |
| 1268 | live = configuration; |
| 1269 | if (!frontendMap[live.frontendId].canConnectToCiCam) { |
| 1270 | continue; |
| 1271 | } |
| 1272 | mFrontendTests.tuneTest(frontendMap[live.frontendId]); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1273 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1274 | } |
| 1275 | |
Hongguang | fcedda0 | 2021-12-13 17:08:02 -0800 | [diff] [blame] | 1276 | TEST_P(TunerFrontendAidlTest, getHardwareInfo) { |
| 1277 | description("Test Frontend get hardware info"); |
| 1278 | if (!live.hasFrontendConnection) { |
| 1279 | return; |
| 1280 | } |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 1281 | auto live_configs = generateLiveConfigurations(); |
| 1282 | for (auto& configuration : live_configs) { |
| 1283 | live = configuration; |
| 1284 | mFrontendTests.debugInfoTest(frontendMap[live.frontendId]); |
| 1285 | } |
Hongguang | fcedda0 | 2021-12-13 17:08:02 -0800 | [diff] [blame] | 1286 | } |
| 1287 | |
Hongguang | 5766ddf | 2021-12-23 11:40:37 -0800 | [diff] [blame] | 1288 | TEST_P(TunerFrontendAidlTest, maxNumberOfFrontends) { |
| 1289 | description("Test Max Frontend number"); |
| 1290 | if (!live.hasFrontendConnection) { |
| 1291 | return; |
| 1292 | } |
| 1293 | mFrontendTests.maxNumberOfFrontendsTest(); |
| 1294 | } |
| 1295 | |
Hongguang | 881190f | 2022-01-14 13:23:37 -0800 | [diff] [blame] | 1296 | TEST_P(TunerFrontendAidlTest, statusReadinessTest) { |
| 1297 | description("Test Max Frontend status readiness"); |
| 1298 | if (!live.hasFrontendConnection) { |
| 1299 | return; |
| 1300 | } |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 1301 | auto live_configs = generateLiveConfigurations(); |
| 1302 | for (auto& configuration : live_configs) { |
| 1303 | live = configuration; |
| 1304 | mFrontendTests.statusReadinessTest(frontendMap[live.frontendId]); |
| 1305 | } |
Hongguang | 881190f | 2022-01-14 13:23:37 -0800 | [diff] [blame] | 1306 | } |
| 1307 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1308 | TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowVideoFilterTest) { |
| 1309 | description("Test Video Filter functionality in Broadcast use case."); |
| 1310 | if (!live.hasFrontendConnection) { |
| 1311 | return; |
| 1312 | } |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 1313 | auto live_configs = generateLiveConfigurations(); |
| 1314 | for (auto& configuration : live_configs) { |
| 1315 | live = configuration; |
| 1316 | broadcastSingleFilterTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]); |
| 1317 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1318 | } |
| 1319 | |
| 1320 | TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowAudioFilterTest) { |
| 1321 | description("Test Audio Filter functionality in Broadcast use case."); |
| 1322 | if (!live.hasFrontendConnection) { |
| 1323 | return; |
| 1324 | } |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 1325 | auto live_configs = generateLiveConfigurations(); |
| 1326 | for (auto& configuration : live_configs) { |
| 1327 | live = configuration; |
| 1328 | broadcastSingleFilterTest(filterMap[live.audioFilterId], frontendMap[live.frontendId]); |
| 1329 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1330 | } |
| 1331 | |
| 1332 | TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowSectionFilterTest) { |
| 1333 | description("Test Section Filter functionality in Broadcast use case."); |
| 1334 | if (!live.hasFrontendConnection) { |
| 1335 | return; |
| 1336 | } |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 1337 | auto live_configs = generateLiveConfigurations(); |
| 1338 | for (auto& configuration : live_configs) { |
| 1339 | live = configuration; |
| 1340 | if (live.sectionFilterId.compare(emptyHardwareId) == 0) { |
| 1341 | continue; |
| 1342 | } |
| 1343 | broadcastSingleFilterTest(filterMap[live.sectionFilterId], frontendMap[live.frontendId]); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1344 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1345 | } |
| 1346 | |
| 1347 | TEST_P(TunerBroadcastAidlTest, IonBufferTest) { |
| 1348 | description("Test the av filter data bufferring."); |
| 1349 | if (!live.hasFrontendConnection) { |
| 1350 | return; |
| 1351 | } |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 1352 | auto live_configs = generateLiveConfigurations(); |
| 1353 | for (auto& configuration : live_configs) { |
| 1354 | live = configuration; |
| 1355 | broadcastSingleFilterTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]); |
| 1356 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1357 | } |
| 1358 | |
| 1359 | TEST_P(TunerBroadcastAidlTest, LnbBroadcastDataFlowVideoFilterTest) { |
| 1360 | description("Test Video Filter functionality in Broadcast with Lnb use case."); |
| 1361 | if (!lnbLive.support) { |
| 1362 | return; |
| 1363 | } |
Frankie Lizcano | 1e283b3 | 2022-07-08 21:07:42 +0000 | [diff] [blame] | 1364 | vector<LnbLiveHardwareConnections> lnbLive_configs = generateLnbLiveConfigurations(); |
| 1365 | if (lnbLive_configs.empty()) { |
| 1366 | ALOGD("No frontends that support satellites."); |
| 1367 | return; |
| 1368 | } |
| 1369 | for (auto& combination : lnbLive_configs) { |
| 1370 | lnbLive = combination; |
| 1371 | broadcastSingleFilterTestWithLnb(filterMap[lnbLive.videoFilterId], |
| 1372 | frontendMap[lnbLive.frontendId], lnbMap[lnbLive.lnbId]); |
| 1373 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1374 | } |
| 1375 | |
| 1376 | TEST_P(TunerBroadcastAidlTest, MediaFilterWithSharedMemoryHandle) { |
| 1377 | description("Test the Media Filter with shared memory handle"); |
| 1378 | if (!live.hasFrontendConnection) { |
| 1379 | return; |
| 1380 | } |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 1381 | auto live_configs = generateLiveConfigurations(); |
| 1382 | for (auto& configuration : live_configs) { |
| 1383 | live = configuration; |
Ray Chin | 967c8e8 | 2024-12-24 12:27:27 +0800 | [diff] [blame] | 1384 | // shared memory handle is not used by a passthrough filter at all |
| 1385 | if (isPassthroughFilter(filterMap[live.videoFilterId])) { |
| 1386 | continue; |
| 1387 | } |
Frankie Lizcano | 8b87f25 | 2022-07-19 21:51:54 +0000 | [diff] [blame] | 1388 | mediaFilterUsingSharedMemoryTest(filterMap[live.videoFilterId], |
| 1389 | frontendMap[live.frontendId]); |
| 1390 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1391 | } |
| 1392 | |
| 1393 | TEST_P(TunerDescramblerAidlTest, CreateDescrambler) { |
| 1394 | description("Create Descrambler"); |
| 1395 | if (!descrambling.support) { |
| 1396 | return; |
| 1397 | } |
Frankie Lizcano | f4e0796 | 2022-07-13 20:54:34 +0000 | [diff] [blame] | 1398 | vector<DescramblingHardwareConnections> descrambling_configs = |
| 1399 | generateDescramblingConfigurations(); |
| 1400 | if (descrambling_configs.empty()) { |
| 1401 | ALOGD("No valid descrambling combinations in the configuration file."); |
| 1402 | return; |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1403 | } |
Frankie Lizcano | f4e0796 | 2022-07-13 20:54:34 +0000 | [diff] [blame] | 1404 | for (auto& combination : descrambling_configs) { |
| 1405 | descrambling = combination; |
| 1406 | int32_t demuxId; |
| 1407 | std::shared_ptr<IDemux> demux; |
| 1408 | ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId)); |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1409 | |
Frankie Lizcano | f4e0796 | 2022-07-13 20:54:34 +0000 | [diff] [blame] | 1410 | if (descrambling.hasFrontendConnection) { |
| 1411 | int32_t feId; |
| 1412 | mFrontendTests.getFrontendIdByType(frontendMap[descrambling.frontendId].type, feId); |
| 1413 | ASSERT_TRUE(feId != INVALID_ID); |
| 1414 | ASSERT_TRUE(mFrontendTests.openFrontendById(feId)); |
| 1415 | ASSERT_TRUE(mFrontendTests.setFrontendCallback()); |
| 1416 | ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId)); |
| 1417 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1418 | |
Frankie Lizcano | f4e0796 | 2022-07-13 20:54:34 +0000 | [diff] [blame] | 1419 | ASSERT_TRUE(mDescramblerTests.openDescrambler(demuxId)); |
| 1420 | ASSERT_TRUE(mDescramblerTests.closeDescrambler()); |
| 1421 | ASSERT_TRUE(mDemuxTests.closeDemux()); |
| 1422 | |
| 1423 | if (descrambling.hasFrontendConnection) { |
| 1424 | ASSERT_TRUE(mFrontendTests.closeFrontend()); |
| 1425 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1426 | } |
| 1427 | } |
| 1428 | |
| 1429 | TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTest) { |
| 1430 | description("Test ts audio filter in scrambled broadcast use case"); |
| 1431 | if (!descrambling.support) { |
| 1432 | return; |
| 1433 | } |
Frankie Lizcano | f4e0796 | 2022-07-13 20:54:34 +0000 | [diff] [blame] | 1434 | vector<DescramblingHardwareConnections> descrambling_configs = |
| 1435 | generateDescramblingConfigurations(); |
| 1436 | if (descrambling_configs.empty()) { |
| 1437 | ALOGD("No valid descrambling combinations in the configuration file."); |
| 1438 | return; |
| 1439 | } |
| 1440 | for (auto& combination : descrambling_configs) { |
| 1441 | descrambling = combination; |
| 1442 | set<FilterConfig> filterConfs; |
| 1443 | filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.audioFilterId])); |
| 1444 | filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.videoFilterId])); |
| 1445 | scrambledBroadcastTest(filterConfs, frontendMap[descrambling.frontendId], |
Frankie Lizcano | 82101d2 | 2022-07-28 00:12:35 +0000 | [diff] [blame] | 1446 | descramblerMap[descrambling.descramblerId], |
| 1447 | Dataflow_Context::DESCRAMBLING); |
Frankie Lizcano | f4e0796 | 2022-07-13 20:54:34 +0000 | [diff] [blame] | 1448 | } |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1449 | } |
| 1450 | |
Frankie Lizcano | 82101d2 | 2022-07-28 00:12:35 +0000 | [diff] [blame] | 1451 | TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTestWithLnb) { |
| 1452 | description("Test media filters in scrambled broadcast use case with Lnb"); |
| 1453 | if (!lnbDescrambling.support) { |
| 1454 | return; |
| 1455 | } |
Frankie Lizcano | bcf4ebb | 2022-08-01 18:06:00 +0000 | [diff] [blame] | 1456 | auto lnbDescrambling_configs = generateLnbDescramblingConfigurations(); |
| 1457 | if (lnbDescrambling_configs.empty()) { |
| 1458 | ALOGD("No frontends that support satellites."); |
| 1459 | return; |
| 1460 | } |
| 1461 | for (auto& configuration : lnbDescrambling_configs) { |
| 1462 | lnbDescrambling = configuration; |
| 1463 | set<FilterConfig> filterConfs; |
| 1464 | filterConfs.insert(static_cast<FilterConfig>(filterMap[lnbDescrambling.audioFilterId])); |
| 1465 | filterConfs.insert(static_cast<FilterConfig>(filterMap[lnbDescrambling.videoFilterId])); |
| 1466 | scrambledBroadcastTestWithLnb(filterConfs, frontendMap[lnbDescrambling.frontendId], |
| 1467 | descramblerMap[lnbDescrambling.descramblerId], |
| 1468 | lnbMap[lnbDescrambling.lnbId]); |
| 1469 | } |
Frankie Lizcano | 82101d2 | 2022-07-28 00:12:35 +0000 | [diff] [blame] | 1470 | } |
| 1471 | |
Hongguang | 600a6ae | 2021-07-08 18:51:51 -0700 | [diff] [blame] | 1472 | INSTANTIATE_TEST_SUITE_P(PerInstance, TunerBroadcastAidlTest, |
| 1473 | testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)), |
| 1474 | android::PrintInstanceNameToString); |
| 1475 | |
| 1476 | INSTANTIATE_TEST_SUITE_P(PerInstance, TunerFrontendAidlTest, |
| 1477 | testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)), |
| 1478 | android::PrintInstanceNameToString); |
| 1479 | |
| 1480 | INSTANTIATE_TEST_SUITE_P(PerInstance, TunerFilterAidlTest, |
| 1481 | testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)), |
| 1482 | android::PrintInstanceNameToString); |
| 1483 | |
| 1484 | INSTANTIATE_TEST_SUITE_P(PerInstance, TunerRecordAidlTest, |
| 1485 | testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)), |
| 1486 | android::PrintInstanceNameToString); |
| 1487 | |
| 1488 | INSTANTIATE_TEST_SUITE_P(PerInstance, TunerLnbAidlTest, |
| 1489 | testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)), |
| 1490 | android::PrintInstanceNameToString); |
| 1491 | |
| 1492 | INSTANTIATE_TEST_SUITE_P(PerInstance, TunerDemuxAidlTest, |
| 1493 | testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)), |
| 1494 | android::PrintInstanceNameToString); |
| 1495 | |
| 1496 | INSTANTIATE_TEST_SUITE_P(PerInstance, TunerPlaybackAidlTest, |
| 1497 | testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)), |
| 1498 | android::PrintInstanceNameToString); |
| 1499 | |
| 1500 | INSTANTIATE_TEST_SUITE_P(PerInstance, TunerDescramblerAidlTest, |
| 1501 | testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)), |
| 1502 | android::PrintInstanceNameToString); |
| 1503 | |
| 1504 | } // namespace |
| 1505 | |
| 1506 | // Start thread pool to receive callbacks from AIDL service. |
| 1507 | int main(int argc, char** argv) { |
| 1508 | ::testing::InitGoogleTest(&argc, argv); |
| 1509 | ABinderProcess_setThreadPoolMaxThreadCount(1); |
| 1510 | ABinderProcess_startThreadPool(); |
| 1511 | return RUN_ALL_TESTS(); |
| 1512 | } |