blob: f42f032cacc2802b3fb21fb4e2e00da0bfb35a31 [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;
shubang4b8c5402019-10-24 17:49:53 -070031using ::android::hardware::tv::tuner::V1_0::FrontendEventType;
shubang7e849b02019-10-18 19:36:25 -070032using ::android::hardware::tv::tuner::V1_0::FrontendId;
shubang4b8c5402019-10-24 17:49:53 -070033using ::android::hardware::tv::tuner::V1_0::FrontendScanMessage;
34using ::android::hardware::tv::tuner::V1_0::FrontendScanMessageType;
shubang6f473d62019-11-01 15:42:21 -070035using ::android::hardware::tv::tuner::V1_0::IDemux;
36using ::android::hardware::tv::tuner::V1_0::IFilter;
37using ::android::hardware::tv::tuner::V1_0::IFilterCallback;
shubang7e849b02019-10-18 19:36:25 -070038using ::android::hardware::tv::tuner::V1_0::IFrontend;
shubang4b8c5402019-10-24 17:49:53 -070039using ::android::hardware::tv::tuner::V1_0::IFrontendCallback;
shubang760f0312019-11-12 17:11:28 -080040using ::android::hardware::tv::tuner::V1_0::ILnb;
41using ::android::hardware::tv::tuner::V1_0::ILnbCallback;
shubang8ab43b12019-10-18 15:55:55 -070042using ::android::hardware::tv::tuner::V1_0::ITuner;
shubang760f0312019-11-12 17:11:28 -080043using ::android::hardware::tv::tuner::V1_0::LnbEventType;
44using ::android::hardware::tv::tuner::V1_0::LnbId;
shubang8ab43b12019-10-18 15:55:55 -070045
46namespace android {
47
shubang760f0312019-11-12 17:11:28 -080048struct LnbCallback : public ILnbCallback {
49 LnbCallback(jweak tunerObj, LnbId id);
50 virtual Return<void> onEvent(LnbEventType lnbEventType);
51 virtual Return<void> onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
52 jweak mObject;
53 LnbId mId;
54};
55
shubang6f473d62019-11-01 15:42:21 -070056struct FilterCallback : public IFilterCallback {
57 virtual Return<void> onFilterEvent(const DemuxFilterEvent& filterEvent);
58 virtual Return<void> onFilterStatus(const DemuxFilterStatus status);
shubangcdf30de2019-11-06 17:28:38 -080059
60 void setFilter(const jobject filter);
61private:
62 jweak mFilter;
shubang6f473d62019-11-01 15:42:21 -070063};
64
shubang4b8c5402019-10-24 17:49:53 -070065struct FrontendCallback : public IFrontendCallback {
66 FrontendCallback(jweak tunerObj, FrontendId id);
67
68 virtual Return<void> onEvent(FrontendEventType frontendEventType);
69 virtual Return<void> onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
70 virtual Return<void> onScanMessage(
71 FrontendScanMessageType type, const FrontendScanMessage& message);
72
73 jweak mObject;
74 FrontendId mId;
75};
76
shubang8ab43b12019-10-18 15:55:55 -070077struct JTuner : public RefBase {
78 JTuner(JNIEnv *env, jobject thiz);
79 sp<ITuner> getTunerService();
shubang7e849b02019-10-18 19:36:25 -070080 jobject getFrontendIds();
81 jobject openFrontendById(int id);
shubang760f0312019-11-12 17:11:28 -080082 jobject getLnbIds();
83 jobject openLnbById(int id);
shubang6f473d62019-11-01 15:42:21 -070084 jobject openFilter(DemuxFilterType type, int bufferSize);
shubang760f0312019-11-12 17:11:28 -080085
shubang8ab43b12019-10-18 15:55:55 -070086protected:
shubang6f473d62019-11-01 15:42:21 -070087 bool openDemux();
shubang8ab43b12019-10-18 15:55:55 -070088 virtual ~JTuner();
89
90private:
91 jclass mClass;
92 jweak mObject;
93 static sp<ITuner> mTuner;
shubang4b8c5402019-10-24 17:49:53 -070094 hidl_vec<FrontendId> mFeIds;
shubang7e849b02019-10-18 19:36:25 -070095 sp<IFrontend> mFe;
shubang760f0312019-11-12 17:11:28 -080096 hidl_vec<LnbId> mLnbIds;
97 sp<ILnb> mLnb;
shubang6f473d62019-11-01 15:42:21 -070098 sp<IDemux> mDemux;
99 int mDemuxId;
shubang8ab43b12019-10-18 15:55:55 -0700100};
101
102} // namespace android
103
104#endif // _ANDROID_MEDIA_TV_TUNER_H_