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 
getDemuxIds(std::vector<int32_t> & demuxIds)19 AssertionResult DemuxTests::getDemuxIds(std::vector<int32_t>& demuxIds) {
20     ndk::ScopedAStatus status;
21     status = mService->getDemuxIds(&demuxIds);
22     return AssertionResult(status.isOk());
23 }
24 
openDemux(std::shared_ptr<IDemux> & demux,int32_t & demuxId)25 AssertionResult DemuxTests::openDemux(std::shared_ptr<IDemux>& demux, int32_t& demuxId) {
26     std::vector<int32_t> id;
27     auto status = mService->openDemux(&id, &mDemux);
28     if (status.isOk()) {
29         demux = mDemux;
30         demuxId = id[0];
31     }
32     return AssertionResult(status.isOk());
33 }
34 
openDemuxById(int32_t demuxId,std::shared_ptr<IDemux> & demux)35 AssertionResult DemuxTests::openDemuxById(int32_t demuxId, std::shared_ptr<IDemux>& demux) {
36     auto status = mService->openDemuxById(demuxId, &mDemux);
37     if (status.isOk()) {
38         demux = mDemux;
39     }
40     return AssertionResult(status.isOk());
41 }
42 
setDemuxFrontendDataSource(int32_t frontendId)43 AssertionResult DemuxTests::setDemuxFrontendDataSource(int32_t frontendId) {
44     EXPECT_TRUE(mDemux) << "Test with openDemux first.";
45     auto status = mDemux->setFrontendDataSource(frontendId);
46     return AssertionResult(status.isOk());
47 }
48 
getDemuxCaps(DemuxCapabilities & demuxCaps)49 AssertionResult DemuxTests::getDemuxCaps(DemuxCapabilities& demuxCaps) {
50     auto status = mService->getDemuxCaps(&demuxCaps);
51     return AssertionResult(status.isOk());
52 }
53 
getDemuxInfo(int32_t demuxId,DemuxInfo & demuxInfo)54 AssertionResult DemuxTests::getDemuxInfo(int32_t demuxId, DemuxInfo& demuxInfo) {
55     auto status = mService->getDemuxInfo(demuxId, &demuxInfo);
56     return AssertionResult(status.isOk());
57 }
58 
getAvSyncId(std::shared_ptr<IFilter> filter,int32_t & avSyncHwId)59 AssertionResult DemuxTests::getAvSyncId(std::shared_ptr<IFilter> filter, int32_t& avSyncHwId) {
60     EXPECT_TRUE(mDemux) << "Demux is not opened yet.";
61 
62     auto status = mDemux->getAvSyncHwId(filter, &avSyncHwId);
63     return AssertionResult(status.isOk());
64 }
65 
getAvSyncTime(int32_t avSyncId)66 AssertionResult DemuxTests::getAvSyncTime(int32_t avSyncId) {
67     EXPECT_TRUE(mDemux) << "Demux is not opened yet.";
68 
69     int64_t syncTime;
70     auto status = mDemux->getAvSyncTime(avSyncId, &syncTime);
71     return AssertionResult(status.isOk());
72 }
73 
closeDemux()74 AssertionResult DemuxTests::closeDemux() {
75     EXPECT_TRUE(mDemux) << "Test with openDemux first.";
76     auto status = mDemux->close();
77     mDemux = nullptr;
78     return AssertionResult(status.isOk());
79 }
80