blob: f856791e26184b2843a4495c6bbcf271f1f6b1b3 [file] [log] [blame]
shubang8ab43b12019-10-18 15:55:55 -07001/*
2 * Copyright 2019 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#ifndef _ANDROID_MEDIA_TV_TUNER_H_
18#define _ANDROID_MEDIA_TV_TUNER_H_
19
20#include <android/hardware/tv/tuner/1.0/ITuner.h>
shubang6f473d62019-11-01 15:42:21 -070021#include <unordered_map>
shubang8ab43b12019-10-18 15:55:55 -070022#include <utils/RefBase.h>
23
24#include "jni.h"
25
shubang6f473d62019-11-01 15:42:21 -070026using ::android::hardware::Return;
shubang4b8c5402019-10-24 17:49:53 -070027using ::android::hardware::hidl_vec;
shubang6f473d62019-11-01 15:42:21 -070028using ::android::hardware::tv::tuner::V1_0::DemuxFilterEvent;
29using ::android::hardware::tv::tuner::V1_0::DemuxFilterStatus;
30using ::android::hardware::tv::tuner::V1_0::DemuxFilterType;
shubang13f15e02019-11-04 17:51:02 -080031using ::android::hardware::tv::tuner::V1_0::DemuxPid;
shubang4a0eddf2019-11-08 17:10:18 -080032using ::android::hardware::tv::tuner::V1_0::DvrType;
shubang4b8c5402019-10-24 17:49:53 -070033using ::android::hardware::tv::tuner::V1_0::FrontendEventType;
shubang7e849b02019-10-18 19:36:25 -070034using ::android::hardware::tv::tuner::V1_0::FrontendId;
shubang4b8c5402019-10-24 17:49:53 -070035using ::android::hardware::tv::tuner::V1_0::FrontendScanMessage;
36using ::android::hardware::tv::tuner::V1_0::FrontendScanMessageType;
shubang74bfd482019-10-29 19:10:22 -070037using ::android::hardware::tv::tuner::V1_0::FrontendSettings;
shubang6f473d62019-11-01 15:42:21 -070038using ::android::hardware::tv::tuner::V1_0::IDemux;
shubang13f15e02019-11-04 17:51:02 -080039using ::android::hardware::tv::tuner::V1_0::IDescrambler;
shubang4a0eddf2019-11-08 17:10:18 -080040using ::android::hardware::tv::tuner::V1_0::IDvr;
41using ::android::hardware::tv::tuner::V1_0::IDvrCallback;
shubang6f473d62019-11-01 15:42:21 -070042using ::android::hardware::tv::tuner::V1_0::IFilter;
43using ::android::hardware::tv::tuner::V1_0::IFilterCallback;
shubang7e849b02019-10-18 19:36:25 -070044using ::android::hardware::tv::tuner::V1_0::IFrontend;
shubang4b8c5402019-10-24 17:49:53 -070045using ::android::hardware::tv::tuner::V1_0::IFrontendCallback;
shubang760f0312019-11-12 17:11:28 -080046using ::android::hardware::tv::tuner::V1_0::ILnb;
47using ::android::hardware::tv::tuner::V1_0::ILnbCallback;
shubang8ab43b12019-10-18 15:55:55 -070048using ::android::hardware::tv::tuner::V1_0::ITuner;
shubang760f0312019-11-12 17:11:28 -080049using ::android::hardware::tv::tuner::V1_0::LnbEventType;
50using ::android::hardware::tv::tuner::V1_0::LnbId;
shubang4a0eddf2019-11-08 17:10:18 -080051using ::android::hardware::tv::tuner::V1_0::PlaybackStatus;
52using ::android::hardware::tv::tuner::V1_0::RecordStatus;
shubang8ab43b12019-10-18 15:55:55 -070053
54namespace android {
55
shubang760f0312019-11-12 17:11:28 -080056struct LnbCallback : public ILnbCallback {
57 LnbCallback(jweak tunerObj, LnbId id);
58 virtual Return<void> onEvent(LnbEventType lnbEventType);
59 virtual Return<void> onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
60 jweak mObject;
61 LnbId mId;
62};
63
shubang4a0eddf2019-11-08 17:10:18 -080064struct DvrCallback : public IDvrCallback {
65 virtual Return<void> onRecordStatus(RecordStatus status);
66 virtual Return<void> onPlaybackStatus(PlaybackStatus status);
67
68 void setDvr(const jobject dvr);
69private:
70 jweak mDvr;
71};
72
shubang6f473d62019-11-01 15:42:21 -070073struct FilterCallback : public IFilterCallback {
74 virtual Return<void> onFilterEvent(const DemuxFilterEvent& filterEvent);
75 virtual Return<void> onFilterStatus(const DemuxFilterStatus status);
shubangcdf30de2019-11-06 17:28:38 -080076
77 void setFilter(const jobject filter);
78private:
79 jweak mFilter;
shubang6f473d62019-11-01 15:42:21 -070080};
81
shubang4b8c5402019-10-24 17:49:53 -070082struct FrontendCallback : public IFrontendCallback {
83 FrontendCallback(jweak tunerObj, FrontendId id);
84
85 virtual Return<void> onEvent(FrontendEventType frontendEventType);
86 virtual Return<void> onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
87 virtual Return<void> onScanMessage(
88 FrontendScanMessageType type, const FrontendScanMessage& message);
89
90 jweak mObject;
91 FrontendId mId;
92};
93
shubang8ab43b12019-10-18 15:55:55 -070094struct JTuner : public RefBase {
95 JTuner(JNIEnv *env, jobject thiz);
96 sp<ITuner> getTunerService();
shubang7e849b02019-10-18 19:36:25 -070097 jobject getFrontendIds();
98 jobject openFrontendById(int id);
shubang74bfd482019-10-29 19:10:22 -070099 int tune(const FrontendSettings& settings);
shubang760f0312019-11-12 17:11:28 -0800100 jobject getLnbIds();
101 jobject openLnbById(int id);
shubang6f473d62019-11-01 15:42:21 -0700102 jobject openFilter(DemuxFilterType type, int bufferSize);
shubang13f15e02019-11-04 17:51:02 -0800103 jobject openDescrambler();
shubang4a0eddf2019-11-08 17:10:18 -0800104 jobject openDvr(DvrType type, int bufferSize);
shubang760f0312019-11-12 17:11:28 -0800105
shubang8ab43b12019-10-18 15:55:55 -0700106protected:
shubang6f473d62019-11-01 15:42:21 -0700107 bool openDemux();
shubang8ab43b12019-10-18 15:55:55 -0700108 virtual ~JTuner();
109
110private:
111 jclass mClass;
112 jweak mObject;
113 static sp<ITuner> mTuner;
shubang4b8c5402019-10-24 17:49:53 -0700114 hidl_vec<FrontendId> mFeIds;
shubang7e849b02019-10-18 19:36:25 -0700115 sp<IFrontend> mFe;
shubang760f0312019-11-12 17:11:28 -0800116 hidl_vec<LnbId> mLnbIds;
117 sp<ILnb> mLnb;
shubang6f473d62019-11-01 15:42:21 -0700118 sp<IDemux> mDemux;
119 int mDemuxId;
shubang8ab43b12019-10-18 15:55:55 -0700120};
121
122} // namespace android
123
124#endif // _ANDROID_MEDIA_TV_TUNER_H_