blob: 17a1aeeb40b043709608eadcf1de429d7c0a36d0 [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"
sadiqsada56c98292023-11-02 16:45:31 -070024#include "dtv_plugin.h"
Hongguang4092f2f2021-07-08 18:49:12 -070025
26using namespace std;
27
28namespace aidl {
29namespace android {
30namespace hardware {
31namespace tv {
32namespace tuner {
33
34class Tuner;
35
36class Frontend : public BnFrontend {
37 public:
Hongguang4a8ac292022-08-09 14:02:03 -070038 Frontend(FrontendType type, int32_t id);
Hongguang4092f2f2021-07-08 18:49:12 -070039
40 ::ndk::ScopedAStatus setCallback(
41 const std::shared_ptr<IFrontendCallback>& in_callback) override;
42 ::ndk::ScopedAStatus tune(const FrontendSettings& in_settings) override;
43 ::ndk::ScopedAStatus stopTune() override;
44 ::ndk::ScopedAStatus close() override;
45 ::ndk::ScopedAStatus scan(const FrontendSettings& in_settings,
46 FrontendScanType in_type) override;
47 ::ndk::ScopedAStatus stopScan() override;
48 ::ndk::ScopedAStatus getStatus(const std::vector<FrontendStatusType>& in_statusTypes,
49 std::vector<FrontendStatus>* _aidl_return) override;
50 ::ndk::ScopedAStatus setLnb(int32_t in_lnbId) override;
Hongguang4092f2f2021-07-08 18:49:12 -070051 ::ndk::ScopedAStatus linkCiCam(int32_t in_ciCamId, int32_t* _aidl_return) override;
52 ::ndk::ScopedAStatus unlinkCiCam(int32_t in_ciCamId) override;
Hongguangfcedda02021-12-13 17:08:02 -080053 ::ndk::ScopedAStatus getHardwareInfo(std::string* _aidl_return) override;
Hongguange106f472022-01-11 12:09:22 -080054 ::ndk::ScopedAStatus removeOutputPid(int32_t in_pid) override;
Hongguang881190f2022-01-14 13:23:37 -080055 ::ndk::ScopedAStatus getFrontendStatusReadiness(
56 const std::vector<FrontendStatusType>& in_statusTypes,
57 std::vector<FrontendStatusReadiness>* _aidl_return) override;
Hongguang4092f2f2021-07-08 18:49:12 -070058
Hongguang2ecfc392021-11-23 10:29:15 -080059 binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
60
Hongguang4092f2f2021-07-08 18:49:12 -070061 FrontendType getFrontendType();
62 int32_t getFrontendId();
63 string getSourceFile();
sadiqsada56c98292023-11-02 16:45:31 -070064 dtv_plugin* getIptvPluginInterface();
65 string getIptvTransportDescription();
66 dtv_streamer* getIptvPluginStreamer();
67 void readTuneByte(dtv_streamer* streamer, void* buf, size_t size, int timeout_ms);
Hongguang4092f2f2021-07-08 18:49:12 -070068 bool isLocked();
Hongguang881190f2022-01-14 13:23:37 -080069 void getFrontendInfo(FrontendInfo* _aidl_return);
Hongguang4a8ac292022-08-09 14:02:03 -070070 void setTunerService(std::shared_ptr<Tuner> tuner);
Hongguang4092f2f2021-07-08 18:49:12 -070071
72 private:
73 virtual ~Frontend();
74 bool supportsSatellite();
Hongguang6c09bff2021-12-23 10:50:03 -080075 void scanThreadLoop();
76
Hongguang4092f2f2021-07-08 18:49:12 -070077 std::shared_ptr<IFrontendCallback> mCallback;
Hongguang Chenff2c6b02021-08-07 00:12:26 +000078 std::shared_ptr<Tuner> mTuner;
Hongguang4092f2f2021-07-08 18:49:12 -070079 FrontendType mType = FrontendType::UNDEFINED;
80 int32_t mId = 0;
81 bool mIsLocked = false;
82 int32_t mCiCamId;
Hongguang6c09bff2021-12-23 10:50:03 -080083 std::thread mScanThread;
84 FrontendSettings mFrontendSettings;
85 FrontendScanType mFrontendScanType;
Hongguang4092f2f2021-07-08 18:49:12 -070086 std::ifstream mFrontendData;
Hongguang881190f2022-01-14 13:23:37 -080087 FrontendCapabilities mFrontendCaps;
88 vector<FrontendStatusType> mFrontendStatusCaps;
sadiqsada56c98292023-11-02 16:45:31 -070089 dtv_plugin* mIptvPluginInterface;
90 string mIptvTransportDescription;
91 dtv_streamer* mIptvPluginStreamer;
92 std::thread mIptvFrontendTuneThread;
Hongguang4092f2f2021-07-08 18:49:12 -070093};
94
95} // namespace tuner
96} // namespace tv
97} // namespace hardware
98} // namespace android
99} // namespace aidl