blob: 26569336ef8b6d1b1d5743ab47ce689efc0a1ef9 [file] [log] [blame]
Hongguang4092f2f2021-07-08 18:49:12 -07001/*
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
27using namespace std;
28
29namespace aidl {
30namespace android {
31namespace hardware {
32namespace tv {
33namespace tuner {
34
35class Frontend;
36class Demux;
37class Lnb;
38
39class 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;
Kensuke Miyagi73b18ac2022-11-07 10:49:09 -080049 ::ndk::ScopedAStatus openDemuxById(int32_t in_demuxId,
50 std::shared_ptr<IDemux>* _aidl_return) override;
Hongguang4092f2f2021-07-08 18:49:12 -070051 ::ndk::ScopedAStatus getDemuxCaps(DemuxCapabilities* _aidl_return) override;
Kensuke Miyagi73b18ac2022-11-07 10:49:09 -080052 ::ndk::ScopedAStatus getDemuxInfo(int32_t in_demuxId, DemuxInfo* _aidl_return) override;
53 ::ndk::ScopedAStatus getDemuxIds(std::vector<int32_t>* _aidl_return) override;
Hongguang4092f2f2021-07-08 18:49:12 -070054 ::ndk::ScopedAStatus openDescrambler(std::shared_ptr<IDescrambler>* _aidl_return) override;
55 ::ndk::ScopedAStatus getFrontendInfo(int32_t in_frontendId,
56 FrontendInfo* _aidl_return) override;
57 ::ndk::ScopedAStatus getLnbIds(std::vector<int32_t>* _aidl_return) override;
58 ::ndk::ScopedAStatus openLnbById(int32_t in_lnbId,
59 std::shared_ptr<ILnb>* _aidl_return) override;
60 ::ndk::ScopedAStatus openLnbByName(const std::string& in_lnbName,
61 std::vector<int32_t>* out_lnbId,
62 std::shared_ptr<ILnb>* _aidl_return) override;
Hongguangfcedda02021-12-13 17:08:02 -080063 ::ndk::ScopedAStatus setLna(bool in_bEnable) override;
Hongguang5766ddf2021-12-23 11:40:37 -080064 ::ndk::ScopedAStatus setMaxNumberOfFrontends(FrontendType in_frontendType,
65 int32_t in_maxNumber) override;
66 ::ndk::ScopedAStatus getMaxNumberOfFrontends(FrontendType in_frontendType,
67 int32_t* _aidl_return) override;
Ray Chin8fe32b22022-11-01 11:51:23 +080068 ::ndk::ScopedAStatus isLnaSupported(bool* _aidl_return) override;
Hongguang4092f2f2021-07-08 18:49:12 -070069
Hongguang2ecfc392021-11-23 10:29:15 -080070 binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
71
Hongguang4092f2f2021-07-08 18:49:12 -070072 std::shared_ptr<Frontend> getFrontendById(int32_t frontendId);
73 void setFrontendAsDemuxSource(int32_t frontendId, int32_t demuxId);
74 void frontendStartTune(int32_t frontendId);
75 void frontendStopTune(int32_t frontendId);
76 void removeDemux(int32_t demuxId);
77 void removeFrontend(int32_t frontendId);
Hongguang Chenff2c6b02021-08-07 00:12:26 +000078 void init();
Hongguang4092f2f2021-07-08 18:49:12 -070079
80 private:
81 // Static mFrontends array to maintain local frontends information
82 map<int32_t, std::shared_ptr<Frontend>> mFrontends;
Hongguang4092f2f2021-07-08 18:49:12 -070083 map<int32_t, int32_t> mFrontendToDemux;
Kensuke Miyagi73b18ac2022-11-07 10:49:09 -080084 map<int32_t, std::shared_ptr<Demux>> mDemuxes; // use demuxId as the key in
85 // this sample implementation
Hongguang4092f2f2021-07-08 18:49:12 -070086 // To maintain how many Frontends we have
87 int mFrontendSize;
Hongguang4092f2f2021-07-08 18:49:12 -070088 vector<std::shared_ptr<Lnb>> mLnbs;
Hongguang5766ddf2021-12-23 11:40:37 -080089 map<FrontendType, int32_t> mMaxUsableFrontends;
Hongguang4092f2f2021-07-08 18:49:12 -070090};
91
92} // namespace tuner
93} // namespace tv
94} // namespace hardware
95} // namespace android
96} // namespace aidl