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