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