• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>
22 #include <thread>
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:
37     Frontend(FrontendType type, int32_t id);
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;
50     ::ndk::ScopedAStatus linkCiCam(int32_t in_ciCamId, int32_t* _aidl_return) override;
51     ::ndk::ScopedAStatus unlinkCiCam(int32_t in_ciCamId) override;
52     ::ndk::ScopedAStatus getHardwareInfo(std::string* _aidl_return) override;
53     ::ndk::ScopedAStatus removeOutputPid(int32_t in_pid) override;
54     ::ndk::ScopedAStatus getFrontendStatusReadiness(
55             const std::vector<FrontendStatusType>& in_statusTypes,
56             std::vector<FrontendStatusReadiness>* _aidl_return) override;
57 
58     binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
59 
60     FrontendType getFrontendType();
61     int32_t getFrontendId();
62     string getSourceFile();
63     bool isLocked();
64     void getFrontendInfo(FrontendInfo* _aidl_return);
65     void setTunerService(std::shared_ptr<Tuner> tuner);
66 
67   private:
68     virtual ~Frontend();
69     bool supportsSatellite();
70     void scanThreadLoop();
71 
72     std::shared_ptr<IFrontendCallback> mCallback;
73     std::shared_ptr<Tuner> mTuner;
74     FrontendType mType = FrontendType::UNDEFINED;
75     int32_t mId = 0;
76     bool mIsLocked = false;
77     int32_t mCiCamId;
78     std::thread mScanThread;
79     FrontendSettings mFrontendSettings;
80     FrontendScanType mFrontendScanType;
81     std::ifstream mFrontendData;
82     FrontendCapabilities mFrontendCaps;
83     vector<FrontendStatusType> mFrontendStatusCaps;
84 };
85 
86 }  // namespace tuner
87 }  // namespace tv
88 }  // namespace hardware
89 }  // namespace android
90 }  // namespace aidl
91