blob: 1b507e1f883d1c6c3d7a16ecd3d9a99b584b36b1 [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));
51 mFilterTests.setDemux(demux);
52 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
53 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
54 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
55 if (filterConf.type.mainType == DemuxFilterMainType::IP) {
56 ASSERT_TRUE(mFilterTests.configIpFilterCid(filterConf.ipCid, filterId));
57 }
58 if (filterConf.monitorEventTypes > 0) {
59 ASSERT_TRUE(mFilterTests.configureMonitorEvent(filterId, filterConf.monitorEventTypes));
60 }
61 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
62 ASSERT_TRUE(mFilterTests.startFilter(filterId));
Eddy-SH Chen566240a2023-09-13 15:25:24 +080063 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
64 if (filterConf.monitorEventTypes > 0) {
65 ASSERT_TRUE(mFilterTests.testMonitorEvent(filterId, filterConf.monitorEventTypes));
66 }
67 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -070068 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
69 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
70 ASSERT_TRUE(mDemuxTests.closeDemux());
71 ASSERT_TRUE(mFrontendTests.closeFrontend());
72}
73
74void TunerFilterAidlTest::reconfigSingleFilterInDemuxTest(FilterConfig filterConf,
75 FilterConfig filterReconf,
76 FrontendConfig frontendConf) {
77 int32_t feId;
78 int32_t demuxId;
79 std::shared_ptr<IDemux> demux;
80 int64_t filterId;
81
82 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
83 ASSERT_TRUE(feId != INVALID_ID);
84 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
85 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
86 if (frontendConf.isSoftwareFe) {
87 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[live.dvrSoftwareFeId]);
88 }
89 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
90 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
91 mFrontendTests.setDemux(demux);
92 mFilterTests.setDemux(demux);
93 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
94 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
95 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
96 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
97 ASSERT_TRUE(mFilterTests.startFilter(filterId));
98 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
99 ASSERT_TRUE(mFilterTests.configFilter(filterReconf.settings, filterId));
100 ASSERT_TRUE(mFilterTests.startFilter(filterId));
101 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
102 ASSERT_TRUE(mFilterTests.startIdTest(filterId));
103 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
104 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
105 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
106 ASSERT_TRUE(mDemuxTests.closeDemux());
107 ASSERT_TRUE(mFrontendTests.closeFrontend());
108}
109
110void TunerFilterAidlTest::testTimeFilter(TimeFilterConfig filterConf) {
111 int32_t demuxId;
112 std::shared_ptr<IDemux> demux;
113 DemuxCapabilities caps;
114
115 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
116 ASSERT_TRUE(mDemuxTests.getDemuxCaps(caps));
117 ASSERT_TRUE(caps.bTimeFilter);
118 mFilterTests.setDemux(demux);
119 ASSERT_TRUE(mFilterTests.openTimeFilterInDemux());
120 ASSERT_TRUE(mFilterTests.setTimeStamp(filterConf.timeStamp));
121 ASSERT_TRUE(mFilterTests.getTimeStamp());
122 ASSERT_TRUE(mFilterTests.clearTimeStamp());
123 ASSERT_TRUE(mFilterTests.closeTimeFilter());
124 ASSERT_TRUE(mDemuxTests.closeDemux());
125}
126
127void TunerBroadcastAidlTest::broadcastSingleFilterTest(FilterConfig filterConf,
128 FrontendConfig frontendConf) {
129 int32_t feId;
130 int32_t demuxId;
131 std::shared_ptr<IDemux> demux;
132 int64_t filterId;
133
134 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
135 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
136 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
Frankie Lizcano87421812022-07-28 17:13:01 +0000137 if (mLnbId != INVALID_LNB_ID) {
138 ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
Hongguang600a6ae2021-07-08 18:51:51 -0700139 }
140 if (frontendConf.isSoftwareFe) {
141 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[live.dvrSoftwareFeId]);
142 }
143 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
144 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
145 mFrontendTests.setDemux(demux);
146 mFilterTests.setDemux(demux);
147 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
148 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
149 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
150 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
151 ASSERT_TRUE(mFilterTests.startFilter(filterId));
152 // tune test
153 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
154 ASSERT_TRUE(filterDataOutputTest());
155 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
156 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
157 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
158 ASSERT_TRUE(mDemuxTests.closeDemux());
159 ASSERT_TRUE(mFrontendTests.closeFrontend());
160}
161
162void TunerBroadcastAidlTest::broadcastSingleFilterTestWithLnb(FilterConfig filterConf,
163 FrontendConfig frontendConf,
164 LnbConfig lnbConf) {
165 if (lnbConf.name.compare(emptyHardwareId) == 0) {
166 vector<int32_t> ids;
167 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
168 ASSERT_TRUE(ids.size() > 0);
169 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
Frankie Lizcano87421812022-07-28 17:13:01 +0000170 mLnbId = ids[0];
Hongguang600a6ae2021-07-08 18:51:51 -0700171 } else {
Frankie Lizcano87421812022-07-28 17:13:01 +0000172 ASSERT_TRUE(mLnbTests.openLnbByName(lnbConf.name, mLnbId));
Hongguang600a6ae2021-07-08 18:51:51 -0700173 }
174 ASSERT_TRUE(mLnbTests.setLnbCallback());
175 ASSERT_TRUE(mLnbTests.setVoltage(lnbConf.voltage));
176 ASSERT_TRUE(mLnbTests.setTone(lnbConf.tone));
177 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConf.position));
Frankie Lizcanod1f520e2022-07-26 20:05:46 +0000178 if (!frontendConf.isSoftwareFe) {
179 broadcastSingleFilterTest(filterConf, frontendConf);
180 }
Hongguang600a6ae2021-07-08 18:51:51 -0700181 ASSERT_TRUE(mLnbTests.closeLnb());
Frankie Lizcano87421812022-07-28 17:13:01 +0000182 mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700183}
184
185void TunerBroadcastAidlTest::mediaFilterUsingSharedMemoryTest(FilterConfig filterConf,
186 FrontendConfig frontendConf) {
187 int32_t feId;
188 int32_t demuxId;
189 std::shared_ptr<IDemux> demux;
190 int64_t filterId;
191
192 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
193 ASSERT_TRUE(feId != INVALID_ID);
194 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
195 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
196 if (frontendConf.isSoftwareFe) {
197 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[live.dvrSoftwareFeId]);
198 }
199 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
200 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
201 mFrontendTests.setDemux(demux);
202 mFilterTests.setDemux(demux);
203 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
204 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
205 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
206 ASSERT_TRUE(mFilterTests.getSharedAvMemoryHandle(filterId));
207 ASSERT_TRUE(mFilterTests.configAvFilterStreamType(filterConf.streamType, filterId));
208 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
209 ASSERT_TRUE(mFilterTests.startFilter(filterId));
210 // tune test
211 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
212 ASSERT_TRUE(filterDataOutputTest());
213 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
214 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
215 ASSERT_TRUE(mFilterTests.releaseShareAvHandle(filterId));
216 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
217 ASSERT_TRUE(mDemuxTests.closeDemux());
218 ASSERT_TRUE(mFrontendTests.closeFrontend());
219}
220
221void TunerPlaybackAidlTest::playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf) {
222 int32_t demuxId;
223 std::shared_ptr<IDemux> demux;
224 int64_t filterId;
225
226 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
227 mFilterTests.setDemux(demux);
228 mDvrTests.setDemux(demux);
229 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
230 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrConf.settings));
231 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
232 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
233 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
234 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
235 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
236 mDvrTests.startPlaybackInputThread(dvrConf.playbackInputFile,
237 dvrConf.settings.get<DvrSettings::Tag::playback>());
238 ASSERT_TRUE(mDvrTests.startDvrPlayback());
239 ASSERT_TRUE(mFilterTests.startFilter(filterId));
240 ASSERT_TRUE(filterDataOutputTest());
241 mDvrTests.stopPlaybackThread();
242 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
243 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
244 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
245 mDvrTests.closeDvrPlayback();
246 ASSERT_TRUE(mDemuxTests.closeDemux());
247}
248
Ray Chin62ab6c92022-09-15 15:07:33 +0800249void TunerPlaybackAidlTest::setStatusCheckIntervalHintTest(int64_t statusCheckIntervalHint,
250 DvrConfig dvrConf) {
251 int32_t demuxId;
252 std::shared_ptr<IDemux> demux;
253
254 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
255 mDvrTests.setDemux(demux);
256 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
257 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrConf.settings));
258 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
259
260 ASSERT_TRUE(mDvrTests.setPlaybackStatusCheckIntervalHint(statusCheckIntervalHint));
261
262 mDvrTests.startPlaybackInputThread(dvrConf.playbackInputFile,
263 dvrConf.settings.get<DvrSettings::Tag::playback>());
264 ASSERT_TRUE(mDvrTests.startDvrPlayback());
265 mDvrTests.stopPlaybackThread();
266 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
267 mDvrTests.closeDvrPlayback();
268 ASSERT_TRUE(mDemuxTests.closeDemux());
269}
270
Hongguang600a6ae2021-07-08 18:51:51 -0700271void TunerRecordAidlTest::recordSingleFilterTestWithLnb(FilterConfig filterConf,
272 FrontendConfig frontendConf,
273 DvrConfig dvrConf, LnbConfig lnbConf) {
274 if (lnbConf.name.compare(emptyHardwareId) == 0) {
275 vector<int32_t> ids;
276 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
277 ASSERT_TRUE(ids.size() > 0);
278 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
Frankie Lizcano87421812022-07-28 17:13:01 +0000279 mLnbId = ids[0];
Hongguang600a6ae2021-07-08 18:51:51 -0700280 } else {
Frankie Lizcano87421812022-07-28 17:13:01 +0000281 ASSERT_TRUE(mLnbTests.openLnbByName(lnbConf.name, mLnbId));
Hongguang600a6ae2021-07-08 18:51:51 -0700282 }
283 ASSERT_TRUE(mLnbTests.setLnbCallback());
284 ASSERT_TRUE(mLnbTests.setVoltage(lnbConf.voltage));
285 ASSERT_TRUE(mLnbTests.setTone(lnbConf.tone));
286 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConf.position));
287 for (auto msgName : lnbRecord.diseqcMsgs) {
288 ASSERT_TRUE(mLnbTests.sendDiseqcMessage(diseqcMsgMap[msgName]));
289 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000290 if (!frontendConf.isSoftwareFe) {
291 recordSingleFilterTest(filterConf, frontendConf, dvrConf, Dataflow_Context::LNBRECORD);
292 }
Hongguang600a6ae2021-07-08 18:51:51 -0700293 ASSERT_TRUE(mLnbTests.closeLnb());
Frankie Lizcano87421812022-07-28 17:13:01 +0000294 mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700295}
296
297void TunerRecordAidlTest::attachSingleFilterToRecordDvrTest(FilterConfig filterConf,
298 FrontendConfig frontendConf,
299 DvrConfig dvrConf) {
300 int32_t demuxId;
301 std::shared_ptr<IDemux> demux;
302 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
303 mDvrTests.setDemux(demux);
304
305 DvrConfig dvrSourceConfig;
306 if (record.hasFrontendConnection) {
307 int32_t feId;
308 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
309 ASSERT_TRUE(feId != INVALID_ID);
310 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
311 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
312 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
313 } else {
314 dvrSourceConfig = dvrMap[record.dvrSourceId];
315 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
316 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
317 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
318 }
319
320 int64_t filterId;
321 std::shared_ptr<IFilter> filter;
322 mFilterTests.setDemux(demux);
323
324 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
325 ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
326 ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
327
328 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
329 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
330 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
331 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
332 filter = mFilterTests.getFilterById(filterId);
333 ASSERT_TRUE(filter != nullptr);
334 ASSERT_TRUE(mDvrTests.attachFilterToDvr(filter));
335 ASSERT_TRUE(mDvrTests.startDvrRecord());
336 ASSERT_TRUE(mFilterTests.startFilter(filterId));
337 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
338 ASSERT_TRUE(mDvrTests.stopDvrRecord());
339 ASSERT_TRUE(mDvrTests.detachFilterToDvr(filter));
340 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
341 mDvrTests.closeDvrRecord();
342 ASSERT_TRUE(mDemuxTests.closeDemux());
343
344 if (record.hasFrontendConnection) {
345 ASSERT_TRUE(mFrontendTests.closeFrontend());
346 }
347}
348
349void TunerRecordAidlTest::recordSingleFilterTest(FilterConfig filterConf,
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000350 FrontendConfig frontendConf, DvrConfig dvrConf,
351 Dataflow_Context context) {
Hongguang600a6ae2021-07-08 18:51:51 -0700352 int32_t demuxId;
353 std::shared_ptr<IDemux> demux;
354 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
355 mDvrTests.setDemux(demux);
356
357 DvrConfig dvrSourceConfig;
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000358 if (context == Dataflow_Context::RECORD) {
359 if (record.hasFrontendConnection) {
360 int32_t feId;
361 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
362 ASSERT_TRUE(feId != INVALID_ID);
363 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
364 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
365 if (frontendConf.isSoftwareFe) {
366 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[record.dvrSoftwareFeId]);
367 }
368 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
369 mFrontendTests.setDvrTests(&mDvrTests);
370 } else {
371 dvrSourceConfig = dvrMap[record.dvrSourceId];
372 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
373 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
374 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
375 }
376 } else if (context == Dataflow_Context::LNBRECORD) {
377 // If function arrives here, frontend should not be software, so no need to configure a dvr
378 // source or dvr fe connection that might be used for recording without an Lnb
Hongguang600a6ae2021-07-08 18:51:51 -0700379 int32_t feId;
380 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
381 ASSERT_TRUE(feId != INVALID_ID);
382 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
383 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000384 if (mLnbId != INVALID_LNB_ID) {
385 ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
386 } else {
387 FAIL();
Hongguang600a6ae2021-07-08 18:51:51 -0700388 }
389 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
390 mFrontendTests.setDvrTests(&mDvrTests);
Hongguang600a6ae2021-07-08 18:51:51 -0700391 }
392
393 int64_t filterId;
394 std::shared_ptr<IFilter> filter;
395 mFilterTests.setDemux(demux);
396 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
397 ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
398 ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
399 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
400 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
401 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
402 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
403 filter = mFilterTests.getFilterById(filterId);
404 ASSERT_TRUE(filter != nullptr);
405 mDvrTests.startRecordOutputThread(dvrConf.settings.get<DvrSettings::Tag::record>());
406 ASSERT_TRUE(mDvrTests.attachFilterToDvr(filter));
407 ASSERT_TRUE(mDvrTests.startDvrRecord());
408 ASSERT_TRUE(mFilterTests.startFilter(filterId));
409
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000410 if (context == Dataflow_Context::RECORD) {
411 if (record.hasFrontendConnection) {
412 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
413 } else {
414 // Start DVR Source
415 mDvrTests.startPlaybackInputThread(
416 dvrSourceConfig.playbackInputFile,
417 dvrSourceConfig.settings.get<DvrSettings::Tag::playback>());
418 ASSERT_TRUE(mDvrTests.startDvrPlayback());
419 }
420 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700421 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700422 }
Hongguang600a6ae2021-07-08 18:51:51 -0700423 mDvrTests.testRecordOutput();
424 mDvrTests.stopRecordThread();
425
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000426 if (context == Dataflow_Context::RECORD) {
427 if (record.hasFrontendConnection) {
428 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
429 } else {
430 mDvrTests.stopPlaybackThread();
431 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
432 }
433 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700434 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700435 }
436
437 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
438 ASSERT_TRUE(mDvrTests.stopDvrRecord());
439 ASSERT_TRUE(mDvrTests.detachFilterToDvr(filter));
440 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
441 mDvrTests.closeDvrRecord();
442
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000443 if (context == Dataflow_Context::RECORD) {
444 if (record.hasFrontendConnection) {
445 ASSERT_TRUE(mFrontendTests.closeFrontend());
446 } else {
447 mDvrTests.closeDvrPlayback();
448 }
449 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700450 ASSERT_TRUE(mFrontendTests.closeFrontend());
Hongguang600a6ae2021-07-08 18:51:51 -0700451 }
452
453 ASSERT_TRUE(mDemuxTests.closeDemux());
454}
455
Ray Chin62ab6c92022-09-15 15:07:33 +0800456void TunerRecordAidlTest::setStatusCheckIntervalHintTest(int64_t statusCheckIntervalHint,
457 FrontendConfig frontendConf,
458 DvrConfig dvrConf) {
459 int32_t demuxId;
460 std::shared_ptr<IDemux> demux;
461 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
462 mDvrTests.setDemux(demux);
463
464 DvrConfig dvrSourceConfig;
465 if (record.hasFrontendConnection) {
466 int32_t feId;
467 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
468 ASSERT_TRUE(feId != INVALID_ID);
469 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
470 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
471 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
472 } else {
473 dvrSourceConfig = dvrMap[record.dvrSourceId];
474 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
475 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
476 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
477 }
478
479 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
480 ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
481 ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
482
483 ASSERT_TRUE(mDvrTests.setRecordStatusCheckIntervalHint(statusCheckIntervalHint));
484
485 ASSERT_TRUE(mDvrTests.startDvrRecord());
486 ASSERT_TRUE(mDvrTests.stopDvrRecord());
487 mDvrTests.closeDvrRecord();
488 ASSERT_TRUE(mDemuxTests.closeDemux());
489
490 if (record.hasFrontendConnection) {
491 ASSERT_TRUE(mFrontendTests.closeFrontend());
492 }
493}
494
Hongguang600a6ae2021-07-08 18:51:51 -0700495void TunerDescramblerAidlTest::scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
496 FrontendConfig frontendConf,
Frankie Lizcano82101d22022-07-28 00:12:35 +0000497 DescramblerConfig descConfig,
498 Dataflow_Context context) {
Hongguang600a6ae2021-07-08 18:51:51 -0700499 int32_t demuxId;
500 std::shared_ptr<IDemux> demux;
501 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
502
503 DvrConfig dvrSourceConfig;
Frankie Lizcano82101d22022-07-28 00:12:35 +0000504 if (context == Dataflow_Context::DESCRAMBLING) {
505 if (descrambling.hasFrontendConnection) {
506 int32_t feId;
507 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
508 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
509 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
510 if (frontendConf.isSoftwareFe) {
511 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[descrambling.dvrSoftwareFeId]);
512 }
513 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
514 mFrontendTests.setDemux(demux);
515 } else {
516 dvrSourceConfig = dvrMap[descrambling.dvrSourceId];
517 mDvrTests.setDemux(demux);
518 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
519 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
520 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
521 }
522 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700523 int32_t feId;
524 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
525 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
526 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
Frankie Lizcano82101d22022-07-28 00:12:35 +0000527 if (mLnbId != INVALID_LNB_ID) {
528 ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
529 } else {
530 // If, for some reason, the test got here without failing. We fail it here.
531 ALOGD("mLnbId is null. Something went wrong. Exiting ScrambledBroadcastWithLnbId.");
532 FAIL();
Hongguang600a6ae2021-07-08 18:51:51 -0700533 }
534 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
535 mFrontendTests.setDemux(demux);
Hongguang600a6ae2021-07-08 18:51:51 -0700536 }
537
538 set<int64_t> filterIds;
539 int64_t filterId;
540 set<struct FilterConfig>::iterator config;
541 set<int64_t>::iterator id;
542 mFilterTests.setDemux(demux);
543 for (config = mediaFilterConfs.begin(); config != mediaFilterConfs.end(); config++) {
544 ASSERT_TRUE(mFilterTests.openFilterInDemux((*config).type, (*config).bufferSize));
545 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
546 ASSERT_TRUE(mFilterTests.configFilter((*config).settings, filterId));
547 filterIds.insert(filterId);
548 }
549 ASSERT_TRUE(mDescramblerTests.openDescrambler(demuxId));
550 vector<uint8_t> token;
551 ASSERT_TRUE(mDescramblerTests.getKeyToken(descConfig.casSystemId, descConfig.provisionStr,
552 descConfig.hidlPvtData, token));
553 mDescramblerTests.setKeyToken(token);
554 vector<DemuxPid> pids;
555 DemuxPid pid;
556 for (config = mediaFilterConfs.begin(); config != mediaFilterConfs.end(); config++) {
557 ASSERT_TRUE(mDescramblerTests.getDemuxPidFromFilterSettings((*config).type,
558 (*config).settings, pid));
559 pids.push_back(pid);
560 ASSERT_TRUE(mDescramblerTests.addPid(pid, nullptr));
561 }
562 for (id = filterIds.begin(); id != filterIds.end(); id++) {
563 ASSERT_TRUE(mFilterTests.startFilter(*id));
564 }
565
Frankie Lizcano82101d22022-07-28 00:12:35 +0000566 if (context == Dataflow_Context::DESCRAMBLING) {
567 if (descrambling.hasFrontendConnection) {
568 // tune test
569 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
570 } else {
571 // Start DVR Source
572 mDvrTests.startPlaybackInputThread(
573 dvrSourceConfig.playbackInputFile,
574 dvrSourceConfig.settings.get<DvrSettings::Tag::playback>());
575 ASSERT_TRUE(mDvrTests.startDvrPlayback());
576 }
577 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700578 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700579 }
580
581 ASSERT_TRUE(filterDataOutputTest());
582
Frankie Lizcano82101d22022-07-28 00:12:35 +0000583 if (context == Dataflow_Context::DESCRAMBLING) {
584 if (descrambling.hasFrontendConnection) {
585 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
586 } else {
587 mDvrTests.stopPlaybackThread();
588 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
589 }
590 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700591 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700592 }
593
594 for (id = filterIds.begin(); id != filterIds.end(); id++) {
595 ASSERT_TRUE(mFilterTests.stopFilter(*id));
596 }
597 for (auto pid : pids) {
598 ASSERT_TRUE(mDescramblerTests.removePid(pid, nullptr));
599 }
600 ASSERT_TRUE(mDescramblerTests.closeDescrambler());
601 for (id = filterIds.begin(); id != filterIds.end(); id++) {
602 ASSERT_TRUE(mFilterTests.closeFilter(*id));
603 }
604
Frankie Lizcano82101d22022-07-28 00:12:35 +0000605 if (context == Dataflow_Context::DESCRAMBLING) {
606 if (descrambling.hasFrontendConnection) {
607 ASSERT_TRUE(mFrontendTests.closeFrontend());
608 } else {
609 mDvrTests.closeDvrPlayback();
610 }
611 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700612 ASSERT_TRUE(mFrontendTests.closeFrontend());
Hongguang600a6ae2021-07-08 18:51:51 -0700613 }
614
615 ASSERT_TRUE(mDemuxTests.closeDemux());
616}
617
Frankie Lizcano82101d22022-07-28 00:12:35 +0000618void TunerDescramblerAidlTest::scrambledBroadcastTestWithLnb(
619 set<struct FilterConfig>& mediaFilterConfs, FrontendConfig& frontendConf,
620 DescramblerConfig& descConfig, LnbConfig& lnbConfig) {
621 // We can test the Lnb individually and make sure it functions properly. If the frontend is
622 // software, we cannot test the whole dataflow. If the frontend is hardware, we can
623 if (lnbConfig.name.compare(emptyHardwareId) == 0) {
624 vector<int32_t> ids;
625 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
626 ASSERT_TRUE(ids.size() > 0);
627 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
628 mLnbId = ids[0];
629 } else {
630 ASSERT_TRUE(mLnbTests.openLnbByName(lnbConfig.name, mLnbId));
631 }
632 // Once Lnb is opened, test some of its basic functionality
633 ASSERT_TRUE(mLnbTests.setLnbCallback());
634 ASSERT_TRUE(mLnbTests.setVoltage(lnbConfig.voltage));
635 ASSERT_TRUE(mLnbTests.setTone(lnbConfig.tone));
636 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConfig.position));
637 if (!frontendConf.isSoftwareFe) {
638 ALOGD("Frontend is not software, testing entire dataflow.");
639 scrambledBroadcastTest(mediaFilterConfs, frontendConf, descConfig,
640 Dataflow_Context::LNBDESCRAMBLING);
641 } else {
642 ALOGD("Frontend is software, did not test the entire dataflow, but tested the Lnb "
643 "individually.");
644 }
645 ASSERT_TRUE(mLnbTests.closeLnb());
646 mLnbId = INVALID_LNB_ID;
647}
648
Hongguang600a6ae2021-07-08 18:51:51 -0700649TEST_P(TunerLnbAidlTest, SendDiseqcMessageToLnb) {
650 description("Open and configure an Lnb with specific settings then send a diseqc msg to it.");
651 if (!lnbLive.support) {
652 return;
653 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000654 vector<LnbLiveHardwareConnections> lnbLive_configs = generateLnbLiveConfigurations();
655 if (lnbLive_configs.empty()) {
656 ALOGD("No frontends that support satellites.");
657 return;
Hongguang600a6ae2021-07-08 18:51:51 -0700658 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000659 for (auto& combination : lnbLive_configs) {
660 lnbLive = combination;
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000661 if (lnbMap[lnbLive.lnbId].name.compare(emptyHardwareId) == 0) {
662 vector<int32_t> ids;
663 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
664 ASSERT_TRUE(ids.size() > 0);
665 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
666 } else {
667 int32_t id;
668 ASSERT_TRUE(mLnbTests.openLnbByName(lnbMap[lnbLive.lnbId].name, id));
669 }
670 ASSERT_TRUE(mLnbTests.setLnbCallback());
671 ASSERT_TRUE(mLnbTests.setVoltage(lnbMap[lnbLive.lnbId].voltage));
672 ASSERT_TRUE(mLnbTests.setTone(lnbMap[lnbLive.lnbId].tone));
673 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbMap[lnbLive.lnbId].position));
674 for (auto msgName : lnbLive.diseqcMsgs) {
675 ASSERT_TRUE(mLnbTests.sendDiseqcMessage(diseqcMsgMap[msgName]));
676 }
677 ASSERT_TRUE(mLnbTests.closeLnb());
Hongguang600a6ae2021-07-08 18:51:51 -0700678 }
Hongguang600a6ae2021-07-08 18:51:51 -0700679}
680
681TEST_P(TunerDemuxAidlTest, openDemux) {
682 description("Open and close a Demux.");
683 if (!live.hasFrontendConnection) {
684 return;
685 }
sadiqsada7a191392023-11-07 16:09:09 -0800686 // Do not execute tests for IPTV Frontend
687 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
688 return;
689 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000690 auto live_configs = generateLiveConfigurations();
691 for (auto& configuration : live_configs) {
692 live = configuration;
693 int32_t feId;
694 int32_t demuxId;
695 std::shared_ptr<IDemux> demux;
696 mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId);
697 ASSERT_TRUE(feId != INVALID_ID);
698 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
699 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
700 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
701 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
702 ASSERT_TRUE(mDemuxTests.closeDemux());
703 ASSERT_TRUE(mFrontendTests.closeFrontend());
704 }
Hongguang600a6ae2021-07-08 18:51:51 -0700705}
706
Kensuke Miyagi73b18ac2022-11-07 10:49:09 -0800707TEST_P(TunerDemuxAidlTest, openDemuxById) {
708 description("Open (with id) and close a Demux.");
709 std::vector<int32_t> demuxIds;
710 ASSERT_TRUE(mDemuxTests.getDemuxIds(demuxIds));
711 for (int i = 0; i < demuxIds.size(); i++) {
712 std::shared_ptr<IDemux> demux;
713 ASSERT_TRUE(mDemuxTests.openDemuxById(demuxIds[i], demux));
714 ASSERT_TRUE(mDemuxTests.closeDemux());
715 }
716}
717
718TEST_P(TunerDemuxAidlTest, getDemuxInfo) {
719 description("Check getDemuxInfo against demux caps");
720 std::vector<int32_t> demuxIds;
721 ASSERT_TRUE(mDemuxTests.getDemuxIds(demuxIds));
722 int32_t combinedFilterTypes = 0;
723 for (int i = 0; i < demuxIds.size(); i++) {
724 DemuxInfo demuxInfo;
725 ASSERT_TRUE(mDemuxTests.getDemuxInfo(demuxIds[i], demuxInfo));
726 combinedFilterTypes |= demuxInfo.filterTypes;
727 }
728 if (demuxIds.size() > 0) {
729 DemuxCapabilities demuxCaps;
730 ASSERT_TRUE(mDemuxTests.getDemuxCaps(demuxCaps));
731 ASSERT_TRUE(demuxCaps.filterCaps == combinedFilterTypes);
732 }
733}
734
Hongguang600a6ae2021-07-08 18:51:51 -0700735TEST_P(TunerDemuxAidlTest, getAvSyncTime) {
736 description("Get the A/V sync time from a PCR filter.");
737 if (!live.hasFrontendConnection) {
738 return;
739 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000740 auto live_configs = generateLiveConfigurations();
741 for (auto& configuration : live_configs) {
742 live = configuration;
743 if (live.pcrFilterId.compare(emptyHardwareId) == 0) {
744 continue;
745 }
746 int32_t feId;
747 int32_t demuxId;
748 std::shared_ptr<IDemux> demux;
749 int64_t mediaFilterId;
750 int64_t pcrFilterId;
751 int32_t avSyncHwId;
752 std::shared_ptr<IFilter> mediaFilter;
Hongguang600a6ae2021-07-08 18:51:51 -0700753
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000754 mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId);
755 ASSERT_TRUE(feId != INVALID_ID);
756 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
757 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
758 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
759 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
760 mFilterTests.setDemux(demux);
761 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterMap[live.videoFilterId].type,
762 filterMap[live.videoFilterId].bufferSize));
763 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(mediaFilterId));
764 ASSERT_TRUE(
765 mFilterTests.configFilter(filterMap[live.videoFilterId].settings, mediaFilterId));
766 mediaFilter = mFilterTests.getFilterById(mediaFilterId);
767 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterMap[live.pcrFilterId].type,
768 filterMap[live.pcrFilterId].bufferSize));
769 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(pcrFilterId));
770 ASSERT_TRUE(mFilterTests.configFilter(filterMap[live.pcrFilterId].settings, pcrFilterId));
771 ASSERT_TRUE(mDemuxTests.getAvSyncId(mediaFilter, avSyncHwId));
772 ASSERT_TRUE(pcrFilterId == avSyncHwId);
773 ASSERT_TRUE(mDemuxTests.getAvSyncTime(pcrFilterId));
774 ASSERT_TRUE(mFilterTests.closeFilter(pcrFilterId));
775 ASSERT_TRUE(mFilterTests.closeFilter(mediaFilterId));
776 ASSERT_TRUE(mDemuxTests.closeDemux());
777 ASSERT_TRUE(mFrontendTests.closeFrontend());
778 }
Hongguang600a6ae2021-07-08 18:51:51 -0700779}
780
781TEST_P(TunerFilterAidlTest, StartFilterInDemux) {
782 description("Open and start a filter in Demux.");
783 if (!live.hasFrontendConnection) {
784 return;
785 }
sadiqsada7a191392023-11-07 16:09:09 -0800786 // Do not execute tests for IPTV Frontend
787 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
788 return;
789 }
Hongguang600a6ae2021-07-08 18:51:51 -0700790 // TODO use parameterized tests
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000791 auto live_configs = generateLiveConfigurations();
792 for (auto& configuration : live_configs) {
793 live = configuration;
794 configSingleFilterInDemuxTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
795 }
Hongguang600a6ae2021-07-08 18:51:51 -0700796}
797
798TEST_P(TunerFilterAidlTest, ConfigIpFilterInDemuxWithCid) {
799 description("Open and configure an ip filter in Demux.");
800 // TODO use parameterized tests
801 if (!live.hasFrontendConnection) {
802 return;
803 }
sadiqsada7a191392023-11-07 16:09:09 -0800804 // Do not execute tests for IPTV Frontend
805 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
806 return;
807 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000808 auto live_configs = generateLiveConfigurations();
809 for (auto& configuration : live_configs) {
810 live = configuration;
811 if (live.ipFilterId.compare(emptyHardwareId) == 0) {
812 continue;
813 }
814 configSingleFilterInDemuxTest(filterMap[live.ipFilterId], frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -0700815 }
Hongguang600a6ae2021-07-08 18:51:51 -0700816}
817
818TEST_P(TunerFilterAidlTest, ReconfigFilterToReceiveStartId) {
819 description("Recofigure and restart a filter to test start id.");
820 if (!live.hasFrontendConnection) {
821 return;
822 }
sadiqsada7a191392023-11-07 16:09:09 -0800823 // Do not execute tests for IPTV Frontend
824 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
825 return;
826 }
Hongguang600a6ae2021-07-08 18:51:51 -0700827 // TODO use parameterized tests
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000828 auto live_configs = generateLiveConfigurations();
829 for (auto& configuration : live_configs) {
830 live = configuration;
831 reconfigSingleFilterInDemuxTest(filterMap[live.videoFilterId],
832 filterMap[live.videoFilterId],
833 frontendMap[live.frontendId]);
834 }
Hongguang600a6ae2021-07-08 18:51:51 -0700835}
836
837TEST_P(TunerFilterAidlTest, SetFilterLinkage) {
838 description("Pick up all the possible linkages from the demux caps and set them up.");
839 DemuxCapabilities caps;
840 int32_t demuxId;
841 std::shared_ptr<IDemux> demux;
842 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
843 ASSERT_TRUE(mDemuxTests.getDemuxCaps(caps));
844 mFilterTests.setDemux(demux);
845 for (int i = 0; i < caps.linkCaps.size(); i++) {
846 uint32_t bitMask = 1;
847 for (int j = 0; j < FILTER_MAIN_TYPE_BIT_COUNT; j++) {
848 if (caps.linkCaps[i] & (bitMask << j)) {
849 int64_t sourceFilterId;
850 int64_t sinkFilterId;
851 ASSERT_TRUE(mFilterTests.openFilterInDemux(getLinkageFilterType(i), FMQ_SIZE_16M));
852 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(sourceFilterId));
853 ASSERT_TRUE(mFilterTests.openFilterInDemux(getLinkageFilterType(j), FMQ_SIZE_16M));
854 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(sinkFilterId));
855 ASSERT_TRUE(mFilterTests.setFilterDataSource(sourceFilterId, sinkFilterId));
856 ASSERT_TRUE(mFilterTests.setFilterDataSourceToDemux(sinkFilterId));
857 ASSERT_TRUE(mFilterTests.closeFilter(sinkFilterId));
858 ASSERT_TRUE(mFilterTests.closeFilter(sourceFilterId));
859 }
860 }
861 }
862 ASSERT_TRUE(mDemuxTests.closeDemux());
863}
864
865TEST_P(TunerFilterAidlTest, testTimeFilter) {
866 description("Open a timer filter in Demux and set time stamp.");
867 if (!timeFilter.support) {
868 return;
869 }
870 // TODO use parameterized tests
Frankie Lizcano0c069532022-07-14 20:20:46 +0000871 auto timeFilter_configs = generateTimeFilterConfigurations();
872 for (auto& configuration : timeFilter_configs) {
873 timeFilter = configuration;
874 testTimeFilter(timeFilterMap[timeFilter.timeFilterId]);
875 }
Hongguang600a6ae2021-07-08 18:51:51 -0700876}
877
Gareth Fenn9a808452022-03-31 08:40:00 +0100878static bool isEventProducingFilter(const FilterConfig& filterConfig) {
879 switch (filterConfig.type.mainType) {
880 case DemuxFilterMainType::TS: {
881 auto tsFilterType =
882 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tsFilterType>();
883 return (tsFilterType == DemuxTsFilterType::SECTION ||
884 tsFilterType == DemuxTsFilterType::PES ||
885 tsFilterType == DemuxTsFilterType::AUDIO ||
886 tsFilterType == DemuxTsFilterType::VIDEO ||
887 tsFilterType == DemuxTsFilterType::RECORD ||
888 tsFilterType == DemuxTsFilterType::TEMI);
889 }
890 case DemuxFilterMainType::MMTP: {
891 auto mmtpFilterType =
892 filterConfig.type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>();
893 return (mmtpFilterType == DemuxMmtpFilterType::SECTION ||
894 mmtpFilterType == DemuxMmtpFilterType::PES ||
895 mmtpFilterType == DemuxMmtpFilterType::AUDIO ||
896 mmtpFilterType == DemuxMmtpFilterType::VIDEO ||
897 mmtpFilterType == DemuxMmtpFilterType::RECORD ||
898 mmtpFilterType == DemuxMmtpFilterType::DOWNLOAD);
899 }
900 case DemuxFilterMainType::IP: {
901 auto ipFilterType =
902 filterConfig.type.subType.get<DemuxFilterSubType::Tag::ipFilterType>();
903 return (ipFilterType == DemuxIpFilterType::SECTION);
904 }
905 case DemuxFilterMainType::TLV: {
906 auto tlvFilterType =
907 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tlvFilterType>();
908 return (tlvFilterType == DemuxTlvFilterType::SECTION);
909 }
910 case DemuxFilterMainType::ALP: {
911 auto alpFilterType =
912 filterConfig.type.subType.get<DemuxFilterSubType::Tag::alpFilterType>();
913 return (alpFilterType == DemuxAlpFilterType::SECTION);
914 }
915 default:
916 return false;
917 }
918}
919
Patrick Rohr1586d212021-11-23 00:40:56 +0100920static bool isMediaFilter(const FilterConfig& filterConfig) {
921 switch (filterConfig.type.mainType) {
922 case DemuxFilterMainType::TS: {
923 // TS Audio and Video filters are media filters
924 auto tsFilterType =
925 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tsFilterType>();
926 return (tsFilterType == DemuxTsFilterType::AUDIO ||
927 tsFilterType == DemuxTsFilterType::VIDEO);
928 }
929 case DemuxFilterMainType::MMTP: {
930 // MMTP Audio and Video filters are media filters
931 auto mmtpFilterType =
932 filterConfig.type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>();
933 return (mmtpFilterType == DemuxMmtpFilterType::AUDIO ||
934 mmtpFilterType == DemuxMmtpFilterType::VIDEO);
935 }
936 default:
937 return false;
938 }
939}
Patrick Rohr149b0872021-11-20 00:39:37 +0100940
Patrick Rohr1586d212021-11-23 00:40:56 +0100941static int getDemuxFilterEventDataLength(const DemuxFilterEvent& event) {
942 switch (event.getTag()) {
943 case DemuxFilterEvent::Tag::section:
944 return event.get<DemuxFilterEvent::Tag::section>().dataLength;
945 case DemuxFilterEvent::Tag::media:
946 return event.get<DemuxFilterEvent::Tag::media>().dataLength;
947 case DemuxFilterEvent::Tag::pes:
948 return event.get<DemuxFilterEvent::Tag::pes>().dataLength;
949 case DemuxFilterEvent::Tag::download:
950 return event.get<DemuxFilterEvent::Tag::download>().dataLength;
951 case DemuxFilterEvent::Tag::ipPayload:
952 return event.get<DemuxFilterEvent::Tag::ipPayload>().dataLength;
953
954 case DemuxFilterEvent::Tag::tsRecord:
955 case DemuxFilterEvent::Tag::mmtpRecord:
956 case DemuxFilterEvent::Tag::temi:
957 case DemuxFilterEvent::Tag::monitorEvent:
958 case DemuxFilterEvent::Tag::startId:
959 return 0;
960 }
961}
962
963// TODO: move boilerplate into text fixture
964void TunerFilterAidlTest::testDelayHint(const FilterConfig& filterConf) {
Gareth Fenn9a808452022-03-31 08:40:00 +0100965 if (!filterConf.timeDelayInMs && !filterConf.dataDelayInBytes) {
966 return;
967 }
968 if (!isEventProducingFilter(filterConf)) {
969 return;
970 }
Patrick Rohr149b0872021-11-20 00:39:37 +0100971 int32_t feId;
972 int32_t demuxId;
973 std::shared_ptr<IDemux> demux;
974 int64_t filterId;
975
976 mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId);
977 ASSERT_TRUE(feId != INVALID_ID);
978 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
979 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
980 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
981 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
982 mFilterTests.setDemux(demux);
983
Patrick Rohr149b0872021-11-20 00:39:37 +0100984 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
985 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
Patrick Rohr149b0872021-11-20 00:39:37 +0100986
Patrick Rohr1586d212021-11-23 00:40:56 +0100987 bool mediaFilter = isMediaFilter(filterConf);
Patrick Rohr149b0872021-11-20 00:39:37 +0100988 auto filter = mFilterTests.getFilterById(filterId);
989
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +0100990 // startTime needs to be set before calling setDelayHint.
991 auto startTime = std::chrono::steady_clock::now();
992
Gareth Fenn9a808452022-03-31 08:40:00 +0100993 int timeDelayInMs = filterConf.timeDelayInMs;
994 if (timeDelayInMs > 0) {
Patrick Rohr1586d212021-11-23 00:40:56 +0100995 FilterDelayHint delayHint;
996 delayHint.hintType = FilterDelayHintType::TIME_DELAY_IN_MS;
Gareth Fenn9a808452022-03-31 08:40:00 +0100997 delayHint.hintValue = timeDelayInMs;
Patrick Rohr149b0872021-11-20 00:39:37 +0100998
Patrick Rohr1586d212021-11-23 00:40:56 +0100999 // setDelayHint should fail for media filters.
1000 ASSERT_EQ(filter->setDelayHint(delayHint).isOk(), !mediaFilter);
1001 }
Patrick Rohr149b0872021-11-20 00:39:37 +01001002
Patrick Rohr1586d212021-11-23 00:40:56 +01001003 int dataDelayInBytes = filterConf.dataDelayInBytes;
1004 if (dataDelayInBytes > 0) {
1005 FilterDelayHint delayHint;
1006 delayHint.hintType = FilterDelayHintType::DATA_SIZE_DELAY_IN_BYTES;
1007 delayHint.hintValue = dataDelayInBytes;
Patrick Rohr149b0872021-11-20 00:39:37 +01001008
Patrick Rohr1586d212021-11-23 00:40:56 +01001009 // setDelayHint should fail for media filters.
1010 ASSERT_EQ(filter->setDelayHint(delayHint).isOk(), !mediaFilter);
1011 }
Patrick Rohr149b0872021-11-20 00:39:37 +01001012
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +01001013 // start and stop filter (and wait for first callback) in order to
1014 // circumvent callback scheduler race conditions after adjusting filter
1015 // delays.
1016 auto cb = mFilterTests.getFilterCallbacks().at(filterId);
1017 auto future =
1018 cb->verifyFilterCallback([](const std::vector<DemuxFilterEvent>&) { return true; });
Gareth Fenn9a808452022-03-31 08:40:00 +01001019
1020 // The configure stage can also produce events, so we should set the delay
1021 // hint beforehand.
1022 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
Patrick Rohr1586d212021-11-23 00:40:56 +01001023 mFilterTests.startFilter(filterId);
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +01001024
1025 auto timeout = std::chrono::seconds(30);
1026 ASSERT_EQ(future.wait_for(timeout), std::future_status::ready);
1027
Patrick Rohr1586d212021-11-23 00:40:56 +01001028 mFilterTests.stopFilter(filterId);
Patrick Rohr149b0872021-11-20 00:39:37 +01001029
Patrick Rohr1586d212021-11-23 00:40:56 +01001030 if (!mediaFilter) {
Patrick Rohr1586d212021-11-23 00:40:56 +01001031 int callbackSize = 0;
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +01001032 future = cb->verifyFilterCallback(
Patrick Rohr1586d212021-11-23 00:40:56 +01001033 [&callbackSize](const std::vector<DemuxFilterEvent>& events) {
1034 for (const auto& event : events) {
1035 callbackSize += getDemuxFilterEventDataLength(event);
1036 }
1037 return true;
1038 });
1039
Patrick Rohr1586d212021-11-23 00:40:56 +01001040 ASSERT_TRUE(mFilterTests.startFilter(filterId));
1041
1042 // block and wait for callback to be received.
Patrick Rohr1586d212021-11-23 00:40:56 +01001043 ASSERT_EQ(future.wait_for(timeout), std::future_status::ready);
Patrick Rohr1586d212021-11-23 00:40:56 +01001044
Gareth Fenn9a808452022-03-31 08:40:00 +01001045 auto duration = std::chrono::steady_clock::now() - startTime;
1046 bool delayHintTest = duration >= std::chrono::milliseconds(timeDelayInMs);
Patrick Rohr1586d212021-11-23 00:40:56 +01001047 bool dataSizeTest = callbackSize >= dataDelayInBytes;
1048
Gareth Fenn9a808452022-03-31 08:40:00 +01001049 if (timeDelayInMs > 0 && dataDelayInBytes > 0) {
Patrick Rohr1586d212021-11-23 00:40:56 +01001050 ASSERT_TRUE(delayHintTest || dataSizeTest);
1051 } else {
1052 // if only one of time delay / data delay is configured, one of them
1053 // holds true by default, so we want both assertions to be true.
1054 ASSERT_TRUE(delayHintTest && dataSizeTest);
1055 }
1056
1057 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
1058 }
1059
Patrick Rohr149b0872021-11-20 00:39:37 +01001060 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
1061 ASSERT_TRUE(mDemuxTests.closeDemux());
1062 ASSERT_TRUE(mFrontendTests.closeFrontend());
1063}
1064
Patrick Rohr1586d212021-11-23 00:40:56 +01001065TEST_P(TunerFilterAidlTest, FilterDelayHintTest) {
1066 description("Test filter time delay hint.");
Gareth Fenn9a808452022-03-31 08:40:00 +01001067 if (!live.hasFrontendConnection) {
1068 return;
1069 }
Patrick Rohr1586d212021-11-23 00:40:56 +01001070 for (const auto& obj : filterMap) {
1071 testDelayHint(obj.second);
1072 }
1073}
1074
Hongguang600a6ae2021-07-08 18:51:51 -07001075TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsSectionFilterTest) {
1076 description("Feed ts data from playback and configure Ts section filter to get output");
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001077 if (!playback.support) {
Hongguang600a6ae2021-07-08 18:51:51 -07001078 return;
1079 }
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001080 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1081 for (auto& configuration : playback_configs) {
1082 if (configuration.sectionFilterId.compare(emptyHardwareId) != 0) {
1083 playback = configuration;
1084 playbackSingleFilterTest(filterMap[playback.sectionFilterId], dvrMap[playback.dvrId]);
1085 }
1086 }
Hongguang600a6ae2021-07-08 18:51:51 -07001087}
1088
1089TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsAudioFilterTest) {
1090 description("Feed ts data from playback and configure Ts audio filter to get output");
1091 if (!playback.support) {
1092 return;
1093 }
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001094 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1095 for (auto& configuration : playback_configs) {
1096 playback = configuration;
1097 playbackSingleFilterTest(filterMap[playback.audioFilterId], dvrMap[playback.dvrId]);
1098 }
Hongguang600a6ae2021-07-08 18:51:51 -07001099}
1100
1101TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsVideoFilterTest) {
1102 description("Feed ts data from playback and configure Ts video filter to get output");
1103 if (!playback.support) {
1104 return;
1105 }
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001106 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1107 for (auto& configuration : playback_configs) {
1108 playback = configuration;
1109 playbackSingleFilterTest(filterMap[playback.videoFilterId], dvrMap[playback.dvrId]);
1110 }
Hongguang600a6ae2021-07-08 18:51:51 -07001111}
1112
Ray Chin62ab6c92022-09-15 15:07:33 +08001113TEST_P(TunerPlaybackAidlTest, SetStatusCheckIntervalHintToPlaybackTest) {
1114 description("Set status check interval hint to playback test.");
1115 if (!playback.support) {
1116 return;
1117 }
1118 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1119 for (auto& configuration : playback_configs) {
1120 playback = configuration;
1121 setStatusCheckIntervalHintTest(STATUS_CHECK_INTERVAL_MS, dvrMap[playback.dvrId]);
1122 }
1123}
1124
Hongguang600a6ae2021-07-08 18:51:51 -07001125TEST_P(TunerRecordAidlTest, RecordDataFlowWithTsRecordFilterTest) {
1126 description("Feed ts data from frontend to recording and test with ts record filter");
1127 if (!record.support) {
1128 return;
1129 }
sadiqsada7a191392023-11-07 16:09:09 -08001130 // Do not execute tests for IPTV Frontend
1131 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1132 return;
1133 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +00001134 auto record_configs = generateRecordConfigurations();
1135 for (auto& configuration : record_configs) {
1136 record = configuration;
1137 recordSingleFilterTest(filterMap[record.recordFilterId], frontendMap[record.frontendId],
1138 dvrMap[record.dvrRecordId], Dataflow_Context::RECORD);
1139 }
Hongguang600a6ae2021-07-08 18:51:51 -07001140}
1141
1142TEST_P(TunerRecordAidlTest, AttachFiltersToRecordTest) {
1143 description("Attach a single filter to the record dvr test.");
1144 // TODO use parameterized tests
1145 if (!record.support) {
1146 return;
1147 }
sadiqsada7a191392023-11-07 16:09:09 -08001148 // Do not execute tests for IPTV Frontend
1149 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1150 return;
1151 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +00001152 auto record_configs = generateRecordConfigurations();
1153 for (auto& configuration : record_configs) {
1154 record = configuration;
1155 attachSingleFilterToRecordDvrTest(filterMap[record.recordFilterId],
1156 frontendMap[record.frontendId],
1157 dvrMap[record.dvrRecordId]);
1158 }
Hongguang600a6ae2021-07-08 18:51:51 -07001159}
1160
1161TEST_P(TunerRecordAidlTest, LnbRecordDataFlowWithTsRecordFilterTest) {
1162 description("Feed ts data from Fe with Lnb to recording and test with ts record filter");
1163 if (!lnbRecord.support) {
1164 return;
1165 }
Frankie Lizcanoecba02a2022-07-12 17:56:54 +00001166 vector<LnbRecordHardwareConnections> lnbRecord_configs = generateLnbRecordConfigurations();
1167 if (lnbRecord_configs.empty()) {
1168 ALOGD("No frontends that support satellites.");
1169 return;
1170 }
1171 for (auto& configuration : lnbRecord_configs) {
1172 lnbRecord = configuration;
1173 recordSingleFilterTestWithLnb(filterMap[lnbRecord.recordFilterId],
1174 frontendMap[lnbRecord.frontendId],
1175 dvrMap[lnbRecord.dvrRecordId], lnbMap[lnbRecord.lnbId]);
1176 }
Hongguang600a6ae2021-07-08 18:51:51 -07001177}
1178
Ray Chin62ab6c92022-09-15 15:07:33 +08001179TEST_P(TunerRecordAidlTest, SetStatusCheckIntervalHintToRecordTest) {
1180 description("Set status check interval hint to record test.");
1181 if (!record.support) {
1182 return;
1183 }
sadiqsada7a191392023-11-07 16:09:09 -08001184 // Do not execute tests for IPTV Frontend
1185 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1186 return;
1187 }
Ray Chin62ab6c92022-09-15 15:07:33 +08001188 auto record_configs = generateRecordConfigurations();
1189 for (auto& configuration : record_configs) {
1190 record = configuration;
1191 setStatusCheckIntervalHintTest(STATUS_CHECK_INTERVAL_MS, frontendMap[record.frontendId],
1192 dvrMap[record.dvrRecordId]);
1193 }
1194}
1195
Hongguang600a6ae2021-07-08 18:51:51 -07001196TEST_P(TunerFrontendAidlTest, TuneFrontend) {
1197 description("Tune one Frontend with specific setting and check Lock event");
1198 if (!live.hasFrontendConnection) {
1199 return;
1200 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001201 auto live_configs = generateLiveConfigurations();
1202 for (auto& configuration : live_configs) {
1203 live = configuration;
1204 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
1205 }
Hongguang600a6ae2021-07-08 18:51:51 -07001206}
1207
1208TEST_P(TunerFrontendAidlTest, AutoScanFrontend) {
1209 description("Run an auto frontend scan with specific setting and check lock scanMessage");
1210 if (!scan.hasFrontendConnection) {
1211 return;
1212 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001213 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1214 for (auto& configuration : scan_configs) {
1215 scan = configuration;
1216 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_AUTO);
1217 }
Hongguang600a6ae2021-07-08 18:51:51 -07001218}
1219
1220TEST_P(TunerFrontendAidlTest, BlindScanFrontend) {
1221 description("Run an blind frontend scan with specific setting and check lock scanMessage");
1222 if (!scan.hasFrontendConnection) {
1223 return;
1224 }
sadiqsada7a191392023-11-07 16:09:09 -08001225 // Blind scan is not applicable for IPTV frontend
1226 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1227 return;
1228 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001229 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1230 for (auto& configuration : scan_configs) {
1231 scan = configuration;
1232 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_BLIND);
1233 }
Hongguang600a6ae2021-07-08 18:51:51 -07001234}
1235
1236TEST_P(TunerFrontendAidlTest, TuneFrontendWithFrontendSettings) {
1237 description("Tune one Frontend with setting and check Lock event");
1238 if (!live.hasFrontendConnection) {
1239 return;
1240 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001241 auto live_configs = generateLiveConfigurations();
1242 for (auto& configuration : live_configs) {
1243 live = configuration;
1244 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
1245 }
Hongguang600a6ae2021-07-08 18:51:51 -07001246}
1247
1248TEST_P(TunerFrontendAidlTest, BlindScanFrontendWithEndFrequency) {
1249 description("Run an blind frontend scan with setting and check lock scanMessage");
1250 if (!scan.hasFrontendConnection) {
1251 return;
1252 }
sadiqsada7a191392023-11-07 16:09:09 -08001253 // Blind scan is not application for IPTV frontend
1254 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1255 return;
1256 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001257 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1258 for (auto& configuration : scan_configs) {
1259 scan = configuration;
1260 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_BLIND);
1261 }
Hongguang600a6ae2021-07-08 18:51:51 -07001262}
1263
1264TEST_P(TunerFrontendAidlTest, LinkToCiCam) {
1265 description("Test Frontend link to CiCam");
1266 if (!live.hasFrontendConnection) {
1267 return;
1268 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001269 auto live_configs = generateLiveConfigurations();
1270 for (auto& configuration : live_configs) {
1271 live = configuration;
1272 if (!frontendMap[live.frontendId].canConnectToCiCam) {
1273 continue;
1274 }
1275 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -07001276 }
Hongguang600a6ae2021-07-08 18:51:51 -07001277}
1278
Hongguangfcedda02021-12-13 17:08:02 -08001279TEST_P(TunerFrontendAidlTest, getHardwareInfo) {
1280 description("Test Frontend get hardware info");
sadiqsada7a191392023-11-07 16:09:09 -08001281 // Do not execute tests for IPTV Frontend
1282 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1283 return;
1284 }
Hongguangfcedda02021-12-13 17:08:02 -08001285 if (!live.hasFrontendConnection) {
1286 return;
1287 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001288 auto live_configs = generateLiveConfigurations();
1289 for (auto& configuration : live_configs) {
1290 live = configuration;
1291 mFrontendTests.debugInfoTest(frontendMap[live.frontendId]);
1292 }
Hongguangfcedda02021-12-13 17:08:02 -08001293}
1294
Hongguang5766ddf2021-12-23 11:40:37 -08001295TEST_P(TunerFrontendAidlTest, maxNumberOfFrontends) {
1296 description("Test Max Frontend number");
1297 if (!live.hasFrontendConnection) {
1298 return;
1299 }
1300 mFrontendTests.maxNumberOfFrontendsTest();
1301}
1302
Hongguang881190f2022-01-14 13:23:37 -08001303TEST_P(TunerFrontendAidlTest, statusReadinessTest) {
1304 description("Test Max Frontend status readiness");
1305 if (!live.hasFrontendConnection) {
1306 return;
1307 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001308 auto live_configs = generateLiveConfigurations();
1309 for (auto& configuration : live_configs) {
1310 live = configuration;
1311 mFrontendTests.statusReadinessTest(frontendMap[live.frontendId]);
1312 }
Hongguang881190f2022-01-14 13:23:37 -08001313}
1314
Hongguang600a6ae2021-07-08 18:51:51 -07001315TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowVideoFilterTest) {
1316 description("Test Video Filter functionality in Broadcast use case.");
1317 if (!live.hasFrontendConnection) {
1318 return;
1319 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001320 auto live_configs = generateLiveConfigurations();
1321 for (auto& configuration : live_configs) {
1322 live = configuration;
1323 broadcastSingleFilterTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
1324 }
Hongguang600a6ae2021-07-08 18:51:51 -07001325}
1326
1327TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowAudioFilterTest) {
1328 description("Test Audio Filter functionality in Broadcast use case.");
1329 if (!live.hasFrontendConnection) {
1330 return;
1331 }
sadiqsada7a191392023-11-07 16:09:09 -08001332 // Do not execute tests for IPTV Frontend
1333 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1334 return;
1335 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001336 auto live_configs = generateLiveConfigurations();
1337 for (auto& configuration : live_configs) {
1338 live = configuration;
1339 broadcastSingleFilterTest(filterMap[live.audioFilterId], frontendMap[live.frontendId]);
1340 }
Hongguang600a6ae2021-07-08 18:51:51 -07001341}
1342
1343TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowSectionFilterTest) {
1344 description("Test Section Filter functionality in Broadcast use case.");
1345 if (!live.hasFrontendConnection) {
1346 return;
1347 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001348 auto live_configs = generateLiveConfigurations();
1349 for (auto& configuration : live_configs) {
1350 live = configuration;
1351 if (live.sectionFilterId.compare(emptyHardwareId) == 0) {
1352 continue;
1353 }
1354 broadcastSingleFilterTest(filterMap[live.sectionFilterId], frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -07001355 }
Hongguang600a6ae2021-07-08 18:51:51 -07001356}
1357
1358TEST_P(TunerBroadcastAidlTest, IonBufferTest) {
1359 description("Test the av filter data bufferring.");
1360 if (!live.hasFrontendConnection) {
1361 return;
1362 }
sadiqsada7a191392023-11-07 16:09:09 -08001363 // Do not execute tests for IPTV Frontend
1364 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1365 return;
1366 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001367 auto live_configs = generateLiveConfigurations();
1368 for (auto& configuration : live_configs) {
1369 live = configuration;
1370 broadcastSingleFilterTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
1371 }
Hongguang600a6ae2021-07-08 18:51:51 -07001372}
1373
1374TEST_P(TunerBroadcastAidlTest, LnbBroadcastDataFlowVideoFilterTest) {
1375 description("Test Video Filter functionality in Broadcast with Lnb use case.");
1376 if (!lnbLive.support) {
1377 return;
1378 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +00001379 vector<LnbLiveHardwareConnections> lnbLive_configs = generateLnbLiveConfigurations();
1380 if (lnbLive_configs.empty()) {
1381 ALOGD("No frontends that support satellites.");
1382 return;
1383 }
1384 for (auto& combination : lnbLive_configs) {
1385 lnbLive = combination;
1386 broadcastSingleFilterTestWithLnb(filterMap[lnbLive.videoFilterId],
1387 frontendMap[lnbLive.frontendId], lnbMap[lnbLive.lnbId]);
1388 }
Hongguang600a6ae2021-07-08 18:51:51 -07001389}
1390
1391TEST_P(TunerBroadcastAidlTest, MediaFilterWithSharedMemoryHandle) {
1392 description("Test the Media Filter with shared memory handle");
1393 if (!live.hasFrontendConnection) {
1394 return;
1395 }
sadiqsada7a191392023-11-07 16:09:09 -08001396 // Do not execute tests for IPTV Frontend
1397 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1398 return;
1399 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001400 auto live_configs = generateLiveConfigurations();
1401 for (auto& configuration : live_configs) {
1402 live = configuration;
1403 mediaFilterUsingSharedMemoryTest(filterMap[live.videoFilterId],
1404 frontendMap[live.frontendId]);
1405 }
Hongguang600a6ae2021-07-08 18:51:51 -07001406}
1407
1408TEST_P(TunerDescramblerAidlTest, CreateDescrambler) {
1409 description("Create Descrambler");
1410 if (!descrambling.support) {
1411 return;
1412 }
sadiqsada7a191392023-11-07 16:09:09 -08001413 // Do not execute tests for IPTV Frontend
1414 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1415 return;
1416 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001417 vector<DescramblingHardwareConnections> descrambling_configs =
1418 generateDescramblingConfigurations();
1419 if (descrambling_configs.empty()) {
1420 ALOGD("No valid descrambling combinations in the configuration file.");
1421 return;
Hongguang600a6ae2021-07-08 18:51:51 -07001422 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001423 for (auto& combination : descrambling_configs) {
1424 descrambling = combination;
1425 int32_t demuxId;
1426 std::shared_ptr<IDemux> demux;
1427 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
Hongguang600a6ae2021-07-08 18:51:51 -07001428
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001429 if (descrambling.hasFrontendConnection) {
1430 int32_t feId;
1431 mFrontendTests.getFrontendIdByType(frontendMap[descrambling.frontendId].type, feId);
1432 ASSERT_TRUE(feId != INVALID_ID);
1433 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
1434 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
1435 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
1436 }
Hongguang600a6ae2021-07-08 18:51:51 -07001437
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001438 ASSERT_TRUE(mDescramblerTests.openDescrambler(demuxId));
1439 ASSERT_TRUE(mDescramblerTests.closeDescrambler());
1440 ASSERT_TRUE(mDemuxTests.closeDemux());
1441
1442 if (descrambling.hasFrontendConnection) {
1443 ASSERT_TRUE(mFrontendTests.closeFrontend());
1444 }
Hongguang600a6ae2021-07-08 18:51:51 -07001445 }
1446}
1447
1448TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTest) {
1449 description("Test ts audio filter in scrambled broadcast use case");
1450 if (!descrambling.support) {
1451 return;
1452 }
sadiqsada7a191392023-11-07 16:09:09 -08001453 // Do not execute tests for IPTV Frontend
1454 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1455 return;
1456 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001457 vector<DescramblingHardwareConnections> descrambling_configs =
1458 generateDescramblingConfigurations();
1459 if (descrambling_configs.empty()) {
1460 ALOGD("No valid descrambling combinations in the configuration file.");
1461 return;
1462 }
1463 for (auto& combination : descrambling_configs) {
1464 descrambling = combination;
1465 set<FilterConfig> filterConfs;
1466 filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.audioFilterId]));
1467 filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.videoFilterId]));
1468 scrambledBroadcastTest(filterConfs, frontendMap[descrambling.frontendId],
Frankie Lizcano82101d22022-07-28 00:12:35 +00001469 descramblerMap[descrambling.descramblerId],
1470 Dataflow_Context::DESCRAMBLING);
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001471 }
Hongguang600a6ae2021-07-08 18:51:51 -07001472}
1473
Frankie Lizcano82101d22022-07-28 00:12:35 +00001474TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTestWithLnb) {
1475 description("Test media filters in scrambled broadcast use case with Lnb");
1476 if (!lnbDescrambling.support) {
1477 return;
1478 }
Frankie Lizcanobcf4ebb2022-08-01 18:06:00 +00001479 auto lnbDescrambling_configs = generateLnbDescramblingConfigurations();
1480 if (lnbDescrambling_configs.empty()) {
1481 ALOGD("No frontends that support satellites.");
1482 return;
1483 }
1484 for (auto& configuration : lnbDescrambling_configs) {
1485 lnbDescrambling = configuration;
1486 set<FilterConfig> filterConfs;
1487 filterConfs.insert(static_cast<FilterConfig>(filterMap[lnbDescrambling.audioFilterId]));
1488 filterConfs.insert(static_cast<FilterConfig>(filterMap[lnbDescrambling.videoFilterId]));
1489 scrambledBroadcastTestWithLnb(filterConfs, frontendMap[lnbDescrambling.frontendId],
1490 descramblerMap[lnbDescrambling.descramblerId],
1491 lnbMap[lnbDescrambling.lnbId]);
1492 }
Frankie Lizcano82101d22022-07-28 00:12:35 +00001493}
1494
Hongguang600a6ae2021-07-08 18:51:51 -07001495INSTANTIATE_TEST_SUITE_P(PerInstance, TunerBroadcastAidlTest,
1496 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1497 android::PrintInstanceNameToString);
1498
1499INSTANTIATE_TEST_SUITE_P(PerInstance, TunerFrontendAidlTest,
1500 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1501 android::PrintInstanceNameToString);
1502
1503INSTANTIATE_TEST_SUITE_P(PerInstance, TunerFilterAidlTest,
1504 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1505 android::PrintInstanceNameToString);
1506
1507INSTANTIATE_TEST_SUITE_P(PerInstance, TunerRecordAidlTest,
1508 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1509 android::PrintInstanceNameToString);
1510
1511INSTANTIATE_TEST_SUITE_P(PerInstance, TunerLnbAidlTest,
1512 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1513 android::PrintInstanceNameToString);
1514
1515INSTANTIATE_TEST_SUITE_P(PerInstance, TunerDemuxAidlTest,
1516 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1517 android::PrintInstanceNameToString);
1518
1519INSTANTIATE_TEST_SUITE_P(PerInstance, TunerPlaybackAidlTest,
1520 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1521 android::PrintInstanceNameToString);
1522
1523INSTANTIATE_TEST_SUITE_P(PerInstance, TunerDescramblerAidlTest,
1524 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1525 android::PrintInstanceNameToString);
1526
1527} // namespace
1528
1529// Start thread pool to receive callbacks from AIDL service.
1530int main(int argc, char** argv) {
1531 ::testing::InitGoogleTest(&argc, argv);
1532 ABinderProcess_setThreadPoolMaxThreadCount(1);
1533 ABinderProcess_startThreadPool();
1534 return RUN_ALL_TESTS();
1535}