blob: 6aa1e162cfee77a15954c81d7bca94049bfa007e [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));
63 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
64 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
65 ASSERT_TRUE(mDemuxTests.closeDemux());
66 ASSERT_TRUE(mFrontendTests.closeFrontend());
67}
68
69void TunerFilterAidlTest::reconfigSingleFilterInDemuxTest(FilterConfig filterConf,
70 FilterConfig filterReconf,
71 FrontendConfig frontendConf) {
72 int32_t feId;
73 int32_t demuxId;
74 std::shared_ptr<IDemux> demux;
75 int64_t filterId;
76
77 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
78 ASSERT_TRUE(feId != INVALID_ID);
79 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
80 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
81 if (frontendConf.isSoftwareFe) {
82 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[live.dvrSoftwareFeId]);
83 }
84 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
85 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
86 mFrontendTests.setDemux(demux);
87 mFilterTests.setDemux(demux);
88 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
89 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
90 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
91 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
92 ASSERT_TRUE(mFilterTests.startFilter(filterId));
93 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
94 ASSERT_TRUE(mFilterTests.configFilter(filterReconf.settings, filterId));
95 ASSERT_TRUE(mFilterTests.startFilter(filterId));
96 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
97 ASSERT_TRUE(mFilterTests.startIdTest(filterId));
98 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
99 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
100 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
101 ASSERT_TRUE(mDemuxTests.closeDemux());
102 ASSERT_TRUE(mFrontendTests.closeFrontend());
103}
104
105void TunerFilterAidlTest::testTimeFilter(TimeFilterConfig filterConf) {
106 int32_t demuxId;
107 std::shared_ptr<IDemux> demux;
108 DemuxCapabilities caps;
109
110 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
111 ASSERT_TRUE(mDemuxTests.getDemuxCaps(caps));
112 ASSERT_TRUE(caps.bTimeFilter);
113 mFilterTests.setDemux(demux);
114 ASSERT_TRUE(mFilterTests.openTimeFilterInDemux());
115 ASSERT_TRUE(mFilterTests.setTimeStamp(filterConf.timeStamp));
116 ASSERT_TRUE(mFilterTests.getTimeStamp());
117 ASSERT_TRUE(mFilterTests.clearTimeStamp());
118 ASSERT_TRUE(mFilterTests.closeTimeFilter());
119 ASSERT_TRUE(mDemuxTests.closeDemux());
120}
121
122void TunerBroadcastAidlTest::broadcastSingleFilterTest(FilterConfig filterConf,
123 FrontendConfig frontendConf) {
124 int32_t feId;
125 int32_t demuxId;
126 std::shared_ptr<IDemux> demux;
127 int64_t filterId;
128
129 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
130 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
131 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
Frankie Lizcano87421812022-07-28 17:13:01 +0000132 if (mLnbId != INVALID_LNB_ID) {
133 ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
Hongguang600a6ae2021-07-08 18:51:51 -0700134 }
135 if (frontendConf.isSoftwareFe) {
136 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[live.dvrSoftwareFeId]);
137 }
138 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
139 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
140 mFrontendTests.setDemux(demux);
141 mFilterTests.setDemux(demux);
142 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
143 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
144 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
145 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
146 ASSERT_TRUE(mFilterTests.startFilter(filterId));
147 // tune test
148 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
149 ASSERT_TRUE(filterDataOutputTest());
150 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
151 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
152 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
153 ASSERT_TRUE(mDemuxTests.closeDemux());
154 ASSERT_TRUE(mFrontendTests.closeFrontend());
155}
156
157void TunerBroadcastAidlTest::broadcastSingleFilterTestWithLnb(FilterConfig filterConf,
158 FrontendConfig frontendConf,
159 LnbConfig lnbConf) {
160 if (lnbConf.name.compare(emptyHardwareId) == 0) {
161 vector<int32_t> ids;
162 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
163 ASSERT_TRUE(ids.size() > 0);
164 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
Frankie Lizcano87421812022-07-28 17:13:01 +0000165 mLnbId = ids[0];
Hongguang600a6ae2021-07-08 18:51:51 -0700166 } else {
Frankie Lizcano87421812022-07-28 17:13:01 +0000167 ASSERT_TRUE(mLnbTests.openLnbByName(lnbConf.name, mLnbId));
Hongguang600a6ae2021-07-08 18:51:51 -0700168 }
169 ASSERT_TRUE(mLnbTests.setLnbCallback());
170 ASSERT_TRUE(mLnbTests.setVoltage(lnbConf.voltage));
171 ASSERT_TRUE(mLnbTests.setTone(lnbConf.tone));
172 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConf.position));
Frankie Lizcanod1f520e2022-07-26 20:05:46 +0000173 if (!frontendConf.isSoftwareFe) {
174 broadcastSingleFilterTest(filterConf, frontendConf);
175 }
Hongguang600a6ae2021-07-08 18:51:51 -0700176 ASSERT_TRUE(mLnbTests.closeLnb());
Frankie Lizcano87421812022-07-28 17:13:01 +0000177 mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700178}
179
180void TunerBroadcastAidlTest::mediaFilterUsingSharedMemoryTest(FilterConfig filterConf,
181 FrontendConfig frontendConf) {
182 int32_t feId;
183 int32_t demuxId;
184 std::shared_ptr<IDemux> demux;
185 int64_t filterId;
186
187 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
188 ASSERT_TRUE(feId != INVALID_ID);
189 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
190 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
191 if (frontendConf.isSoftwareFe) {
192 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[live.dvrSoftwareFeId]);
193 }
194 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
195 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
196 mFrontendTests.setDemux(demux);
197 mFilterTests.setDemux(demux);
198 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
199 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
200 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
201 ASSERT_TRUE(mFilterTests.getSharedAvMemoryHandle(filterId));
202 ASSERT_TRUE(mFilterTests.configAvFilterStreamType(filterConf.streamType, filterId));
203 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
204 ASSERT_TRUE(mFilterTests.startFilter(filterId));
205 // tune test
206 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
207 ASSERT_TRUE(filterDataOutputTest());
208 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
209 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
210 ASSERT_TRUE(mFilterTests.releaseShareAvHandle(filterId));
211 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
212 ASSERT_TRUE(mDemuxTests.closeDemux());
213 ASSERT_TRUE(mFrontendTests.closeFrontend());
214}
215
216void TunerPlaybackAidlTest::playbackSingleFilterTest(FilterConfig filterConf, DvrConfig dvrConf) {
217 int32_t demuxId;
218 std::shared_ptr<IDemux> demux;
219 int64_t filterId;
220
221 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
222 mFilterTests.setDemux(demux);
223 mDvrTests.setDemux(demux);
224 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
225 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrConf.settings));
226 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
227 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
228 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
229 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
230 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
231 mDvrTests.startPlaybackInputThread(dvrConf.playbackInputFile,
232 dvrConf.settings.get<DvrSettings::Tag::playback>());
233 ASSERT_TRUE(mDvrTests.startDvrPlayback());
234 ASSERT_TRUE(mFilterTests.startFilter(filterId));
235 ASSERT_TRUE(filterDataOutputTest());
236 mDvrTests.stopPlaybackThread();
237 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
238 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
239 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
240 mDvrTests.closeDvrPlayback();
241 ASSERT_TRUE(mDemuxTests.closeDemux());
242}
243
Ray Chin62ab6c92022-09-15 15:07:33 +0800244void TunerPlaybackAidlTest::setStatusCheckIntervalHintTest(int64_t statusCheckIntervalHint,
245 DvrConfig dvrConf) {
246 int32_t demuxId;
247 std::shared_ptr<IDemux> demux;
248
249 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
250 mDvrTests.setDemux(demux);
251 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
252 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrConf.settings));
253 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
254
255 ASSERT_TRUE(mDvrTests.setPlaybackStatusCheckIntervalHint(statusCheckIntervalHint));
256
257 mDvrTests.startPlaybackInputThread(dvrConf.playbackInputFile,
258 dvrConf.settings.get<DvrSettings::Tag::playback>());
259 ASSERT_TRUE(mDvrTests.startDvrPlayback());
260 mDvrTests.stopPlaybackThread();
261 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
262 mDvrTests.closeDvrPlayback();
263 ASSERT_TRUE(mDemuxTests.closeDemux());
264}
265
Hongguang600a6ae2021-07-08 18:51:51 -0700266void TunerRecordAidlTest::recordSingleFilterTestWithLnb(FilterConfig filterConf,
267 FrontendConfig frontendConf,
268 DvrConfig dvrConf, LnbConfig lnbConf) {
269 if (lnbConf.name.compare(emptyHardwareId) == 0) {
270 vector<int32_t> ids;
271 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
272 ASSERT_TRUE(ids.size() > 0);
273 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
Frankie Lizcano87421812022-07-28 17:13:01 +0000274 mLnbId = ids[0];
Hongguang600a6ae2021-07-08 18:51:51 -0700275 } else {
Frankie Lizcano87421812022-07-28 17:13:01 +0000276 ASSERT_TRUE(mLnbTests.openLnbByName(lnbConf.name, mLnbId));
Hongguang600a6ae2021-07-08 18:51:51 -0700277 }
278 ASSERT_TRUE(mLnbTests.setLnbCallback());
279 ASSERT_TRUE(mLnbTests.setVoltage(lnbConf.voltage));
280 ASSERT_TRUE(mLnbTests.setTone(lnbConf.tone));
281 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConf.position));
282 for (auto msgName : lnbRecord.diseqcMsgs) {
283 ASSERT_TRUE(mLnbTests.sendDiseqcMessage(diseqcMsgMap[msgName]));
284 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000285 if (!frontendConf.isSoftwareFe) {
286 recordSingleFilterTest(filterConf, frontendConf, dvrConf, Dataflow_Context::LNBRECORD);
287 }
Hongguang600a6ae2021-07-08 18:51:51 -0700288 ASSERT_TRUE(mLnbTests.closeLnb());
Frankie Lizcano87421812022-07-28 17:13:01 +0000289 mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700290}
291
292void TunerRecordAidlTest::attachSingleFilterToRecordDvrTest(FilterConfig filterConf,
293 FrontendConfig frontendConf,
294 DvrConfig dvrConf) {
295 int32_t demuxId;
296 std::shared_ptr<IDemux> demux;
297 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
298 mDvrTests.setDemux(demux);
299
300 DvrConfig dvrSourceConfig;
301 if (record.hasFrontendConnection) {
302 int32_t feId;
303 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
304 ASSERT_TRUE(feId != INVALID_ID);
305 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
306 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
307 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
308 } else {
309 dvrSourceConfig = dvrMap[record.dvrSourceId];
310 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
311 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
312 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
313 }
314
315 int64_t filterId;
316 std::shared_ptr<IFilter> filter;
317 mFilterTests.setDemux(demux);
318
319 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
320 ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
321 ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
322
323 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
324 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
325 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
326 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
327 filter = mFilterTests.getFilterById(filterId);
328 ASSERT_TRUE(filter != nullptr);
329 ASSERT_TRUE(mDvrTests.attachFilterToDvr(filter));
330 ASSERT_TRUE(mDvrTests.startDvrRecord());
331 ASSERT_TRUE(mFilterTests.startFilter(filterId));
332 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
333 ASSERT_TRUE(mDvrTests.stopDvrRecord());
334 ASSERT_TRUE(mDvrTests.detachFilterToDvr(filter));
335 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
336 mDvrTests.closeDvrRecord();
337 ASSERT_TRUE(mDemuxTests.closeDemux());
338
339 if (record.hasFrontendConnection) {
340 ASSERT_TRUE(mFrontendTests.closeFrontend());
341 }
342}
343
344void TunerRecordAidlTest::recordSingleFilterTest(FilterConfig filterConf,
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000345 FrontendConfig frontendConf, DvrConfig dvrConf,
346 Dataflow_Context context) {
Hongguang600a6ae2021-07-08 18:51:51 -0700347 int32_t demuxId;
348 std::shared_ptr<IDemux> demux;
349 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
350 mDvrTests.setDemux(demux);
351
352 DvrConfig dvrSourceConfig;
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000353 if (context == Dataflow_Context::RECORD) {
354 if (record.hasFrontendConnection) {
355 int32_t feId;
356 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
357 ASSERT_TRUE(feId != INVALID_ID);
358 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
359 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
360 if (frontendConf.isSoftwareFe) {
361 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[record.dvrSoftwareFeId]);
362 }
363 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
364 mFrontendTests.setDvrTests(&mDvrTests);
365 } else {
366 dvrSourceConfig = dvrMap[record.dvrSourceId];
367 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
368 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
369 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
370 }
371 } else if (context == Dataflow_Context::LNBRECORD) {
372 // If function arrives here, frontend should not be software, so no need to configure a dvr
373 // source or dvr fe connection that might be used for recording without an Lnb
Hongguang600a6ae2021-07-08 18:51:51 -0700374 int32_t feId;
375 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
376 ASSERT_TRUE(feId != INVALID_ID);
377 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
378 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000379 if (mLnbId != INVALID_LNB_ID) {
380 ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
381 } else {
382 FAIL();
Hongguang600a6ae2021-07-08 18:51:51 -0700383 }
384 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
385 mFrontendTests.setDvrTests(&mDvrTests);
Hongguang600a6ae2021-07-08 18:51:51 -0700386 }
387
388 int64_t filterId;
389 std::shared_ptr<IFilter> filter;
390 mFilterTests.setDemux(demux);
391 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
392 ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
393 ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
394 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
395 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
396 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
397 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
398 filter = mFilterTests.getFilterById(filterId);
399 ASSERT_TRUE(filter != nullptr);
400 mDvrTests.startRecordOutputThread(dvrConf.settings.get<DvrSettings::Tag::record>());
401 ASSERT_TRUE(mDvrTests.attachFilterToDvr(filter));
402 ASSERT_TRUE(mDvrTests.startDvrRecord());
403 ASSERT_TRUE(mFilterTests.startFilter(filterId));
404
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000405 if (context == Dataflow_Context::RECORD) {
406 if (record.hasFrontendConnection) {
407 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
408 } else {
409 // Start DVR Source
410 mDvrTests.startPlaybackInputThread(
411 dvrSourceConfig.playbackInputFile,
412 dvrSourceConfig.settings.get<DvrSettings::Tag::playback>());
413 ASSERT_TRUE(mDvrTests.startDvrPlayback());
414 }
415 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700416 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700417 }
Hongguang600a6ae2021-07-08 18:51:51 -0700418 mDvrTests.testRecordOutput();
419 mDvrTests.stopRecordThread();
420
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000421 if (context == Dataflow_Context::RECORD) {
422 if (record.hasFrontendConnection) {
423 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
424 } else {
425 mDvrTests.stopPlaybackThread();
426 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
427 }
428 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700429 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700430 }
431
432 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
433 ASSERT_TRUE(mDvrTests.stopDvrRecord());
434 ASSERT_TRUE(mDvrTests.detachFilterToDvr(filter));
435 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
436 mDvrTests.closeDvrRecord();
437
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000438 if (context == Dataflow_Context::RECORD) {
439 if (record.hasFrontendConnection) {
440 ASSERT_TRUE(mFrontendTests.closeFrontend());
441 } else {
442 mDvrTests.closeDvrPlayback();
443 }
444 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700445 ASSERT_TRUE(mFrontendTests.closeFrontend());
Hongguang600a6ae2021-07-08 18:51:51 -0700446 }
447
448 ASSERT_TRUE(mDemuxTests.closeDemux());
449}
450
Ray Chin62ab6c92022-09-15 15:07:33 +0800451void TunerRecordAidlTest::setStatusCheckIntervalHintTest(int64_t statusCheckIntervalHint,
452 FrontendConfig frontendConf,
453 DvrConfig dvrConf) {
454 int32_t demuxId;
455 std::shared_ptr<IDemux> demux;
456 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
457 mDvrTests.setDemux(demux);
458
459 DvrConfig dvrSourceConfig;
460 if (record.hasFrontendConnection) {
461 int32_t feId;
462 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
463 ASSERT_TRUE(feId != INVALID_ID);
464 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
465 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
466 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
467 } else {
468 dvrSourceConfig = dvrMap[record.dvrSourceId];
469 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
470 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
471 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
472 }
473
474 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
475 ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
476 ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
477
478 ASSERT_TRUE(mDvrTests.setRecordStatusCheckIntervalHint(statusCheckIntervalHint));
479
480 ASSERT_TRUE(mDvrTests.startDvrRecord());
481 ASSERT_TRUE(mDvrTests.stopDvrRecord());
482 mDvrTests.closeDvrRecord();
483 ASSERT_TRUE(mDemuxTests.closeDemux());
484
485 if (record.hasFrontendConnection) {
486 ASSERT_TRUE(mFrontendTests.closeFrontend());
487 }
488}
489
Hongguang600a6ae2021-07-08 18:51:51 -0700490void TunerDescramblerAidlTest::scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
491 FrontendConfig frontendConf,
Frankie Lizcano82101d22022-07-28 00:12:35 +0000492 DescramblerConfig descConfig,
493 Dataflow_Context context) {
Hongguang600a6ae2021-07-08 18:51:51 -0700494 int32_t demuxId;
495 std::shared_ptr<IDemux> demux;
496 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
497
498 DvrConfig dvrSourceConfig;
Frankie Lizcano82101d22022-07-28 00:12:35 +0000499 if (context == Dataflow_Context::DESCRAMBLING) {
500 if (descrambling.hasFrontendConnection) {
501 int32_t feId;
502 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
503 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
504 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
505 if (frontendConf.isSoftwareFe) {
506 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[descrambling.dvrSoftwareFeId]);
507 }
508 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
509 mFrontendTests.setDemux(demux);
510 } else {
511 dvrSourceConfig = dvrMap[descrambling.dvrSourceId];
512 mDvrTests.setDemux(demux);
513 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
514 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
515 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
516 }
517 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700518 int32_t feId;
519 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
520 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
521 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
Frankie Lizcano82101d22022-07-28 00:12:35 +0000522 if (mLnbId != INVALID_LNB_ID) {
523 ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
524 } else {
525 // If, for some reason, the test got here without failing. We fail it here.
526 ALOGD("mLnbId is null. Something went wrong. Exiting ScrambledBroadcastWithLnbId.");
527 FAIL();
Hongguang600a6ae2021-07-08 18:51:51 -0700528 }
529 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
530 mFrontendTests.setDemux(demux);
Hongguang600a6ae2021-07-08 18:51:51 -0700531 }
532
533 set<int64_t> filterIds;
534 int64_t filterId;
535 set<struct FilterConfig>::iterator config;
536 set<int64_t>::iterator id;
537 mFilterTests.setDemux(demux);
538 for (config = mediaFilterConfs.begin(); config != mediaFilterConfs.end(); config++) {
539 ASSERT_TRUE(mFilterTests.openFilterInDemux((*config).type, (*config).bufferSize));
540 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
541 ASSERT_TRUE(mFilterTests.configFilter((*config).settings, filterId));
542 filterIds.insert(filterId);
543 }
544 ASSERT_TRUE(mDescramblerTests.openDescrambler(demuxId));
545 vector<uint8_t> token;
546 ASSERT_TRUE(mDescramblerTests.getKeyToken(descConfig.casSystemId, descConfig.provisionStr,
547 descConfig.hidlPvtData, token));
548 mDescramblerTests.setKeyToken(token);
549 vector<DemuxPid> pids;
550 DemuxPid pid;
551 for (config = mediaFilterConfs.begin(); config != mediaFilterConfs.end(); config++) {
552 ASSERT_TRUE(mDescramblerTests.getDemuxPidFromFilterSettings((*config).type,
553 (*config).settings, pid));
554 pids.push_back(pid);
555 ASSERT_TRUE(mDescramblerTests.addPid(pid, nullptr));
556 }
557 for (id = filterIds.begin(); id != filterIds.end(); id++) {
558 ASSERT_TRUE(mFilterTests.startFilter(*id));
559 }
560
Frankie Lizcano82101d22022-07-28 00:12:35 +0000561 if (context == Dataflow_Context::DESCRAMBLING) {
562 if (descrambling.hasFrontendConnection) {
563 // tune test
564 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
565 } else {
566 // Start DVR Source
567 mDvrTests.startPlaybackInputThread(
568 dvrSourceConfig.playbackInputFile,
569 dvrSourceConfig.settings.get<DvrSettings::Tag::playback>());
570 ASSERT_TRUE(mDvrTests.startDvrPlayback());
571 }
572 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700573 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700574 }
575
576 ASSERT_TRUE(filterDataOutputTest());
577
Frankie Lizcano82101d22022-07-28 00:12:35 +0000578 if (context == Dataflow_Context::DESCRAMBLING) {
579 if (descrambling.hasFrontendConnection) {
580 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
581 } else {
582 mDvrTests.stopPlaybackThread();
583 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
584 }
585 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700586 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700587 }
588
589 for (id = filterIds.begin(); id != filterIds.end(); id++) {
590 ASSERT_TRUE(mFilterTests.stopFilter(*id));
591 }
592 for (auto pid : pids) {
593 ASSERT_TRUE(mDescramblerTests.removePid(pid, nullptr));
594 }
595 ASSERT_TRUE(mDescramblerTests.closeDescrambler());
596 for (id = filterIds.begin(); id != filterIds.end(); id++) {
597 ASSERT_TRUE(mFilterTests.closeFilter(*id));
598 }
599
Frankie Lizcano82101d22022-07-28 00:12:35 +0000600 if (context == Dataflow_Context::DESCRAMBLING) {
601 if (descrambling.hasFrontendConnection) {
602 ASSERT_TRUE(mFrontendTests.closeFrontend());
603 } else {
604 mDvrTests.closeDvrPlayback();
605 }
606 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700607 ASSERT_TRUE(mFrontendTests.closeFrontend());
Hongguang600a6ae2021-07-08 18:51:51 -0700608 }
609
610 ASSERT_TRUE(mDemuxTests.closeDemux());
611}
612
Frankie Lizcano82101d22022-07-28 00:12:35 +0000613void TunerDescramblerAidlTest::scrambledBroadcastTestWithLnb(
614 set<struct FilterConfig>& mediaFilterConfs, FrontendConfig& frontendConf,
615 DescramblerConfig& descConfig, LnbConfig& lnbConfig) {
616 // We can test the Lnb individually and make sure it functions properly. If the frontend is
617 // software, we cannot test the whole dataflow. If the frontend is hardware, we can
618 if (lnbConfig.name.compare(emptyHardwareId) == 0) {
619 vector<int32_t> ids;
620 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
621 ASSERT_TRUE(ids.size() > 0);
622 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
623 mLnbId = ids[0];
624 } else {
625 ASSERT_TRUE(mLnbTests.openLnbByName(lnbConfig.name, mLnbId));
626 }
627 // Once Lnb is opened, test some of its basic functionality
628 ASSERT_TRUE(mLnbTests.setLnbCallback());
629 ASSERT_TRUE(mLnbTests.setVoltage(lnbConfig.voltage));
630 ASSERT_TRUE(mLnbTests.setTone(lnbConfig.tone));
631 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConfig.position));
632 if (!frontendConf.isSoftwareFe) {
633 ALOGD("Frontend is not software, testing entire dataflow.");
634 scrambledBroadcastTest(mediaFilterConfs, frontendConf, descConfig,
635 Dataflow_Context::LNBDESCRAMBLING);
636 } else {
637 ALOGD("Frontend is software, did not test the entire dataflow, but tested the Lnb "
638 "individually.");
639 }
640 ASSERT_TRUE(mLnbTests.closeLnb());
641 mLnbId = INVALID_LNB_ID;
642}
643
Hongguang600a6ae2021-07-08 18:51:51 -0700644TEST_P(TunerLnbAidlTest, SendDiseqcMessageToLnb) {
645 description("Open and configure an Lnb with specific settings then send a diseqc msg to it.");
646 if (!lnbLive.support) {
647 return;
648 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000649 vector<LnbLiveHardwareConnections> lnbLive_configs = generateLnbLiveConfigurations();
650 if (lnbLive_configs.empty()) {
651 ALOGD("No frontends that support satellites.");
652 return;
Hongguang600a6ae2021-07-08 18:51:51 -0700653 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000654 for (auto& combination : lnbLive_configs) {
655 lnbLive = combination;
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000656 if (lnbMap[lnbLive.lnbId].name.compare(emptyHardwareId) == 0) {
657 vector<int32_t> ids;
658 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
659 ASSERT_TRUE(ids.size() > 0);
660 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
661 } else {
662 int32_t id;
663 ASSERT_TRUE(mLnbTests.openLnbByName(lnbMap[lnbLive.lnbId].name, id));
664 }
665 ASSERT_TRUE(mLnbTests.setLnbCallback());
666 ASSERT_TRUE(mLnbTests.setVoltage(lnbMap[lnbLive.lnbId].voltage));
667 ASSERT_TRUE(mLnbTests.setTone(lnbMap[lnbLive.lnbId].tone));
668 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbMap[lnbLive.lnbId].position));
669 for (auto msgName : lnbLive.diseqcMsgs) {
670 ASSERT_TRUE(mLnbTests.sendDiseqcMessage(diseqcMsgMap[msgName]));
671 }
672 ASSERT_TRUE(mLnbTests.closeLnb());
Hongguang600a6ae2021-07-08 18:51:51 -0700673 }
Hongguang600a6ae2021-07-08 18:51:51 -0700674}
675
676TEST_P(TunerDemuxAidlTest, openDemux) {
677 description("Open and close a Demux.");
678 if (!live.hasFrontendConnection) {
679 return;
680 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000681 auto live_configs = generateLiveConfigurations();
682 for (auto& configuration : live_configs) {
683 live = configuration;
684 int32_t feId;
685 int32_t demuxId;
686 std::shared_ptr<IDemux> demux;
687 mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId);
688 ASSERT_TRUE(feId != INVALID_ID);
689 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
690 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
691 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
692 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
693 ASSERT_TRUE(mDemuxTests.closeDemux());
694 ASSERT_TRUE(mFrontendTests.closeFrontend());
695 }
Hongguang600a6ae2021-07-08 18:51:51 -0700696}
697
698TEST_P(TunerDemuxAidlTest, getAvSyncTime) {
699 description("Get the A/V sync time from a PCR filter.");
700 if (!live.hasFrontendConnection) {
701 return;
702 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000703 auto live_configs = generateLiveConfigurations();
704 for (auto& configuration : live_configs) {
705 live = configuration;
706 if (live.pcrFilterId.compare(emptyHardwareId) == 0) {
707 continue;
708 }
709 int32_t feId;
710 int32_t demuxId;
711 std::shared_ptr<IDemux> demux;
712 int64_t mediaFilterId;
713 int64_t pcrFilterId;
714 int32_t avSyncHwId;
715 std::shared_ptr<IFilter> mediaFilter;
Hongguang600a6ae2021-07-08 18:51:51 -0700716
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000717 mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId);
718 ASSERT_TRUE(feId != INVALID_ID);
719 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
720 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
721 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
722 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
723 mFilterTests.setDemux(demux);
724 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterMap[live.videoFilterId].type,
725 filterMap[live.videoFilterId].bufferSize));
726 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(mediaFilterId));
727 ASSERT_TRUE(
728 mFilterTests.configFilter(filterMap[live.videoFilterId].settings, mediaFilterId));
729 mediaFilter = mFilterTests.getFilterById(mediaFilterId);
730 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterMap[live.pcrFilterId].type,
731 filterMap[live.pcrFilterId].bufferSize));
732 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(pcrFilterId));
733 ASSERT_TRUE(mFilterTests.configFilter(filterMap[live.pcrFilterId].settings, pcrFilterId));
734 ASSERT_TRUE(mDemuxTests.getAvSyncId(mediaFilter, avSyncHwId));
735 ASSERT_TRUE(pcrFilterId == avSyncHwId);
736 ASSERT_TRUE(mDemuxTests.getAvSyncTime(pcrFilterId));
737 ASSERT_TRUE(mFilterTests.closeFilter(pcrFilterId));
738 ASSERT_TRUE(mFilterTests.closeFilter(mediaFilterId));
739 ASSERT_TRUE(mDemuxTests.closeDemux());
740 ASSERT_TRUE(mFrontendTests.closeFrontend());
741 }
Hongguang600a6ae2021-07-08 18:51:51 -0700742}
743
744TEST_P(TunerFilterAidlTest, StartFilterInDemux) {
745 description("Open and start a filter in Demux.");
746 if (!live.hasFrontendConnection) {
747 return;
748 }
749 // TODO use parameterized tests
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000750 auto live_configs = generateLiveConfigurations();
751 for (auto& configuration : live_configs) {
752 live = configuration;
753 configSingleFilterInDemuxTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
754 }
Hongguang600a6ae2021-07-08 18:51:51 -0700755}
756
757TEST_P(TunerFilterAidlTest, ConfigIpFilterInDemuxWithCid) {
758 description("Open and configure an ip filter in Demux.");
759 // TODO use parameterized tests
760 if (!live.hasFrontendConnection) {
761 return;
762 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000763 auto live_configs = generateLiveConfigurations();
764 for (auto& configuration : live_configs) {
765 live = configuration;
766 if (live.ipFilterId.compare(emptyHardwareId) == 0) {
767 continue;
768 }
769 configSingleFilterInDemuxTest(filterMap[live.ipFilterId], frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -0700770 }
Hongguang600a6ae2021-07-08 18:51:51 -0700771}
772
773TEST_P(TunerFilterAidlTest, ReconfigFilterToReceiveStartId) {
774 description("Recofigure and restart a filter to test start id.");
775 if (!live.hasFrontendConnection) {
776 return;
777 }
778 // TODO use parameterized tests
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000779 auto live_configs = generateLiveConfigurations();
780 for (auto& configuration : live_configs) {
781 live = configuration;
782 reconfigSingleFilterInDemuxTest(filterMap[live.videoFilterId],
783 filterMap[live.videoFilterId],
784 frontendMap[live.frontendId]);
785 }
Hongguang600a6ae2021-07-08 18:51:51 -0700786}
787
788TEST_P(TunerFilterAidlTest, SetFilterLinkage) {
789 description("Pick up all the possible linkages from the demux caps and set them up.");
790 DemuxCapabilities caps;
791 int32_t demuxId;
792 std::shared_ptr<IDemux> demux;
793 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
794 ASSERT_TRUE(mDemuxTests.getDemuxCaps(caps));
795 mFilterTests.setDemux(demux);
796 for (int i = 0; i < caps.linkCaps.size(); i++) {
797 uint32_t bitMask = 1;
798 for (int j = 0; j < FILTER_MAIN_TYPE_BIT_COUNT; j++) {
799 if (caps.linkCaps[i] & (bitMask << j)) {
800 int64_t sourceFilterId;
801 int64_t sinkFilterId;
802 ASSERT_TRUE(mFilterTests.openFilterInDemux(getLinkageFilterType(i), FMQ_SIZE_16M));
803 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(sourceFilterId));
804 ASSERT_TRUE(mFilterTests.openFilterInDemux(getLinkageFilterType(j), FMQ_SIZE_16M));
805 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(sinkFilterId));
806 ASSERT_TRUE(mFilterTests.setFilterDataSource(sourceFilterId, sinkFilterId));
807 ASSERT_TRUE(mFilterTests.setFilterDataSourceToDemux(sinkFilterId));
808 ASSERT_TRUE(mFilterTests.closeFilter(sinkFilterId));
809 ASSERT_TRUE(mFilterTests.closeFilter(sourceFilterId));
810 }
811 }
812 }
813 ASSERT_TRUE(mDemuxTests.closeDemux());
814}
815
816TEST_P(TunerFilterAidlTest, testTimeFilter) {
817 description("Open a timer filter in Demux and set time stamp.");
818 if (!timeFilter.support) {
819 return;
820 }
821 // TODO use parameterized tests
Frankie Lizcano0c069532022-07-14 20:20:46 +0000822 auto timeFilter_configs = generateTimeFilterConfigurations();
823 for (auto& configuration : timeFilter_configs) {
824 timeFilter = configuration;
825 testTimeFilter(timeFilterMap[timeFilter.timeFilterId]);
826 }
Hongguang600a6ae2021-07-08 18:51:51 -0700827}
828
Gareth Fenn9a808452022-03-31 08:40:00 +0100829static bool isEventProducingFilter(const FilterConfig& filterConfig) {
830 switch (filterConfig.type.mainType) {
831 case DemuxFilterMainType::TS: {
832 auto tsFilterType =
833 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tsFilterType>();
834 return (tsFilterType == DemuxTsFilterType::SECTION ||
835 tsFilterType == DemuxTsFilterType::PES ||
836 tsFilterType == DemuxTsFilterType::AUDIO ||
837 tsFilterType == DemuxTsFilterType::VIDEO ||
838 tsFilterType == DemuxTsFilterType::RECORD ||
839 tsFilterType == DemuxTsFilterType::TEMI);
840 }
841 case DemuxFilterMainType::MMTP: {
842 auto mmtpFilterType =
843 filterConfig.type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>();
844 return (mmtpFilterType == DemuxMmtpFilterType::SECTION ||
845 mmtpFilterType == DemuxMmtpFilterType::PES ||
846 mmtpFilterType == DemuxMmtpFilterType::AUDIO ||
847 mmtpFilterType == DemuxMmtpFilterType::VIDEO ||
848 mmtpFilterType == DemuxMmtpFilterType::RECORD ||
849 mmtpFilterType == DemuxMmtpFilterType::DOWNLOAD);
850 }
851 case DemuxFilterMainType::IP: {
852 auto ipFilterType =
853 filterConfig.type.subType.get<DemuxFilterSubType::Tag::ipFilterType>();
854 return (ipFilterType == DemuxIpFilterType::SECTION);
855 }
856 case DemuxFilterMainType::TLV: {
857 auto tlvFilterType =
858 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tlvFilterType>();
859 return (tlvFilterType == DemuxTlvFilterType::SECTION);
860 }
861 case DemuxFilterMainType::ALP: {
862 auto alpFilterType =
863 filterConfig.type.subType.get<DemuxFilterSubType::Tag::alpFilterType>();
864 return (alpFilterType == DemuxAlpFilterType::SECTION);
865 }
866 default:
867 return false;
868 }
869}
870
Patrick Rohr1586d212021-11-23 00:40:56 +0100871static bool isMediaFilter(const FilterConfig& filterConfig) {
872 switch (filterConfig.type.mainType) {
873 case DemuxFilterMainType::TS: {
874 // TS Audio and Video filters are media filters
875 auto tsFilterType =
876 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tsFilterType>();
877 return (tsFilterType == DemuxTsFilterType::AUDIO ||
878 tsFilterType == DemuxTsFilterType::VIDEO);
879 }
880 case DemuxFilterMainType::MMTP: {
881 // MMTP Audio and Video filters are media filters
882 auto mmtpFilterType =
883 filterConfig.type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>();
884 return (mmtpFilterType == DemuxMmtpFilterType::AUDIO ||
885 mmtpFilterType == DemuxMmtpFilterType::VIDEO);
886 }
887 default:
888 return false;
889 }
890}
Patrick Rohr149b0872021-11-20 00:39:37 +0100891
Patrick Rohr1586d212021-11-23 00:40:56 +0100892static int getDemuxFilterEventDataLength(const DemuxFilterEvent& event) {
893 switch (event.getTag()) {
894 case DemuxFilterEvent::Tag::section:
895 return event.get<DemuxFilterEvent::Tag::section>().dataLength;
896 case DemuxFilterEvent::Tag::media:
897 return event.get<DemuxFilterEvent::Tag::media>().dataLength;
898 case DemuxFilterEvent::Tag::pes:
899 return event.get<DemuxFilterEvent::Tag::pes>().dataLength;
900 case DemuxFilterEvent::Tag::download:
901 return event.get<DemuxFilterEvent::Tag::download>().dataLength;
902 case DemuxFilterEvent::Tag::ipPayload:
903 return event.get<DemuxFilterEvent::Tag::ipPayload>().dataLength;
904
905 case DemuxFilterEvent::Tag::tsRecord:
906 case DemuxFilterEvent::Tag::mmtpRecord:
907 case DemuxFilterEvent::Tag::temi:
908 case DemuxFilterEvent::Tag::monitorEvent:
909 case DemuxFilterEvent::Tag::startId:
910 return 0;
911 }
912}
913
914// TODO: move boilerplate into text fixture
915void TunerFilterAidlTest::testDelayHint(const FilterConfig& filterConf) {
Gareth Fenn9a808452022-03-31 08:40:00 +0100916 if (!filterConf.timeDelayInMs && !filterConf.dataDelayInBytes) {
917 return;
918 }
919 if (!isEventProducingFilter(filterConf)) {
920 return;
921 }
Patrick Rohr149b0872021-11-20 00:39:37 +0100922 int32_t feId;
923 int32_t demuxId;
924 std::shared_ptr<IDemux> demux;
925 int64_t filterId;
926
927 mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId);
928 ASSERT_TRUE(feId != INVALID_ID);
929 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
930 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
931 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
932 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
933 mFilterTests.setDemux(demux);
934
Patrick Rohr149b0872021-11-20 00:39:37 +0100935 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
936 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
Patrick Rohr149b0872021-11-20 00:39:37 +0100937
Patrick Rohr1586d212021-11-23 00:40:56 +0100938 bool mediaFilter = isMediaFilter(filterConf);
Patrick Rohr149b0872021-11-20 00:39:37 +0100939 auto filter = mFilterTests.getFilterById(filterId);
940
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +0100941 // startTime needs to be set before calling setDelayHint.
942 auto startTime = std::chrono::steady_clock::now();
943
Gareth Fenn9a808452022-03-31 08:40:00 +0100944 int timeDelayInMs = filterConf.timeDelayInMs;
945 if (timeDelayInMs > 0) {
Patrick Rohr1586d212021-11-23 00:40:56 +0100946 FilterDelayHint delayHint;
947 delayHint.hintType = FilterDelayHintType::TIME_DELAY_IN_MS;
Gareth Fenn9a808452022-03-31 08:40:00 +0100948 delayHint.hintValue = timeDelayInMs;
Patrick Rohr149b0872021-11-20 00:39:37 +0100949
Patrick Rohr1586d212021-11-23 00:40:56 +0100950 // setDelayHint should fail for media filters.
951 ASSERT_EQ(filter->setDelayHint(delayHint).isOk(), !mediaFilter);
952 }
Patrick Rohr149b0872021-11-20 00:39:37 +0100953
Patrick Rohr1586d212021-11-23 00:40:56 +0100954 int dataDelayInBytes = filterConf.dataDelayInBytes;
955 if (dataDelayInBytes > 0) {
956 FilterDelayHint delayHint;
957 delayHint.hintType = FilterDelayHintType::DATA_SIZE_DELAY_IN_BYTES;
958 delayHint.hintValue = dataDelayInBytes;
Patrick Rohr149b0872021-11-20 00:39:37 +0100959
Patrick Rohr1586d212021-11-23 00:40:56 +0100960 // setDelayHint should fail for media filters.
961 ASSERT_EQ(filter->setDelayHint(delayHint).isOk(), !mediaFilter);
962 }
Patrick Rohr149b0872021-11-20 00:39:37 +0100963
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +0100964 // start and stop filter (and wait for first callback) in order to
965 // circumvent callback scheduler race conditions after adjusting filter
966 // delays.
967 auto cb = mFilterTests.getFilterCallbacks().at(filterId);
968 auto future =
969 cb->verifyFilterCallback([](const std::vector<DemuxFilterEvent>&) { return true; });
Gareth Fenn9a808452022-03-31 08:40:00 +0100970
971 // The configure stage can also produce events, so we should set the delay
972 // hint beforehand.
973 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
Patrick Rohr1586d212021-11-23 00:40:56 +0100974 mFilterTests.startFilter(filterId);
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +0100975
976 auto timeout = std::chrono::seconds(30);
977 ASSERT_EQ(future.wait_for(timeout), std::future_status::ready);
978
Patrick Rohr1586d212021-11-23 00:40:56 +0100979 mFilterTests.stopFilter(filterId);
Patrick Rohr149b0872021-11-20 00:39:37 +0100980
Patrick Rohr1586d212021-11-23 00:40:56 +0100981 if (!mediaFilter) {
Patrick Rohr1586d212021-11-23 00:40:56 +0100982 int callbackSize = 0;
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +0100983 future = cb->verifyFilterCallback(
Patrick Rohr1586d212021-11-23 00:40:56 +0100984 [&callbackSize](const std::vector<DemuxFilterEvent>& events) {
985 for (const auto& event : events) {
986 callbackSize += getDemuxFilterEventDataLength(event);
987 }
988 return true;
989 });
990
Patrick Rohr1586d212021-11-23 00:40:56 +0100991 ASSERT_TRUE(mFilterTests.startFilter(filterId));
992
993 // block and wait for callback to be received.
Patrick Rohr1586d212021-11-23 00:40:56 +0100994 ASSERT_EQ(future.wait_for(timeout), std::future_status::ready);
Patrick Rohr1586d212021-11-23 00:40:56 +0100995
Gareth Fenn9a808452022-03-31 08:40:00 +0100996 auto duration = std::chrono::steady_clock::now() - startTime;
997 bool delayHintTest = duration >= std::chrono::milliseconds(timeDelayInMs);
Patrick Rohr1586d212021-11-23 00:40:56 +0100998 bool dataSizeTest = callbackSize >= dataDelayInBytes;
999
Gareth Fenn9a808452022-03-31 08:40:00 +01001000 if (timeDelayInMs > 0 && dataDelayInBytes > 0) {
Patrick Rohr1586d212021-11-23 00:40:56 +01001001 ASSERT_TRUE(delayHintTest || dataSizeTest);
1002 } else {
1003 // if only one of time delay / data delay is configured, one of them
1004 // holds true by default, so we want both assertions to be true.
1005 ASSERT_TRUE(delayHintTest && dataSizeTest);
1006 }
1007
1008 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
1009 }
1010
Patrick Rohr149b0872021-11-20 00:39:37 +01001011 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
1012 ASSERT_TRUE(mDemuxTests.closeDemux());
1013 ASSERT_TRUE(mFrontendTests.closeFrontend());
1014}
1015
Patrick Rohr1586d212021-11-23 00:40:56 +01001016TEST_P(TunerFilterAidlTest, FilterDelayHintTest) {
1017 description("Test filter time delay hint.");
Gareth Fenn9a808452022-03-31 08:40:00 +01001018 if (!live.hasFrontendConnection) {
1019 return;
1020 }
Patrick Rohr1586d212021-11-23 00:40:56 +01001021 for (const auto& obj : filterMap) {
1022 testDelayHint(obj.second);
1023 }
1024}
1025
Hongguang600a6ae2021-07-08 18:51:51 -07001026TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsSectionFilterTest) {
1027 description("Feed ts data from playback and configure Ts section filter to get output");
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001028 if (!playback.support) {
Hongguang600a6ae2021-07-08 18:51:51 -07001029 return;
1030 }
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001031 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1032 for (auto& configuration : playback_configs) {
1033 if (configuration.sectionFilterId.compare(emptyHardwareId) != 0) {
1034 playback = configuration;
1035 playbackSingleFilterTest(filterMap[playback.sectionFilterId], dvrMap[playback.dvrId]);
1036 }
1037 }
Hongguang600a6ae2021-07-08 18:51:51 -07001038}
1039
1040TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsAudioFilterTest) {
1041 description("Feed ts data from playback and configure Ts audio filter to get output");
1042 if (!playback.support) {
1043 return;
1044 }
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001045 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1046 for (auto& configuration : playback_configs) {
1047 playback = configuration;
1048 playbackSingleFilterTest(filterMap[playback.audioFilterId], dvrMap[playback.dvrId]);
1049 }
Hongguang600a6ae2021-07-08 18:51:51 -07001050}
1051
1052TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsVideoFilterTest) {
1053 description("Feed ts data from playback and configure Ts video filter to get output");
1054 if (!playback.support) {
1055 return;
1056 }
Frankie Lizcanoa53f5542022-07-07 17:32:06 +00001057 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1058 for (auto& configuration : playback_configs) {
1059 playback = configuration;
1060 playbackSingleFilterTest(filterMap[playback.videoFilterId], dvrMap[playback.dvrId]);
1061 }
Hongguang600a6ae2021-07-08 18:51:51 -07001062}
1063
Ray Chin62ab6c92022-09-15 15:07:33 +08001064TEST_P(TunerPlaybackAidlTest, SetStatusCheckIntervalHintToPlaybackTest) {
1065 description("Set status check interval hint to playback test.");
1066 if (!playback.support) {
1067 return;
1068 }
1069 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
1070 for (auto& configuration : playback_configs) {
1071 playback = configuration;
1072 setStatusCheckIntervalHintTest(STATUS_CHECK_INTERVAL_MS, dvrMap[playback.dvrId]);
1073 }
1074}
1075
Hongguang600a6ae2021-07-08 18:51:51 -07001076TEST_P(TunerRecordAidlTest, RecordDataFlowWithTsRecordFilterTest) {
1077 description("Feed ts data from frontend to recording and test with ts record filter");
1078 if (!record.support) {
1079 return;
1080 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +00001081 auto record_configs = generateRecordConfigurations();
1082 for (auto& configuration : record_configs) {
1083 record = configuration;
1084 recordSingleFilterTest(filterMap[record.recordFilterId], frontendMap[record.frontendId],
1085 dvrMap[record.dvrRecordId], Dataflow_Context::RECORD);
1086 }
Hongguang600a6ae2021-07-08 18:51:51 -07001087}
1088
1089TEST_P(TunerRecordAidlTest, AttachFiltersToRecordTest) {
1090 description("Attach a single filter to the record dvr test.");
1091 // TODO use parameterized tests
1092 if (!record.support) {
1093 return;
1094 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +00001095 auto record_configs = generateRecordConfigurations();
1096 for (auto& configuration : record_configs) {
1097 record = configuration;
1098 attachSingleFilterToRecordDvrTest(filterMap[record.recordFilterId],
1099 frontendMap[record.frontendId],
1100 dvrMap[record.dvrRecordId]);
1101 }
Hongguang600a6ae2021-07-08 18:51:51 -07001102}
1103
1104TEST_P(TunerRecordAidlTest, LnbRecordDataFlowWithTsRecordFilterTest) {
1105 description("Feed ts data from Fe with Lnb to recording and test with ts record filter");
1106 if (!lnbRecord.support) {
1107 return;
1108 }
Frankie Lizcanoecba02a2022-07-12 17:56:54 +00001109 vector<LnbRecordHardwareConnections> lnbRecord_configs = generateLnbRecordConfigurations();
1110 if (lnbRecord_configs.empty()) {
1111 ALOGD("No frontends that support satellites.");
1112 return;
1113 }
1114 for (auto& configuration : lnbRecord_configs) {
1115 lnbRecord = configuration;
1116 recordSingleFilterTestWithLnb(filterMap[lnbRecord.recordFilterId],
1117 frontendMap[lnbRecord.frontendId],
1118 dvrMap[lnbRecord.dvrRecordId], lnbMap[lnbRecord.lnbId]);
1119 }
Hongguang600a6ae2021-07-08 18:51:51 -07001120}
1121
Ray Chin62ab6c92022-09-15 15:07:33 +08001122TEST_P(TunerRecordAidlTest, SetStatusCheckIntervalHintToRecordTest) {
1123 description("Set status check interval hint to record test.");
1124 if (!record.support) {
1125 return;
1126 }
1127 auto record_configs = generateRecordConfigurations();
1128 for (auto& configuration : record_configs) {
1129 record = configuration;
1130 setStatusCheckIntervalHintTest(STATUS_CHECK_INTERVAL_MS, frontendMap[record.frontendId],
1131 dvrMap[record.dvrRecordId]);
1132 }
1133}
1134
Hongguang600a6ae2021-07-08 18:51:51 -07001135TEST_P(TunerFrontendAidlTest, TuneFrontend) {
1136 description("Tune one Frontend with specific setting and check Lock event");
1137 if (!live.hasFrontendConnection) {
1138 return;
1139 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001140 auto live_configs = generateLiveConfigurations();
1141 for (auto& configuration : live_configs) {
1142 live = configuration;
1143 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
1144 }
Hongguang600a6ae2021-07-08 18:51:51 -07001145}
1146
1147TEST_P(TunerFrontendAidlTest, AutoScanFrontend) {
1148 description("Run an auto frontend scan with specific setting and check lock scanMessage");
1149 if (!scan.hasFrontendConnection) {
1150 return;
1151 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001152 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1153 for (auto& configuration : scan_configs) {
1154 scan = configuration;
1155 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_AUTO);
1156 }
Hongguang600a6ae2021-07-08 18:51:51 -07001157}
1158
1159TEST_P(TunerFrontendAidlTest, BlindScanFrontend) {
1160 description("Run an blind frontend scan with specific setting and check lock scanMessage");
1161 if (!scan.hasFrontendConnection) {
1162 return;
1163 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001164 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1165 for (auto& configuration : scan_configs) {
1166 scan = configuration;
1167 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_BLIND);
1168 }
Hongguang600a6ae2021-07-08 18:51:51 -07001169}
1170
1171TEST_P(TunerFrontendAidlTest, TuneFrontendWithFrontendSettings) {
1172 description("Tune one Frontend with setting and check Lock event");
1173 if (!live.hasFrontendConnection) {
1174 return;
1175 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001176 auto live_configs = generateLiveConfigurations();
1177 for (auto& configuration : live_configs) {
1178 live = configuration;
1179 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
1180 }
Hongguang600a6ae2021-07-08 18:51:51 -07001181}
1182
1183TEST_P(TunerFrontendAidlTest, BlindScanFrontendWithEndFrequency) {
1184 description("Run an blind frontend scan with setting and check lock scanMessage");
1185 if (!scan.hasFrontendConnection) {
1186 return;
1187 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001188 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1189 for (auto& configuration : scan_configs) {
1190 scan = configuration;
1191 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_BLIND);
1192 }
Hongguang600a6ae2021-07-08 18:51:51 -07001193}
1194
1195TEST_P(TunerFrontendAidlTest, LinkToCiCam) {
1196 description("Test Frontend link to CiCam");
1197 if (!live.hasFrontendConnection) {
1198 return;
1199 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001200 auto live_configs = generateLiveConfigurations();
1201 for (auto& configuration : live_configs) {
1202 live = configuration;
1203 if (!frontendMap[live.frontendId].canConnectToCiCam) {
1204 continue;
1205 }
1206 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -07001207 }
Hongguang600a6ae2021-07-08 18:51:51 -07001208}
1209
Hongguangfcedda02021-12-13 17:08:02 -08001210TEST_P(TunerFrontendAidlTest, getHardwareInfo) {
1211 description("Test Frontend get hardware info");
1212 if (!live.hasFrontendConnection) {
1213 return;
1214 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001215 auto live_configs = generateLiveConfigurations();
1216 for (auto& configuration : live_configs) {
1217 live = configuration;
1218 mFrontendTests.debugInfoTest(frontendMap[live.frontendId]);
1219 }
Hongguangfcedda02021-12-13 17:08:02 -08001220}
1221
Hongguang5766ddf2021-12-23 11:40:37 -08001222TEST_P(TunerFrontendAidlTest, maxNumberOfFrontends) {
1223 description("Test Max Frontend number");
1224 if (!live.hasFrontendConnection) {
1225 return;
1226 }
1227 mFrontendTests.maxNumberOfFrontendsTest();
1228}
1229
Hongguang881190f2022-01-14 13:23:37 -08001230TEST_P(TunerFrontendAidlTest, statusReadinessTest) {
1231 description("Test Max Frontend status readiness");
1232 if (!live.hasFrontendConnection) {
1233 return;
1234 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001235 auto live_configs = generateLiveConfigurations();
1236 for (auto& configuration : live_configs) {
1237 live = configuration;
1238 mFrontendTests.statusReadinessTest(frontendMap[live.frontendId]);
1239 }
Hongguang881190f2022-01-14 13:23:37 -08001240}
1241
Hongguang600a6ae2021-07-08 18:51:51 -07001242TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowVideoFilterTest) {
1243 description("Test Video Filter functionality in Broadcast use case.");
1244 if (!live.hasFrontendConnection) {
1245 return;
1246 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001247 auto live_configs = generateLiveConfigurations();
1248 for (auto& configuration : live_configs) {
1249 live = configuration;
1250 broadcastSingleFilterTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
1251 }
Hongguang600a6ae2021-07-08 18:51:51 -07001252}
1253
1254TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowAudioFilterTest) {
1255 description("Test Audio Filter functionality in Broadcast use case.");
1256 if (!live.hasFrontendConnection) {
1257 return;
1258 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001259 auto live_configs = generateLiveConfigurations();
1260 for (auto& configuration : live_configs) {
1261 live = configuration;
1262 broadcastSingleFilterTest(filterMap[live.audioFilterId], frontendMap[live.frontendId]);
1263 }
Hongguang600a6ae2021-07-08 18:51:51 -07001264}
1265
1266TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowSectionFilterTest) {
1267 description("Test Section Filter functionality in Broadcast use case.");
1268 if (!live.hasFrontendConnection) {
1269 return;
1270 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001271 auto live_configs = generateLiveConfigurations();
1272 for (auto& configuration : live_configs) {
1273 live = configuration;
1274 if (live.sectionFilterId.compare(emptyHardwareId) == 0) {
1275 continue;
1276 }
1277 broadcastSingleFilterTest(filterMap[live.sectionFilterId], frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -07001278 }
Hongguang600a6ae2021-07-08 18:51:51 -07001279}
1280
1281TEST_P(TunerBroadcastAidlTest, IonBufferTest) {
1282 description("Test the av filter data bufferring.");
1283 if (!live.hasFrontendConnection) {
1284 return;
1285 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001286 auto live_configs = generateLiveConfigurations();
1287 for (auto& configuration : live_configs) {
1288 live = configuration;
1289 broadcastSingleFilterTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
1290 }
Hongguang600a6ae2021-07-08 18:51:51 -07001291}
1292
1293TEST_P(TunerBroadcastAidlTest, LnbBroadcastDataFlowVideoFilterTest) {
1294 description("Test Video Filter functionality in Broadcast with Lnb use case.");
1295 if (!lnbLive.support) {
1296 return;
1297 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +00001298 vector<LnbLiveHardwareConnections> lnbLive_configs = generateLnbLiveConfigurations();
1299 if (lnbLive_configs.empty()) {
1300 ALOGD("No frontends that support satellites.");
1301 return;
1302 }
1303 for (auto& combination : lnbLive_configs) {
1304 lnbLive = combination;
1305 broadcastSingleFilterTestWithLnb(filterMap[lnbLive.videoFilterId],
1306 frontendMap[lnbLive.frontendId], lnbMap[lnbLive.lnbId]);
1307 }
Hongguang600a6ae2021-07-08 18:51:51 -07001308}
1309
1310TEST_P(TunerBroadcastAidlTest, MediaFilterWithSharedMemoryHandle) {
1311 description("Test the Media Filter with shared memory handle");
1312 if (!live.hasFrontendConnection) {
1313 return;
1314 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001315 auto live_configs = generateLiveConfigurations();
1316 for (auto& configuration : live_configs) {
1317 live = configuration;
1318 mediaFilterUsingSharedMemoryTest(filterMap[live.videoFilterId],
1319 frontendMap[live.frontendId]);
1320 }
Hongguang600a6ae2021-07-08 18:51:51 -07001321}
1322
1323TEST_P(TunerDescramblerAidlTest, CreateDescrambler) {
1324 description("Create Descrambler");
1325 if (!descrambling.support) {
1326 return;
1327 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001328 vector<DescramblingHardwareConnections> descrambling_configs =
1329 generateDescramblingConfigurations();
1330 if (descrambling_configs.empty()) {
1331 ALOGD("No valid descrambling combinations in the configuration file.");
1332 return;
Hongguang600a6ae2021-07-08 18:51:51 -07001333 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001334 for (auto& combination : descrambling_configs) {
1335 descrambling = combination;
1336 int32_t demuxId;
1337 std::shared_ptr<IDemux> demux;
1338 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
Hongguang600a6ae2021-07-08 18:51:51 -07001339
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001340 if (descrambling.hasFrontendConnection) {
1341 int32_t feId;
1342 mFrontendTests.getFrontendIdByType(frontendMap[descrambling.frontendId].type, feId);
1343 ASSERT_TRUE(feId != INVALID_ID);
1344 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
1345 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
1346 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
1347 }
Hongguang600a6ae2021-07-08 18:51:51 -07001348
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001349 ASSERT_TRUE(mDescramblerTests.openDescrambler(demuxId));
1350 ASSERT_TRUE(mDescramblerTests.closeDescrambler());
1351 ASSERT_TRUE(mDemuxTests.closeDemux());
1352
1353 if (descrambling.hasFrontendConnection) {
1354 ASSERT_TRUE(mFrontendTests.closeFrontend());
1355 }
Hongguang600a6ae2021-07-08 18:51:51 -07001356 }
1357}
1358
1359TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTest) {
1360 description("Test ts audio filter in scrambled broadcast use case");
1361 if (!descrambling.support) {
1362 return;
1363 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001364 vector<DescramblingHardwareConnections> descrambling_configs =
1365 generateDescramblingConfigurations();
1366 if (descrambling_configs.empty()) {
1367 ALOGD("No valid descrambling combinations in the configuration file.");
1368 return;
1369 }
1370 for (auto& combination : descrambling_configs) {
1371 descrambling = combination;
1372 set<FilterConfig> filterConfs;
1373 filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.audioFilterId]));
1374 filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.videoFilterId]));
1375 scrambledBroadcastTest(filterConfs, frontendMap[descrambling.frontendId],
Frankie Lizcano82101d22022-07-28 00:12:35 +00001376 descramblerMap[descrambling.descramblerId],
1377 Dataflow_Context::DESCRAMBLING);
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001378 }
Hongguang600a6ae2021-07-08 18:51:51 -07001379}
1380
Frankie Lizcano82101d22022-07-28 00:12:35 +00001381TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTestWithLnb) {
1382 description("Test media filters in scrambled broadcast use case with Lnb");
1383 if (!lnbDescrambling.support) {
1384 return;
1385 }
Frankie Lizcanobcf4ebb2022-08-01 18:06:00 +00001386 auto lnbDescrambling_configs = generateLnbDescramblingConfigurations();
1387 if (lnbDescrambling_configs.empty()) {
1388 ALOGD("No frontends that support satellites.");
1389 return;
1390 }
1391 for (auto& configuration : lnbDescrambling_configs) {
1392 lnbDescrambling = configuration;
1393 set<FilterConfig> filterConfs;
1394 filterConfs.insert(static_cast<FilterConfig>(filterMap[lnbDescrambling.audioFilterId]));
1395 filterConfs.insert(static_cast<FilterConfig>(filterMap[lnbDescrambling.videoFilterId]));
1396 scrambledBroadcastTestWithLnb(filterConfs, frontendMap[lnbDescrambling.frontendId],
1397 descramblerMap[lnbDescrambling.descramblerId],
1398 lnbMap[lnbDescrambling.lnbId]);
1399 }
Frankie Lizcano82101d22022-07-28 00:12:35 +00001400}
1401
Hongguang600a6ae2021-07-08 18:51:51 -07001402INSTANTIATE_TEST_SUITE_P(PerInstance, TunerBroadcastAidlTest,
1403 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1404 android::PrintInstanceNameToString);
1405
1406INSTANTIATE_TEST_SUITE_P(PerInstance, TunerFrontendAidlTest,
1407 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1408 android::PrintInstanceNameToString);
1409
1410INSTANTIATE_TEST_SUITE_P(PerInstance, TunerFilterAidlTest,
1411 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1412 android::PrintInstanceNameToString);
1413
1414INSTANTIATE_TEST_SUITE_P(PerInstance, TunerRecordAidlTest,
1415 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1416 android::PrintInstanceNameToString);
1417
1418INSTANTIATE_TEST_SUITE_P(PerInstance, TunerLnbAidlTest,
1419 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1420 android::PrintInstanceNameToString);
1421
1422INSTANTIATE_TEST_SUITE_P(PerInstance, TunerDemuxAidlTest,
1423 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1424 android::PrintInstanceNameToString);
1425
1426INSTANTIATE_TEST_SUITE_P(PerInstance, TunerPlaybackAidlTest,
1427 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1428 android::PrintInstanceNameToString);
1429
1430INSTANTIATE_TEST_SUITE_P(PerInstance, TunerDescramblerAidlTest,
1431 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1432 android::PrintInstanceNameToString);
1433
1434} // namespace
1435
1436// Start thread pool to receive callbacks from AIDL service.
1437int main(int argc, char** argv) {
1438 ::testing::InitGoogleTest(&argc, argv);
1439 ABinderProcess_setThreadPoolMaxThreadCount(1);
1440 ABinderProcess_startThreadPool();
1441 return RUN_ALL_TESTS();
1442}