1 /*
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 "DemuxTests.h"
18
openDemux(std::shared_ptr<IDemux> & demux,int32_t & demuxId)19 AssertionResult DemuxTests::openDemux(std::shared_ptr<IDemux>& demux, int32_t& demuxId) {
20 std::vector<int32_t> id;
21 auto status = mService->openDemux(&id, &mDemux);
22 if (status.isOk()) {
23 demux = mDemux;
24 demuxId = id[0];
25 }
26 return AssertionResult(status.isOk());
27 }
28
setDemuxFrontendDataSource(int32_t frontendId)29 AssertionResult DemuxTests::setDemuxFrontendDataSource(int32_t frontendId) {
30 EXPECT_TRUE(mDemux) << "Test with openDemux first.";
31 auto status = mDemux->setFrontendDataSource(frontendId);
32 return AssertionResult(status.isOk());
33 }
34
getDemuxCaps(DemuxCapabilities & demuxCaps)35 AssertionResult DemuxTests::getDemuxCaps(DemuxCapabilities& demuxCaps) {
36 if (!mDemux) {
37 ALOGW("[vts] Test with openDemux first.");
38 return failure();
39 }
40 auto status = mService->getDemuxCaps(&demuxCaps);
41 return AssertionResult(status.isOk());
42 }
43
getAvSyncId(std::shared_ptr<IFilter> filter,int32_t & avSyncHwId)44 AssertionResult DemuxTests::getAvSyncId(std::shared_ptr<IFilter> filter, int32_t& avSyncHwId) {
45 EXPECT_TRUE(mDemux) << "Demux is not opened yet.";
46
47 auto status = mDemux->getAvSyncHwId(filter, &avSyncHwId);
48 return AssertionResult(status.isOk());
49 }
50
getAvSyncTime(int32_t avSyncId)51 AssertionResult DemuxTests::getAvSyncTime(int32_t avSyncId) {
52 EXPECT_TRUE(mDemux) << "Demux is not opened yet.";
53
54 int64_t syncTime;
55 auto status = mDemux->getAvSyncTime(avSyncId, &syncTime);
56 return AssertionResult(status.isOk());
57 }
58
closeDemux()59 AssertionResult DemuxTests::closeDemux() {
60 EXPECT_TRUE(mDemux) << "Test with openDemux first.";
61 auto status = mDemux->close();
62 mDemux = nullptr;
63 return AssertionResult(status.isOk());
64 }
65