diff --git a/media/jni/Android.bp b/media/jni/Android.bp index 25b1b4026265d..383389f448e8a 100644 --- a/media/jni/Android.bp +++ b/media/jni/Android.bp @@ -140,9 +140,11 @@ cc_library_shared { 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 0000000000000..f0ea418b6587a --- /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 +#include + +#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 descrambler) { + mDescrambler = descrambler; +} + +Result DescramblerClient::setDemuxSource(sp /*demuxClient*/) { + return Result::SUCCESS; +} + +Result DescramblerClient::setKeyToken(vector /*keyToken*/) { + return Result::SUCCESS; +} + +Result DescramblerClient::addPid(DemuxPid /*pid*/, sp /*optionalSourceFilter*/) { + return Result::SUCCESS; +} + +Result DescramblerClient::removePid(DemuxPid /*pid*/, sp /*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 0000000000000..8af688314db18 --- /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 +#include +#include + +#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 descrambler); + + /** + * Set a demux as source of the descrambler. + */ + Result setDemuxSource(sp demuxClient); + + /** + * Set a key token to link descrambler to a key slot. + */ + Result setKeyToken(vector keyToken); + + /** + * Add packets' PID to the descrambler for descrambling. + */ + Result addPid(DemuxPid pid, sp optionalSourceFilter); + + /** + * Remove packets' PID from the descrambler. + */ + Result removePid(DemuxPid pid, sp 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 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 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 0000000000000..c9f9f849df2f7 --- /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 +#include + +#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 lnb) { + mLnb = lnb; +} + +Result LnbClient::setCallback(sp /*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 /*diseqcMessage*/) { + return Result::SUCCESS; +} + +Result LnbClient::close() { + return Result::SUCCESS; +} + +/////////////// ILnbCallback /////////////////////// + +HidlLnbCallback::HidlLnbCallback(sp lnbClientCallback) + : mLnbClientCallback(lnbClientCallback) {} + +Return HidlLnbCallback::onEvent(const LnbEventType lnbEventType) { + if (mLnbClientCallback != NULL) { + mLnbClientCallback->onEvent(lnbEventType); + } + return Void(); +} + +Return HidlLnbCallback::onDiseqcMessage(const hidl_vec& 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 0000000000000..c548777ad40ca --- /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 +#include +#include +#include + +#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); + + Status onEvent(int lnbEventType); + Status onDiseqcMessage(vector diseqcMessage); + +private: + sp mLnbClientCallback; +};*/ + +struct HidlLnbCallback : public ILnbCallback { + +public: + HidlLnbCallback(sp lnbClientCallback); + virtual Return onEvent(const LnbEventType lnbEventType); + virtual Return onDiseqcMessage(const hidl_vec& diseqcMessage); + +private: + sp 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 lnb); + + /** + * Set the lnb callback. + */ + Result setCallback(sp 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 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 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 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 0000000000000..253d7ef110e33 --- /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& 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 649828f50fd4c..67a559cc440ee 100644 --- a/media/jni/tuner/TunerClient.cpp +++ b/media/jni/tuner/TunerClient.cpp @@ -171,6 +171,23 @@ sp TunerClient::openDemux(int /*demuxHandle*/) { return NULL; } +DemuxCapabilities TunerClient::getDemuxCaps() { + DemuxCapabilities caps; + return caps; +} + +sp TunerClient::openDescrambler(int /*descramblerHandle*/) { + return NULL; +} + +sp TunerClient::openLnb(int /*lnbHandle*/) { + return NULL; +} + +sp TunerClient::openLnbByName(string /*lnbName*/) { + return NULL; +} + /////////////// TunerClient Helper Methods /////////////////////// sp TunerClient::getHidlTuner() { diff --git a/media/jni/tuner/TunerClient.h b/media/jni/tuner/TunerClient.h index 108293bfd6014..98ae24df8d4a5 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 @@ public: * * @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 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 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 openLnbByName(string lnbName); /** * Get the current Tuner HAL version. The high 16 bits are the major version number