Amy Zhang | 45cc57a | 2020-07-09 22:56:25 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 19 | AssertionResult 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 | |
| 30 | AssertionResult 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 | |
| 36 | AssertionResult DemuxTests::closeDemux() { |
| 37 | EXPECT_TRUE(mDemux) << "Test with openDemux first."; |
| 38 | auto status = mDemux->close(); |
| 39 | mDemux = nullptr; |
| 40 | return AssertionResult(status.isOk()); |
Amy Zhang | 80cb960 | 2020-07-15 13:06:39 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | AssertionResult 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 | |
| 62 | AssertionResult 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 Zhang | 45cc57a | 2020-07-09 22:56:25 -0700 | [diff] [blame] | 71 | } |