Add Descrambler and Lnb Client interfaces
Test: make libmedia_tv_tuner
Bug: 174095851
Change-Id: I6140f8554b1c45a40cad7b6ba80d48402861ead4
diff --git a/media/jni/Android.bp b/media/jni/Android.bp
index 25b1b40..383389f 100644
--- a/media/jni/Android.bp
+++ b/media/jni/Android.bp
@@ -140,9 +140,11 @@
srcs: [
"android_media_tv_Tuner.cpp",
"tuner/DemuxClient.cpp",
+ "tuner/DescramblerClient.cpp",
"tuner/DvrClient.cpp",
"tuner/FilterClient.cpp",
"tuner/FrontendClient.cpp",
+ "tuner/LnbClient.cpp",
"tuner/TunerClient.cpp",
],
diff --git a/media/jni/tuner/DescramblerClient.cpp b/media/jni/tuner/DescramblerClient.cpp
new file mode 100644
index 0000000..f0ea418b
--- /dev/null
+++ b/media/jni/tuner/DescramblerClient.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "DescramblerClient"
+
+#include <android-base/logging.h>
+#include <utils/Log.h>
+
+#include "DescramblerClient.h"
+
+using ::android::hardware::tv::tuner::V1_0::Result;
+
+namespace android {
+
+/////////////// DescramblerClient ///////////////////////
+
+// TODO: pending aidl interface
+DescramblerClient::DescramblerClient() {
+ //mTunerDescrambler = tunerDescrambler;
+}
+
+DescramblerClient::~DescramblerClient() {
+ //mTunerDescrambler = NULL;
+ mDescrambler = NULL;
+}
+
+// TODO: remove after migration to Tuner Service is done.
+void DescramblerClient::setHidlDescrambler(sp<IDescrambler> descrambler) {
+ mDescrambler = descrambler;
+}
+
+Result DescramblerClient::setDemuxSource(sp<DemuxClient> /*demuxClient*/) {
+ return Result::SUCCESS;
+}
+
+Result DescramblerClient::setKeyToken(vector<uint8_t> /*keyToken*/) {
+ return Result::SUCCESS;
+}
+
+Result DescramblerClient::addPid(DemuxPid /*pid*/, sp<FilterClient> /*optionalSourceFilter*/) {
+ return Result::SUCCESS;
+}
+
+Result DescramblerClient::removePid(DemuxPid /*pid*/, sp<FilterClient> /*optionalSourceFilter*/) {
+ return Result::SUCCESS;
+}
+
+Result DescramblerClient::close() {
+ return Result::SUCCESS;
+}
+
+/////////////// DescramblerClient Helper Methods ///////////////////////
+
+} // namespace android
diff --git a/media/jni/tuner/DescramblerClient.h b/media/jni/tuner/DescramblerClient.h
new file mode 100644
index 0000000..8af6883
--- /dev/null
+++ b/media/jni/tuner/DescramblerClient.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ANDROID_MEDIA_TV_DESCRAMBLER_CLIENT_H_
+#define _ANDROID_MEDIA_TV_DESCRAMBLER_CLIENT_H_
+
+//#include <aidl/android/media/tv/tuner/ITunerDescrambler.h>
+#include <android/hardware/tv/tuner/1.0/IDescrambler.h>
+#include <android/hardware/tv/tuner/1.1/types.h>
+
+#include "DemuxClient.h"
+#include "FilterClient.h"
+
+//using ::aidl::android::media::tv::tuner::ITunerDescrambler;
+
+using ::android::hardware::tv::tuner::V1_0::IDescrambler;
+using ::android::hardware::tv::tuner::V1_0::Result;
+using ::android::hardware::tv::tuner::V1_0::DemuxPid;
+
+using namespace std;
+
+namespace android {
+
+struct DescramblerClient : public RefBase {
+
+public:
+ // TODO: pending hidl interface
+ DescramblerClient();
+ ~DescramblerClient();
+
+ // TODO: remove after migration to Tuner Service is done.
+ void setHidlDescrambler(sp<IDescrambler> descrambler);
+
+ /**
+ * Set a demux as source of the descrambler.
+ */
+ Result setDemuxSource(sp<DemuxClient> demuxClient);
+
+ /**
+ * Set a key token to link descrambler to a key slot.
+ */
+ Result setKeyToken(vector<uint8_t> keyToken);
+
+ /**
+ * Add packets' PID to the descrambler for descrambling.
+ */
+ Result addPid(DemuxPid pid, sp<FilterClient> optionalSourceFilter);
+
+ /**
+ * Remove packets' PID from the descrambler.
+ */
+ Result removePid(DemuxPid pid, sp<FilterClient> optionalSourceFilter);
+
+ /**
+ * Close a new interface of ITunerDescrambler.
+ */
+ Result close();
+
+private:
+ /**
+ * An AIDL Tuner Descrambler Singleton assigned at the first time the Tuner Client
+ * opens a descrambler. Default null when descrambler is not opened.
+ */
+ // TODO: pending on aidl interface
+ //shared_ptr<ITunerDescrambler> mTunerDescrambler;
+
+ /**
+ * A Descrambler HAL interface that is ready before migrating to the TunerDescrambler.
+ * This is a temprary interface before Tuner Framework migrates to use TunerService.
+ * Default null when the HAL service does not exist.
+ */
+ sp<IDescrambler> mDescrambler;
+};
+} // namespace android
+
+#endif // _ANDROID_MEDIA_TV_DESCRAMBLER_CLIENT_H_
diff --git a/media/jni/tuner/LnbClient.cpp b/media/jni/tuner/LnbClient.cpp
new file mode 100644
index 0000000..c9f9f84
--- /dev/null
+++ b/media/jni/tuner/LnbClient.cpp
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "LnbClient"
+
+#include <android-base/logging.h>
+#include <utils/Log.h>
+
+#include "LnbClient.h"
+
+using ::android::hardware::tv::tuner::V1_0::Result;
+
+namespace android {
+
+/////////////// LnbClient ///////////////////////
+
+// TODO: pending aidl interface
+LnbClient::LnbClient() {
+ //mTunerLnb = tunerLnb;
+}
+
+LnbClient::~LnbClient() {
+ //mTunerLnb = NULL;
+ mLnb = NULL;
+}
+
+// TODO: remove after migration to Tuner Service is done.
+void LnbClient::setHidlLnb(sp<ILnb> lnb) {
+ mLnb = lnb;
+}
+
+Result LnbClient::setCallback(sp<LnbClientCallback> /*cb*/) {
+ return Result::SUCCESS;
+}
+
+Result LnbClient::setVoltage(int /*voltage*/) {
+ return Result::SUCCESS;
+}
+
+Result LnbClient::setTone(int /*tone*/) {
+ return Result::SUCCESS;
+}
+
+Result LnbClient::setSatellitePosition(int /*position*/) {
+ return Result::SUCCESS;
+}
+
+Result LnbClient::sendDiseqcMessage(vector<uint8_t> /*diseqcMessage*/) {
+ return Result::SUCCESS;
+}
+
+Result LnbClient::close() {
+ return Result::SUCCESS;
+}
+
+/////////////// ILnbCallback ///////////////////////
+
+HidlLnbCallback::HidlLnbCallback(sp<LnbClientCallback> lnbClientCallback)
+ : mLnbClientCallback(lnbClientCallback) {}
+
+Return<void> HidlLnbCallback::onEvent(const LnbEventType lnbEventType) {
+ if (mLnbClientCallback != NULL) {
+ mLnbClientCallback->onEvent(lnbEventType);
+ }
+ return Void();
+}
+
+Return<void> HidlLnbCallback::onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage) {
+ if (mLnbClientCallback != NULL) {
+ mLnbClientCallback->onDiseqcMessage(diseqcMessage);
+ }
+ return Void();
+}
+
+/////////////// LnbClient Helper Methods ///////////////////////
+
+} // namespace android
diff --git a/media/jni/tuner/LnbClient.h b/media/jni/tuner/LnbClient.h
new file mode 100644
index 0000000..c548777
--- /dev/null
+++ b/media/jni/tuner/LnbClient.h
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ANDROID_MEDIA_TV_LNB_CLIENT_H_
+#define _ANDROID_MEDIA_TV_LNB_CLIENT_H_
+
+//#include <aidl/android/media/tv/tuner/ITunerLnb.h>
+#include <android/hardware/tv/tuner/1.0/ILnb.h>
+#include <android/hardware/tv/tuner/1.0/ILnbCallback.h>
+#include <android/hardware/tv/tuner/1.1/types.h>
+
+#include "LnbClientCallback.h"
+
+//using ::aidl::android::media::tv::tuner::ITunerLnb;
+
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::tv::tuner::V1_0::ILnb;
+using ::android::hardware::tv::tuner::V1_0::ILnbCallback;
+using ::android::hardware::tv::tuner::V1_0::Result;
+
+using namespace std;
+
+namespace android {
+
+// TODO: pending aidl interface
+/*class TunerLnbCallback : public BnTunerLnbCallback {
+
+public:
+ TunerLnbCallback(sp<LnbClientCallback> lnbClientCallback);
+
+ Status onEvent(int lnbEventType);
+ Status onDiseqcMessage(vector<uint8_t> diseqcMessage);
+
+private:
+ sp<LnbClientCallback> mLnbClientCallback;
+};*/
+
+struct HidlLnbCallback : public ILnbCallback {
+
+public:
+ HidlLnbCallback(sp<LnbClientCallback> lnbClientCallback);
+ virtual Return<void> onEvent(const LnbEventType lnbEventType);
+ virtual Return<void> onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
+
+private:
+ sp<LnbClientCallback> mLnbClientCallback;
+};
+
+struct LnbClient : public RefBase {
+
+public:
+ // TODO: add TunerLnb as parameter.
+ LnbClient();
+ ~LnbClient();
+
+ // TODO: remove after migration to Tuner Service is done.
+ void setHidlLnb(sp<ILnb> lnb);
+
+ /**
+ * Set the lnb callback.
+ */
+ Result setCallback(sp<LnbClientCallback> cb);
+
+ /**
+ * Set the lnb's power voltage.
+ */
+ Result setVoltage(int voltage);
+
+ /**
+ * Set the lnb's tone mode.
+ */
+ Result setTone(int tone);
+
+ /**
+ * Select the lnb's position.
+ */
+ Result setSatellitePosition(int position);
+
+ /**
+ * Sends DiSEqC (Digital Satellite Equipment Control) message.
+ */
+ Result sendDiseqcMessage(vector<uint8_t> diseqcMessage);
+
+ /**
+ * Releases the LNB instance.
+ */
+ Result close();
+
+private:
+ /**
+ * An AIDL Tuner Lnb Singleton assigned at the first time the Tuner Client
+ * opens an Lnb. Default null when lnb is not opened.
+ */
+ // TODO: pending on aidl interface
+ //shared_ptr<ITunerLnb> mTunerLnb;
+
+ /**
+ * A Lnb HAL interface that is ready before migrating to the TunerLnb.
+ * This is a temprary interface before Tuner Framework migrates to use TunerService.
+ * Default null when the HAL service does not exist.
+ */
+ sp<ILnb> mLnb;
+};
+} // namespace android
+
+#endif // _ANDROID_MEDIA_TV_LNB_CLIENT_H_
diff --git a/media/jni/tuner/LnbClientCallback.h b/media/jni/tuner/LnbClientCallback.h
new file mode 100644
index 0000000..253d7ef
--- /dev/null
+++ b/media/jni/tuner/LnbClientCallback.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ANDROID_MEDIA_TV_LNB_CLIENT_CALLBACK_H_
+#define _ANDROID_MEDIA_TV_LNB_CLIENT_CALLBACK_H_
+
+using ::android::hardware::hidl_vec;
+using ::android::hardware::tv::tuner::V1_0::LnbEventType;
+
+using namespace std;
+
+namespace android {
+
+struct LnbClientCallback : public RefBase {
+ virtual void onEvent(const LnbEventType lnbEventType);
+ virtual void onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
+};
+} // namespace android
+
+#endif // _ANDROID_MEDIA_TV_LNB_CLIENT_CALLBACK_H_
\ No newline at end of file
diff --git a/media/jni/tuner/TunerClient.cpp b/media/jni/tuner/TunerClient.cpp
index 649828f..67a559c 100644
--- a/media/jni/tuner/TunerClient.cpp
+++ b/media/jni/tuner/TunerClient.cpp
@@ -171,6 +171,23 @@
return NULL;
}
+DemuxCapabilities TunerClient::getDemuxCaps() {
+ DemuxCapabilities caps;
+ return caps;
+}
+
+sp<DescramblerClient> TunerClient::openDescrambler(int /*descramblerHandle*/) {
+ return NULL;
+}
+
+sp<LnbClient> TunerClient::openLnb(int /*lnbHandle*/) {
+ return NULL;
+}
+
+sp<LnbClient> TunerClient::openLnbByName(string /*lnbName*/) {
+ return NULL;
+}
+
/////////////// TunerClient Helper Methods ///////////////////////
sp<ITuner> TunerClient::getHidlTuner() {
diff --git a/media/jni/tuner/TunerClient.h b/media/jni/tuner/TunerClient.h
index 108293b..98ae24d 100644
--- a/media/jni/tuner/TunerClient.h
+++ b/media/jni/tuner/TunerClient.h
@@ -23,6 +23,8 @@
#include "FrontendClient.h"
#include "DemuxClient.h"
+#include "DescramblerClient.h"
+#include "LnbClient.h"
using ::aidl::android::media::tv::tuner::ITunerService;
using ::aidl::android::media::tv::tuner::TunerServiceFrontendInfo;
@@ -94,7 +96,31 @@
*
* @return the demux’s capabilities.
*/
- //DemuxCapabilities getDemuxCaps() {};
+ DemuxCapabilities getDemuxCaps();
+
+ /**
+ * Open a new interface of DescramblerClient given a descramblerHandle.
+ *
+ * @param descramblerHandle the handle of the descrambler granted by TRM.
+ * @return a newly created DescramblerClient interface.
+ */
+ sp<DescramblerClient> openDescrambler(int descramblerHandle);
+
+ /**
+ * Open a new interface of LnbClient given an lnbHandle.
+ *
+ * @param lnbHandle the handle of the LNB granted by TRM.
+ * @return a newly created LnbClient interface.
+ */
+ sp<LnbClient> openLnb(int lnbHandle);
+
+ /**
+ * Open a new interface of LnbClient given a LNB name.
+ *
+ * @param lnbName the name for an external LNB to be opened.
+ * @return a newly created LnbClient interface.
+ */
+ sp<LnbClient> openLnbByName(string lnbName);
/**
* Get the current Tuner HAL version. The high 16 bits are the major version number