• 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 #ifndef _ANDROID_MEDIA_TV_LNB_CLIENT_H_
18 #define _ANDROID_MEDIA_TV_LNB_CLIENT_H_
19 
20 #include <aidl/android/hardware/tv/tuner/LnbPosition.h>
21 #include <aidl/android/hardware/tv/tuner/LnbTone.h>
22 #include <aidl/android/hardware/tv/tuner/LnbVoltage.h>
23 #include <aidl/android/media/tv/tuner/BnTunerLnbCallback.h>
24 #include <aidl/android/media/tv/tuner/ITunerLnb.h>
25 #include <utils/RefBase.h>
26 
27 #include "ClientHelper.h"
28 #include "LnbClientCallback.h"
29 
30 using Status = ::ndk::ScopedAStatus;
31 
32 using ::aidl::android::hardware::tv::tuner::LnbPosition;
33 using ::aidl::android::hardware::tv::tuner::LnbTone;
34 using ::aidl::android::hardware::tv::tuner::LnbVoltage;
35 using ::aidl::android::media::tv::tuner::BnTunerLnbCallback;
36 using ::aidl::android::media::tv::tuner::ITunerLnb;
37 
38 using namespace std;
39 
40 namespace android {
41 
42 class TunerLnbCallback : public BnTunerLnbCallback {
43 
44 public:
45     TunerLnbCallback(sp<LnbClientCallback> lnbClientCallback);
46 
47     Status onEvent(LnbEventType lnbEventType);
48     Status onDiseqcMessage(const vector<uint8_t>& diseqcMessage);
49 
50 private:
51     sp<LnbClientCallback> mLnbClientCallback;
52 };
53 
54 struct LnbClient : public RefBase {
55 
56 public:
57     LnbClient(shared_ptr<ITunerLnb> tunerLnb);
58     ~LnbClient();
59 
60     /**
61      * Set the lnb callback.
62      */
63     Result setCallback(sp<LnbClientCallback> cb);
64 
65     /**
66      * Set the lnb's power voltage.
67      */
68     Result setVoltage(LnbVoltage voltage);
69 
70     /**
71      * Set the lnb's tone mode.
72      */
73     Result setTone(LnbTone tone);
74 
75     /**
76      * Select the lnb's position.
77      */
78     Result setSatellitePosition(LnbPosition position);
79 
80     /**
81      * Sends DiSEqC (Digital Satellite Equipment Control) message.
82      */
83     Result sendDiseqcMessage(vector<uint8_t> diseqcMessage);
84 
85     /**
86      * Releases the LNB instance.
87      */
88     Result close();
89 
getAidlLnbLnbClient90     shared_ptr<ITunerLnb> getAidlLnb() { return mTunerLnb; }
91 
92 private:
93     /**
94      * An AIDL Tuner Lnb Singleton assigned at the first time the Tuner Client
95      * opens an Lnb. Default null when lnb is not opened.
96      */
97     shared_ptr<ITunerLnb> mTunerLnb;
98 };
99 }  // namespace android
100 
101 #endif  // _ANDROID_MEDIA_TV_LNB_CLIENT_H_
102