blob: fdedf1ef6f05eb8b926daa717ef04995104e8775 [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;
Hongguang4092f2f2021-07-08 18:49:12 -070053
Hongguang2ecfc392021-11-23 10:29:15 -080054 binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
55
Hongguang4092f2f2021-07-08 18:49:12 -070056 FrontendType getFrontendType();
57 int32_t getFrontendId();
58 string getSourceFile();
59 bool isLocked();
60
61 private:
62 virtual ~Frontend();
63 bool supportsSatellite();
Hongguang6c09bff2021-12-23 10:50:03 -080064 void scanThreadLoop();
65
Hongguang4092f2f2021-07-08 18:49:12 -070066 std::shared_ptr<IFrontendCallback> mCallback;
Hongguang Chenff2c6b02021-08-07 00:12:26 +000067 std::shared_ptr<Tuner> mTuner;
Hongguang4092f2f2021-07-08 18:49:12 -070068 FrontendType mType = FrontendType::UNDEFINED;
69 int32_t mId = 0;
70 bool mIsLocked = false;
71 int32_t mCiCamId;
Hongguang6c09bff2021-12-23 10:50:03 -080072 std::thread mScanThread;
73 FrontendSettings mFrontendSettings;
74 FrontendScanType mFrontendScanType;
Hongguang4092f2f2021-07-08 18:49:12 -070075 std::ifstream mFrontendData;
76};
77
78} // namespace tuner
79} // namespace tv
80} // namespace hardware
81} // namespace android
82} // namespace aidl