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 
openDemux(sp<IDemux> & demux,uint32_t & demuxId)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 
setDemuxFrontendDataSource(uint32_t frontendId)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 
closeDemux()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());
41 }