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/BnFrontend.h> |
| 20 | #include <fstream> |
| 21 | #include <iostream> |
Hongguang | 6c09bff | 2021-12-23 10:50:03 -0800 | [diff] [blame^] | 22 | #include <thread> |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 23 | #include "Tuner.h" |
| 24 | |
| 25 | using namespace std; |
| 26 | |
| 27 | namespace aidl { |
| 28 | namespace android { |
| 29 | namespace hardware { |
| 30 | namespace tv { |
| 31 | namespace tuner { |
| 32 | |
| 33 | class Tuner; |
| 34 | |
| 35 | class Frontend : public BnFrontend { |
| 36 | public: |
Hongguang Chen | ff2c6b0 | 2021-08-07 00:12:26 +0000 | [diff] [blame] | 37 | Frontend(FrontendType type, int32_t id, std::shared_ptr<Tuner> tuner); |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 38 | |
| 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; |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 50 | ::ndk::ScopedAStatus linkCiCam(int32_t in_ciCamId, int32_t* _aidl_return) override; |
| 51 | ::ndk::ScopedAStatus unlinkCiCam(int32_t in_ciCamId) override; |
Hongguang | fcedda0 | 2021-12-13 17:08:02 -0800 | [diff] [blame] | 52 | ::ndk::ScopedAStatus getHardwareInfo(std::string* _aidl_return) override; |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 53 | |
Hongguang | 2ecfc39 | 2021-11-23 10:29:15 -0800 | [diff] [blame] | 54 | binder_status_t dump(int fd, const char** args, uint32_t numArgs) override; |
| 55 | |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 56 | FrontendType getFrontendType(); |
| 57 | int32_t getFrontendId(); |
| 58 | string getSourceFile(); |
| 59 | bool isLocked(); |
| 60 | |
| 61 | private: |
| 62 | virtual ~Frontend(); |
| 63 | bool supportsSatellite(); |
Hongguang | 6c09bff | 2021-12-23 10:50:03 -0800 | [diff] [blame^] | 64 | void scanThreadLoop(); |
| 65 | |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 66 | std::shared_ptr<IFrontendCallback> mCallback; |
Hongguang Chen | ff2c6b0 | 2021-08-07 00:12:26 +0000 | [diff] [blame] | 67 | std::shared_ptr<Tuner> mTuner; |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 68 | FrontendType mType = FrontendType::UNDEFINED; |
| 69 | int32_t mId = 0; |
| 70 | bool mIsLocked = false; |
| 71 | int32_t mCiCamId; |
Hongguang | 6c09bff | 2021-12-23 10:50:03 -0800 | [diff] [blame^] | 72 | std::thread mScanThread; |
| 73 | FrontendSettings mFrontendSettings; |
| 74 | FrontendScanType mFrontendScanType; |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 75 | std::ifstream mFrontendData; |
| 76 | }; |
| 77 | |
| 78 | } // namespace tuner |
| 79 | } // namespace tv |
| 80 | } // namespace hardware |
| 81 | } // namespace android |
| 82 | } // namespace aidl |