blob: e0600b62a1d31a2b0da12dc3fa872fd96f1f3e8e [file] [log] [blame]
Amy Zhang45cc57a2020-07-09 22:56:25 -07001/*
2 * Copyright 2020 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 "DemuxTests.h"
18
19AssertionResult DemuxTests::openDemux(sp<IDemux>& demux, uint32_t& demuxId) {
20 Result status;
21 mService->openDemux([&](Result result, uint32_t id, const sp<IDemux>& demuxSp) {
22 mDemux = demuxSp;
23 demux = demuxSp;
24 demuxId = id;
25 status = result;
26 });
27 return AssertionResult(status == Result::SUCCESS);
28}
29
30AssertionResult DemuxTests::setDemuxFrontendDataSource(uint32_t frontendId) {
31 EXPECT_TRUE(mDemux) << "Test with openDemux first.";
32 auto status = mDemux->setFrontendDataSource(frontendId);
33 return AssertionResult(status.isOk());
34}
35
36AssertionResult DemuxTests::closeDemux() {
37 EXPECT_TRUE(mDemux) << "Test with openDemux first.";
38 auto status = mDemux->close();
39 mDemux = nullptr;
40 return AssertionResult(status.isOk());
Amy Zhang80cb9602020-07-15 13:06:39 -070041}
42
43AssertionResult DemuxTests::getAvSyncId_64bit(sp<IFilter> filter, uint64_t& avSyncHwId) {
44 EXPECT_TRUE(mDemux) << "Demux is not opened yet.";
45 Result status;
46
47 sp<android::hardware::tv::tuner::V1_1::IDemux> demux_v1_1 =
48 android::hardware::tv::tuner::V1_1::IDemux::castFrom(mDemux);
49 if (demux_v1_1 != NULL) {
50 demux_v1_1->getAvSyncHwId64Bit(filter, [&](Result result, uint64_t id) {
51 status = result;
52 avSyncHwId = id;
53 });
54 } else {
55 ALOGW("[vts] Can't cast IDemux into v1_1.");
56 return failure();
57 }
58
59 return AssertionResult(status == Result::SUCCESS);
60}
61
62AssertionResult DemuxTests::getAvSyncTime(uint32_t avSyncId) {
63 EXPECT_TRUE(mDemux) << "Demux is not opened yet.";
64 Result status;
65 uint64_t syncTime;
66 mDemux->getAvSyncTime(avSyncId, [&](Result result, uint64_t time) {
67 status = result;
68 syncTime = time;
69 });
70 return AssertionResult(status == Result::SUCCESS);
Amy Zhang45cc57a2020-07-09 22:56:25 -070071}