blob: f78e508d6e7386b08ad147a6b7f8e7b95f5b48bc [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
244void TunerRecordAidlTest::recordSingleFilterTestWithLnb(FilterConfig filterConf,
245 FrontendConfig frontendConf,
246 DvrConfig dvrConf, LnbConfig lnbConf) {
247 if (lnbConf.name.compare(emptyHardwareId) == 0) {
248 vector<int32_t> ids;
249 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
250 ASSERT_TRUE(ids.size() > 0);
251 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
Frankie Lizcano87421812022-07-28 17:13:01 +0000252 mLnbId = ids[0];
Hongguang600a6ae2021-07-08 18:51:51 -0700253 } else {
Frankie Lizcano87421812022-07-28 17:13:01 +0000254 ASSERT_TRUE(mLnbTests.openLnbByName(lnbConf.name, mLnbId));
Hongguang600a6ae2021-07-08 18:51:51 -0700255 }
256 ASSERT_TRUE(mLnbTests.setLnbCallback());
257 ASSERT_TRUE(mLnbTests.setVoltage(lnbConf.voltage));
258 ASSERT_TRUE(mLnbTests.setTone(lnbConf.tone));
259 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConf.position));
260 for (auto msgName : lnbRecord.diseqcMsgs) {
261 ASSERT_TRUE(mLnbTests.sendDiseqcMessage(diseqcMsgMap[msgName]));
262 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000263 if (!frontendConf.isSoftwareFe) {
264 recordSingleFilterTest(filterConf, frontendConf, dvrConf, Dataflow_Context::LNBRECORD);
265 }
Hongguang600a6ae2021-07-08 18:51:51 -0700266 ASSERT_TRUE(mLnbTests.closeLnb());
Frankie Lizcano87421812022-07-28 17:13:01 +0000267 mLnbId = INVALID_LNB_ID;
Hongguang600a6ae2021-07-08 18:51:51 -0700268}
269
270void TunerRecordAidlTest::attachSingleFilterToRecordDvrTest(FilterConfig filterConf,
271 FrontendConfig frontendConf,
272 DvrConfig dvrConf) {
273 int32_t demuxId;
274 std::shared_ptr<IDemux> demux;
275 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
276 mDvrTests.setDemux(demux);
277
278 DvrConfig dvrSourceConfig;
279 if (record.hasFrontendConnection) {
280 int32_t feId;
281 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
282 ASSERT_TRUE(feId != INVALID_ID);
283 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
284 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
285 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
286 } else {
287 dvrSourceConfig = dvrMap[record.dvrSourceId];
288 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
289 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
290 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
291 }
292
293 int64_t filterId;
294 std::shared_ptr<IFilter> filter;
295 mFilterTests.setDemux(demux);
296
297 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
298 ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
299 ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
300
301 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
302 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
303 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
304 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
305 filter = mFilterTests.getFilterById(filterId);
306 ASSERT_TRUE(filter != nullptr);
307 ASSERT_TRUE(mDvrTests.attachFilterToDvr(filter));
308 ASSERT_TRUE(mDvrTests.startDvrRecord());
309 ASSERT_TRUE(mFilterTests.startFilter(filterId));
310 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
311 ASSERT_TRUE(mDvrTests.stopDvrRecord());
312 ASSERT_TRUE(mDvrTests.detachFilterToDvr(filter));
313 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
314 mDvrTests.closeDvrRecord();
315 ASSERT_TRUE(mDemuxTests.closeDemux());
316
317 if (record.hasFrontendConnection) {
318 ASSERT_TRUE(mFrontendTests.closeFrontend());
319 }
320}
321
322void TunerRecordAidlTest::recordSingleFilterTest(FilterConfig filterConf,
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000323 FrontendConfig frontendConf, DvrConfig dvrConf,
324 Dataflow_Context context) {
Hongguang600a6ae2021-07-08 18:51:51 -0700325 int32_t demuxId;
326 std::shared_ptr<IDemux> demux;
327 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
328 mDvrTests.setDemux(demux);
329
330 DvrConfig dvrSourceConfig;
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000331 if (context == Dataflow_Context::RECORD) {
332 if (record.hasFrontendConnection) {
333 int32_t feId;
334 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
335 ASSERT_TRUE(feId != INVALID_ID);
336 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
337 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
338 if (frontendConf.isSoftwareFe) {
339 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[record.dvrSoftwareFeId]);
340 }
341 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
342 mFrontendTests.setDvrTests(&mDvrTests);
343 } else {
344 dvrSourceConfig = dvrMap[record.dvrSourceId];
345 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
346 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
347 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
348 }
349 } else if (context == Dataflow_Context::LNBRECORD) {
350 // If function arrives here, frontend should not be software, so no need to configure a dvr
351 // source or dvr fe connection that might be used for recording without an Lnb
Hongguang600a6ae2021-07-08 18:51:51 -0700352 int32_t feId;
353 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
354 ASSERT_TRUE(feId != INVALID_ID);
355 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
356 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000357 if (mLnbId != INVALID_LNB_ID) {
358 ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
359 } else {
360 FAIL();
Hongguang600a6ae2021-07-08 18:51:51 -0700361 }
362 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
363 mFrontendTests.setDvrTests(&mDvrTests);
Hongguang600a6ae2021-07-08 18:51:51 -0700364 }
365
366 int64_t filterId;
367 std::shared_ptr<IFilter> filter;
368 mFilterTests.setDemux(demux);
369 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrConf.type, dvrConf.bufferSize));
370 ASSERT_TRUE(mDvrTests.configDvrRecord(dvrConf.settings));
371 ASSERT_TRUE(mDvrTests.getDvrRecordMQDescriptor());
372 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
373 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
374 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
375 ASSERT_TRUE(mFilterTests.getFilterMQDescriptor(filterId, filterConf.getMqDesc));
376 filter = mFilterTests.getFilterById(filterId);
377 ASSERT_TRUE(filter != nullptr);
378 mDvrTests.startRecordOutputThread(dvrConf.settings.get<DvrSettings::Tag::record>());
379 ASSERT_TRUE(mDvrTests.attachFilterToDvr(filter));
380 ASSERT_TRUE(mDvrTests.startDvrRecord());
381 ASSERT_TRUE(mFilterTests.startFilter(filterId));
382
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000383 if (context == Dataflow_Context::RECORD) {
384 if (record.hasFrontendConnection) {
385 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
386 } else {
387 // Start DVR Source
388 mDvrTests.startPlaybackInputThread(
389 dvrSourceConfig.playbackInputFile,
390 dvrSourceConfig.settings.get<DvrSettings::Tag::playback>());
391 ASSERT_TRUE(mDvrTests.startDvrPlayback());
392 }
393 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700394 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700395 }
Hongguang600a6ae2021-07-08 18:51:51 -0700396 mDvrTests.testRecordOutput();
397 mDvrTests.stopRecordThread();
398
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000399 if (context == Dataflow_Context::RECORD) {
400 if (record.hasFrontendConnection) {
401 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
402 } else {
403 mDvrTests.stopPlaybackThread();
404 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
405 }
406 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700407 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700408 }
409
410 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
411 ASSERT_TRUE(mDvrTests.stopDvrRecord());
412 ASSERT_TRUE(mDvrTests.detachFilterToDvr(filter));
413 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
414 mDvrTests.closeDvrRecord();
415
Frankie Lizcano9c464f72022-07-18 17:56:52 +0000416 if (context == Dataflow_Context::RECORD) {
417 if (record.hasFrontendConnection) {
418 ASSERT_TRUE(mFrontendTests.closeFrontend());
419 } else {
420 mDvrTests.closeDvrPlayback();
421 }
422 } else if (context == Dataflow_Context::LNBRECORD) {
Hongguang600a6ae2021-07-08 18:51:51 -0700423 ASSERT_TRUE(mFrontendTests.closeFrontend());
Hongguang600a6ae2021-07-08 18:51:51 -0700424 }
425
426 ASSERT_TRUE(mDemuxTests.closeDemux());
427}
428
429void TunerDescramblerAidlTest::scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
430 FrontendConfig frontendConf,
Frankie Lizcano82101d22022-07-28 00:12:35 +0000431 DescramblerConfig descConfig,
432 Dataflow_Context context) {
Hongguang600a6ae2021-07-08 18:51:51 -0700433 int32_t demuxId;
434 std::shared_ptr<IDemux> demux;
435 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
436
437 DvrConfig dvrSourceConfig;
Frankie Lizcano82101d22022-07-28 00:12:35 +0000438 if (context == Dataflow_Context::DESCRAMBLING) {
439 if (descrambling.hasFrontendConnection) {
440 int32_t feId;
441 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
442 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
443 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
444 if (frontendConf.isSoftwareFe) {
445 mFrontendTests.setSoftwareFrontendDvrConfig(dvrMap[descrambling.dvrSoftwareFeId]);
446 }
447 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
448 mFrontendTests.setDemux(demux);
449 } else {
450 dvrSourceConfig = dvrMap[descrambling.dvrSourceId];
451 mDvrTests.setDemux(demux);
452 ASSERT_TRUE(mDvrTests.openDvrInDemux(dvrSourceConfig.type, dvrSourceConfig.bufferSize));
453 ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
454 ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
455 }
456 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700457 int32_t feId;
458 mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
459 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
460 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
Frankie Lizcano82101d22022-07-28 00:12:35 +0000461 if (mLnbId != INVALID_LNB_ID) {
462 ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
463 } else {
464 // If, for some reason, the test got here without failing. We fail it here.
465 ALOGD("mLnbId is null. Something went wrong. Exiting ScrambledBroadcastWithLnbId.");
466 FAIL();
Hongguang600a6ae2021-07-08 18:51:51 -0700467 }
468 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
469 mFrontendTests.setDemux(demux);
Hongguang600a6ae2021-07-08 18:51:51 -0700470 }
471
472 set<int64_t> filterIds;
473 int64_t filterId;
474 set<struct FilterConfig>::iterator config;
475 set<int64_t>::iterator id;
476 mFilterTests.setDemux(demux);
477 for (config = mediaFilterConfs.begin(); config != mediaFilterConfs.end(); config++) {
478 ASSERT_TRUE(mFilterTests.openFilterInDemux((*config).type, (*config).bufferSize));
479 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
480 ASSERT_TRUE(mFilterTests.configFilter((*config).settings, filterId));
481 filterIds.insert(filterId);
482 }
483 ASSERT_TRUE(mDescramblerTests.openDescrambler(demuxId));
484 vector<uint8_t> token;
485 ASSERT_TRUE(mDescramblerTests.getKeyToken(descConfig.casSystemId, descConfig.provisionStr,
486 descConfig.hidlPvtData, token));
487 mDescramblerTests.setKeyToken(token);
488 vector<DemuxPid> pids;
489 DemuxPid pid;
490 for (config = mediaFilterConfs.begin(); config != mediaFilterConfs.end(); config++) {
491 ASSERT_TRUE(mDescramblerTests.getDemuxPidFromFilterSettings((*config).type,
492 (*config).settings, pid));
493 pids.push_back(pid);
494 ASSERT_TRUE(mDescramblerTests.addPid(pid, nullptr));
495 }
496 for (id = filterIds.begin(); id != filterIds.end(); id++) {
497 ASSERT_TRUE(mFilterTests.startFilter(*id));
498 }
499
Frankie Lizcano82101d22022-07-28 00:12:35 +0000500 if (context == Dataflow_Context::DESCRAMBLING) {
501 if (descrambling.hasFrontendConnection) {
502 // tune test
503 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
504 } else {
505 // Start DVR Source
506 mDvrTests.startPlaybackInputThread(
507 dvrSourceConfig.playbackInputFile,
508 dvrSourceConfig.settings.get<DvrSettings::Tag::playback>());
509 ASSERT_TRUE(mDvrTests.startDvrPlayback());
510 }
511 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700512 ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700513 }
514
515 ASSERT_TRUE(filterDataOutputTest());
516
Frankie Lizcano82101d22022-07-28 00:12:35 +0000517 if (context == Dataflow_Context::DESCRAMBLING) {
518 if (descrambling.hasFrontendConnection) {
519 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
520 } else {
521 mDvrTests.stopPlaybackThread();
522 ASSERT_TRUE(mDvrTests.stopDvrPlayback());
523 }
524 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700525 ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
Hongguang600a6ae2021-07-08 18:51:51 -0700526 }
527
528 for (id = filterIds.begin(); id != filterIds.end(); id++) {
529 ASSERT_TRUE(mFilterTests.stopFilter(*id));
530 }
531 for (auto pid : pids) {
532 ASSERT_TRUE(mDescramblerTests.removePid(pid, nullptr));
533 }
534 ASSERT_TRUE(mDescramblerTests.closeDescrambler());
535 for (id = filterIds.begin(); id != filterIds.end(); id++) {
536 ASSERT_TRUE(mFilterTests.closeFilter(*id));
537 }
538
Frankie Lizcano82101d22022-07-28 00:12:35 +0000539 if (context == Dataflow_Context::DESCRAMBLING) {
540 if (descrambling.hasFrontendConnection) {
541 ASSERT_TRUE(mFrontendTests.closeFrontend());
542 } else {
543 mDvrTests.closeDvrPlayback();
544 }
545 } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
Hongguang600a6ae2021-07-08 18:51:51 -0700546 ASSERT_TRUE(mFrontendTests.closeFrontend());
Hongguang600a6ae2021-07-08 18:51:51 -0700547 }
548
549 ASSERT_TRUE(mDemuxTests.closeDemux());
550}
551
Frankie Lizcano82101d22022-07-28 00:12:35 +0000552void TunerDescramblerAidlTest::scrambledBroadcastTestWithLnb(
553 set<struct FilterConfig>& mediaFilterConfs, FrontendConfig& frontendConf,
554 DescramblerConfig& descConfig, LnbConfig& lnbConfig) {
555 // We can test the Lnb individually and make sure it functions properly. If the frontend is
556 // software, we cannot test the whole dataflow. If the frontend is hardware, we can
557 if (lnbConfig.name.compare(emptyHardwareId) == 0) {
558 vector<int32_t> ids;
559 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
560 ASSERT_TRUE(ids.size() > 0);
561 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
562 mLnbId = ids[0];
563 } else {
564 ASSERT_TRUE(mLnbTests.openLnbByName(lnbConfig.name, mLnbId));
565 }
566 // Once Lnb is opened, test some of its basic functionality
567 ASSERT_TRUE(mLnbTests.setLnbCallback());
568 ASSERT_TRUE(mLnbTests.setVoltage(lnbConfig.voltage));
569 ASSERT_TRUE(mLnbTests.setTone(lnbConfig.tone));
570 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConfig.position));
571 if (!frontendConf.isSoftwareFe) {
572 ALOGD("Frontend is not software, testing entire dataflow.");
573 scrambledBroadcastTest(mediaFilterConfs, frontendConf, descConfig,
574 Dataflow_Context::LNBDESCRAMBLING);
575 } else {
576 ALOGD("Frontend is software, did not test the entire dataflow, but tested the Lnb "
577 "individually.");
578 }
579 ASSERT_TRUE(mLnbTests.closeLnb());
580 mLnbId = INVALID_LNB_ID;
581}
582
Hongguang600a6ae2021-07-08 18:51:51 -0700583TEST_P(TunerLnbAidlTest, SendDiseqcMessageToLnb) {
584 description("Open and configure an Lnb with specific settings then send a diseqc msg to it.");
585 if (!lnbLive.support) {
586 return;
587 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000588 vector<LnbLiveHardwareConnections> lnbLive_configs = generateLnbLiveConfigurations();
589 if (lnbLive_configs.empty()) {
590 ALOGD("No frontends that support satellites.");
591 return;
Hongguang600a6ae2021-07-08 18:51:51 -0700592 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000593 for (auto& combination : lnbLive_configs) {
594 lnbLive = combination;
Frankie Lizcano1e283b32022-07-08 21:07:42 +0000595 if (lnbMap[lnbLive.lnbId].name.compare(emptyHardwareId) == 0) {
596 vector<int32_t> ids;
597 ASSERT_TRUE(mLnbTests.getLnbIds(ids));
598 ASSERT_TRUE(ids.size() > 0);
599 ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
600 } else {
601 int32_t id;
602 ASSERT_TRUE(mLnbTests.openLnbByName(lnbMap[lnbLive.lnbId].name, id));
603 }
604 ASSERT_TRUE(mLnbTests.setLnbCallback());
605 ASSERT_TRUE(mLnbTests.setVoltage(lnbMap[lnbLive.lnbId].voltage));
606 ASSERT_TRUE(mLnbTests.setTone(lnbMap[lnbLive.lnbId].tone));
607 ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbMap[lnbLive.lnbId].position));
608 for (auto msgName : lnbLive.diseqcMsgs) {
609 ASSERT_TRUE(mLnbTests.sendDiseqcMessage(diseqcMsgMap[msgName]));
610 }
611 ASSERT_TRUE(mLnbTests.closeLnb());
Hongguang600a6ae2021-07-08 18:51:51 -0700612 }
Hongguang600a6ae2021-07-08 18:51:51 -0700613}
614
615TEST_P(TunerDemuxAidlTest, openDemux) {
616 description("Open and close a Demux.");
617 if (!live.hasFrontendConnection) {
618 return;
619 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000620 auto live_configs = generateLiveConfigurations();
621 for (auto& configuration : live_configs) {
622 live = configuration;
623 int32_t feId;
624 int32_t demuxId;
625 std::shared_ptr<IDemux> demux;
626 mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId);
627 ASSERT_TRUE(feId != INVALID_ID);
628 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
629 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
630 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
631 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
632 ASSERT_TRUE(mDemuxTests.closeDemux());
633 ASSERT_TRUE(mFrontendTests.closeFrontend());
634 }
Hongguang600a6ae2021-07-08 18:51:51 -0700635}
636
637TEST_P(TunerDemuxAidlTest, getAvSyncTime) {
638 description("Get the A/V sync time from a PCR filter.");
639 if (!live.hasFrontendConnection) {
640 return;
641 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000642 auto live_configs = generateLiveConfigurations();
643 for (auto& configuration : live_configs) {
644 live = configuration;
645 if (live.pcrFilterId.compare(emptyHardwareId) == 0) {
646 continue;
647 }
648 int32_t feId;
649 int32_t demuxId;
650 std::shared_ptr<IDemux> demux;
651 int64_t mediaFilterId;
652 int64_t pcrFilterId;
653 int32_t avSyncHwId;
654 std::shared_ptr<IFilter> mediaFilter;
Hongguang600a6ae2021-07-08 18:51:51 -0700655
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000656 mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId);
657 ASSERT_TRUE(feId != INVALID_ID);
658 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
659 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
660 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
661 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
662 mFilterTests.setDemux(demux);
663 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterMap[live.videoFilterId].type,
664 filterMap[live.videoFilterId].bufferSize));
665 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(mediaFilterId));
666 ASSERT_TRUE(
667 mFilterTests.configFilter(filterMap[live.videoFilterId].settings, mediaFilterId));
668 mediaFilter = mFilterTests.getFilterById(mediaFilterId);
669 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterMap[live.pcrFilterId].type,
670 filterMap[live.pcrFilterId].bufferSize));
671 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(pcrFilterId));
672 ASSERT_TRUE(mFilterTests.configFilter(filterMap[live.pcrFilterId].settings, pcrFilterId));
673 ASSERT_TRUE(mDemuxTests.getAvSyncId(mediaFilter, avSyncHwId));
674 ASSERT_TRUE(pcrFilterId == avSyncHwId);
675 ASSERT_TRUE(mDemuxTests.getAvSyncTime(pcrFilterId));
676 ASSERT_TRUE(mFilterTests.closeFilter(pcrFilterId));
677 ASSERT_TRUE(mFilterTests.closeFilter(mediaFilterId));
678 ASSERT_TRUE(mDemuxTests.closeDemux());
679 ASSERT_TRUE(mFrontendTests.closeFrontend());
680 }
Hongguang600a6ae2021-07-08 18:51:51 -0700681}
682
683TEST_P(TunerFilterAidlTest, StartFilterInDemux) {
684 description("Open and start a filter in Demux.");
685 if (!live.hasFrontendConnection) {
686 return;
687 }
688 // TODO use parameterized tests
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000689 auto live_configs = generateLiveConfigurations();
690 for (auto& configuration : live_configs) {
691 live = configuration;
692 configSingleFilterInDemuxTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
693 }
Hongguang600a6ae2021-07-08 18:51:51 -0700694}
695
696TEST_P(TunerFilterAidlTest, ConfigIpFilterInDemuxWithCid) {
697 description("Open and configure an ip filter in Demux.");
698 // TODO use parameterized tests
699 if (!live.hasFrontendConnection) {
700 return;
701 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000702 auto live_configs = generateLiveConfigurations();
703 for (auto& configuration : live_configs) {
704 live = configuration;
705 if (live.ipFilterId.compare(emptyHardwareId) == 0) {
706 continue;
707 }
708 configSingleFilterInDemuxTest(filterMap[live.ipFilterId], frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -0700709 }
Hongguang600a6ae2021-07-08 18:51:51 -0700710}
711
712TEST_P(TunerFilterAidlTest, ReconfigFilterToReceiveStartId) {
713 description("Recofigure and restart a filter to test start id.");
714 if (!live.hasFrontendConnection) {
715 return;
716 }
717 // TODO use parameterized tests
Frankie Lizcano8b87f252022-07-19 21:51:54 +0000718 auto live_configs = generateLiveConfigurations();
719 for (auto& configuration : live_configs) {
720 live = configuration;
721 reconfigSingleFilterInDemuxTest(filterMap[live.videoFilterId],
722 filterMap[live.videoFilterId],
723 frontendMap[live.frontendId]);
724 }
Hongguang600a6ae2021-07-08 18:51:51 -0700725}
726
727TEST_P(TunerFilterAidlTest, SetFilterLinkage) {
728 description("Pick up all the possible linkages from the demux caps and set them up.");
729 DemuxCapabilities caps;
730 int32_t demuxId;
731 std::shared_ptr<IDemux> demux;
732 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
733 ASSERT_TRUE(mDemuxTests.getDemuxCaps(caps));
734 mFilterTests.setDemux(demux);
735 for (int i = 0; i < caps.linkCaps.size(); i++) {
736 uint32_t bitMask = 1;
737 for (int j = 0; j < FILTER_MAIN_TYPE_BIT_COUNT; j++) {
738 if (caps.linkCaps[i] & (bitMask << j)) {
739 int64_t sourceFilterId;
740 int64_t sinkFilterId;
741 ASSERT_TRUE(mFilterTests.openFilterInDemux(getLinkageFilterType(i), FMQ_SIZE_16M));
742 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(sourceFilterId));
743 ASSERT_TRUE(mFilterTests.openFilterInDemux(getLinkageFilterType(j), FMQ_SIZE_16M));
744 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(sinkFilterId));
745 ASSERT_TRUE(mFilterTests.setFilterDataSource(sourceFilterId, sinkFilterId));
746 ASSERT_TRUE(mFilterTests.setFilterDataSourceToDemux(sinkFilterId));
747 ASSERT_TRUE(mFilterTests.closeFilter(sinkFilterId));
748 ASSERT_TRUE(mFilterTests.closeFilter(sourceFilterId));
749 }
750 }
751 }
752 ASSERT_TRUE(mDemuxTests.closeDemux());
753}
754
755TEST_P(TunerFilterAidlTest, testTimeFilter) {
756 description("Open a timer filter in Demux and set time stamp.");
757 if (!timeFilter.support) {
758 return;
759 }
760 // TODO use parameterized tests
Frankie Lizcano0c069532022-07-14 20:20:46 +0000761 auto timeFilter_configs = generateTimeFilterConfigurations();
762 for (auto& configuration : timeFilter_configs) {
763 timeFilter = configuration;
764 testTimeFilter(timeFilterMap[timeFilter.timeFilterId]);
765 }
Hongguang600a6ae2021-07-08 18:51:51 -0700766}
767
Gareth Fenn9a808452022-03-31 08:40:00 +0100768static bool isEventProducingFilter(const FilterConfig& filterConfig) {
769 switch (filterConfig.type.mainType) {
770 case DemuxFilterMainType::TS: {
771 auto tsFilterType =
772 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tsFilterType>();
773 return (tsFilterType == DemuxTsFilterType::SECTION ||
774 tsFilterType == DemuxTsFilterType::PES ||
775 tsFilterType == DemuxTsFilterType::AUDIO ||
776 tsFilterType == DemuxTsFilterType::VIDEO ||
777 tsFilterType == DemuxTsFilterType::RECORD ||
778 tsFilterType == DemuxTsFilterType::TEMI);
779 }
780 case DemuxFilterMainType::MMTP: {
781 auto mmtpFilterType =
782 filterConfig.type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>();
783 return (mmtpFilterType == DemuxMmtpFilterType::SECTION ||
784 mmtpFilterType == DemuxMmtpFilterType::PES ||
785 mmtpFilterType == DemuxMmtpFilterType::AUDIO ||
786 mmtpFilterType == DemuxMmtpFilterType::VIDEO ||
787 mmtpFilterType == DemuxMmtpFilterType::RECORD ||
788 mmtpFilterType == DemuxMmtpFilterType::DOWNLOAD);
789 }
790 case DemuxFilterMainType::IP: {
791 auto ipFilterType =
792 filterConfig.type.subType.get<DemuxFilterSubType::Tag::ipFilterType>();
793 return (ipFilterType == DemuxIpFilterType::SECTION);
794 }
795 case DemuxFilterMainType::TLV: {
796 auto tlvFilterType =
797 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tlvFilterType>();
798 return (tlvFilterType == DemuxTlvFilterType::SECTION);
799 }
800 case DemuxFilterMainType::ALP: {
801 auto alpFilterType =
802 filterConfig.type.subType.get<DemuxFilterSubType::Tag::alpFilterType>();
803 return (alpFilterType == DemuxAlpFilterType::SECTION);
804 }
805 default:
806 return false;
807 }
808}
809
Patrick Rohr1586d212021-11-23 00:40:56 +0100810static bool isMediaFilter(const FilterConfig& filterConfig) {
811 switch (filterConfig.type.mainType) {
812 case DemuxFilterMainType::TS: {
813 // TS Audio and Video filters are media filters
814 auto tsFilterType =
815 filterConfig.type.subType.get<DemuxFilterSubType::Tag::tsFilterType>();
816 return (tsFilterType == DemuxTsFilterType::AUDIO ||
817 tsFilterType == DemuxTsFilterType::VIDEO);
818 }
819 case DemuxFilterMainType::MMTP: {
820 // MMTP Audio and Video filters are media filters
821 auto mmtpFilterType =
822 filterConfig.type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>();
823 return (mmtpFilterType == DemuxMmtpFilterType::AUDIO ||
824 mmtpFilterType == DemuxMmtpFilterType::VIDEO);
825 }
826 default:
827 return false;
828 }
829}
Patrick Rohr149b0872021-11-20 00:39:37 +0100830
Patrick Rohr1586d212021-11-23 00:40:56 +0100831static int getDemuxFilterEventDataLength(const DemuxFilterEvent& event) {
832 switch (event.getTag()) {
833 case DemuxFilterEvent::Tag::section:
834 return event.get<DemuxFilterEvent::Tag::section>().dataLength;
835 case DemuxFilterEvent::Tag::media:
836 return event.get<DemuxFilterEvent::Tag::media>().dataLength;
837 case DemuxFilterEvent::Tag::pes:
838 return event.get<DemuxFilterEvent::Tag::pes>().dataLength;
839 case DemuxFilterEvent::Tag::download:
840 return event.get<DemuxFilterEvent::Tag::download>().dataLength;
841 case DemuxFilterEvent::Tag::ipPayload:
842 return event.get<DemuxFilterEvent::Tag::ipPayload>().dataLength;
843
844 case DemuxFilterEvent::Tag::tsRecord:
845 case DemuxFilterEvent::Tag::mmtpRecord:
846 case DemuxFilterEvent::Tag::temi:
847 case DemuxFilterEvent::Tag::monitorEvent:
848 case DemuxFilterEvent::Tag::startId:
849 return 0;
850 }
851}
852
853// TODO: move boilerplate into text fixture
854void TunerFilterAidlTest::testDelayHint(const FilterConfig& filterConf) {
Gareth Fenn9a808452022-03-31 08:40:00 +0100855 if (!filterConf.timeDelayInMs && !filterConf.dataDelayInBytes) {
856 return;
857 }
858 if (!isEventProducingFilter(filterConf)) {
859 return;
860 }
Patrick Rohr149b0872021-11-20 00:39:37 +0100861 int32_t feId;
862 int32_t demuxId;
863 std::shared_ptr<IDemux> demux;
864 int64_t filterId;
865
866 mFrontendTests.getFrontendIdByType(frontendMap[live.frontendId].type, feId);
867 ASSERT_TRUE(feId != INVALID_ID);
868 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
869 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
870 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
871 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
872 mFilterTests.setDemux(demux);
873
Patrick Rohr149b0872021-11-20 00:39:37 +0100874 ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
875 ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
Patrick Rohr149b0872021-11-20 00:39:37 +0100876
Patrick Rohr1586d212021-11-23 00:40:56 +0100877 bool mediaFilter = isMediaFilter(filterConf);
Patrick Rohr149b0872021-11-20 00:39:37 +0100878 auto filter = mFilterTests.getFilterById(filterId);
879
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +0100880 // startTime needs to be set before calling setDelayHint.
881 auto startTime = std::chrono::steady_clock::now();
882
Gareth Fenn9a808452022-03-31 08:40:00 +0100883 int timeDelayInMs = filterConf.timeDelayInMs;
884 if (timeDelayInMs > 0) {
Patrick Rohr1586d212021-11-23 00:40:56 +0100885 FilterDelayHint delayHint;
886 delayHint.hintType = FilterDelayHintType::TIME_DELAY_IN_MS;
Gareth Fenn9a808452022-03-31 08:40:00 +0100887 delayHint.hintValue = timeDelayInMs;
Patrick Rohr149b0872021-11-20 00:39:37 +0100888
Patrick Rohr1586d212021-11-23 00:40:56 +0100889 // setDelayHint should fail for media filters.
890 ASSERT_EQ(filter->setDelayHint(delayHint).isOk(), !mediaFilter);
891 }
Patrick Rohr149b0872021-11-20 00:39:37 +0100892
Patrick Rohr1586d212021-11-23 00:40:56 +0100893 int dataDelayInBytes = filterConf.dataDelayInBytes;
894 if (dataDelayInBytes > 0) {
895 FilterDelayHint delayHint;
896 delayHint.hintType = FilterDelayHintType::DATA_SIZE_DELAY_IN_BYTES;
897 delayHint.hintValue = dataDelayInBytes;
Patrick Rohr149b0872021-11-20 00:39:37 +0100898
Patrick Rohr1586d212021-11-23 00:40:56 +0100899 // setDelayHint should fail for media filters.
900 ASSERT_EQ(filter->setDelayHint(delayHint).isOk(), !mediaFilter);
901 }
Patrick Rohr149b0872021-11-20 00:39:37 +0100902
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +0100903 // start and stop filter (and wait for first callback) in order to
904 // circumvent callback scheduler race conditions after adjusting filter
905 // delays.
906 auto cb = mFilterTests.getFilterCallbacks().at(filterId);
907 auto future =
908 cb->verifyFilterCallback([](const std::vector<DemuxFilterEvent>&) { return true; });
Gareth Fenn9a808452022-03-31 08:40:00 +0100909
910 // The configure stage can also produce events, so we should set the delay
911 // hint beforehand.
912 ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
Patrick Rohr1586d212021-11-23 00:40:56 +0100913 mFilterTests.startFilter(filterId);
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +0100914
915 auto timeout = std::chrono::seconds(30);
916 ASSERT_EQ(future.wait_for(timeout), std::future_status::ready);
917
Patrick Rohr1586d212021-11-23 00:40:56 +0100918 mFilterTests.stopFilter(filterId);
Patrick Rohr149b0872021-11-20 00:39:37 +0100919
Patrick Rohr1586d212021-11-23 00:40:56 +0100920 if (!mediaFilter) {
Patrick Rohr1586d212021-11-23 00:40:56 +0100921 int callbackSize = 0;
Patrick Rohr2b0e9ee2021-12-27 13:55:16 +0100922 future = cb->verifyFilterCallback(
Patrick Rohr1586d212021-11-23 00:40:56 +0100923 [&callbackSize](const std::vector<DemuxFilterEvent>& events) {
924 for (const auto& event : events) {
925 callbackSize += getDemuxFilterEventDataLength(event);
926 }
927 return true;
928 });
929
Patrick Rohr1586d212021-11-23 00:40:56 +0100930 ASSERT_TRUE(mFilterTests.startFilter(filterId));
931
932 // block and wait for callback to be received.
Patrick Rohr1586d212021-11-23 00:40:56 +0100933 ASSERT_EQ(future.wait_for(timeout), std::future_status::ready);
Patrick Rohr1586d212021-11-23 00:40:56 +0100934
Gareth Fenn9a808452022-03-31 08:40:00 +0100935 auto duration = std::chrono::steady_clock::now() - startTime;
936 bool delayHintTest = duration >= std::chrono::milliseconds(timeDelayInMs);
Patrick Rohr1586d212021-11-23 00:40:56 +0100937 bool dataSizeTest = callbackSize >= dataDelayInBytes;
938
Gareth Fenn9a808452022-03-31 08:40:00 +0100939 if (timeDelayInMs > 0 && dataDelayInBytes > 0) {
Patrick Rohr1586d212021-11-23 00:40:56 +0100940 ASSERT_TRUE(delayHintTest || dataSizeTest);
941 } else {
942 // if only one of time delay / data delay is configured, one of them
943 // holds true by default, so we want both assertions to be true.
944 ASSERT_TRUE(delayHintTest && dataSizeTest);
945 }
946
947 ASSERT_TRUE(mFilterTests.stopFilter(filterId));
948 }
949
Patrick Rohr149b0872021-11-20 00:39:37 +0100950 ASSERT_TRUE(mFilterTests.closeFilter(filterId));
951 ASSERT_TRUE(mDemuxTests.closeDemux());
952 ASSERT_TRUE(mFrontendTests.closeFrontend());
953}
954
Patrick Rohr1586d212021-11-23 00:40:56 +0100955TEST_P(TunerFilterAidlTest, FilterDelayHintTest) {
956 description("Test filter time delay hint.");
Gareth Fenn9a808452022-03-31 08:40:00 +0100957 if (!live.hasFrontendConnection) {
958 return;
959 }
Patrick Rohr1586d212021-11-23 00:40:56 +0100960 for (const auto& obj : filterMap) {
961 testDelayHint(obj.second);
962 }
963}
964
Hongguang600a6ae2021-07-08 18:51:51 -0700965TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsSectionFilterTest) {
966 description("Feed ts data from playback and configure Ts section filter to get output");
Frankie Lizcanoa53f5542022-07-07 17:32:06 +0000967 if (!playback.support) {
Hongguang600a6ae2021-07-08 18:51:51 -0700968 return;
969 }
Frankie Lizcanoa53f5542022-07-07 17:32:06 +0000970 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
971 for (auto& configuration : playback_configs) {
972 if (configuration.sectionFilterId.compare(emptyHardwareId) != 0) {
973 playback = configuration;
974 playbackSingleFilterTest(filterMap[playback.sectionFilterId], dvrMap[playback.dvrId]);
975 }
976 }
Hongguang600a6ae2021-07-08 18:51:51 -0700977}
978
979TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsAudioFilterTest) {
980 description("Feed ts data from playback and configure Ts audio filter to get output");
981 if (!playback.support) {
982 return;
983 }
Frankie Lizcanoa53f5542022-07-07 17:32:06 +0000984 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
985 for (auto& configuration : playback_configs) {
986 playback = configuration;
987 playbackSingleFilterTest(filterMap[playback.audioFilterId], dvrMap[playback.dvrId]);
988 }
Hongguang600a6ae2021-07-08 18:51:51 -0700989}
990
991TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsVideoFilterTest) {
992 description("Feed ts data from playback and configure Ts video filter to get output");
993 if (!playback.support) {
994 return;
995 }
Frankie Lizcanoa53f5542022-07-07 17:32:06 +0000996 vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
997 for (auto& configuration : playback_configs) {
998 playback = configuration;
999 playbackSingleFilterTest(filterMap[playback.videoFilterId], dvrMap[playback.dvrId]);
1000 }
Hongguang600a6ae2021-07-08 18:51:51 -07001001}
1002
1003TEST_P(TunerRecordAidlTest, RecordDataFlowWithTsRecordFilterTest) {
1004 description("Feed ts data from frontend to recording and test with ts record filter");
1005 if (!record.support) {
1006 return;
1007 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +00001008 auto record_configs = generateRecordConfigurations();
1009 for (auto& configuration : record_configs) {
1010 record = configuration;
1011 recordSingleFilterTest(filterMap[record.recordFilterId], frontendMap[record.frontendId],
1012 dvrMap[record.dvrRecordId], Dataflow_Context::RECORD);
1013 }
Hongguang600a6ae2021-07-08 18:51:51 -07001014}
1015
1016TEST_P(TunerRecordAidlTest, AttachFiltersToRecordTest) {
1017 description("Attach a single filter to the record dvr test.");
1018 // TODO use parameterized tests
1019 if (!record.support) {
1020 return;
1021 }
Frankie Lizcano9c464f72022-07-18 17:56:52 +00001022 auto record_configs = generateRecordConfigurations();
1023 for (auto& configuration : record_configs) {
1024 record = configuration;
1025 attachSingleFilterToRecordDvrTest(filterMap[record.recordFilterId],
1026 frontendMap[record.frontendId],
1027 dvrMap[record.dvrRecordId]);
1028 }
Hongguang600a6ae2021-07-08 18:51:51 -07001029}
1030
1031TEST_P(TunerRecordAidlTest, LnbRecordDataFlowWithTsRecordFilterTest) {
1032 description("Feed ts data from Fe with Lnb to recording and test with ts record filter");
1033 if (!lnbRecord.support) {
1034 return;
1035 }
Frankie Lizcanoecba02a2022-07-12 17:56:54 +00001036 vector<LnbRecordHardwareConnections> lnbRecord_configs = generateLnbRecordConfigurations();
1037 if (lnbRecord_configs.empty()) {
1038 ALOGD("No frontends that support satellites.");
1039 return;
1040 }
1041 for (auto& configuration : lnbRecord_configs) {
1042 lnbRecord = configuration;
1043 recordSingleFilterTestWithLnb(filterMap[lnbRecord.recordFilterId],
1044 frontendMap[lnbRecord.frontendId],
1045 dvrMap[lnbRecord.dvrRecordId], lnbMap[lnbRecord.lnbId]);
1046 }
Hongguang600a6ae2021-07-08 18:51:51 -07001047}
1048
1049TEST_P(TunerFrontendAidlTest, TuneFrontend) {
1050 description("Tune one Frontend with specific setting and check Lock event");
1051 if (!live.hasFrontendConnection) {
1052 return;
1053 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001054 auto live_configs = generateLiveConfigurations();
1055 for (auto& configuration : live_configs) {
1056 live = configuration;
1057 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
1058 }
Hongguang600a6ae2021-07-08 18:51:51 -07001059}
1060
1061TEST_P(TunerFrontendAidlTest, AutoScanFrontend) {
1062 description("Run an auto frontend scan with specific setting and check lock scanMessage");
1063 if (!scan.hasFrontendConnection) {
1064 return;
1065 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001066 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1067 for (auto& configuration : scan_configs) {
1068 scan = configuration;
1069 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_AUTO);
1070 }
Hongguang600a6ae2021-07-08 18:51:51 -07001071}
1072
1073TEST_P(TunerFrontendAidlTest, BlindScanFrontend) {
1074 description("Run an blind frontend scan with specific setting and check lock scanMessage");
1075 if (!scan.hasFrontendConnection) {
1076 return;
1077 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001078 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1079 for (auto& configuration : scan_configs) {
1080 scan = configuration;
1081 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_BLIND);
1082 }
Hongguang600a6ae2021-07-08 18:51:51 -07001083}
1084
1085TEST_P(TunerFrontendAidlTest, TuneFrontendWithFrontendSettings) {
1086 description("Tune one Frontend with setting and check Lock event");
1087 if (!live.hasFrontendConnection) {
1088 return;
1089 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001090 auto live_configs = generateLiveConfigurations();
1091 for (auto& configuration : live_configs) {
1092 live = configuration;
1093 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
1094 }
Hongguang600a6ae2021-07-08 18:51:51 -07001095}
1096
1097TEST_P(TunerFrontendAidlTest, BlindScanFrontendWithEndFrequency) {
1098 description("Run an blind frontend scan with setting and check lock scanMessage");
1099 if (!scan.hasFrontendConnection) {
1100 return;
1101 }
Frankie Lizcano3138d6b2022-07-11 22:06:45 +00001102 vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
1103 for (auto& configuration : scan_configs) {
1104 scan = configuration;
1105 mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_BLIND);
1106 }
Hongguang600a6ae2021-07-08 18:51:51 -07001107}
1108
1109TEST_P(TunerFrontendAidlTest, LinkToCiCam) {
1110 description("Test Frontend link to CiCam");
1111 if (!live.hasFrontendConnection) {
1112 return;
1113 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001114 auto live_configs = generateLiveConfigurations();
1115 for (auto& configuration : live_configs) {
1116 live = configuration;
1117 if (!frontendMap[live.frontendId].canConnectToCiCam) {
1118 continue;
1119 }
1120 mFrontendTests.tuneTest(frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -07001121 }
Hongguang600a6ae2021-07-08 18:51:51 -07001122}
1123
Hongguangfcedda02021-12-13 17:08:02 -08001124TEST_P(TunerFrontendAidlTest, getHardwareInfo) {
1125 description("Test Frontend get hardware info");
1126 if (!live.hasFrontendConnection) {
1127 return;
1128 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001129 auto live_configs = generateLiveConfigurations();
1130 for (auto& configuration : live_configs) {
1131 live = configuration;
1132 mFrontendTests.debugInfoTest(frontendMap[live.frontendId]);
1133 }
Hongguangfcedda02021-12-13 17:08:02 -08001134}
1135
Hongguang5766ddf2021-12-23 11:40:37 -08001136TEST_P(TunerFrontendAidlTest, maxNumberOfFrontends) {
1137 description("Test Max Frontend number");
1138 if (!live.hasFrontendConnection) {
1139 return;
1140 }
1141 mFrontendTests.maxNumberOfFrontendsTest();
1142}
1143
Hongguang881190f2022-01-14 13:23:37 -08001144TEST_P(TunerFrontendAidlTest, statusReadinessTest) {
1145 description("Test Max Frontend status readiness");
1146 if (!live.hasFrontendConnection) {
1147 return;
1148 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001149 auto live_configs = generateLiveConfigurations();
1150 for (auto& configuration : live_configs) {
1151 live = configuration;
1152 mFrontendTests.statusReadinessTest(frontendMap[live.frontendId]);
1153 }
Hongguang881190f2022-01-14 13:23:37 -08001154}
1155
Hongguang600a6ae2021-07-08 18:51:51 -07001156TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowVideoFilterTest) {
1157 description("Test Video Filter functionality in Broadcast use case.");
1158 if (!live.hasFrontendConnection) {
1159 return;
1160 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001161 auto live_configs = generateLiveConfigurations();
1162 for (auto& configuration : live_configs) {
1163 live = configuration;
1164 broadcastSingleFilterTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
1165 }
Hongguang600a6ae2021-07-08 18:51:51 -07001166}
1167
1168TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowAudioFilterTest) {
1169 description("Test Audio Filter functionality in Broadcast use case.");
1170 if (!live.hasFrontendConnection) {
1171 return;
1172 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001173 auto live_configs = generateLiveConfigurations();
1174 for (auto& configuration : live_configs) {
1175 live = configuration;
1176 broadcastSingleFilterTest(filterMap[live.audioFilterId], frontendMap[live.frontendId]);
1177 }
Hongguang600a6ae2021-07-08 18:51:51 -07001178}
1179
1180TEST_P(TunerBroadcastAidlTest, BroadcastDataFlowSectionFilterTest) {
1181 description("Test Section Filter functionality in Broadcast use case.");
1182 if (!live.hasFrontendConnection) {
1183 return;
1184 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001185 auto live_configs = generateLiveConfigurations();
1186 for (auto& configuration : live_configs) {
1187 live = configuration;
1188 if (live.sectionFilterId.compare(emptyHardwareId) == 0) {
1189 continue;
1190 }
1191 broadcastSingleFilterTest(filterMap[live.sectionFilterId], frontendMap[live.frontendId]);
Hongguang600a6ae2021-07-08 18:51:51 -07001192 }
Hongguang600a6ae2021-07-08 18:51:51 -07001193}
1194
1195TEST_P(TunerBroadcastAidlTest, IonBufferTest) {
1196 description("Test the av filter data bufferring.");
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 broadcastSingleFilterTest(filterMap[live.videoFilterId], frontendMap[live.frontendId]);
1204 }
Hongguang600a6ae2021-07-08 18:51:51 -07001205}
1206
1207TEST_P(TunerBroadcastAidlTest, LnbBroadcastDataFlowVideoFilterTest) {
1208 description("Test Video Filter functionality in Broadcast with Lnb use case.");
1209 if (!lnbLive.support) {
1210 return;
1211 }
Frankie Lizcano1e283b32022-07-08 21:07:42 +00001212 vector<LnbLiveHardwareConnections> lnbLive_configs = generateLnbLiveConfigurations();
1213 if (lnbLive_configs.empty()) {
1214 ALOGD("No frontends that support satellites.");
1215 return;
1216 }
1217 for (auto& combination : lnbLive_configs) {
1218 lnbLive = combination;
1219 broadcastSingleFilterTestWithLnb(filterMap[lnbLive.videoFilterId],
1220 frontendMap[lnbLive.frontendId], lnbMap[lnbLive.lnbId]);
1221 }
Hongguang600a6ae2021-07-08 18:51:51 -07001222}
1223
1224TEST_P(TunerBroadcastAidlTest, MediaFilterWithSharedMemoryHandle) {
1225 description("Test the Media Filter with shared memory handle");
1226 if (!live.hasFrontendConnection) {
1227 return;
1228 }
Frankie Lizcano8b87f252022-07-19 21:51:54 +00001229 auto live_configs = generateLiveConfigurations();
1230 for (auto& configuration : live_configs) {
1231 live = configuration;
1232 mediaFilterUsingSharedMemoryTest(filterMap[live.videoFilterId],
1233 frontendMap[live.frontendId]);
1234 }
Hongguang600a6ae2021-07-08 18:51:51 -07001235}
1236
1237TEST_P(TunerDescramblerAidlTest, CreateDescrambler) {
1238 description("Create Descrambler");
1239 if (!descrambling.support) {
1240 return;
1241 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001242 vector<DescramblingHardwareConnections> descrambling_configs =
1243 generateDescramblingConfigurations();
1244 if (descrambling_configs.empty()) {
1245 ALOGD("No valid descrambling combinations in the configuration file.");
1246 return;
Hongguang600a6ae2021-07-08 18:51:51 -07001247 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001248 for (auto& combination : descrambling_configs) {
1249 descrambling = combination;
1250 int32_t demuxId;
1251 std::shared_ptr<IDemux> demux;
1252 ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
Hongguang600a6ae2021-07-08 18:51:51 -07001253
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001254 if (descrambling.hasFrontendConnection) {
1255 int32_t feId;
1256 mFrontendTests.getFrontendIdByType(frontendMap[descrambling.frontendId].type, feId);
1257 ASSERT_TRUE(feId != INVALID_ID);
1258 ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
1259 ASSERT_TRUE(mFrontendTests.setFrontendCallback());
1260 ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
1261 }
Hongguang600a6ae2021-07-08 18:51:51 -07001262
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001263 ASSERT_TRUE(mDescramblerTests.openDescrambler(demuxId));
1264 ASSERT_TRUE(mDescramblerTests.closeDescrambler());
1265 ASSERT_TRUE(mDemuxTests.closeDemux());
1266
1267 if (descrambling.hasFrontendConnection) {
1268 ASSERT_TRUE(mFrontendTests.closeFrontend());
1269 }
Hongguang600a6ae2021-07-08 18:51:51 -07001270 }
1271}
1272
1273TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTest) {
1274 description("Test ts audio filter in scrambled broadcast use case");
1275 if (!descrambling.support) {
1276 return;
1277 }
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001278 vector<DescramblingHardwareConnections> descrambling_configs =
1279 generateDescramblingConfigurations();
1280 if (descrambling_configs.empty()) {
1281 ALOGD("No valid descrambling combinations in the configuration file.");
1282 return;
1283 }
1284 for (auto& combination : descrambling_configs) {
1285 descrambling = combination;
1286 set<FilterConfig> filterConfs;
1287 filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.audioFilterId]));
1288 filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.videoFilterId]));
1289 scrambledBroadcastTest(filterConfs, frontendMap[descrambling.frontendId],
Frankie Lizcano82101d22022-07-28 00:12:35 +00001290 descramblerMap[descrambling.descramblerId],
1291 Dataflow_Context::DESCRAMBLING);
Frankie Lizcanof4e07962022-07-13 20:54:34 +00001292 }
Hongguang600a6ae2021-07-08 18:51:51 -07001293}
1294
Frankie Lizcano82101d22022-07-28 00:12:35 +00001295TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTestWithLnb) {
1296 description("Test media filters in scrambled broadcast use case with Lnb");
1297 if (!lnbDescrambling.support) {
1298 return;
1299 }
1300 set<FilterConfig> filterConfs;
1301 filterConfs.insert(static_cast<FilterConfig>(filterMap[lnbDescrambling.audioFilterId]));
1302 filterConfs.insert(static_cast<FilterConfig>(filterMap[lnbDescrambling.videoFilterId]));
1303 scrambledBroadcastTestWithLnb(filterConfs, frontendMap[lnbDescrambling.frontendId],
1304 descramblerMap[lnbDescrambling.descramblerId],
1305 lnbMap[lnbDescrambling.lnbId]);
1306}
1307
Hongguang600a6ae2021-07-08 18:51:51 -07001308INSTANTIATE_TEST_SUITE_P(PerInstance, TunerBroadcastAidlTest,
1309 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1310 android::PrintInstanceNameToString);
1311
1312INSTANTIATE_TEST_SUITE_P(PerInstance, TunerFrontendAidlTest,
1313 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1314 android::PrintInstanceNameToString);
1315
1316INSTANTIATE_TEST_SUITE_P(PerInstance, TunerFilterAidlTest,
1317 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1318 android::PrintInstanceNameToString);
1319
1320INSTANTIATE_TEST_SUITE_P(PerInstance, TunerRecordAidlTest,
1321 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1322 android::PrintInstanceNameToString);
1323
1324INSTANTIATE_TEST_SUITE_P(PerInstance, TunerLnbAidlTest,
1325 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1326 android::PrintInstanceNameToString);
1327
1328INSTANTIATE_TEST_SUITE_P(PerInstance, TunerDemuxAidlTest,
1329 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1330 android::PrintInstanceNameToString);
1331
1332INSTANTIATE_TEST_SUITE_P(PerInstance, TunerPlaybackAidlTest,
1333 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1334 android::PrintInstanceNameToString);
1335
1336INSTANTIATE_TEST_SUITE_P(PerInstance, TunerDescramblerAidlTest,
1337 testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
1338 android::PrintInstanceNameToString);
1339
1340} // namespace
1341
1342// Start thread pool to receive callbacks from AIDL service.
1343int main(int argc, char** argv) {
1344 ::testing::InitGoogleTest(&argc, argv);
1345 ABinderProcess_setThreadPoolMaxThreadCount(1);
1346 ABinderProcess_startThreadPool();
1347 return RUN_ALL_TESTS();
1348}