blob: 85bd636cc48958651f9d2269a571d860fc44d246 [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/BnFrontend.h>
20#include <fstream>
21#include <iostream>
Hongguang6c09bff2021-12-23 10:50:03 -080022#include <thread>
Hongguang4092f2f2021-07-08 18:49:12 -070023#include "Tuner.h"
24
25using namespace std;
26
27namespace aidl {
28namespace android {
29namespace hardware {
30namespace tv {
31namespace tuner {
32
33class Tuner;
34
35class Frontend : public BnFrontend {
36 public:
Hongguang4a8ac292022-08-09 14:02:03 -070037 Frontend(FrontendType type, int32_t id);
Hongguang4092f2f2021-07-08 18:49:12 -070038
39 ::ndk::ScopedAStatus setCallback(
40 const std::shared_ptr<IFrontendCallback>& in_callback) override;
41 ::ndk::ScopedAStatus tune(const FrontendSettings& in_settings) override;
42 ::ndk::ScopedAStatus stopTune() override;
43 ::ndk::ScopedAStatus close() override;
44 ::ndk::ScopedAStatus scan(const FrontendSettings& in_settings,
45 FrontendScanType in_type) override;
46 ::ndk::ScopedAStatus stopScan() override;
47 ::ndk::ScopedAStatus getStatus(const std::vector<FrontendStatusType>& in_statusTypes,
48 std::vector<FrontendStatus>* _aidl_return) override;
49 ::ndk::ScopedAStatus setLnb(int32_t in_lnbId) override;
Hongguang4092f2f2021-07-08 18:49:12 -070050 ::ndk::ScopedAStatus linkCiCam(int32_t in_ciCamId, int32_t* _aidl_return) override;
51 ::ndk::ScopedAStatus unlinkCiCam(int32_t in_ciCamId) override;
Hongguangfcedda02021-12-13 17:08:02 -080052 ::ndk::ScopedAStatus getHardwareInfo(std::string* _aidl_return) override;
Hongguange106f472022-01-11 12:09:22 -080053 ::ndk::ScopedAStatus removeOutputPid(int32_t in_pid) override;
Hongguang881190f2022-01-14 13:23:37 -080054 ::ndk::ScopedAStatus getFrontendStatusReadiness(
55 const std::vector<FrontendStatusType>& in_statusTypes,
56 std::vector<FrontendStatusReadiness>* _aidl_return) override;
Hongguang4092f2f2021-07-08 18:49:12 -070057
Hongguang2ecfc392021-11-23 10:29:15 -080058 binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
59
Hongguang4092f2f2021-07-08 18:49:12 -070060 FrontendType getFrontendType();
61 int32_t getFrontendId();
62 string getSourceFile();
63 bool isLocked();
Hongguang881190f2022-01-14 13:23:37 -080064 void getFrontendInfo(FrontendInfo* _aidl_return);
Hongguang4a8ac292022-08-09 14:02:03 -070065 void setTunerService(std::shared_ptr<Tuner> tuner);
Hongguang4092f2f2021-07-08 18:49:12 -070066
67 private:
68 virtual ~Frontend();
69 bool supportsSatellite();
Hongguang6c09bff2021-12-23 10:50:03 -080070 void scanThreadLoop();
71
Hongguang4092f2f2021-07-08 18:49:12 -070072 std::shared_ptr<IFrontendCallback> mCallback;
Hongguang Chenff2c6b02021-08-07 00:12:26 +000073 std::shared_ptr<Tuner> mTuner;
Hongguang4092f2f2021-07-08 18:49:12 -070074 FrontendType mType = FrontendType::UNDEFINED;
75 int32_t mId = 0;
76 bool mIsLocked = false;
77 int32_t mCiCamId;
Hongguang6c09bff2021-12-23 10:50:03 -080078 std::thread mScanThread;
79 FrontendSettings mFrontendSettings;
80 FrontendScanType mFrontendScanType;
Hongguang4092f2f2021-07-08 18:49:12 -070081 std::ifstream mFrontendData;
Hongguang881190f2022-01-14 13:23:37 -080082 FrontendCapabilities mFrontendCaps;
83 vector<FrontendStatusType> mFrontendStatusCaps;
Hongguang4092f2f2021-07-08 18:49:12 -070084};
85
86} // namespace tuner
87} // namespace tv
88} // namespace hardware
89} // namespace android
90} // namespace aidl