blob: 1d9ab53a617b2cb6f97171886263c232c40d5b48 [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:
Hongguang Chenff2c6b02021-08-07 00:12:26 +000037 Frontend(FrontendType type, int32_t id, std::shared_ptr<Tuner> tuner);
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);
Hongguang4092f2f2021-07-08 18:49:12 -070065
66 private:
67 virtual ~Frontend();
68 bool supportsSatellite();
Hongguang6c09bff2021-12-23 10:50:03 -080069 void scanThreadLoop();
70
Hongguang4092f2f2021-07-08 18:49:12 -070071 std::shared_ptr<IFrontendCallback> mCallback;
Hongguang Chenff2c6b02021-08-07 00:12:26 +000072 std::shared_ptr<Tuner> mTuner;
Hongguang4092f2f2021-07-08 18:49:12 -070073 FrontendType mType = FrontendType::UNDEFINED;
74 int32_t mId = 0;
75 bool mIsLocked = false;
76 int32_t mCiCamId;
Hongguang6c09bff2021-12-23 10:50:03 -080077 std::thread mScanThread;
78 FrontendSettings mFrontendSettings;
79 FrontendScanType mFrontendScanType;
Hongguang4092f2f2021-07-08 18:49:12 -070080 std::ifstream mFrontendData;
Hongguang881190f2022-01-14 13:23:37 -080081 FrontendCapabilities mFrontendCaps;
82 vector<FrontendStatusType> mFrontendStatusCaps;
Hongguang4092f2f2021-07-08 18:49:12 -070083};
84
85} // namespace tuner
86} // namespace tv
87} // namespace hardware
88} // namespace android
89} // namespace aidl