Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 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 | #pragma once |
| 18 | |
| 19 | #include <aidl/android/hardware/tv/tuner/BnTuner.h> |
| 20 | #include <aidl/android/hardware/tv/tuner/FrontendCapabilities.h> |
| 21 | |
| 22 | #include <map> |
| 23 | #include "Demux.h" |
| 24 | #include "Frontend.h" |
| 25 | #include "Lnb.h" |
| 26 | |
| 27 | using namespace std; |
| 28 | |
| 29 | namespace aidl { |
| 30 | namespace android { |
| 31 | namespace hardware { |
| 32 | namespace tv { |
| 33 | namespace tuner { |
| 34 | |
| 35 | class Frontend; |
| 36 | class Demux; |
| 37 | class Lnb; |
| 38 | |
| 39 | class Tuner : public BnTuner { |
| 40 | public: |
| 41 | Tuner(); |
| 42 | virtual ~Tuner(); |
| 43 | |
| 44 | ::ndk::ScopedAStatus getFrontendIds(std::vector<int32_t>* _aidl_return) override; |
| 45 | ::ndk::ScopedAStatus openFrontendById(int32_t in_frontendId, |
| 46 | std::shared_ptr<IFrontend>* _aidl_return) override; |
| 47 | ::ndk::ScopedAStatus openDemux(std::vector<int32_t>* out_demuxId, |
| 48 | std::shared_ptr<IDemux>* _aidl_return) override; |
| 49 | ::ndk::ScopedAStatus getDemuxCaps(DemuxCapabilities* _aidl_return) override; |
| 50 | ::ndk::ScopedAStatus openDescrambler(std::shared_ptr<IDescrambler>* _aidl_return) override; |
| 51 | ::ndk::ScopedAStatus getFrontendInfo(int32_t in_frontendId, |
| 52 | FrontendInfo* _aidl_return) override; |
| 53 | ::ndk::ScopedAStatus getLnbIds(std::vector<int32_t>* _aidl_return) override; |
| 54 | ::ndk::ScopedAStatus openLnbById(int32_t in_lnbId, |
| 55 | std::shared_ptr<ILnb>* _aidl_return) override; |
| 56 | ::ndk::ScopedAStatus openLnbByName(const std::string& in_lnbName, |
| 57 | std::vector<int32_t>* out_lnbId, |
| 58 | std::shared_ptr<ILnb>* _aidl_return) override; |
| 59 | |
| 60 | std::shared_ptr<Frontend> getFrontendById(int32_t frontendId); |
| 61 | void setFrontendAsDemuxSource(int32_t frontendId, int32_t demuxId); |
| 62 | void frontendStartTune(int32_t frontendId); |
| 63 | void frontendStopTune(int32_t frontendId); |
| 64 | void removeDemux(int32_t demuxId); |
| 65 | void removeFrontend(int32_t frontendId); |
Hongguang Chen | ff2c6b0 | 2021-08-07 00:12:26 +0000 | [diff] [blame^] | 66 | void init(); |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 67 | |
| 68 | private: |
| 69 | // Static mFrontends array to maintain local frontends information |
| 70 | map<int32_t, std::shared_ptr<Frontend>> mFrontends; |
| 71 | map<int32_t, FrontendCapabilities> mFrontendCaps; |
| 72 | map<int32_t, vector<FrontendStatusType>> mFrontendStatusCaps; |
| 73 | map<int32_t, int32_t> mFrontendToDemux; |
| 74 | map<int32_t, std::shared_ptr<Demux>> mDemuxes; |
| 75 | // To maintain how many Frontends we have |
| 76 | int mFrontendSize; |
| 77 | // The last used demux id. Initial value is -1. |
| 78 | // First used id will be 0. |
| 79 | int32_t mLastUsedId = -1; |
| 80 | vector<std::shared_ptr<Lnb>> mLnbs; |
| 81 | }; |
| 82 | |
| 83 | } // namespace tuner |
| 84 | } // namespace tv |
| 85 | } // namespace hardware |
| 86 | } // namespace android |
| 87 | } // namespace aidl |