blob: 59d9593546a9e68fd4e48eb795551d0586a0f183 [file] [log] [blame]
Hongguang600a6ae2021-07-08 18:51:51 -07001/*
2 * Copyright 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#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
24namespace {
25
26AssertionResult TunerBroadcastAidlTest::filterDataOutputTest() {
27 return filterDataOutputTestBase(mFilterTests);
28}
29
30AssertionResult TunerPlaybackAidlTest::filterDataOutputTest() {
31 return filterDataOutputTestBase(mFilterTests);
32}
33
34AssertionResult TunerDescramblerAidlTest::filterDataOutputTest() {
35 return filterDataOutputTestBase(mFilterTests);
36}
37
38void 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));
sadiqsada630a9742023-12-20 22:14:31 +000051 mFrontendTests.setDemux(demux);
Hongguang600a6ae2021-07-08 18:51:51 -070052 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 Chen566240a2023-09-13 15:25:24 +080064 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*/));
Hongguang600a6ae2021-07-08 18:51:51 -070069 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
70 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
71 ASSERT_TRUE(mDemuxTests.closeDemux());
72 ASSERT_TRUE(mFrontendTests.closeFrontend());
73}
74
75void TunerFilterAidlTest::reconfigSingleFilterInDemuxTest(FilterConfig filterConf,
76 FilterConfig filterReconf,
77 FrontendConfig frontendConf) {
78 int32_t feId;
79 int32_t demuxId;
80 std::shared_ptr<IDemux> demux;
81 int64_t filterId;
82
83 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
84 ASSERT_TRUE(feId != INVALID_ID);
85 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
86 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
87 if (frontendConf.isSoftwareFe) {
88 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[live.dvrSoftwareFeId]);
89 }
90 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
91 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
92 mFrontendTests.setDemux(demux);
93 mFilterTests.setDemux(demux);
94 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
95 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
96 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
97 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
98 ASSERT_TRUE(mFilterTests.startFilter(filterId));
99 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
100 ASSERT_TRUE(mFilterTests.configFilter(filterReconf.settings, filterId));
101 ASSERT_TRUE(mFilterTests.startFilter(filterId));
102 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
Ray Chin17a3bf02024-11-19 20:55:25 +0800103 if (!isPassthroughFilter(filterReconf)) {
104 ASSERT_TRUE(mFilterTests.startIdTest(filterId));
105 }
Hongguang600a6ae2021-07-08 18:51:51 -0700106 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
107 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
108 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
109 ASSERT_TRUE(mDemuxTests.closeDemux());
110 ASSERT_TRUE(mFrontendTests.closeFrontend());
111}
112
113void TunerFilterAidlTest::testTimeFilter(TimeFilterConfig filterConf) {
114 int32_t demuxId;
115 std::shared_ptr<IDemux> demux;
116 DemuxCapabilities caps;
117
118 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
119 ASSERT_TRUE(mDemuxTests.getDemuxCaps(caps));
120 ASSERT_TRUE(caps.bTimeFilter);
121 mFilterTests.setDemux(demux);
122 ASSERT_TRUE(mFilterTests.openTimeFilterInDemux());
123 ASSERT_TRUE(mFilterTests.setTimeStamp(filterConf.timeStamp));
124 ASSERT_TRUE(mFilterTests.getTimeStamp());
125 ASSERT_TRUE(mFilterTests.clearTimeStamp());
126 ASSERT_TRUE(mFilterTests.closeTimeFilter());
127 ASSERT_TRUE(mDemuxTests.closeDemux());
128}
129
130void TunerBroadcastAidlTest::broadcastSingleFilterTest(FilterConfig filterConf,
131 FrontendConfig frontendConf) {
132 int32_t feId;
133 int32_t demuxId;
134 std::shared_ptr<IDemux> demux;
135 int64_t filterId;
136
137 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
138 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
139 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
Frankie Lizcano87421812022-07-28 17:13:01 +0000140 if (mLnbId != INVALID_LNB_ID) {
141 ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
Hongguang600a6ae2021-07-08 18:51:51 -0700142 }
143 if (frontendConf.isSoftwareFe) {
144 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[live.dvrSoftwareFeId]);
145 }
146 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
147 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
148 mFrontendTests.setDemux(demux);
149 mFilterTests.setDemux(demux);
150 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
151 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
152 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
153 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
154 ASSERT_TRUE(mFilterTests.startFilter(filterId));
155 // tune test
156 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
Ray Chin17a3bf02024-11-19 20:55:25 +0800157 if (!isPassthroughFilter(filterConf)) {
158 ASSERT_TRUE(filterDataOutputTest());
159 }
Hongguang600a6ae2021-07-08 18:51:51 -0700160 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
161 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
162 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
163 ASSERT_TRUE(mDemuxTests.closeDemux());
164 ASSERT_TRUE(mFrontendTests.closeFrontend());
165}
166
167void TunerBroadcastAidlTest::broadcastSingleFilterTestWithLnb(FilterConfig filterConf,
168 FrontendConfig frontendConf,
169 LnbConfig lnbConf) {
170 if (lnbConf.name.compare(emptyHardwareId) == 0) {
171 vector<int32_t> ids;
172 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
173 ASSERT_TRUE(ids.size() > 0);
174 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
Frankie Lizcano87421812022-07-28 17:13:01 +0000175 mLnbId = ids[0];
Hongguang600a6ae2021-07-08 18:51:51 -0700176 } else {
Frankie Lizcano87421812022-07-28 17:13:01 +0000177 ASSERT_TRUE(mLnbTests.openLnbByName(lnbConf.name, mLnbId));
Hongguang600a6ae2021-07-08 18:51:51 -0700178 }
179 ASSERT_TRUE(mLnbTests.setLnbCallback());
180 ASSERT_TRUE(mLnbTests.setVoltage(lnbConf.voltage));
181 ASSERT_TRUE(mLnbTests.setTone(lnbConf.tone));
182 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConf.position));
Frankie Lizcanod1f520e2022-07-26 20:05:46 +0000183 if (!frontendConf.isSoftwareFe) {
184 broadcastSingleFilterTest(filterConf, frontendConf);
185 }
Hongguang600a6ae2021-07-08 18:51:51 -0700186 ASSERT_TRUE(mLnbTests.closeLnb());
Frankie Lizcano87421812022-07-28 17:13:01 +0000187 mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700188}
189
190void TunerBroadcastAidlTest::mediaFilterUsingSharedMemoryTest(FilterConfig filterConf,
191 FrontendConfig frontendConf) {
192 int32_t feId;
193 int32_t demuxId;
194 std::shared_ptr<IDemux> demux;
195 int64_t filterId;
196
197 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
198 ASSERT_TRUE(feId != INVALID_ID);
199 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
200 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
201 if (frontendConf.isSoftwareFe) {
202 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[live.dvrSoftwareFeId]);
203 }
204 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
205 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
206 mFrontendTests.setDemux(demux);
207 mFilterTests.setDemux(demux);
208 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
209 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
210 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
211 ASSERT_TRUE(mFilterTests.getSharedAvMemoryHandle(filterId));
212 ASSERT_TRUE(mFilterTests.configAvFilterStreamType(filterConf.streamType, filterId));
213 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
214 ASSERT_TRUE(mFilterTests.startFilter(filterId));
215 // tune test
216 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
Ray Chin967c8e82024-12-24 12:27:27 +0800217 ASSERT_TRUE(filterDataOutputTest());
Hongguang600a6ae2021-07-08 18:51:51 -0700218 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
219 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
220 ASSERT_TRUE(mFilterTests.releaseShareAvHandle(filterId));
221 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
222 ASSERT_TRUE(mDemuxTests.closeDemux());
223 ASSERT_TRUE(mFrontendTests.closeFrontend());
224}
225
226void TunerPlaybackAidlTest::playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf) {
227 int32_t demuxId;
228 std::shared_ptr<IDemux> demux;
229 int64_t filterId;
230
231 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
232 mFilterTests.setDemux(demux);
233 mDvrTests.setDemux(demux);
234 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
235 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrConf.settings));
236 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
237 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
238 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
239 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
240 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
241 mDvrTests.startPlaybackInputThread(dvrConf.playbackInputFile,
242 dvrConf.settings.get<DvrSettings::Tag::playback>());
243 ASSERT_TRUE(mDvrTests.startDvrPlayback());
244 ASSERT_TRUE(mFilterTests.startFilter(filterId));
245 ASSERT_TRUE(filterDataOutputTest());
246 mDvrTests.stopPlaybackThread();
247 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
248 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
249 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
250 mDvrTests.closeDvrPlayback();
251 ASSERT_TRUE(mDemuxTests.closeDemux());
252}
253
Ray Chin62ab6c92022-09-15 15:07:33 +0800254void TunerPlaybackAidlTest::setStatusCheckIntervalHintTest(int64_t statusCheckIntervalHint,
255 DvrConfig dvrConf) {
256 int32_t demuxId;
257 std::shared_ptr<IDemux> demux;
258
259 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
260 mDvrTests.setDemux(demux);
261 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
262 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrConf.settings));
263 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
264
265 ASSERT_TRUE(mDvrTests.setPlaybackStatusCheckIntervalHint(statusCheckIntervalHint));
266
267 mDvrTests.startPlaybackInputThread(dvrConf.playbackInputFile,
268 dvrConf.settings.get<DvrSettings::Tag::playback>());
269 ASSERT_TRUE(mDvrTests.startDvrPlayback());
270 mDvrTests.stopPlaybackThread();
271 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
272 mDvrTests.closeDvrPlayback();
273 ASSERT_TRUE(mDemuxTests.closeDemux());
274}
275
Hongguang600a6ae2021-07-08 18:51:51 -0700276void TunerRecordAidlTest::recordSingleFilterTestWithLnb(FilterConfig filterConf,
277 FrontendConfig frontendConf,
278 DvrConfig dvrConf, LnbConfig lnbConf) {
279 if (lnbConf.name.compare(emptyHardwareId) == 0) {
280 vector<int32_t> ids;
281 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
282 ASSERT_TRUE(ids.size() > 0);
283 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
Frankie Lizcano87421812022-07-28 17:13:01 +0000284 mLnbId = ids[0];
Hongguang600a6ae2021-07-08 18:51:51 -0700285 } else {
Frankie Lizcano87421812022-07-28 17:13:01 +0000286 ASSERT_TRUE(mLnbTests.openLnbByName(lnbConf.name, mLnbId));
Hongguang600a6ae2021-07-08 18:51:51 -0700287 }
288 ASSERT_TRUE(mLnbTests.setLnbCallback());
289 ASSERT_TRUE(mLnbTests.setVoltage(lnbConf.voltage));
290 ASSERT_TRUE(mLnbTests.setTone(lnbConf.tone));
291 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConf.position));
292 for (auto msgName : lnbRecord.diseqcMsgs) {
293 ASSERT_TRUE(mLnbTests.sendDiseqcMessage(diseqcMsgMap[msgName]));
294 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000295 if (!frontendConf.isSoftwareFe) {
296 recordSingleFilterTest(filterConf, frontendConf, dvrConf, Dataflow_Context::LNBRECORD);
297 }
Hongguang600a6ae2021-07-08 18:51:51 -0700298 ASSERT_TRUE(mLnbTests.closeLnb());
Frankie Lizcano87421812022-07-28 17:13:01 +0000299 mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700300}
301
302void TunerRecordAidlTest::attachSingleFilterToRecordDvrTest(FilterConfig filterConf,
303 FrontendConfig frontendConf,
304 DvrConfig dvrConf) {
305 int32_t demuxId;
306 std::shared_ptr<IDemux> demux;
307 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
308 mDvrTests.setDemux(demux);
309
310 DvrConfig dvrSourceConfig;
311 if (record.hasFrontendConnection) {
312 int32_t feId;
313 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
314 ASSERT_TRUE(feId != INVALID_ID);
315 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
316 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
317 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
318 } else {
319 dvrSourceConfig = dvrMap[record.dvrSourceId];
320 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
321 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
322 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
323 }
324
325 int64_t filterId;
326 std::shared_ptr<IFilter> filter;
327 mFilterTests.setDemux(demux);
328
329 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
330 ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
331 ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
332
333 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
334 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
335 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
336 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
337 filter = mFilterTests.getFilterById(filterId);
338 ASSERT_TRUE(filter != nullptr);
339 ASSERT_TRUE(mDvrTests.attachFilterToDvr(filter));
340 ASSERT_TRUE(mDvrTests.startDvrRecord());
341 ASSERT_TRUE(mFilterTests.startFilter(filterId));
342 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
343 ASSERT_TRUE(mDvrTests.stopDvrRecord());
344 ASSERT_TRUE(mDvrTests.detachFilterToDvr(filter));
345 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
346 mDvrTests.closeDvrRecord();
347 ASSERT_TRUE(mDemuxTests.closeDemux());
348
349 if (record.hasFrontendConnection) {
350 ASSERT_TRUE(mFrontendTests.closeFrontend());
351 }
352}
353
354void TunerRecordAidlTest::recordSingleFilterTest(FilterConfig filterConf,
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000355 FrontendConfig frontendConf, DvrConfig dvrConf,
356 Dataflow_Context context) {
Hongguang600a6ae2021-07-08 18:51:51 -0700357 int32_t demuxId;
358 std::shared_ptr<IDemux> demux;
359 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
360 mDvrTests.setDemux(demux);
361
362 DvrConfig dvrSourceConfig;
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000363 if (context == Dataflow_Context::RECORD) {
364 if (record.hasFrontendConnection) {
365 int32_t feId;
366 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
367 ASSERT_TRUE(feId != INVALID_ID);
368 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
369 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
370 if (frontendConf.isSoftwareFe) {
371 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[record.dvrSoftwareFeId]);
372 }
373 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
374 mFrontendTests.setDvrTests(&mDvrTests);
375 } else {
376 dvrSourceConfig = dvrMap[record.dvrSourceId];
377 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
378 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
379 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
380 }
381 } else if (context == Dataflow_Context::LNBRECORD) {
382 // If function arrives here, frontend should not be software, so no need to configure a dvr
383 // source or dvr fe connection that might be used for recording without an Lnb
Hongguang600a6ae2021-07-08 18:51:51 -0700384 int32_t feId;
385 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
386 ASSERT_TRUE(feId != INVALID_ID);
387 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
388 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000389 if (mLnbId != INVALID_LNB_ID) {
390 ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
391 } else {
392 FAIL();
Hongguang600a6ae2021-07-08 18:51:51 -0700393 }
394 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
395 mFrontendTests.setDvrTests(&mDvrTests);
Hongguang600a6ae2021-07-08 18:51:51 -0700396 }
397
398 int64_t filterId;
399 std::shared_ptr<IFilter> filter;
400 mFilterTests.setDemux(demux);
401 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
402 ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
403 ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
404 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
405 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
406 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
407 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
408 filter = mFilterTests.getFilterById(filterId);
409 ASSERT_TRUE(filter != nullptr);
410 mDvrTests.startRecordOutputThread(dvrConf.settings.get<DvrSettings::Tag::record>());
411 ASSERT_TRUE(mDvrTests.attachFilterToDvr(filter));
412 ASSERT_TRUE(mDvrTests.startDvrRecord());
413 ASSERT_TRUE(mFilterTests.startFilter(filterId));
414
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000415 if (context == Dataflow_Context::RECORD) {
416 if (record.hasFrontendConnection) {
417 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
418 } else {
419 // Start DVR Source
420 mDvrTests.startPlaybackInputThread(
421 dvrSourceConfig.playbackInputFile,
422 dvrSourceConfig.settings.get<DvrSettings::Tag::playback>());
423 ASSERT_TRUE(mDvrTests.startDvrPlayback());
424 }
425 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700426 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700427 }
Hongguang600a6ae2021-07-08 18:51:51 -0700428 mDvrTests.testRecordOutput();
429 mDvrTests.stopRecordThread();
430
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000431 if (context == Dataflow_Context::RECORD) {
432 if (record.hasFrontendConnection) {
433 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
434 } else {
435 mDvrTests.stopPlaybackThread();
436 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
437 }
438 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700439 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700440 }
441
442 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
443 ASSERT_TRUE(mDvrTests.stopDvrRecord());
444 ASSERT_TRUE(mDvrTests.detachFilterToDvr(filter));
445 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
446 mDvrTests.closeDvrRecord();
447
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000448 if (context == Dataflow_Context::RECORD) {
449 if (record.hasFrontendConnection) {
450 ASSERT_TRUE(mFrontendTests.closeFrontend());
451 } else {
452 mDvrTests.closeDvrPlayback();
453 }
454 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700455 ASSERT_TRUE(mFrontendTests.closeFrontend());
Hongguang600a6ae2021-07-08 18:51:51 -0700456 }
457
458 ASSERT_TRUE(mDemuxTests.closeDemux());
459}
460
Ray Chin62ab6c92022-09-15 15:07:33 +0800461void TunerRecordAidlTest::setStatusCheckIntervalHintTest(int64_t statusCheckIntervalHint,
462 FrontendConfig frontendConf,
463 DvrConfig dvrConf) {
464 int32_t demuxId;
465 std::shared_ptr<IDemux> demux;
466 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
467 mDvrTests.setDemux(demux);
468
469 DvrConfig dvrSourceConfig;
470 if (record.hasFrontendConnection) {
471 int32_t feId;
472 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
473 ASSERT_TRUE(feId != INVALID_ID);
474 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
475 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
476 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
477 } else {
478 dvrSourceConfig = dvrMap[record.dvrSourceId];
479 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
480 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
481 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
482 }
483
484 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
485 ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
486 ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
487
488 ASSERT_TRUE(mDvrTests.setRecordStatusCheckIntervalHint(statusCheckIntervalHint));
489
490 ASSERT_TRUE(mDvrTests.startDvrRecord());
491 ASSERT_TRUE(mDvrTests.stopDvrRecord());
492 mDvrTests.closeDvrRecord();
493 ASSERT_TRUE(mDemuxTests.closeDemux());
494
495 if (record.hasFrontendConnection) {
496 ASSERT_TRUE(mFrontendTests.closeFrontend());
497 }
498}
499
Hongguang600a6ae2021-07-08 18:51:51 -0700500void TunerDescramblerAidlTest::scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
501 FrontendConfig frontendConf,
Frankie Lizcano82101d22022-07-28 00:12:35 +0000502 DescramblerConfig descConfig,
503 Dataflow_Context context) {
Hongguang600a6ae2021-07-08 18:51:51 -0700504 int32_t demuxId;
505 std::shared_ptr<IDemux> demux;
506 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
507
508 DvrConfig dvrSourceConfig;
Frankie Lizcano82101d22022-07-28 00:12:35 +0000509 if (context == Dataflow_Context::DESCRAMBLING) {
510 if (descrambling.hasFrontendConnection) {
511 int32_t feId;
512 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
513 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
514 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
515 if (frontendConf.isSoftwareFe) {
516 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[descrambling.dvrSoftwareFeId]);
517 }
518 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
519 mFrontendTests.setDemux(demux);
520 } else {
521 dvrSourceConfig = dvrMap[descrambling.dvrSourceId];
522 mDvrTests.setDemux(demux);
523 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
524 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
525 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
526 }
527 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700528 int32_t feId;
529 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
530 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
531 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
Frankie Lizcano82101d22022-07-28 00:12:35 +0000532 if (mLnbId != INVALID_LNB_ID) {
533 ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
534 } else {
535 // If, for some reason, the test got here without failing. We fail it here.
536 ALOGD("mLnbId is null. Something went wrong. Exiting ScrambledBroadcastWithLnbId.");
537 FAIL();
Hongguang600a6ae2021-07-08 18:51:51 -0700538 }
539 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
540 mFrontendTests.setDemux(demux);
Hongguang600a6ae2021-07-08 18:51:51 -0700541 }
542
543 set<int64_t> filterIds;
544 int64_t filterId;
545 set<struct FilterConfig>::iterator config;
546 set<int64_t>::iterator id;
547 mFilterTests.setDemux(demux);
548 for (config = mediaFilterConfs.begin(); config != mediaFilterConfs.end(); config++) {
549 ASSERT_TRUE(mFilterTests.openFilterInDemux((*config).type, (*config).bufferSize));
550 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
551 ASSERT_TRUE(mFilterTests.configFilter((*config).settings, filterId));
552 filterIds.insert(filterId);
553 }
554 ASSERT_TRUE(mDescramblerTests.openDescrambler(demuxId));
555 vector<uint8_t> token;
556 ASSERT_TRUE(mDescramblerTests.getKeyToken(descConfig.casSystemId, descConfig.provisionStr,
557 descConfig.hidlPvtData, token));
558 mDescramblerTests.setKeyToken(token);
559 vector<DemuxPid> pids;
560 DemuxPid pid;
561 for (config = mediaFilterConfs.begin(); config != mediaFilterConfs.end(); config++) {
562 ASSERT_TRUE(mDescramblerTests.getDemuxPidFromFilterSettings((*config).type,
563 (*config).settings, pid));
564 pids.push_back(pid);
565 ASSERT_TRUE(mDescramblerTests.addPid(pid, nullptr));
566 }
567 for (id = filterIds.begin(); id != filterIds.end(); id++) {
568 ASSERT_TRUE(mFilterTests.startFilter(*id));
569 }
570
Frankie Lizcano82101d22022-07-28 00:12:35 +0000571 if (context == Dataflow_Context::DESCRAMBLING) {
572 if (descrambling.hasFrontendConnection) {
573 // tune test
574 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
575 } else {
576 // Start DVR Source
577 mDvrTests.startPlaybackInputThread(
578 dvrSourceConfig.playbackInputFile,
579 dvrSourceConfig.settings.get<DvrSettings::Tag::playback>());
580 ASSERT_TRUE(mDvrTests.startDvrPlayback());
581 }
582 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700583 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700584 }
585
586 ASSERT_TRUE(filterDataOutputTest());
587
Frankie Lizcano82101d22022-07-28 00:12:35 +0000588 if (context == Dataflow_Context::DESCRAMBLING) {
589 if (descrambling.hasFrontendConnection) {
590 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
591 } else {
592 mDvrTests.stopPlaybackThread();
593 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
594 }
595 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700596 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700597 }
598
599 for (id = filterIds.begin(); id != filterIds.end(); id++) {
600 ASSERT_TRUE(mFilterTests.stopFilter(*id));
601 }
602 for (auto pid : pids) {
603 ASSERT_TRUE(mDescramblerTests.removePid(pid, nullptr));
604 }
605 ASSERT_TRUE(mDescramblerTests.closeDescrambler());
606 for (id = filterIds.begin(); id != filterIds.end(); id++) {
607 ASSERT_TRUE(mFilterTests.closeFilter(*id));
608 }
609
Frankie Lizcano82101d22022-07-28 00:12:35 +0000610 if (context == Dataflow_Context::DESCRAMBLING) {
611 if (descrambling.hasFrontendConnection) {
612 ASSERT_TRUE(mFrontendTests.closeFrontend());
613 } else {
614 mDvrTests.closeDvrPlayback();
615 }
616 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700617 ASSERT_TRUE(mFrontendTests.closeFrontend());
Hongguang600a6ae2021-07-08 18:51:51 -0700618 }
619
620 ASSERT_TRUE(mDemuxTests.closeDemux());
621}
622
Frankie Lizcano82101d22022-07-28 00:12:35 +0000623void TunerDescramblerAidlTest::scrambledBroadcastTestWithLnb(
624 set<struct FilterConfig>& mediaFilterConfs, FrontendConfig& frontendConf,
625 DescramblerConfig& descConfig, LnbConfig& lnbConfig) {
626 // We can test the Lnb individually and make sure it functions properly. If the frontend is
627 // software, we cannot test the whole dataflow. If the frontend is hardware, we can
628 if (lnbConfig.name.compare(emptyHardwareId) == 0) {
629 vector<int32_t> ids;
630 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
631 ASSERT_TRUE(ids.size() > 0);
632 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
633 mLnbId = ids[0];
634 } else {
635 ASSERT_TRUE(mLnbTests.openLnbByName(lnbConfig.name, mLnbId));
636 }
637 // Once Lnb is opened, test some of its basic functionality
638 ASSERT_TRUE(mLnbTests.setLnbCallback());
639 ASSERT_TRUE(mLnbTests.setVoltage(lnbConfig.voltage));
640 ASSERT_TRUE(mLnbTests.setTone(lnbConfig.tone));
641 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConfig.position));
642 if (!frontendConf.isSoftwareFe) {
643 ALOGD("Frontend is not software, testing entire dataflow.");
644 scrambledBroadcastTest(mediaFilterConfs, frontendConf, descConfig,
645 Dataflow_Context::LNBDESCRAMBLING);
646 } else {
647 ALOGD("Frontend is software, did not test the entire dataflow, but tested the Lnb "
648 "individually.");
649 }
650 ASSERT_TRUE(mLnbTests.closeLnb());
651 mLnbId = INVALID_LNB_ID;
652}
653
Hongguang600a6ae2021-07-08 18:51:51 -0700654TEST_P(TunerLnbAidlTest, SendDiseqcMessageToLnb) {
655 description("Open and configure an Lnb with specific settings then send a diseqc msg to it.");
656 if (!lnbLive.support) {
657 return;
658 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000659 vector<LnbLiveHardwareConnections> lnbLive_configs = generateLnbLiveConfigurations();
660 if (lnbLive_configs.empty()) {
661 ALOGD("No frontends that support satellites.");
662 return;
Hongguang600a6ae2021-07-08 18:51:51 -0700663 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000664 for (auto& combination : lnbLive_configs) {
665 lnbLive = combination;
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000666 if (lnbMap[lnbLive.lnbId].name.compare(emptyHardwareId) == 0) {
667 vector<int32_t> ids;
668 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
669 ASSERT_TRUE(ids.size() > 0);
670 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
671 } else {
672 int32_t id;
673 ASSERT_TRUE(mLnbTests.openLnbByName(lnbMap[lnbLive.lnbId].name, id));
674 }
675 ASSERT_TRUE(mLnbTests.setLnbCallback());
676 ASSERT_TRUE(mLnbTests.setVoltage(lnbMap[lnbLive.lnbId].voltage));
677 ASSERT_TRUE(mLnbTests.setTone(lnbMap[lnbLive.lnbId].tone));
678 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbMap[lnbLive.lnbId].position));
679 for (auto msgName : lnbLive.diseqcMsgs) {
680 ASSERT_TRUE(mLnbTests.sendDiseqcMessage(diseqcMsgMap[msgName]));
681 }
682 ASSERT_TRUE(mLnbTests.closeLnb());
Hongguang600a6ae2021-07-08 18:51:51 -0700683 }
Hongguang600a6ae2021-07-08 18:51:51 -0700684}
685
686TEST_P(TunerDemuxAidlTest, openDemux) {
687 description("Open and close a Demux.");
688 if (!live.hasFrontendConnection) {
689 return;
690 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000691 auto live_configs = generateLiveConfigurations();
692 for (auto& configuration : live_configs) {
693 live = configuration;
694 int32_t feId;
695 int32_t demuxId;
696 std::shared_ptr<IDemux> demux;
697 mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId);
698 ASSERT_TRUE(feId != INVALID_ID);
699 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
700 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
701 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
702 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
703 ASSERT_TRUE(mDemuxTests.closeDemux());
704 ASSERT_TRUE(mFrontendTests.closeFrontend());
705 }
Hongguang600a6ae2021-07-08 18:51:51 -0700706}
707
Kensuke Miyagi73b18ac2022-11-07 10:49:09 -0800708TEST_P(TunerDemuxAidlTest, openDemuxById) {
709 description("Open (with id) and close a Demux.");
710 std::vector<int32_t> demuxIds;
711 ASSERT_TRUE(mDemuxTests.getDemuxIds(demuxIds));
712 for (int i = 0; i < demuxIds.size(); i++) {
713 std::shared_ptr<IDemux> demux;
714 ASSERT_TRUE(mDemuxTests.openDemuxById(demuxIds[i], demux));
715 ASSERT_TRUE(mDemuxTests.closeDemux());
716 }
717}
718
719TEST_P(TunerDemuxAidlTest, getDemuxInfo) {
720 description("Check getDemuxInfo against demux caps");
721 std::vector<int32_t> demuxIds;
722 ASSERT_TRUE(mDemuxTests.getDemuxIds(demuxIds));
723 int32_t combinedFilterTypes = 0;
724 for (int i = 0; i < demuxIds.size(); i++) {
725 DemuxInfo demuxInfo;
726 ASSERT_TRUE(mDemuxTests.getDemuxInfo(demuxIds[i], demuxInfo));
727 combinedFilterTypes |= demuxInfo.filterTypes;
728 }
729 if (demuxIds.size() > 0) {
730 DemuxCapabilities demuxCaps;
731 ASSERT_TRUE(mDemuxTests.getDemuxCaps(demuxCaps));
732 ASSERT_TRUE(demuxCaps.filterCaps == combinedFilterTypes);
733 }
734}
735
Hongguang600a6ae2021-07-08 18:51:51 -0700736TEST_P(TunerDemuxAidlTest, getAvSyncTime) {
737 description("Get the A/V sync time from a PCR filter.");
738 if (!live.hasFrontendConnection) {
739 return;
740 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000741 auto live_configs = generateLiveConfigurations();
742 for (auto& configuration : live_configs) {
743 live = configuration;
744 if (live.pcrFilterId.compare(emptyHardwareId) == 0) {
745 continue;
746 }
747 int32_t feId;
748 int32_t demuxId;
749 std::shared_ptr<IDemux> demux;
750 int64_t mediaFilterId;
751 int64_t pcrFilterId;
752 int32_t avSyncHwId;
753 std::shared_ptr<IFilter> mediaFilter;
Hongguang600a6ae2021-07-08 18:51:51 -0700754
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000755 mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId);
756 ASSERT_TRUE(feId != INVALID_ID);
757 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
758 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
759 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
760 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
761 mFilterTests.setDemux(demux);
762 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterMap[live.videoFilterId].type,
763 filterMap[live.videoFilterId].bufferSize));
764 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(mediaFilterId));
765 ASSERT_TRUE(
766 mFilterTests.configFilter(filterMap[live.videoFilterId].settings, mediaFilterId));
767 mediaFilter = mFilterTests.getFilterById(mediaFilterId);
768 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterMap[live.pcrFilterId].type,
769 filterMap[live.pcrFilterId].bufferSize));
770 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(pcrFilterId));
771 ASSERT_TRUE(mFilterTests.configFilter(filterMap[live.pcrFilterId].settings, pcrFilterId));
772 ASSERT_TRUE(mDemuxTests.getAvSyncId(mediaFilter, avSyncHwId));
773 ASSERT_TRUE(pcrFilterId == avSyncHwId);
774 ASSERT_TRUE(mDemuxTests.getAvSyncTime(pcrFilterId));
775 ASSERT_TRUE(mFilterTests.closeFilter(pcrFilterId));
776 ASSERT_TRUE(mFilterTests.closeFilter(mediaFilterId));
777 ASSERT_TRUE(mDemuxTests.closeDemux());
778 ASSERT_TRUE(mFrontendTests.closeFrontend());
779 }
Hongguang600a6ae2021-07-08 18:51:51 -0700780}
781
782TEST_P(TunerFilterAidlTest, StartFilterInDemux) {
783 description("Open and start a filter in Demux.");
784 if (!live.hasFrontendConnection) {
785 return;
786 }
787 // TODO use parameterized tests
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000788 auto live_configs = generateLiveConfigurations();
789 for (auto& configuration : live_configs) {
790 live = configuration;
791 configSingleFilterInDemuxTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
792 }
Hongguang600a6ae2021-07-08 18:51:51 -0700793}
794
795TEST_P(TunerFilterAidlTest, ConfigIpFilterInDemuxWithCid) {
796 description("Open and configure an ip filter in Demux.");
797 // TODO use parameterized tests
798 if (!live.hasFrontendConnection) {
799 return;
800 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000801 auto live_configs = generateLiveConfigurations();
802 for (auto& configuration : live_configs) {
803 live = configuration;
804 if (live.ipFilterId.compare(emptyHardwareId) == 0) {
805 continue;
806 }
807 configSingleFilterInDemuxTest(filterMap[live.ipFilterId], frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -0700808 }
Hongguang600a6ae2021-07-08 18:51:51 -0700809}
810
811TEST_P(TunerFilterAidlTest, ReconfigFilterToReceiveStartId) {
812 description("Recofigure and restart a filter to test start id.");
813 if (!live.hasFrontendConnection) {
814 return;
815 }
816 // TODO use parameterized tests
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000817 auto live_configs = generateLiveConfigurations();
818 for (auto& configuration : live_configs) {
819 live = configuration;
820 reconfigSingleFilterInDemuxTest(filterMap[live.videoFilterId],
821 filterMap[live.videoFilterId],
822 frontendMap[live.frontendId]);
823 }
Hongguang600a6ae2021-07-08 18:51:51 -0700824}
825
826TEST_P(TunerFilterAidlTest, SetFilterLinkage) {
827 description("Pick up all the possible linkages from the demux caps and set them up.");
828 DemuxCapabilities caps;
829 int32_t demuxId;
830 std::shared_ptr<IDemux> demux;
831 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
832 ASSERT_TRUE(mDemuxTests.getDemuxCaps(caps));
833 mFilterTests.setDemux(demux);
834 for (int i = 0; i < caps.linkCaps.size(); i++) {
835 uint32_t bitMask = 1;
836 for (int j = 0; j < FILTER_MAIN_TYPE_BIT_COUNT; j++) {
837 if (caps.linkCaps[i] & (bitMask << j)) {
838 int64_t sourceFilterId;
839 int64_t sinkFilterId;
840 ASSERT_TRUE(mFilterTests.openFilterInDemux(getLinkageFilterType(i), FMQ_SIZE_16M));
841 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(sourceFilterId));
842 ASSERT_TRUE(mFilterTests.openFilterInDemux(getLinkageFilterType(j), FMQ_SIZE_16M));
843 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(sinkFilterId));
844 ASSERT_TRUE(mFilterTests.setFilterDataSource(sourceFilterId, sinkFilterId));
845 ASSERT_TRUE(mFilterTests.setFilterDataSourceToDemux(sinkFilterId));
846 ASSERT_TRUE(mFilterTests.closeFilter(sinkFilterId));
847 ASSERT_TRUE(mFilterTests.closeFilter(sourceFilterId));
848 }
849 }
850 }
851 ASSERT_TRUE(mDemuxTests.closeDemux());
852}
853
854TEST_P(TunerFilterAidlTest, testTimeFilter) {
855 description("Open a timer filter in Demux and set time stamp.");
856 if (!timeFilter.support) {
857 return;
858 }
859 // TODO use parameterized tests
Frankie Lizcano0c069532022-07-14 20:20:46 +0000860 auto timeFilter_configs = generateTimeFilterConfigurations();
861 for (auto& configuration : timeFilter_configs) {
862 timeFilter = configuration;
863 testTimeFilter(timeFilterMap[timeFilter.timeFilterId]);
864 }
Hongguang600a6ae2021-07-08 18:51:51 -0700865}
866
Gareth Fenn9a808452022-03-31 08:40:00 +0100867static bool isEventProducingFilter(const FilterConfig& filterConfig) {
868 switch (filterConfig.type.mainType) {
869 case DemuxFilterMainType::TS: {
870 auto tsFilterType =
871 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tsFilterType>();
872 return (tsFilterType == DemuxTsFilterType::SECTION ||
873 tsFilterType == DemuxTsFilterType::PES ||
874 tsFilterType == DemuxTsFilterType::AUDIO ||
875 tsFilterType == DemuxTsFilterType::VIDEO ||
876 tsFilterType == DemuxTsFilterType::RECORD ||
877 tsFilterType == DemuxTsFilterType::TEMI);
878 }
879 case DemuxFilterMainType::MMTP: {
880 auto mmtpFilterType =
881 filterConfig.type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>();
882 return (mmtpFilterType == DemuxMmtpFilterType::SECTION ||
883 mmtpFilterType == DemuxMmtpFilterType::PES ||
884 mmtpFilterType == DemuxMmtpFilterType::AUDIO ||
885 mmtpFilterType == DemuxMmtpFilterType::VIDEO ||
886 mmtpFilterType == DemuxMmtpFilterType::RECORD ||
887 mmtpFilterType == DemuxMmtpFilterType::DOWNLOAD);
888 }
889 case DemuxFilterMainType::IP: {
890 auto ipFilterType =
891 filterConfig.type.subType.get<DemuxFilterSubType::Tag::ipFilterType>();
892 return (ipFilterType == DemuxIpFilterType::SECTION);
893 }
894 case DemuxFilterMainType::TLV: {
895 auto tlvFilterType =
896 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tlvFilterType>();
897 return (tlvFilterType == DemuxTlvFilterType::SECTION);
898 }
899 case DemuxFilterMainType::ALP: {
900 auto alpFilterType =
901 filterConfig.type.subType.get<DemuxFilterSubType::Tag::alpFilterType>();
902 return (alpFilterType == DemuxAlpFilterType::SECTION);
903 }
904 default:
905 return false;
906 }
907}
908
Patrick Rohr1586d212021-11-23 00:40:56 +0100909static bool isMediaFilter(const FilterConfig& filterConfig) {
910 switch (filterConfig.type.mainType) {
911 case DemuxFilterMainType::TS: {
912 // TS Audio and Video filters are media filters
913 auto tsFilterType =
914 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tsFilterType>();
915 return (tsFilterType == DemuxTsFilterType::AUDIO ||
916 tsFilterType == DemuxTsFilterType::VIDEO);
917 }
918 case DemuxFilterMainType::MMTP: {
919 // MMTP Audio and Video filters are media filters
920 auto mmtpFilterType =
921 filterConfig.type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>();
922 return (mmtpFilterType == DemuxMmtpFilterType::AUDIO ||
923 mmtpFilterType == DemuxMmtpFilterType::VIDEO);
924 }
925 default:
926 return false;
927 }
928}
Patrick Rohr149b0872021-11-20 00:39:37 +0100929
Patrick Rohr1586d212021-11-23 00:40:56 +0100930static int getDemuxFilterEventDataLength(const DemuxFilterEvent& event) {
931 switch (event.getTag()) {
932 case DemuxFilterEvent::Tag::section:
933 return event.get<DemuxFilterEvent::Tag::section>().dataLength;
934 case DemuxFilterEvent::Tag::media:
935 return event.get<DemuxFilterEvent::Tag::media>().dataLength;
936 case DemuxFilterEvent::Tag::pes:
937 return event.get<DemuxFilterEvent::Tag::pes>().dataLength;
938 case DemuxFilterEvent::Tag::download:
939 return event.get<DemuxFilterEvent::Tag::download>().dataLength;
940 case DemuxFilterEvent::Tag::ipPayload:
941 return event.get<DemuxFilterEvent::Tag::ipPayload>().dataLength;
942
943 case DemuxFilterEvent::Tag::tsRecord:
944 case DemuxFilterEvent::Tag::mmtpRecord:
945 case DemuxFilterEvent::Tag::temi:
946 case DemuxFilterEvent::Tag::monitorEvent:
947 case DemuxFilterEvent::Tag::startId:
948 return 0;
949 }
950}
951
952// TODO: move boilerplate into text fixture
953void TunerFilterAidlTest::testDelayHint(const FilterConfig& filterConf) {
Gareth Fenn9a808452022-03-31 08:40:00 +0100954 if (!filterConf.timeDelayInMs && !filterConf.dataDelayInBytes) {
955 return;
956 }
957 if (!isEventProducingFilter(filterConf)) {
958 return;
959 }
Patrick Rohr149b0872021-11-20 00:39:37 +0100960 int32_t feId;
961 int32_t demuxId;
962 std::shared_ptr<IDemux> demux;
963 int64_t filterId;
964
965 mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId);
966 ASSERT_TRUE(feId != INVALID_ID);
967 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
968 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
969 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
970 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
971 mFilterTests.setDemux(demux);
972
Patrick Rohr149b0872021-11-20 00:39:37 +0100973 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
974 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
Patrick Rohr149b0872021-11-20 00:39:37 +0100975
Patrick Rohr1586d212021-11-23 00:40:56 +0100976 bool mediaFilter = isMediaFilter(filterConf);
Patrick Rohr149b0872021-11-20 00:39:37 +0100977 auto filter = mFilterTests.getFilterById(filterId);
978
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +0100979 // startTime needs to be set before calling setDelayHint.
980 auto startTime = std::chrono::steady_clock::now();
981
Gareth Fenn9a808452022-03-31 08:40:00 +0100982 int timeDelayInMs = filterConf.timeDelayInMs;
983 if (timeDelayInMs > 0) {
Patrick Rohr1586d212021-11-23 00:40:56 +0100984 FilterDelayHint delayHint;
985 delayHint.hintType = FilterDelayHintType::TIME_DELAY_IN_MS;
Gareth Fenn9a808452022-03-31 08:40:00 +0100986 delayHint.hintValue = timeDelayInMs;
Patrick Rohr149b0872021-11-20 00:39:37 +0100987
Patrick Rohr1586d212021-11-23 00:40:56 +0100988 // setDelayHint should fail for media filters.
989 ASSERT_EQ(filter->setDelayHint(delayHint).isOk(), !mediaFilter);
990 }
Patrick Rohr149b0872021-11-20 00:39:37 +0100991
Patrick Rohr1586d212021-11-23 00:40:56 +0100992 int dataDelayInBytes = filterConf.dataDelayInBytes;
993 if (dataDelayInBytes > 0) {
994 FilterDelayHint delayHint;
995 delayHint.hintType = FilterDelayHintType::DATA_SIZE_DELAY_IN_BYTES;
996 delayHint.hintValue = dataDelayInBytes;
Patrick Rohr149b0872021-11-20 00:39:37 +0100997
Patrick Rohr1586d212021-11-23 00:40:56 +0100998 // setDelayHint should fail for media filters.
999 ASSERT_EQ(filter->setDelayHint(delayHint).isOk(), !mediaFilter);
1000 }
Patrick Rohr149b0872021-11-20 00:39:37 +01001001
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +01001002 // start and stop filter (and wait for first callback) in order to
1003 // circumvent callback scheduler race conditions after adjusting filter
1004 // delays.
1005 auto cb = mFilterTests.getFilterCallbacks().at(filterId);
1006 auto future =
1007 cb->verifyFilterCallback([](const std::vector<DemuxFilterEvent>&) { return true; });
Gareth Fenn9a808452022-03-31 08:40:00 +01001008
1009 // The configure stage can also produce events, so we should set the delay
1010 // hint beforehand.
1011 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
Patrick Rohr1586d212021-11-23 00:40:56 +01001012 mFilterTests.startFilter(filterId);
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +01001013
1014 auto timeout = std::chrono::seconds(30);
1015 ASSERT_EQ(future.wait_for(timeout), std::future_status::ready);
1016
Patrick Rohr1586d212021-11-23 00:40:56 +01001017 mFilterTests.stopFilter(filterId);
Patrick Rohr149b0872021-11-20 00:39:37 +01001018
Patrick Rohr1586d212021-11-23 00:40:56 +01001019 if (!mediaFilter) {
Patrick Rohr1586d212021-11-23 00:40:56 +01001020 int callbackSize = 0;
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +01001021 future = cb->verifyFilterCallback(
Patrick Rohr1586d212021-11-23 00:40:56 +01001022 [&callbackSize](const std::vector<DemuxFilterEvent>& events) {
1023 for (const auto& event : events) {
1024 callbackSize += getDemuxFilterEventDataLength(event);
1025 }
1026 return true;
1027 });
1028
Patrick Rohr1586d212021-11-23 00:40:56 +01001029 ASSERT_TRUE(mFilterTests.startFilter(filterId));
1030
1031 // block and wait for callback to be received.
Patrick Rohr1586d212021-11-23 00:40:56 +01001032 ASSERT_EQ(future.wait_for(timeout), std::future_status::ready);
Patrick Rohr1586d212021-11-23 00:40:56 +01001033
Gareth Fenn9a808452022-03-31 08:40:00 +01001034 auto duration = std::chrono::steady_clock::now() - startTime;
1035 bool delayHintTest = duration >= std::chrono::milliseconds(timeDelayInMs);
Patrick Rohr1586d212021-11-23 00:40:56 +01001036 bool dataSizeTest = callbackSize >= dataDelayInBytes;
1037
Gareth Fenn9a808452022-03-31 08:40:00 +01001038 if (timeDelayInMs > 0 && dataDelayInBytes > 0) {
Patrick Rohr1586d212021-11-23 00:40:56 +01001039 ASSERT_TRUE(delayHintTest || dataSizeTest);
1040 } else {
1041 // if only one of time delay / data delay is configured, one of them
1042 // holds true by default, so we want both assertions to be true.
1043 ASSERT_TRUE(delayHintTest && dataSizeTest);
1044 }
1045
1046 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
1047 }
1048
Patrick Rohr149b0872021-11-20 00:39:37 +01001049 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
1050 ASSERT_TRUE(mDemuxTests.closeDemux());
1051 ASSERT_TRUE(mFrontendTests.closeFrontend());
1052}
1053
Patrick Rohr1586d212021-11-23 00:40:56 +01001054TEST_P(TunerFilterAidlTest, FilterDelayHintTest) {
1055 description("Test filter time delay hint.");
Gareth Fenn9a808452022-03-31 08:40:00 +01001056 if (!live.hasFrontendConnection) {
1057 return;
1058 }
Patrick Rohr1586d212021-11-23 00:40:56 +01001059 for (const auto& obj : filterMap) {
1060 testDelayHint(obj.second);
1061 }
1062}
1063
Hongguang600a6ae2021-07-08 18:51:51 -07001064TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsSectionFilterTest) {
1065 description("Feed ts data from playback and configure Ts section filter to get output");
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001066 if (!playback.support) {
Hongguang600a6ae2021-07-08 18:51:51 -07001067 return;
1068 }
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001069 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1070 for (auto& configuration : playback_configs) {
1071 if (configuration.sectionFilterId.compare(emptyHardwareId) != 0) {
1072 playback = configuration;
1073 playbackSingleFilterTest(filterMap[playback.sectionFilterId], dvrMap[playback.dvrId]);
1074 }
1075 }
Hongguang600a6ae2021-07-08 18:51:51 -07001076}
1077
1078TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsAudioFilterTest) {
1079 description("Feed ts data from playback and configure Ts audio filter to get output");
1080 if (!playback.support) {
1081 return;
1082 }
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001083 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1084 for (auto& configuration : playback_configs) {
1085 playback = configuration;
1086 playbackSingleFilterTest(filterMap[playback.audioFilterId], dvrMap[playback.dvrId]);
1087 }
Hongguang600a6ae2021-07-08 18:51:51 -07001088}
1089
1090TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsVideoFilterTest) {
1091 description("Feed ts data from playback and configure Ts video filter to get output");
1092 if (!playback.support) {
1093 return;
1094 }
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001095 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1096 for (auto& configuration : playback_configs) {
1097 playback = configuration;
1098 playbackSingleFilterTest(filterMap[playback.videoFilterId], dvrMap[playback.dvrId]);
1099 }
Hongguang600a6ae2021-07-08 18:51:51 -07001100}
1101
Ray Chin62ab6c92022-09-15 15:07:33 +08001102TEST_P(TunerPlaybackAidlTest, SetStatusCheckIntervalHintToPlaybackTest) {
1103 description("Set status check interval hint to playback test.");
1104 if (!playback.support) {
1105 return;
1106 }
1107 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1108 for (auto& configuration : playback_configs) {
1109 playback = configuration;
1110 setStatusCheckIntervalHintTest(STATUS_CHECK_INTERVAL_MS, dvrMap[playback.dvrId]);
1111 }
1112}
1113
Hongguang600a6ae2021-07-08 18:51:51 -07001114TEST_P(TunerRecordAidlTest, RecordDataFlowWithTsRecordFilterTest) {
1115 description("Feed ts data from frontend to recording and test with ts record filter");
1116 if (!record.support) {
1117 return;
1118 }
sadiqsadadb9c51a2024-01-18 13:49:09 -08001119 // Recording is not currently supported for IPTV frontend
sadiqsada7a191392023-11-07 16:09:09 -08001120 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1121 return;
1122 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +00001123 auto record_configs = generateRecordConfigurations();
1124 for (auto& configuration : record_configs) {
1125 record = configuration;
1126 recordSingleFilterTest(filterMap[record.recordFilterId], frontendMap[record.frontendId],
1127 dvrMap[record.dvrRecordId], Dataflow_Context::RECORD);
1128 }
Hongguang600a6ae2021-07-08 18:51:51 -07001129}
1130
1131TEST_P(TunerRecordAidlTest, AttachFiltersToRecordTest) {
1132 description("Attach a single filter to the record dvr test.");
1133 // TODO use parameterized tests
1134 if (!record.support) {
1135 return;
1136 }
sadiqsadadb9c51a2024-01-18 13:49:09 -08001137 // Recording is not currently supported for IPTV frontend
sadiqsada7a191392023-11-07 16:09:09 -08001138 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1139 return;
1140 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +00001141 auto record_configs = generateRecordConfigurations();
1142 for (auto& configuration : record_configs) {
1143 record = configuration;
1144 attachSingleFilterToRecordDvrTest(filterMap[record.recordFilterId],
1145 frontendMap[record.frontendId],
1146 dvrMap[record.dvrRecordId]);
1147 }
Hongguang600a6ae2021-07-08 18:51:51 -07001148}
1149
1150TEST_P(TunerRecordAidlTest, LnbRecordDataFlowWithTsRecordFilterTest) {
1151 description("Feed ts data from Fe with Lnb to recording and test with ts record filter");
1152 if (!lnbRecord.support) {
1153 return;
1154 }
Frankie Lizcanoecba02a2022-07-12 17:56:54 +00001155 vector<LnbRecordHardwareConnections> lnbRecord_configs = generateLnbRecordConfigurations();
1156 if (lnbRecord_configs.empty()) {
1157 ALOGD("No frontends that support satellites.");
1158 return;
1159 }
1160 for (auto& configuration : lnbRecord_configs) {
1161 lnbRecord = configuration;
1162 recordSingleFilterTestWithLnb(filterMap[lnbRecord.recordFilterId],
1163 frontendMap[lnbRecord.frontendId],
1164 dvrMap[lnbRecord.dvrRecordId], lnbMap[lnbRecord.lnbId]);
1165 }
Hongguang600a6ae2021-07-08 18:51:51 -07001166}
1167
Ray Chin62ab6c92022-09-15 15:07:33 +08001168TEST_P(TunerRecordAidlTest, SetStatusCheckIntervalHintToRecordTest) {
1169 description("Set status check interval hint to record test.");
1170 if (!record.support) {
1171 return;
1172 }
sadiqsadadb9c51a2024-01-18 13:49:09 -08001173 // Recording is not currently supported for IPTV frontend
sadiqsada7a191392023-11-07 16:09:09 -08001174 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1175 return;
1176 }
Ray Chin62ab6c92022-09-15 15:07:33 +08001177 auto record_configs = generateRecordConfigurations();
1178 for (auto& configuration : record_configs) {
1179 record = configuration;
1180 setStatusCheckIntervalHintTest(STATUS_CHECK_INTERVAL_MS, frontendMap[record.frontendId],
1181 dvrMap[record.dvrRecordId]);
1182 }
1183}
1184
Hongguang600a6ae2021-07-08 18:51:51 -07001185TEST_P(TunerFrontendAidlTest, TuneFrontend) {
1186 description("Tune one Frontend with specific setting and check Lock event");
1187 if (!live.hasFrontendConnection) {
1188 return;
1189 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001190 auto live_configs = generateLiveConfigurations();
1191 for (auto& configuration : live_configs) {
1192 live = configuration;
1193 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
1194 }
Hongguang600a6ae2021-07-08 18:51:51 -07001195}
1196
1197TEST_P(TunerFrontendAidlTest, AutoScanFrontend) {
1198 description("Run an auto frontend scan with specific setting and check lock scanMessage");
1199 if (!scan.hasFrontendConnection) {
1200 return;
1201 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001202 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1203 for (auto& configuration : scan_configs) {
1204 scan = configuration;
1205 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_AUTO);
1206 }
Hongguang600a6ae2021-07-08 18:51:51 -07001207}
1208
1209TEST_P(TunerFrontendAidlTest, BlindScanFrontend) {
1210 description("Run an blind frontend scan with specific setting and check lock scanMessage");
1211 if (!scan.hasFrontendConnection) {
1212 return;
1213 }
sadiqsada7a191392023-11-07 16:09:09 -08001214 // Blind scan is not applicable for IPTV frontend
1215 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1216 return;
1217 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001218 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1219 for (auto& configuration : scan_configs) {
1220 scan = configuration;
Ray Chin740a0a82023-12-22 19:10:46 +08001221 // Skip test if the frontend implementation doesn't support blind scan
1222 if (!frontendMap[scan.frontendId].supportBlindScan) {
1223 continue;
1224 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001225 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_BLIND);
1226 }
Hongguang600a6ae2021-07-08 18:51:51 -07001227}
1228
1229TEST_P(TunerFrontendAidlTest, TuneFrontendWithFrontendSettings) {
1230 description("Tune one Frontend with setting and check Lock event");
1231 if (!live.hasFrontendConnection) {
1232 return;
1233 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001234 auto live_configs = generateLiveConfigurations();
1235 for (auto& configuration : live_configs) {
1236 live = configuration;
1237 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
1238 }
Hongguang600a6ae2021-07-08 18:51:51 -07001239}
1240
1241TEST_P(TunerFrontendAidlTest, BlindScanFrontendWithEndFrequency) {
1242 description("Run an blind frontend scan with setting and check lock scanMessage");
1243 if (!scan.hasFrontendConnection) {
1244 return;
1245 }
sadiqsada7a191392023-11-07 16:09:09 -08001246 // Blind scan is not application for IPTV frontend
1247 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1248 return;
1249 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001250 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1251 for (auto& configuration : scan_configs) {
1252 scan = configuration;
Ray Chin740a0a82023-12-22 19:10:46 +08001253 // Skip test if the frontend implementation doesn't support blind scan
1254 if (!frontendMap[scan.frontendId].supportBlindScan) {
1255 continue;
1256 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001257 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_BLIND);
1258 }
Hongguang600a6ae2021-07-08 18:51:51 -07001259}
1260
1261TEST_P(TunerFrontendAidlTest, LinkToCiCam) {
1262 description("Test Frontend link to CiCam");
1263 if (!live.hasFrontendConnection) {
1264 return;
1265 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001266 auto live_configs = generateLiveConfigurations();
1267 for (auto& configuration : live_configs) {
1268 live = configuration;
1269 if (!frontendMap[live.frontendId].canConnectToCiCam) {
1270 continue;
1271 }
1272 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -07001273 }
Hongguang600a6ae2021-07-08 18:51:51 -07001274}
1275
Hongguangfcedda02021-12-13 17:08:02 -08001276TEST_P(TunerFrontendAidlTest, getHardwareInfo) {
1277 description("Test Frontend get hardware info");
1278 if (!live.hasFrontendConnection) {
1279 return;
1280 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001281 auto live_configs = generateLiveConfigurations();
1282 for (auto& configuration : live_configs) {
1283 live = configuration;
1284 mFrontendTests.debugInfoTest(frontendMap[live.frontendId]);
1285 }
Hongguangfcedda02021-12-13 17:08:02 -08001286}
1287
Hongguang5766ddf2021-12-23 11:40:37 -08001288TEST_P(TunerFrontendAidlTest, maxNumberOfFrontends) {
1289 description("Test Max Frontend number");
1290 if (!live.hasFrontendConnection) {
1291 return;
1292 }
1293 mFrontendTests.maxNumberOfFrontendsTest();
1294}
1295
Hongguang881190f2022-01-14 13:23:37 -08001296TEST_P(TunerFrontendAidlTest, statusReadinessTest) {
1297 description("Test Max Frontend status readiness");
1298 if (!live.hasFrontendConnection) {
1299 return;
1300 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001301 auto live_configs = generateLiveConfigurations();
1302 for (auto& configuration : live_configs) {
1303 live = configuration;
1304 mFrontendTests.statusReadinessTest(frontendMap[live.frontendId]);
1305 }
Hongguang881190f2022-01-14 13:23:37 -08001306}
1307
Hongguang600a6ae2021-07-08 18:51:51 -07001308TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowVideoFilterTest) {
1309 description("Test Video Filter functionality in Broadcast use case.");
1310 if (!live.hasFrontendConnection) {
1311 return;
1312 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001313 auto live_configs = generateLiveConfigurations();
1314 for (auto& configuration : live_configs) {
1315 live = configuration;
1316 broadcastSingleFilterTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
1317 }
Hongguang600a6ae2021-07-08 18:51:51 -07001318}
1319
1320TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowAudioFilterTest) {
1321 description("Test Audio Filter functionality in Broadcast use case.");
1322 if (!live.hasFrontendConnection) {
1323 return;
1324 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001325 auto live_configs = generateLiveConfigurations();
1326 for (auto& configuration : live_configs) {
1327 live = configuration;
1328 broadcastSingleFilterTest(filterMap[live.audioFilterId], frontendMap[live.frontendId]);
1329 }
Hongguang600a6ae2021-07-08 18:51:51 -07001330}
1331
1332TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowSectionFilterTest) {
1333 description("Test Section Filter functionality in Broadcast use case.");
1334 if (!live.hasFrontendConnection) {
1335 return;
1336 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001337 auto live_configs = generateLiveConfigurations();
1338 for (auto& configuration : live_configs) {
1339 live = configuration;
1340 if (live.sectionFilterId.compare(emptyHardwareId) == 0) {
1341 continue;
1342 }
1343 broadcastSingleFilterTest(filterMap[live.sectionFilterId], frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -07001344 }
Hongguang600a6ae2021-07-08 18:51:51 -07001345}
1346
1347TEST_P(TunerBroadcastAidlTest, IonBufferTest) {
1348 description("Test the av filter data bufferring.");
1349 if (!live.hasFrontendConnection) {
1350 return;
1351 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001352 auto live_configs = generateLiveConfigurations();
1353 for (auto& configuration : live_configs) {
1354 live = configuration;
1355 broadcastSingleFilterTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
1356 }
Hongguang600a6ae2021-07-08 18:51:51 -07001357}
1358
1359TEST_P(TunerBroadcastAidlTest, LnbBroadcastDataFlowVideoFilterTest) {
1360 description("Test Video Filter functionality in Broadcast with Lnb use case.");
1361 if (!lnbLive.support) {
1362 return;
1363 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +00001364 vector<LnbLiveHardwareConnections> lnbLive_configs = generateLnbLiveConfigurations();
1365 if (lnbLive_configs.empty()) {
1366 ALOGD("No frontends that support satellites.");
1367 return;
1368 }
1369 for (auto& combination : lnbLive_configs) {
1370 lnbLive = combination;
1371 broadcastSingleFilterTestWithLnb(filterMap[lnbLive.videoFilterId],
1372 frontendMap[lnbLive.frontendId], lnbMap[lnbLive.lnbId]);
1373 }
Hongguang600a6ae2021-07-08 18:51:51 -07001374}
1375
1376TEST_P(TunerBroadcastAidlTest, MediaFilterWithSharedMemoryHandle) {
1377 description("Test the Media Filter with shared memory handle");
1378 if (!live.hasFrontendConnection) {
1379 return;
1380 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001381 auto live_configs = generateLiveConfigurations();
1382 for (auto& configuration : live_configs) {
1383 live = configuration;
Ray Chin967c8e82024-12-24 12:27:27 +08001384 // shared memory handle is not used by a passthrough filter at all
1385 if (isPassthroughFilter(filterMap[live.videoFilterId])) {
1386 continue;
1387 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001388 mediaFilterUsingSharedMemoryTest(filterMap[live.videoFilterId],
1389 frontendMap[live.frontendId]);
1390 }
Hongguang600a6ae2021-07-08 18:51:51 -07001391}
1392
1393TEST_P(TunerDescramblerAidlTest, CreateDescrambler) {
1394 description("Create Descrambler");
1395 if (!descrambling.support) {
1396 return;
1397 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001398 vector<DescramblingHardwareConnections> descrambling_configs =
1399 generateDescramblingConfigurations();
1400 if (descrambling_configs.empty()) {
1401 ALOGD("No valid descrambling combinations in the configuration file.");
1402 return;
Hongguang600a6ae2021-07-08 18:51:51 -07001403 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001404 for (auto& combination : descrambling_configs) {
1405 descrambling = combination;
1406 int32_t demuxId;
1407 std::shared_ptr<IDemux> demux;
1408 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
Hongguang600a6ae2021-07-08 18:51:51 -07001409
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001410 if (descrambling.hasFrontendConnection) {
1411 int32_t feId;
1412 mFrontendTests.getFrontendIdByType(frontendMap[descrambling.frontendId].type, feId);
1413 ASSERT_TRUE(feId != INVALID_ID);
1414 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
1415 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
1416 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
1417 }
Hongguang600a6ae2021-07-08 18:51:51 -07001418
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001419 ASSERT_TRUE(mDescramblerTests.openDescrambler(demuxId));
1420 ASSERT_TRUE(mDescramblerTests.closeDescrambler());
1421 ASSERT_TRUE(mDemuxTests.closeDemux());
1422
1423 if (descrambling.hasFrontendConnection) {
1424 ASSERT_TRUE(mFrontendTests.closeFrontend());
1425 }
Hongguang600a6ae2021-07-08 18:51:51 -07001426 }
1427}
1428
1429TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTest) {
1430 description("Test ts audio filter in scrambled broadcast use case");
1431 if (!descrambling.support) {
1432 return;
1433 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001434 vector<DescramblingHardwareConnections> descrambling_configs =
1435 generateDescramblingConfigurations();
1436 if (descrambling_configs.empty()) {
1437 ALOGD("No valid descrambling combinations in the configuration file.");
1438 return;
1439 }
1440 for (auto& combination : descrambling_configs) {
1441 descrambling = combination;
1442 set<FilterConfig> filterConfs;
1443 filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.audioFilterId]));
1444 filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.videoFilterId]));
1445 scrambledBroadcastTest(filterConfs, frontendMap[descrambling.frontendId],
Frankie Lizcano82101d22022-07-28 00:12:35 +00001446 descramblerMap[descrambling.descramblerId],
1447 Dataflow_Context::DESCRAMBLING);
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001448 }
Hongguang600a6ae2021-07-08 18:51:51 -07001449}
1450
Frankie Lizcano82101d22022-07-28 00:12:35 +00001451TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTestWithLnb) {
1452 description("Test media filters in scrambled broadcast use case with Lnb");
1453 if (!lnbDescrambling.support) {
1454 return;
1455 }
Frankie Lizcanobcf4ebb2022-08-01 18:06:00 +00001456 auto lnbDescrambling_configs = generateLnbDescramblingConfigurations();
1457 if (lnbDescrambling_configs.empty()) {
1458 ALOGD("No frontends that support satellites.");
1459 return;
1460 }
1461 for (auto& configuration : lnbDescrambling_configs) {
1462 lnbDescrambling = configuration;
1463 set<FilterConfig> filterConfs;
1464 filterConfs.insert(static_cast<FilterConfig>(filterMap[lnbDescrambling.audioFilterId]));
1465 filterConfs.insert(static_cast<FilterConfig>(filterMap[lnbDescrambling.videoFilterId]));
1466 scrambledBroadcastTestWithLnb(filterConfs, frontendMap[lnbDescrambling.frontendId],
1467 descramblerMap[lnbDescrambling.descramblerId],
1468 lnbMap[lnbDescrambling.lnbId]);
1469 }
Frankie Lizcano82101d22022-07-28 00:12:35 +00001470}
1471
Hongguang600a6ae2021-07-08 18:51:51 -07001472INSTANTIATE_TEST_SUITE_P(PerInstance, TunerBroadcastAidlTest,
1473 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1474 android::PrintInstanceNameToString);
1475
1476INSTANTIATE_TEST_SUITE_P(PerInstance, TunerFrontendAidlTest,
1477 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1478 android::PrintInstanceNameToString);
1479
1480INSTANTIATE_TEST_SUITE_P(PerInstance, TunerFilterAidlTest,
1481 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1482 android::PrintInstanceNameToString);
1483
1484INSTANTIATE_TEST_SUITE_P(PerInstance, TunerRecordAidlTest,
1485 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1486 android::PrintInstanceNameToString);
1487
1488INSTANTIATE_TEST_SUITE_P(PerInstance, TunerLnbAidlTest,
1489 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1490 android::PrintInstanceNameToString);
1491
1492INSTANTIATE_TEST_SUITE_P(PerInstance, TunerDemuxAidlTest,
1493 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1494 android::PrintInstanceNameToString);
1495
1496INSTANTIATE_TEST_SUITE_P(PerInstance, TunerPlaybackAidlTest,
1497 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1498 android::PrintInstanceNameToString);
1499
1500INSTANTIATE_TEST_SUITE_P(PerInstance, TunerDescramblerAidlTest,
1501 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1502 android::PrintInstanceNameToString);
1503
1504} // namespace
1505
1506// Start thread pool to receive callbacks from AIDL service.
1507int main(int argc, char** argv) {
1508 ::testing::InitGoogleTest(&argc, argv);
1509 ABinderProcess_setThreadPoolMaxThreadCount(1);
1510 ABinderProcess_startThreadPool();
1511 return RUN_ALL_TESTS();
1512}