New TunerService implemented by AIDL HAL.
TODO: add backward HIDL HAL support to separate files.
Bug: 191825295
Test: atest android.media.tv.tuner.cts
Change-Id: I8400fd75080971ee897e1e2dc35e2bab45ec1659
diff --git a/services/tuner/.clang-format b/services/tuner/.clang-format
new file mode 100644
index 0000000..f14cc88
--- /dev/null
+++ b/services/tuner/.clang-format
@@ -0,0 +1,33 @@
+---
+BasedOnStyle: Google
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortIfStatementsOnASingleLine: true
+AllowShortLoopsOnASingleLine: true
+BinPackArguments: true
+BinPackParameters: true
+CommentPragmas: NOLINT:.*
+ContinuationIndentWidth: 8
+DerivePointerAlignment: false
+IndentWidth: 4
+PointerAlignment: Left
+TabWidth: 4
+
+# Deviations from the above file:
+# "Don't indent the section label"
+AccessModifierOffset: -4
+# "Each line of text in your code should be at most 100 columns long."
+ColumnLimit: 100
+# "Constructor initializer lists can be all on one line or with subsequent
+# lines indented eight spaces.". clang-format does not support having the colon
+# on the same line as the constructor function name, so this is the best
+# approximation of that rule, which makes all entries in the list (except the
+# first one) have an eight space indentation.
+ConstructorInitializerIndentWidth: 6
+# There is nothing in go/droidcppstyle about case labels, but there seems to be
+# more code that does not indent the case labels in frameworks/base.
+IndentCaseLabels: false
+# There have been some bugs in which subsequent formatting operations introduce
+# weird comment jumps.
+ReflowComments: false
+# Android does support C++11 now.
+Standard: Cpp11
\ No newline at end of file
diff --git a/services/tuner/OWNERS b/services/tuner/OWNERS
index 0ceb8e8..bf9fe34 100644
--- a/services/tuner/OWNERS
+++ b/services/tuner/OWNERS
@@ -1,2 +1,2 @@
-nchalko@google.com
+hgchen@google.com
quxiangfang@google.com
diff --git a/services/tuner/TunerDemux.cpp b/services/tuner/TunerDemux.cpp
index 99032ad..34efe01 100644
--- a/services/tuner/TunerDemux.cpp
+++ b/services/tuner/TunerDemux.cpp
@@ -16,23 +16,32 @@
#define LOG_TAG "TunerDemux"
-#include "TunerDvr.h"
#include "TunerDemux.h"
+
+#include <aidl/android/hardware/tv/tuner/IDvr.h>
+#include <aidl/android/hardware/tv/tuner/IDvrCallback.h>
+#include <aidl/android/hardware/tv/tuner/IFilter.h>
+#include <aidl/android/hardware/tv/tuner/IFilterCallback.h>
+#include <aidl/android/hardware/tv/tuner/ITimeFilter.h>
+#include <aidl/android/hardware/tv/tuner/Result.h>
+
+#include "TunerDvr.h"
#include "TunerTimeFilter.h"
-using ::android::hardware::tv::tuner::V1_0::DemuxAlpFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxIpFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxMmtpFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxTlvFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
-using ::android::hardware::tv::tuner::V1_0::DvrType;
-using ::android::hardware::tv::tuner::V1_0::Result;
+using ::aidl::android::hardware::tv::tuner::IDvr;
+using ::aidl::android::hardware::tv::tuner::IDvrCallback;
+using ::aidl::android::hardware::tv::tuner::IFilter;
+using ::aidl::android::hardware::tv::tuner::IFilterCallback;
+using ::aidl::android::hardware::tv::tuner::ITimeFilter;
+using ::aidl::android::hardware::tv::tuner::Result;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-TunerDemux::TunerDemux(sp<IDemux> demux, int id) {
+TunerDemux::TunerDemux(shared_ptr<IDemux> demux, int id) {
mDemux = demux;
mDemuxId = id;
}
@@ -41,205 +50,141 @@
mDemux = nullptr;
}
-Status TunerDemux::setFrontendDataSource(const std::shared_ptr<ITunerFrontend>& frontend) {
+::ndk::ScopedAStatus TunerDemux::setFrontendDataSource(
+ const shared_ptr<ITunerFrontend>& in_frontend) {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
int frontendId;
- frontend->getFrontendId(&frontendId);
- Result res = mDemux->setFrontendDataSource(frontendId);
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ in_frontend->getFrontendId(&frontendId);
+
+ return mDemux->setFrontendDataSource(frontendId);
}
-Status TunerDemux::setFrontendDataSourceById(int frontendId) {
+::ndk::ScopedAStatus TunerDemux::setFrontendDataSourceById(int frontendId) {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDemux->setFrontendDataSource(frontendId);
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDemux->setFrontendDataSource(frontendId);
}
-Status TunerDemux::openFilter(
- int type, int subType, int bufferSize, const std::shared_ptr<ITunerFilterCallback>& cb,
- std::shared_ptr<ITunerFilter>* _aidl_return) {
+::ndk::ScopedAStatus TunerDemux::openFilter(const DemuxFilterType& in_type, int32_t in_bufferSize,
+ const shared_ptr<ITunerFilterCallback>& in_cb,
+ shared_ptr<ITunerFilter>* _aidl_return) {
+ if (mDemux == nullptr) {
+ ALOGE("IDemux is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ shared_ptr<IFilter> filter;
+ shared_ptr<IFilterCallback> cb = ::ndk::SharedRefBase::make<TunerFilter::FilterCallback>(in_cb);
+ auto status = mDemux->openFilter(in_type, in_bufferSize, cb, &filter);
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerFilter>(filter, in_type);
+ }
+
+ return status;
+}
+
+::ndk::ScopedAStatus TunerDemux::openTimeFilter(shared_ptr<ITunerTimeFilter>* _aidl_return) {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- DemuxFilterMainType mainType = static_cast<DemuxFilterMainType>(type);
- DemuxFilterType filterType {
- .mainType = mainType,
- };
-
- switch(mainType) {
- case DemuxFilterMainType::TS:
- filterType.subType.tsFilterType(static_cast<DemuxTsFilterType>(subType));
- break;
- case DemuxFilterMainType::MMTP:
- filterType.subType.mmtpFilterType(static_cast<DemuxMmtpFilterType>(subType));
- break;
- case DemuxFilterMainType::IP:
- filterType.subType.ipFilterType(static_cast<DemuxIpFilterType>(subType));
- break;
- case DemuxFilterMainType::TLV:
- filterType.subType.tlvFilterType(static_cast<DemuxTlvFilterType>(subType));
- break;
- case DemuxFilterMainType::ALP:
- filterType.subType.alpFilterType(static_cast<DemuxAlpFilterType>(subType));
- break;
- }
- Result status;
- sp<IFilter> filterSp;
- sp<IFilterCallback> cbSp = new TunerFilter::FilterCallback(cb);
- mDemux->openFilter(filterType, bufferSize, cbSp,
- [&](Result r, const sp<IFilter>& filter) {
- filterSp = filter;
- status = r;
- });
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ shared_ptr<ITimeFilter> filter;
+ auto status = mDemux->openTimeFilter(&filter);
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerTimeFilter>(filter);
}
- *_aidl_return = ::ndk::SharedRefBase::make<TunerFilter>(filterSp, type, subType);
- return Status::ok();
+ return status;
}
-Status TunerDemux::openTimeFilter(shared_ptr<ITunerTimeFilter>* _aidl_return) {
+::ndk::ScopedAStatus TunerDemux::getAvSyncHwId(const shared_ptr<ITunerFilter>& tunerFilter,
+ int32_t* _aidl_return) {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status;
- sp<ITimeFilter> filterSp;
- mDemux->openTimeFilter([&](Result r, const sp<ITimeFilter>& filter) {
- filterSp = filter;
- status = r;
- });
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
-
- *_aidl_return = ::ndk::SharedRefBase::make<TunerTimeFilter>(filterSp);
- return Status::ok();
+ shared_ptr<IFilter> halFilter = (static_cast<TunerFilter*>(tunerFilter.get()))->getHalFilter();
+ return mDemux->getAvSyncHwId(halFilter, _aidl_return);
}
-Status TunerDemux::getAvSyncHwId(const shared_ptr<ITunerFilter>& tunerFilter, int* _aidl_return) {
+::ndk::ScopedAStatus TunerDemux::getAvSyncTime(int32_t avSyncHwId, int64_t* _aidl_return) {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- uint32_t avSyncHwId;
- Result res;
- sp<IFilter> halFilter = static_cast<TunerFilter*>(tunerFilter.get())->getHalFilter();
- mDemux->getAvSyncHwId(halFilter,
- [&](Result r, uint32_t id) {
- res = r;
- avSyncHwId = id;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- *_aidl_return = (int)avSyncHwId;
- return Status::ok();
+ return mDemux->getAvSyncTime(avSyncHwId, _aidl_return);
}
-Status TunerDemux::getAvSyncTime(int avSyncHwId, int64_t* _aidl_return) {
+::ndk::ScopedAStatus TunerDemux::openDvr(DvrType in_dvbType, int32_t in_bufferSize,
+ const shared_ptr<ITunerDvrCallback>& in_cb,
+ shared_ptr<ITunerDvr>* _aidl_return) {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- uint64_t time;
- Result res;
- mDemux->getAvSyncTime(static_cast<uint32_t>(avSyncHwId),
- [&](Result r, uint64_t ts) {
- res = r;
- time = ts;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
+ shared_ptr<IDvrCallback> callback = ::ndk::SharedRefBase::make<TunerDvr::DvrCallback>(in_cb);
+ shared_ptr<IDvr> halDvr;
+ auto res = mDemux->openDvr(in_dvbType, in_bufferSize, callback, &halDvr);
+ if (res.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerDvr>(halDvr, in_dvbType);
}
- *_aidl_return = (int64_t)time;
- return Status::ok();
+ return res;
}
-Status TunerDemux::openDvr(int dvrType, int bufferSize, const shared_ptr<ITunerDvrCallback>& cb,
- shared_ptr<ITunerDvr>* _aidl_return) {
+::ndk::ScopedAStatus TunerDemux::connectCiCam(int32_t ciCamId) {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res;
- sp<IDvrCallback> callback = new TunerDvr::DvrCallback(cb);
- sp<IDvr> hidlDvr;
- mDemux->openDvr(static_cast<DvrType>(dvrType), bufferSize, callback,
- [&](Result r, const sp<IDvr>& dvr) {
- hidlDvr = dvr;
- res = r;
- });
- if (res != Result::SUCCESS) {
- *_aidl_return = NULL;
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- *_aidl_return = ::ndk::SharedRefBase::make<TunerDvr>(hidlDvr, dvrType);
- return Status::ok();
+ return mDemux->connectCiCam(ciCamId);
}
-Status TunerDemux::connectCiCam(int ciCamId) {
+::ndk::ScopedAStatus TunerDemux::disconnectCiCam() {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDemux->connectCiCam(static_cast<uint32_t>(ciCamId));
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDemux->disconnectCiCam();
}
-Status TunerDemux::disconnectCiCam() {
+::ndk::ScopedAStatus TunerDemux::close() {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDemux->disconnectCiCam();
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ auto res = mDemux->close();
+ mDemux = nullptr;
+
+ return res;
}
-Status TunerDemux::close() {
- if (mDemux == nullptr) {
- ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- Result res = mDemux->close();
- mDemux = NULL;
-
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
-}
+} // namespace tuner
+} // namespace tv
+} // namespace media
} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerDemux.h b/services/tuner/TunerDemux.h
index c2f91f0..cdb3aa0 100644
--- a/services/tuner/TunerDemux.h
+++ b/services/tuner/TunerDemux.h
@@ -17,53 +17,55 @@
#ifndef ANDROID_MEDIA_TUNERDEMUX_H
#define ANDROID_MEDIA_TUNERDEMUX_H
+#include <aidl/android/hardware/tv/tuner/IDemux.h>
#include <aidl/android/media/tv/tuner/BnTunerDemux.h>
-#include <android/hardware/tv/tuner/1.0/ITuner.h>
-using Status = ::ndk::ScopedAStatus;
-using ::aidl::android::media::tv::tuner::BnTunerDemux;
-using ::aidl::android::media::tv::tuner::ITunerDvr;
-using ::aidl::android::media::tv::tuner::ITunerDvrCallback;
-using ::aidl::android::media::tv::tuner::ITunerFilter;
-using ::aidl::android::media::tv::tuner::ITunerFilterCallback;
-using ::aidl::android::media::tv::tuner::ITunerFrontend;
-using ::aidl::android::media::tv::tuner::ITunerTimeFilter;
-using ::android::hardware::tv::tuner::V1_0::IDemux;
-using ::android::hardware::tv::tuner::V1_0::IDvr;
-using ::android::hardware::tv::tuner::V1_0::IDvrCallback;
-using ::android::hardware::tv::tuner::V1_0::ITimeFilter;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterType;
+using ::aidl::android::hardware::tv::tuner::DvrType;
+using ::aidl::android::hardware::tv::tuner::IDemux;
using namespace std;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
class TunerDemux : public BnTunerDemux {
public:
- TunerDemux(sp<IDemux> demux, int demuxId);
+ TunerDemux(shared_ptr<IDemux> demux, int demuxId);
virtual ~TunerDemux();
- Status setFrontendDataSource(const shared_ptr<ITunerFrontend>& frontend) override;
- Status setFrontendDataSourceById(int frontendId) override;
- Status openFilter(
- int mainType, int subtype, int bufferSize, const shared_ptr<ITunerFilterCallback>& cb,
- shared_ptr<ITunerFilter>* _aidl_return) override;
- Status openTimeFilter(shared_ptr<ITunerTimeFilter>* _aidl_return) override;
- Status getAvSyncHwId(const shared_ptr<ITunerFilter>& tunerFilter, int* _aidl_return) override;
- Status getAvSyncTime(int avSyncHwId, int64_t* _aidl_return) override;
- Status openDvr(
- int dvbType, int bufferSize, const shared_ptr<ITunerDvrCallback>& cb,
- shared_ptr<ITunerDvr>* _aidl_return) override;
- Status connectCiCam(int ciCamId) override;
- Status disconnectCiCam() override;
- Status close() override;
+
+ ::ndk::ScopedAStatus setFrontendDataSource(
+ const shared_ptr<ITunerFrontend>& in_frontend) override;
+ ::ndk::ScopedAStatus setFrontendDataSourceById(int frontendId) override;
+ ::ndk::ScopedAStatus openFilter(const DemuxFilterType& in_type, int32_t in_bufferSize,
+ const shared_ptr<ITunerFilterCallback>& in_cb,
+ shared_ptr<ITunerFilter>* _aidl_return) override;
+ ::ndk::ScopedAStatus openTimeFilter(shared_ptr<ITunerTimeFilter>* _aidl_return) override;
+ ::ndk::ScopedAStatus getAvSyncHwId(const shared_ptr<ITunerFilter>& in_tunerFilter,
+ int32_t* _aidl_return) override;
+ ::ndk::ScopedAStatus getAvSyncTime(int32_t in_avSyncHwId, int64_t* _aidl_return) override;
+ ::ndk::ScopedAStatus openDvr(DvrType in_dvbType, int32_t in_bufferSize,
+ const shared_ptr<ITunerDvrCallback>& in_cb,
+ shared_ptr<ITunerDvr>* _aidl_return) override;
+ ::ndk::ScopedAStatus connectCiCam(int32_t in_ciCamId) override;
+ ::ndk::ScopedAStatus disconnectCiCam() override;
+ ::ndk::ScopedAStatus close() override;
int getId() { return mDemuxId; }
private:
- sp<IDemux> mDemux;
+ shared_ptr<IDemux> mDemux;
int mDemuxId;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERDEMUX_H
diff --git a/services/tuner/TunerDescrambler.cpp b/services/tuner/TunerDescrambler.cpp
index b7ae167..8e2d6c7 100644
--- a/services/tuner/TunerDescrambler.cpp
+++ b/services/tuner/TunerDescrambler.cpp
@@ -16,17 +16,26 @@
#define LOG_TAG "TunerDescrambler"
-#include "TunerFilter.h"
-#include "TunerDemux.h"
#include "TunerDescrambler.h"
-using ::android::hardware::tv::tuner::V1_0::Result;
+#include <aidl/android/hardware/tv/tuner/IFilter.h>
+#include <aidl/android/hardware/tv/tuner/Result.h>
+
+#include "TunerDemux.h"
+#include "TunerFilter.h"
+
+using ::aidl::android::hardware::tv::tuner::IFilter;
+using ::aidl::android::hardware::tv::tuner::Result;
using namespace std;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-TunerDescrambler::TunerDescrambler(sp<IDescrambler> descrambler) {
+TunerDescrambler::TunerDescrambler(shared_ptr<IDescrambler> descrambler) {
mDescrambler = descrambler;
}
@@ -34,91 +43,74 @@
mDescrambler = nullptr;
}
-Status TunerDescrambler::setDemuxSource(const std::shared_ptr<ITunerDemux>& demux) {
+::ndk::ScopedAStatus TunerDescrambler::setDemuxSource(
+ const shared_ptr<ITunerDemux>& in_tunerDemux) {
if (mDescrambler == nullptr) {
ALOGE("IDescrambler is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDescrambler->setDemuxSource(static_cast<TunerDemux*>(demux.get())->getId());
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDescrambler->setDemuxSource((static_cast<TunerDemux*>(in_tunerDemux.get()))->getId());
}
-Status TunerDescrambler::setKeyToken(const vector<uint8_t>& keyToken) {
+::ndk::ScopedAStatus TunerDescrambler::setKeyToken(const vector<uint8_t>& in_keyToken) {
if (mDescrambler == nullptr) {
ALOGE("IDescrambler is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDescrambler->setKeyToken(keyToken);
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDescrambler->setKeyToken(in_keyToken);
}
-Status TunerDescrambler::addPid(const TunerDemuxPid& pid,
- const shared_ptr<ITunerFilter>& optionalSourceFilter) {
+::ndk::ScopedAStatus TunerDescrambler::addPid(
+ const DemuxPid& in_pid, const shared_ptr<ITunerFilter>& in_optionalSourceFilter) {
if (mDescrambler == nullptr) {
ALOGE("IDescrambler is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- sp<IFilter> halFilter = (optionalSourceFilter == NULL)
- ? NULL : static_cast<TunerFilter*>(optionalSourceFilter.get())->getHalFilter();
- Result res = mDescrambler->addPid(getHidlDemuxPid(pid), halFilter);
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ shared_ptr<IFilter> halFilter =
+ (in_optionalSourceFilter == nullptr)
+ ? nullptr
+ : static_cast<TunerFilter*>(in_optionalSourceFilter.get())->getHalFilter();
+
+ return mDescrambler->addPid(in_pid, halFilter);
}
-Status TunerDescrambler::removePid(const TunerDemuxPid& pid,
- const shared_ptr<ITunerFilter>& optionalSourceFilter) {
+::ndk::ScopedAStatus TunerDescrambler::removePid(
+ const DemuxPid& in_pid, const shared_ptr<ITunerFilter>& in_optionalSourceFilter) {
if (mDescrambler == nullptr) {
ALOGE("IDescrambler is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- sp<IFilter> halFilter = (optionalSourceFilter == NULL)
- ? NULL : static_cast<TunerFilter*>(optionalSourceFilter.get())->getHalFilter();
- Result res = mDescrambler->removePid(getHidlDemuxPid(pid), halFilter);
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ shared_ptr<IFilter> halFilter =
+ (in_optionalSourceFilter == nullptr)
+ ? nullptr
+ : static_cast<TunerFilter*>(in_optionalSourceFilter.get())->getHalFilter();
+
+ return mDescrambler->removePid(in_pid, halFilter);
}
-Status TunerDescrambler::close() {
+::ndk::ScopedAStatus TunerDescrambler::close() {
if (mDescrambler == nullptr) {
ALOGE("IDescrambler is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDescrambler->close();
- mDescrambler = NULL;
+ auto res = mDescrambler->close();
+ mDescrambler = nullptr;
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return res;
}
-DemuxPid TunerDescrambler::getHidlDemuxPid(const TunerDemuxPid& pid) {
- DemuxPid hidlPid;
- switch (pid.getTag()) {
- case TunerDemuxPid::tPid: {
- hidlPid.tPid((uint16_t)pid.get<TunerDemuxPid::tPid>());
- break;
- }
- case TunerDemuxPid::mmtpPid: {
- hidlPid.mmtpPid((uint16_t)pid.get<TunerDemuxPid::mmtpPid>());
- break;
- }
- }
- return hidlPid;
-}
+} // namespace tuner
+} // namespace tv
+} // namespace media
} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerDescrambler.h b/services/tuner/TunerDescrambler.h
index 1970fb7..b1d5fb9 100644
--- a/services/tuner/TunerDescrambler.h
+++ b/services/tuner/TunerDescrambler.h
@@ -17,38 +17,43 @@
#ifndef ANDROID_MEDIA_TUNERDESCRAMBLER_H
#define ANDROID_MEDIA_TUNERDESCRAMBLER_H
+#include <aidl/android/hardware/tv/tuner/IDescrambler.h>
#include <aidl/android/media/tv/tuner/BnTunerDescrambler.h>
-#include <android/hardware/tv/tuner/1.0/ITuner.h>
-using Status = ::ndk::ScopedAStatus;
-using ::aidl::android::media::tv::tuner::BnTunerDescrambler;
-using ::aidl::android::media::tv::tuner::ITunerDemux;
-using ::aidl::android::media::tv::tuner::ITunerFilter;
-using ::aidl::android::media::tv::tuner::TunerDemuxPid;
-using ::android::hardware::tv::tuner::V1_0::DemuxPid;
-using ::android::hardware::tv::tuner::V1_0::IDescrambler;
+using ::aidl::android::hardware::tv::tuner::DemuxPid;
+using ::aidl::android::hardware::tv::tuner::IDescrambler;
+using namespace std;
+
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
class TunerDescrambler : public BnTunerDescrambler {
public:
- TunerDescrambler(sp<IDescrambler> descrambler);
+ TunerDescrambler(shared_ptr<IDescrambler> descrambler);
virtual ~TunerDescrambler();
- Status setDemuxSource(const shared_ptr<ITunerDemux>& demux) override;
- Status setKeyToken(const vector<uint8_t>& keyToken) override;
- Status addPid(const TunerDemuxPid& pid,
- const shared_ptr<ITunerFilter>& optionalSourceFilter) override;
- Status removePid(const TunerDemuxPid& pid,
- const shared_ptr<ITunerFilter>& optionalSourceFilter) override;
- Status close() override;
+
+ ::ndk::ScopedAStatus setDemuxSource(const shared_ptr<ITunerDemux>& in_tunerDemux) override;
+ ::ndk::ScopedAStatus setKeyToken(const vector<uint8_t>& in_keyToken) override;
+ ::ndk::ScopedAStatus addPid(const DemuxPid& in_pid,
+ const shared_ptr<ITunerFilter>& in_optionalSourceFilter) override;
+ ::ndk::ScopedAStatus removePid(
+ const DemuxPid& in_pid,
+ const shared_ptr<ITunerFilter>& in_optionalSourceFilter) override;
+ ::ndk::ScopedAStatus close() override;
private:
- DemuxPid getHidlDemuxPid(const TunerDemuxPid& pid);
-
- sp<IDescrambler> mDescrambler;
+ shared_ptr<IDescrambler> mDescrambler;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERDESCRAMBLER_H
diff --git a/services/tuner/TunerDvr.cpp b/services/tuner/TunerDvr.cpp
index db4e07b..fb03b06 100644
--- a/services/tuner/TunerDvr.cpp
+++ b/services/tuner/TunerDvr.cpp
@@ -16,194 +16,151 @@
#define LOG_TAG "TunerDvr"
-#include <fmq/ConvertMQDescriptors.h>
#include "TunerDvr.h"
+
+#include <aidl/android/hardware/tv/tuner/Result.h>
+
#include "TunerFilter.h"
-using ::android::hardware::tv::tuner::V1_0::DataFormat;
-using ::android::hardware::tv::tuner::V1_0::Result;
+using ::aidl::android::hardware::tv::tuner::Result;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-TunerDvr::TunerDvr(sp<IDvr> dvr, int type) {
+TunerDvr::TunerDvr(shared_ptr<IDvr> dvr, DvrType type) {
mDvr = dvr;
- mType = static_cast<DvrType>(type);
+ mType = type;
}
TunerDvr::~TunerDvr() {
- mDvr = NULL;
+ mDvr = nullptr;
}
-Status TunerDvr::getQueueDesc(AidlMQDesc* _aidl_return) {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::getQueueDesc(AidlMQDesc* _aidl_return) {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- MQDesc dvrMQDesc;
- Result res;
- mDvr->getQueueDesc([&](Result r, const MQDesc& desc) {
- dvrMQDesc = desc;
- res = r;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- AidlMQDesc aidlMQDesc;
- unsafeHidlToAidlMQDescriptor<uint8_t, int8_t, SynchronizedReadWrite>(
- dvrMQDesc, &aidlMQDesc);
- *_aidl_return = move(aidlMQDesc);
- return Status::ok();
+ return mDvr->getQueueDesc(_aidl_return);
}
-Status TunerDvr::configure(const TunerDvrSettings& settings) {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::configure(const DvrSettings& in_settings) {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDvr->configure(getHidlDvrSettingsFromAidl(settings));
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDvr->configure(in_settings);
}
-Status TunerDvr::attachFilter(const shared_ptr<ITunerFilter>& filter) {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::attachFilter(const shared_ptr<ITunerFilter>& in_filter) {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- ITunerFilter* tunerFilter = filter.get();
- sp<IFilter> hidlFilter = static_cast<TunerFilter*>(tunerFilter)->getHalFilter();
- if (hidlFilter == NULL) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_ARGUMENT));
+ if (in_filter == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- Result res = mDvr->attachFilter(hidlFilter);
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
+ shared_ptr<IFilter> halFilter = (static_cast<TunerFilter*>(in_filter.get()))->getHalFilter();
+ if (halFilter == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- return Status::ok();
+
+ return mDvr->attachFilter(halFilter);
}
-Status TunerDvr::detachFilter(const shared_ptr<ITunerFilter>& filter) {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::detachFilter(const shared_ptr<ITunerFilter>& in_filter) {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- ITunerFilter* tunerFilter = filter.get();
- sp<IFilter> hidlFilter = static_cast<TunerFilter*>(tunerFilter)->getHalFilter();
- if (hidlFilter == NULL) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_ARGUMENT));
+ if (in_filter == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- Result res = mDvr->detachFilter(hidlFilter);
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
+ shared_ptr<IFilter> halFilter = (static_cast<TunerFilter*>(in_filter.get()))->getHalFilter();
+ if (halFilter == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- return Status::ok();
+
+ return mDvr->detachFilter(halFilter);
}
-Status TunerDvr::start() {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::start() {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDvr->start();
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDvr->start();
}
-Status TunerDvr::stop() {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::stop() {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDvr->stop();
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDvr->stop();
}
-Status TunerDvr::flush() {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::flush() {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDvr->flush();
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDvr->flush();
}
-Status TunerDvr::close() {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::close() {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDvr->close();
- mDvr = NULL;
+ auto status = mDvr->close();
+ mDvr = nullptr;
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
-}
-
-DvrSettings TunerDvr::getHidlDvrSettingsFromAidl(TunerDvrSettings settings) {
- DvrSettings s;
- switch (mType) {
- case DvrType::PLAYBACK: {
- s.playback({
- .statusMask = static_cast<uint8_t>(settings.statusMask),
- .lowThreshold = static_cast<uint32_t>(settings.lowThreshold),
- .highThreshold = static_cast<uint32_t>(settings.highThreshold),
- .dataFormat = static_cast<DataFormat>(settings.dataFormat),
- .packetSize = static_cast<uint8_t>(settings.packetSize),
- });
- return s;
- }
- case DvrType::RECORD: {
- s.record({
- .statusMask = static_cast<uint8_t>(settings.statusMask),
- .lowThreshold = static_cast<uint32_t>(settings.lowThreshold),
- .highThreshold = static_cast<uint32_t>(settings.highThreshold),
- .dataFormat = static_cast<DataFormat>(settings.dataFormat),
- .packetSize = static_cast<uint8_t>(settings.packetSize),
- });
- return s;
- }
- default:
- break;
- }
- return s;
+ return status;
}
/////////////// IDvrCallback ///////////////////////
-
-Return<void> TunerDvr::DvrCallback::onRecordStatus(const RecordStatus status) {
- if (mTunerDvrCallback != NULL) {
- mTunerDvrCallback->onRecordStatus(static_cast<int>(status));
+::ndk::ScopedAStatus TunerDvr::DvrCallback::onRecordStatus(const RecordStatus status) {
+ if (mTunerDvrCallback != nullptr) {
+ mTunerDvrCallback->onRecordStatus(status);
}
- return Void();
+ return ndk::ScopedAStatus::ok();
}
-Return<void> TunerDvr::DvrCallback::onPlaybackStatus(const PlaybackStatus status) {
- if (mTunerDvrCallback != NULL) {
- mTunerDvrCallback->onPlaybackStatus(static_cast<int>(status));
+::ndk::ScopedAStatus TunerDvr::DvrCallback::onPlaybackStatus(const PlaybackStatus status) {
+ if (mTunerDvrCallback != nullptr) {
+ mTunerDvrCallback->onPlaybackStatus(status);
}
- return Void();
+ return ndk::ScopedAStatus::ok();
}
+
+} // namespace tuner
+} // namespace tv
+} // namespace media
} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerDvr.h b/services/tuner/TunerDvr.h
index a508e99..1854d08 100644
--- a/services/tuner/TunerDvr.h
+++ b/services/tuner/TunerDvr.h
@@ -17,81 +17,71 @@
#ifndef ANDROID_MEDIA_TUNERDVR_H
#define ANDROID_MEDIA_TUNERDVR_H
+#include <aidl/android/hardware/tv/tuner/BnDvrCallback.h>
+#include <aidl/android/hardware/tv/tuner/DvrSettings.h>
+#include <aidl/android/hardware/tv/tuner/DvrType.h>
+#include <aidl/android/hardware/tv/tuner/IDvr.h>
+#include <aidl/android/hardware/tv/tuner/PlaybackStatus.h>
+#include <aidl/android/hardware/tv/tuner/RecordStatus.h>
#include <aidl/android/media/tv/tuner/BnTunerDvr.h>
#include <aidl/android/media/tv/tuner/ITunerDvrCallback.h>
-#include <android/hardware/tv/tuner/1.0/ITuner.h>
-#include <fmq/MessageQueue.h>
-#include <TunerFilter.h>
+#include "TunerFilter.h"
-using Status = ::ndk::ScopedAStatus;
-using ::aidl::android::hardware::common::fmq::GrantorDescriptor;
using ::aidl::android::hardware::common::fmq::MQDescriptor;
using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
-using ::aidl::android::media::tv::tuner::BnTunerDvr;
-using ::aidl::android::media::tv::tuner::ITunerDvrCallback;
-using ::aidl::android::media::tv::tuner::ITunerFilter;
-using ::aidl::android::media::tv::tuner::TunerDvrSettings;
-
-using ::android::hardware::MQDescriptorSync;
-using ::android::hardware::MessageQueue;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-
-using ::android::hardware::tv::tuner::V1_0::DvrSettings;
-using ::android::hardware::tv::tuner::V1_0::DvrType;
-using ::android::hardware::tv::tuner::V1_0::IDvr;
-using ::android::hardware::tv::tuner::V1_0::IDvrCallback;
-using ::android::hardware::tv::tuner::V1_0::PlaybackStatus;
-using ::android::hardware::tv::tuner::V1_0::RecordStatus;
+using ::aidl::android::hardware::tv::tuner::BnDvrCallback;
+using ::aidl::android::hardware::tv::tuner::DvrSettings;
+using ::aidl::android::hardware::tv::tuner::DvrType;
+using ::aidl::android::hardware::tv::tuner::IDvr;
+using ::aidl::android::hardware::tv::tuner::PlaybackStatus;
+using ::aidl::android::hardware::tv::tuner::RecordStatus;
using namespace std;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-using MQDesc = MQDescriptorSync<uint8_t>;
using AidlMQDesc = MQDescriptor<int8_t, SynchronizedReadWrite>;
class TunerDvr : public BnTunerDvr {
public:
- TunerDvr(sp<IDvr> dvr, int type);
+ TunerDvr(shared_ptr<IDvr> dvr, DvrType type);
~TunerDvr();
- Status getQueueDesc(AidlMQDesc* _aidl_return) override;
+ ::ndk::ScopedAStatus getQueueDesc(AidlMQDesc* _aidl_return) override;
+ ::ndk::ScopedAStatus configure(const DvrSettings& in_settings) override;
+ ::ndk::ScopedAStatus attachFilter(const shared_ptr<ITunerFilter>& in_filter) override;
+ ::ndk::ScopedAStatus detachFilter(const shared_ptr<ITunerFilter>& in_filter) override;
+ ::ndk::ScopedAStatus start() override;
+ ::ndk::ScopedAStatus stop() override;
+ ::ndk::ScopedAStatus flush() override;
+ ::ndk::ScopedAStatus close() override;
- Status configure(const TunerDvrSettings& settings) override;
-
- Status attachFilter(const shared_ptr<ITunerFilter>& filter) override;
-
- Status detachFilter(const shared_ptr<ITunerFilter>& filter) override;
-
- Status start() override;
-
- Status stop() override;
-
- Status flush() override;
-
- Status close() override;
-
- struct DvrCallback : public IDvrCallback {
+ struct DvrCallback : public BnDvrCallback {
DvrCallback(const shared_ptr<ITunerDvrCallback> tunerDvrCallback)
- : mTunerDvrCallback(tunerDvrCallback) {};
+ : mTunerDvrCallback(tunerDvrCallback){};
- virtual Return<void> onRecordStatus(const RecordStatus status);
- virtual Return<void> onPlaybackStatus(const PlaybackStatus status);
+ ::ndk::ScopedAStatus onRecordStatus(const RecordStatus status) override;
+ ::ndk::ScopedAStatus onPlaybackStatus(const PlaybackStatus status) override;
- private:
- shared_ptr<ITunerDvrCallback> mTunerDvrCallback;
+ private:
+ shared_ptr<ITunerDvrCallback> mTunerDvrCallback;
};
private:
- DvrSettings getHidlDvrSettingsFromAidl(TunerDvrSettings settings);
-
- sp<IDvr> mDvr;
+ shared_ptr<IDvr> mDvr;
DvrType mType;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERDVR_H
diff --git a/services/tuner/TunerFilter.cpp b/services/tuner/TunerFilter.cpp
index 039fd31..005445a 100644
--- a/services/tuner/TunerFilter.cpp
+++ b/services/tuner/TunerFilter.cpp
@@ -18,893 +18,205 @@
#include "TunerFilter.h"
-using ::aidl::android::media::tv::tuner::TunerFilterSectionCondition;
+#include <aidl/android/hardware/tv/tuner/Result.h>
-using ::android::hardware::hidl_handle;
-using ::android::hardware::tv::tuner::V1_0::DemuxAlpLengthType;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
-using ::android::hardware::tv::tuner::V1_0::DemuxIpAddress;
-using ::android::hardware::tv::tuner::V1_0::DemuxMmtpFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxMmtpPid;
-using ::android::hardware::tv::tuner::V1_0::DemuxRecordScIndexType;
-using ::android::hardware::tv::tuner::V1_0::DemuxStreamId;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
-using ::android::hardware::tv::tuner::V1_0::Result;
-using ::android::hardware::tv::tuner::V1_1::AudioStreamType;
-using ::android::hardware::tv::tuner::V1_1::Constant;
-using ::android::hardware::tv::tuner::V1_1::VideoStreamType;
+using ::aidl::android::hardware::tv::tuner::Result;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
using namespace std;
-TunerFilter::TunerFilter(
- sp<IFilter> filter, int mainType, int subType) {
- mFilter = filter;
- mFilter_1_1 = ::android::hardware::tv::tuner::V1_1::IFilter::castFrom(filter);
- mMainType = mainType;
- mSubType = subType;
-}
+TunerFilter::TunerFilter(shared_ptr<IFilter> filter, DemuxFilterType type)
+ : mFilter(filter), mType(type) {}
TunerFilter::~TunerFilter() {
mFilter = nullptr;
- mFilter_1_1 = nullptr;
}
-Status TunerFilter::getQueueDesc(AidlMQDesc* _aidl_return) {
- if (mFilter == NULL) {
- ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- MQDesc filterMQDesc;
- Result res;
- mFilter->getQueueDesc([&](Result r, const MQDesc& desc) {
- filterMQDesc = desc;
- res = r;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- AidlMQDesc aidlMQDesc;
- unsafeHidlToAidlMQDescriptor<uint8_t, int8_t, SynchronizedReadWrite>(
- filterMQDesc, &aidlMQDesc);
- *_aidl_return = move(aidlMQDesc);
- return Status::ok();
-}
-
-Status TunerFilter::getId(int32_t* _aidl_return) {
+::ndk::ScopedAStatus TunerFilter::getQueueDesc(AidlMQDesc* _aidl_return) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res;
- mFilter->getId([&](Result r, uint32_t filterId) {
- res = r;
- mId = filterId;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- *_aidl_return = mId;
- return Status::ok();
+ return mFilter->getQueueDesc(_aidl_return);
}
-Status TunerFilter::getId64Bit(int64_t* _aidl_return) {
- if (mFilter_1_1 == nullptr) {
- ALOGE("IFilter_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- Result res;
- mFilter_1_1->getId64Bit([&](Result r, uint64_t filterId) {
- res = r;
- mId64Bit = filterId;
- });
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- *_aidl_return = mId64Bit;
- return Status::ok();
-}
-
-Status TunerFilter::configure(const TunerFilterConfiguration& config) {
+::ndk::ScopedAStatus TunerFilter::getId(int32_t* _aidl_return) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- DemuxFilterSettings settings;
- switch (config.getTag()) {
- case TunerFilterConfiguration::ts: {
- getHidlTsSettings(config, settings);
- break;
- }
- case TunerFilterConfiguration::mmtp: {
- getHidlMmtpSettings(config, settings);
- break;
- }
- case TunerFilterConfiguration::ip: {
- getHidlIpSettings(config, settings);
- break;
- }
- case TunerFilterConfiguration::tlv: {
- getHidlTlvSettings(config, settings);
- break;
- }
- case TunerFilterConfiguration::alp: {
- getHidlAlpSettings(config, settings);
- break;
- }
+ auto status = mFilter->getId(&mId);
+ if (status.isOk()) {
+ *_aidl_return = mId;
}
-
- Result res = mFilter->configure(settings);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return status;
}
-Status TunerFilter::configureMonitorEvent(int monitorEventType) {
- if (mFilter_1_1 == nullptr) {
- ALOGE("IFilter_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- Result res = mFilter_1_1->configureMonitorEvent(monitorEventType);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
-}
-
-Status TunerFilter::configureIpFilterContextId(int cid) {
- if (mFilter_1_1 == nullptr) {
- ALOGE("IFilter_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- Result res = mFilter_1_1->configureIpCid(cid);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
-}
-
-Status TunerFilter::configureAvStreamType(int avStreamType) {
- if (mFilter_1_1 == nullptr) {
- ALOGE("IFilter_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- AvStreamType type;
- if (!getHidlAvStreamType(avStreamType, type)) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_STATE));
- }
-
- Result res = mFilter_1_1->configureAvStreamType(type);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
-}
-
-Status TunerFilter::setDataSource(const shared_ptr<ITunerFilter>& filter) {
+::ndk::ScopedAStatus TunerFilter::getId64Bit(int64_t* _aidl_return) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- ITunerFilter* tunerFilter = filter.get();
- sp<IFilter> hidlFilter = static_cast<TunerFilter*>(tunerFilter)->getHalFilter();
- Result res = mFilter->setDataSource(hidlFilter);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
+ auto status = mFilter->getId64Bit(&mId64Bit);
+ if (status.isOk()) {
+ *_aidl_return = mId64Bit;
}
- return Status::ok();
+ return status;
}
-void TunerFilter::getHidlTsSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
- auto tsConf = config.get<TunerFilterConfiguration::ts>();
- DemuxTsFilterSettings ts{
- .tpid = static_cast<uint16_t>(tsConf.tpid),
- };
-
- TunerFilterSettings tunerSettings = tsConf.filterSettings;
- switch (tunerSettings.getTag()) {
- case TunerFilterSettings::av: {
- ts.filterSettings.av(getAvSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::section: {
- ts.filterSettings.section(getSectionSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::pesData: {
- ts.filterSettings.pesData(getPesDataSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::record: {
- ts.filterSettings.record(getRecordSettings(tunerSettings));
- break;
- }
- default: {
- ts.filterSettings.noinit();
- break;
- }
- }
- settings.ts(ts);
-}
-
-void TunerFilter::getHidlMmtpSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
- auto mmtpConf = config.get<TunerFilterConfiguration::mmtp>();
- DemuxMmtpFilterSettings mmtp{
- .mmtpPid = static_cast<DemuxMmtpPid>(mmtpConf.mmtpPid),
- };
-
- TunerFilterSettings tunerSettings = mmtpConf.filterSettings;
- switch (tunerSettings.getTag()) {
- case TunerFilterSettings::av: {
- mmtp.filterSettings.av(getAvSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::section: {
- mmtp.filterSettings.section(getSectionSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::pesData: {
- mmtp.filterSettings.pesData(getPesDataSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::record: {
- mmtp.filterSettings.record(getRecordSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::download: {
- mmtp.filterSettings.download(getDownloadSettings(tunerSettings));
- break;
- }
- default: {
- mmtp.filterSettings.noinit();
- break;
- }
- }
- settings.mmtp(mmtp);
-}
-
-void TunerFilter::getHidlIpSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
- auto ipConf = config.get<TunerFilterConfiguration::ip>();
- DemuxIpAddress ipAddr{
- .srcPort = static_cast<uint16_t>(ipConf.ipAddr.srcPort),
- .dstPort = static_cast<uint16_t>(ipConf.ipAddr.dstPort),
- };
-
- ipConf.ipAddr.srcIpAddress.isIpV6
- ? ipAddr.srcIpAddress.v6(getIpV6Address(ipConf.ipAddr.srcIpAddress))
- : ipAddr.srcIpAddress.v4(getIpV4Address(ipConf.ipAddr.srcIpAddress));
- ipConf.ipAddr.dstIpAddress.isIpV6
- ? ipAddr.dstIpAddress.v6(getIpV6Address(ipConf.ipAddr.dstIpAddress))
- : ipAddr.dstIpAddress.v4(getIpV4Address(ipConf.ipAddr.dstIpAddress));
- DemuxIpFilterSettings ip{
- .ipAddr = ipAddr,
- };
-
- TunerFilterSettings tunerSettings = ipConf.filterSettings;
- switch (tunerSettings.getTag()) {
- case TunerFilterSettings::section: {
- ip.filterSettings.section(getSectionSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::isPassthrough: {
- ip.filterSettings.bPassthrough(tunerSettings.isPassthrough);
- break;
- }
- default: {
- ip.filterSettings.noinit();
- break;
- }
- }
- settings.ip(ip);
-}
-
-hidl_array<uint8_t, IP_V6_LENGTH> TunerFilter::getIpV6Address(TunerDemuxIpAddress addr) {
- hidl_array<uint8_t, IP_V6_LENGTH> ip;
- if (addr.addr.size() != IP_V6_LENGTH) {
- return ip;
- }
- copy(addr.addr.begin(), addr.addr.end(), ip.data());
- return ip;
-}
-
-hidl_array<uint8_t, IP_V4_LENGTH> TunerFilter::getIpV4Address(TunerDemuxIpAddress addr) {
- hidl_array<uint8_t, IP_V4_LENGTH> ip;
- if (addr.addr.size() != IP_V4_LENGTH) {
- return ip;
- }
- copy(addr.addr.begin(), addr.addr.end(), ip.data());
- return ip;
-}
-
-void TunerFilter::getHidlTlvSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
- auto tlvConf = config.get<TunerFilterConfiguration::tlv>();
- DemuxTlvFilterSettings tlv{
- .packetType = static_cast<uint8_t>(tlvConf.packetType),
- .isCompressedIpPacket = tlvConf.isCompressedIpPacket,
- };
-
- TunerFilterSettings tunerSettings = tlvConf.filterSettings;
- switch (tunerSettings.getTag()) {
- case TunerFilterSettings::section: {
- tlv.filterSettings.section(getSectionSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::isPassthrough: {
- tlv.filterSettings.bPassthrough(tunerSettings.isPassthrough);
- break;
- }
- default: {
- tlv.filterSettings.noinit();
- break;
- }
- }
- settings.tlv(tlv);
-}
-
-void TunerFilter::getHidlAlpSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
- auto alpConf = config.get<TunerFilterConfiguration::alp>();
- DemuxAlpFilterSettings alp{
- .packetType = static_cast<uint8_t>(alpConf.packetType),
- .lengthType = static_cast<DemuxAlpLengthType>(alpConf.lengthType),
- };
-
- TunerFilterSettings tunerSettings = alpConf.filterSettings;
- switch (tunerSettings.getTag()) {
- case TunerFilterSettings::section: {
- alp.filterSettings.section(getSectionSettings(tunerSettings));
- break;
- }
- default: {
- alp.filterSettings.noinit();
- break;
- }
- }
- settings.alp(alp);
-}
-
-DemuxFilterAvSettings TunerFilter::getAvSettings(const TunerFilterSettings& settings) {
- DemuxFilterAvSettings av {
- .isPassthrough = settings.get<TunerFilterSettings::av>().isPassthrough,
- };
- return av;
-}
-
-DemuxFilterSectionSettings TunerFilter::getSectionSettings(const TunerFilterSettings& settings) {
- auto s = settings.get<TunerFilterSettings::section>();
- DemuxFilterSectionSettings section{
- .isCheckCrc = s.isCheckCrc,
- .isRepeat = s.isRepeat,
- .isRaw = s.isRaw,
- };
-
- switch (s.condition.getTag()) {
- case TunerFilterSectionCondition::sectionBits: {
- auto sectionBits = s.condition.get<TunerFilterSectionCondition::sectionBits>();
- vector<uint8_t> filter(sectionBits.filter.begin(), sectionBits.filter.end());
- vector<uint8_t> mask(sectionBits.mask.begin(), sectionBits.mask.end());
- vector<uint8_t> mode(sectionBits.mode.begin(), sectionBits.mode.end());
- section.condition.sectionBits({
- .filter = filter,
- .mask = mask,
- .mode = mode,
- });
- break;
- }
- case TunerFilterSectionCondition::tableInfo: {
- auto tableInfo = s.condition.get<TunerFilterSectionCondition::tableInfo>();
- section.condition.tableInfo({
- .tableId = static_cast<uint16_t>(tableInfo.tableId),
- .version = static_cast<uint16_t>(tableInfo.version),
- });
- break;
- }
- default: {
- break;
- }
- }
- return section;
-}
-
-DemuxFilterPesDataSettings TunerFilter::getPesDataSettings(const TunerFilterSettings& settings) {
- DemuxFilterPesDataSettings pes{
- .streamId = static_cast<DemuxStreamId>(
- settings.get<TunerFilterSettings::pesData>().streamId),
- .isRaw = settings.get<TunerFilterSettings::pesData>().isRaw,
- };
- return pes;
-}
-
-DemuxFilterRecordSettings TunerFilter::getRecordSettings(const TunerFilterSettings& settings) {
- auto r = settings.get<TunerFilterSettings::record>();
- DemuxFilterRecordSettings record{
- .tsIndexMask = static_cast<uint32_t>(r.tsIndexMask),
- .scIndexType = static_cast<DemuxRecordScIndexType>(r.scIndexType),
- };
-
- switch (r.scIndexMask.getTag()) {
- case TunerFilterScIndexMask::sc: {
- record.scIndexMask.sc(static_cast<uint32_t>(
- r.scIndexMask.get<TunerFilterScIndexMask::sc>()));
- break;
- }
- case TunerFilterScIndexMask::scHevc: {
- record.scIndexMask.scHevc(static_cast<uint32_t>(
- r.scIndexMask.get<TunerFilterScIndexMask::scHevc>()));
- break;
- }
- }
- return record;
-}
-
-DemuxFilterDownloadSettings TunerFilter::getDownloadSettings(const TunerFilterSettings& settings) {
- DemuxFilterDownloadSettings download {
- .downloadId = static_cast<uint32_t>(
- settings.get<TunerFilterSettings::download>().downloadId),
- };
- return download;
-}
-
-Status TunerFilter::getAvSharedHandleInfo(TunerFilterSharedHandleInfo* _aidl_return) {
- if (mFilter_1_1 == nullptr) {
- ALOGE("IFilter_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- Result res;
- mFilter_1_1->getAvSharedHandle([&](Result r, hidl_handle avMemory, uint64_t avMemSize) {
- res = r;
- if (res == Result::SUCCESS) {
- TunerFilterSharedHandleInfo info{
- .handle = dupToAidl(avMemory),
- .size = static_cast<int64_t>(avMemSize),
- };
- *_aidl_return = move(info);
- } else {
- _aidl_return = NULL;
- }
- });
-
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
-}
-
-Status TunerFilter::releaseAvHandle(
- const ::aidl::android::hardware::common::NativeHandle& handle, int64_t avDataId) {
+::ndk::ScopedAStatus TunerFilter::configure(const DemuxFilterSettings& in_settings) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mFilter->releaseAvHandle(hidl_handle(makeFromAidl(handle)), avDataId);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mFilter->configure(in_settings);
}
-Status TunerFilter::start() {
+::ndk::ScopedAStatus TunerFilter::configureMonitorEvent(int32_t monitorEventType) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mFilter->start();
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+
+ return mFilter->configureMonitorEvent(monitorEventType);
}
-Status TunerFilter::stop() {
+::ndk::ScopedAStatus TunerFilter::configureIpFilterContextId(int32_t cid) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mFilter->stop();
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+
+ return mFilter->configureIpCid(cid);
}
-Status TunerFilter::flush() {
+::ndk::ScopedAStatus TunerFilter::configureAvStreamType(const AvStreamType& in_avStreamType) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mFilter->flush();
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+
+ return mFilter->configureAvStreamType(in_avStreamType);
}
-Status TunerFilter::close() {
+::ndk::ScopedAStatus TunerFilter::setDataSource(const shared_ptr<ITunerFilter>& filter) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mFilter->close();
- mFilter = NULL;
- mFilter_1_1 = NULL;
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
+ if (filter == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- return Status::ok();
+
+ shared_ptr<IFilter> halFilter = static_cast<TunerFilter*>(filter.get())->getHalFilter();
+ return mFilter->setDataSource(halFilter);
}
-sp<IFilter> TunerFilter::getHalFilter() {
+::ndk::ScopedAStatus TunerFilter::getAvSharedHandle(NativeHandle* out_avMemory,
+ int64_t* _aidl_return) {
+ if (mFilter == nullptr) {
+ ALOGE("IFilter is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ return mFilter->getAvSharedHandle(out_avMemory, _aidl_return);
+}
+
+::ndk::ScopedAStatus TunerFilter::releaseAvHandle(const NativeHandle& in_handle,
+ int64_t in_avDataId) {
+ if (mFilter == nullptr) {
+ ALOGE("IFilter is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ return mFilter->releaseAvHandle(in_handle, in_avDataId);
+}
+
+::ndk::ScopedAStatus TunerFilter::start() {
+ if (mFilter == nullptr) {
+ ALOGE("IFilter is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ return mFilter->start();
+}
+
+::ndk::ScopedAStatus TunerFilter::stop() {
+ if (mFilter == nullptr) {
+ ALOGE("IFilter is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ return mFilter->stop();
+}
+
+::ndk::ScopedAStatus TunerFilter::flush() {
+ if (mFilter == nullptr) {
+ ALOGE("IFilter is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ return mFilter->flush();
+}
+
+::ndk::ScopedAStatus TunerFilter::close() {
+ if (mFilter == nullptr) {
+ ALOGE("IFilter is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+ auto res = mFilter->close();
+ mFilter = nullptr;
+
+ return res;
+}
+
+shared_ptr<IFilter> TunerFilter::getHalFilter() {
return mFilter;
}
-bool TunerFilter::isAudioFilter() {
- return (mMainType == (int)DemuxFilterMainType::TS
- && mSubType == (int)DemuxTsFilterType::AUDIO)
- || (mMainType == (int)DemuxFilterMainType::MMTP
- && mSubType == (int)DemuxMmtpFilterType::AUDIO);
-}
-
-bool TunerFilter::isVideoFilter() {
- return (mMainType == (int)DemuxFilterMainType::TS
- && mSubType == (int)DemuxTsFilterType::VIDEO)
- || (mMainType == (int)DemuxFilterMainType::MMTP
- && mSubType == (int)DemuxMmtpFilterType::VIDEO);
-}
-
-bool TunerFilter::getHidlAvStreamType(int avStreamType, AvStreamType& type) {
- if (isAudioFilter()) {
- type.audio(static_cast<AudioStreamType>(avStreamType));
- return true;
- }
-
- if (isVideoFilter()) {
- type.video(static_cast<VideoStreamType>(avStreamType));
- return true;
- }
-
- return false;
-}
-
/////////////// FilterCallback ///////////////////////
-
-Return<void> TunerFilter::FilterCallback::onFilterStatus(DemuxFilterStatus status) {
- if (mTunerFilterCallback != NULL) {
- mTunerFilterCallback->onFilterStatus((int)status);
+::ndk::ScopedAStatus TunerFilter::FilterCallback::onFilterStatus(DemuxFilterStatus status) {
+ if (mTunerFilterCallback != nullptr) {
+ mTunerFilterCallback->onFilterStatus(status);
}
- return Void();
+ return ::ndk::ScopedAStatus::ok();
}
-Return<void> TunerFilter::FilterCallback::onFilterEvent(const DemuxFilterEvent& filterEvent) {
- vector<DemuxFilterEventExt::Event> emptyEventsExt;
- DemuxFilterEventExt emptyFilterEventExt {
- .events = emptyEventsExt,
- };
- onFilterEvent_1_1(filterEvent, emptyFilterEventExt);
- return Void();
-}
-
-Return<void> TunerFilter::FilterCallback::onFilterEvent_1_1(const DemuxFilterEvent& filterEvent,
- const DemuxFilterEventExt& filterEventExt) {
- if (mTunerFilterCallback != NULL) {
- vector<DemuxFilterEvent::Event> events = filterEvent.events;
- vector<DemuxFilterEventExt::Event> eventsExt = filterEventExt.events;
- vector<TunerFilterEvent> tunerEvent;
-
- getAidlFilterEvent(events, eventsExt, tunerEvent);
- mTunerFilterCallback->onFilterEvent(tunerEvent);
+::ndk::ScopedAStatus TunerFilter::FilterCallback::onFilterEvent(
+ const vector<DemuxFilterEvent>& events) {
+ if (mTunerFilterCallback != nullptr) {
+ mTunerFilterCallback->onFilterEvent(events);
}
- return Void();
+ return ::ndk::ScopedAStatus::ok();
}
-/////////////// FilterCallback Helper Methods ///////////////////////
-
-void TunerFilter::FilterCallback::getAidlFilterEvent(vector<DemuxFilterEvent::Event>& events,
- vector<DemuxFilterEventExt::Event>& eventsExt,
- vector<TunerFilterEvent>& tunerEvent) {
- if (events.empty() && !eventsExt.empty()) {
- auto eventExt = eventsExt[0];
- switch (eventExt.getDiscriminator()) {
- case DemuxFilterEventExt::Event::hidl_discriminator::monitorEvent: {
- getMonitorEvent(eventsExt, tunerEvent);
- return;
- }
- case DemuxFilterEventExt::Event::hidl_discriminator::startId: {
- getRestartEvent(eventsExt, tunerEvent);
- return;
- }
- default: {
- break;
- }
- }
- return;
- }
-
- if (!events.empty()) {
- auto event = events[0];
- switch (event.getDiscriminator()) {
- case DemuxFilterEvent::Event::hidl_discriminator::media: {
- getMediaEvent(events, tunerEvent);
- break;
- }
- case DemuxFilterEvent::Event::hidl_discriminator::section: {
- getSectionEvent(events, tunerEvent);
- break;
- }
- case DemuxFilterEvent::Event::hidl_discriminator::pes: {
- getPesEvent(events, tunerEvent);
- break;
- }
- case DemuxFilterEvent::Event::hidl_discriminator::tsRecord: {
- getTsRecordEvent(events, eventsExt, tunerEvent);
- break;
- }
- case DemuxFilterEvent::Event::hidl_discriminator::mmtpRecord: {
- getMmtpRecordEvent(events, eventsExt, tunerEvent);
- break;
- }
- case DemuxFilterEvent::Event::hidl_discriminator::download: {
- getDownloadEvent(events, tunerEvent);
- break;
- }
- case DemuxFilterEvent::Event::hidl_discriminator::ipPayload: {
- getIpPayloadEvent(events, tunerEvent);
- break;
- }
- case DemuxFilterEvent::Event::hidl_discriminator::temi: {
- getTemiEvent(events, tunerEvent);
- break;
- }
- default: {
- break;
- }
- }
- }
-}
-
-void TunerFilter::FilterCallback::getMediaEvent(
- vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
- for (DemuxFilterEvent::Event e : events) {
- DemuxFilterMediaEvent mediaEvent = e.media();
- TunerFilterMediaEvent tunerMedia;
-
- tunerMedia.streamId = static_cast<char16_t>(mediaEvent.streamId);
- tunerMedia.isPtsPresent = mediaEvent.isPtsPresent;
- tunerMedia.pts = static_cast<long>(mediaEvent.pts);
- tunerMedia.dataLength = static_cast<int>(mediaEvent.dataLength);
- tunerMedia.offset = static_cast<int>(mediaEvent.offset);
- tunerMedia.isSecureMemory = mediaEvent.isSecureMemory;
- tunerMedia.avDataId = static_cast<long>(mediaEvent.avDataId);
- tunerMedia.mpuSequenceNumber = static_cast<int>(mediaEvent.mpuSequenceNumber);
- tunerMedia.isPesPrivateData = mediaEvent.isPesPrivateData;
-
- if (mediaEvent.extraMetaData.getDiscriminator() ==
- DemuxFilterMediaEvent::ExtraMetaData::hidl_discriminator::audio) {
- tunerMedia.isAudioExtraMetaData = true;
- tunerMedia.audio = {
- .adFade = static_cast<int8_t>(
- mediaEvent.extraMetaData.audio().adFade),
- .adPan = static_cast<int8_t>(
- mediaEvent.extraMetaData.audio().adPan),
- .versionTextTag = static_cast<int8_t>(
- mediaEvent.extraMetaData.audio().versionTextTag),
- .adGainCenter = static_cast<int8_t>(
- mediaEvent.extraMetaData.audio().adGainCenter),
- .adGainFront = static_cast<int8_t>(
- mediaEvent.extraMetaData.audio().adGainFront),
- .adGainSurround = static_cast<int8_t>(
- mediaEvent.extraMetaData.audio().adGainSurround),
- };
- } else {
- tunerMedia.isAudioExtraMetaData = false;
- }
-
- if (mediaEvent.avMemory.getNativeHandle() != nullptr) {
- tunerMedia.avMemory = dupToAidl(mediaEvent.avMemory.getNativeHandle());
- }
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::media>(move(tunerMedia));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getSectionEvent(
- vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
- for (DemuxFilterEvent::Event e : events) {
- DemuxFilterSectionEvent sectionEvent = e.section();
- TunerFilterSectionEvent tunerSection;
-
- tunerSection.tableId = static_cast<char16_t>(sectionEvent.tableId);
- tunerSection.version = static_cast<char16_t>(sectionEvent.version);
- tunerSection.sectionNum = static_cast<char16_t>(sectionEvent.sectionNum);
- tunerSection.dataLength = static_cast<char16_t>(sectionEvent.dataLength);
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::section>(move(tunerSection));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getPesEvent(
- vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
- for (DemuxFilterEvent::Event e : events) {
- DemuxFilterPesEvent pesEvent = e.pes();
- TunerFilterPesEvent tunerPes;
-
- tunerPes.streamId = static_cast<char16_t>(pesEvent.streamId);
- tunerPes.dataLength = static_cast<char16_t>(pesEvent.dataLength);
- tunerPes.mpuSequenceNumber = static_cast<int>(pesEvent.mpuSequenceNumber);
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::pes>(move(tunerPes));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getTsRecordEvent(vector<DemuxFilterEvent::Event>& events,
- vector<DemuxFilterEventExt::Event>& eventsExt, vector<TunerFilterEvent>& res) {
- for (int i = 0; i < events.size(); i++) {
- TunerFilterTsRecordEvent tunerTsRecord;
- DemuxFilterTsRecordEvent tsRecordEvent = events[i].tsRecord();
-
- TunerFilterScIndexMask scIndexMask;
- if (tsRecordEvent.scIndexMask.getDiscriminator()
- == DemuxFilterTsRecordEvent::ScIndexMask::hidl_discriminator::sc) {
- scIndexMask.set<TunerFilterScIndexMask::sc>(
- static_cast<int>(tsRecordEvent.scIndexMask.sc()));
- } else if (tsRecordEvent.scIndexMask.getDiscriminator()
- == DemuxFilterTsRecordEvent::ScIndexMask::hidl_discriminator::scHevc) {
- scIndexMask.set<TunerFilterScIndexMask::scHevc>(
- static_cast<int>(tsRecordEvent.scIndexMask.scHevc()));
- }
-
- if (tsRecordEvent.pid.getDiscriminator() == DemuxPid::hidl_discriminator::tPid) {
- tunerTsRecord.pid = static_cast<char16_t>(tsRecordEvent.pid.tPid());
- } else {
- tunerTsRecord.pid = static_cast<char16_t>(Constant::INVALID_TS_PID);
- }
-
- tunerTsRecord.scIndexMask = scIndexMask;
- tunerTsRecord.tsIndexMask = static_cast<int>(tsRecordEvent.tsIndexMask);
- tunerTsRecord.byteNumber = static_cast<long>(tsRecordEvent.byteNumber);
-
- if (eventsExt.size() > i && eventsExt[i].getDiscriminator() ==
- DemuxFilterEventExt::Event::hidl_discriminator::tsRecord) {
- tunerTsRecord.isExtended = true;
- tunerTsRecord.pts = static_cast<long>(eventsExt[i].tsRecord().pts);
- tunerTsRecord.firstMbInSlice = static_cast<int>(eventsExt[i].tsRecord().firstMbInSlice);
- } else {
- tunerTsRecord.isExtended = false;
- }
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::tsRecord>(move(tunerTsRecord));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getMmtpRecordEvent(vector<DemuxFilterEvent::Event>& events,
- vector<DemuxFilterEventExt::Event>& eventsExt, vector<TunerFilterEvent>& res) {
- for (int i = 0; i < events.size(); i++) {
- TunerFilterMmtpRecordEvent tunerMmtpRecord;
- DemuxFilterMmtpRecordEvent mmtpRecordEvent = events[i].mmtpRecord();
-
- tunerMmtpRecord.scHevcIndexMask = static_cast<int>(mmtpRecordEvent.scHevcIndexMask);
- tunerMmtpRecord.byteNumber = static_cast<long>(mmtpRecordEvent.byteNumber);
-
- if (eventsExt.size() > i && eventsExt[i].getDiscriminator() ==
- DemuxFilterEventExt::Event::hidl_discriminator::mmtpRecord) {
- tunerMmtpRecord.isExtended = true;
- tunerMmtpRecord.pts = static_cast<long>(eventsExt[i].mmtpRecord().pts);
- tunerMmtpRecord.mpuSequenceNumber =
- static_cast<int>(eventsExt[i].mmtpRecord().mpuSequenceNumber);
- tunerMmtpRecord.firstMbInSlice =
- static_cast<int>(eventsExt[i].mmtpRecord().firstMbInSlice);
- tunerMmtpRecord.tsIndexMask = static_cast<int>(eventsExt[i].mmtpRecord().tsIndexMask);
- } else {
- tunerMmtpRecord.isExtended = false;
- }
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::mmtpRecord>(move(tunerMmtpRecord));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getDownloadEvent(
- vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
- for (DemuxFilterEvent::Event e : events) {
- DemuxFilterDownloadEvent downloadEvent = e.download();
- TunerFilterDownloadEvent tunerDownload;
-
- tunerDownload.itemId = static_cast<int>(downloadEvent.itemId);
- tunerDownload.itemFragmentIndex = static_cast<int>(downloadEvent.itemFragmentIndex);
- tunerDownload.mpuSequenceNumber = static_cast<int>(downloadEvent.mpuSequenceNumber);
- tunerDownload.lastItemFragmentIndex = static_cast<int>(downloadEvent.lastItemFragmentIndex);
- tunerDownload.dataLength = static_cast<char16_t>(downloadEvent.dataLength);
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::download>(move(tunerDownload));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getIpPayloadEvent(
- vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
- for (DemuxFilterEvent::Event e : events) {
- DemuxFilterIpPayloadEvent ipPayloadEvent = e.ipPayload();
- TunerFilterIpPayloadEvent tunerIpPayload;
-
- tunerIpPayload.dataLength = static_cast<char16_t>(ipPayloadEvent.dataLength);
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::ipPayload>(move(tunerIpPayload));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getTemiEvent(
- vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
- for (DemuxFilterEvent::Event e : events) {
- DemuxFilterTemiEvent temiEvent = e.temi();
- TunerFilterTemiEvent tunerTemi;
-
- tunerTemi.pts = static_cast<long>(temiEvent.pts);
- tunerTemi.descrTag = static_cast<int8_t>(temiEvent.descrTag);
- vector<uint8_t> descrData = temiEvent.descrData;
- tunerTemi.descrData.resize(descrData.size());
- copy(descrData.begin(), descrData.end(), tunerTemi.descrData.begin());
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::temi>(move(tunerTemi));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getMonitorEvent(
- vector<DemuxFilterEventExt::Event>& eventsExt, vector<TunerFilterEvent>& res) {
- DemuxFilterMonitorEvent monitorEvent = eventsExt[0].monitorEvent();
- TunerFilterMonitorEvent tunerMonitor;
-
- switch (monitorEvent.getDiscriminator()) {
- case DemuxFilterMonitorEvent::hidl_discriminator::scramblingStatus: {
- tunerMonitor.set<TunerFilterMonitorEvent::scramblingStatus>(
- static_cast<int>(monitorEvent.scramblingStatus()));
- break;
- }
- case DemuxFilterMonitorEvent::hidl_discriminator::cid: {
- tunerMonitor.set<TunerFilterMonitorEvent::cid>(static_cast<int>(monitorEvent.cid()));
- break;
- }
- }
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::monitor>(move(tunerMonitor));
- res.push_back(move(tunerEvent));
-}
-
-void TunerFilter::FilterCallback::getRestartEvent(
- vector<DemuxFilterEventExt::Event>& eventsExt, vector<TunerFilterEvent>& res) {
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::startId>(static_cast<int>(eventsExt[0].startId()));
- res.push_back(move(tunerEvent));
-}
+} // namespace tuner
+} // namespace tv
+} // namespace media
} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerFilter.h b/services/tuner/TunerFilter.h
index ff4728c..86d178c 100644
--- a/services/tuner/TunerFilter.h
+++ b/services/tuner/TunerFilter.h
@@ -17,176 +17,90 @@
#ifndef ANDROID_MEDIA_TUNERFILTER_H
#define ANDROID_MEDIA_TUNERFILTER_H
+#include <aidl/android/hardware/tv/tuner/AvStreamType.h>
+#include <aidl/android/hardware/tv/tuner/BnFilterCallback.h>
+#include <aidl/android/hardware/tv/tuner/DemuxFilterEvent.h>
+#include <aidl/android/hardware/tv/tuner/DemuxFilterSettings.h>
+#include <aidl/android/hardware/tv/tuner/DemuxFilterStatus.h>
+#include <aidl/android/hardware/tv/tuner/DemuxFilterType.h>
+#include <aidl/android/hardware/tv/tuner/IFilter.h>
#include <aidl/android/media/tv/tuner/BnTunerFilter.h>
#include <aidl/android/media/tv/tuner/ITunerFilterCallback.h>
-#include <aidlcommonsupport/NativeHandle.h>
-#include <android/hardware/tv/tuner/1.0/ITuner.h>
-#include <android/hardware/tv/tuner/1.1/IFilter.h>
-#include <android/hardware/tv/tuner/1.1/IFilterCallback.h>
-#include <android/hardware/tv/tuner/1.1/types.h>
#include <media/stagefright/foundation/ADebug.h>
-#include <fmq/ConvertMQDescriptors.h>
-#include <fmq/MessageQueue.h>
-using Status = ::ndk::ScopedAStatus;
+using ::aidl::android::hardware::common::NativeHandle;
using ::aidl::android::hardware::common::fmq::MQDescriptor;
using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
+using ::aidl::android::hardware::tv::tuner::AvStreamType;
+using ::aidl::android::hardware::tv::tuner::BnFilterCallback;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterEvent;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterSettings;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterStatus;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterType;
+using ::aidl::android::hardware::tv::tuner::IFilter;
using ::aidl::android::media::tv::tuner::BnTunerFilter;
-using ::aidl::android::media::tv::tuner::ITunerFilterCallback;
-using ::aidl::android::media::tv::tuner::TunerDemuxIpAddress;
-using ::aidl::android::media::tv::tuner::TunerFilterConfiguration;
-using ::aidl::android::media::tv::tuner::TunerFilterDownloadEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterIpPayloadEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterMediaEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterMmtpRecordEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterMonitorEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterPesEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterScIndexMask;
-using ::aidl::android::media::tv::tuner::TunerFilterSectionEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterSharedHandleInfo;
-using ::aidl::android::media::tv::tuner::TunerFilterSettings;
-using ::aidl::android::media::tv::tuner::TunerFilterTemiEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterTsRecordEvent;
-using ::android::hardware::MQDescriptorSync;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_array;
-using ::android::hardware::tv::tuner::V1_0::DemuxAlpFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterAvSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterDownloadEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterDownloadSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterIpPayloadEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterMediaEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterMmtpRecordEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterPesDataSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterPesEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterRecordSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterSectionEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterSectionSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterStatus;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterTemiEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterTsRecordEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxIpFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxMmtpFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxTlvFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxPid;
-using ::android::hardware::tv::tuner::V1_0::IFilter;
-using ::android::hardware::tv::tuner::V1_1::AvStreamType;
-using ::android::hardware::tv::tuner::V1_1::DemuxFilterEventExt;
-using ::android::hardware::tv::tuner::V1_1::DemuxFilterMonitorEvent;
-using ::android::hardware::tv::tuner::V1_1::DemuxFilterTsRecordEventExt;
-using ::android::hardware::tv::tuner::V1_1::IFilterCallback;
+using namespace std;
+
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-using MQDesc = MQDescriptorSync<uint8_t>;
using AidlMQDesc = MQDescriptor<int8_t, SynchronizedReadWrite>;
-const static int IP_V4_LENGTH = 4;
-const static int IP_V6_LENGTH = 16;
-
class TunerFilter : public BnTunerFilter {
public:
- TunerFilter(sp<IFilter> filter, int mainType, int subTyp);
+ TunerFilter(shared_ptr<IFilter> filter, DemuxFilterType type);
virtual ~TunerFilter();
- Status getId(int32_t* _aidl_return) override;
- Status getId64Bit(int64_t* _aidl_return) override;
- Status getQueueDesc(AidlMQDesc* _aidl_return) override;
- Status configure(const TunerFilterConfiguration& config) override;
- Status configureMonitorEvent(int monitorEventType) override;
- Status configureIpFilterContextId(int cid) override;
- Status configureAvStreamType(int avStreamType) override;
- Status getAvSharedHandleInfo(TunerFilterSharedHandleInfo* _aidl_return) override;
- Status releaseAvHandle(const ::aidl::android::hardware::common::NativeHandle& handle,
- int64_t avDataId) override;
- Status setDataSource(const std::shared_ptr<ITunerFilter>& filter) override;
- Status start() override;
- Status stop() override;
- Status flush() override;
- Status close() override;
- sp<IFilter> getHalFilter();
- struct FilterCallback : public IFilterCallback {
- FilterCallback(const std::shared_ptr<ITunerFilterCallback> tunerFilterCallback)
- : mTunerFilterCallback(tunerFilterCallback) {};
+ ::ndk::ScopedAStatus getId(int32_t* _aidl_return) override;
+ ::ndk::ScopedAStatus getId64Bit(int64_t* _aidl_return) override;
+ ::ndk::ScopedAStatus getQueueDesc(AidlMQDesc* _aidl_return) override;
+ ::ndk::ScopedAStatus configure(const DemuxFilterSettings& in_settings) override;
+ ::ndk::ScopedAStatus configureMonitorEvent(int32_t in_monitorEventTypes) override;
+ ::ndk::ScopedAStatus configureIpFilterContextId(int32_t in_cid) override;
+ ::ndk::ScopedAStatus configureAvStreamType(const AvStreamType& in_avStreamType) override;
+ ::ndk::ScopedAStatus getAvSharedHandle(NativeHandle* out_avMemory,
+ int64_t* _aidl_return) override;
+ ::ndk::ScopedAStatus releaseAvHandle(const NativeHandle& in_handle,
+ int64_t in_avDataId) override;
+ ::ndk::ScopedAStatus setDataSource(const shared_ptr<ITunerFilter>& in_filter) override;
+ ::ndk::ScopedAStatus start() override;
+ ::ndk::ScopedAStatus stop() override;
+ ::ndk::ScopedAStatus flush() override;
+ ::ndk::ScopedAStatus close() override;
- virtual Return<void> onFilterEvent(const DemuxFilterEvent& filterEvent);
- virtual Return<void> onFilterEvent_1_1(const DemuxFilterEvent& filterEvent,
- const DemuxFilterEventExt& filterEventExt);
- virtual Return<void> onFilterStatus(DemuxFilterStatus status);
+ shared_ptr<IFilter> getHalFilter();
- void getAidlFilterEvent(std::vector<DemuxFilterEvent::Event>& events,
- std::vector<DemuxFilterEventExt::Event>& eventsExt,
- std::vector<TunerFilterEvent>& tunerEvent);
+ class FilterCallback : public BnFilterCallback {
+ public:
+ FilterCallback(const shared_ptr<ITunerFilterCallback> tunerFilterCallback)
+ : mTunerFilterCallback(tunerFilterCallback){};
- void getMediaEvent(
- std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res);
- void getSectionEvent(
- std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res);
- void getPesEvent(
- std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res);
- void getTsRecordEvent(
- std::vector<DemuxFilterEvent::Event>& events,
- std::vector<DemuxFilterEventExt::Event>& eventsExt,
- std::vector<TunerFilterEvent>& res);
- void getMmtpRecordEvent(
- std::vector<DemuxFilterEvent::Event>& events,
- std::vector<DemuxFilterEventExt::Event>& eventsExt,
- std::vector<TunerFilterEvent>& res);
- void getDownloadEvent(
- std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res);
- void getIpPayloadEvent(
- std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res);
- void getTemiEvent(
- std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res);
- void getMonitorEvent(
- std::vector<DemuxFilterEventExt::Event>& eventsExt,
- std::vector<TunerFilterEvent>& res);
- void getRestartEvent(
- std::vector<DemuxFilterEventExt::Event>& eventsExt,
- std::vector<TunerFilterEvent>& res);
+ ::ndk::ScopedAStatus onFilterEvent(const vector<DemuxFilterEvent>& events) override;
+ ::ndk::ScopedAStatus onFilterStatus(DemuxFilterStatus status) override;
- std::shared_ptr<ITunerFilterCallback> mTunerFilterCallback;
+ private:
+ shared_ptr<ITunerFilterCallback> mTunerFilterCallback;
};
private:
- DemuxFilterAvSettings getAvSettings(const TunerFilterSettings& settings);
- DemuxFilterSectionSettings getSectionSettings(const TunerFilterSettings& settings);
- DemuxFilterPesDataSettings getPesDataSettings(const TunerFilterSettings& settings);
- DemuxFilterRecordSettings getRecordSettings(const TunerFilterSettings& settings);
- DemuxFilterDownloadSettings getDownloadSettings(const TunerFilterSettings& settings);
-
bool isAudioFilter();
bool isVideoFilter();
- bool getHidlAvStreamType(int avStreamType, AvStreamType& type);
- void getHidlTsSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
- void getHidlMmtpSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
- void getHidlIpSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
- void getHidlTlvSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
- void getHidlAlpSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
-
- hidl_array<uint8_t, IP_V4_LENGTH> getIpV4Address(TunerDemuxIpAddress addr);
- hidl_array<uint8_t, IP_V6_LENGTH> getIpV6Address(TunerDemuxIpAddress addr);
-
- sp<IFilter> mFilter;
- sp<::android::hardware::tv::tuner::V1_1::IFilter> mFilter_1_1;
+ shared_ptr<IFilter> mFilter;
int32_t mId;
int64_t mId64Bit;
- int mMainType;
- int mSubType;
+ DemuxFilterType mType;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERFILTER_H
diff --git a/services/tuner/TunerFrontend.cpp b/services/tuner/TunerFrontend.cpp
index 74b5519..e86e8e1 100644
--- a/services/tuner/TunerFrontend.cpp
+++ b/services/tuner/TunerFrontend.cpp
@@ -1,5 +1,5 @@
/**
- * Copyright 2020, The Android Open Source Project
+ * 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.
@@ -14,1081 +14,186 @@
* limitations under the License.
*/
+//#define LOG_NDEBUG 0
#define LOG_TAG "TunerFrontend"
#include "TunerFrontend.h"
+
+#include <aidl/android/hardware/tv/tuner/Result.h>
+
#include "TunerLnb.h"
-using ::aidl::android::media::tv::tuner::TunerFrontendAtsc3PlpSettings;
-using ::aidl::android::media::tv::tuner::TunerFrontendScanAtsc3PlpInfo;
-using ::aidl::android::media::tv::tuner::TunerFrontendStatusAtsc3PlpInfo;
-using ::aidl::android::media::tv::tuner::TunerFrontendUnionSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendAnalogSifStandard;
-using ::android::hardware::tv::tuner::V1_0::FrontendAnalogType;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtscModulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtsc3Bandwidth;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtsc3CodeRate;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtsc3DemodOutputFormat;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtsc3Fec;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtsc3Modulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtsc3TimeInterleaveMode;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbcAnnex;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbcModulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbcOuterFec;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbcSpectralInversion;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsModulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsPilot;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsRolloff;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsStandard;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsVcmMode;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtBandwidth;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtCoderate;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtConstellation;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtGuardInterval;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtHierarchy;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtPlpMode;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtStandard;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtTransmissionMode;
-using ::android::hardware::tv::tuner::V1_0::FrontendInnerFec;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbs3Coderate;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbs3Modulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbs3Rolloff;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbs3Settings;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbsCoderate;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbsModulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbsRolloff;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbsSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbsStreamIdType;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbtBandwidth;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbtCoderate;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbtGuardInterval;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbtMode;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbtModulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbtSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendModulationStatus;
-using ::android::hardware::tv::tuner::V1_0::FrontendScanAtsc3PlpInfo;
-using ::android::hardware::tv::tuner::V1_0::FrontendScanType;
-using ::android::hardware::tv::tuner::V1_0::FrontendStatusType;
-using ::android::hardware::tv::tuner::V1_0::Result;
-using ::android::hardware::tv::tuner::V1_1::FrontendAnalogAftFlag;
-using ::android::hardware::tv::tuner::V1_1::FrontendBandwidth;
-using ::android::hardware::tv::tuner::V1_1::FrontendCableTimeInterleaveMode;
-using ::android::hardware::tv::tuner::V1_1::FrontendDvbcBandwidth;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbBandwidth;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbCodeRate;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbGuardInterval;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbModulation;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbTimeInterleaveMode;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbTransmissionMode;
-using ::android::hardware::tv::tuner::V1_1::FrontendDvbsScanType;
-using ::android::hardware::tv::tuner::V1_1::FrontendGuardInterval;
-using ::android::hardware::tv::tuner::V1_1::FrontendInterleaveMode;
-using ::android::hardware::tv::tuner::V1_1::FrontendModulation;
-using ::android::hardware::tv::tuner::V1_1::FrontendRollOff;
-using ::android::hardware::tv::tuner::V1_1::FrontendTransmissionMode;
-using ::android::hardware::tv::tuner::V1_1::FrontendSpectralInversion;
-using ::android::hardware::tv::tuner::V1_1::FrontendStatusTypeExt1_1;
+using ::aidl::android::hardware::tv::tuner::Result;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-TunerFrontend::TunerFrontend(sp<IFrontend> frontend, int id) {
+TunerFrontend::TunerFrontend(shared_ptr<IFrontend> frontend, int id) {
mFrontend = frontend;
- mFrontend_1_1 = ::android::hardware::tv::tuner::V1_1::IFrontend::castFrom(mFrontend);
mId = id;
}
TunerFrontend::~TunerFrontend() {
- mFrontend = NULL;
- mFrontend_1_1 = NULL;
+ mFrontend = nullptr;
mId = -1;
}
-Status TunerFrontend::setCallback(
+::ndk::ScopedAStatus TunerFrontend::setCallback(
const shared_ptr<ITunerFrontendCallback>& tunerFrontendCallback) {
- if (mFrontend == NULL) {
+ if (mFrontend == nullptr) {
ALOGE("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- if (tunerFrontendCallback == NULL) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_ARGUMENT));
+ if (tunerFrontendCallback == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- sp<IFrontendCallback> frontendCallback = new FrontendCallback(tunerFrontendCallback);
- Result status = mFrontend->setCallback(frontendCallback);
- if (status == Result::SUCCESS) {
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ shared_ptr<IFrontendCallback> frontendCallback =
+ ::ndk::SharedRefBase::make<FrontendCallback>(tunerFrontendCallback);
+ return mFrontend->setCallback(frontendCallback);
}
-Status TunerFrontend::tune(const TunerFrontendSettings& settings) {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::tune(const FrontendSettings& settings) {
+ if (mFrontend == nullptr) {
ALOGE("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status;
- FrontendSettings frontendSettings = getHidlFrontendSettings(settings);
- if (settings.isExtended) {
- if (mFrontend_1_1 == NULL) {
- ALOGE("IFrontend_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
- FrontendSettingsExt1_1 frontendSettingsExt = getHidlFrontendSettingsExt(settings);
- status = mFrontend_1_1->tune_1_1(frontendSettings, frontendSettingsExt);
- } else {
- status = mFrontend->tune(frontendSettings);
- }
-
- if (status == Result::SUCCESS) {
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ return mFrontend->tune(settings);
}
-Status TunerFrontend::stopTune() {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::stopTune() {
+ if (mFrontend == nullptr) {
ALOGD("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mFrontend->stopTune();
- if (status == Result::SUCCESS) {
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ return mFrontend->stopTune();
}
-Status TunerFrontend::scan(const TunerFrontendSettings& settings, int frontendScanType) {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::scan(const FrontendSettings& settings,
+ FrontendScanType frontendScanType) {
+ if (mFrontend == nullptr) {
ALOGD("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status;
- FrontendSettings frontendSettings = getHidlFrontendSettings(settings);
- if (settings.isExtended) {
- if (mFrontend_1_1 == NULL) {
- ALOGE("IFrontend_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
- FrontendSettingsExt1_1 frontendSettingsExt = getHidlFrontendSettingsExt(settings);
- status = mFrontend_1_1->scan_1_1(frontendSettings,
- static_cast<FrontendScanType>(frontendScanType), frontendSettingsExt);
- } else {
- status = mFrontend->scan(
- frontendSettings, static_cast<FrontendScanType>(frontendScanType));
- }
-
- if (status == Result::SUCCESS) {
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ return mFrontend->scan(settings, frontendScanType);
}
-Status TunerFrontend::stopScan() {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::stopScan() {
+ if (mFrontend == nullptr) {
ALOGD("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mFrontend->stopScan();
- if (status == Result::SUCCESS) {
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ return mFrontend->stopScan();
}
-Status TunerFrontend::setLnb(const shared_ptr<ITunerLnb>& lnb) {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::setLnb(const shared_ptr<ITunerLnb>& lnb) {
+ if (mFrontend == nullptr) {
ALOGD("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mFrontend->setLnb(static_cast<TunerLnb*>(lnb.get())->getId());
- if (status == Result::SUCCESS) {
- return Status::ok();
+ if (lnb == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ return mFrontend->setLnb(static_cast<TunerLnb*>(lnb.get())->getId());
}
-Status TunerFrontend::setLna(bool bEnable) {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::setLna(bool bEnable) {
+ if (mFrontend == nullptr) {
ALOGD("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mFrontend->setLna(bEnable);
- if (status == Result::SUCCESS) {
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ return mFrontend->setLna(bEnable);
}
-Status TunerFrontend::linkCiCamToFrontend(int ciCamId, int32_t* _aidl_return) {
- if (mFrontend_1_1 == NULL) {
- ALOGD("IFrontend_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- int ltsId;
- Result status;
- mFrontend_1_1->linkCiCam(static_cast<uint32_t>(ciCamId),
- [&](Result r, uint32_t id) {
- status = r;
- ltsId = id;
- });
-
- if (status == Result::SUCCESS) {
- *_aidl_return = ltsId;
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
-}
-
-Status TunerFrontend::unlinkCiCamToFrontend(int ciCamId) {
- if (mFrontend_1_1 == NULL) {
- ALOGD("IFrontend_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- Result status = mFrontend_1_1->unlinkCiCam(ciCamId);
- if (status == Result::SUCCESS) {
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
-}
-
-Status TunerFrontend::close() {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::linkCiCamToFrontend(int32_t ciCamId, int32_t* _aidl_return) {
+ if (mFrontend == nullptr) {
ALOGD("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mFrontend->close();
- mFrontend = NULL;
- mFrontend_1_1 = NULL;
-
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ return mFrontend->linkCiCam(ciCamId, _aidl_return);
}
-Status TunerFrontend::getStatus(const vector<int32_t>& statusTypes,
- vector<TunerFrontendStatus>* _aidl_return) {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::unlinkCiCamToFrontend(int32_t ciCamId) {
+ if (mFrontend == nullptr) {
ALOGD("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res;
- vector<FrontendStatus> status;
- vector<FrontendStatusType> types;
- for (auto s : statusTypes) {
- types.push_back(static_cast<FrontendStatusType>(s));
- }
-
- mFrontend->getStatus(types, [&](Result r, const hidl_vec<FrontendStatus>& s) {
- res = r;
- status = s;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- getAidlFrontendStatus(status, *_aidl_return);
- return Status::ok();
+ return mFrontend->unlinkCiCam(ciCamId);
}
-Status TunerFrontend::getStatusExtended_1_1(const vector<int32_t>& statusTypes,
- vector<TunerFrontendStatus>* _aidl_return) {
- if (mFrontend_1_1 == NULL) {
- ALOGD("IFrontend_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+::ndk::ScopedAStatus TunerFrontend::close() {
+ if (mFrontend == nullptr) {
+ ALOGD("IFrontend is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res;
- vector<FrontendStatusExt1_1> status;
- vector<FrontendStatusTypeExt1_1> types;
- for (auto s : statusTypes) {
- types.push_back(static_cast<FrontendStatusTypeExt1_1>(s));
- }
+ auto res = mFrontend->close();
+ mFrontend = nullptr;
- mFrontend_1_1->getStatusExt1_1(types, [&](Result r, const hidl_vec<FrontendStatusExt1_1>& s) {
- res = r;
- status = s;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- getAidlFrontendStatusExt(status, *_aidl_return);
- return Status::ok();
+ return res;
}
-Status TunerFrontend::getFrontendId(int* _aidl_return) {
+::ndk::ScopedAStatus TunerFrontend::getStatus(const vector<FrontendStatusType>& in_statusTypes,
+ vector<FrontendStatus>* _aidl_return) {
+ if (mFrontend == nullptr) {
+ ALOGD("IFrontend is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ return mFrontend->getStatus(in_statusTypes, _aidl_return);
+}
+
+::ndk::ScopedAStatus TunerFrontend::getFrontendId(int32_t* _aidl_return) {
*_aidl_return = mId;
- return Status::ok();
+ return ::ndk::ScopedAStatus::ok();
}
/////////////// FrontendCallback ///////////////////////
-
-Return<void> TunerFrontend::FrontendCallback::onEvent(FrontendEventType frontendEventType) {
- ALOGD("FrontendCallback::onEvent, type=%d", frontendEventType);
- mTunerFrontendCallback->onEvent((int)frontendEventType);
- return Void();
+::ndk::ScopedAStatus TunerFrontend::FrontendCallback::onEvent(FrontendEventType frontendEventType) {
+ ALOGV("FrontendCallback::onEvent, type=%d", frontendEventType);
+ if (mTunerFrontendCallback != nullptr) {
+ mTunerFrontendCallback->onEvent(frontendEventType);
+ }
+ return ndk::ScopedAStatus::ok();
}
-Return<void> TunerFrontend::FrontendCallback::onScanMessage(
+::ndk::ScopedAStatus TunerFrontend::FrontendCallback::onScanMessage(
FrontendScanMessageType type, const FrontendScanMessage& message) {
- ALOGD("FrontendCallback::onScanMessage, type=%d", type);
- TunerFrontendScanMessage scanMessage;
- switch(type) {
- case FrontendScanMessageType::LOCKED: {
- scanMessage.set<TunerFrontendScanMessage::isLocked>(message.isLocked());
- break;
- }
- case FrontendScanMessageType::END: {
- scanMessage.set<TunerFrontendScanMessage::isEnd>(message.isEnd());
- break;
- }
- case FrontendScanMessageType::PROGRESS_PERCENT: {
- scanMessage.set<TunerFrontendScanMessage::progressPercent>(message.progressPercent());
- break;
- }
- case FrontendScanMessageType::FREQUENCY: {
- auto f = message.frequencies();
- vector<int> frequencies(begin(f), end(f));
- scanMessage.set<TunerFrontendScanMessage::frequencies>(frequencies);
- break;
- }
- case FrontendScanMessageType::SYMBOL_RATE: {
- auto s = message.symbolRates();
- vector<int> symbolRates(begin(s), end(s));
- scanMessage.set<TunerFrontendScanMessage::symbolRates>(symbolRates);
- break;
- }
- case FrontendScanMessageType::HIERARCHY: {
- scanMessage.set<TunerFrontendScanMessage::hierarchy>((int)message.hierarchy());
- break;
- }
- case FrontendScanMessageType::ANALOG_TYPE: {
- scanMessage.set<TunerFrontendScanMessage::analogType>((int)message.analogType());
- break;
- }
- case FrontendScanMessageType::PLP_IDS: {
- auto p = message.plpIds();
- vector<uint8_t> plpIds(begin(p), end(p));
- scanMessage.set<TunerFrontendScanMessage::plpIds>(plpIds);
- break;
- }
- case FrontendScanMessageType::GROUP_IDS: {
- auto g = message.groupIds();
- vector<uint8_t> groupIds(begin(g), end(g));
- scanMessage.set<TunerFrontendScanMessage::groupIds>(groupIds);
- break;
- }
- case FrontendScanMessageType::INPUT_STREAM_IDS: {
- auto i = message.inputStreamIds();
- vector<char16_t> streamIds(begin(i), end(i));
- scanMessage.set<TunerFrontendScanMessage::inputStreamIds>(streamIds);
- break;
- }
- case FrontendScanMessageType::STANDARD: {
- FrontendScanMessage::Standard std = message.std();
- int standard;
- if (std.getDiscriminator() == FrontendScanMessage::Standard::hidl_discriminator::sStd) {
- standard = (int) std.sStd();
- } else if (std.getDiscriminator() ==
- FrontendScanMessage::Standard::hidl_discriminator::tStd) {
- standard = (int) std.tStd();
- } else if (std.getDiscriminator() ==
- FrontendScanMessage::Standard::hidl_discriminator::sifStd) {
- standard = (int) std.sifStd();
- }
- scanMessage.set<TunerFrontendScanMessage::std>(standard);
- break;
- }
- case FrontendScanMessageType::ATSC3_PLP_INFO: {
- vector<FrontendScanAtsc3PlpInfo> plpInfos = message.atsc3PlpInfos();
- vector<TunerFrontendScanAtsc3PlpInfo> tunerPlpInfos;
- for (int i = 0; i < plpInfos.size(); i++) {
- auto info = plpInfos[i];
- int8_t plpId = (int8_t) info.plpId;
- bool lls = (bool) info.bLlsFlag;
- TunerFrontendScanAtsc3PlpInfo plpInfo{
- .plpId = plpId,
- .llsFlag = lls,
- };
- tunerPlpInfos.push_back(plpInfo);
- }
- scanMessage.set<TunerFrontendScanMessage::atsc3PlpInfos>(tunerPlpInfos);
- break;
- }
- default:
- break;
+ ALOGV("FrontendCallback::onScanMessage, type=%d", type);
+ if (mTunerFrontendCallback != nullptr) {
+ mTunerFrontendCallback->onScanMessage(type, message);
}
- mTunerFrontendCallback->onScanMessage((int)type, scanMessage);
- return Void();
+ return ndk::ScopedAStatus::ok();
}
-Return<void> TunerFrontend::FrontendCallback::onScanMessageExt1_1(
- FrontendScanMessageTypeExt1_1 type, const FrontendScanMessageExt1_1& message) {
- ALOGD("onScanMessageExt1_1::onScanMessage, type=%d", type);
- TunerFrontendScanMessage scanMessage;
- switch(type) {
- case FrontendScanMessageTypeExt1_1::MODULATION: {
- FrontendModulation m = message.modulation();
- int modulation;
- switch (m.getDiscriminator()) {
- case FrontendModulation::hidl_discriminator::dvbc:
- modulation = (int) m.dvbc();
- break;
- case FrontendModulation::hidl_discriminator::dvbt:
- modulation = (int) m.dvbt();
- break;
- case FrontendModulation::hidl_discriminator::dvbs:
- modulation = (int) m.dvbs();
- break;
- case FrontendModulation::hidl_discriminator::isdbs:
- modulation = (int) m.isdbs();
- break;
- case FrontendModulation::hidl_discriminator::isdbs3:
- modulation = (int) m.isdbs3();
- break;
- case FrontendModulation::hidl_discriminator::isdbt:
- modulation = (int) m.isdbt();
- break;
- case FrontendModulation::hidl_discriminator::atsc:
- modulation = (int) m.atsc();
- break;
- case FrontendModulation::hidl_discriminator::atsc3:
- modulation = (int) m.atsc3();
- break;
- case FrontendModulation::hidl_discriminator::dtmb:
- modulation = (int) m.dtmb();
- break;
- }
- scanMessage.set<TunerFrontendScanMessage::modulation>(modulation);
- break;
- }
- case FrontendScanMessageTypeExt1_1::DVBC_ANNEX: {
- scanMessage.set<TunerFrontendScanMessage::annex>((int)message.annex());
- break;
- }
- case FrontendScanMessageTypeExt1_1::HIGH_PRIORITY: {
- scanMessage.set<TunerFrontendScanMessage::isHighPriority>(message.isHighPriority());
- break;
- }
- default:
- break;
- }
- mTunerFrontendCallback->onScanMessage((int)type, scanMessage);
- return Void();
-}
-
-/////////////// TunerFrontend Helper Methods ///////////////////////
-
-void TunerFrontend::getAidlFrontendStatus(
- vector<FrontendStatus>& hidlStatus, vector<TunerFrontendStatus>& aidlStatus) {
- for (FrontendStatus s : hidlStatus) {
- TunerFrontendStatus status;
- switch (s.getDiscriminator()) {
- case FrontendStatus::hidl_discriminator::isDemodLocked: {
- status.set<TunerFrontendStatus::isDemodLocked>(s.isDemodLocked());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::snr: {
- status.set<TunerFrontendStatus::snr>((int)s.snr());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::ber: {
- status.set<TunerFrontendStatus::ber>((int)s.ber());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::per: {
- status.set<TunerFrontendStatus::per>((int)s.per());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::preBer: {
- status.set<TunerFrontendStatus::preBer>((int)s.preBer());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::signalQuality: {
- status.set<TunerFrontendStatus::signalQuality>((int)s.signalQuality());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::signalStrength: {
- status.set<TunerFrontendStatus::signalStrength>((int)s.signalStrength());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::symbolRate: {
- status.set<TunerFrontendStatus::symbolRate>((int)s.symbolRate());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::innerFec: {
- status.set<TunerFrontendStatus::innerFec>((long)s.innerFec());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::modulation: {
- switch (s.modulation().getDiscriminator()) {
- case FrontendModulationStatus::hidl_discriminator::dvbc:
- status.set<TunerFrontendStatus::modulation>((int)s.modulation().dvbc());
- aidlStatus.push_back(status);
- break;
- case FrontendModulationStatus::hidl_discriminator::dvbs:
- status.set<TunerFrontendStatus::modulation>((int)s.modulation().dvbs());
- aidlStatus.push_back(status);
- break;
- case FrontendModulationStatus::hidl_discriminator::isdbs:
- status.set<TunerFrontendStatus::modulation>((int)s.modulation().isdbs());
- aidlStatus.push_back(status);
- break;
- case FrontendModulationStatus::hidl_discriminator::isdbs3:
- status.set<TunerFrontendStatus::modulation>((int)s.modulation().isdbs3());
- aidlStatus.push_back(status);
- break;
- case FrontendModulationStatus::hidl_discriminator::isdbt:
- status.set<TunerFrontendStatus::modulation>((int)s.modulation().isdbt());
- aidlStatus.push_back(status);
- break;
- }
- break;
- }
- case FrontendStatus::hidl_discriminator::inversion: {
- status.set<TunerFrontendStatus::inversion>((int)s.inversion());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::lnbVoltage: {
- status.set<TunerFrontendStatus::lnbVoltage>((int)s.lnbVoltage());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::plpId: {
- status.set<TunerFrontendStatus::plpId>((int8_t)s.plpId());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::isEWBS: {
- status.set<TunerFrontendStatus::isEWBS>(s.isEWBS());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::agc: {
- status.set<TunerFrontendStatus::agc>((int8_t)s.agc());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::isLnaOn: {
- status.set<TunerFrontendStatus::isLnaOn>(s.isLnaOn());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::isLayerError: {
- vector<bool> e(s.isLayerError().begin(), s.isLayerError().end());
- status.set<TunerFrontendStatus::isLayerError>(e);
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::mer: {
- status.set<TunerFrontendStatus::mer>((int)s.mer());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::freqOffset: {
- status.set<TunerFrontendStatus::freqOffset>((int)s.freqOffset());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::hierarchy: {
- status.set<TunerFrontendStatus::hierarchy>((int)s.hierarchy());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::isRfLocked: {
- status.set<TunerFrontendStatus::isRfLocked>(s.isRfLocked());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::plpInfo: {
- vector<TunerFrontendStatusAtsc3PlpInfo> info;
- for (auto i : s.plpInfo()) {
- info.push_back({
- .plpId = (int8_t)i.plpId,
- .isLocked = i.isLocked,
- .uec = (int)i.uec,
- });
- }
- status.set<TunerFrontendStatus::plpInfo>(info);
- aidlStatus.push_back(status);
- break;
- }
- }
- }
-}
-
-void TunerFrontend::getAidlFrontendStatusExt(
- vector<FrontendStatusExt1_1>& hidlStatus, vector<TunerFrontendStatus>& aidlStatus) {
- for (FrontendStatusExt1_1 s : hidlStatus) {
- TunerFrontendStatus status;
- switch (s.getDiscriminator()) {
- case FrontendStatusExt1_1::hidl_discriminator::modulations: {
- vector<int> aidlMod;
- for (auto m : s.modulations()) {
- switch (m.getDiscriminator()) {
- case FrontendModulation::hidl_discriminator::dvbc:
- aidlMod.push_back((int)m.dvbc());
- break;
- case FrontendModulation::hidl_discriminator::dvbs:
- aidlMod.push_back((int)m.dvbs());
- break;
- case FrontendModulation::hidl_discriminator::dvbt:
- aidlMod.push_back((int)m.dvbt());
- break;
- case FrontendModulation::hidl_discriminator::isdbs:
- aidlMod.push_back((int)m.isdbs());
- break;
- case FrontendModulation::hidl_discriminator::isdbs3:
- aidlMod.push_back((int)m.isdbs3());
- break;
- case FrontendModulation::hidl_discriminator::isdbt:
- aidlMod.push_back((int)m.isdbt());
- break;
- case FrontendModulation::hidl_discriminator::atsc:
- aidlMod.push_back((int)m.atsc());
- break;
- case FrontendModulation::hidl_discriminator::atsc3:
- aidlMod.push_back((int)m.atsc3());
- break;
- case FrontendModulation::hidl_discriminator::dtmb:
- aidlMod.push_back((int)m.dtmb());
- break;
- }
- }
- status.set<TunerFrontendStatus::modulations>(aidlMod);
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::bers: {
- vector<int> b(s.bers().begin(), s.bers().end());
- status.set<TunerFrontendStatus::bers>(b);
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::codeRates: {
- vector<int64_t> codeRates;
- for (auto c : s.codeRates()) {
- codeRates.push_back((long)c);
- }
- status.set<TunerFrontendStatus::codeRates>(codeRates);
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::bandwidth: {
- switch (s.bandwidth().getDiscriminator()) {
- case FrontendBandwidth::hidl_discriminator::atsc3:
- status.set<TunerFrontendStatus::bandwidth>((int)s.bandwidth().atsc3());
- break;
- case FrontendBandwidth::hidl_discriminator::dvbc:
- status.set<TunerFrontendStatus::bandwidth>((int)s.bandwidth().dvbc());
- break;
- case FrontendBandwidth::hidl_discriminator::dvbt:
- status.set<TunerFrontendStatus::bandwidth>((int)s.bandwidth().dvbt());
- break;
- case FrontendBandwidth::hidl_discriminator::isdbt:
- status.set<TunerFrontendStatus::bandwidth>((int)s.bandwidth().isdbt());
- break;
- case FrontendBandwidth::hidl_discriminator::dtmb:
- status.set<TunerFrontendStatus::bandwidth>((int)s.bandwidth().dtmb());
- break;
- }
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::interval: {
- switch (s.interval().getDiscriminator()) {
- case FrontendGuardInterval::hidl_discriminator::dvbt:
- status.set<TunerFrontendStatus::interval>((int)s.interval().dvbt());
- break;
- case FrontendGuardInterval::hidl_discriminator::isdbt:
- status.set<TunerFrontendStatus::interval>((int)s.interval().isdbt());
- break;
- case FrontendGuardInterval::hidl_discriminator::dtmb:
- status.set<TunerFrontendStatus::interval>((int)s.interval().dtmb());
- break;
- }
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::transmissionMode: {
- switch (s.transmissionMode().getDiscriminator()) {
- case FrontendTransmissionMode::hidl_discriminator::dvbt:
- status.set<TunerFrontendStatus::transmissionMode>(
- (int)s.transmissionMode().dvbt());
- break;
- case FrontendTransmissionMode::hidl_discriminator::isdbt:
- status.set<TunerFrontendStatus::transmissionMode>(
- (int)s.transmissionMode().isdbt());
- break;
- case FrontendTransmissionMode::hidl_discriminator::dtmb:
- status.set<TunerFrontendStatus::transmissionMode>(
- (int)s.transmissionMode().dtmb());
- break;
- }
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::uec: {
- status.set<TunerFrontendStatus::uec>((int)s.uec());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::systemId: {
- status.set<TunerFrontendStatus::systemId>((char16_t)s.systemId());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::interleaving: {
- vector<int> aidlInter;
- for (auto i : s.interleaving()) {
- switch (i.getDiscriminator()) {
- case FrontendInterleaveMode::hidl_discriminator::atsc3:
- aidlInter.push_back((int)i.atsc3());
- break;
- case FrontendInterleaveMode::hidl_discriminator::dvbc:
- aidlInter.push_back((int)i.dvbc());
- break;
- case FrontendInterleaveMode::hidl_discriminator::dtmb:
- aidlInter.push_back((int)i.dtmb());
- break;
- }
- }
- status.set<TunerFrontendStatus::interleaving>(aidlInter);
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::isdbtSegment: {
- auto seg = s.isdbtSegment();
- vector<uint8_t> i(seg.begin(), seg.end());
- status.set<TunerFrontendStatus::isdbtSegment>(i);
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::tsDataRate: {
- vector<int> ts(s.tsDataRate().begin(), s.tsDataRate().end());
- status.set<TunerFrontendStatus::tsDataRate>(ts);
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::rollOff: {
- switch (s.rollOff().getDiscriminator()) {
- case FrontendRollOff::hidl_discriminator::dvbs:
- status.set<TunerFrontendStatus::rollOff>((int)s.rollOff().dvbs());
- break;
- case FrontendRollOff::hidl_discriminator::isdbs:
- status.set<TunerFrontendStatus::rollOff>((int)s.rollOff().isdbs());
- break;
- case FrontendRollOff::hidl_discriminator::isdbs3:
- status.set<TunerFrontendStatus::rollOff>((int)s.rollOff().isdbs3());
- break;
- }
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::isMiso: {
- status.set<TunerFrontendStatus::isMiso>(s.isMiso());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::isLinear: {
- status.set<TunerFrontendStatus::isLinear>(s.isLinear());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::isShortFrames: {
- status.set<TunerFrontendStatus::isShortFrames>(s.isShortFrames());
- aidlStatus.push_back(status);
- break;
- }
- }
- }
-}
-
-hidl_vec<FrontendAtsc3PlpSettings> TunerFrontend::getAtsc3PlpSettings(
- const TunerFrontendAtsc3Settings& settings) {
- int len = settings.plpSettings.size();
- hidl_vec<FrontendAtsc3PlpSettings> plps = hidl_vec<FrontendAtsc3PlpSettings>(len);
- // parse PLP settings
- for (int i = 0; i < len; i++) {
- uint8_t plpId = static_cast<uint8_t>(settings.plpSettings[i].plpId);
- FrontendAtsc3Modulation modulation =
- static_cast<FrontendAtsc3Modulation>(settings.plpSettings[i].modulation);
- FrontendAtsc3TimeInterleaveMode interleaveMode =
- static_cast<FrontendAtsc3TimeInterleaveMode>(
- settings.plpSettings[i].interleaveMode);
- FrontendAtsc3CodeRate codeRate =
- static_cast<FrontendAtsc3CodeRate>(settings.plpSettings[i].codeRate);
- FrontendAtsc3Fec fec =
- static_cast<FrontendAtsc3Fec>(settings.plpSettings[i].fec);
- FrontendAtsc3PlpSettings frontendAtsc3PlpSettings {
- .plpId = plpId,
- .modulation = modulation,
- .interleaveMode = interleaveMode,
- .codeRate = codeRate,
- .fec = fec,
- };
- plps[i] = frontendAtsc3PlpSettings;
- }
- return plps;
-}
-
-FrontendDvbsCodeRate TunerFrontend::getDvbsCodeRate(const TunerFrontendDvbsCodeRate& codeRate) {
- FrontendInnerFec innerFec = static_cast<FrontendInnerFec>(codeRate.fec);
- bool isLinear = codeRate.isLinear;
- bool isShortFrames = codeRate.isShortFrames;
- uint32_t bitsPer1000Symbol = static_cast<uint32_t>(codeRate.bitsPer1000Symbol);
- FrontendDvbsCodeRate coderate {
- .fec = innerFec,
- .isLinear = isLinear,
- .isShortFrames = isShortFrames,
- .bitsPer1000Symbol = bitsPer1000Symbol,
- };
- return coderate;
-}
-
-FrontendSettings TunerFrontend::getHidlFrontendSettings(const TunerFrontendSettings& aidlSettings) {
- auto settings = aidlSettings.settings;
- FrontendSettings frontendSettings;
-
- switch (settings.getTag()) {
- case TunerFrontendUnionSettings::analog: {
- auto analog = settings.get<TunerFrontendUnionSettings::analog>();
- frontendSettings.analog({
- .frequency = static_cast<uint32_t>(analog.frequency),
- .type = static_cast<FrontendAnalogType>(analog.signalType),
- .sifStandard = static_cast<FrontendAnalogSifStandard>(analog.sifStandard),
- });
- break;
- }
- case TunerFrontendUnionSettings::atsc: {
- auto atsc = settings.get<TunerFrontendUnionSettings::atsc>();
- frontendSettings.atsc({
- .frequency = static_cast<uint32_t>(atsc.frequency),
- .modulation = static_cast<FrontendAtscModulation>(atsc.modulation),
- });
- break;
- }
- case TunerFrontendUnionSettings::atsc3: {
- auto atsc3 = settings.get<TunerFrontendUnionSettings::atsc3>();
- frontendSettings.atsc3({
- .frequency = static_cast<uint32_t>(atsc3.frequency),
- .bandwidth = static_cast<FrontendAtsc3Bandwidth>(atsc3.bandwidth),
- .demodOutputFormat = static_cast<FrontendAtsc3DemodOutputFormat>(
- atsc3.demodOutputFormat),
- .plpSettings = getAtsc3PlpSettings(atsc3),
- });
- break;
- }
- case TunerFrontendUnionSettings::cable: {
- auto dvbc = settings.get<TunerFrontendUnionSettings::cable>();
- frontendSettings.dvbc({
- .frequency = static_cast<uint32_t>(dvbc.frequency),
- .modulation = static_cast<FrontendDvbcModulation>(dvbc.modulation),
- .fec = static_cast<FrontendInnerFec>(dvbc.innerFec),
- .symbolRate = static_cast<uint32_t>(dvbc.symbolRate),
- .outerFec = static_cast<FrontendDvbcOuterFec>(dvbc.outerFec),
- .annex = static_cast<FrontendDvbcAnnex>(dvbc.annex),
- .spectralInversion = static_cast<FrontendDvbcSpectralInversion>(
- dvbc.spectralInversion),
- });
- break;
- }
- case TunerFrontendUnionSettings::dvbs: {
- auto dvbs = settings.get<TunerFrontendUnionSettings::dvbs>();
- frontendSettings.dvbs({
- .frequency = static_cast<uint32_t>(dvbs.frequency),
- .modulation = static_cast<FrontendDvbsModulation>(dvbs.modulation),
- .coderate = getDvbsCodeRate(dvbs.codeRate),
- .symbolRate = static_cast<uint32_t>(dvbs.symbolRate),
- .rolloff = static_cast<FrontendDvbsRolloff>(dvbs.rolloff),
- .pilot = static_cast<FrontendDvbsPilot>(dvbs.pilot),
- .inputStreamId = static_cast<uint32_t>(dvbs.inputStreamId),
- .standard = static_cast<FrontendDvbsStandard>(dvbs.standard),
- .vcmMode = static_cast<FrontendDvbsVcmMode>(dvbs.vcm),
- });
- break;
- }
- case TunerFrontendUnionSettings::dvbt: {
- auto dvbt = settings.get<TunerFrontendUnionSettings::dvbt>();
- frontendSettings.dvbt({
- .frequency = static_cast<uint32_t>(dvbt.frequency),
- .transmissionMode = static_cast<FrontendDvbtTransmissionMode>(
- dvbt.transmissionMode),
- .bandwidth = static_cast<FrontendDvbtBandwidth>(dvbt.bandwidth),
- .constellation = static_cast<FrontendDvbtConstellation>(dvbt.constellation),
- .hierarchy = static_cast<FrontendDvbtHierarchy>(dvbt.hierarchy),
- .hpCoderate = static_cast<FrontendDvbtCoderate>(dvbt.hpCodeRate),
- .lpCoderate = static_cast<FrontendDvbtCoderate>(dvbt.lpCodeRate),
- .guardInterval = static_cast<FrontendDvbtGuardInterval>(dvbt.guardInterval),
- .isHighPriority = dvbt.isHighPriority,
- .standard = static_cast<FrontendDvbtStandard>(dvbt.standard),
- .isMiso = dvbt.isMiso,
- .plpMode = static_cast<FrontendDvbtPlpMode>(dvbt.plpMode),
- .plpId = static_cast<uint8_t>(dvbt.plpId),
- .plpGroupId = static_cast<uint8_t>(dvbt.plpGroupId),
- });
- break;
- }
- case TunerFrontendUnionSettings::isdbs: {
- auto isdbs = settings.get<TunerFrontendUnionSettings::isdbs>();
- frontendSettings.isdbs({
- .frequency = static_cast<uint32_t>(isdbs.frequency),
- .streamId = static_cast<uint16_t>(isdbs.streamId),
- .streamIdType = static_cast<FrontendIsdbsStreamIdType>(isdbs.streamIdType),
- .modulation = static_cast<FrontendIsdbsModulation>(isdbs.modulation),
- .coderate = static_cast<FrontendIsdbsCoderate>(isdbs.codeRate),
- .symbolRate = static_cast<uint32_t>(isdbs.symbolRate),
- .rolloff = static_cast<FrontendIsdbsRolloff>(isdbs.rolloff),
- });
- break;
- }
- case TunerFrontendUnionSettings::isdbs3: {
- auto isdbs3 = settings.get<TunerFrontendUnionSettings::isdbs3>();
- frontendSettings.isdbs3({
- .frequency = static_cast<uint32_t>(isdbs3.frequency),
- .streamId = static_cast<uint16_t>(isdbs3.streamId),
- .streamIdType = static_cast<FrontendIsdbsStreamIdType>(isdbs3.streamIdType),
- .modulation = static_cast<FrontendIsdbs3Modulation>(isdbs3.modulation),
- .coderate = static_cast<FrontendIsdbs3Coderate>(isdbs3.codeRate),
- .symbolRate = static_cast<uint32_t>(isdbs3.symbolRate),
- .rolloff = static_cast<FrontendIsdbs3Rolloff>(isdbs3.rolloff),
- });
- break;
- }
- case TunerFrontendUnionSettings::isdbt: {
- auto isdbt = settings.get<TunerFrontendUnionSettings::isdbt>();
- frontendSettings.isdbt({
- .frequency = static_cast<uint32_t>(isdbt.frequency),
- .modulation = static_cast<FrontendIsdbtModulation>(isdbt.modulation),
- .bandwidth = static_cast<FrontendIsdbtBandwidth>(isdbt.bandwidth),
- .mode = static_cast<FrontendIsdbtMode>(isdbt.mode),
- .coderate = static_cast<FrontendIsdbtCoderate>(isdbt.codeRate),
- .guardInterval = static_cast<FrontendIsdbtGuardInterval>(isdbt.guardInterval),
- .serviceAreaId = static_cast<uint32_t>(isdbt.serviceAreaId),
- });
- break;
- }
- default:
- break;
- }
-
- return frontendSettings;
-}
-
-FrontendSettingsExt1_1 TunerFrontend::getHidlFrontendSettingsExt(
- const TunerFrontendSettings& aidlSettings) {
- FrontendSettingsExt1_1 frontendSettingsExt{
- .endFrequency = static_cast<uint32_t>(aidlSettings.endFrequency),
- .inversion = static_cast<FrontendSpectralInversion>(aidlSettings.inversion),
- };
-
- auto settings = aidlSettings.settings;
- switch (settings.getTag()) {
- case TunerFrontendUnionSettings::analog: {
- auto analog = settings.get<TunerFrontendUnionSettings::analog>();
- if (analog.isExtended) {
- frontendSettingsExt.settingExt.analog({
- .aftFlag = static_cast<FrontendAnalogAftFlag>(analog.aftFlag),
- });
- } else {
- frontendSettingsExt.settingExt.noinit();
- }
- break;
- }
- case TunerFrontendUnionSettings::cable: {
- auto dvbc = settings.get<TunerFrontendUnionSettings::cable>();
- if (dvbc.isExtended) {
- frontendSettingsExt.settingExt.dvbc({
- .interleaveMode = static_cast<FrontendCableTimeInterleaveMode>(
- dvbc.interleaveMode),
- .bandwidth = static_cast<FrontendDvbcBandwidth>(
- dvbc.bandwidth),
- });
- } else {
- frontendSettingsExt.settingExt.noinit();
- }
- break;
- }
- case TunerFrontendUnionSettings::dvbs: {
- auto dvbs = settings.get<TunerFrontendUnionSettings::dvbs>();
- if (dvbs.isExtended) {
- frontendSettingsExt.settingExt.dvbs({
- .scanType = static_cast<FrontendDvbsScanType>(dvbs.scanType),
- .isDiseqcRxMessage = dvbs.isDiseqcRxMessage,
- });
- } else {
- frontendSettingsExt.settingExt.noinit();
- }
- break;
- }
- case TunerFrontendUnionSettings::dvbt: {
- auto dvbt = settings.get<TunerFrontendUnionSettings::dvbt>();
- if (dvbt.isExtended) {
- frontendSettingsExt.settingExt.dvbt({
- .constellation =
- static_cast<hardware::tv::tuner::V1_1::FrontendDvbtConstellation>(
- dvbt.constellation),
- .transmissionMode =
- static_cast<hardware::tv::tuner::V1_1::FrontendDvbtTransmissionMode>(
- dvbt.transmissionMode),
- });
- } else {
- frontendSettingsExt.settingExt.noinit();
- }
- break;
- }
- case TunerFrontendUnionSettings::dtmb: {
- auto dtmb = settings.get<TunerFrontendUnionSettings::dtmb>();
- frontendSettingsExt.settingExt.dtmb({
- .frequency = static_cast<uint32_t>(dtmb.frequency),
- .transmissionMode = static_cast<FrontendDtmbTransmissionMode>(
- dtmb.transmissionMode),
- .bandwidth = static_cast<FrontendDtmbBandwidth>(dtmb.bandwidth),
- .modulation = static_cast<FrontendDtmbModulation>(dtmb.modulation),
- .codeRate = static_cast<FrontendDtmbCodeRate>(dtmb.codeRate),
- .guardInterval = static_cast<FrontendDtmbGuardInterval>(dtmb.guardInterval),
- .interleaveMode = static_cast<FrontendDtmbTimeInterleaveMode>(dtmb.interleaveMode),
- });
- break;
- }
- default:
- frontendSettingsExt.settingExt.noinit();
- break;
- }
-
- return frontendSettingsExt;
-}
+} // namespace tuner
+} // namespace tv
+} // namespace media
} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerFrontend.h b/services/tuner/TunerFrontend.h
index 22fd509..4106941 100644
--- a/services/tuner/TunerFrontend.h
+++ b/services/tuner/TunerFrontend.h
@@ -1,5 +1,5 @@
/**
- * Copyright 2020, The Android Open Source Project
+ * 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.
@@ -17,95 +17,74 @@
#ifndef ANDROID_MEDIA_TUNERFRONTEND_H
#define ANDROID_MEDIA_TUNERFRONTEND_H
+#include <aidl/android/hardware/tv/tuner/BnFrontendCallback.h>
+#include <aidl/android/hardware/tv/tuner/IFrontend.h>
+#include <aidl/android/hardware/tv/tuner/IFrontendCallback.h>
#include <aidl/android/media/tv/tuner/BnTunerFrontend.h>
-#include <android/hardware/tv/tuner/1.0/ITuner.h>
-#include <android/hardware/tv/tuner/1.1/IFrontend.h>
-#include <android/hardware/tv/tuner/1.1/IFrontendCallback.h>
#include <media/stagefright/foundation/ADebug.h>
#include <utils/Log.h>
-using Status = ::ndk::ScopedAStatus;
-using ::aidl::android::media::tv::tuner::BnTunerFrontend;
-using ::aidl::android::media::tv::tuner::ITunerFrontendCallback;
-using ::aidl::android::media::tv::tuner::ITunerLnb;
-using ::aidl::android::media::tv::tuner::TunerFrontendAtsc3Settings;
-using ::aidl::android::media::tv::tuner::TunerFrontendDvbsCodeRate;
-using ::aidl::android::media::tv::tuner::TunerFrontendScanMessage;
-using ::aidl::android::media::tv::tuner::TunerFrontendSettings;
-using ::aidl::android::media::tv::tuner::TunerFrontendStatus;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtsc3PlpSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsCodeRate;
-using ::android::hardware::tv::tuner::V1_0::FrontendEventType;
-using ::android::hardware::tv::tuner::V1_0::FrontendId;
-using ::android::hardware::tv::tuner::V1_0::FrontendScanMessage;
-using ::android::hardware::tv::tuner::V1_0::FrontendScanMessageType;
-using ::android::hardware::tv::tuner::V1_0::FrontendSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendStatus;
-using ::android::hardware::tv::tuner::V1_0::IFrontend;
-using ::android::hardware::tv::tuner::V1_1::IFrontendCallback;
-using ::android::hardware::tv::tuner::V1_1::FrontendScanMessageExt1_1;
-using ::android::hardware::tv::tuner::V1_1::FrontendScanMessageTypeExt1_1;
-using ::android::hardware::tv::tuner::V1_1::FrontendSettingsExt1_1;
-using ::android::hardware::tv::tuner::V1_1::FrontendStatusExt1_1;
+using ::aidl::android::hardware::tv::tuner::BnFrontendCallback;
+using ::aidl::android::hardware::tv::tuner::FrontendEventType;
+using ::aidl::android::hardware::tv::tuner::FrontendScanMessage;
+using ::aidl::android::hardware::tv::tuner::FrontendScanMessageType;
+using ::aidl::android::hardware::tv::tuner::FrontendScanType;
+using ::aidl::android::hardware::tv::tuner::FrontendSettings;
+using ::aidl::android::hardware::tv::tuner::FrontendStatus;
+using ::aidl::android::hardware::tv::tuner::FrontendStatusType;
+using ::aidl::android::hardware::tv::tuner::IFrontend;
+using ::aidl::android::hardware::tv::tuner::IFrontendCallback;
using namespace std;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
class TunerFrontend : public BnTunerFrontend {
public:
- TunerFrontend(sp<IFrontend> frontend, int id);
+ TunerFrontend(shared_ptr<IFrontend> frontend, int id);
virtual ~TunerFrontend();
- Status setCallback(
- const shared_ptr<ITunerFrontendCallback>& tunerFrontendCallback) override;
- Status tune(const TunerFrontendSettings& settings) override;
- Status stopTune() override;
- Status scan(const TunerFrontendSettings& settings, int frontendScanType) override;
- Status stopScan() override;
- Status setLnb(const shared_ptr<ITunerLnb>& lnb) override;
- Status setLna(bool bEnable) override;
- Status linkCiCamToFrontend(int ciCamId, int32_t* _aidl_return) override;
- Status unlinkCiCamToFrontend(int ciCamId) override;
- Status close() override;
- Status getStatus(const vector<int32_t>& statusTypes,
- vector<TunerFrontendStatus>* _aidl_return) override;
- Status getStatusExtended_1_1(const vector<int32_t>& statusTypes,
- vector<TunerFrontendStatus>* _aidl_return) override;
- Status getFrontendId(int* _aidl_return) override;
- struct FrontendCallback : public IFrontendCallback {
+ ::ndk::ScopedAStatus setCallback(
+ const shared_ptr<ITunerFrontendCallback>& in_tunerFrontendCallback) override;
+ ::ndk::ScopedAStatus tune(const FrontendSettings& in_settings) override;
+ ::ndk::ScopedAStatus stopTune() override;
+ ::ndk::ScopedAStatus scan(const FrontendSettings& in_settings,
+ FrontendScanType in_frontendScanType) override;
+ ::ndk::ScopedAStatus stopScan() override;
+ ::ndk::ScopedAStatus setLnb(const shared_ptr<ITunerLnb>& in_lnb) override;
+ ::ndk::ScopedAStatus setLna(bool in_bEnable) override;
+ ::ndk::ScopedAStatus linkCiCamToFrontend(int32_t in_ciCamId, int32_t* _aidl_return) override;
+ ::ndk::ScopedAStatus unlinkCiCamToFrontend(int32_t in_ciCamId) override;
+ ::ndk::ScopedAStatus close() override;
+ ::ndk::ScopedAStatus getStatus(const vector<FrontendStatusType>& in_statusTypes,
+ vector<FrontendStatus>* _aidl_return) override;
+ ::ndk::ScopedAStatus getFrontendId(int32_t* _aidl_return) override;
+
+ struct FrontendCallback : public BnFrontendCallback {
FrontendCallback(const shared_ptr<ITunerFrontendCallback> tunerFrontendCallback)
- : mTunerFrontendCallback(tunerFrontendCallback) {};
+ : mTunerFrontendCallback(tunerFrontendCallback){};
- virtual Return<void> onEvent(FrontendEventType frontendEventType);
- virtual Return<void> onScanMessage(
- FrontendScanMessageType type, const FrontendScanMessage& message);
- virtual Return<void> onScanMessageExt1_1(
- FrontendScanMessageTypeExt1_1 type, const FrontendScanMessageExt1_1& message);
+ ::ndk::ScopedAStatus onEvent(FrontendEventType frontendEventType) override;
+ ::ndk::ScopedAStatus onScanMessage(FrontendScanMessageType type,
+ const FrontendScanMessage& message) override;
shared_ptr<ITunerFrontendCallback> mTunerFrontendCallback;
};
private:
- hidl_vec<FrontendAtsc3PlpSettings> getAtsc3PlpSettings(
- const TunerFrontendAtsc3Settings& settings);
- FrontendDvbsCodeRate getDvbsCodeRate(const TunerFrontendDvbsCodeRate& codeRate);
- FrontendSettings getHidlFrontendSettings(const TunerFrontendSettings& aidlSettings);
- FrontendSettingsExt1_1 getHidlFrontendSettingsExt(const TunerFrontendSettings& aidlSettings);
- void getAidlFrontendStatus(
- vector<FrontendStatus>& hidlStatus, vector<TunerFrontendStatus>& aidlStatus);
- void getAidlFrontendStatusExt(
- vector<FrontendStatusExt1_1>& hidlStatus, vector<TunerFrontendStatus>& aidlStatus);
-
int mId;
- sp<IFrontend> mFrontend;
- sp<::android::hardware::tv::tuner::V1_1::IFrontend> mFrontend_1_1;
+ shared_ptr<IFrontend> mFrontend;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERFRONTEND_H
diff --git a/services/tuner/TunerLnb.cpp b/services/tuner/TunerLnb.cpp
index 77248d4..1e143c3 100644
--- a/services/tuner/TunerLnb.cpp
+++ b/services/tuner/TunerLnb.cpp
@@ -18,123 +18,116 @@
#include "TunerLnb.h"
-using ::android::hardware::tv::tuner::V1_0::LnbPosition;
-using ::android::hardware::tv::tuner::V1_0::LnbTone;
-using ::android::hardware::tv::tuner::V1_0::LnbVoltage;
-using ::android::hardware::tv::tuner::V1_0::Result;
+#include <aidl/android/hardware/tv/tuner/ILnbCallback.h>
+#include <aidl/android/hardware/tv/tuner/Result.h>
+using ::aidl::android::hardware::tv::tuner::ILnbCallback;
+using ::aidl::android::hardware::tv::tuner::Result;
+
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-TunerLnb::TunerLnb(sp<ILnb> lnb, int id) {
+TunerLnb::TunerLnb(shared_ptr<ILnb> lnb, int id) {
mLnb = lnb;
mId = id;
}
TunerLnb::~TunerLnb() {
- mLnb = NULL;
+ mLnb = nullptr;
mId = -1;
}
-Status TunerLnb::setCallback(
- const shared_ptr<ITunerLnbCallback>& tunerLnbCallback) {
- if (mLnb == NULL) {
+::ndk::ScopedAStatus TunerLnb::setCallback(
+ const shared_ptr<ITunerLnbCallback>& in_tunerLnbCallback) {
+ if (mLnb == nullptr) {
ALOGE("ILnb is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- if (tunerLnbCallback == NULL) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_ARGUMENT));
+ if (in_tunerLnbCallback == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- sp<ILnbCallback> lnbCallback = new LnbCallback(tunerLnbCallback);
- Result status = mLnb->setCallback(lnbCallback);
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ shared_ptr<ILnbCallback> lnbCallback =
+ ::ndk::SharedRefBase::make<LnbCallback>(in_tunerLnbCallback);
+ return mLnb->setCallback(lnbCallback);
}
-Status TunerLnb::setVoltage(int voltage) {
- if (mLnb == NULL) {
+::ndk::ScopedAStatus TunerLnb::setVoltage(LnbVoltage in_voltage) {
+ if (mLnb == nullptr) {
ALOGE("ILnb is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mLnb->setVoltage(static_cast<LnbVoltage>(voltage));
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ return mLnb->setVoltage(in_voltage);
}
-Status TunerLnb::setTone(int tone) {
- if (mLnb == NULL) {
+::ndk::ScopedAStatus TunerLnb::setTone(LnbTone in_tone) {
+ if (mLnb == nullptr) {
ALOGE("ILnb is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mLnb->setTone(static_cast<LnbTone>(tone));
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ return mLnb->setTone(in_tone);
}
-Status TunerLnb::setSatellitePosition(int position) {
- if (mLnb == NULL) {
+::ndk::ScopedAStatus TunerLnb::setSatellitePosition(LnbPosition in_position) {
+ if (mLnb == nullptr) {
ALOGE("ILnb is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mLnb->setSatellitePosition(static_cast<LnbPosition>(position));
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ return mLnb->setSatellitePosition(in_position);
}
-Status TunerLnb::sendDiseqcMessage(const vector<uint8_t>& diseqcMessage) {
- if (mLnb == NULL) {
+::ndk::ScopedAStatus TunerLnb::sendDiseqcMessage(const vector<uint8_t>& in_diseqcMessage) {
+ if (mLnb == nullptr) {
ALOGE("ILnb is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mLnb->sendDiseqcMessage(diseqcMessage);
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ return mLnb->sendDiseqcMessage(in_diseqcMessage);
}
-Status TunerLnb::close() {
- if (mLnb == NULL) {
+::ndk::ScopedAStatus TunerLnb::close() {
+ if (mLnb == nullptr) {
ALOGE("ILnb is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mLnb->close();
- mLnb = NULL;
+ auto res = mLnb->close();
+ mLnb = nullptr;
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return res;
}
/////////////// ILnbCallback ///////////////////////
-
-Return<void> TunerLnb::LnbCallback::onEvent(const LnbEventType lnbEventType) {
- if (mTunerLnbCallback != NULL) {
- mTunerLnbCallback->onEvent((int)lnbEventType);
+::ndk::ScopedAStatus TunerLnb::LnbCallback::onEvent(const LnbEventType lnbEventType) {
+ if (mTunerLnbCallback != nullptr) {
+ mTunerLnbCallback->onEvent(lnbEventType);
}
- return Void();
+ return ndk::ScopedAStatus::ok();
}
-Return<void> TunerLnb::LnbCallback::onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage) {
- if (mTunerLnbCallback != NULL && diseqcMessage != NULL) {
- vector<uint8_t> msg(begin(diseqcMessage), end(diseqcMessage));
- mTunerLnbCallback->onDiseqcMessage(msg);
+::ndk::ScopedAStatus TunerLnb::LnbCallback::onDiseqcMessage(const vector<uint8_t>& diseqcMessage) {
+ if (mTunerLnbCallback != nullptr) {
+ mTunerLnbCallback->onDiseqcMessage(diseqcMessage);
}
- return Void();
+ return ndk::ScopedAStatus::ok();
}
+
+} // namespace tuner
+} // namespace tv
+} // namespace media
} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerLnb.h b/services/tuner/TunerLnb.h
index 500d072..37efdf8 100644
--- a/services/tuner/TunerLnb.h
+++ b/services/tuner/TunerLnb.h
@@ -17,55 +17,62 @@
#ifndef ANDROID_MEDIA_TUNERFLNB_H
#define ANDROID_MEDIA_TUNERFLNB_H
+#include <aidl/android/hardware/tv/tuner/BnLnbCallback.h>
+#include <aidl/android/hardware/tv/tuner/ILnb.h>
#include <aidl/android/media/tv/tuner/BnTunerLnb.h>
-#include <android/hardware/tv/tuner/1.0/ILnb.h>
-#include <android/hardware/tv/tuner/1.0/ILnbCallback.h>
#include <media/stagefright/foundation/ADebug.h>
#include <utils/Log.h>
-using Status = ::ndk::ScopedAStatus;
-using ::aidl::android::media::tv::tuner::BnTunerLnb;
-using ::aidl::android::media::tv::tuner::ITunerLnbCallback;
-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::LnbEventType;
+using ::aidl::android::hardware::tv::tuner::BnLnbCallback;
+using ::aidl::android::hardware::tv::tuner::ILnb;
+using ::aidl::android::hardware::tv::tuner::LnbEventType;
+using ::aidl::android::hardware::tv::tuner::LnbPosition;
+using ::aidl::android::hardware::tv::tuner::LnbTone;
+using ::aidl::android::hardware::tv::tuner::LnbVoltage;
using namespace std;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
class TunerLnb : public BnTunerLnb {
public:
- TunerLnb(sp<ILnb> lnb, int id);
+ TunerLnb(shared_ptr<ILnb> lnb, int id);
virtual ~TunerLnb();
- Status setCallback(const shared_ptr<ITunerLnbCallback>& tunerLnbCallback) override;
- Status setVoltage(int voltage) override;
- Status setTone(int tone) override;
- Status setSatellitePosition(int position) override;
- Status sendDiseqcMessage(const vector<uint8_t>& diseqcMessage) override;
- Status close() override;
+
+ ::ndk::ScopedAStatus setCallback(
+ const shared_ptr<ITunerLnbCallback>& in_tunerLnbCallback) override;
+ ::ndk::ScopedAStatus setVoltage(LnbVoltage in_voltage) override;
+ ::ndk::ScopedAStatus setTone(LnbTone in_tone) override;
+ ::ndk::ScopedAStatus setSatellitePosition(LnbPosition in_position) override;
+ ::ndk::ScopedAStatus sendDiseqcMessage(const vector<uint8_t>& in_diseqcMessage) override;
+ ::ndk::ScopedAStatus close() override;
int getId() { return mId; }
- struct LnbCallback : public ILnbCallback {
+ struct LnbCallback : public BnLnbCallback {
LnbCallback(const shared_ptr<ITunerLnbCallback> tunerLnbCallback)
- : mTunerLnbCallback(tunerLnbCallback) {};
+ : mTunerLnbCallback(tunerLnbCallback){};
- virtual Return<void> onEvent(const LnbEventType lnbEventType);
- virtual Return<void> onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
+ ::ndk::ScopedAStatus onEvent(const LnbEventType lnbEventType) override;
+ ::ndk::ScopedAStatus onDiseqcMessage(const vector<uint8_t>& diseqcMessage) override;
shared_ptr<ITunerLnbCallback> mTunerLnbCallback;
};
private:
int mId;
- sp<ILnb> mLnb;
+ shared_ptr<ILnb> mLnb;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERFLNB_H
diff --git a/services/tuner/TunerService.cpp b/services/tuner/TunerService.cpp
index 5b4129a..0703700 100644
--- a/services/tuner/TunerService.cpp
+++ b/services/tuner/TunerService.cpp
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2020, The Android Open Source Project
+ * Copyright (c) 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.
@@ -14,60 +14,63 @@
* limitations under the License.
*/
+//#define LOG_NDEBUG 0
#define LOG_TAG "TunerService"
+#include "TunerService.h"
+
+#include <aidl/android/hardware/tv/tuner/IDemux.h>
+#include <aidl/android/hardware/tv/tuner/IDescrambler.h>
+#include <aidl/android/hardware/tv/tuner/IFrontend.h>
+#include <aidl/android/hardware/tv/tuner/ILnb.h>
+#include <aidl/android/hardware/tv/tuner/Result.h>
+#include <aidl/android/media/tv/tunerresourcemanager/TunerFrontendInfo.h>
#include <android/binder_manager.h>
#include <android/content/pm/IPackageManagerNative.h>
#include <binder/IServiceManager.h>
#include <utils/Log.h>
-#include "TunerService.h"
-#include "TunerFrontend.h"
-#include "TunerLnb.h"
+
#include "TunerDemux.h"
#include "TunerDescrambler.h"
+#include "TunerFrontend.h"
+#include "TunerLnb.h"
-using ::aidl::android::media::tv::tuner::TunerFrontendAnalogCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendAtsc3Capabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendAtscCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendCableCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendDvbsCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendDvbtCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendIsdbs3Capabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendIsdbsCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendIsdbtCapabilities;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterAvSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
-using ::android::hardware::tv::tuner::V1_0::FrontendId;
-using ::android::hardware::tv::tuner::V1_0::FrontendType;
-using ::android::hardware::tv::tuner::V1_0::IFrontend;
-using ::android::hardware::tv::tuner::V1_0::ILnb;
-using ::android::hardware::tv::tuner::V1_0::LnbId;
-using ::android::hardware::tv::tuner::V1_0::Result;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbCapabilities;
+using ::aidl::android::hardware::tv::tuner::IDemux;
+using ::aidl::android::hardware::tv::tuner::IDescrambler;
+using ::aidl::android::hardware::tv::tuner::IFrontend;
+using ::aidl::android::hardware::tv::tuner::Result;
+using ::aidl::android::media::tv::tunerresourcemanager::TunerFrontendInfo;
+using ::android::defaultServiceManager;
+using ::android::IBinder;
+using ::android::interface_cast;
+using ::android::IServiceManager;
+using ::android::sp;
+using ::android::String16;
+using ::android::binder::Status;
+using ::android::content::pm::IPackageManagerNative;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
TunerService::TunerService() {
sp<IServiceManager> serviceMgr = defaultServiceManager();
- sp<content::pm::IPackageManagerNative> packageMgr;
+ sp<IPackageManagerNative> packageMgr;
if (serviceMgr.get() == nullptr) {
ALOGE("%s: Cannot find service manager", __func__);
return;
} else {
sp<IBinder> binder = serviceMgr->waitForService(String16("package_native"));
- packageMgr = interface_cast<content::pm::IPackageManagerNative>(binder);
+ packageMgr = interface_cast<IPackageManagerNative>(binder);
}
- bool hasFeature = false;
if (packageMgr != nullptr) {
- binder::Status status = packageMgr->hasSystemFeature(FEATURE_TUNER, 0, &hasFeature);
+ bool hasFeature = false;
+ Status status = packageMgr->hasSystemFeature(FEATURE_TUNER, 0, &hasFeature);
if (!status.isOk()) {
- ALOGE("%s: hasSystemFeature failed: %s",
- __func__, status.exceptionMessage().c_str());
+ ALOGE("%s: hasSystemFeature failed: %s", __func__, status.exceptionMessage().c_str());
return;
}
if (!hasFeature) {
@@ -93,231 +96,149 @@
}
bool TunerService::hasITuner() {
- ALOGD("hasITuner");
+ ALOGV("hasITuner");
if (mTuner != nullptr) {
return true;
}
- mTuner = ITuner::getService();
- if (mTuner == nullptr) {
- ALOGE("Failed to get ITuner service");
+ const string statsServiceName = string() + ITuner::descriptor + "/default";
+ if (AServiceManager_isDeclared(statsServiceName.c_str())) {
+ ::ndk::SpAIBinder binder(AServiceManager_waitForService(statsServiceName.c_str()));
+ mTuner = ITuner::fromBinder(binder);
+ } else {
+ mTuner = nullptr;
+ ALOGE("Failed to get Tuner HAL Service");
return false;
}
- mTunerVersion = TUNER_HAL_VERSION_1_0;
- mTuner_1_1 = ::android::hardware::tv::tuner::V1_1::ITuner::castFrom(mTuner);
- if (mTuner_1_1 != nullptr) {
- mTunerVersion = TUNER_HAL_VERSION_1_1;
- } else {
- ALOGE("Failed to get ITuner_1_1 service");
- }
+
+ mTunerVersion = TUNER_HAL_VERSION_2_0;
+ // TODO: Enable this after Tuner HAL is frozen.
+ // if (mTuner->getInterfaceVersion(&mTunerVersion).isOk()) {
+ // // Tuner AIDL HAL version 1 will be Tuner HAL 2.0
+ // mTunerVersion = (mTunerVersion + 1) << 16;
+ //}
+
return true;
}
-bool TunerService::hasITuner_1_1() {
- ALOGD("hasITuner_1_1");
- hasITuner();
- return (mTunerVersion == TUNER_HAL_VERSION_1_1);
-}
-
-Status TunerService::openDemux(
- int /* demuxHandle */, std::shared_ptr<ITunerDemux>* _aidl_return) {
- ALOGD("openDemux");
+::ndk::ScopedAStatus TunerService::openDemux(int32_t /* in_demuxHandle */,
+ shared_ptr<ITunerDemux>* _aidl_return) {
+ ALOGV("openDemux");
if (!hasITuner()) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::NOT_INITIALIZED));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res;
- uint32_t id;
- sp<IDemux> demuxSp = nullptr;
- shared_ptr<ITunerDemux> tunerDemux = nullptr;
- mTuner->openDemux([&](Result r, uint32_t demuxId, const sp<IDemux>& demux) {
- demuxSp = demux;
- id = demuxId;
- res = r;
- ALOGD("open demux, id = %d", demuxId);
- });
- if (res == Result::SUCCESS) {
- tunerDemux = ::ndk::SharedRefBase::make<TunerDemux>(demuxSp, id);
- *_aidl_return = tunerDemux->ref<ITunerDemux>();
- return Status::ok();
+ vector<int32_t> id;
+ shared_ptr<IDemux> demux;
+ auto status = mTuner->openDemux(&id, &demux);
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerDemux>(demux, id[0]);
}
- ALOGW("open demux failed, res = %d", res);
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
+ return status;
}
-Status TunerService::getDemuxCaps(TunerDemuxCapabilities* _aidl_return) {
- ALOGD("getDemuxCaps");
+::ndk::ScopedAStatus TunerService::getDemuxCaps(DemuxCapabilities* _aidl_return) {
+ ALOGV("getDemuxCaps");
if (!hasITuner()) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::NOT_INITIALIZED));
- }
- Result res;
- DemuxCapabilities caps;
- mTuner->getDemuxCaps([&](Result r, const DemuxCapabilities& demuxCaps) {
- caps = demuxCaps;
- res = r;
- });
- if (res == Result::SUCCESS) {
- *_aidl_return = getAidlDemuxCaps(caps);
- return Status::ok();
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- ALOGW("Get demux caps failed, res = %d", res);
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
+ return mTuner->getDemuxCaps(_aidl_return);
}
-Status TunerService::getFrontendIds(vector<int32_t>* ids) {
+::ndk::ScopedAStatus TunerService::getFrontendIds(vector<int32_t>* ids) {
if (!hasITuner()) {
- return Status::fromServiceSpecificError(
- static_cast<int32_t>(Result::NOT_INITIALIZED));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- hidl_vec<FrontendId> feIds;
- Result res = getHidlFrontendIds(feIds);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- ids->resize(feIds.size());
- copy(feIds.begin(), feIds.end(), ids->begin());
- return Status::ok();
+ return mTuner->getFrontendIds(ids);
}
-Status TunerService::getFrontendInfo(int32_t id, TunerFrontendInfo* _aidl_return) {
+::ndk::ScopedAStatus TunerService::getFrontendInfo(int32_t id, FrontendInfo* _aidl_return) {
if (!hasITuner()) {
ALOGE("ITuner service is not init.");
return ::ndk::ScopedAStatus::fromServiceSpecificError(
static_cast<int32_t>(Result::UNAVAILABLE));
}
- FrontendInfo info;
- Result res = getHidlFrontendInfo(id, info);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- TunerFrontendInfo tunerInfo = convertToAidlFrontendInfo(info);
- *_aidl_return = tunerInfo;
- return Status::ok();
+ return mTuner->getFrontendInfo(id, _aidl_return);
}
-Status TunerService::getFrontendDtmbCapabilities(
- int32_t id, TunerFrontendDtmbCapabilities* _aidl_return) {
- if (!hasITuner_1_1()) {
- ALOGE("ITuner_1_1 service is not init.");
+::ndk::ScopedAStatus TunerService::openFrontend(int32_t frontendHandle,
+ shared_ptr<ITunerFrontend>* _aidl_return) {
+ if (!hasITuner()) {
+ ALOGE("ITuner service is not init.");
return ::ndk::ScopedAStatus::fromServiceSpecificError(
static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res;
- FrontendDtmbCapabilities dtmbCaps;
- mTuner_1_1->getFrontendDtmbCapabilities(id,
- [&](Result r, const FrontendDtmbCapabilities& caps) {
- dtmbCaps = caps;
- res = r;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- TunerFrontendDtmbCapabilities aidlDtmbCaps{
- .transmissionModeCap = (int)dtmbCaps.transmissionModeCap,
- .bandwidthCap = (int)dtmbCaps.bandwidthCap,
- .modulationCap = (int)dtmbCaps.modulationCap,
- .codeRateCap = (int)dtmbCaps.codeRateCap,
- .guardIntervalCap = (int)dtmbCaps.guardIntervalCap,
- .interleaveModeCap = (int)dtmbCaps.interleaveModeCap,
- };
-
- *_aidl_return = aidlDtmbCaps;
- return Status::ok();
-}
-
-Status TunerService::openFrontend(
- int32_t frontendHandle, shared_ptr<ITunerFrontend>* _aidl_return) {
- if (!hasITuner()) {
- ALOGE("ITuner service is not init.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- Result status;
- sp<IFrontend> frontend;
int id = getResourceIdFromHandle(frontendHandle, FRONTEND);
- mTuner->openFrontendById(id, [&](Result result, const sp<IFrontend>& fe) {
- frontend = fe;
- status = result;
- });
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ shared_ptr<IFrontend> frontend;
+ auto status = mTuner->openFrontendById(id, &frontend);
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerFrontend>(frontend, id);
}
- *_aidl_return = ::ndk::SharedRefBase::make<TunerFrontend>(frontend, id);
- return Status::ok();
+
+ return status;
}
-Status TunerService::openLnb(int lnbHandle, shared_ptr<ITunerLnb>* _aidl_return) {
+::ndk::ScopedAStatus TunerService::openLnb(int lnbHandle, shared_ptr<ITunerLnb>* _aidl_return) {
if (!hasITuner()) {
ALOGD("get ITuner failed");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status;
- sp<ILnb> lnb;
+ shared_ptr<ILnb> lnb;
int id = getResourceIdFromHandle(lnbHandle, LNB);
- mTuner->openLnbById(id, [&](Result result, const sp<ILnb>& lnbSp){
- lnb = lnbSp;
- status = result;
- });
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ auto status = mTuner->openLnbById(id, &lnb);
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerLnb>(lnb, id);
}
- *_aidl_return = ::ndk::SharedRefBase::make<TunerLnb>(lnb, id);
- return Status::ok();
+ return status;
}
-Status TunerService::openLnbByName(const string& lnbName, shared_ptr<ITunerLnb>* _aidl_return) {
+::ndk::ScopedAStatus TunerService::openLnbByName(const string& lnbName,
+ shared_ptr<ITunerLnb>* _aidl_return) {
if (!hasITuner()) {
ALOGE("get ITuner failed");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- int lnbId;
- Result status;
- sp<ILnb> lnb;
- mTuner->openLnbByName(lnbName, [&](Result r, LnbId id, const sp<ILnb>& lnbSp) {
- status = r;
- lnb = lnbSp;
- lnbId = (int)id;
- });
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ vector<int32_t> id;
+ shared_ptr<ILnb> lnb;
+ auto status = mTuner->openLnbByName(lnbName, &id, &lnb);
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerLnb>(lnb, id[0]);
}
- *_aidl_return = ::ndk::SharedRefBase::make<TunerLnb>(lnb, lnbId);
- return Status::ok();
+ return ::ndk::ScopedAStatus::ok();
}
-Status TunerService::openDescrambler(int32_t /*descramblerHandle*/,
- std::shared_ptr<ITunerDescrambler>* _aidl_return) {
+::ndk::ScopedAStatus TunerService::openDescrambler(int32_t /*descramblerHandle*/,
+ shared_ptr<ITunerDescrambler>* _aidl_return) {
if (!hasITuner()) {
ALOGD("get ITuner failed");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status;
- sp<IDescrambler> descrambler;
- //int id = getResourceIdFromHandle(descramblerHandle, DESCRAMBLER);
- mTuner->openDescrambler([&](Result r, const sp<IDescrambler>& descramblerSp) {
- status = r;
- descrambler = descramblerSp;
- });
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ shared_ptr<IDescrambler> descrambler;
+ // int id = getResourceIdFromHandle(descramblerHandle, DESCRAMBLER);
+ auto status = mTuner->openDescrambler(&descrambler);
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerDescrambler>(descrambler);
}
- *_aidl_return = ::ndk::SharedRefBase::make<TunerDescrambler>(descrambler);
- return Status::ok();
+ return status;
}
void TunerService::updateTunerResources() {
- if (!hasITuner() || mTunerResourceManager == NULL) {
+ if (!hasITuner() || mTunerResourceManager == nullptr) {
ALOGE("Failed to updateTunerResources");
return;
}
@@ -327,29 +248,30 @@
// TODO: update Demux, Descrambler.
}
-Status TunerService::getTunerHalVersion(int* _aidl_return) {
+::ndk::ScopedAStatus TunerService::getTunerHalVersion(int* _aidl_return) {
hasITuner();
*_aidl_return = mTunerVersion;
- return Status::ok();
+ return ::ndk::ScopedAStatus::ok();
}
void TunerService::updateFrontendResources() {
- hidl_vec<FrontendId> ids;
- Result res = getHidlFrontendIds(ids);
- if (res != Result::SUCCESS) {
+ vector<int32_t> ids;
+ auto status = mTuner->getFrontendIds(&ids);
+ if (!status.isOk()) {
return;
}
+
vector<TunerFrontendInfo> infos;
for (int i = 0; i < ids.size(); i++) {
FrontendInfo frontendInfo;
- Result res = getHidlFrontendInfo((int)ids[i], frontendInfo);
- if (res != Result::SUCCESS) {
+ auto res = mTuner->getFrontendInfo(ids[i], &frontendInfo);
+ if (!res.isOk()) {
continue;
}
TunerFrontendInfo tunerFrontendInfo{
- .handle = getResourceHandleFromId((int)ids[i], FRONTEND),
- .type = static_cast<int>(frontendInfo.type),
- .exclusiveGroupId = static_cast<int>(frontendInfo.exclusiveGroupId),
+ .handle = getResourceHandleFromId((int)ids[i], FRONTEND),
+ .type = static_cast<int>(frontendInfo.type),
+ .exclusiveGroupId = frontendInfo.exclusiveGroupId,
};
infos.push_back(tunerFrontendInfo);
}
@@ -357,26 +279,21 @@
}
void TunerService::updateLnbResources() {
- vector<int> handles = getLnbHandles();
+ vector<int32_t> handles = getLnbHandles();
if (handles.size() == 0) {
return;
}
mTunerResourceManager->setLnbInfoList(handles);
}
-vector<int> TunerService::getLnbHandles() {
- vector<int> lnbHandles;
- if (mTuner != NULL) {
- Result res;
- vector<LnbId> lnbIds;
- mTuner->getLnbIds([&](Result r, const hardware::hidl_vec<LnbId>& ids) {
- lnbIds = ids;
- res = r;
- });
- if (res != Result::SUCCESS || lnbIds.size() == 0) {
- } else {
+vector<int32_t> TunerService::getLnbHandles() {
+ vector<int32_t> lnbHandles;
+ if (mTuner != nullptr) {
+ vector<int32_t> lnbIds;
+ auto res = mTuner->getLnbIds(&lnbIds);
+ if (res.isOk()) {
for (int i = 0; i < lnbIds.size(); i++) {
- lnbHandles.push_back(getResourceHandleFromId((int)lnbIds[i], LNB));
+ lnbHandles.push_back(getResourceHandleFromId(lnbIds[i], LNB));
}
}
}
@@ -384,186 +301,8 @@
return lnbHandles;
}
-Result TunerService::getHidlFrontendIds(hidl_vec<FrontendId>& ids) {
- if (mTuner == NULL) {
- return Result::NOT_INITIALIZED;
- }
- Result res;
- mTuner->getFrontendIds([&](Result r, const hidl_vec<FrontendId>& frontendIds) {
- ids = frontendIds;
- res = r;
- });
- return res;
-}
-
-Result TunerService::getHidlFrontendInfo(int id, FrontendInfo& info) {
- if (mTuner == NULL) {
- return Result::NOT_INITIALIZED;
- }
- Result res;
- mTuner->getFrontendInfo(id, [&](Result r, const FrontendInfo& feInfo) {
- info = feInfo;
- res = r;
- });
- return res;
-}
-
-TunerDemuxCapabilities TunerService::getAidlDemuxCaps(DemuxCapabilities caps) {
- TunerDemuxCapabilities aidlCaps{
- .numDemux = (int)caps.numDemux,
- .numRecord = (int)caps.numRecord,
- .numPlayback = (int)caps.numPlayback,
- .numTsFilter = (int)caps.numTsFilter,
- .numSectionFilter = (int)caps.numSectionFilter,
- .numAudioFilter = (int)caps.numAudioFilter,
- .numVideoFilter = (int)caps.numVideoFilter,
- .numPesFilter = (int)caps.numPesFilter,
- .numPcrFilter = (int)caps.numPcrFilter,
- .numBytesInSectionFilter = (int)caps.numBytesInSectionFilter,
- .filterCaps = (int)caps.filterCaps,
- .bTimeFilter = caps.bTimeFilter,
- };
- aidlCaps.linkCaps.resize(caps.linkCaps.size());
- copy(caps.linkCaps.begin(), caps.linkCaps.end(), aidlCaps.linkCaps.begin());
- return aidlCaps;
-}
-
-TunerFrontendInfo TunerService::convertToAidlFrontendInfo(FrontendInfo halInfo) {
- TunerFrontendInfo info{
- .type = (int)halInfo.type,
- .minFrequency = (int)halInfo.minFrequency,
- .maxFrequency = (int)halInfo.maxFrequency,
- .minSymbolRate = (int)halInfo.minSymbolRate,
- .maxSymbolRate = (int)halInfo.maxSymbolRate,
- .acquireRange = (int)halInfo.acquireRange,
- .exclusiveGroupId = (int)halInfo.exclusiveGroupId,
- };
- for (int i = 0; i < halInfo.statusCaps.size(); i++) {
- info.statusCaps.push_back((int)halInfo.statusCaps[i]);
- }
-
- TunerFrontendCapabilities caps;
- switch (halInfo.type) {
- case FrontendType::ANALOG: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::analogCaps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendAnalogCapabilities analogCaps{
- .typeCap = (int)halInfo.frontendCaps.analogCaps().typeCap,
- .sifStandardCap = (int)halInfo.frontendCaps.analogCaps().sifStandardCap,
- };
- caps.set<TunerFrontendCapabilities::analogCaps>(analogCaps);
- }
- break;
- }
- case FrontendType::ATSC: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::atscCaps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendAtscCapabilities atscCaps{
- .modulationCap = (int)halInfo.frontendCaps.atscCaps().modulationCap,
- };
- caps.set<TunerFrontendCapabilities::atscCaps>(atscCaps);
- }
- break;
- }
- case FrontendType::ATSC3: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::atsc3Caps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendAtsc3Capabilities atsc3Caps{
- .bandwidthCap = (int)halInfo.frontendCaps.atsc3Caps().bandwidthCap,
- .modulationCap = (int)halInfo.frontendCaps.atsc3Caps().modulationCap,
- .timeInterleaveModeCap =
- (int)halInfo.frontendCaps.atsc3Caps().timeInterleaveModeCap,
- .codeRateCap = (int)halInfo.frontendCaps.atsc3Caps().codeRateCap,
- .demodOutputFormatCap
- = (int)halInfo.frontendCaps.atsc3Caps().demodOutputFormatCap,
- .fecCap = (int)halInfo.frontendCaps.atsc3Caps().fecCap,
- };
- caps.set<TunerFrontendCapabilities::atsc3Caps>(atsc3Caps);
- }
- break;
- }
- case FrontendType::DVBC: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::dvbcCaps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendCableCapabilities cableCaps{
- .modulationCap = (int)halInfo.frontendCaps.dvbcCaps().modulationCap,
- .codeRateCap = (int64_t)halInfo.frontendCaps.dvbcCaps().fecCap,
- .annexCap = (int)halInfo.frontendCaps.dvbcCaps().annexCap,
- };
- caps.set<TunerFrontendCapabilities::cableCaps>(cableCaps);
- }
- break;
- }
- case FrontendType::DVBS: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::dvbsCaps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendDvbsCapabilities dvbsCaps{
- .modulationCap = (int)halInfo.frontendCaps.dvbsCaps().modulationCap,
- .codeRateCap = (long)halInfo.frontendCaps.dvbsCaps().innerfecCap,
- .standard = (int)halInfo.frontendCaps.dvbsCaps().standard,
- };
- caps.set<TunerFrontendCapabilities::dvbsCaps>(dvbsCaps);
- }
- break;
- }
- case FrontendType::DVBT: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::dvbtCaps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendDvbtCapabilities dvbtCaps{
- .transmissionModeCap = (int)halInfo.frontendCaps.dvbtCaps().transmissionModeCap,
- .bandwidthCap = (int)halInfo.frontendCaps.dvbtCaps().bandwidthCap,
- .constellationCap = (int)halInfo.frontendCaps.dvbtCaps().constellationCap,
- .codeRateCap = (int)halInfo.frontendCaps.dvbtCaps().coderateCap,
- .hierarchyCap = (int)halInfo.frontendCaps.dvbtCaps().hierarchyCap,
- .guardIntervalCap = (int)halInfo.frontendCaps.dvbtCaps().guardIntervalCap,
- .isT2Supported = (bool)halInfo.frontendCaps.dvbtCaps().isT2Supported,
- .isMisoSupported = (bool)halInfo.frontendCaps.dvbtCaps().isMisoSupported,
- };
- caps.set<TunerFrontendCapabilities::dvbtCaps>(dvbtCaps);
- }
- break;
- }
- case FrontendType::ISDBS: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::isdbsCaps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendIsdbsCapabilities isdbsCaps{
- .modulationCap = (int)halInfo.frontendCaps.isdbsCaps().modulationCap,
- .codeRateCap = (int)halInfo.frontendCaps.isdbsCaps().coderateCap,
- };
- caps.set<TunerFrontendCapabilities::isdbsCaps>(isdbsCaps);
- }
- break;
- }
- case FrontendType::ISDBS3: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::isdbs3Caps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendIsdbs3Capabilities isdbs3Caps{
- .modulationCap = (int)halInfo.frontendCaps.isdbs3Caps().modulationCap,
- .codeRateCap = (int)halInfo.frontendCaps.isdbs3Caps().coderateCap,
- };
- caps.set<TunerFrontendCapabilities::isdbs3Caps>(isdbs3Caps);
- }
- break;
- }
- case FrontendType::ISDBT: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::isdbtCaps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendIsdbtCapabilities isdbtCaps{
- .modeCap = (int)halInfo.frontendCaps.isdbtCaps().modeCap,
- .bandwidthCap = (int)halInfo.frontendCaps.isdbtCaps().bandwidthCap,
- .modulationCap = (int)halInfo.frontendCaps.isdbtCaps().modulationCap,
- .codeRateCap = (int)halInfo.frontendCaps.isdbtCaps().coderateCap,
- .guardIntervalCap = (int)halInfo.frontendCaps.isdbtCaps().guardIntervalCap,
- };
- caps.set<TunerFrontendCapabilities::isdbtCaps>(isdbtCaps);
- }
- break;
- }
- default:
- break;
- }
-
- info.caps = caps;
- return info;
-}
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerService.h b/services/tuner/TunerService.h
index f8e2ee6..164bef8 100644
--- a/services/tuner/TunerService.h
+++ b/services/tuner/TunerService.h
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2020, The Android Open Source Project
+ * Copyright (c) 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.
@@ -17,61 +17,33 @@
#ifndef ANDROID_MEDIA_TUNERSERVICE_H
#define ANDROID_MEDIA_TUNERSERVICE_H
-#include <aidl/android/media/tv/tunerresourcemanager/ITunerResourceManager.h>
+#include <aidl/android/hardware/tv/tuner/BnFilterCallback.h>
+#include <aidl/android/hardware/tv/tuner/DemuxFilterEvent.h>
+#include <aidl/android/hardware/tv/tuner/DemuxFilterStatus.h>
+#include <aidl/android/hardware/tv/tuner/ITuner.h>
#include <aidl/android/media/tv/tuner/BnTunerService.h>
-#include <android/hardware/tv/tuner/1.1/ITuner.h>
-#include <fmq/AidlMessageQueue.h>
-#include <fmq/EventFlag.h>
-#include <fmq/MessageQueue.h>
+#include <aidl/android/media/tv/tunerresourcemanager/ITunerResourceManager.h>
-using ::aidl::android::hardware::common::fmq::GrantorDescriptor;
-using ::aidl::android::hardware::common::fmq::MQDescriptor;
-using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
-using ::aidl::android::media::tv::tuner::BnTunerService;
-using ::aidl::android::media::tv::tuner::ITunerDemux;
-using ::aidl::android::media::tv::tuner::ITunerDescrambler;
-using ::aidl::android::media::tv::tuner::ITunerFrontend;
-using ::aidl::android::media::tv::tuner::ITunerLnb;
-using ::aidl::android::media::tv::tuner::TunerDemuxCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendDtmbCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendInfo;
+using ::aidl::android::hardware::tv::tuner::BnFilterCallback;
+using ::aidl::android::hardware::tv::tuner::DemuxCapabilities;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterEvent;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterStatus;
+using ::aidl::android::hardware::tv::tuner::FrontendInfo;
+using ::aidl::android::hardware::tv::tuner::ITuner;
using ::aidl::android::media::tv::tunerresourcemanager::ITunerResourceManager;
-using ::android::hardware::details::logError;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::kSynchronizedReadWrite;
-using ::android::hardware::EventFlag;
-using ::android::hardware::MessageQueue;
-using ::android::hardware::MQDescriptorSync;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::tv::tuner::V1_0::DemuxCapabilities;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterAvSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterStatus;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
-using ::android::hardware::tv::tuner::V1_0::FrontendId;
-using ::android::hardware::tv::tuner::V1_0::FrontendInfo;
-using ::android::hardware::tv::tuner::V1_0::IDemux;
-using ::android::hardware::tv::tuner::V1_0::IDescrambler;
-using ::android::hardware::tv::tuner::V1_0::IFilter;
-using ::android::hardware::tv::tuner::V1_0::IFilterCallback;
-using ::android::hardware::tv::tuner::V1_0::ITuner;
-using ::android::hardware::tv::tuner::V1_0::Result;
-
-using Status = ::ndk::ScopedAStatus;
-
using namespace std;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
const static int TUNER_HAL_VERSION_UNKNOWN = 0;
const static int TUNER_HAL_VERSION_1_0 = 1 << 16;
const static int TUNER_HAL_VERSION_1_1 = (1 << 16) | 1;
+const static int TUNER_HAL_VERSION_2_0 = 2 << 16;
// System Feature defined in PackageManager
static const ::android::String16 FEATURE_TUNER(::android::String16("android.hardware.tv.tuner"));
@@ -82,40 +54,40 @@
DESCRAMBLER,
} TunerResourceType;
-struct FilterCallback : public IFilterCallback {
+struct FilterCallback : public BnFilterCallback {
~FilterCallback() {}
- Return<void> onFilterEvent(const DemuxFilterEvent&) {
- return Void();
+ virtual ::ndk::ScopedAStatus onFilterEvent(
+ const vector<DemuxFilterEvent>& /* events */) override {
+ return ::ndk::ScopedAStatus::ok();
}
- Return<void> onFilterStatus(const DemuxFilterStatus) {
- return Void();
+
+ virtual ::ndk::ScopedAStatus onFilterStatus(const DemuxFilterStatus /*status*/) override {
+ return ::ndk::ScopedAStatus::ok();
}
};
class TunerService : public BnTunerService {
- typedef AidlMessageQueue<int8_t, SynchronizedReadWrite> AidlMessageQueue;
- typedef MessageQueue<uint8_t, kSynchronizedReadWrite> HidlMessageQueue;
- typedef MQDescriptor<int8_t, SynchronizedReadWrite> AidlMQDesc;
-
public:
static char const *getServiceName() { return "media.tuner"; }
static binder_status_t instantiate();
TunerService();
virtual ~TunerService();
- Status getFrontendIds(vector<int32_t>* ids) override;
- Status getFrontendInfo(int32_t id, TunerFrontendInfo* _aidl_return) override;
- Status getFrontendDtmbCapabilities(
- int32_t id, TunerFrontendDtmbCapabilities* _aidl_return) override;
- Status openFrontend(
- int32_t frontendHandle, shared_ptr<ITunerFrontend>* _aidl_return) override;
- Status openLnb(int lnbHandle, shared_ptr<ITunerLnb>* _aidl_return) override;
- Status openLnbByName(const string& lnbName, shared_ptr<ITunerLnb>* _aidl_return) override;
- Status openDemux(int32_t demuxHandle, std::shared_ptr<ITunerDemux>* _aidl_return) override;
- Status getDemuxCaps(TunerDemuxCapabilities* _aidl_return) override;
- Status openDescrambler(int32_t descramblerHandle,
- std::shared_ptr<ITunerDescrambler>* _aidl_return) override;
- Status getTunerHalVersion(int* _aidl_return) override;
+ ::ndk::ScopedAStatus getFrontendIds(vector<int32_t>* out_ids) override;
+ ::ndk::ScopedAStatus getFrontendInfo(int32_t in_frontendHandle,
+ FrontendInfo* _aidl_return) override;
+ ::ndk::ScopedAStatus openFrontend(int32_t in_frontendHandle,
+ shared_ptr<ITunerFrontend>* _aidl_return) override;
+ ::ndk::ScopedAStatus openLnb(int32_t in_lnbHandle,
+ shared_ptr<ITunerLnb>* _aidl_return) override;
+ ::ndk::ScopedAStatus openLnbByName(const string& in_lnbName,
+ shared_ptr<ITunerLnb>* _aidl_return) override;
+ ::ndk::ScopedAStatus openDemux(int32_t in_demuxHandle,
+ shared_ptr<ITunerDemux>* _aidl_return) override;
+ ::ndk::ScopedAStatus getDemuxCaps(DemuxCapabilities* _aidl_return) override;
+ ::ndk::ScopedAStatus openDescrambler(int32_t in_descramblerHandle,
+ shared_ptr<ITunerDescrambler>* _aidl_return) override;
+ ::ndk::ScopedAStatus getTunerHalVersion(int32_t* _aidl_return) override;
// TODO: create a map between resource id and handles.
static int getResourceIdFromHandle(int resourceHandle, int /*type*/) {
@@ -131,27 +103,21 @@
private:
bool hasITuner();
- bool hasITuner_1_1();
void updateTunerResources();
-
void updateFrontendResources();
void updateLnbResources();
- Result getHidlFrontendIds(hidl_vec<FrontendId>& ids);
- Result getHidlFrontendInfo(int id, FrontendInfo& info);
- vector<int> getLnbHandles();
+ vector<int32_t> getLnbHandles();
- TunerDemuxCapabilities getAidlDemuxCaps(DemuxCapabilities caps);
- TunerFrontendInfo convertToAidlFrontendInfo(FrontendInfo halInfo);
-
- sp<ITuner> mTuner;
- sp<::android::hardware::tv::tuner::V1_1::ITuner> mTuner_1_1;
-
+ shared_ptr<ITuner> mTuner;
shared_ptr<ITunerResourceManager> mTunerResourceManager;
int mResourceRequestCount = 0;
-
int mTunerVersion = TUNER_HAL_VERSION_UNKNOWN;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERSERVICE_H
diff --git a/services/tuner/TunerTimeFilter.cpp b/services/tuner/TunerTimeFilter.cpp
index ea9da30..73cd6b4 100644
--- a/services/tuner/TunerTimeFilter.cpp
+++ b/services/tuner/TunerTimeFilter.cpp
@@ -18,97 +18,91 @@
#include "TunerTimeFilter.h"
-using ::android::hardware::tv::tuner::V1_0::Result;
-using ::android::hardware::tv::tuner::V1_1::Constant64Bit;
+#include <aidl/android/hardware/tv/tuner/Constant64Bit.h>
+#include <aidl/android/hardware/tv/tuner/Result.h>
+using ::aidl::android::hardware::tv::tuner::Constant64Bit;
+using ::aidl::android::hardware::tv::tuner::Result;
+
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-TunerTimeFilter::TunerTimeFilter(sp<ITimeFilter> timeFilter) {
+TunerTimeFilter::TunerTimeFilter(shared_ptr<ITimeFilter> timeFilter) {
mTimeFilter = timeFilter;
}
TunerTimeFilter::~TunerTimeFilter() {
- mTimeFilter = NULL;
+ mTimeFilter = nullptr;
}
-Status TunerTimeFilter::setTimeStamp(int64_t timeStamp) {
- if (mTimeFilter == NULL) {
+::ndk::ScopedAStatus TunerTimeFilter::setTimeStamp(int64_t timeStamp) {
+ if (mTimeFilter == nullptr) {
ALOGE("ITimeFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mTimeFilter->setTimeStamp(timeStamp);
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ return mTimeFilter->setTimeStamp(timeStamp);
}
-Status TunerTimeFilter::clearTimeStamp() {
- if (mTimeFilter == NULL) {
+::ndk::ScopedAStatus TunerTimeFilter::clearTimeStamp() {
+ if (mTimeFilter == nullptr) {
ALOGE("ITimeFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mTimeFilter->clearTimeStamp();
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ return mTimeFilter->clearTimeStamp();
}
-Status TunerTimeFilter::getSourceTime(int64_t* _aidl_return) {
- if (mTimeFilter == NULL) {
+::ndk::ScopedAStatus TunerTimeFilter::getSourceTime(int64_t* _aidl_return) {
+ if (mTimeFilter == nullptr) {
*_aidl_return = (int64_t)Constant64Bit::INVALID_PRESENTATION_TIME_STAMP;
ALOGE("ITimeFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status;
- mTimeFilter->getSourceTime(
- [&](Result r, uint64_t t) {
- status = r;
- *_aidl_return = t;
- });
- if (status != Result::SUCCESS) {
+ auto status = mTimeFilter->getSourceTime(_aidl_return);
+ if (!status.isOk()) {
*_aidl_return = (int64_t)Constant64Bit::INVALID_PRESENTATION_TIME_STAMP;
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
}
- return Status::ok();
+ return status;
}
-Status TunerTimeFilter::getTimeStamp(int64_t* _aidl_return) {
- if (mTimeFilter == NULL) {
+::ndk::ScopedAStatus TunerTimeFilter::getTimeStamp(int64_t* _aidl_return) {
+ if (mTimeFilter == nullptr) {
*_aidl_return = (int64_t)Constant64Bit::INVALID_PRESENTATION_TIME_STAMP;
ALOGE("ITimeFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status;
- mTimeFilter->getTimeStamp(
- [&](Result r, uint64_t t) {
- status = r;
- *_aidl_return = t;
- });
- if (status != Result::SUCCESS) {
+ auto status = mTimeFilter->getTimeStamp(_aidl_return);
+ if (!status.isOk()) {
*_aidl_return = (int64_t)Constant64Bit::INVALID_PRESENTATION_TIME_STAMP;
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
}
- return Status::ok();
+ return status;
}
-Status TunerTimeFilter::close() {
- if (mTimeFilter == NULL) {
+::ndk::ScopedAStatus TunerTimeFilter::close() {
+ if (mTimeFilter == nullptr) {
ALOGE("ITimeFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mTimeFilter->close();
- mTimeFilter = NULL;
+ auto status = mTimeFilter->close();
+ mTimeFilter = nullptr;
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return status;
}
+
+} // namespace tuner
+} // namespace tv
+} // namespace media
} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerTimeFilter.h b/services/tuner/TunerTimeFilter.h
index d675319..c111694 100644
--- a/services/tuner/TunerTimeFilter.h
+++ b/services/tuner/TunerTimeFilter.h
@@ -17,38 +17,41 @@
#ifndef ANDROID_MEDIA_TUNERFTIMEFILTER_H
#define ANDROID_MEDIA_TUNERFTIMEFILTER_H
+#include <aidl/android/hardware/tv/tuner/ITimeFilter.h>
#include <aidl/android/media/tv/tuner/BnTunerTimeFilter.h>
-#include <android/hardware/tv/tuner/1.0/ITimeFilter.h>
-#include <android/hardware/tv/tuner/1.1/types.h>
#include <media/stagefright/foundation/ADebug.h>
#include <utils/Log.h>
-using Status = ::ndk::ScopedAStatus;
-using ::aidl::android::media::tv::tuner::BnTunerTimeFilter;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::tv::tuner::V1_0::ITimeFilter;
+using ::aidl::android::hardware::tv::tuner::ITimeFilter;
using namespace std;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
class TunerTimeFilter : public BnTunerTimeFilter {
public:
- TunerTimeFilter(sp<ITimeFilter> timeFilter);
+ TunerTimeFilter(shared_ptr<ITimeFilter> timeFilter);
virtual ~TunerTimeFilter();
- Status setTimeStamp(int64_t timeStamp) override;
- Status clearTimeStamp() override;
- Status getSourceTime(int64_t* _aidl_return) override;
- Status getTimeStamp(int64_t* _aidl_return) override;
- Status close() override;
+
+ ::ndk::ScopedAStatus setTimeStamp(int64_t in_timeStamp) override;
+ ::ndk::ScopedAStatus clearTimeStamp() override;
+ ::ndk::ScopedAStatus getSourceTime(int64_t* _aidl_return) override;
+ ::ndk::ScopedAStatus getTimeStamp(int64_t* _aidl_return) override;
+ ::ndk::ScopedAStatus close() override;
private:
- sp<ITimeFilter> mTimeFilter;
+ shared_ptr<ITimeFilter> mTimeFilter;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERFTIMEFILTER_H
diff --git a/services/tuner/main_tunerservice.cpp b/services/tuner/main_tunerservice.cpp
index 586a0e2..bda2f71 100644
--- a/services/tuner/main_tunerservice.cpp
+++ b/services/tuner/main_tunerservice.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Android Open Source Project
+ * Copyright (C) 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.
@@ -14,30 +14,27 @@
* limitations under the License.
*/
-#include <utils/Log.h>
+#include <android-base/logging.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
-#include <binder/ProcessState.h>
-#include <hidl/HidlTransportSupport.h>
+#include <utils/Log.h>
#include "TunerService.h"
+using ::aidl::android::media::tv::tuner::TunerService;
+
using namespace android;
-int main(int argc __unused, char** argv) {
+int main() {
ALOGD("Tuner service starting");
- strcpy(argv[0], "media.tuner");
sp<ProcessState> proc(ProcessState::self());
sp<IServiceManager> sm = defaultServiceManager();
- ALOGD("ServiceManager: %p", sm.get());
binder_status_t status = TunerService::instantiate();
- if (status != STATUS_OK) {
- ALOGD("Failed to add tuner service as AIDL interface");
- return -1;
- }
+ CHECK(status == STATUS_OK);
ProcessState::self()->startThreadPool();
IPCThreadState::self()->joinThreadPool();
+ return EXIT_FAILURE; // should not reached
}