blob: 671d07965af1a900f7dbd9acb867c9527d8063ed [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*/));
103 ASSERT_TRUE(mFilterTests.startIdTest(filterId));
104 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
105 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
106 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
107 ASSERT_TRUE(mDemuxTests.closeDemux());
108 ASSERT_TRUE(mFrontendTests.closeFrontend());
109}
110
111void TunerFilterAidlTest::testTimeFilter(TimeFilterConfig filterConf) {
112 int32_t demuxId;
113 std::shared_ptr<IDemux> demux;
114 DemuxCapabilities caps;
115
116 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
117 ASSERT_TRUE(mDemuxTests.getDemuxCaps(caps));
118 ASSERT_TRUE(caps.bTimeFilter);
119 mFilterTests.setDemux(demux);
120 ASSERT_TRUE(mFilterTests.openTimeFilterInDemux());
121 ASSERT_TRUE(mFilterTests.setTimeStamp(filterConf.timeStamp));
122 ASSERT_TRUE(mFilterTests.getTimeStamp());
123 ASSERT_TRUE(mFilterTests.clearTimeStamp());
124 ASSERT_TRUE(mFilterTests.closeTimeFilter());
125 ASSERT_TRUE(mDemuxTests.closeDemux());
126}
127
128void TunerBroadcastAidlTest::broadcastSingleFilterTest(FilterConfig filterConf,
129 FrontendConfig frontendConf) {
130 int32_t feId;
131 int32_t demuxId;
132 std::shared_ptr<IDemux> demux;
133 int64_t filterId;
134
135 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
136 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
137 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
Frankie Lizcano87421812022-07-28 17:13:01 +0000138 if (mLnbId != INVALID_LNB_ID) {
139 ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
Hongguang600a6ae2021-07-08 18:51:51 -0700140 }
141 if (frontendConf.isSoftwareFe) {
142 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[live.dvrSoftwareFeId]);
143 }
144 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
145 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
146 mFrontendTests.setDemux(demux);
147 mFilterTests.setDemux(demux);
148 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
149 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
150 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
151 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
152 ASSERT_TRUE(mFilterTests.startFilter(filterId));
153 // tune test
154 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
155 ASSERT_TRUE(filterDataOutputTest());
156 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
157 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
158 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
159 ASSERT_TRUE(mDemuxTests.closeDemux());
160 ASSERT_TRUE(mFrontendTests.closeFrontend());
161}
162
163void TunerBroadcastAidlTest::broadcastSingleFilterTestWithLnb(FilterConfig filterConf,
164 FrontendConfig frontendConf,
165 LnbConfig lnbConf) {
166 if (lnbConf.name.compare(emptyHardwareId) == 0) {
167 vector<int32_t> ids;
168 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
169 ASSERT_TRUE(ids.size() > 0);
170 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
Frankie Lizcano87421812022-07-28 17:13:01 +0000171 mLnbId = ids[0];
Hongguang600a6ae2021-07-08 18:51:51 -0700172 } else {
Frankie Lizcano87421812022-07-28 17:13:01 +0000173 ASSERT_TRUE(mLnbTests.openLnbByName(lnbConf.name, mLnbId));
Hongguang600a6ae2021-07-08 18:51:51 -0700174 }
175 ASSERT_TRUE(mLnbTests.setLnbCallback());
176 ASSERT_TRUE(mLnbTests.setVoltage(lnbConf.voltage));
177 ASSERT_TRUE(mLnbTests.setTone(lnbConf.tone));
178 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConf.position));
Frankie Lizcanod1f520e2022-07-26 20:05:46 +0000179 if (!frontendConf.isSoftwareFe) {
180 broadcastSingleFilterTest(filterConf, frontendConf);
181 }
Hongguang600a6ae2021-07-08 18:51:51 -0700182 ASSERT_TRUE(mLnbTests.closeLnb());
Frankie Lizcano87421812022-07-28 17:13:01 +0000183 mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700184}
185
186void TunerBroadcastAidlTest::mediaFilterUsingSharedMemoryTest(FilterConfig filterConf,
187 FrontendConfig frontendConf) {
188 int32_t feId;
189 int32_t demuxId;
190 std::shared_ptr<IDemux> demux;
191 int64_t filterId;
192
193 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
194 ASSERT_TRUE(feId != INVALID_ID);
195 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
196 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
197 if (frontendConf.isSoftwareFe) {
198 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[live.dvrSoftwareFeId]);
199 }
200 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
201 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
202 mFrontendTests.setDemux(demux);
203 mFilterTests.setDemux(demux);
204 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
205 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
206 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
207 ASSERT_TRUE(mFilterTests.getSharedAvMemoryHandle(filterId));
208 ASSERT_TRUE(mFilterTests.configAvFilterStreamType(filterConf.streamType, filterId));
209 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
210 ASSERT_TRUE(mFilterTests.startFilter(filterId));
211 // tune test
212 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
213 ASSERT_TRUE(filterDataOutputTest());
214 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
215 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
216 ASSERT_TRUE(mFilterTests.releaseShareAvHandle(filterId));
217 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
218 ASSERT_TRUE(mDemuxTests.closeDemux());
219 ASSERT_TRUE(mFrontendTests.closeFrontend());
220}
221
222void TunerPlaybackAidlTest::playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf) {
223 int32_t demuxId;
224 std::shared_ptr<IDemux> demux;
225 int64_t filterId;
226
227 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
228 mFilterTests.setDemux(demux);
229 mDvrTests.setDemux(demux);
230 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
231 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrConf.settings));
232 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
233 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
234 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
235 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
236 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
237 mDvrTests.startPlaybackInputThread(dvrConf.playbackInputFile,
238 dvrConf.settings.get<DvrSettings::Tag::playback>());
239 ASSERT_TRUE(mDvrTests.startDvrPlayback());
240 ASSERT_TRUE(mFilterTests.startFilter(filterId));
241 ASSERT_TRUE(filterDataOutputTest());
242 mDvrTests.stopPlaybackThread();
243 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
244 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
245 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
246 mDvrTests.closeDvrPlayback();
247 ASSERT_TRUE(mDemuxTests.closeDemux());
248}
249
Ray Chin62ab6c92022-09-15 15:07:33 +0800250void TunerPlaybackAidlTest::setStatusCheckIntervalHintTest(int64_t statusCheckIntervalHint,
251 DvrConfig dvrConf) {
252 int32_t demuxId;
253 std::shared_ptr<IDemux> demux;
254
255 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
256 mDvrTests.setDemux(demux);
257 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
258 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrConf.settings));
259 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
260
261 ASSERT_TRUE(mDvrTests.setPlaybackStatusCheckIntervalHint(statusCheckIntervalHint));
262
263 mDvrTests.startPlaybackInputThread(dvrConf.playbackInputFile,
264 dvrConf.settings.get<DvrSettings::Tag::playback>());
265 ASSERT_TRUE(mDvrTests.startDvrPlayback());
266 mDvrTests.stopPlaybackThread();
267 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
268 mDvrTests.closeDvrPlayback();
269 ASSERT_TRUE(mDemuxTests.closeDemux());
270}
271
Hongguang600a6ae2021-07-08 18:51:51 -0700272void TunerRecordAidlTest::recordSingleFilterTestWithLnb(FilterConfig filterConf,
273 FrontendConfig frontendConf,
274 DvrConfig dvrConf, LnbConfig lnbConf) {
275 if (lnbConf.name.compare(emptyHardwareId) == 0) {
276 vector<int32_t> ids;
277 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
278 ASSERT_TRUE(ids.size() > 0);
279 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
Frankie Lizcano87421812022-07-28 17:13:01 +0000280 mLnbId = ids[0];
Hongguang600a6ae2021-07-08 18:51:51 -0700281 } else {
Frankie Lizcano87421812022-07-28 17:13:01 +0000282 ASSERT_TRUE(mLnbTests.openLnbByName(lnbConf.name, mLnbId));
Hongguang600a6ae2021-07-08 18:51:51 -0700283 }
284 ASSERT_TRUE(mLnbTests.setLnbCallback());
285 ASSERT_TRUE(mLnbTests.setVoltage(lnbConf.voltage));
286 ASSERT_TRUE(mLnbTests.setTone(lnbConf.tone));
287 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConf.position));
288 for (auto msgName : lnbRecord.diseqcMsgs) {
289 ASSERT_TRUE(mLnbTests.sendDiseqcMessage(diseqcMsgMap[msgName]));
290 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000291 if (!frontendConf.isSoftwareFe) {
292 recordSingleFilterTest(filterConf, frontendConf, dvrConf, Dataflow_Context::LNBRECORD);
293 }
Hongguang600a6ae2021-07-08 18:51:51 -0700294 ASSERT_TRUE(mLnbTests.closeLnb());
Frankie Lizcano87421812022-07-28 17:13:01 +0000295 mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700296}
297
298void TunerRecordAidlTest::attachSingleFilterToRecordDvrTest(FilterConfig filterConf,
299 FrontendConfig frontendConf,
300 DvrConfig dvrConf) {
301 int32_t demuxId;
302 std::shared_ptr<IDemux> demux;
303 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
304 mDvrTests.setDemux(demux);
305
306 DvrConfig dvrSourceConfig;
307 if (record.hasFrontendConnection) {
308 int32_t feId;
309 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
310 ASSERT_TRUE(feId != INVALID_ID);
311 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
312 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
313 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
314 } else {
315 dvrSourceConfig = dvrMap[record.dvrSourceId];
316 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
317 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
318 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
319 }
320
321 int64_t filterId;
322 std::shared_ptr<IFilter> filter;
323 mFilterTests.setDemux(demux);
324
325 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
326 ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
327 ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
328
329 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
330 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
331 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
332 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
333 filter = mFilterTests.getFilterById(filterId);
334 ASSERT_TRUE(filter != nullptr);
335 ASSERT_TRUE(mDvrTests.attachFilterToDvr(filter));
336 ASSERT_TRUE(mDvrTests.startDvrRecord());
337 ASSERT_TRUE(mFilterTests.startFilter(filterId));
338 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
339 ASSERT_TRUE(mDvrTests.stopDvrRecord());
340 ASSERT_TRUE(mDvrTests.detachFilterToDvr(filter));
341 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
342 mDvrTests.closeDvrRecord();
343 ASSERT_TRUE(mDemuxTests.closeDemux());
344
345 if (record.hasFrontendConnection) {
346 ASSERT_TRUE(mFrontendTests.closeFrontend());
347 }
348}
349
350void TunerRecordAidlTest::recordSingleFilterTest(FilterConfig filterConf,
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000351 FrontendConfig frontendConf, DvrConfig dvrConf,
352 Dataflow_Context context) {
Hongguang600a6ae2021-07-08 18:51:51 -0700353 int32_t demuxId;
354 std::shared_ptr<IDemux> demux;
355 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
356 mDvrTests.setDemux(demux);
357
358 DvrConfig dvrSourceConfig;
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000359 if (context == Dataflow_Context::RECORD) {
360 if (record.hasFrontendConnection) {
361 int32_t feId;
362 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
363 ASSERT_TRUE(feId != INVALID_ID);
364 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
365 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
366 if (frontendConf.isSoftwareFe) {
367 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[record.dvrSoftwareFeId]);
368 }
369 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
370 mFrontendTests.setDvrTests(&mDvrTests);
371 } else {
372 dvrSourceConfig = dvrMap[record.dvrSourceId];
373 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
374 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
375 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
376 }
377 } else if (context == Dataflow_Context::LNBRECORD) {
378 // If function arrives here, frontend should not be software, so no need to configure a dvr
379 // source or dvr fe connection that might be used for recording without an Lnb
Hongguang600a6ae2021-07-08 18:51:51 -0700380 int32_t feId;
381 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
382 ASSERT_TRUE(feId != INVALID_ID);
383 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
384 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000385 if (mLnbId != INVALID_LNB_ID) {
386 ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
387 } else {
388 FAIL();
Hongguang600a6ae2021-07-08 18:51:51 -0700389 }
390 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
391 mFrontendTests.setDvrTests(&mDvrTests);
Hongguang600a6ae2021-07-08 18:51:51 -0700392 }
393
394 int64_t filterId;
395 std::shared_ptr<IFilter> filter;
396 mFilterTests.setDemux(demux);
397 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
398 ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
399 ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
400 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
401 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
402 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
403 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
404 filter = mFilterTests.getFilterById(filterId);
405 ASSERT_TRUE(filter != nullptr);
406 mDvrTests.startRecordOutputThread(dvrConf.settings.get<DvrSettings::Tag::record>());
407 ASSERT_TRUE(mDvrTests.attachFilterToDvr(filter));
408 ASSERT_TRUE(mDvrTests.startDvrRecord());
409 ASSERT_TRUE(mFilterTests.startFilter(filterId));
410
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000411 if (context == Dataflow_Context::RECORD) {
412 if (record.hasFrontendConnection) {
413 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
414 } else {
415 // Start DVR Source
416 mDvrTests.startPlaybackInputThread(
417 dvrSourceConfig.playbackInputFile,
418 dvrSourceConfig.settings.get<DvrSettings::Tag::playback>());
419 ASSERT_TRUE(mDvrTests.startDvrPlayback());
420 }
421 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700422 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700423 }
Hongguang600a6ae2021-07-08 18:51:51 -0700424 mDvrTests.testRecordOutput();
425 mDvrTests.stopRecordThread();
426
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000427 if (context == Dataflow_Context::RECORD) {
428 if (record.hasFrontendConnection) {
429 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
430 } else {
431 mDvrTests.stopPlaybackThread();
432 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
433 }
434 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700435 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700436 }
437
438 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
439 ASSERT_TRUE(mDvrTests.stopDvrRecord());
440 ASSERT_TRUE(mDvrTests.detachFilterToDvr(filter));
441 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
442 mDvrTests.closeDvrRecord();
443
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000444 if (context == Dataflow_Context::RECORD) {
445 if (record.hasFrontendConnection) {
446 ASSERT_TRUE(mFrontendTests.closeFrontend());
447 } else {
448 mDvrTests.closeDvrPlayback();
449 }
450 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700451 ASSERT_TRUE(mFrontendTests.closeFrontend());
Hongguang600a6ae2021-07-08 18:51:51 -0700452 }
453
454 ASSERT_TRUE(mDemuxTests.closeDemux());
455}
456
Ray Chin62ab6c92022-09-15 15:07:33 +0800457void TunerRecordAidlTest::setStatusCheckIntervalHintTest(int64_t statusCheckIntervalHint,
458 FrontendConfig frontendConf,
459 DvrConfig dvrConf) {
460 int32_t demuxId;
461 std::shared_ptr<IDemux> demux;
462 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
463 mDvrTests.setDemux(demux);
464
465 DvrConfig dvrSourceConfig;
466 if (record.hasFrontendConnection) {
467 int32_t feId;
468 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
469 ASSERT_TRUE(feId != INVALID_ID);
470 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
471 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
472 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
473 } else {
474 dvrSourceConfig = dvrMap[record.dvrSourceId];
475 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
476 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
477 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
478 }
479
480 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
481 ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
482 ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
483
484 ASSERT_TRUE(mDvrTests.setRecordStatusCheckIntervalHint(statusCheckIntervalHint));
485
486 ASSERT_TRUE(mDvrTests.startDvrRecord());
487 ASSERT_TRUE(mDvrTests.stopDvrRecord());
488 mDvrTests.closeDvrRecord();
489 ASSERT_TRUE(mDemuxTests.closeDemux());
490
491 if (record.hasFrontendConnection) {
492 ASSERT_TRUE(mFrontendTests.closeFrontend());
493 }
494}
495
Hongguang600a6ae2021-07-08 18:51:51 -0700496void TunerDescramblerAidlTest::scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
497 FrontendConfig frontendConf,
Frankie Lizcano82101d22022-07-28 00:12:35 +0000498 DescramblerConfig descConfig,
499 Dataflow_Context context) {
Hongguang600a6ae2021-07-08 18:51:51 -0700500 int32_t demuxId;
501 std::shared_ptr<IDemux> demux;
502 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
503
504 DvrConfig dvrSourceConfig;
Frankie Lizcano82101d22022-07-28 00:12:35 +0000505 if (context == Dataflow_Context::DESCRAMBLING) {
506 if (descrambling.hasFrontendConnection) {
507 int32_t feId;
508 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
509 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
510 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
511 if (frontendConf.isSoftwareFe) {
512 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[descrambling.dvrSoftwareFeId]);
513 }
514 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
515 mFrontendTests.setDemux(demux);
516 } else {
517 dvrSourceConfig = dvrMap[descrambling.dvrSourceId];
518 mDvrTests.setDemux(demux);
519 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
520 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
521 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
522 }
523 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700524 int32_t feId;
525 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
526 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
527 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
Frankie Lizcano82101d22022-07-28 00:12:35 +0000528 if (mLnbId != INVALID_LNB_ID) {
529 ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
530 } else {
531 // If, for some reason, the test got here without failing. We fail it here.
532 ALOGD("mLnbId is null. Something went wrong. Exiting ScrambledBroadcastWithLnbId.");
533 FAIL();
Hongguang600a6ae2021-07-08 18:51:51 -0700534 }
535 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
536 mFrontendTests.setDemux(demux);
Hongguang600a6ae2021-07-08 18:51:51 -0700537 }
538
539 set<int64_t> filterIds;
540 int64_t filterId;
541 set<struct FilterConfig>::iterator config;
542 set<int64_t>::iterator id;
543 mFilterTests.setDemux(demux);
544 for (config = mediaFilterConfs.begin(); config != mediaFilterConfs.end(); config++) {
545 ASSERT_TRUE(mFilterTests.openFilterInDemux((*config).type, (*config).bufferSize));
546 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
547 ASSERT_TRUE(mFilterTests.configFilter((*config).settings, filterId));
548 filterIds.insert(filterId);
549 }
550 ASSERT_TRUE(mDescramblerTests.openDescrambler(demuxId));
551 vector<uint8_t> token;
552 ASSERT_TRUE(mDescramblerTests.getKeyToken(descConfig.casSystemId, descConfig.provisionStr,
553 descConfig.hidlPvtData, token));
554 mDescramblerTests.setKeyToken(token);
555 vector<DemuxPid> pids;
556 DemuxPid pid;
557 for (config = mediaFilterConfs.begin(); config != mediaFilterConfs.end(); config++) {
558 ASSERT_TRUE(mDescramblerTests.getDemuxPidFromFilterSettings((*config).type,
559 (*config).settings, pid));
560 pids.push_back(pid);
561 ASSERT_TRUE(mDescramblerTests.addPid(pid, nullptr));
562 }
563 for (id = filterIds.begin(); id != filterIds.end(); id++) {
564 ASSERT_TRUE(mFilterTests.startFilter(*id));
565 }
566
Frankie Lizcano82101d22022-07-28 00:12:35 +0000567 if (context == Dataflow_Context::DESCRAMBLING) {
568 if (descrambling.hasFrontendConnection) {
569 // tune test
570 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
571 } else {
572 // Start DVR Source
573 mDvrTests.startPlaybackInputThread(
574 dvrSourceConfig.playbackInputFile,
575 dvrSourceConfig.settings.get<DvrSettings::Tag::playback>());
576 ASSERT_TRUE(mDvrTests.startDvrPlayback());
577 }
578 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700579 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700580 }
581
582 ASSERT_TRUE(filterDataOutputTest());
583
Frankie Lizcano82101d22022-07-28 00:12:35 +0000584 if (context == Dataflow_Context::DESCRAMBLING) {
585 if (descrambling.hasFrontendConnection) {
586 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
587 } else {
588 mDvrTests.stopPlaybackThread();
589 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
590 }
591 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700592 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700593 }
594
595 for (id = filterIds.begin(); id != filterIds.end(); id++) {
596 ASSERT_TRUE(mFilterTests.stopFilter(*id));
597 }
598 for (auto pid : pids) {
599 ASSERT_TRUE(mDescramblerTests.removePid(pid, nullptr));
600 }
601 ASSERT_TRUE(mDescramblerTests.closeDescrambler());
602 for (id = filterIds.begin(); id != filterIds.end(); id++) {
603 ASSERT_TRUE(mFilterTests.closeFilter(*id));
604 }
605
Frankie Lizcano82101d22022-07-28 00:12:35 +0000606 if (context == Dataflow_Context::DESCRAMBLING) {
607 if (descrambling.hasFrontendConnection) {
608 ASSERT_TRUE(mFrontendTests.closeFrontend());
609 } else {
610 mDvrTests.closeDvrPlayback();
611 }
612 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700613 ASSERT_TRUE(mFrontendTests.closeFrontend());
Hongguang600a6ae2021-07-08 18:51:51 -0700614 }
615
616 ASSERT_TRUE(mDemuxTests.closeDemux());
617}
618
Frankie Lizcano82101d22022-07-28 00:12:35 +0000619void TunerDescramblerAidlTest::scrambledBroadcastTestWithLnb(
620 set<struct FilterConfig>& mediaFilterConfs, FrontendConfig& frontendConf,
621 DescramblerConfig& descConfig, LnbConfig& lnbConfig) {
622 // We can test the Lnb individually and make sure it functions properly. If the frontend is
623 // software, we cannot test the whole dataflow. If the frontend is hardware, we can
624 if (lnbConfig.name.compare(emptyHardwareId) == 0) {
625 vector<int32_t> ids;
626 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
627 ASSERT_TRUE(ids.size() > 0);
628 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
629 mLnbId = ids[0];
630 } else {
631 ASSERT_TRUE(mLnbTests.openLnbByName(lnbConfig.name, mLnbId));
632 }
633 // Once Lnb is opened, test some of its basic functionality
634 ASSERT_TRUE(mLnbTests.setLnbCallback());
635 ASSERT_TRUE(mLnbTests.setVoltage(lnbConfig.voltage));
636 ASSERT_TRUE(mLnbTests.setTone(lnbConfig.tone));
637 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConfig.position));
638 if (!frontendConf.isSoftwareFe) {
639 ALOGD("Frontend is not software, testing entire dataflow.");
640 scrambledBroadcastTest(mediaFilterConfs, frontendConf, descConfig,
641 Dataflow_Context::LNBDESCRAMBLING);
642 } else {
643 ALOGD("Frontend is software, did not test the entire dataflow, but tested the Lnb "
644 "individually.");
645 }
646 ASSERT_TRUE(mLnbTests.closeLnb());
647 mLnbId = INVALID_LNB_ID;
648}
649
Hongguang600a6ae2021-07-08 18:51:51 -0700650TEST_P(TunerLnbAidlTest, SendDiseqcMessageToLnb) {
651 description("Open and configure an Lnb with specific settings then send a diseqc msg to it.");
652 if (!lnbLive.support) {
653 return;
654 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000655 vector<LnbLiveHardwareConnections> lnbLive_configs = generateLnbLiveConfigurations();
656 if (lnbLive_configs.empty()) {
657 ALOGD("No frontends that support satellites.");
658 return;
Hongguang600a6ae2021-07-08 18:51:51 -0700659 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000660 for (auto& combination : lnbLive_configs) {
661 lnbLive = combination;
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000662 if (lnbMap[lnbLive.lnbId].name.compare(emptyHardwareId) == 0) {
663 vector<int32_t> ids;
664 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
665 ASSERT_TRUE(ids.size() > 0);
666 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
667 } else {
668 int32_t id;
669 ASSERT_TRUE(mLnbTests.openLnbByName(lnbMap[lnbLive.lnbId].name, id));
670 }
671 ASSERT_TRUE(mLnbTests.setLnbCallback());
672 ASSERT_TRUE(mLnbTests.setVoltage(lnbMap[lnbLive.lnbId].voltage));
673 ASSERT_TRUE(mLnbTests.setTone(lnbMap[lnbLive.lnbId].tone));
674 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbMap[lnbLive.lnbId].position));
675 for (auto msgName : lnbLive.diseqcMsgs) {
676 ASSERT_TRUE(mLnbTests.sendDiseqcMessage(diseqcMsgMap[msgName]));
677 }
678 ASSERT_TRUE(mLnbTests.closeLnb());
Hongguang600a6ae2021-07-08 18:51:51 -0700679 }
Hongguang600a6ae2021-07-08 18:51:51 -0700680}
681
682TEST_P(TunerDemuxAidlTest, openDemux) {
683 description("Open and close a Demux.");
684 if (!live.hasFrontendConnection) {
685 return;
686 }
sadiqsada7a191392023-11-07 16:09:09 -0800687 // Do not execute tests for IPTV Frontend
688 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
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 }
sadiqsada7a191392023-11-07 16:09:09 -0800787 // Do not execute tests for IPTV Frontend
788 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
789 return;
790 }
Hongguang600a6ae2021-07-08 18:51:51 -0700791 // TODO use parameterized tests
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000792 auto live_configs = generateLiveConfigurations();
793 for (auto& configuration : live_configs) {
794 live = configuration;
795 configSingleFilterInDemuxTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
796 }
Hongguang600a6ae2021-07-08 18:51:51 -0700797}
798
799TEST_P(TunerFilterAidlTest, ConfigIpFilterInDemuxWithCid) {
800 description("Open and configure an ip filter in Demux.");
801 // TODO use parameterized tests
802 if (!live.hasFrontendConnection) {
803 return;
804 }
sadiqsada7a191392023-11-07 16:09:09 -0800805 // Do not execute tests for IPTV Frontend
806 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
807 return;
808 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000809 auto live_configs = generateLiveConfigurations();
810 for (auto& configuration : live_configs) {
811 live = configuration;
812 if (live.ipFilterId.compare(emptyHardwareId) == 0) {
813 continue;
814 }
815 configSingleFilterInDemuxTest(filterMap[live.ipFilterId], frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -0700816 }
Hongguang600a6ae2021-07-08 18:51:51 -0700817}
818
819TEST_P(TunerFilterAidlTest, ReconfigFilterToReceiveStartId) {
820 description("Recofigure and restart a filter to test start id.");
821 if (!live.hasFrontendConnection) {
822 return;
823 }
sadiqsada7a191392023-11-07 16:09:09 -0800824 // Do not execute tests for IPTV Frontend
825 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
826 return;
827 }
Hongguang600a6ae2021-07-08 18:51:51 -0700828 // TODO use parameterized tests
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000829 auto live_configs = generateLiveConfigurations();
830 for (auto& configuration : live_configs) {
831 live = configuration;
832 reconfigSingleFilterInDemuxTest(filterMap[live.videoFilterId],
833 filterMap[live.videoFilterId],
834 frontendMap[live.frontendId]);
835 }
Hongguang600a6ae2021-07-08 18:51:51 -0700836}
837
838TEST_P(TunerFilterAidlTest, SetFilterLinkage) {
839 description("Pick up all the possible linkages from the demux caps and set them up.");
840 DemuxCapabilities caps;
841 int32_t demuxId;
842 std::shared_ptr<IDemux> demux;
843 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
844 ASSERT_TRUE(mDemuxTests.getDemuxCaps(caps));
845 mFilterTests.setDemux(demux);
846 for (int i = 0; i < caps.linkCaps.size(); i++) {
847 uint32_t bitMask = 1;
848 for (int j = 0; j < FILTER_MAIN_TYPE_BIT_COUNT; j++) {
849 if (caps.linkCaps[i] & (bitMask << j)) {
850 int64_t sourceFilterId;
851 int64_t sinkFilterId;
852 ASSERT_TRUE(mFilterTests.openFilterInDemux(getLinkageFilterType(i), FMQ_SIZE_16M));
853 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(sourceFilterId));
854 ASSERT_TRUE(mFilterTests.openFilterInDemux(getLinkageFilterType(j), FMQ_SIZE_16M));
855 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(sinkFilterId));
856 ASSERT_TRUE(mFilterTests.setFilterDataSource(sourceFilterId, sinkFilterId));
857 ASSERT_TRUE(mFilterTests.setFilterDataSourceToDemux(sinkFilterId));
858 ASSERT_TRUE(mFilterTests.closeFilter(sinkFilterId));
859 ASSERT_TRUE(mFilterTests.closeFilter(sourceFilterId));
860 }
861 }
862 }
863 ASSERT_TRUE(mDemuxTests.closeDemux());
864}
865
866TEST_P(TunerFilterAidlTest, testTimeFilter) {
867 description("Open a timer filter in Demux and set time stamp.");
868 if (!timeFilter.support) {
869 return;
870 }
871 // TODO use parameterized tests
Frankie Lizcano0c069532022-07-14 20:20:46 +0000872 auto timeFilter_configs = generateTimeFilterConfigurations();
873 for (auto& configuration : timeFilter_configs) {
874 timeFilter = configuration;
875 testTimeFilter(timeFilterMap[timeFilter.timeFilterId]);
876 }
Hongguang600a6ae2021-07-08 18:51:51 -0700877}
878
Gareth Fenn9a808452022-03-31 08:40:00 +0100879static bool isEventProducingFilter(const FilterConfig& filterConfig) {
880 switch (filterConfig.type.mainType) {
881 case DemuxFilterMainType::TS: {
882 auto tsFilterType =
883 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tsFilterType>();
884 return (tsFilterType == DemuxTsFilterType::SECTION ||
885 tsFilterType == DemuxTsFilterType::PES ||
886 tsFilterType == DemuxTsFilterType::AUDIO ||
887 tsFilterType == DemuxTsFilterType::VIDEO ||
888 tsFilterType == DemuxTsFilterType::RECORD ||
889 tsFilterType == DemuxTsFilterType::TEMI);
890 }
891 case DemuxFilterMainType::MMTP: {
892 auto mmtpFilterType =
893 filterConfig.type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>();
894 return (mmtpFilterType == DemuxMmtpFilterType::SECTION ||
895 mmtpFilterType == DemuxMmtpFilterType::PES ||
896 mmtpFilterType == DemuxMmtpFilterType::AUDIO ||
897 mmtpFilterType == DemuxMmtpFilterType::VIDEO ||
898 mmtpFilterType == DemuxMmtpFilterType::RECORD ||
899 mmtpFilterType == DemuxMmtpFilterType::DOWNLOAD);
900 }
901 case DemuxFilterMainType::IP: {
902 auto ipFilterType =
903 filterConfig.type.subType.get<DemuxFilterSubType::Tag::ipFilterType>();
904 return (ipFilterType == DemuxIpFilterType::SECTION);
905 }
906 case DemuxFilterMainType::TLV: {
907 auto tlvFilterType =
908 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tlvFilterType>();
909 return (tlvFilterType == DemuxTlvFilterType::SECTION);
910 }
911 case DemuxFilterMainType::ALP: {
912 auto alpFilterType =
913 filterConfig.type.subType.get<DemuxFilterSubType::Tag::alpFilterType>();
914 return (alpFilterType == DemuxAlpFilterType::SECTION);
915 }
916 default:
917 return false;
918 }
919}
920
Patrick Rohr1586d212021-11-23 00:40:56 +0100921static bool isMediaFilter(const FilterConfig& filterConfig) {
922 switch (filterConfig.type.mainType) {
923 case DemuxFilterMainType::TS: {
924 // TS Audio and Video filters are media filters
925 auto tsFilterType =
926 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tsFilterType>();
927 return (tsFilterType == DemuxTsFilterType::AUDIO ||
928 tsFilterType == DemuxTsFilterType::VIDEO);
929 }
930 case DemuxFilterMainType::MMTP: {
931 // MMTP Audio and Video filters are media filters
932 auto mmtpFilterType =
933 filterConfig.type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>();
934 return (mmtpFilterType == DemuxMmtpFilterType::AUDIO ||
935 mmtpFilterType == DemuxMmtpFilterType::VIDEO);
936 }
937 default:
938 return false;
939 }
940}
Patrick Rohr149b0872021-11-20 00:39:37 +0100941
Patrick Rohr1586d212021-11-23 00:40:56 +0100942static int getDemuxFilterEventDataLength(const DemuxFilterEvent& event) {
943 switch (event.getTag()) {
944 case DemuxFilterEvent::Tag::section:
945 return event.get<DemuxFilterEvent::Tag::section>().dataLength;
946 case DemuxFilterEvent::Tag::media:
947 return event.get<DemuxFilterEvent::Tag::media>().dataLength;
948 case DemuxFilterEvent::Tag::pes:
949 return event.get<DemuxFilterEvent::Tag::pes>().dataLength;
950 case DemuxFilterEvent::Tag::download:
951 return event.get<DemuxFilterEvent::Tag::download>().dataLength;
952 case DemuxFilterEvent::Tag::ipPayload:
953 return event.get<DemuxFilterEvent::Tag::ipPayload>().dataLength;
954
955 case DemuxFilterEvent::Tag::tsRecord:
956 case DemuxFilterEvent::Tag::mmtpRecord:
957 case DemuxFilterEvent::Tag::temi:
958 case DemuxFilterEvent::Tag::monitorEvent:
959 case DemuxFilterEvent::Tag::startId:
960 return 0;
961 }
962}
963
964// TODO: move boilerplate into text fixture
965void TunerFilterAidlTest::testDelayHint(const FilterConfig& filterConf) {
Gareth Fenn9a808452022-03-31 08:40:00 +0100966 if (!filterConf.timeDelayInMs && !filterConf.dataDelayInBytes) {
967 return;
968 }
969 if (!isEventProducingFilter(filterConf)) {
970 return;
971 }
Patrick Rohr149b0872021-11-20 00:39:37 +0100972 int32_t feId;
973 int32_t demuxId;
974 std::shared_ptr<IDemux> demux;
975 int64_t filterId;
976
977 mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId);
978 ASSERT_TRUE(feId != INVALID_ID);
979 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
980 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
981 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
982 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
983 mFilterTests.setDemux(demux);
984
Patrick Rohr149b0872021-11-20 00:39:37 +0100985 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
986 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
Patrick Rohr149b0872021-11-20 00:39:37 +0100987
Patrick Rohr1586d212021-11-23 00:40:56 +0100988 bool mediaFilter = isMediaFilter(filterConf);
Patrick Rohr149b0872021-11-20 00:39:37 +0100989 auto filter = mFilterTests.getFilterById(filterId);
990
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +0100991 // startTime needs to be set before calling setDelayHint.
992 auto startTime = std::chrono::steady_clock::now();
993
Gareth Fenn9a808452022-03-31 08:40:00 +0100994 int timeDelayInMs = filterConf.timeDelayInMs;
995 if (timeDelayInMs > 0) {
Patrick Rohr1586d212021-11-23 00:40:56 +0100996 FilterDelayHint delayHint;
997 delayHint.hintType = FilterDelayHintType::TIME_DELAY_IN_MS;
Gareth Fenn9a808452022-03-31 08:40:00 +0100998 delayHint.hintValue = timeDelayInMs;
Patrick Rohr149b0872021-11-20 00:39:37 +0100999
Patrick Rohr1586d212021-11-23 00:40:56 +01001000 // setDelayHint should fail for media filters.
1001 ASSERT_EQ(filter->setDelayHint(delayHint).isOk(), !mediaFilter);
1002 }
Patrick Rohr149b0872021-11-20 00:39:37 +01001003
Patrick Rohr1586d212021-11-23 00:40:56 +01001004 int dataDelayInBytes = filterConf.dataDelayInBytes;
1005 if (dataDelayInBytes > 0) {
1006 FilterDelayHint delayHint;
1007 delayHint.hintType = FilterDelayHintType::DATA_SIZE_DELAY_IN_BYTES;
1008 delayHint.hintValue = dataDelayInBytes;
Patrick Rohr149b0872021-11-20 00:39:37 +01001009
Patrick Rohr1586d212021-11-23 00:40:56 +01001010 // setDelayHint should fail for media filters.
1011 ASSERT_EQ(filter->setDelayHint(delayHint).isOk(), !mediaFilter);
1012 }
Patrick Rohr149b0872021-11-20 00:39:37 +01001013
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +01001014 // start and stop filter (and wait for first callback) in order to
1015 // circumvent callback scheduler race conditions after adjusting filter
1016 // delays.
1017 auto cb = mFilterTests.getFilterCallbacks().at(filterId);
1018 auto future =
1019 cb->verifyFilterCallback([](const std::vector<DemuxFilterEvent>&) { return true; });
Gareth Fenn9a808452022-03-31 08:40:00 +01001020
1021 // The configure stage can also produce events, so we should set the delay
1022 // hint beforehand.
1023 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
Patrick Rohr1586d212021-11-23 00:40:56 +01001024 mFilterTests.startFilter(filterId);
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +01001025
1026 auto timeout = std::chrono::seconds(30);
1027 ASSERT_EQ(future.wait_for(timeout), std::future_status::ready);
1028
Patrick Rohr1586d212021-11-23 00:40:56 +01001029 mFilterTests.stopFilter(filterId);
Patrick Rohr149b0872021-11-20 00:39:37 +01001030
Patrick Rohr1586d212021-11-23 00:40:56 +01001031 if (!mediaFilter) {
Patrick Rohr1586d212021-11-23 00:40:56 +01001032 int callbackSize = 0;
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +01001033 future = cb->verifyFilterCallback(
Patrick Rohr1586d212021-11-23 00:40:56 +01001034 [&callbackSize](const std::vector<DemuxFilterEvent>& events) {
1035 for (const auto& event : events) {
1036 callbackSize += getDemuxFilterEventDataLength(event);
1037 }
1038 return true;
1039 });
1040
Patrick Rohr1586d212021-11-23 00:40:56 +01001041 ASSERT_TRUE(mFilterTests.startFilter(filterId));
1042
1043 // block and wait for callback to be received.
Patrick Rohr1586d212021-11-23 00:40:56 +01001044 ASSERT_EQ(future.wait_for(timeout), std::future_status::ready);
Patrick Rohr1586d212021-11-23 00:40:56 +01001045
Gareth Fenn9a808452022-03-31 08:40:00 +01001046 auto duration = std::chrono::steady_clock::now() - startTime;
1047 bool delayHintTest = duration >= std::chrono::milliseconds(timeDelayInMs);
Patrick Rohr1586d212021-11-23 00:40:56 +01001048 bool dataSizeTest = callbackSize >= dataDelayInBytes;
1049
Gareth Fenn9a808452022-03-31 08:40:00 +01001050 if (timeDelayInMs > 0 && dataDelayInBytes > 0) {
Patrick Rohr1586d212021-11-23 00:40:56 +01001051 ASSERT_TRUE(delayHintTest || dataSizeTest);
1052 } else {
1053 // if only one of time delay / data delay is configured, one of them
1054 // holds true by default, so we want both assertions to be true.
1055 ASSERT_TRUE(delayHintTest && dataSizeTest);
1056 }
1057
1058 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
1059 }
1060
Patrick Rohr149b0872021-11-20 00:39:37 +01001061 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
1062 ASSERT_TRUE(mDemuxTests.closeDemux());
1063 ASSERT_TRUE(mFrontendTests.closeFrontend());
1064}
1065
Patrick Rohr1586d212021-11-23 00:40:56 +01001066TEST_P(TunerFilterAidlTest, FilterDelayHintTest) {
1067 description("Test filter time delay hint.");
Gareth Fenn9a808452022-03-31 08:40:00 +01001068 if (!live.hasFrontendConnection) {
1069 return;
1070 }
Patrick Rohr1586d212021-11-23 00:40:56 +01001071 for (const auto& obj : filterMap) {
1072 testDelayHint(obj.second);
1073 }
1074}
1075
Hongguang600a6ae2021-07-08 18:51:51 -07001076TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsSectionFilterTest) {
1077 description("Feed ts data from playback and configure Ts section filter to get output");
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001078 if (!playback.support) {
Hongguang600a6ae2021-07-08 18:51:51 -07001079 return;
1080 }
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001081 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1082 for (auto& configuration : playback_configs) {
1083 if (configuration.sectionFilterId.compare(emptyHardwareId) != 0) {
1084 playback = configuration;
1085 playbackSingleFilterTest(filterMap[playback.sectionFilterId], dvrMap[playback.dvrId]);
1086 }
1087 }
Hongguang600a6ae2021-07-08 18:51:51 -07001088}
1089
1090TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsAudioFilterTest) {
1091 description("Feed ts data from playback and configure Ts audio 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.audioFilterId], dvrMap[playback.dvrId]);
1099 }
Hongguang600a6ae2021-07-08 18:51:51 -07001100}
1101
1102TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsVideoFilterTest) {
1103 description("Feed ts data from playback and configure Ts video filter to get output");
1104 if (!playback.support) {
1105 return;
1106 }
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001107 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1108 for (auto& configuration : playback_configs) {
1109 playback = configuration;
1110 playbackSingleFilterTest(filterMap[playback.videoFilterId], dvrMap[playback.dvrId]);
1111 }
Hongguang600a6ae2021-07-08 18:51:51 -07001112}
1113
Ray Chin62ab6c92022-09-15 15:07:33 +08001114TEST_P(TunerPlaybackAidlTest, SetStatusCheckIntervalHintToPlaybackTest) {
1115 description("Set status check interval hint to playback test.");
1116 if (!playback.support) {
1117 return;
1118 }
1119 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1120 for (auto& configuration : playback_configs) {
1121 playback = configuration;
1122 setStatusCheckIntervalHintTest(STATUS_CHECK_INTERVAL_MS, dvrMap[playback.dvrId]);
1123 }
1124}
1125
Hongguang600a6ae2021-07-08 18:51:51 -07001126TEST_P(TunerRecordAidlTest, RecordDataFlowWithTsRecordFilterTest) {
1127 description("Feed ts data from frontend to recording and test with ts record filter");
1128 if (!record.support) {
1129 return;
1130 }
sadiqsada7a191392023-11-07 16:09:09 -08001131 // Do not execute tests for IPTV Frontend
1132 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1133 return;
1134 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +00001135 auto record_configs = generateRecordConfigurations();
1136 for (auto& configuration : record_configs) {
1137 record = configuration;
1138 recordSingleFilterTest(filterMap[record.recordFilterId], frontendMap[record.frontendId],
1139 dvrMap[record.dvrRecordId], Dataflow_Context::RECORD);
1140 }
Hongguang600a6ae2021-07-08 18:51:51 -07001141}
1142
1143TEST_P(TunerRecordAidlTest, AttachFiltersToRecordTest) {
1144 description("Attach a single filter to the record dvr test.");
1145 // TODO use parameterized tests
1146 if (!record.support) {
1147 return;
1148 }
sadiqsada7a191392023-11-07 16:09:09 -08001149 // Do not execute tests for IPTV Frontend
1150 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1151 return;
1152 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +00001153 auto record_configs = generateRecordConfigurations();
1154 for (auto& configuration : record_configs) {
1155 record = configuration;
1156 attachSingleFilterToRecordDvrTest(filterMap[record.recordFilterId],
1157 frontendMap[record.frontendId],
1158 dvrMap[record.dvrRecordId]);
1159 }
Hongguang600a6ae2021-07-08 18:51:51 -07001160}
1161
1162TEST_P(TunerRecordAidlTest, LnbRecordDataFlowWithTsRecordFilterTest) {
1163 description("Feed ts data from Fe with Lnb to recording and test with ts record filter");
1164 if (!lnbRecord.support) {
1165 return;
1166 }
Frankie Lizcanoecba02a2022-07-12 17:56:54 +00001167 vector<LnbRecordHardwareConnections> lnbRecord_configs = generateLnbRecordConfigurations();
1168 if (lnbRecord_configs.empty()) {
1169 ALOGD("No frontends that support satellites.");
1170 return;
1171 }
1172 for (auto& configuration : lnbRecord_configs) {
1173 lnbRecord = configuration;
1174 recordSingleFilterTestWithLnb(filterMap[lnbRecord.recordFilterId],
1175 frontendMap[lnbRecord.frontendId],
1176 dvrMap[lnbRecord.dvrRecordId], lnbMap[lnbRecord.lnbId]);
1177 }
Hongguang600a6ae2021-07-08 18:51:51 -07001178}
1179
Ray Chin62ab6c92022-09-15 15:07:33 +08001180TEST_P(TunerRecordAidlTest, SetStatusCheckIntervalHintToRecordTest) {
1181 description("Set status check interval hint to record test.");
1182 if (!record.support) {
1183 return;
1184 }
sadiqsada7a191392023-11-07 16:09:09 -08001185 // Do not execute tests for IPTV Frontend
1186 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1187 return;
1188 }
Ray Chin62ab6c92022-09-15 15:07:33 +08001189 auto record_configs = generateRecordConfigurations();
1190 for (auto& configuration : record_configs) {
1191 record = configuration;
1192 setStatusCheckIntervalHintTest(STATUS_CHECK_INTERVAL_MS, frontendMap[record.frontendId],
1193 dvrMap[record.dvrRecordId]);
1194 }
1195}
1196
Hongguang600a6ae2021-07-08 18:51:51 -07001197TEST_P(TunerFrontendAidlTest, TuneFrontend) {
1198 description("Tune one Frontend with specific setting and check Lock event");
1199 if (!live.hasFrontendConnection) {
1200 return;
1201 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001202 auto live_configs = generateLiveConfigurations();
1203 for (auto& configuration : live_configs) {
1204 live = configuration;
1205 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
1206 }
Hongguang600a6ae2021-07-08 18:51:51 -07001207}
1208
1209TEST_P(TunerFrontendAidlTest, AutoScanFrontend) {
1210 description("Run an auto frontend scan with specific setting and check lock scanMessage");
1211 if (!scan.hasFrontendConnection) {
1212 return;
1213 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001214 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1215 for (auto& configuration : scan_configs) {
1216 scan = configuration;
1217 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_AUTO);
1218 }
Hongguang600a6ae2021-07-08 18:51:51 -07001219}
1220
1221TEST_P(TunerFrontendAidlTest, BlindScanFrontend) {
1222 description("Run an blind frontend scan with specific setting and check lock scanMessage");
1223 if (!scan.hasFrontendConnection) {
1224 return;
1225 }
sadiqsada7a191392023-11-07 16:09:09 -08001226 // Blind scan is not applicable for IPTV frontend
1227 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1228 return;
1229 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001230 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1231 for (auto& configuration : scan_configs) {
1232 scan = configuration;
Ray Chin740a0a82023-12-22 19:10:46 +08001233 // Skip test if the frontend implementation doesn't support blind scan
1234 if (!frontendMap[scan.frontendId].supportBlindScan) {
1235 continue;
1236 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001237 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_BLIND);
1238 }
Hongguang600a6ae2021-07-08 18:51:51 -07001239}
1240
1241TEST_P(TunerFrontendAidlTest, TuneFrontendWithFrontendSettings) {
1242 description("Tune one Frontend with setting and check Lock event");
1243 if (!live.hasFrontendConnection) {
1244 return;
1245 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001246 auto live_configs = generateLiveConfigurations();
1247 for (auto& configuration : live_configs) {
1248 live = configuration;
1249 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
1250 }
Hongguang600a6ae2021-07-08 18:51:51 -07001251}
1252
1253TEST_P(TunerFrontendAidlTest, BlindScanFrontendWithEndFrequency) {
1254 description("Run an blind frontend scan with setting and check lock scanMessage");
1255 if (!scan.hasFrontendConnection) {
1256 return;
1257 }
sadiqsada7a191392023-11-07 16:09:09 -08001258 // Blind scan is not application for IPTV frontend
1259 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1260 return;
1261 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001262 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1263 for (auto& configuration : scan_configs) {
1264 scan = configuration;
Ray Chin740a0a82023-12-22 19:10:46 +08001265 // Skip test if the frontend implementation doesn't support blind scan
1266 if (!frontendMap[scan.frontendId].supportBlindScan) {
1267 continue;
1268 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001269 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_BLIND);
1270 }
Hongguang600a6ae2021-07-08 18:51:51 -07001271}
1272
1273TEST_P(TunerFrontendAidlTest, LinkToCiCam) {
1274 description("Test Frontend link to CiCam");
1275 if (!live.hasFrontendConnection) {
1276 return;
1277 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001278 auto live_configs = generateLiveConfigurations();
1279 for (auto& configuration : live_configs) {
1280 live = configuration;
1281 if (!frontendMap[live.frontendId].canConnectToCiCam) {
1282 continue;
1283 }
1284 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -07001285 }
Hongguang600a6ae2021-07-08 18:51:51 -07001286}
1287
Hongguangfcedda02021-12-13 17:08:02 -08001288TEST_P(TunerFrontendAidlTest, getHardwareInfo) {
1289 description("Test Frontend get hardware info");
sadiqsada7a191392023-11-07 16:09:09 -08001290 // Do not execute tests for IPTV Frontend
1291 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1292 return;
1293 }
Hongguangfcedda02021-12-13 17:08:02 -08001294 if (!live.hasFrontendConnection) {
1295 return;
1296 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001297 auto live_configs = generateLiveConfigurations();
1298 for (auto& configuration : live_configs) {
1299 live = configuration;
1300 mFrontendTests.debugInfoTest(frontendMap[live.frontendId]);
1301 }
Hongguangfcedda02021-12-13 17:08:02 -08001302}
1303
Hongguang5766ddf2021-12-23 11:40:37 -08001304TEST_P(TunerFrontendAidlTest, maxNumberOfFrontends) {
1305 description("Test Max Frontend number");
1306 if (!live.hasFrontendConnection) {
1307 return;
1308 }
1309 mFrontendTests.maxNumberOfFrontendsTest();
1310}
1311
Hongguang881190f2022-01-14 13:23:37 -08001312TEST_P(TunerFrontendAidlTest, statusReadinessTest) {
1313 description("Test Max Frontend status readiness");
1314 if (!live.hasFrontendConnection) {
1315 return;
1316 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001317 auto live_configs = generateLiveConfigurations();
1318 for (auto& configuration : live_configs) {
1319 live = configuration;
1320 mFrontendTests.statusReadinessTest(frontendMap[live.frontendId]);
1321 }
Hongguang881190f2022-01-14 13:23:37 -08001322}
1323
Hongguang600a6ae2021-07-08 18:51:51 -07001324TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowVideoFilterTest) {
1325 description("Test Video Filter functionality in Broadcast use case.");
1326 if (!live.hasFrontendConnection) {
1327 return;
1328 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001329 auto live_configs = generateLiveConfigurations();
1330 for (auto& configuration : live_configs) {
1331 live = configuration;
1332 broadcastSingleFilterTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
1333 }
Hongguang600a6ae2021-07-08 18:51:51 -07001334}
1335
1336TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowAudioFilterTest) {
1337 description("Test Audio Filter functionality in Broadcast use case.");
1338 if (!live.hasFrontendConnection) {
1339 return;
1340 }
sadiqsada7a191392023-11-07 16:09:09 -08001341 // Do not execute tests for IPTV Frontend
1342 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1343 return;
1344 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001345 auto live_configs = generateLiveConfigurations();
1346 for (auto& configuration : live_configs) {
1347 live = configuration;
1348 broadcastSingleFilterTest(filterMap[live.audioFilterId], frontendMap[live.frontendId]);
1349 }
Hongguang600a6ae2021-07-08 18:51:51 -07001350}
1351
1352TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowSectionFilterTest) {
1353 description("Test Section Filter functionality in Broadcast use case.");
1354 if (!live.hasFrontendConnection) {
1355 return;
1356 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001357 auto live_configs = generateLiveConfigurations();
1358 for (auto& configuration : live_configs) {
1359 live = configuration;
1360 if (live.sectionFilterId.compare(emptyHardwareId) == 0) {
1361 continue;
1362 }
1363 broadcastSingleFilterTest(filterMap[live.sectionFilterId], frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -07001364 }
Hongguang600a6ae2021-07-08 18:51:51 -07001365}
1366
1367TEST_P(TunerBroadcastAidlTest, IonBufferTest) {
1368 description("Test the av filter data bufferring.");
1369 if (!live.hasFrontendConnection) {
1370 return;
1371 }
sadiqsada7a191392023-11-07 16:09:09 -08001372 // Do not execute tests for IPTV Frontend
1373 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1374 return;
1375 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001376 auto live_configs = generateLiveConfigurations();
1377 for (auto& configuration : live_configs) {
1378 live = configuration;
1379 broadcastSingleFilterTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
1380 }
Hongguang600a6ae2021-07-08 18:51:51 -07001381}
1382
1383TEST_P(TunerBroadcastAidlTest, LnbBroadcastDataFlowVideoFilterTest) {
1384 description("Test Video Filter functionality in Broadcast with Lnb use case.");
1385 if (!lnbLive.support) {
1386 return;
1387 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +00001388 vector<LnbLiveHardwareConnections> lnbLive_configs = generateLnbLiveConfigurations();
1389 if (lnbLive_configs.empty()) {
1390 ALOGD("No frontends that support satellites.");
1391 return;
1392 }
1393 for (auto& combination : lnbLive_configs) {
1394 lnbLive = combination;
1395 broadcastSingleFilterTestWithLnb(filterMap[lnbLive.videoFilterId],
1396 frontendMap[lnbLive.frontendId], lnbMap[lnbLive.lnbId]);
1397 }
Hongguang600a6ae2021-07-08 18:51:51 -07001398}
1399
1400TEST_P(TunerBroadcastAidlTest, MediaFilterWithSharedMemoryHandle) {
1401 description("Test the Media Filter with shared memory handle");
1402 if (!live.hasFrontendConnection) {
1403 return;
1404 }
sadiqsada7a191392023-11-07 16:09:09 -08001405 // Do not execute tests for IPTV Frontend
1406 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1407 return;
1408 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001409 auto live_configs = generateLiveConfigurations();
1410 for (auto& configuration : live_configs) {
1411 live = configuration;
1412 mediaFilterUsingSharedMemoryTest(filterMap[live.videoFilterId],
1413 frontendMap[live.frontendId]);
1414 }
Hongguang600a6ae2021-07-08 18:51:51 -07001415}
1416
1417TEST_P(TunerDescramblerAidlTest, CreateDescrambler) {
1418 description("Create Descrambler");
1419 if (!descrambling.support) {
1420 return;
1421 }
sadiqsada7a191392023-11-07 16:09:09 -08001422 // Do not execute tests for IPTV Frontend
1423 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1424 return;
1425 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001426 vector<DescramblingHardwareConnections> descrambling_configs =
1427 generateDescramblingConfigurations();
1428 if (descrambling_configs.empty()) {
1429 ALOGD("No valid descrambling combinations in the configuration file.");
1430 return;
Hongguang600a6ae2021-07-08 18:51:51 -07001431 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001432 for (auto& combination : descrambling_configs) {
1433 descrambling = combination;
1434 int32_t demuxId;
1435 std::shared_ptr<IDemux> demux;
1436 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
Hongguang600a6ae2021-07-08 18:51:51 -07001437
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001438 if (descrambling.hasFrontendConnection) {
1439 int32_t feId;
1440 mFrontendTests.getFrontendIdByType(frontendMap[descrambling.frontendId].type, feId);
1441 ASSERT_TRUE(feId != INVALID_ID);
1442 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
1443 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
1444 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
1445 }
Hongguang600a6ae2021-07-08 18:51:51 -07001446
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001447 ASSERT_TRUE(mDescramblerTests.openDescrambler(demuxId));
1448 ASSERT_TRUE(mDescramblerTests.closeDescrambler());
1449 ASSERT_TRUE(mDemuxTests.closeDemux());
1450
1451 if (descrambling.hasFrontendConnection) {
1452 ASSERT_TRUE(mFrontendTests.closeFrontend());
1453 }
Hongguang600a6ae2021-07-08 18:51:51 -07001454 }
1455}
1456
1457TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTest) {
1458 description("Test ts audio filter in scrambled broadcast use case");
1459 if (!descrambling.support) {
1460 return;
1461 }
sadiqsada7a191392023-11-07 16:09:09 -08001462 // Do not execute tests for IPTV Frontend
1463 if (frontendMap[live.frontendId].type == FrontendType::IPTV) {
1464 return;
1465 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001466 vector<DescramblingHardwareConnections> descrambling_configs =
1467 generateDescramblingConfigurations();
1468 if (descrambling_configs.empty()) {
1469 ALOGD("No valid descrambling combinations in the configuration file.");
1470 return;
1471 }
1472 for (auto& combination : descrambling_configs) {
1473 descrambling = combination;
1474 set<FilterConfig> filterConfs;
1475 filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.audioFilterId]));
1476 filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.videoFilterId]));
1477 scrambledBroadcastTest(filterConfs, frontendMap[descrambling.frontendId],
Frankie Lizcano82101d22022-07-28 00:12:35 +00001478 descramblerMap[descrambling.descramblerId],
1479 Dataflow_Context::DESCRAMBLING);
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001480 }
Hongguang600a6ae2021-07-08 18:51:51 -07001481}
1482
Frankie Lizcano82101d22022-07-28 00:12:35 +00001483TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTestWithLnb) {
1484 description("Test media filters in scrambled broadcast use case with Lnb");
1485 if (!lnbDescrambling.support) {
1486 return;
1487 }
Frankie Lizcanobcf4ebb2022-08-01 18:06:00 +00001488 auto lnbDescrambling_configs = generateLnbDescramblingConfigurations();
1489 if (lnbDescrambling_configs.empty()) {
1490 ALOGD("No frontends that support satellites.");
1491 return;
1492 }
1493 for (auto& configuration : lnbDescrambling_configs) {
1494 lnbDescrambling = configuration;
1495 set<FilterConfig> filterConfs;
1496 filterConfs.insert(static_cast<FilterConfig>(filterMap[lnbDescrambling.audioFilterId]));
1497 filterConfs.insert(static_cast<FilterConfig>(filterMap[lnbDescrambling.videoFilterId]));
1498 scrambledBroadcastTestWithLnb(filterConfs, frontendMap[lnbDescrambling.frontendId],
1499 descramblerMap[lnbDescrambling.descramblerId],
1500 lnbMap[lnbDescrambling.lnbId]);
1501 }
Frankie Lizcano82101d22022-07-28 00:12:35 +00001502}
1503
Hongguang600a6ae2021-07-08 18:51:51 -07001504INSTANTIATE_TEST_SUITE_P(PerInstance, TunerBroadcastAidlTest,
1505 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1506 android::PrintInstanceNameToString);
1507
1508INSTANTIATE_TEST_SUITE_P(PerInstance, TunerFrontendAidlTest,
1509 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1510 android::PrintInstanceNameToString);
1511
1512INSTANTIATE_TEST_SUITE_P(PerInstance, TunerFilterAidlTest,
1513 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1514 android::PrintInstanceNameToString);
1515
1516INSTANTIATE_TEST_SUITE_P(PerInstance, TunerRecordAidlTest,
1517 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1518 android::PrintInstanceNameToString);
1519
1520INSTANTIATE_TEST_SUITE_P(PerInstance, TunerLnbAidlTest,
1521 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1522 android::PrintInstanceNameToString);
1523
1524INSTANTIATE_TEST_SUITE_P(PerInstance, TunerDemuxAidlTest,
1525 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1526 android::PrintInstanceNameToString);
1527
1528INSTANTIATE_TEST_SUITE_P(PerInstance, TunerPlaybackAidlTest,
1529 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1530 android::PrintInstanceNameToString);
1531
1532INSTANTIATE_TEST_SUITE_P(PerInstance, TunerDescramblerAidlTest,
1533 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1534 android::PrintInstanceNameToString);
1535
1536} // namespace
1537
1538// Start thread pool to receive callbacks from AIDL service.
1539int main(int argc, char** argv) {
1540 ::testing::InitGoogleTest(&argc, argv);
1541 ABinderProcess_setThreadPoolMaxThreadCount(1);
1542 ABinderProcess_startThreadPool();
1543 return RUN_ALL_TESTS();
1544}