Migrate native tuner to new AIDL HAL.
After this change, tuner java and jni will not reply on HIDL anymore. It
also cleans up the the unused HIDL direct calls.
Bug: 191825295
Test: atest android.media.tv.tuner.cts
Change-Id: I0113565568119a79ed631b318cc8ccd32e0ae2ec
diff --git a/media/jni/tuner/ClientHelper.h b/media/jni/tuner/ClientHelper.h
index 508dccf..d7a847a 100644
--- a/media/jni/tuner/ClientHelper.h
+++ b/media/jni/tuner/ClientHelper.h
@@ -17,22 +17,18 @@
#ifndef _ANDROID_MEDIA_TV_CLIENT_HELPER_H_
#define _ANDROID_MEDIA_TV_CLIENT_HELPER_H_
+#include <aidl/android/hardware/tv/tuner/Result.h>
#include <android/binder_parcel_utils.h>
-#include <android/hardware/tv/tuner/1.1/types.h>
#include <utils/Log.h>
+using ::aidl::android::hardware::tv::tuner::Result;
using Status = ::ndk::ScopedAStatus;
-using ::android::hardware::tv::tuner::V1_0::Result;
-
-using namespace std;
-
namespace android {
-struct ClientHelper {
-
+class ClientHelper {
public:
- static Result getServiceSpecificErrorCode(Status& s) {
+ static Result getServiceSpecificErrorCode(Status& s) {
if (s.getExceptionCode() == EX_SERVICE_SPECIFIC) {
return static_cast<Result>(s.getServiceSpecificError());
} else if (s.isOk()) {
@@ -42,6 +38,7 @@
return Result::UNKNOWN_ERROR;
}
};
+
} // namespace android
-#endif // _ANDROID_MEDIA_TV_CLIENT_HELPER_H_
\ No newline at end of file
+#endif // _ANDROID_MEDIA_TV_CLIENT_HELPER_H_
diff --git a/media/jni/tuner/DemuxClient.cpp b/media/jni/tuner/DemuxClient.cpp
index 6c4295b..4ee3f48 100644
--- a/media/jni/tuner/DemuxClient.cpp
+++ b/media/jni/tuner/DemuxClient.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.
@@ -16,52 +16,41 @@
#define LOG_TAG "DemuxClient"
+#include "DemuxClient.h"
+
+#include <aidl/android/hardware/tv/tuner/Constant.h>
+#include <aidl/android/hardware/tv/tuner/Constant64Bit.h>
#include <android-base/logging.h>
#include <utils/Log.h>
-#include "DemuxClient.h"
-
-using ::aidl::android::media::tv::tuner::TunerFrontendSettings;
-
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
-using ::android::hardware::tv::tuner::V1_0::Result;
+using ::aidl::android::hardware::tv::tuner::Constant;
+using ::aidl::android::hardware::tv::tuner::Constant64Bit;
namespace android {
-
/////////////// DemuxClient ///////////////////////
-
DemuxClient::DemuxClient(shared_ptr<ITunerDemux> tunerDemux) {
mTunerDemux = tunerDemux;
- mId = -1;
}
DemuxClient::~DemuxClient() {
- mTunerDemux = NULL;
- mDemux = NULL;
- mId = -1;
-}
-
-// TODO: remove after migration to Tuner Service is done.
-void DemuxClient::setHidlDemux(sp<IDemux> demux) {
- mDemux = demux;
+ mTunerDemux = nullptr;
}
Result DemuxClient::setFrontendDataSource(sp<FrontendClient> frontendClient) {
- if (mTunerDemux != NULL) {
- Status s = mTunerDemux->setFrontendDataSource(frontendClient->getAidlFrontend());
- return ClientHelper::getServiceSpecificErrorCode(s);
+ if (frontendClient == nullptr) {
+ return Result::INVALID_ARGUMENT;
}
- if (mDemux != NULL) {
- Result res = mDemux->setFrontendDataSource(frontendClient->getId());
- return res;
+ if (mTunerDemux != nullptr) {
+ Status s = mTunerDemux->setFrontendDataSource(frontendClient->getAidlFrontend());
+ return ClientHelper::getServiceSpecificErrorCode(s);
}
return Result::INVALID_STATE;
}
Result DemuxClient::setFrontendDataSourceById(int frontendId) {
- if (mTunerDemux != NULL) {
+ if (mTunerDemux != nullptr) {
Status s = mTunerDemux->setFrontendDataSourceById(frontendId);
return ClientHelper::getServiceSpecificErrorCode(s);
}
@@ -69,251 +58,114 @@
return Result::INVALID_STATE;
}
-sp<FilterClient> DemuxClient::openFilter(DemuxFilterType type, int bufferSize,
- sp<FilterClientCallback> cb) {
- if (mTunerDemux != NULL) {
+sp<FilterClient> DemuxClient::openFilter(const DemuxFilterType& type, int32_t bufferSize,
+ sp<FilterClientCallback> cb) {
+ if (cb == nullptr) {
+ return nullptr;
+ }
+
+ if (mTunerDemux != nullptr) {
shared_ptr<ITunerFilter> tunerFilter;
shared_ptr<TunerFilterCallback> callback =
::ndk::SharedRefBase::make<TunerFilterCallback>(cb);
- Status s = mTunerDemux->openFilter((int)type.mainType, getSubType(type),
- bufferSize, callback, &tunerFilter);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return NULL;
+ Status s = mTunerDemux->openFilter(type, bufferSize, callback, &tunerFilter);
+ if (!s.isOk()) {
+ return nullptr;
}
return new FilterClient(type, tunerFilter);
}
- if (mDemux != NULL) {
- sp<HidlFilterCallback> callback = new HidlFilterCallback(cb);
- sp<IFilter> hidlFilter = openHidlFilter(type, bufferSize, callback);
- if (hidlFilter != NULL) {
- sp<FilterClient> filterClient = new FilterClient(type, NULL);
- filterClient->setHidlFilter(hidlFilter);
- return filterClient;
- }
- }
-
- return NULL;
+ return nullptr;
}
sp<TimeFilterClient> DemuxClient::openTimeFilter() {
- if (mTunerDemux != NULL) {
+ if (mTunerDemux != nullptr) {
shared_ptr<ITunerTimeFilter> tunerTimeFilter;
Status s = mTunerDemux->openTimeFilter(&tunerTimeFilter);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return NULL;
+ if (!s.isOk()) {
+ return nullptr;
}
return new TimeFilterClient(tunerTimeFilter);
}
- if (mDemux != NULL) {
- sp<ITimeFilter> hidlTimeFilter = openHidlTimeFilter();
- if (hidlTimeFilter != NULL) {
- sp<TimeFilterClient> timeFilterClient = new TimeFilterClient(NULL);
- timeFilterClient->setHidlTimeFilter(hidlTimeFilter);
- return timeFilterClient;
- }
- }
-
- return NULL;
+ return nullptr;
}
-int DemuxClient::getAvSyncHwId(sp<FilterClient> filterClient) {
- if (mTunerDemux != NULL) {
- int hwId;
+int32_t DemuxClient::getAvSyncHwId(sp<FilterClient> filterClient) {
+ if (filterClient == nullptr) {
+ return static_cast<int32_t>(Constant::INVALID_AV_SYNC_ID);
+ }
+
+ if (mTunerDemux != nullptr) {
+ int32_t hwId;
Status s = mTunerDemux->getAvSyncHwId(filterClient->getAidlFilter(), &hwId);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return INVALID_AV_SYNC_HW_ID;
+ if (!s.isOk()) {
+ return static_cast<int32_t>(Constant::INVALID_AV_SYNC_ID);
}
return hwId;
}
- if (mDemux != NULL) {
- uint32_t avSyncHwId;
- Result res;
- sp<IFilter> halFilter = filterClient->getHalFilter();
- mDemux->getAvSyncHwId(halFilter,
- [&](Result r, uint32_t id) {
- res = r;
- avSyncHwId = id;
- });
- if (res == Result::SUCCESS) {
- return (int) avSyncHwId;
- }
- }
-
- return INVALID_AV_SYNC_HW_ID;
+ return static_cast<int32_t>(Constant::INVALID_AV_SYNC_ID);
}
-long DemuxClient::getAvSyncTime(int avSyncHwId) {
- if (mTunerDemux != NULL) {
+int64_t DemuxClient::getAvSyncTime(int32_t avSyncHwId) {
+ if (mTunerDemux != nullptr) {
int64_t time;
Status s = mTunerDemux->getAvSyncTime(avSyncHwId, &time);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return INVALID_AV_SYNC_TIME;
+ if (!s.isOk()) {
+ return static_cast<int64_t>(Constant64Bit::INVALID_PRESENTATION_TIME_STAMP);
}
return time;
}
- if (mDemux != NULL) {
- 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 (long) time;
- }
- }
-
- return INVALID_AV_SYNC_TIME;
+ return static_cast<int64_t>(Constant64Bit::INVALID_PRESENTATION_TIME_STAMP);
}
-sp<DvrClient> DemuxClient::openDvr(DvrType dvbType, int bufferSize, sp<DvrClientCallback> cb) {
- if (mTunerDemux != NULL) {
+sp<DvrClient> DemuxClient::openDvr(DvrType dvbType, int32_t bufferSize, sp<DvrClientCallback> cb) {
+ if (cb == nullptr) {
+ return nullptr;
+ }
+
+ if (mTunerDemux != nullptr) {
shared_ptr<ITunerDvr> tunerDvr;
shared_ptr<TunerDvrCallback> callback =
::ndk::SharedRefBase::make<TunerDvrCallback>(cb);
- Status s = mTunerDemux->openDvr((int)dvbType, bufferSize, callback, &tunerDvr);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return NULL;
+ Status s = mTunerDemux->openDvr(dvbType, bufferSize, callback, &tunerDvr);
+ if (!s.isOk()) {
+ return nullptr;
}
return new DvrClient(tunerDvr);
}
- if (mDemux != NULL) {
- sp<HidlDvrCallback> callback = new HidlDvrCallback(cb);
- sp<IDvr> hidlDvr = openHidlDvr(dvbType, bufferSize, callback);
- if (hidlDvr != NULL) {
- sp<DvrClient> dvrClient = new DvrClient(NULL);
- dvrClient->setHidlDvr(hidlDvr);
- return dvrClient;
- }
- }
-
- return NULL;
+ return nullptr;
}
-Result DemuxClient::connectCiCam(int ciCamId) {
- if (mTunerDemux != NULL) {
+Result DemuxClient::connectCiCam(int32_t ciCamId) {
+ if (mTunerDemux != nullptr) {
Status s = mTunerDemux->connectCiCam(ciCamId);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mDemux != NULL) {
- return mDemux->connectCiCam(static_cast<uint32_t>(ciCamId));
- }
-
return Result::INVALID_STATE;
}
Result DemuxClient::disconnectCiCam() {
- if (mTunerDemux != NULL) {
+ if (mTunerDemux != nullptr) {
Status s = mTunerDemux->disconnectCiCam();
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mDemux != NULL) {
- return mDemux->disconnectCiCam();
- }
-
return Result::INVALID_STATE;
}
Result DemuxClient::close() {
- if (mTunerDemux != NULL) {
+ if (mTunerDemux != nullptr) {
Status s = mTunerDemux->close();
- mTunerDemux = NULL;
+ mTunerDemux = nullptr;
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mDemux != NULL) {
- Result res = mDemux->close();
- mDemux = NULL;
- return res;
- }
-
return Result::INVALID_STATE;
}
-/////////////// DemuxClient Helper Methods ///////////////////////
-
-sp<IFilter> DemuxClient::openHidlFilter(DemuxFilterType type, int bufferSize,
- sp<HidlFilterCallback> callback) {
- if (mDemux == NULL) {
- return NULL;
- }
-
- sp<IFilter> hidlFilter;
- Result res;
- mDemux->openFilter(type, bufferSize, callback,
- [&](Result r, const sp<IFilter>& filter) {
- hidlFilter = filter;
- res = r;
- });
- if (res != Result::SUCCESS || hidlFilter == NULL) {
- return NULL;
- }
-
- return hidlFilter;
-}
-
-sp<ITimeFilter> DemuxClient::openHidlTimeFilter() {
- if (mDemux == NULL) {
- return NULL;
- }
-
- sp<ITimeFilter> timeFilter;
- Result res;
- mDemux->openTimeFilter(
- [&](Result r, const sp<ITimeFilter>& timeFilterSp) {
- timeFilter = timeFilterSp;
- res = r;
- });
-
- if (res != Result::SUCCESS || timeFilter == NULL) {
- return NULL;
- }
-
- return timeFilter;
-}
-
-sp<IDvr> DemuxClient::openHidlDvr(DvrType dvrType, int bufferSize,
- sp<HidlDvrCallback> callback) {
- if (mDemux == NULL) {
- return NULL;
- }
-
- sp<IDvr> hidlDvr;
- Result res;
- mDemux->openDvr(dvrType, bufferSize, callback,
- [&](Result r, const sp<IDvr>& dvr) {
- hidlDvr = dvr;
- res = r;
- });
- if (res != Result::SUCCESS || hidlDvr == NULL) {
- return NULL;
- }
-
- return hidlDvr;
-}
-
-int DemuxClient::getSubType(DemuxFilterType filterType) {
- switch (filterType.mainType) {
- case DemuxFilterMainType::TS:
- return (int)filterType.subType.tsFilterType();
- case DemuxFilterMainType::MMTP:
- return (int)filterType.subType.mmtpFilterType();
- case DemuxFilterMainType::IP:
- return (int)filterType.subType.ipFilterType();
- case DemuxFilterMainType::TLV:
- return (int)filterType.subType.tlvFilterType();
- case DemuxFilterMainType::ALP:
- return (int)filterType.subType.alpFilterType();
- default:
- return -1;
- }
-}
} // namespace android
diff --git a/media/jni/tuner/DemuxClient.h b/media/jni/tuner/DemuxClient.h
index 46b0a3d..d5f5f2f 100644
--- a/media/jni/tuner/DemuxClient.h
+++ b/media/jni/tuner/DemuxClient.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,12 +17,11 @@
#ifndef _ANDROID_MEDIA_TV_DEMUX_CLIENT_H_
#define _ANDROID_MEDIA_TV_DEMUX_CLIENT_H_
+#include <aidl/android/hardware/tv/tuner/Result.h>
#include <aidl/android/media/tv/tuner/ITunerDemux.h>
-#include <android/hardware/tv/tuner/1.0/IDemux.h>
-#include <android/hardware/tv/tuner/1.1/types.h>
-#include "DvrClient.h"
#include "ClientHelper.h"
+#include "DvrClient.h"
#include "DvrClientCallback.h"
#include "FilterClient.h"
#include "FilterClientCallback.h"
@@ -30,20 +29,14 @@
#include "TimeFilterClient.h"
using Status = ::ndk::ScopedAStatus;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterType;
+using ::aidl::android::hardware::tv::tuner::DvrType;
+using ::aidl::android::hardware::tv::tuner::Result;
using ::aidl::android::media::tv::tuner::ITunerDemux;
using ::aidl::android::media::tv::tuner::ITunerTimeFilter;
-using ::android::hardware::tv::tuner::V1_0::IDemux;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterType;
-using ::android::hardware::tv::tuner::V1_0::DvrType;
-using ::android::hardware::tv::tuner::V1_0::IDemux;
-using ::android::hardware::tv::tuner::V1_0::ITimeFilter;
-
using namespace std;
-const int64_t INVALID_AV_SYNC_TIME = -1;
-const int INVALID_AV_SYNC_HW_ID = -1;
-
namespace android {
struct DemuxClient : public RefBase {
@@ -52,9 +45,6 @@
DemuxClient(shared_ptr<ITunerDemux> tunerDemux);
~DemuxClient();
- // TODO: remove after migration to Tuner Service is done.
- void setHidlDemux(sp<IDemux> demux);
-
/**
* Set a frontend resource as data input of the demux.
*/
@@ -68,7 +58,8 @@
/**
* Open a new filter client.
*/
- sp<FilterClient> openFilter(DemuxFilterType type, int bufferSize, sp<FilterClientCallback> cb);
+ sp<FilterClient> openFilter(const DemuxFilterType& type, int32_t bufferSize,
+ sp<FilterClientCallback> cb);
/**
* Open time filter of the demux.
@@ -78,22 +69,22 @@
/**
* Get hardware sync ID for audio and video.
*/
- int getAvSyncHwId(sp<FilterClient> filterClient);
+ int32_t getAvSyncHwId(sp<FilterClient> filterClient);
/**
* Get current time stamp to use for A/V sync.
*/
- long getAvSyncTime(int avSyncHwId);
+ int64_t getAvSyncTime(int32_t avSyncHwId);
/**
* Open a DVR (Digital Video Record) client.
*/
- sp<DvrClient> openDvr(DvrType dvbType, int bufferSize, sp<DvrClientCallback> cb);
+ sp<DvrClient> openDvr(DvrType dvbType, int32_t bufferSize, sp<DvrClientCallback> cb);
/**
* Connect Conditional Access Modules (CAM) through Common Interface (CI).
*/
- Result connectCiCam(int ciCamId);
+ Result connectCiCam(int32_t ciCamId);
/**
* Disconnect Conditional Access Modules (CAM).
@@ -110,29 +101,12 @@
*/
shared_ptr<ITunerDemux> getAidlDemux() { return mTunerDemux; }
- void setId(int id) { mId = id; }
- int getId() { return mId; }
-
private:
- sp<IFilter> openHidlFilter(DemuxFilterType type, int bufferSize, sp<HidlFilterCallback> cb);
- sp<ITimeFilter> openHidlTimeFilter();
- sp<IDvr> openHidlDvr(DvrType type, int bufferSize, sp<HidlDvrCallback> cb);
- int getSubType(DemuxFilterType filterType);
-
/**
* An AIDL Tuner Demux Singleton assigned at the first time the Tuner Client
* opens a demux. Default null when demux is not opened.
*/
shared_ptr<ITunerDemux> mTunerDemux;
-
- /**
- * A Demux HAL interface that is ready before migrating to the TunerDemux.
- * This is a temprary interface before Tuner Framework migrates to use TunerService.
- * Default null when the HAL service does not exist.
- */
- sp<IDemux> mDemux;
-
- int mId;
};
} // namespace android
diff --git a/media/jni/tuner/DescramblerClient.cpp b/media/jni/tuner/DescramblerClient.cpp
index 3e4ed82..052fa7a 100644
--- a/media/jni/tuner/DescramblerClient.cpp
+++ b/media/jni/tuner/DescramblerClient.cpp
@@ -21,118 +21,69 @@
#include "DescramblerClient.h"
-using ::android::hardware::tv::tuner::V1_0::Result;
-
namespace android {
/////////////// DescramblerClient ///////////////////////
-
DescramblerClient::DescramblerClient(shared_ptr<ITunerDescrambler> tunerDescrambler) {
mTunerDescrambler = tunerDescrambler;
}
DescramblerClient::~DescramblerClient() {
- mTunerDescrambler = NULL;
- mDescrambler = NULL;
-}
-
-// TODO: remove after migration to Tuner Service is done.
-void DescramblerClient::setHidlDescrambler(sp<IDescrambler> descrambler) {
- mDescrambler = descrambler;
+ mTunerDescrambler = nullptr;
}
Result DescramblerClient::setDemuxSource(sp<DemuxClient> demuxClient) {
- if (demuxClient == NULL) {
+ if (demuxClient == nullptr) {
return Result::INVALID_ARGUMENT;
}
- if (mTunerDescrambler != NULL) {
+ if (mTunerDescrambler != nullptr) {
Status s = mTunerDescrambler->setDemuxSource(demuxClient->getAidlDemux());
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mDescrambler != NULL) {
- return mDescrambler->setDemuxSource(demuxClient->getId());
- }
-
return Result::INVALID_STATE;
}
Result DescramblerClient::setKeyToken(vector<uint8_t> keyToken) {
- if (mTunerDescrambler != NULL) {
+ if (mTunerDescrambler != nullptr) {
Status s = mTunerDescrambler->setKeyToken(keyToken);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mDescrambler != NULL) {
- return mDescrambler->setKeyToken(keyToken);
- }
-
return Result::INVALID_STATE;
}
Result DescramblerClient::addPid(DemuxPid pid, sp<FilterClient> optionalSourceFilter) {
- if (mTunerDescrambler != NULL) {
- shared_ptr<ITunerFilter> aidlFilter = (optionalSourceFilter == NULL)
- ? NULL : optionalSourceFilter->getAidlFilter();
- Status s = mTunerDescrambler->addPid(getAidlDemuxPid(pid), aidlFilter);
+ if (mTunerDescrambler != nullptr) {
+ shared_ptr<ITunerFilter> aidlFilter =
+ (optionalSourceFilter == nullptr) ? nullptr : optionalSourceFilter->getAidlFilter();
+ Status s = mTunerDescrambler->addPid(pid, aidlFilter);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mDescrambler != NULL) {
- sp<IFilter> halFilter = (optionalSourceFilter == NULL)
- ? NULL : optionalSourceFilter->getHalFilter();
- return mDescrambler->addPid(pid, halFilter);
- }
-
return Result::INVALID_STATE;
}
Result DescramblerClient::removePid(DemuxPid pid, sp<FilterClient> optionalSourceFilter) {
- if (mTunerDescrambler != NULL) {
- shared_ptr<ITunerFilter> aidlFilter = (optionalSourceFilter == NULL)
- ? NULL : optionalSourceFilter->getAidlFilter();
- Status s = mTunerDescrambler->removePid(getAidlDemuxPid(pid), aidlFilter);
+ if (mTunerDescrambler != nullptr) {
+ shared_ptr<ITunerFilter> aidlFilter =
+ (optionalSourceFilter == nullptr) ? nullptr : optionalSourceFilter->getAidlFilter();
+ Status s = mTunerDescrambler->removePid(pid, aidlFilter);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mDescrambler != NULL) {
- sp<IFilter> halFilter = (optionalSourceFilter == NULL)
- ? NULL : optionalSourceFilter->getHalFilter();
- return mDescrambler->removePid(pid, halFilter);
- }
-
return Result::INVALID_STATE;
}
Result DescramblerClient::close() {
- if (mTunerDescrambler != NULL) {
+ if (mTunerDescrambler != nullptr) {
Status s = mTunerDescrambler->close();
- mTunerDescrambler = NULL;
+ mTunerDescrambler = nullptr;
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mDescrambler != NULL) {
- Result res = mDescrambler->close();
- mDescrambler = NULL;
- return res;
- }
-
return Result::INVALID_STATE;
}
-/////////////// DescramblerClient Helper Methods ///////////////////////
-
-TunerDemuxPid DescramblerClient::getAidlDemuxPid(DemuxPid& pid) {
- TunerDemuxPid aidlPid;
- switch (pid.getDiscriminator()) {
- case DemuxPid::hidl_discriminator::tPid:
- aidlPid.set<TunerDemuxPid::tPid>((int)pid.tPid());
- break;
- case DemuxPid::hidl_discriminator::mmtpPid:
- aidlPid.set<TunerDemuxPid::mmtpPid>((int)pid.mmtpPid());
- break;
- }
- return aidlPid;
-}
} // namespace android
diff --git a/media/jni/tuner/DescramblerClient.h b/media/jni/tuner/DescramblerClient.h
index a8fa1e2..c851e84 100644
--- a/media/jni/tuner/DescramblerClient.h
+++ b/media/jni/tuner/DescramblerClient.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,19 +17,15 @@
#ifndef _ANDROID_MEDIA_TV_DESCRAMBLER_CLIENT_H_
#define _ANDROID_MEDIA_TV_DESCRAMBLER_CLIENT_H_
+#include <aidl/android/hardware/tv/tuner/Result.h>
#include <aidl/android/media/tv/tuner/ITunerDescrambler.h>
-#include <android/hardware/tv/tuner/1.0/IDescrambler.h>
-#include <android/hardware/tv/tuner/1.1/types.h>
#include "DemuxClient.h"
#include "FilterClient.h"
+using ::aidl::android::hardware::tv::tuner::DemuxPid;
+using ::aidl::android::hardware::tv::tuner::Result;
using ::aidl::android::media::tv::tuner::ITunerDescrambler;
-using ::aidl::android::media::tv::tuner::TunerDemuxPid;
-
-using ::android::hardware::tv::tuner::V1_0::IDescrambler;
-using ::android::hardware::tv::tuner::V1_0::Result;
-using ::android::hardware::tv::tuner::V1_0::DemuxPid;
using namespace std;
@@ -41,9 +37,6 @@
DescramblerClient(shared_ptr<ITunerDescrambler> tunerDescrambler);
~DescramblerClient();
- // TODO: remove after migration to Tuner Service is done.
- void setHidlDescrambler(sp<IDescrambler> descrambler);
-
/**
* Set a demux as source of the descrambler.
*/
@@ -70,20 +63,11 @@
Result close();
private:
- TunerDemuxPid getAidlDemuxPid(DemuxPid& pid);
-
/**
* An AIDL Tuner Descrambler Singleton assigned at the first time the Tuner Client
* opens a descrambler. Default null when descrambler is not opened.
*/
shared_ptr<ITunerDescrambler> mTunerDescrambler;
-
- /**
- * A Descrambler HAL interface that is ready before migrating to the TunerDescrambler.
- * This is a temprary interface before Tuner Framework migrates to use TunerService.
- * Default null when the HAL service does not exist.
- */
- sp<IDescrambler> mDescrambler;
};
} // namespace android
diff --git a/media/jni/tuner/DvrClient.cpp b/media/jni/tuner/DvrClient.cpp
index 0476216..052b465 100644
--- a/media/jni/tuner/DvrClient.cpp
+++ b/media/jni/tuner/DvrClient.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,48 +14,42 @@
* limitations under the License.
*/
+//#define LOG_NDEBUG 0
#define LOG_TAG "DvrClient"
+#include "DvrClient.h"
+
+#include <aidl/android/hardware/tv/tuner/DemuxQueueNotifyBits.h>
#include <android-base/logging.h>
-#include <fmq/ConvertMQDescriptors.h>
+#include <inttypes.h>
#include <utils/Log.h>
#include "ClientHelper.h"
-#include "DvrClient.h"
-using ::android::hardware::tv::tuner::V1_0::DemuxQueueNotifyBits;
-using ::android::hardware::tv::tuner::V1_0::Result;
+using ::aidl::android::hardware::tv::tuner::DemuxQueueNotifyBits;
namespace android {
-
/////////////// DvrClient ///////////////////////
-
DvrClient::DvrClient(shared_ptr<ITunerDvr> tunerDvr) {
mTunerDvr = tunerDvr;
mFd = -1;
- mDvrMQ = NULL;
- mDvrMQEventFlag = NULL;
+ mDvrMQ = nullptr;
+ mDvrMQEventFlag = nullptr;
}
DvrClient::~DvrClient() {
- mTunerDvr = NULL;
- mDvr = NULL;
+ mTunerDvr = nullptr;
mFd = -1;
- mDvrMQ = NULL;
- mDvrMQEventFlag = NULL;
+ mDvrMQ = nullptr;
+ mDvrMQEventFlag = nullptr;
}
-// TODO: remove after migration to Tuner Service is done.
-void DvrClient::setHidlDvr(sp<IDvr> dvr) {
- mDvr = dvr;
-}
-
-void DvrClient::setFd(int fd) {
+void DvrClient::setFd(int32_t fd) {
mFd = fd;
}
-long DvrClient::readFromFile(long size) {
- if (mDvrMQ == NULL || mDvrMQEventFlag == NULL) {
+int64_t DvrClient::readFromFile(int64_t size) {
+ if (mDvrMQ == nullptr || mDvrMQEventFlag == nullptr) {
ALOGE("Failed to readFromFile. DVR mq is not configured");
return -1;
}
@@ -64,16 +58,16 @@
return -1;
}
- long available = mDvrMQ->availableToWrite();
- long write = min(size, available);
+ int64_t available = mDvrMQ->availableToWrite();
+ int64_t write = min(size, available);
AidlMQ::MemTransaction tx;
- long ret = 0;
+ int64_t ret = 0;
if (mDvrMQ->beginWrite(write, &tx)) {
auto first = tx.getFirstRegion();
auto data = first.getAddress();
- long length = first.getLength();
- long firstToWrite = min(length, write);
+ int64_t length = first.getLength();
+ int64_t firstToWrite = min(length, write);
ret = read(mFd, data, firstToWrite);
if (ret < 0) {
@@ -81,17 +75,20 @@
return -1;
}
if (ret < firstToWrite) {
- ALOGW("file to MQ, first region: %ld bytes to write, but %ld bytes written",
- firstToWrite, ret);
+ ALOGW("file to MQ, first region: %" PRIu64 " bytes to write, but %" PRIu64
+ " bytes written",
+ firstToWrite, ret);
} else if (firstToWrite < write) {
- ALOGD("write second region: %ld bytes written, %ld bytes in total", ret, write);
+ ALOGV("write second region: %" PRIu64 " bytes written, %" PRIu64 " bytes in total", ret,
+ write);
auto second = tx.getSecondRegion();
data = second.getAddress();
length = second.getLength();
- int secondToWrite = std::min(length, write - firstToWrite);
+ int64_t secondToWrite = std::min(length, write - firstToWrite);
ret += read(mFd, data, secondToWrite);
}
- ALOGD("file to MQ: %ld bytes need to be written, %ld bytes written", write, ret);
+ ALOGV("file to MQ: %" PRIu64 " bytes need to be written, %" PRIu64 " bytes written", write,
+ ret);
if (!mDvrMQ->commitWrite(ret)) {
ALOGE("Error: failed to commit write!");
return -1;
@@ -106,8 +103,8 @@
return ret;
}
-long DvrClient::readFromBuffer(int8_t* buffer, long size) {
- if (mDvrMQ == NULL || mDvrMQEventFlag == NULL) {
+int64_t DvrClient::readFromBuffer(int8_t* buffer, int64_t size) {
+ if (mDvrMQ == nullptr || mDvrMQEventFlag == nullptr) {
ALOGE("Failed to readFromBuffer. DVR mq is not configured");
return -1;
}
@@ -116,7 +113,7 @@
return -1;
}
- long available = mDvrMQ->availableToWrite();
+ int64_t available = mDvrMQ->availableToWrite();
size = min(size, available);
if (mDvrMQ->write(buffer, size)) {
@@ -128,8 +125,8 @@
return size;
}
-long DvrClient::writeToFile(long size) {
- if (mDvrMQ == NULL || mDvrMQEventFlag == NULL) {
+int64_t DvrClient::writeToFile(int64_t size) {
+ if (mDvrMQ == nullptr || mDvrMQEventFlag == nullptr) {
ALOGE("Failed to writeToFile. DVR mq is not configured");
return -1;
}
@@ -138,16 +135,16 @@
return -1;
}
- long available = mDvrMQ->availableToRead();
- long toRead = min(size, available);
+ int64_t available = mDvrMQ->availableToRead();
+ int64_t toRead = min(size, available);
- long ret = 0;
+ int64_t ret = 0;
AidlMQ::MemTransaction tx;
if (mDvrMQ->beginRead(toRead, &tx)) {
auto first = tx.getFirstRegion();
auto data = first.getAddress();
- long length = first.getLength();
- long firstToRead = std::min(length, toRead);
+ int64_t length = first.getLength();
+ int64_t firstToRead = std::min(length, toRead);
ret = write(mFd, data, firstToRead);
if (ret < 0) {
@@ -155,16 +152,18 @@
return -1;
}
if (ret < firstToRead) {
- ALOGW("MQ to file: %ld bytes read, but %ld bytes written", firstToRead, ret);
+ ALOGW("MQ to file: %" PRIu64 " bytes read, but %" PRIu64 " bytes written", firstToRead,
+ ret);
} else if (firstToRead < toRead) {
- ALOGD("read second region: %ld bytes read, %ld bytes in total", ret, toRead);
+ ALOGV("read second region: %" PRIu64 " bytes read, %" PRIu64 " bytes in total", ret,
+ toRead);
auto second = tx.getSecondRegion();
data = second.getAddress();
length = second.getLength();
- int secondToRead = toRead - firstToRead;
+ int32_t secondToRead = toRead - firstToRead;
ret += write(mFd, data, secondToRead);
}
- ALOGD("MQ to file: %ld bytes to be read, %ld bytes written", toRead, ret);
+ ALOGV("MQ to file: %" PRIu64 " bytes to be read, %" PRIu64 " bytes written", toRead, ret);
if (!mDvrMQ->commitRead(ret)) {
ALOGE("Error: failed to commit read!");
return 0;
@@ -179,8 +178,8 @@
return ret;
}
-long DvrClient::writeToBuffer(int8_t* buffer, long size) {
- if (mDvrMQ == NULL || mDvrMQEventFlag == NULL) {
+int64_t DvrClient::writeToBuffer(int8_t* buffer, int64_t size) {
+ if (mDvrMQ == nullptr || mDvrMQEventFlag == nullptr) {
ALOGE("Failed to writetoBuffer. DVR mq is not configured");
return -1;
}
@@ -189,7 +188,7 @@
return -1;
}
- long available = mDvrMQ->availableToRead();
+ int64_t available = mDvrMQ->availableToRead();
size = min(size, available);
if (mDvrMQ->read(buffer, size)) {
@@ -202,9 +201,8 @@
}
Result DvrClient::configure(DvrSettings settings) {
- if (mTunerDvr != NULL) {
- TunerDvrSettings dvrSettings = getAidlDvrSettingsFromHidl(settings);
- Status s = mTunerDvr->configure(dvrSettings);
+ if (mTunerDvr != nullptr) {
+ Status s = mTunerDvr->configure(settings);
Result res = ClientHelper::getServiceSpecificErrorCode(s);
if (res != Result::SUCCESS) {
return res;
@@ -221,196 +219,95 @@
return res;
}
- if (mDvr != NULL) {
- Result res = mDvr->configure(settings);
- if (res == Result::SUCCESS) {
- MQDescriptorSync<uint8_t> dvrMQDesc;
- res = getQueueDesc(dvrMQDesc);
- if (res == Result::SUCCESS) {
- AidlMQDesc aidlMQDesc;
- unsafeHidlToAidlMQDescriptor<uint8_t, int8_t, SynchronizedReadWrite>(
- dvrMQDesc, &aidlMQDesc);
- mDvrMQ = new (nothrow) AidlMessageQueue(aidlMQDesc);
- EventFlag::createEventFlag(mDvrMQ->getEventFlagWord(), &mDvrMQEventFlag);
- }
- }
- return res;
- }
-
return Result::INVALID_STATE;
}
Result DvrClient::attachFilter(sp<FilterClient> filterClient) {
- if (mTunerDvr != NULL) {
- Status s = mTunerDvr->attachFilter(filterClient->getAidlFilter());
- return ClientHelper::getServiceSpecificErrorCode(s);
+ if (filterClient == nullptr) {
+ return Result::INVALID_ARGUMENT;
}
- if (mDvr != NULL) {
- sp<IFilter> hidlFilter = filterClient->getHalFilter();
- if (hidlFilter == NULL) {
- return Result::INVALID_ARGUMENT;
- }
- return mDvr->attachFilter(hidlFilter);
+ if (mTunerDvr != nullptr) {
+ Status s = mTunerDvr->attachFilter(filterClient->getAidlFilter());
+ return ClientHelper::getServiceSpecificErrorCode(s);
}
return Result::INVALID_STATE;
}
Result DvrClient::detachFilter(sp<FilterClient> filterClient) {
- if (mTunerDvr != NULL) {
- Status s = mTunerDvr->detachFilter(filterClient->getAidlFilter());
- return ClientHelper::getServiceSpecificErrorCode(s);
+ if (filterClient == nullptr) {
+ return Result::INVALID_ARGUMENT;
}
- if (mDvr != NULL) {
- sp<IFilter> hidlFilter = filterClient->getHalFilter();
- if (hidlFilter == NULL) {
- return Result::INVALID_ARGUMENT;
- }
- return mDvr->detachFilter(hidlFilter);
+ if (mTunerDvr != nullptr) {
+ Status s = mTunerDvr->detachFilter(filterClient->getAidlFilter());
+ return ClientHelper::getServiceSpecificErrorCode(s);
}
return Result::INVALID_STATE;
}
Result DvrClient::start() {
- if (mTunerDvr != NULL) {
+ if (mTunerDvr != nullptr) {
Status s = mTunerDvr->start();
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mDvr != NULL) {
- return mDvr->start();
- }
-
return Result::INVALID_STATE;
}
Result DvrClient::stop() {
- if (mTunerDvr != NULL) {
+ if (mTunerDvr != nullptr) {
Status s = mTunerDvr->stop();
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mDvr != NULL) {
- return mDvr->stop();
- }
-
return Result::INVALID_STATE;
}
Result DvrClient::flush() {
- if (mTunerDvr != NULL) {
+ if (mTunerDvr != nullptr) {
Status s = mTunerDvr->flush();
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mDvr != NULL) {
- return mDvr->flush();
- }
-
return Result::INVALID_STATE;
}
Result DvrClient::close() {
- if (mDvrMQEventFlag != NULL) {
+ if (mDvrMQEventFlag != nullptr) {
EventFlag::deleteEventFlag(&mDvrMQEventFlag);
}
- mDvrMQ = NULL;
+ mDvrMQ = nullptr;
- if (mTunerDvr != NULL) {
+ if (mTunerDvr != nullptr) {
Status s = mTunerDvr->close();
- mTunerDvr = NULL;
+ mTunerDvr = nullptr;
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mDvr != NULL) {
- Result res = mDvr->close();
- mDvr = NULL;
- return res;
- }
-
return Result::INVALID_STATE;
}
-/////////////// IDvrCallback ///////////////////////
-
-HidlDvrCallback::HidlDvrCallback(sp<DvrClientCallback> dvrClientCallback)
- : mDvrClientCallback(dvrClientCallback) {}
-
-Return<void> HidlDvrCallback::onRecordStatus(const RecordStatus status) {
- if (mDvrClientCallback != NULL) {
- mDvrClientCallback->onRecordStatus(status);
- }
- return Void();
-}
-
-Return<void> HidlDvrCallback::onPlaybackStatus(const PlaybackStatus status) {
- if (mDvrClientCallback != NULL) {
- mDvrClientCallback->onPlaybackStatus(status);
- }
- return Void();
-}
-
/////////////// TunerDvrCallback ///////////////////////
-
TunerDvrCallback::TunerDvrCallback(sp<DvrClientCallback> dvrClientCallback)
: mDvrClientCallback(dvrClientCallback) {}
-Status TunerDvrCallback::onRecordStatus(int status) {
- if (mDvrClientCallback != NULL) {
- mDvrClientCallback->onRecordStatus(static_cast<RecordStatus>(status));
+Status TunerDvrCallback::onRecordStatus(RecordStatus status) {
+ if (mDvrClientCallback != nullptr) {
+ mDvrClientCallback->onRecordStatus(status);
return Status::ok();
}
return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_STATE));
}
-Status TunerDvrCallback::onPlaybackStatus(int status) {
- if (mDvrClientCallback != NULL) {
- mDvrClientCallback->onPlaybackStatus(static_cast<PlaybackStatus>(status));
+Status TunerDvrCallback::onPlaybackStatus(PlaybackStatus status) {
+ if (mDvrClientCallback != nullptr) {
+ mDvrClientCallback->onPlaybackStatus(status);
return Status::ok();
}
return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_STATE));
}
-/////////////// DvrClient Helper Methods ///////////////////////
-
-Result DvrClient::getQueueDesc(MQDesc& dvrMQDesc) {
- if (mDvr != NULL) {
- Result res = Result::UNKNOWN_ERROR;
- mDvr->getQueueDesc([&](Result r, const MQDesc& desc) {
- dvrMQDesc = desc;
- res = r;
- });
- return res;
- }
-
- return Result::INVALID_STATE;
-}
-
-TunerDvrSettings DvrClient::getAidlDvrSettingsFromHidl(DvrSettings settings) {
- TunerDvrSettings s;
- switch (settings.getDiscriminator()) {
- case DvrSettings::hidl_discriminator::record: {
- s.statusMask = static_cast<int>(settings.record().statusMask);
- s.lowThreshold = static_cast<int>(settings.record().lowThreshold);
- s.highThreshold = static_cast<int>(settings.record().highThreshold);
- s.dataFormat = static_cast<int>(settings.record().dataFormat);
- s.packetSize = static_cast<int>(settings.record().packetSize);
- return s;
- }
- case DvrSettings::hidl_discriminator::playback: {
- s.statusMask = static_cast<int>(settings.playback().statusMask);
- s.lowThreshold = static_cast<int>(settings.playback().lowThreshold);
- s.highThreshold = static_cast<int>(settings.playback().highThreshold);
- s.dataFormat = static_cast<int>(settings.playback().dataFormat);
- s.packetSize = static_cast<int>(settings.playback().packetSize);
- return s;
- }
- default:
- break;
- }
- return s;
-}
} // namespace android
diff --git a/media/jni/tuner/DvrClient.h b/media/jni/tuner/DvrClient.h
index 252554e..9080c72 100644
--- a/media/jni/tuner/DvrClient.h
+++ b/media/jni/tuner/DvrClient.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,36 +17,29 @@
#ifndef _ANDROID_MEDIA_TV_DVR_CLIENT_H_
#define _ANDROID_MEDIA_TV_DVR_CLIENT_H_
+#include <aidl/android/hardware/tv/tuner/DvrSettings.h>
+#include <aidl/android/hardware/tv/tuner/Result.h>
#include <aidl/android/media/tv/tuner/BnTunerDvrCallback.h>
#include <aidl/android/media/tv/tuner/ITunerDvr.h>
-#include <android/hardware/tv/tuner/1.0/IDvr.h>
-#include <android/hardware/tv/tuner/1.0/IDvrCallback.h>
-#include <android/hardware/tv/tuner/1.1/types.h>
#include <fmq/AidlMessageQueue.h>
-#include <fmq/MessageQueue.h>
#include "DvrClientCallback.h"
#include "FilterClient.h"
using Status = ::ndk::ScopedAStatus;
+using ::aidl::android::hardware::common::fmq::MQDescriptor;
using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
+using ::aidl::android::hardware::tv::tuner::DvrSettings;
+using ::aidl::android::hardware::tv::tuner::PlaybackStatus;
+using ::aidl::android::hardware::tv::tuner::RecordStatus;
+using ::aidl::android::hardware::tv::tuner::Result;
using ::aidl::android::media::tv::tuner::BnTunerDvrCallback;
using ::aidl::android::media::tv::tuner::ITunerDvr;
-using ::aidl::android::media::tv::tuner::TunerDvrSettings;
-
-using ::android::hardware::EventFlag;
-using ::android::hardware::MQDescriptorSync;
-using ::android::hardware::MessageQueue;
-using ::android::hardware::tv::tuner::V1_0::DvrSettings;
-using ::android::hardware::tv::tuner::V1_0::IDvr;
-using ::android::hardware::tv::tuner::V1_0::IDvrCallback;
using namespace std;
namespace android {
-using MQ = MessageQueue<uint8_t, kSynchronizedReadWrite>;
-using MQDesc = MQDescriptorSync<uint8_t>;
using AidlMQ = AidlMessageQueue<int8_t, SynchronizedReadWrite>;
using AidlMQDesc = MQDescriptor<int8_t, SynchronizedReadWrite>;
@@ -55,19 +48,8 @@
public:
TunerDvrCallback(sp<DvrClientCallback> dvrClientCallback);
- Status onRecordStatus(int status);
- Status onPlaybackStatus(int status);
-
-private:
- sp<DvrClientCallback> mDvrClientCallback;
-};
-
-struct HidlDvrCallback : public IDvrCallback {
-
-public:
- HidlDvrCallback(sp<DvrClientCallback> dvrClientCallback);
- virtual Return<void> onRecordStatus(const RecordStatus status);
- virtual Return<void> onPlaybackStatus(const PlaybackStatus status);
+ Status onRecordStatus(RecordStatus status);
+ Status onPlaybackStatus(PlaybackStatus status);
private:
sp<DvrClientCallback> mDvrClientCallback;
@@ -79,33 +61,30 @@
DvrClient(shared_ptr<ITunerDvr> tunerDvr);
~DvrClient();
- // TODO: remove after migration to Tuner Service is done.
- void setHidlDvr(sp<IDvr> dvr);
-
/**
* Set the DVR file descriptor.
*/
- void setFd(int fd);
+ void setFd(int32_t fd);
/**
* Read data from file with given size. Return the actual read size.
*/
- long readFromFile(long size);
+ int64_t readFromFile(int64_t size);
/**
* Read data from the given buffer with given size. Return the actual read size.
*/
- long readFromBuffer(int8_t* buffer, long size);
+ int64_t readFromBuffer(int8_t* buffer, int64_t size);
/**
* Write data to file with given size. Return the actual write size.
*/
- long writeToFile(long size);
+ int64_t writeToFile(int64_t size);
/**
* Write data to the given buffer with given size. Return the actual write size.
*/
- long writeToBuffer(int8_t* buffer, long size);
+ int64_t writeToBuffer(int8_t* buffer, int64_t size);
/**
* Configure the DVR.
@@ -143,26 +122,16 @@
Result close();
private:
- Result getQueueDesc(MQDesc& dvrMQDesc);
- TunerDvrSettings getAidlDvrSettingsFromHidl(DvrSettings settings);
-
/**
* An AIDL Tuner Dvr Singleton assigned at the first time the Tuner Client
* opens a dvr. Default null when dvr is not opened.
*/
shared_ptr<ITunerDvr> mTunerDvr;
- /**
- * A Dvr HAL interface that is ready before migrating to the TunerDvr.
- * This is a temprary interface before Tuner Framework migrates to use TunerService.
- * Default null when the HAL service does not exist.
- */
- sp<IDvr> mDvr;
-
AidlMQ* mDvrMQ;
EventFlag* mDvrMQEventFlag;
string mFilePath;
- int mFd;
+ int32_t mFd;
};
} // namespace android
diff --git a/media/jni/tuner/DvrClientCallback.h b/media/jni/tuner/DvrClientCallback.h
index 6684424..a75f199 100644
--- a/media/jni/tuner/DvrClientCallback.h
+++ b/media/jni/tuner/DvrClientCallback.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,8 +17,12 @@
#ifndef _ANDROID_MEDIA_TV_DVR_CLIENT_CALLBACK_H_
#define _ANDROID_MEDIA_TV_DVR_CLIENT_CALLBACK_H_
-using ::android::hardware::tv::tuner::V1_0::PlaybackStatus;
-using ::android::hardware::tv::tuner::V1_0::RecordStatus;
+#include <aidl/android/hardware/tv/tuner/PlaybackStatus.h>
+#include <aidl/android/hardware/tv/tuner/RecordStatus.h>
+#include <utils/RefBase.h>
+
+using ::aidl::android::hardware::tv::tuner::PlaybackStatus;
+using ::aidl::android::hardware::tv::tuner::RecordStatus;
using namespace std;
@@ -30,4 +34,4 @@
};
} // namespace android
-#endif // _ANDROID_MEDIA_TV_DVR_CLIENT_CALLBACK_H_
\ No newline at end of file
+#endif // _ANDROID_MEDIA_TV_DVR_CLIENT_CALLBACK_H_
diff --git a/media/jni/tuner/FilterClient.cpp b/media/jni/tuner/FilterClient.cpp
index 324c09a..eea27ea 100644
--- a/media/jni/tuner/FilterClient.cpp
+++ b/media/jni/tuner/FilterClient.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.
@@ -16,65 +16,43 @@
#define LOG_TAG "FilterClient"
-#include <aidlcommonsupport/NativeHandle.h>
-#include <android-base/logging.h>
-#include <fmq/ConvertMQDescriptors.h>
-#include <utils/Log.h>
-
#include "FilterClient.h"
-using ::aidl::android::media::tv::tuner::TunerDemuxIpAddressSettings;
-using ::aidl::android::media::tv::tuner::TunerFilterAlpConfiguration;
-using ::aidl::android::media::tv::tuner::TunerFilterIpConfiguration;
-using ::aidl::android::media::tv::tuner::TunerFilterMmtpConfiguration;
-using ::aidl::android::media::tv::tuner::TunerFilterMonitorEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterScIndexMask;
-using ::aidl::android::media::tv::tuner::TunerFilterSectionBits;
-using ::aidl::android::media::tv::tuner::TunerFilterSectionCondition;
-using ::aidl::android::media::tv::tuner::TunerFilterSectionTableInfo;
-using ::aidl::android::media::tv::tuner::TunerFilterSharedHandleInfo;
-using ::aidl::android::media::tv::tuner::TunerFilterTlvConfiguration;
-using ::aidl::android::media::tv::tuner::TunerFilterTsConfiguration;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
-using ::android::hardware::tv::tuner::V1_0::DemuxMmtpFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxQueueNotifyBits;
-using ::android::hardware::tv::tuner::V1_0::DemuxStreamId;
-using ::android::hardware::tv::tuner::V1_0::DemuxTpid;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
-using ::android::hardware::tv::tuner::V1_1::DemuxFilterMonitorEvent;
-using ::android::hardware::tv::tuner::V1_1::ScramblingStatus;
+#include <aidl/android/hardware/tv/tuner/DemuxFilterMainType.h>
+#include <aidl/android/hardware/tv/tuner/DemuxQueueNotifyBits.h>
+#include <aidlcommonsupport/NativeHandle.h>
+#include <android-base/logging.h>
+#include <utils/Log.h>
+
+using ::aidl::android::hardware::common::NativeHandle;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterMainType;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterSubType;
+using ::aidl::android::hardware::tv::tuner::DemuxMmtpFilterSettingsFilterSettings;
+using ::aidl::android::hardware::tv::tuner::DemuxMmtpFilterType;
+using ::aidl::android::hardware::tv::tuner::DemuxQueueNotifyBits;
+using ::aidl::android::hardware::tv::tuner::DemuxTsFilterSettingsFilterSettings;
+using ::aidl::android::hardware::tv::tuner::DemuxTsFilterType;
+using ::aidl::android::hardware::tv::tuner::ScramblingStatus;
namespace android {
-
/////////////// FilterClient ///////////////////////
-
FilterClient::FilterClient(DemuxFilterType type, shared_ptr<ITunerFilter> tunerFilter) {
mTunerFilter = tunerFilter;
- mAvSharedHandle = NULL;
+ mAvSharedHandle = nullptr;
checkIsMediaFilter(type);
}
FilterClient::~FilterClient() {
- mTunerFilter = NULL;
- mFilter = NULL;
- mFilter_1_1 = NULL;
- mAvSharedHandle = NULL;
+ mTunerFilter = nullptr;
+ mAvSharedHandle = nullptr;
mAvSharedMemSize = 0;
mIsMediaFilter = false;
mIsPassthroughFilter = false;
- mFilterMQ = NULL;
- mFilterMQEventFlag = NULL;
+ mFilterMQ = nullptr;
+ mFilterMQEventFlag = nullptr;
}
-// TODO: remove after migration to Tuner Service is done.
-void FilterClient::setHidlFilter(sp<IFilter> filter) {
- mFilter = filter;
- mFilter_1_1 = ::android::hardware::tv::tuner::V1_1::IFilter::castFrom(mFilter);
-}
-
-int FilterClient::read(int8_t* buffer, int size) {
+int64_t FilterClient::read(int8_t* buffer, int64_t size) {
Result res = getFilterMq();
if (res != Result::SUCCESS) {
return -1;
@@ -85,8 +63,8 @@
SharedHandleInfo FilterClient::getAvSharedHandleInfo() {
handleAvShareMemory();
SharedHandleInfo info{
- .sharedHandle = (mIsMediaFilter && !mIsPassthroughFilter) ? mAvSharedHandle : NULL,
- .size = mAvSharedMemSize,
+ .sharedHandle = (mIsMediaFilter && !mIsPassthroughFilter) ? mAvSharedHandle : nullptr,
+ .size = mAvSharedMemSize,
};
return info;
@@ -96,8 +74,8 @@
Result res;
checkIsPassthroughFilter(configure);
- if (mTunerFilter != NULL) {
- Status s = mTunerFilter->configure(getAidlFilterSettings(configure));
+ if (mTunerFilter != nullptr) {
+ Status s = mTunerFilter->configure(configure);
res = ClientHelper::getServiceSpecificErrorCode(s);
if (res == Result::SUCCESS) {
getAvSharedHandleInfo();
@@ -105,171 +83,96 @@
return res;
}
- if (mFilter != NULL) {
- res = mFilter->configure(configure);
- if (res == Result::SUCCESS) {
- getAvSharedHandleInfo();
- }
- return res;
- }
-
return Result::INVALID_STATE;
}
-Result FilterClient::configureMonitorEvent(int monitorEventType) {
- if (mTunerFilter != NULL) {
+Result FilterClient::configureMonitorEvent(int32_t monitorEventType) {
+ if (mTunerFilter != nullptr) {
Status s = mTunerFilter->configureMonitorEvent(monitorEventType);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFilter_1_1 != NULL) {
- return mFilter_1_1->configureMonitorEvent(monitorEventType);
- }
-
return Result::INVALID_STATE;
}
-Result FilterClient::configureIpFilterContextId(int cid) {
- if (mTunerFilter != NULL) {
+Result FilterClient::configureIpFilterContextId(int32_t cid) {
+ if (mTunerFilter != nullptr) {
Status s = mTunerFilter->configureIpFilterContextId(cid);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFilter_1_1 != NULL) {
- return mFilter_1_1->configureIpCid(cid);
- }
-
return Result::INVALID_STATE;
}
Result FilterClient::configureAvStreamType(AvStreamType avStreamType) {
- if (mTunerFilter != NULL) {
- int type;
- switch (avStreamType.getDiscriminator()) {
- case AvStreamType::hidl_discriminator::audio:
- type = (int)avStreamType.audio();
- break;
- case AvStreamType::hidl_discriminator::video:
- type = (int)avStreamType.video();
- break;
- }
- Status s = mTunerFilter->configureAvStreamType(type);
+ if (mTunerFilter != nullptr) {
+ Status s = mTunerFilter->configureAvStreamType(avStreamType);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFilter_1_1 != NULL) {
- return mFilter_1_1->configureAvStreamType(avStreamType);
- }
-
return Result::INVALID_STATE;
}
Result FilterClient::start() {
- if (mTunerFilter != NULL) {
+ if (mTunerFilter != nullptr) {
Status s = mTunerFilter->start();
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFilter != NULL) {
- return mFilter->start();
- }
-
return Result::INVALID_STATE;
}
Result FilterClient::stop() {
- if (mTunerFilter != NULL) {
+ if (mTunerFilter != nullptr) {
Status s = mTunerFilter->stop();
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFilter != NULL) {
- return mFilter->stop();
- }
-
return Result::INVALID_STATE;
}
Result FilterClient::flush() {
- if (mTunerFilter != NULL) {
+ if (mTunerFilter != nullptr) {
Status s = mTunerFilter->flush();
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFilter != NULL) {
- return mFilter->flush();
+ return Result::INVALID_STATE;
+}
+
+Result FilterClient::getId(int32_t& id) {
+ if (mTunerFilter != nullptr) {
+ Status s = mTunerFilter->getId(&id);
+ return ClientHelper::getServiceSpecificErrorCode(s);
}
return Result::INVALID_STATE;
}
-Result FilterClient::getId(uint32_t& id) {
- if (mTunerFilter != NULL) {
- int32_t id32Bit;
- Status s = mTunerFilter->getId(&id32Bit);
- id = static_cast<uint32_t>(id32Bit);
+Result FilterClient::getId64Bit(int64_t& id) {
+ if (mTunerFilter != nullptr) {
+ Status s = mTunerFilter->getId64Bit(&id);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFilter != NULL) {
- Result res;
- mFilter->getId([&](Result r, uint32_t filterId) {
- res = r;
- id = filterId;
- });
- return res;
- }
-
- return Result::INVALID_STATE;
-}
-
-Result FilterClient::getId64Bit(uint64_t& id) {
- if (mTunerFilter != NULL) {
- int64_t id64Bit;
- Status s = mTunerFilter->getId64Bit(&id64Bit);
- id = static_cast<uint64_t>(id64Bit);
- return ClientHelper::getServiceSpecificErrorCode(s);
- }
-
- if (mFilter_1_1 != NULL) {
- Result res;
- mFilter_1_1->getId64Bit([&](Result r, uint64_t filterId) {
- res = r;
- id = filterId;
- });
- return res;
- }
-
return Result::INVALID_STATE;
}
Result FilterClient::releaseAvHandle(native_handle_t* handle, uint64_t avDataId) {
- if (mTunerFilter != NULL) {
+ if (mTunerFilter != nullptr) {
Status s = mTunerFilter->releaseAvHandle(makeToAidl(handle), avDataId);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFilter != NULL) {
- return mFilter->releaseAvHandle(hidl_handle(handle), avDataId);
- }
-
return Result::INVALID_STATE;
}
Result FilterClient::setDataSource(sp<FilterClient> filterClient){
- if (mTunerFilter != NULL) {
+ if (mTunerFilter != nullptr) {
Status s = mTunerFilter->setDataSource(filterClient->getAidlFilter());
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFilter != NULL) {
- sp<IFilter> sourceFilter = filterClient->getHalFilter();
- if (sourceFilter == NULL) {
- return Result::INVALID_ARGUMENT;
- }
- return mFilter->setDataSource(sourceFilter);
- }
-
return Result::INVALID_STATE;
}
@@ -277,648 +180,38 @@
if (mFilterMQEventFlag) {
EventFlag::deleteEventFlag(&mFilterMQEventFlag);
}
- mFilterMQEventFlag = NULL;
- mFilterMQ = NULL;
+ mFilterMQEventFlag = nullptr;
+ mFilterMQ = nullptr;
- if (mTunerFilter != NULL) {
+ if (mTunerFilter != nullptr) {
Status s = mTunerFilter->close();
closeAvSharedMemory();
- mTunerFilter = NULL;
+ mTunerFilter = nullptr;
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFilter != NULL) {
- Result res = mFilter->close();
- mFilter = NULL;
- mFilter_1_1 = NULL;
- closeAvSharedMemory();
- return res;
- }
-
return Result::INVALID_STATE;
}
-/////////////// IFilterCallback ///////////////////////
-
-HidlFilterCallback::HidlFilterCallback(sp<FilterClientCallback> filterClientCallback)
- : mFilterClientCallback(filterClientCallback) {}
-
-Return<void> HidlFilterCallback::onFilterStatus(const DemuxFilterStatus status) {
- if (mFilterClientCallback != NULL) {
- mFilterClientCallback->onFilterStatus(status);
- }
- return Void();
-}
-
-Return<void> HidlFilterCallback::onFilterEvent(const DemuxFilterEvent& filterEvent) {
- if (mFilterClientCallback != NULL) {
- mFilterClientCallback->onFilterEvent(filterEvent);
- }
- return Void();
-}
-
-Return<void> HidlFilterCallback::onFilterEvent_1_1(const DemuxFilterEvent& filterEvent,
- const DemuxFilterEventExt& filterEventExt) {
- if (mFilterClientCallback != NULL) {
- mFilterClientCallback->onFilterEvent_1_1(filterEvent, filterEventExt);
- }
- return Void();
-}
-
/////////////// TunerFilterCallback ///////////////////////
TunerFilterCallback::TunerFilterCallback(sp<FilterClientCallback> filterClientCallback)
: mFilterClientCallback(filterClientCallback) {}
-Status TunerFilterCallback::onFilterStatus(int status) {
- if (mFilterClientCallback != NULL) {
- mFilterClientCallback->onFilterStatus(static_cast<DemuxFilterStatus>(status));
+Status TunerFilterCallback::onFilterStatus(DemuxFilterStatus status) {
+ if (mFilterClientCallback != nullptr) {
+ mFilterClientCallback->onFilterStatus(status);
return Status::ok();
}
return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_STATE));
}
-Status TunerFilterCallback::onFilterEvent(const vector<TunerFilterEvent>& filterEvents) {
- if (mFilterClientCallback == NULL) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_STATE));
+Status TunerFilterCallback::onFilterEvent(const vector<DemuxFilterEvent>& filterEvents) {
+ if (mFilterClientCallback != nullptr) {
+ mFilterClientCallback->onFilterEvent(filterEvents);
+ return Status::ok();
}
-
- if (filterEvents.size() == 0) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_ARGUMENT));
- }
-
- DemuxFilterEvent event;
- DemuxFilterEventExt eventExt;
- getHidlFilterEvent(filterEvents, event, eventExt);
- if (eventExt.events.size() > 0) {
- mFilterClientCallback->onFilterEvent_1_1(event, eventExt);
- } else {
- mFilterClientCallback->onFilterEvent(event);
- }
-
- return Status::ok();
-}
-
-/////////////// FilterClient Helper Methods ///////////////////////
-
-TunerFilterConfiguration FilterClient::getAidlFilterSettings(DemuxFilterSettings configure) {
- TunerFilterConfiguration config;
- switch (configure.getDiscriminator()) {
- case DemuxFilterSettings::hidl_discriminator::ts:
- return getAidlTsSettings(configure.ts());
- case DemuxFilterSettings::hidl_discriminator::mmtp:
- return getAidlMmtpSettings(configure.mmtp());
- case DemuxFilterSettings::hidl_discriminator::ip:
- return getAidlIpSettings(configure.ip());
- case DemuxFilterSettings::hidl_discriminator::tlv:
- return getAidlTlvSettings(configure.tlv());
- case DemuxFilterSettings::hidl_discriminator::alp:
- return getAidlAlpSettings(configure.alp());
- default:
- break;
- }
- ALOGE("Wrong DemuxFilterSettings union.");
- return config;
-}
-
-TunerFilterConfiguration FilterClient::getAidlTsSettings(DemuxTsFilterSettings ts) {
- TunerFilterConfiguration config;
- TunerFilterSettings filterSettings;
- switch (ts.filterSettings.getDiscriminator()) {
- case DemuxTsFilterSettings::FilterSettings::hidl_discriminator::av: {
- filterSettings.set<TunerFilterSettings::av>(
- getAidlAvSettings(ts.filterSettings.av()));
- break;
- }
- case DemuxTsFilterSettings::FilterSettings::hidl_discriminator::section: {
- filterSettings.set<TunerFilterSettings::section>(
- getAidlSectionSettings(ts.filterSettings.section()));
- break;
- }
- case DemuxTsFilterSettings::FilterSettings::hidl_discriminator::pesData: {
- filterSettings.set<TunerFilterSettings::pesData>(
- getAidlPesDataSettings(ts.filterSettings.pesData()));
- break;
- }
- case DemuxTsFilterSettings::FilterSettings::hidl_discriminator::record: {
- filterSettings.set<TunerFilterSettings::record>(
- getAidlRecordSettings(ts.filterSettings.record()));
- break;
- }
- default:
- filterSettings.set<TunerFilterSettings::nothing>(true);
- break;
- }
-
- TunerFilterTsConfiguration aidlTs{
- .tpid = static_cast<char16_t>(ts.tpid),
- .filterSettings = filterSettings,
- };
- config.set<TunerFilterConfiguration::ts>(aidlTs);
-
- return config;
-}
-
-TunerFilterConfiguration FilterClient::getAidlMmtpSettings(DemuxMmtpFilterSettings mmtp) {
- TunerFilterConfiguration config;
- TunerFilterSettings filterSettings;
- switch (mmtp.filterSettings.getDiscriminator()) {
- case DemuxMmtpFilterSettings::FilterSettings::hidl_discriminator::av: {
- filterSettings.set<TunerFilterSettings::av>(
- getAidlAvSettings(mmtp.filterSettings.av()));
- break;
- }
- case DemuxMmtpFilterSettings::FilterSettings::hidl_discriminator::section: {
- filterSettings.set<TunerFilterSettings::section>(
- getAidlSectionSettings(mmtp.filterSettings.section()));
- break;
- }
- case DemuxMmtpFilterSettings::FilterSettings::hidl_discriminator::pesData: {
- filterSettings.set<TunerFilterSettings::pesData>(
- getAidlPesDataSettings(mmtp.filterSettings.pesData()));
- break;
- }
- case DemuxMmtpFilterSettings::FilterSettings::hidl_discriminator::record: {
- filterSettings.set<TunerFilterSettings::record>(
- getAidlRecordSettings(mmtp.filterSettings.record()));
- break;
- }
- case DemuxMmtpFilterSettings::FilterSettings::hidl_discriminator::download: {
- filterSettings.set<TunerFilterSettings::download>(
- getAidlDownloadSettings(mmtp.filterSettings.download()));
- break;
- }
- default:
- filterSettings.set<TunerFilterSettings::nothing>(true);
- break;
- }
-
- TunerFilterMmtpConfiguration aidlMmtp{
- .mmtpPid = static_cast<char16_t>(mmtp.mmtpPid),
- .filterSettings = filterSettings,
- };
- config.set<TunerFilterConfiguration::mmtp>(aidlMmtp);
-
- return config;
-}
-
-TunerFilterConfiguration FilterClient::getAidlIpSettings(DemuxIpFilterSettings ip) {
- TunerFilterConfiguration config;
- TunerFilterSettings filterSettings;
- switch (ip.filterSettings.getDiscriminator()) {
- case DemuxIpFilterSettings::FilterSettings::hidl_discriminator::section: {
- filterSettings.set<TunerFilterSettings::section>(
- getAidlSectionSettings(ip.filterSettings.section()));
- break;
- }
- case DemuxIpFilterSettings::FilterSettings::hidl_discriminator::bPassthrough: {
- filterSettings.set<TunerFilterSettings::isPassthrough>(
- ip.filterSettings.bPassthrough());
- break;
- }
- default:
- filterSettings.set<TunerFilterSettings::nothing>(true);
- break;
- }
-
- TunerDemuxIpAddressSettings ipAddr{
- .srcPort = static_cast<char16_t>(ip.ipAddr.srcPort),
- .dstPort = static_cast<char16_t>(ip.ipAddr.dstPort),
- };
- getAidlIpAddress(ip.ipAddr, ipAddr.srcIpAddress, ipAddr.dstIpAddress);
-
- TunerFilterIpConfiguration aidlIp{
- .ipAddr = ipAddr,
- .filterSettings = filterSettings,
- };
- config.set<TunerFilterConfiguration::ip>(aidlIp);
-
- return config;
-}
-
-void FilterClient::getAidlIpAddress(DemuxIpAddress ipAddr,
- TunerDemuxIpAddress& srcIpAddress, TunerDemuxIpAddress& dstIpAddress) {
- switch (ipAddr.srcIpAddress.getDiscriminator()) {
- case DemuxIpAddress::SrcIpAddress::hidl_discriminator::v4: {
- int size = ipAddr.srcIpAddress.v4().size();
- srcIpAddress.isIpV6 = false;
- srcIpAddress.addr.resize(size);
- copy(&ipAddr.srcIpAddress.v4()[0], &ipAddr.srcIpAddress.v4()[size],
- srcIpAddress.addr.begin());
- break;
- }
- case DemuxIpAddress::SrcIpAddress::hidl_discriminator::v6: {
- int size = ipAddr.srcIpAddress.v6().size();
- srcIpAddress.isIpV6 = true;
- srcIpAddress.addr.resize(size);
- copy(&ipAddr.srcIpAddress.v6()[0], &ipAddr.srcIpAddress.v6()[size],
- srcIpAddress.addr.begin());
- break;
- }
- }
- switch (ipAddr.dstIpAddress.getDiscriminator()) {
- case DemuxIpAddress::DstIpAddress::hidl_discriminator::v4: {
- int size = ipAddr.dstIpAddress.v4().size();
- dstIpAddress.isIpV6 = false;
- dstIpAddress.addr.resize(size);
- copy(&ipAddr.dstIpAddress.v4()[0], &ipAddr.dstIpAddress.v4()[size],
- dstIpAddress.addr.begin());
- break;
- }
- case DemuxIpAddress::DstIpAddress::hidl_discriminator::v6: {
- int size = ipAddr.dstIpAddress.v6().size();
- dstIpAddress.isIpV6 = true;
- dstIpAddress.addr.resize(size);
- copy(&ipAddr.dstIpAddress.v6()[0], &ipAddr.dstIpAddress.v6()[size],
- dstIpAddress.addr.begin());
- break;
- }
- }
-}
-
-TunerFilterConfiguration FilterClient::getAidlTlvSettings(DemuxTlvFilterSettings tlv) {
- TunerFilterConfiguration config;
- TunerFilterSettings filterSettings;
- switch (tlv.filterSettings.getDiscriminator()) {
- case DemuxTlvFilterSettings::FilterSettings::hidl_discriminator::section: {
- filterSettings.set<TunerFilterSettings::section>(
- getAidlSectionSettings(tlv.filterSettings.section()));
- break;
- }
- case DemuxTlvFilterSettings::FilterSettings::hidl_discriminator::bPassthrough: {
- filterSettings.set<TunerFilterSettings::isPassthrough>(
- tlv.filterSettings.bPassthrough());
- break;
- }
- default:
- filterSettings.set<TunerFilterSettings::nothing>(true);
- break;
- }
-
- TunerFilterTlvConfiguration aidlTlv{
- .packetType = static_cast<int8_t>(tlv.packetType),
- .isCompressedIpPacket = tlv.isCompressedIpPacket,
- .filterSettings = filterSettings,
- };
- config.set<TunerFilterConfiguration::tlv>(aidlTlv);
-
- return config;
-}
-
-TunerFilterConfiguration FilterClient::getAidlAlpSettings(DemuxAlpFilterSettings alp) {
- TunerFilterConfiguration config;
- TunerFilterSettings filterSettings;
- switch (alp.filterSettings.getDiscriminator()) {
- case DemuxAlpFilterSettings::FilterSettings::hidl_discriminator::section: {
- filterSettings.set<TunerFilterSettings::section>(
- getAidlSectionSettings(alp.filterSettings.section()));
- break;
- }
- default:
- filterSettings.set<TunerFilterSettings::nothing>(true);
- break;
- }
-
- TunerFilterAlpConfiguration aidlAlp{
- .packetType = static_cast<int8_t>(alp.packetType),
- .lengthType = static_cast<int8_t>(alp.lengthType),
- .filterSettings = filterSettings,
- };
- config.set<TunerFilterConfiguration::alp>(aidlAlp);
-
- return config;
-}
-
-TunerFilterAvSettings FilterClient::getAidlAvSettings(DemuxFilterAvSettings hidlAv) {
- TunerFilterAvSettings aidlAv{
- .isPassthrough = hidlAv.isPassthrough,
- };
- return aidlAv;
-}
-
-TunerFilterSectionSettings FilterClient::getAidlSectionSettings(
- DemuxFilterSectionSettings hidlSection) {
- TunerFilterSectionSettings aidlSection;
-
- switch (hidlSection.condition.getDiscriminator()) {
- case DemuxFilterSectionSettings::Condition::hidl_discriminator::sectionBits: {
- TunerFilterSectionBits sectionBits;
- auto hidlSectionBits = hidlSection.condition.sectionBits();
- sectionBits.filter.resize(hidlSectionBits.filter.size());
- sectionBits.mask.resize(hidlSectionBits.mask.size());
- sectionBits.mode.resize(hidlSectionBits.mode.size());
- copy(hidlSectionBits.filter.begin(), hidlSectionBits.filter.end(),
- sectionBits.filter.begin());
- copy(hidlSectionBits.mask.begin(), hidlSectionBits.mask.end(),
- sectionBits.mask.begin());
- copy(hidlSectionBits.mode.begin(), hidlSectionBits.mode.end(),
- sectionBits.mode.begin());
- aidlSection.condition.set<TunerFilterSectionCondition::sectionBits>(sectionBits);
- break;
- }
- case DemuxFilterSectionSettings::Condition::hidl_discriminator::tableInfo: {
- TunerFilterSectionTableInfo tableInfo{
- .tableId = static_cast<char16_t>(hidlSection.condition.tableInfo().tableId),
- .version = static_cast<char16_t>(hidlSection.condition.tableInfo().version),
- };
- aidlSection.condition.set<TunerFilterSectionCondition::tableInfo>(tableInfo);
- break;
- }
- }
- aidlSection.isCheckCrc = hidlSection.isCheckCrc;
- aidlSection.isRepeat = hidlSection.isRepeat;
- aidlSection.isRaw = hidlSection.isRaw;
- return aidlSection;
-}
-
-TunerFilterPesDataSettings FilterClient::getAidlPesDataSettings(
- DemuxFilterPesDataSettings hidlPesData) {
- TunerFilterPesDataSettings aidlPesData{
- .streamId = static_cast<char16_t>(hidlPesData.streamId),
- .isRaw = hidlPesData.isRaw,
- };
- return aidlPesData;
-}
-
-TunerFilterRecordSettings FilterClient::getAidlRecordSettings(
- DemuxFilterRecordSettings hidlRecord) {
- TunerFilterScIndexMask mask;
- switch (hidlRecord.scIndexMask.getDiscriminator()) {
- case DemuxFilterRecordSettings::ScIndexMask::hidl_discriminator::sc: {
- mask.set<TunerFilterScIndexMask::sc>(hidlRecord.scIndexMask.sc());
- break;
- }
- case DemuxFilterRecordSettings::ScIndexMask::hidl_discriminator::scHevc: {
- mask.set<TunerFilterScIndexMask::scHevc>(hidlRecord.scIndexMask.scHevc());
- break;
- }
- default:
- break;
- }
- TunerFilterRecordSettings aidlRecord{
- .tsIndexMask = static_cast<int32_t>(hidlRecord.tsIndexMask),
- .scIndexType = static_cast<int32_t>(hidlRecord.scIndexType),
- .scIndexMask = mask,
- };
- return aidlRecord;
-}
-
-TunerFilterDownloadSettings FilterClient::getAidlDownloadSettings(
- DemuxFilterDownloadSettings hidlDownload) {
- TunerFilterDownloadSettings aidlDownload{
- .downloadId = static_cast<int32_t>(hidlDownload.downloadId),
- };
- return aidlDownload;
-}
-
-void TunerFilterCallback::getHidlFilterEvent(const vector<TunerFilterEvent>& filterEvents,
- DemuxFilterEvent& event, DemuxFilterEventExt& eventExt) {
- switch (filterEvents[0].getTag()) {
- case TunerFilterEvent::media: {
- getHidlMediaEvent(filterEvents, event);
- break;
- }
- case TunerFilterEvent::section: {
- getHidlSectionEvent(filterEvents, event);
- break;
- }
- case TunerFilterEvent::pes: {
- getHidlPesEvent(filterEvents, event);
- break;
- }
- case TunerFilterEvent::tsRecord: {
- getHidlTsRecordEvent(filterEvents, event, eventExt);
- break;
- }
- case TunerFilterEvent::mmtpRecord: {
- getHidlMmtpRecordEvent(filterEvents, event, eventExt);
- break;
- }
- case TunerFilterEvent::download: {
- getHidlDownloadEvent(filterEvents, event);
- break;
- }
- case TunerFilterEvent::ipPayload: {
- getHidlIpPayloadEvent(filterEvents, event);
- break;
- }
- case TunerFilterEvent::temi: {
- getHidlTemiEvent(filterEvents, event);
- break;
- }
- case TunerFilterEvent::monitor: {
- getHidlMonitorEvent(filterEvents, eventExt);
- break;
- }
- case TunerFilterEvent::startId: {
- getHidlRestartEvent(filterEvents, eventExt);
- break;
- }
- }
-}
-
-void TunerFilterCallback::getHidlMediaEvent(
- const vector<TunerFilterEvent>& filterEvents, DemuxFilterEvent& event) {
- event.events.resize(filterEvents.size());
- for (int i = 0; i < filterEvents.size(); i++) {
- hidl_handle handle = hidl_handle(makeFromAidl(filterEvents[i]
- .get<TunerFilterEvent::media>().avMemory));
- event.events[i].media({
- .avMemory = handle,
- .streamId = static_cast<DemuxStreamId>(filterEvents[i]
- .get<TunerFilterEvent::media>().streamId),
- .isPtsPresent = filterEvents[i]
- .get<TunerFilterEvent::media>().isPtsPresent,
- .pts = static_cast<uint64_t>(filterEvents[i]
- .get<TunerFilterEvent::media>().pts),
- .dataLength = static_cast<uint32_t>(filterEvents[i]
- .get<TunerFilterEvent::media>().dataLength),
- .offset = static_cast<uint32_t>(filterEvents[i]
- .get<TunerFilterEvent::media>().offset),
- .isSecureMemory = filterEvents[i]
- .get<TunerFilterEvent::media>().isSecureMemory,
- .avDataId = static_cast<uint64_t>(filterEvents[i]
- .get<TunerFilterEvent::media>().avDataId),
- .mpuSequenceNumber = static_cast<uint32_t>(filterEvents[i]
- .get<TunerFilterEvent::media>().offset),
- .isPesPrivateData = filterEvents[i]
- .get<TunerFilterEvent::media>().isPesPrivateData,
- });
-
- if (filterEvents[i].get<TunerFilterEvent::media>().isAudioExtraMetaData) {
- event.events[i].media().extraMetaData.audio({
- .adFade = static_cast<uint8_t>(filterEvents[i]
- .get<TunerFilterEvent::media>().audio.adFade),
- .adPan = static_cast<uint8_t>(filterEvents[i]
- .get<TunerFilterEvent::media>().audio.adPan),
- .versionTextTag = static_cast<uint8_t>(filterEvents[i]
- .get<TunerFilterEvent::media>().audio.versionTextTag),
- .adGainCenter = static_cast<uint8_t>(filterEvents[i]
- .get<TunerFilterEvent::media>().audio.adGainCenter),
- .adGainFront = static_cast<uint8_t>(filterEvents[i]
- .get<TunerFilterEvent::media>().audio.adGainFront),
- .adGainSurround = static_cast<uint8_t>(filterEvents[i]
- .get<TunerFilterEvent::media>().audio.adGainSurround),
- });
- } else {
- event.events[i].media().extraMetaData.noinit();
- }
- }
-}
-
-void TunerFilterCallback::getHidlSectionEvent(
- const vector<TunerFilterEvent>& filterEvents, DemuxFilterEvent& event) {
- event.events.resize(filterEvents.size());
- for (int i = 0; i < filterEvents.size(); i++) {
- auto section = filterEvents[i].get<TunerFilterEvent::section>();
- event.events[i].section({
- .tableId = static_cast<uint16_t>(section.tableId),
- .version = static_cast<uint16_t>(section.version),
- .sectionNum = static_cast<uint16_t>(section.sectionNum),
- .dataLength = static_cast<uint16_t>(section.dataLength),
- });
- }
-}
-
-void TunerFilterCallback::getHidlPesEvent(
- const vector<TunerFilterEvent>& filterEvents, DemuxFilterEvent& event) {
- event.events.resize(filterEvents.size());
- for (int i = 0; i < filterEvents.size(); i++) {
- auto pes = filterEvents[i].get<TunerFilterEvent::pes>();
- event.events[i].pes({
- .streamId = static_cast<DemuxStreamId>(pes.streamId),
- .dataLength = static_cast<uint16_t>(pes.dataLength),
- .mpuSequenceNumber = static_cast<uint32_t>(pes.mpuSequenceNumber),
- });
- }
-}
-
-void TunerFilterCallback::getHidlTsRecordEvent(const vector<TunerFilterEvent>& filterEvents,
- DemuxFilterEvent& event, DemuxFilterEventExt& eventExt) {
- event.events.resize(filterEvents.size());
- eventExt.events.resize(filterEvents.size());
- for (int i = 0; i < filterEvents.size(); i++) {
- auto ts = filterEvents[i].get<TunerFilterEvent::tsRecord>();
- event.events[i].tsRecord({
- .tsIndexMask = static_cast<uint32_t>(ts.tsIndexMask),
- .byteNumber = static_cast<uint64_t>(ts.byteNumber),
- });
- event.events[i].tsRecord().pid.tPid(static_cast<DemuxTpid>(ts.pid));
-
- switch (ts.scIndexMask.getTag()) {
- case TunerFilterScIndexMask::sc: {
- event.events[i].tsRecord().scIndexMask.sc(
- ts.scIndexMask.get<TunerFilterScIndexMask::sc>());
- break;
- }
- case TunerFilterScIndexMask::scHevc: {
- event.events[i].tsRecord().scIndexMask.scHevc(
- ts.scIndexMask.get<TunerFilterScIndexMask::scHevc>());
- break;
- }
- default:
- break;
- }
-
- if (ts.isExtended) {
- eventExt.events[i].tsRecord({
- .pts = static_cast<uint64_t>(ts.pts),
- .firstMbInSlice = static_cast<uint32_t>(ts.firstMbInSlice),
- });
- } else {
- eventExt.events[i].noinit();
- }
- }
-}
-
-void TunerFilterCallback::getHidlMmtpRecordEvent(const vector<TunerFilterEvent>& filterEvents,
- DemuxFilterEvent& event, DemuxFilterEventExt& eventExt) {
- event.events.resize(filterEvents.size());
- eventExt.events.resize(filterEvents.size());
- for (int i = 0; i < filterEvents.size(); i++) {
- auto mmtp = filterEvents[i].get<TunerFilterEvent::mmtpRecord>();
- event.events[i].mmtpRecord({
- .scHevcIndexMask = static_cast<uint32_t>(mmtp.scHevcIndexMask),
- .byteNumber = static_cast<uint64_t>(mmtp.byteNumber),
- });
-
- if (mmtp.isExtended) {
- eventExt.events[i].mmtpRecord({
- .pts = static_cast<uint64_t>(mmtp.pts),
- .mpuSequenceNumber = static_cast<uint32_t>(mmtp.mpuSequenceNumber),
- .firstMbInSlice = static_cast<uint32_t>(mmtp.firstMbInSlice),
- .tsIndexMask = static_cast<uint32_t>(mmtp.tsIndexMask),
- });
- } else {
- eventExt.events[i].noinit();
- }
- }
-}
-
-void TunerFilterCallback::getHidlDownloadEvent(const vector<TunerFilterEvent>& filterEvents,
- DemuxFilterEvent& event) {
- event.events.resize(filterEvents.size());
- for (int i = 0; i < filterEvents.size(); i++) {
- auto download = filterEvents[i].get<TunerFilterEvent::download>();
- event.events[i].download({
- .itemId = static_cast<uint32_t>(download.itemId),
- .mpuSequenceNumber = static_cast<uint32_t>(download.mpuSequenceNumber),
- .itemFragmentIndex = static_cast<uint32_t>(download.itemFragmentIndex),
- .lastItemFragmentIndex = static_cast<uint32_t>(download.lastItemFragmentIndex),
- .dataLength = static_cast<uint16_t>(download.dataLength),
- });
- }
-}
-
-void TunerFilterCallback::getHidlIpPayloadEvent(const vector<TunerFilterEvent>& filterEvents,
- DemuxFilterEvent& event) {
- event.events.resize(filterEvents.size());
- for (int i = 0; i < filterEvents.size(); i++) {
- auto ip = filterEvents[i].get<TunerFilterEvent::ipPayload>();
- event.events[i].ipPayload({
- .dataLength = static_cast<uint16_t>(ip.dataLength),
- });
- }
-}
-
-void TunerFilterCallback::getHidlTemiEvent(const vector<TunerFilterEvent>& filterEvents,
- DemuxFilterEvent& event) {
- event.events.resize(filterEvents.size());
- for (int i = 0; i < filterEvents.size(); i++) {
- auto temi = filterEvents[i].get<TunerFilterEvent::temi>();
- event.events[i].temi({
- .pts = static_cast<uint64_t>(temi.pts),
- .descrTag = static_cast<uint8_t>(temi.descrTag),
- });
- hidl_vec<uint8_t> descrData(temi.descrData.begin(), temi.descrData.end());
- event.events[i].temi().descrData = descrData;
- }
-}
-
-void TunerFilterCallback::getHidlMonitorEvent(const vector<TunerFilterEvent>& filterEvents,
- DemuxFilterEventExt& eventExt) {
- auto monitor = filterEvents[0].get<TunerFilterEvent::monitor>();
- eventExt.events.resize(1);
- DemuxFilterMonitorEvent monitorEvent;
- switch (monitor.getTag()) {
- case TunerFilterMonitorEvent::scramblingStatus: {
- monitorEvent.scramblingStatus(static_cast<ScramblingStatus>(monitor.scramblingStatus));
- eventExt.events[0].monitorEvent(monitorEvent);
- break;
- }
- case TunerFilterMonitorEvent::cid: {
- monitorEvent.cid(static_cast<uint32_t>(monitor.cid));
- eventExt.events[0].monitorEvent(monitorEvent);
- break;
- }
- }
-}
-
-void TunerFilterCallback::getHidlRestartEvent(const vector<TunerFilterEvent>& filterEvents,
- DemuxFilterEventExt& eventExt) {
- uint32_t startId = filterEvents[0].get<TunerFilterEvent::startId>();
- eventExt.events.resize(1);
- eventExt.events[0].startId(static_cast<uint32_t>(startId));
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_STATE));
}
Result FilterClient::getFilterMq() {
@@ -931,39 +224,21 @@
if (mTunerFilter != NULL) {
Status s = mTunerFilter->getQueueDesc(&aidlMqDesc);
- res = ClientHelper::getServiceSpecificErrorCode(s);
- if (res == Result::SUCCESS) {
+ if (s.isOk()) {
mFilterMQ = new (nothrow) AidlMQ(aidlMqDesc, false/*resetPointer*/);
EventFlag::createEventFlag(mFilterMQ->getEventFlagWord(), &mFilterMQEventFlag);
}
- return res;
- }
-
- if (mFilter != NULL) {
- MQDescriptorSync<uint8_t> filterMQDesc;
- mFilter->getQueueDesc(
- [&](Result r, const MQDescriptorSync<uint8_t>& desc) {
- filterMQDesc = desc;
- res = r;
- });
- if (res == Result::SUCCESS) {
- AidlMQDesc aidlMQDesc;
- unsafeHidlToAidlMQDescriptor<uint8_t, int8_t, SynchronizedReadWrite>(
- filterMQDesc, &aidlMQDesc);
- mFilterMQ = new (nothrow) AidlMessageQueue(aidlMQDesc, false/*resetPointer*/);
- EventFlag::createEventFlag(mFilterMQ->getEventFlagWord(), &mFilterMQEventFlag);
- }
}
return res;
}
-int FilterClient::copyData(int8_t* buffer, int size) {
- if (mFilterMQ == NULL || mFilterMQEventFlag == NULL) {
+int64_t FilterClient::copyData(int8_t* buffer, int64_t size) {
+ if (mFilterMQ == nullptr || mFilterMQEventFlag == nullptr) {
return -1;
}
- int available = mFilterMQ->availableToRead();
+ int64_t available = mFilterMQ->availableToRead();
size = min(size, available);
if (mFilterMQ->read(buffer, size)) {
@@ -977,16 +252,18 @@
void FilterClient::checkIsMediaFilter(DemuxFilterType type) {
if (type.mainType == DemuxFilterMainType::MMTP) {
- if (type.subType.mmtpFilterType() == DemuxMmtpFilterType::AUDIO ||
- type.subType.mmtpFilterType() == DemuxMmtpFilterType::VIDEO) {
+ if (type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>() ==
+ DemuxMmtpFilterType::AUDIO ||
+ type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>() ==
+ DemuxMmtpFilterType::VIDEO) {
mIsMediaFilter = true;
return;
}
}
if (type.mainType == DemuxFilterMainType::TS) {
- if (type.subType.tsFilterType() == DemuxTsFilterType::AUDIO ||
- type.subType.tsFilterType() == DemuxTsFilterType::VIDEO) {
+ if (type.subType.get<DemuxFilterSubType::Tag::tsFilterType>() == DemuxTsFilterType::AUDIO ||
+ type.subType.get<DemuxFilterSubType::Tag::tsFilterType>() == DemuxTsFilterType::VIDEO) {
mIsMediaFilter = true;
return;
}
@@ -1001,15 +278,19 @@
return;
}
- if (configure.getDiscriminator() == DemuxFilterSettings::hidl_discriminator::ts) {
- if (configure.ts().filterSettings.av().isPassthrough) {
+ if (configure.getTag() == DemuxFilterSettings::Tag::ts) {
+ if (configure.get<DemuxFilterSettings::Tag::ts>()
+ .filterSettings.get<DemuxTsFilterSettingsFilterSettings::Tag::av>()
+ .isPassthrough) {
mIsPassthroughFilter = true;
return;
}
}
- if (configure.getDiscriminator() == DemuxFilterSettings::hidl_discriminator::mmtp) {
- if (configure.mmtp().filterSettings.av().isPassthrough) {
+ if (configure.getTag() == DemuxFilterSettings::Tag::mmtp) {
+ if (configure.get<DemuxFilterSettings::Tag::mmtp>()
+ .filterSettings.get<DemuxMmtpFilterSettingsFilterSettings::Tag::av>()
+ .isPassthrough) {
mIsPassthroughFilter = true;
return;
}
@@ -1019,37 +300,28 @@
}
void FilterClient::handleAvShareMemory() {
- if (mAvSharedHandle != NULL) {
+ if (mAvSharedHandle != nullptr) {
return;
}
- if (mTunerFilter != NULL && mIsMediaFilter && !mIsPassthroughFilter) {
- TunerFilterSharedHandleInfo aidlHandleInfo;
- Status s = mTunerFilter->getAvSharedHandleInfo(&aidlHandleInfo);
- if (ClientHelper::getServiceSpecificErrorCode(s) == Result::SUCCESS) {
- mAvSharedHandle = native_handle_clone(makeFromAidl(aidlHandleInfo.handle));
- mAvSharedMemSize = aidlHandleInfo.size;
+ if (mTunerFilter != nullptr && mIsMediaFilter && !mIsPassthroughFilter) {
+ int64_t size;
+ NativeHandle avMemory;
+ Status s = mTunerFilter->getAvSharedHandle(&avMemory, &size);
+ if (s.isOk()) {
+ mAvSharedHandle = native_handle_clone(makeFromAidl(avMemory));
+ mAvSharedMemSize = size;
}
- return;
- }
-
- if (mFilter_1_1 != NULL && mIsMediaFilter && !mIsPassthroughFilter) {
- mFilter_1_1->getAvSharedHandle([&](Result r, hidl_handle avMemory, uint64_t avMemSize) {
- if (r == Result::SUCCESS) {
- mAvSharedHandle = native_handle_clone(avMemory.getNativeHandle());
- mAvSharedMemSize = avMemSize;
- }
- });
}
}
void FilterClient::closeAvSharedMemory() {
- if (mAvSharedHandle == NULL) {
+ if (mAvSharedHandle == nullptr) {
mAvSharedMemSize = 0;
return;
}
native_handle_close(mAvSharedHandle);
native_handle_delete(mAvSharedHandle);
mAvSharedMemSize = 0;
- mAvSharedHandle = NULL;
+ mAvSharedHandle = nullptr;
}
} // namespace android
diff --git a/media/jni/tuner/FilterClient.h b/media/jni/tuner/FilterClient.h
index 5d78bfd..136d1f5 100644
--- a/media/jni/tuner/FilterClient.h
+++ b/media/jni/tuner/FilterClient.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,64 +17,30 @@
#ifndef _ANDROID_MEDIA_TV_FILTER_CLIENT_H_
#define _ANDROID_MEDIA_TV_FILTER_CLIENT_H_
-#include <aidl/android/media/tv/tuner/ITunerFilter.h>
+#include <aidl/android/hardware/tv/tuner/DemuxFilterType.h>
#include <aidl/android/media/tv/tuner/BnTunerFilterCallback.h>
-#include <aidl/android/media/tv/tuner/TunerFilterEvent.h>
-#include <aidl/android/media/tv/tuner/TunerFilterSettings.h>
-#include <aidlcommonsupport/NativeHandle.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 <aidl/android/media/tv/tuner/ITunerFilter.h>
#include <fmq/AidlMessageQueue.h>
-#include <fmq/MessageQueue.h>
#include "ClientHelper.h"
#include "FilterClientCallback.h"
using Status = ::ndk::ScopedAStatus;
+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::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::media::tv::tuner::BnTunerFilterCallback;
using ::aidl::android::media::tv::tuner::ITunerFilter;
-using ::aidl::android::media::tv::tuner::TunerDemuxIpAddress;
-using ::aidl::android::media::tv::tuner::TunerFilterAvSettings;
-using ::aidl::android::media::tv::tuner::TunerFilterConfiguration;
-using ::aidl::android::media::tv::tuner::TunerFilterDownloadSettings;
-using ::aidl::android::media::tv::tuner::TunerFilterEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterPesDataSettings;
-using ::aidl::android::media::tv::tuner::TunerFilterRecordSettings;
-using ::aidl::android::media::tv::tuner::TunerFilterSectionSettings;
-using ::aidl::android::media::tv::tuner::TunerFilterSettings;
-
using ::android::hardware::EventFlag;
-using ::android::hardware::MessageQueue;
-using ::android::hardware::MQDescriptorSync;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_handle;
-using ::android::hardware::tv::tuner::V1_0::DemuxAlpFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxMmtpFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterAvSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterDownloadSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterPesDataSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterRecordSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterSectionSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxIpAddress;
-using ::android::hardware::tv::tuner::V1_0::DemuxIpFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxTlvFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::IFilter;
-using ::android::hardware::tv::tuner::V1_0::Result;
-using ::android::hardware::tv::tuner::V1_1::AvStreamType;
-using ::android::hardware::tv::tuner::V1_1::IFilterCallback;
using namespace std;
namespace android {
-using MQ = MessageQueue<uint8_t, kSynchronizedReadWrite>;
-using MQDesc = MQDescriptorSync<uint8_t>;
using AidlMQ = AidlMessageQueue<int8_t, SynchronizedReadWrite>;
using AidlMQDesc = MQDescriptor<int8_t, SynchronizedReadWrite>;
@@ -84,47 +50,10 @@
};
class TunerFilterCallback : public BnTunerFilterCallback {
-
public:
TunerFilterCallback(sp<FilterClientCallback> filterClientCallback);
- Status onFilterStatus(int status);
- Status onFilterEvent(const vector<TunerFilterEvent>& filterEvents);
-
-private:
- void getHidlFilterEvent(const vector<TunerFilterEvent>& filterEvents,
- DemuxFilterEvent& event, DemuxFilterEventExt& eventExt);
- void getHidlMediaEvent(
- const vector<TunerFilterEvent>& filterEvents, DemuxFilterEvent& event);
- void getHidlSectionEvent(
- const vector<TunerFilterEvent>& filterEvents, DemuxFilterEvent& event);
- void getHidlPesEvent(
- const vector<TunerFilterEvent>& filterEvents, DemuxFilterEvent& event);
- void getHidlTsRecordEvent(const vector<TunerFilterEvent>& filterEvents,
- DemuxFilterEvent& event, DemuxFilterEventExt& eventExt);
- void getHidlMmtpRecordEvent(const vector<TunerFilterEvent>& filterEvents,
- DemuxFilterEvent& event, DemuxFilterEventExt& eventExt);
- void getHidlDownloadEvent(
- const vector<TunerFilterEvent>& filterEvents, DemuxFilterEvent& event);
- void getHidlIpPayloadEvent(
- const vector<TunerFilterEvent>& filterEvents, DemuxFilterEvent& event);
- void getHidlTemiEvent(
- const vector<TunerFilterEvent>& filterEvents, DemuxFilterEvent& event);
- void getHidlMonitorEvent(
- const vector<TunerFilterEvent>& filterEvents, DemuxFilterEventExt& eventExt);
- void getHidlRestartEvent(
- const vector<TunerFilterEvent>& filterEvents, DemuxFilterEventExt& eventExt);
-
- sp<FilterClientCallback> mFilterClientCallback;
-};
-
-struct HidlFilterCallback : public IFilterCallback {
-
-public:
- HidlFilterCallback(sp<FilterClientCallback> filterClientCallback);
- virtual Return<void> onFilterEvent_1_1(const DemuxFilterEvent& filterEvent,
- const DemuxFilterEventExt& filterEventExt);
- virtual Return<void> onFilterEvent(const DemuxFilterEvent& filterEvent);
- virtual Return<void> onFilterStatus(const DemuxFilterStatus status);
+ Status onFilterStatus(DemuxFilterStatus status);
+ Status onFilterEvent(const vector<DemuxFilterEvent>& filterEvents);
private:
sp<FilterClientCallback> mFilterClientCallback;
@@ -136,15 +65,12 @@
FilterClient(DemuxFilterType type, shared_ptr<ITunerFilter> tunerFilter);
~FilterClient();
- // TODO: remove after migration to Tuner Service is done.
- void setHidlFilter(sp<IFilter> filter);
-
/**
* Read size of data from filter FMQ into buffer.
*
* @return the actual reading size. -1 if failed to read.
*/
- int read(int8_t* buffer, int size);
+ int64_t read(int8_t* buffer, int64_t size);
/**
* Get the a/v shared memory handle information
@@ -159,12 +85,12 @@
/**
* Configure the monitor event of the Filter.
*/
- Result configureMonitorEvent(int monitorEventType);
+ Result configureMonitorEvent(int32_t monitorEventType);
/**
* Configure the context id of the IP Filter.
*/
- Result configureIpFilterContextId(int cid);
+ Result configureIpFilterContextId(int32_t cid);
/**
* Configure the stream type of the media Filter.
@@ -189,12 +115,12 @@
/**
* Get the 32-bit filter Id.
*/
- Result getId(uint32_t& id);
+ Result getId(int32_t& id);
/**
* Get the 64-bit filter Id.
*/
- Result getId64Bit(uint64_t& id);
+ Result getId64Bit(int64_t& id);
/**
* Release the handle reported by the HAL for AV memory.
@@ -207,11 +133,6 @@
Result setDataSource(sp<FilterClient> filterClient);
/**
- * Get the Hal filter to build up filter linkage.
- */
- sp<IFilter> getHalFilter() { return mFilter; }
-
- /**
* Get the Aidl filter to build up filter linkage.
*/
shared_ptr<ITunerFilter> getAidlFilter() { return mTunerFilter; }
@@ -222,24 +143,8 @@
Result close();
private:
- TunerFilterConfiguration getAidlFilterSettings(DemuxFilterSettings configure);
-
- TunerFilterConfiguration getAidlTsSettings(DemuxTsFilterSettings configure);
- TunerFilterConfiguration getAidlMmtpSettings(DemuxMmtpFilterSettings mmtp);
- TunerFilterConfiguration getAidlIpSettings(DemuxIpFilterSettings ip);
- TunerFilterConfiguration getAidlTlvSettings(DemuxTlvFilterSettings tlv);
- TunerFilterConfiguration getAidlAlpSettings(DemuxAlpFilterSettings alp);
-
- TunerFilterAvSettings getAidlAvSettings(DemuxFilterAvSettings hidlAv);
- TunerFilterSectionSettings getAidlSectionSettings(DemuxFilterSectionSettings hidlSection);
- TunerFilterPesDataSettings getAidlPesDataSettings(DemuxFilterPesDataSettings hidlPesData);
- TunerFilterRecordSettings getAidlRecordSettings(DemuxFilterRecordSettings hidlRecord);
- TunerFilterDownloadSettings getAidlDownloadSettings(DemuxFilterDownloadSettings hidlDownload);
-
- void getAidlIpAddress(DemuxIpAddress ipAddr,
- TunerDemuxIpAddress& srcIpAddress, TunerDemuxIpAddress& dstIpAddress);
Result getFilterMq();
- int copyData(int8_t* buffer, int size);
+ int64_t copyData(int8_t* buffer, int64_t size);
void checkIsMediaFilter(DemuxFilterType type);
void checkIsPassthroughFilter(DemuxFilterSettings configure);
void handleAvShareMemory();
@@ -251,22 +156,8 @@
*/
shared_ptr<ITunerFilter> mTunerFilter;
- /**
- * A 1.0 Filter HAL interface that is ready before migrating to the TunerFilter.
- * This is a temprary interface before Tuner Framework migrates to use TunerService.
- * Default null when the HAL service does not exist.
- */
- sp<IFilter> mFilter;
-
- /**
- * A 1.1 Filter HAL interface that is ready before migrating to the TunerFilter.
- * This is a temprary interface before Tuner Framework migrates to use TunerService.
- * Default null when the HAL service does not exist.
- */
- sp<::android::hardware::tv::tuner::V1_1::IFilter> mFilter_1_1;
-
- AidlMQ* mFilterMQ = NULL;
- EventFlag* mFilterMQEventFlag = NULL;
+ AidlMQ* mFilterMQ = nullptr;
+ EventFlag* mFilterMQEventFlag = nullptr;
native_handle_t* mAvSharedHandle;
uint64_t mAvSharedMemSize;
diff --git a/media/jni/tuner/FilterClientCallback.h b/media/jni/tuner/FilterClientCallback.h
index 94b7821..05e7ff0 100644
--- a/media/jni/tuner/FilterClientCallback.h
+++ b/media/jni/tuner/FilterClientCallback.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,20 +17,21 @@
#ifndef _ANDROID_MEDIA_TV_FILTER_CLIENT_CALLBACK_H_
#define _ANDROID_MEDIA_TV_FILTER_CLIENT_CALLBACK_H_
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterStatus;
-using ::android::hardware::tv::tuner::V1_1::DemuxFilterEventExt;
+#include <aidl/android/hardware/tv/tuner/DemuxFilterEvent.h>
+#include <aidl/android/hardware/tv/tuner/DemuxFilterStatus.h>
+#include <utils/RefBase.h>
+
+using ::aidl::android::hardware::tv::tuner::DemuxFilterEvent;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterStatus;
using namespace std;
namespace android {
struct FilterClientCallback : public RefBase {
- virtual void onFilterEvent_1_1(const DemuxFilterEvent& filterEvent,
- const DemuxFilterEventExt& filterEventExt);
- virtual void onFilterEvent(const DemuxFilterEvent& filterEvent);
+ virtual void onFilterEvent(const vector<DemuxFilterEvent>& filterEvents);
virtual void onFilterStatus(const DemuxFilterStatus status);
};
} // namespace android
-#endif // _ANDROID_MEDIA_TV_FILTER_CLIENT_CALLBACK_H_
\ No newline at end of file
+#endif // _ANDROID_MEDIA_TV_FILTER_CLIENT_CALLBACK_H_
diff --git a/media/jni/tuner/FrontendClient.cpp b/media/jni/tuner/FrontendClient.cpp
index 5d9b12d..70309a0 100644
--- a/media/jni/tuner/FrontendClient.cpp
+++ b/media/jni/tuner/FrontendClient.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.
@@ -16,1235 +16,168 @@
#define LOG_TAG "FrontendClient"
+#include "FrontendClient.h"
+
+#include <aidl/android/hardware/tv/tuner/Constant.h>
#include <android-base/logging.h>
#include <utils/Log.h>
-#include "FrontendClient.h"
-
-using ::aidl::android::media::tv::tuner::TunerFrontendScanAtsc3PlpInfo;
-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::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::FrontendDvbcSpectralInversion;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsModulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsStandard;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsRolloff;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtBandwidth;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtGuardInterval;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtHierarchy;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtStandard;
-using ::android::hardware::tv::tuner::V1_0::FrontendInnerFec;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbsModulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbsRolloff;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbs3Modulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbs3Rolloff;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbtBandwidth;
-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::FrontendModulationStatus;
-using ::android::hardware::tv::tuner::V1_0::FrontendScanAtsc3PlpInfo;
-using ::android::hardware::tv::tuner::V1_0::FrontendStatusAtsc3PlpInfo;
-using ::android::hardware::tv::tuner::V1_0::LnbVoltage;
-using ::android::hardware::tv::tuner::V1_1::Constant;
-using ::android::hardware::tv::tuner::V1_1::FrontendBandwidth;
-using ::android::hardware::tv::tuner::V1_1::FrontendCableTimeInterleaveMode;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbBandwidth;
-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::FrontendDvbcBandwidth;
-using ::android::hardware::tv::tuner::V1_1::FrontendDvbtConstellation;
-using ::android::hardware::tv::tuner::V1_1::FrontendDvbtTransmissionMode;
-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::FrontendSpectralInversion;
-using ::android::hardware::tv::tuner::V1_1::FrontendTransmissionMode;
-using ::android::hardware::tv::tuner::V1_1::FrontendType;
+using ::aidl::android::hardware::tv::tuner::Constant;
namespace android {
-
/////////////// FrontendClient ///////////////////////
-
-FrontendClient::FrontendClient(shared_ptr<ITunerFrontend> tunerFrontend, int type) {
+FrontendClient::FrontendClient(shared_ptr<ITunerFrontend> tunerFrontend, FrontendType type) {
mTunerFrontend = tunerFrontend;
mType = type;
}
FrontendClient::~FrontendClient() {
- mTunerFrontend = NULL;
- mFrontend = NULL;
- mFrontend_1_1 = NULL;
- mId = -1;
- mType = -1;
+ mTunerFrontend = nullptr;
+ mType = FrontendType::UNDEFINED;
}
Result FrontendClient::setCallback(sp<FrontendClientCallback> frontendClientCallback) {
- if (mTunerFrontend != NULL) {
+ if (mTunerFrontend != nullptr) {
shared_ptr<TunerFrontendCallback> aidlCallback =
::ndk::SharedRefBase::make<TunerFrontendCallback>(frontendClientCallback);
- aidlCallback->setFrontendType(mType);
Status s = mTunerFrontend->setCallback(aidlCallback);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- sp<HidlFrontendCallback> hidlCallback = new HidlFrontendCallback(frontendClientCallback);
- return mFrontend->setCallback(hidlCallback);
+ return Result::INVALID_STATE;
}
-void FrontendClient::setHidlFrontend(sp<IFrontend> frontend) {
- mFrontend = frontend;
- mFrontend_1_1 = ::android::hardware::tv::tuner::V1_1::IFrontend::castFrom(mFrontend);
-}
-
-// TODO: move after migration is done
-void FrontendClient::setId(int id) {
- mId = id;
-}
-
-Result FrontendClient::tune(const FrontendSettings& settings,
- const FrontendSettingsExt1_1& settingsExt1_1) {
- if (mTunerFrontend != NULL) {
- TunerFrontendSettings tunerFeSettings = getAidlFrontendSettings(settings, settingsExt1_1);
- Status s = mTunerFrontend->tune(tunerFeSettings);
+Result FrontendClient::tune(const FrontendSettings& settings) {
+ if (mTunerFrontend != nullptr) {
+ Status s = mTunerFrontend->tune(settings);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- Result result;
- if (mFrontend_1_1 != NULL && validateExtendedSettings(settingsExt1_1)) {
- result = mFrontend_1_1->tune_1_1(settings, settingsExt1_1);
- return result;
- }
-
- if (mFrontend != NULL) {
- result = mFrontend->tune(settings);
- return result;
- }
-
return Result::INVALID_STATE;
}
Result FrontendClient::stopTune() {
- if (mTunerFrontend != NULL) {
+ if (mTunerFrontend != nullptr) {
Status s = mTunerFrontend->stopTune();
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFrontend != NULL) {
- Result result = mFrontend->stopTune();
- return result;
- }
-
return Result::INVALID_STATE;
}
-Result FrontendClient::scan(const FrontendSettings& settings, FrontendScanType type,
- const FrontendSettingsExt1_1& settingsExt1_1) {
- if (mTunerFrontend != NULL) {
- TunerFrontendSettings tunerFeSettings = getAidlFrontendSettings(settings, settingsExt1_1);
- Status s = mTunerFrontend->scan(tunerFeSettings, (int)type);
+Result FrontendClient::scan(const FrontendSettings& settings, FrontendScanType type) {
+ if (mTunerFrontend != nullptr) {
+ Status s = mTunerFrontend->scan(settings, type);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- Result result;
- if (mFrontend_1_1 != NULL && validateExtendedSettings(settingsExt1_1)) {
- result = mFrontend_1_1->scan_1_1(settings, type, settingsExt1_1);
- return result;
- }
-
- if (mFrontend != NULL) {
- result = mFrontend->scan(settings, type);
- return result;
- }
-
return Result::INVALID_STATE;
}
Result FrontendClient::stopScan() {
- if (mTunerFrontend != NULL) {
+ if (mTunerFrontend != nullptr) {
Status s = mTunerFrontend->stopScan();
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFrontend != NULL) {
- Result result = mFrontend->stopScan();
- return result;
- }
-
return Result::INVALID_STATE;
}
vector<FrontendStatus> FrontendClient::getStatus(vector<FrontendStatusType> statusTypes) {
vector<FrontendStatus> status;
- if (mTunerFrontend != NULL) {
- vector<TunerFrontendStatus> aidlStatus;
- vector<int> types;
- for (auto t : statusTypes) {
- types.push_back((int)t);
- }
- Status s = mTunerFrontend->getStatus(types, &aidlStatus);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return status;
- }
- return getHidlStatus(aidlStatus);
- }
-
- if (mFrontend != NULL && statusTypes.size() > 0) {
- Result res;
- mFrontend->getStatus(statusTypes,
- [&](Result r, const hidl_vec<FrontendStatus>& s) {
- res = r;
- status = s;
- });
- if (res != Result::SUCCESS) {
- status.clear();
- return status;
- }
- }
-
- return status;
-}
-
-vector<FrontendStatusExt1_1> FrontendClient::getStatusExtended_1_1(
- vector<FrontendStatusTypeExt1_1> statusTypes) {
- vector<FrontendStatusExt1_1> status;
-
- if (mTunerFrontend != NULL) {
- vector<TunerFrontendStatus> aidlStatus;
- vector<int> types;
- for (auto t : statusTypes) {
- types.push_back((int)t);
- }
- Status s = mTunerFrontend->getStatusExtended_1_1(types, &aidlStatus);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return status;
- }
- return getHidlStatusExt(aidlStatus);
- }
-
- if (mFrontend_1_1 != NULL && statusTypes.size() > 0) {
- Result res;
- mFrontend_1_1->getStatusExt1_1(statusTypes,
- [&](Result r, const hidl_vec<FrontendStatusExt1_1>& s) {
- res = r;
- status = s;
- });
- if (res != Result::SUCCESS) {
- status.clear();
- return status;
- }
+ if (mTunerFrontend != nullptr) {
+ mTunerFrontend->getStatus(statusTypes, &status);
}
return status;
}
Result FrontendClient::setLnb(sp<LnbClient> lnbClient) {
- if (mTunerFrontend != NULL) {
+ if (mTunerFrontend != nullptr) {
Status s = mTunerFrontend->setLnb(lnbClient->getAidlLnb());
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFrontend != NULL) {
- Result result = mFrontend->setLnb(lnbClient->getId());
- return result;
- }
-
return Result::INVALID_STATE;
}
Result FrontendClient::setLna(bool bEnable) {
- if (mTunerFrontend != NULL) {
+ if (mTunerFrontend != nullptr) {
Status s = mTunerFrontend->setLna(bEnable);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFrontend != NULL) {
- Result result = mFrontend->setLna(bEnable);
- return result;
- }
-
return Result::INVALID_STATE;
}
-int FrontendClient::linkCiCamToFrontend(int ciCamId) {
- int ltsId = (int)Constant::INVALID_LTS_ID;
+int32_t FrontendClient::linkCiCamToFrontend(int32_t ciCamId) {
+ int32_t ltsId = static_cast<int32_t>(Constant::INVALID_LTS_ID);
- if (mTunerFrontend != NULL) {
+ if (mTunerFrontend != nullptr) {
Status s = mTunerFrontend->linkCiCamToFrontend(ciCamId, <sId);
- if (ClientHelper::getServiceSpecificErrorCode(s) == Result::SUCCESS) {
- return ltsId;
- }
- return (int)Constant::INVALID_LTS_ID;
- }
-
- if (mFrontend_1_1 != NULL) {
- Result res;
- mFrontend_1_1->linkCiCam(static_cast<uint32_t>(ciCamId),
- [&](Result r, uint32_t id) {
- res = r;
- ltsId = id;
- });
- if (res != Result::SUCCESS) {
- return (int)Constant::INVALID_LTS_ID;
+ if (!s.isOk()) {
+ return static_cast<int32_t>(Constant::INVALID_LTS_ID);
}
}
return ltsId;
}
-Result FrontendClient::unlinkCiCamToFrontend(int ciCamId) {
- if (mTunerFrontend != NULL) {
+Result FrontendClient::unlinkCiCamToFrontend(int32_t ciCamId) {
+ if (mTunerFrontend != nullptr) {
Status s = mTunerFrontend->unlinkCiCamToFrontend(ciCamId);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFrontend_1_1 != NULL) {
- return mFrontend_1_1->unlinkCiCam(static_cast<uint32_t>(ciCamId));
- }
-
return Result::INVALID_STATE;
}
Result FrontendClient::close() {
- if (mTunerFrontend != NULL) {
+ if (mTunerFrontend != nullptr) {
Status s = mTunerFrontend->close();
- mTunerFrontend = NULL;
+ mTunerFrontend = nullptr;
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mFrontend != NULL) {
- Result result = mFrontend->close();
- mFrontend = NULL;
- mFrontend_1_1 = NULL;
- return result;
- }
-
return Result::INVALID_STATE;
}
-/////////////// TunerFrontend Helper Methods ///////////////////////
-
shared_ptr<ITunerFrontend> FrontendClient::getAidlFrontend() {
return mTunerFrontend;
}
-int FrontendClient::getId() {
- if (mTunerFrontend != NULL) {
- Status s = mTunerFrontend->getFrontendId(&mId);
- if (ClientHelper::getServiceSpecificErrorCode(s) == Result::SUCCESS) {
- return mId;
- }
- ALOGE("Failed to getFrontendId from Tuner Frontend");
- return -1;
- }
-
- if (mFrontend != NULL) {
- return mId;
- }
-
- return -1;
-}
-
-vector<FrontendStatus> FrontendClient::getHidlStatus(vector<TunerFrontendStatus>& aidlStatus) {
- vector<FrontendStatus> hidlStatus;
- for (TunerFrontendStatus s : aidlStatus) {
- FrontendStatus status = FrontendStatus();
- switch (s.getTag()) {
- case TunerFrontendStatus::isDemodLocked: {
- status.isDemodLocked(s.get<TunerFrontendStatus::isDemodLocked>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::snr: {
- status.snr(s.get<TunerFrontendStatus::snr>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::ber: {
- status.ber((uint32_t)s.get<TunerFrontendStatus::ber>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::per: {
- status.per((uint32_t)s.get<TunerFrontendStatus::per>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::preBer: {
- status.preBer((uint32_t)s.get<TunerFrontendStatus::preBer>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::signalQuality: {
- status.signalQuality((uint32_t)s.get<TunerFrontendStatus::signalQuality>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::signalStrength: {
- status.signalStrength(s.get<TunerFrontendStatus::signalStrength>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::symbolRate: {
- status.symbolRate((uint32_t)s.get<TunerFrontendStatus::symbolRate>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::innerFec: {
- status.innerFec(static_cast<FrontendInnerFec>(
- s.get<TunerFrontendStatus::innerFec>()));
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::modulation: {
- auto aidlMod = s.get<TunerFrontendStatus::modulation>();
- FrontendModulationStatus modulation;
- switch (mType) {
- case (int)FrontendType::DVBC:
- modulation.dvbc(static_cast<FrontendDvbcModulation>(aidlMod));
- status.modulation(modulation);
- hidlStatus.push_back(status);
- break;
- case (int)FrontendType::DVBS:
- modulation.dvbs(static_cast<FrontendDvbsModulation>(aidlMod));
- status.modulation(modulation);
- hidlStatus.push_back(status);
- break;
- case (int)FrontendType::ISDBS:
- modulation.isdbs(static_cast<FrontendIsdbsModulation>(aidlMod));
- status.modulation(modulation);
- hidlStatus.push_back(status);
- break;
- case (int)FrontendType::ISDBS3:
- modulation.isdbs3(static_cast<FrontendIsdbs3Modulation>(aidlMod));
- status.modulation(modulation);
- hidlStatus.push_back(status);
- break;
- case (int)FrontendType::ISDBT:
- modulation.isdbt(static_cast<FrontendIsdbtModulation>(aidlMod));
- status.modulation(modulation);
- hidlStatus.push_back(status);
- break;
- default:
- break;
- }
- break;
- }
- case TunerFrontendStatus::inversion: {
- status.inversion(static_cast<FrontendDvbcSpectralInversion>(
- s.get<TunerFrontendStatus::inversion>()));
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::lnbVoltage: {
- status.lnbVoltage(static_cast<LnbVoltage>(
- s.get<TunerFrontendStatus::lnbVoltage>()));
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::plpId: {
- status.plpId((uint8_t)s.get<TunerFrontendStatus::plpId>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::isEWBS: {
- status.isEWBS(s.get<TunerFrontendStatus::isEWBS>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::agc: {
- status.agc((uint8_t)s.get<TunerFrontendStatus::agc>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::isLnaOn: {
- status.isLnaOn(s.get<TunerFrontendStatus::isLnaOn>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::isLayerError: {
- auto aidlE = s.get<TunerFrontendStatus::isLayerError>();
- hidl_vec<bool> e(aidlE.begin(), aidlE.end());
- status.isLayerError(e);
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::mer: {
- status.mer(s.get<TunerFrontendStatus::mer>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::freqOffset: {
- status.freqOffset(s.get<TunerFrontendStatus::freqOffset>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::hierarchy: {
- status.hierarchy(static_cast<FrontendDvbtHierarchy>(
- s.get<TunerFrontendStatus::hierarchy>()));
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::isRfLocked: {
- status.isRfLocked(s.get<TunerFrontendStatus::isRfLocked>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::plpInfo: {
- int size = s.get<TunerFrontendStatus::plpInfo>().size();
- hidl_vec<FrontendStatusAtsc3PlpInfo> info(size);
- for (int i = 0; i < size; i++) {
- auto aidlInfo = s.get<TunerFrontendStatus::plpInfo>()[i];
- info[i] = {
- .plpId = (uint8_t)aidlInfo.plpId,
- .isLocked = aidlInfo.isLocked,
- .uec = (uint32_t)aidlInfo.uec,
- };
- }
- status.plpInfo(info);
- hidlStatus.push_back(status);
- break;
- }
- default:
- break;
+int32_t FrontendClient::getId() {
+ if (mTunerFrontend != nullptr) {
+ int32_t id;
+ Status s = mTunerFrontend->getFrontendId(&id);
+ if (s.isOk()) {
+ return id;
}
}
- return hidlStatus;
-}
-vector<FrontendStatusExt1_1> FrontendClient::getHidlStatusExt(
- vector<TunerFrontendStatus>& aidlStatus) {
- vector<FrontendStatusExt1_1> hidlStatus;
- for (TunerFrontendStatus s : aidlStatus) {
- FrontendStatusExt1_1 status;
- switch (s.getTag()) {
- case TunerFrontendStatus::modulations: {
- vector<FrontendModulation> ms;
- for (auto aidlMod : s.get<TunerFrontendStatus::modulations>()) {
- FrontendModulation m;
- switch (mType) {
- case (int)FrontendType::DVBC:
- m.dvbc(static_cast<FrontendDvbcModulation>(aidlMod));
- ms.push_back(m);
- break;
- case (int)FrontendType::DVBS:
- m.dvbs(static_cast<FrontendDvbsModulation>(aidlMod));
- ms.push_back(m);
- break;
- case (int)FrontendType::DVBT:
- m.dvbt(static_cast<FrontendDvbtConstellation>(aidlMod));
- ms.push_back(m);
- break;
- case (int)FrontendType::ISDBS:
- m.isdbs(static_cast<FrontendIsdbsModulation>(aidlMod));
- ms.push_back(m);
- break;
- case (int)FrontendType::ISDBS3:
- m.isdbs3(static_cast<FrontendIsdbs3Modulation>(aidlMod));
- ms.push_back(m);
- break;
- case (int)FrontendType::ISDBT:
- m.isdbt(static_cast<FrontendIsdbtModulation>(aidlMod));
- ms.push_back(m);
- break;
- case (int)FrontendType::ATSC:
- m.atsc(static_cast<FrontendAtscModulation>(aidlMod));
- ms.push_back(m);
- break;
- case (int)FrontendType::ATSC3:
- m.atsc3(static_cast<FrontendAtsc3Modulation>(aidlMod));
- ms.push_back(m);
- break;
- case (int)FrontendType::DTMB:
- m.dtmb(static_cast<FrontendDtmbModulation>(aidlMod));
- ms.push_back(m);
- break;
- default:
- break;
- }
- }
- if (ms.size() > 0) {
- status.modulations(ms);
- hidlStatus.push_back(status);
- }
- break;
- }
- case TunerFrontendStatus::bers: {
- auto aidlB = s.get<TunerFrontendStatus::bers>();
- hidl_vec<uint32_t> b(aidlB.begin(), aidlB.end());
- status.bers(b);
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::codeRates: {
- vector<hardware::tv::tuner::V1_1::FrontendInnerFec> codeRates;
- for (auto aidlCodeRate : s.get<TunerFrontendStatus::codeRates>()) {
- codeRates.push_back(
- static_cast<hardware::tv::tuner::V1_1::FrontendInnerFec>(aidlCodeRate));
- }
- if (codeRates.size() > 0) {
- status.codeRates(codeRates);
- hidlStatus.push_back(status);
- }
- break;
- }
- case TunerFrontendStatus::bandwidth: {
- auto aidlBand = s.get<TunerFrontendStatus::bandwidth>();
- FrontendBandwidth band;
- switch (mType) {
- case (int)FrontendType::ATSC3:
- band.atsc3(static_cast<FrontendAtsc3Bandwidth>(aidlBand));
- status.bandwidth(band);
- hidlStatus.push_back(status);
- break;
- case (int)FrontendType::DVBC:
- band.dvbc(static_cast<FrontendDvbcBandwidth>(aidlBand));
- status.bandwidth(band);
- hidlStatus.push_back(status);
- break;
- case (int)FrontendType::DVBT:
- band.dvbt(static_cast<FrontendDvbtBandwidth>(aidlBand));
- status.bandwidth(band);
- hidlStatus.push_back(status);
- break;
- case (int)FrontendType::ISDBT:
- band.isdbt(static_cast<FrontendIsdbtBandwidth>(aidlBand));
- status.bandwidth(band);
- hidlStatus.push_back(status);
- break;
- case (int)FrontendType::DTMB:
- band.dtmb(static_cast<FrontendDtmbBandwidth>(aidlBand));
- status.bandwidth(band);
- hidlStatus.push_back(status);
- break;
- default:
- break;
- }
- break;
- }
- case TunerFrontendStatus::interval: {
- auto aidlInter = s.get<TunerFrontendStatus::interval>();
- FrontendGuardInterval inter;
- switch (mType) {
- case (int)FrontendType::DVBT:
- inter.dvbt(static_cast<FrontendDvbtGuardInterval>(aidlInter));
- status.interval(inter);
- hidlStatus.push_back(status);
- break;
- case (int)FrontendType::ISDBT:
- inter.isdbt(static_cast<FrontendIsdbtGuardInterval>(aidlInter));
- status.interval(inter);
- hidlStatus.push_back(status);
- break;
- case (int)FrontendType::DTMB:
- inter.dtmb(static_cast<FrontendDtmbGuardInterval>(aidlInter));
- status.interval(inter);
- hidlStatus.push_back(status);
- break;
- default:
- break;
- }
- break;
- }
- case TunerFrontendStatus::transmissionMode: {
- auto aidlTran = s.get<TunerFrontendStatus::transmissionMode>();
- FrontendTransmissionMode trans;
- switch (mType) {
- case (int)FrontendType::DVBT:
- trans.dvbt(static_cast<FrontendDvbtTransmissionMode>(aidlTran));
- status.transmissionMode(trans);
- hidlStatus.push_back(status);
- break;
- case (int)FrontendType::ISDBT:
- trans.isdbt(static_cast<FrontendIsdbtMode>(aidlTran));
- status.transmissionMode(trans);
- hidlStatus.push_back(status);
- break;
- case (int)FrontendType::DTMB:
- trans.dtmb(static_cast<FrontendDtmbTransmissionMode>(aidlTran));
- status.transmissionMode(trans);
- hidlStatus.push_back(status);
- break;
- default:
- break;
- }
- break;
- }
- case TunerFrontendStatus::uec: {
- status.uec((uint32_t)s.get<TunerFrontendStatus::uec>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::systemId: {
- status.systemId((uint16_t)s.get<TunerFrontendStatus::systemId>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::interleaving: {
- vector<FrontendInterleaveMode> modes;
- for (auto aidlInter : s.get<TunerFrontendStatus::interleaving>()) {
- FrontendInterleaveMode mode;
- switch (mType) {
- case (int)FrontendType::DVBC:
- mode.dvbc(static_cast<FrontendCableTimeInterleaveMode>(aidlInter));
- modes.push_back(mode);
- break;
- case (int)FrontendType::ATSC3:
- mode.atsc3(static_cast<FrontendAtsc3TimeInterleaveMode>(aidlInter));
- modes.push_back(mode);
- break;
- case (int)FrontendType::DTMB:
- mode.dtmb(static_cast<FrontendDtmbTimeInterleaveMode>(aidlInter));
- modes.push_back(mode);
- break;
- default:
- break;
- }
- }
- if (modes.size() > 0) {
- status.interleaving(modes);
- hidlStatus.push_back(status);
- }
- break;
- }
- case TunerFrontendStatus::isdbtSegment: {
- auto aidlSeg = s.get<TunerFrontendStatus::isdbtSegment>();
- hidl_vec<uint8_t> s(aidlSeg.begin(), aidlSeg.end());
- status.isdbtSegment(s);
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::tsDataRate: {
- auto aidlTs = s.get<TunerFrontendStatus::tsDataRate>();
- hidl_vec<uint32_t> ts(aidlTs.begin(), aidlTs.end());
- status.tsDataRate(ts);
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::rollOff: {
- auto aidlRoll = s.get<TunerFrontendStatus::rollOff>();
- FrontendRollOff roll;
- switch (mType) {
- case (int)FrontendType::DVBS:
- roll.dvbs(static_cast<FrontendDvbsRolloff>(aidlRoll));
- status.rollOff(roll);
- hidlStatus.push_back(status);
- break;
- case (int)FrontendType::ISDBS:
- roll.isdbs(static_cast<FrontendIsdbsRolloff>(aidlRoll));
- status.rollOff(roll);
- hidlStatus.push_back(status);
- break;
- case (int)FrontendType::ISDBS3:
- roll.isdbs3(static_cast<FrontendIsdbs3Rolloff>(aidlRoll));
- status.rollOff(roll);
- hidlStatus.push_back(status);
- break;
- default:
- break;
- }
- break;
- }
- case TunerFrontendStatus::isMiso: {
- status.isMiso(s.get<TunerFrontendStatus::isMiso>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::isLinear: {
- status.isLinear(s.get<TunerFrontendStatus::isLinear>());
- hidlStatus.push_back(status);
- break;
- }
- case TunerFrontendStatus::isShortFrames: {
- status.isShortFrames(s.get<TunerFrontendStatus::isShortFrames>());
- hidlStatus.push_back(status);
- break;
- }
- default:
- break;
- }
- }
- return hidlStatus;
-}
-
-TunerFrontendSettings FrontendClient::getAidlFrontendSettings(const FrontendSettings& settings,
- const FrontendSettingsExt1_1& settingsExt1_1) {
- bool isExtended = validateExtendedSettings(settingsExt1_1);
- TunerFrontendSettings s{
- .isExtended = isExtended,
- .endFrequency = (int) settingsExt1_1.endFrequency,
- .inversion = (int) settingsExt1_1.inversion,
- };
-
- if (settingsExt1_1.settingExt.getDiscriminator()
- == FrontendSettingsExt1_1::SettingsExt::hidl_discriminator::dtmb) {
- s.settings.set<TunerFrontendUnionSettings::dtmb>(getAidlDtmbSettings(settingsExt1_1));
- return s;
- }
-
- switch (settings.getDiscriminator()) {
- case FrontendSettings::hidl_discriminator::analog: {
- s.settings.set<TunerFrontendUnionSettings::analog>(
- getAidlAnalogSettings(settings, settingsExt1_1));
- break;
- }
- case FrontendSettings::hidl_discriminator::atsc: {
- s.settings.set<TunerFrontendUnionSettings::atsc>(getAidlAtscSettings(settings));
- break;
- }
- case FrontendSettings::hidl_discriminator::atsc3: {
- s.settings.set<TunerFrontendUnionSettings::atsc3>(getAidlAtsc3Settings(settings));
- break;
- }
- case FrontendSettings::hidl_discriminator::dvbs: {
- s.settings.set<TunerFrontendUnionSettings::dvbs>(
- getAidlDvbsSettings(settings, settingsExt1_1));
- break;
- }
- case FrontendSettings::hidl_discriminator::dvbc: {
- s.settings.set<TunerFrontendUnionSettings::cable>(
- getAidlCableSettings(settings, settingsExt1_1));
- break;
- }
- case FrontendSettings::hidl_discriminator::dvbt: {
- s.settings.set<TunerFrontendUnionSettings::dvbt>(
- getAidlDvbtSettings(settings, settingsExt1_1));
- break;
- }
- case FrontendSettings::hidl_discriminator::isdbs: {
- s.settings.set<TunerFrontendUnionSettings::isdbs>(getAidlIsdbsSettings(settings));
- break;
- }
- case FrontendSettings::hidl_discriminator::isdbs3: {
- s.settings.set<TunerFrontendUnionSettings::isdbs3>(getAidlIsdbs3Settings(settings));
- break;
- }
- case FrontendSettings::hidl_discriminator::isdbt: {
- s.settings.set<TunerFrontendUnionSettings::isdbt>(getAidlIsdbtSettings(settings));
- break;
- }
- default:
- break;
- }
- return s;
-}
-
-TunerFrontendAnalogSettings FrontendClient::getAidlAnalogSettings(const FrontendSettings& settings,
- const FrontendSettingsExt1_1& settingsExt1_1) {
- TunerFrontendAnalogSettings analogSettings{
- .frequency = (int)settings.analog().frequency,
- .signalType = (int)settings.analog().type,
- .sifStandard = (int)settings.analog().sifStandard,
- };
- if (settingsExt1_1.settingExt.getDiscriminator()
- == FrontendSettingsExt1_1::SettingsExt::hidl_discriminator::analog) {
- analogSettings.isExtended = true;
- analogSettings.aftFlag = (int)settingsExt1_1.settingExt.analog().aftFlag;
- } else {
- analogSettings.isExtended = false;
- }
- return analogSettings;
-}
-
-TunerFrontendDvbsSettings FrontendClient::getAidlDvbsSettings(const FrontendSettings& settings,
- const FrontendSettingsExt1_1& settingsExt1_1) {
- TunerFrontendDvbsSettings dvbsSettings{
- .frequency = (int)settings.dvbs().frequency,
- .modulation = (int)settings.dvbs().modulation,
- .codeRate = {
- .fec = (long)settings.dvbs().coderate.fec,
- .isLinear = settings.dvbs().coderate.isLinear,
- .isShortFrames = settings.dvbs().coderate.isShortFrames,
- .bitsPer1000Symbol = (int)settings.dvbs().coderate.bitsPer1000Symbol,
- },
- .symbolRate = (int)settings.dvbs().symbolRate,
- .rolloff = (int)settings.dvbs().rolloff,
- .pilot = (int)settings.dvbs().pilot,
- .inputStreamId = (int)settings.dvbs().inputStreamId,
- .standard = (int)settings.dvbs().standard,
- .vcm = (int)settings.dvbs().vcmMode,
- };
- if (settingsExt1_1.settingExt.getDiscriminator()
- == FrontendSettingsExt1_1::SettingsExt::hidl_discriminator::dvbs) {
- dvbsSettings.isExtended = true;
- dvbsSettings.scanType = (int)settingsExt1_1.settingExt.dvbs().scanType;
- dvbsSettings.isDiseqcRxMessage = settingsExt1_1.settingExt.dvbs().isDiseqcRxMessage;
- } else {
- dvbsSettings.isExtended = false;
- }
- return dvbsSettings;
-}
-
-TunerFrontendCableSettings FrontendClient::getAidlCableSettings(const FrontendSettings& settings,
- const FrontendSettingsExt1_1& settingsExt1_1) {
- TunerFrontendCableSettings cableSettings{
- .frequency = (int)settings.dvbc().frequency,
- .modulation = (int)settings.dvbc().modulation,
- .innerFec = (long)settings.dvbc().fec,
- .symbolRate = (int)settings.dvbc().symbolRate,
- .outerFec = (int)settings.dvbc().outerFec,
- .annex = (int)settings.dvbc().annex,
- .spectralInversion = (int)settings.dvbc().spectralInversion,
- };
- if (settingsExt1_1.settingExt.getDiscriminator()
- == FrontendSettingsExt1_1::SettingsExt::hidl_discriminator::dvbc) {
- cableSettings.isExtended = true;
- cableSettings.interleaveMode = (int)settingsExt1_1.settingExt.dvbc().interleaveMode;
- cableSettings.bandwidth = (int)settingsExt1_1.settingExt.dvbc().bandwidth;
- } else {
- cableSettings.isExtended = false;
- }
- return cableSettings;
-}
-
-TunerFrontendDvbtSettings FrontendClient::getAidlDvbtSettings(const FrontendSettings& settings,
- const FrontendSettingsExt1_1& settingsExt1_1) {
- TunerFrontendDvbtSettings dvbtSettings{
- .frequency = (int)settings.dvbt().frequency,
- .transmissionMode = (int)settings.dvbt().transmissionMode,
- .bandwidth = (int)settings.dvbt().bandwidth,
- .constellation = (int)settings.dvbt().constellation,
- .hierarchy = (int)settings.dvbt().hierarchy,
- .hpCodeRate = (int)settings.dvbt().hpCoderate,
- .lpCodeRate = (int)settings.dvbt().lpCoderate,
- .guardInterval = (int)settings.dvbt().guardInterval,
- .isHighPriority = settings.dvbt().isHighPriority,
- .standard = (int)settings.dvbt().standard,
- .isMiso = settings.dvbt().isMiso,
- .plpMode = (int)settings.dvbt().plpMode,
- .plpId = (int)settings.dvbt().plpId,
- .plpGroupId = (int)settings.dvbt().plpGroupId,
- };
- if (settingsExt1_1.settingExt.getDiscriminator()
- == FrontendSettingsExt1_1::SettingsExt::hidl_discriminator::dvbt) {
- dvbtSettings.isExtended = true;
- dvbtSettings.constellation = (int)settingsExt1_1.settingExt.dvbt().constellation;
- dvbtSettings.transmissionMode =
- (int)settingsExt1_1.settingExt.dvbt().transmissionMode;
- } else {
- dvbtSettings.isExtended = false;
- }
- return dvbtSettings;
-}
-
-TunerFrontendDtmbSettings FrontendClient::getAidlDtmbSettings(
- const FrontendSettingsExt1_1& settingsExt1_1) {
- TunerFrontendDtmbSettings dtmbSettings{
- .frequency = (int)settingsExt1_1.settingExt.dtmb().frequency,
- .transmissionMode = (int)settingsExt1_1.settingExt.dtmb().transmissionMode,
- .bandwidth = (int)settingsExt1_1.settingExt.dtmb().bandwidth,
- .modulation = (int)settingsExt1_1.settingExt.dtmb().modulation,
- .codeRate = (int)settingsExt1_1.settingExt.dtmb().codeRate,
- .guardInterval = (int)settingsExt1_1.settingExt.dtmb().guardInterval,
- .interleaveMode = (int)settingsExt1_1.settingExt.dtmb().interleaveMode,
- };
- return dtmbSettings;
-}
-
-TunerFrontendAtscSettings FrontendClient::getAidlAtscSettings(const FrontendSettings& settings) {
- TunerFrontendAtscSettings atscSettings{
- .frequency = (int)settings.atsc().frequency,
- .modulation = (int)settings.atsc().modulation,
- };
- return atscSettings;
-}
-
-TunerFrontendAtsc3Settings FrontendClient::getAidlAtsc3Settings(const FrontendSettings& settings) {
- TunerFrontendAtsc3Settings atsc3Settings{
- .frequency = (int)settings.atsc3().frequency,
- .bandwidth = (int)settings.atsc3().bandwidth,
- .demodOutputFormat = (int)settings.atsc3().demodOutputFormat,
- };
- atsc3Settings.plpSettings.resize(settings.atsc3().plpSettings.size());
- for (auto plpSetting : settings.atsc3().plpSettings) {
- atsc3Settings.plpSettings.push_back({
- .plpId = (int)plpSetting.plpId,
- .modulation = (int)plpSetting.modulation,
- .interleaveMode = (int)plpSetting.interleaveMode,
- .codeRate = (int)plpSetting.codeRate,
- .fec = (int)plpSetting.fec,
- });
- }
- return atsc3Settings;
-}
-
-TunerFrontendIsdbsSettings FrontendClient::getAidlIsdbsSettings(const FrontendSettings& settings) {
- TunerFrontendIsdbsSettings isdbsSettings{
- .frequency = (int)settings.isdbs().frequency,
- .streamId = (char16_t)settings.isdbs().streamId,
- .streamIdType = (int)settings.isdbs().streamIdType,
- .modulation = (int)settings.isdbs().modulation,
- .codeRate = (int)settings.isdbs().coderate,
- .symbolRate = (int)settings.isdbs().symbolRate,
- .rolloff = (int)settings.isdbs().rolloff,
- };
- return isdbsSettings;
-}
-
-TunerFrontendIsdbs3Settings FrontendClient::getAidlIsdbs3Settings(
- const FrontendSettings& settings) {
- TunerFrontendIsdbs3Settings isdbs3Settings{
- .frequency = (int)settings.isdbs3().frequency,
- .streamId = (char16_t)settings.isdbs3().streamId,
- .streamIdType = (int)settings.isdbs3().streamIdType,
- .modulation = (int)settings.isdbs3().modulation,
- .codeRate = (int)settings.isdbs3().coderate,
- .symbolRate = (int)settings.isdbs3().symbolRate,
- .rolloff = (int)settings.isdbs3().rolloff,
- };
- return isdbs3Settings;
-}
-
-TunerFrontendIsdbtSettings FrontendClient::getAidlIsdbtSettings(const FrontendSettings& settings) {
- TunerFrontendIsdbtSettings isdbtSettings{
- .frequency = (int)settings.isdbt().frequency,
- .modulation = (int)settings.isdbt().modulation,
- .bandwidth = (int)settings.isdbt().bandwidth,
- .mode = (int)settings.isdbt().mode,
- .codeRate = (int)settings.isdbt().coderate,
- .guardInterval = (int)settings.isdbt().guardInterval,
- .serviceAreaId = (int)settings.isdbt().serviceAreaId,
- };
- return isdbtSettings;
-}
-
-bool FrontendClient::validateExtendedSettings(const FrontendSettingsExt1_1& settingsExt1_1) {
- return settingsExt1_1.endFrequency != (uint32_t)Constant::INVALID_FRONTEND_SETTING_FREQUENCY
- || settingsExt1_1.inversion != FrontendSpectralInversion::UNDEFINED
- || settingsExt1_1.settingExt.getDiscriminator()
- != FrontendSettingsExt1_1::SettingsExt::hidl_discriminator::noinit;
-}
-
-/////////////// TunerFrontendCallback ///////////////////////
-
-TunerFrontendCallback::TunerFrontendCallback(sp<FrontendClientCallback> frontendClientCallback)
- : mFrontendClientCallback(frontendClientCallback) {}
-
-Status TunerFrontendCallback::onEvent(int frontendEventType) {
- if (mFrontendClientCallback != NULL) {
- mFrontendClientCallback->onEvent(static_cast<FrontendEventType>(frontendEventType));
- return Status::ok();
- }
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_STATE));
-}
-
-Status TunerFrontendCallback::onScanMessage(int messageType,
- const TunerFrontendScanMessage& message) {
- if (mFrontendClientCallback != NULL) {
- if (!is1_1ExtendedScanMessage(messageType)) {
- mFrontendClientCallback->onScanMessage(
- static_cast<FrontendScanMessageType>(messageType),
- getHalScanMessage(messageType, message));
- } else {
- mFrontendClientCallback->onScanMessageExt1_1(
- static_cast<FrontendScanMessageTypeExt1_1>(messageType),
- getHalScanMessageExt1_1(messageType, message));
- }
- return Status::ok();
- }
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_STATE));
+ return static_cast<int32_t>(Constant::INVALID_FRONTEND_ID);
}
/////////////// IFrontendCallback ///////////////////////
-
-HidlFrontendCallback::HidlFrontendCallback(sp<FrontendClientCallback> frontendClientCallback)
+TunerFrontendCallback::TunerFrontendCallback(sp<FrontendClientCallback> frontendClientCallback)
: mFrontendClientCallback(frontendClientCallback) {}
-Return<void> HidlFrontendCallback::onEvent(FrontendEventType frontendEventType) {
- if (mFrontendClientCallback != NULL) {
+Status TunerFrontendCallback::onEvent(FrontendEventType frontendEventType) {
+ if (mFrontendClientCallback != nullptr) {
mFrontendClientCallback->onEvent(frontendEventType);
+ return Status::ok();
}
- return Void();
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_STATE));
}
-Return<void> HidlFrontendCallback::onScanMessage(FrontendScanMessageType type,
- const FrontendScanMessage& message) {
- if (mFrontendClientCallback != NULL) {
- mFrontendClientCallback->onScanMessage(type, message);
+Status TunerFrontendCallback::onScanMessage(FrontendScanMessageType messageType,
+ const FrontendScanMessage& message) {
+ if (mFrontendClientCallback != nullptr) {
+ mFrontendClientCallback->onScanMessage(messageType, message);
+ return Status::ok();
}
- return Void();
+ return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_STATE));
}
-Return<void> HidlFrontendCallback::onScanMessageExt1_1(FrontendScanMessageTypeExt1_1 type,
- const FrontendScanMessageExt1_1& message) {
- if (mFrontendClientCallback != NULL) {
- mFrontendClientCallback->onScanMessageExt1_1(type, message);
- }
- return Void();
-}
-
-/////////////// FrontendClientCallback Helper Methods ///////////////////////
-
-FrontendScanMessage TunerFrontendCallback::getHalScanMessage(
- int messageType, const TunerFrontendScanMessage& message) {
- FrontendScanMessage scanMessage;
- switch (messageType) {
- case (int) FrontendScanMessageType::LOCKED:
- scanMessage.isLocked(message.get<TunerFrontendScanMessage::isLocked>());
- break;
- case (int) FrontendScanMessageType::END:
- scanMessage.isEnd(message.get<TunerFrontendScanMessage::isEnd>());
- break;
- case (int) FrontendScanMessageType::PROGRESS_PERCENT:
- scanMessage.progressPercent(message.get<TunerFrontendScanMessage::progressPercent>());
- break;
- case (int) FrontendScanMessageType::FREQUENCY: {
- vector<int> f = message.get<TunerFrontendScanMessage::frequencies>();
- hidl_vec<uint32_t> frequencies(begin(f), end(f));
- scanMessage.frequencies(frequencies);
- break;
- }
- case (int) FrontendScanMessageType::SYMBOL_RATE: {
- vector<int> s = message.get<TunerFrontendScanMessage::symbolRates>();
- hidl_vec<uint32_t> symbolRates(begin(s), end(s));
- scanMessage.symbolRates(symbolRates);
- break;
- }
- case (int) FrontendScanMessageType::HIERARCHY:
- scanMessage.hierarchy(static_cast<FrontendDvbtHierarchy>(
- message.get<TunerFrontendScanMessage::hierarchy>()));
- break;
- case (int) FrontendScanMessageType::ANALOG_TYPE:
- scanMessage.analogType(static_cast<FrontendAnalogType>(
- message.get<TunerFrontendScanMessage::analogType>()));
- break;
- case (int) FrontendScanMessageType::PLP_IDS: {
- vector<uint8_t> p = message.get<TunerFrontendScanMessage::plpIds>();
- hidl_vec<uint8_t> plpIds(begin(p), end(p));
- scanMessage.plpIds(plpIds);
- break;
- }
- case (int) FrontendScanMessageType::GROUP_IDS: {
- vector<uint8_t> g = message.get<TunerFrontendScanMessage::groupIds>();
- hidl_vec<uint8_t> groupIds(begin(g), end(g));
- scanMessage.groupIds(groupIds);
- break;
- }
- case (int) FrontendScanMessageType::INPUT_STREAM_IDS: {
- vector<char16_t> i = message.get<TunerFrontendScanMessage::inputStreamIds>();
- hidl_vec<uint16_t> inputStreamIds(begin(i), end(i));
- scanMessage.inputStreamIds(inputStreamIds);
- break;
- }
- case (int) FrontendScanMessageType::STANDARD: {
- FrontendScanMessage::Standard std;
- int standard = message.get<TunerFrontendScanMessage::std>();
- switch (mType) {
- case (int) FrontendType::DVBS:
- std.sStd(static_cast<FrontendDvbsStandard>(standard));
- scanMessage.std(std);
- break;
- case (int) FrontendType::DVBT:
- std.tStd(static_cast<FrontendDvbtStandard>(standard));
- scanMessage.std(std);
- break;
- case (int) FrontendType::ANALOG:
- std.sifStd(static_cast<FrontendAnalogSifStandard>(standard));
- scanMessage.std(std);
- break;
- default:
- break;
- }
- break;
- }
- case (int) FrontendScanMessageType::ATSC3_PLP_INFO: {
- vector<TunerFrontendScanAtsc3PlpInfo> plp =
- message.get<TunerFrontendScanMessage::atsc3PlpInfos>();
- hidl_vec<FrontendScanAtsc3PlpInfo> plpInfo;
- int size = plp.size();
- plpInfo.resize(size);
- for (int i = 0; i < size; i++) {
- auto info = message.get<TunerFrontendScanMessage::atsc3PlpInfos>()[i];
- FrontendScanAtsc3PlpInfo p{
- .plpId = static_cast<uint8_t>(info.plpId),
- .bLlsFlag = info.llsFlag,
- };
- plpInfo[i] = p;
- }
- scanMessage.atsc3PlpInfos(plpInfo);
- break;
- }
- default:
- break;
- }
- return scanMessage;
-}
-
-FrontendScanMessageExt1_1 TunerFrontendCallback::getHalScanMessageExt1_1(
- int messageType, const TunerFrontendScanMessage& message) {
- FrontendScanMessageExt1_1 scanMessage;
- switch (messageType) {
- case (int) FrontendScanMessageTypeExt1_1::HIGH_PRIORITY:
- scanMessage.isHighPriority(message.get<TunerFrontendScanMessage::isHighPriority>());
- break;
- case (int) FrontendScanMessageTypeExt1_1::DVBC_ANNEX:
- scanMessage.annex(static_cast<FrontendDvbcAnnex>(
- message.get<TunerFrontendScanMessage::annex>()));
- break;
- case (int) FrontendScanMessageTypeExt1_1::MODULATION: {
- FrontendModulation m;
- int modulation = message.get<TunerFrontendScanMessage::modulation>();
- switch (mType) {
- case (int) FrontendType::DVBC:
- m.dvbc(static_cast<FrontendDvbcModulation>(modulation));
- scanMessage.modulation(m);
- break;
- case (int) FrontendType::DVBS:
- m.dvbs(static_cast<FrontendDvbsModulation>(modulation));
- scanMessage.modulation(m);
- break;
- case (int) FrontendType::DVBT:
- m.dvbt(static_cast<FrontendDvbtConstellation>(modulation));
- scanMessage.modulation(m);
- break;
- case (int) FrontendType::ISDBS:
- m.isdbs(static_cast<FrontendIsdbsModulation>(modulation));
- scanMessage.modulation(m);
- break;
- case (int) FrontendType::ISDBS3:
- m.isdbs3(static_cast<FrontendIsdbs3Modulation>(modulation));
- scanMessage.modulation(m);
- break;
- case (int) FrontendType::ISDBT:
- m.isdbt(static_cast<FrontendIsdbtModulation>(modulation));
- scanMessage.modulation(m);
- break;
- case (int) FrontendType::ATSC:
- m.atsc(static_cast<FrontendAtscModulation>(modulation));
- scanMessage.modulation(m);
- break;
- case (int) FrontendType::ATSC3:
- m.atsc3(static_cast<FrontendAtsc3Modulation>(modulation));
- scanMessage.modulation(m);
- break;
- case (int) hardware::tv::tuner::V1_1::FrontendType::DTMB:
- m.dtmb(static_cast<FrontendDtmbModulation>(modulation));
- scanMessage.modulation(m);
- break;
- default:
- break;
- }
- break;
- }
- default:
- break;
- }
- return scanMessage;
-}
-
-bool TunerFrontendCallback::is1_1ExtendedScanMessage(int messageType) {
- return messageType >= (int)FrontendScanMessageTypeExt1_1::MODULATION
- && messageType <= (int)FrontendScanMessageTypeExt1_1::HIGH_PRIORITY;
-}
} // namespace android
diff --git a/media/jni/tuner/FrontendClient.h b/media/jni/tuner/FrontendClient.h
index 1dd950e..08c0b20 100644
--- a/media/jni/tuner/FrontendClient.h
+++ b/media/jni/tuner/FrontendClient.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,53 +17,29 @@
#ifndef _ANDROID_MEDIA_TV_FRONTEND_CLIENT_H_
#define _ANDROID_MEDIA_TV_FRONTEND_CLIENT_H_
+#include <aidl/android/hardware/tv/tuner/DemuxFilterSettings.h>
+#include <aidl/android/hardware/tv/tuner/FrontendType.h>
+#include <aidl/android/hardware/tv/tuner/Result.h>
#include <aidl/android/media/tv/tuner/BnTunerFrontendCallback.h>
#include <aidl/android/media/tv/tuner/ITunerFrontend.h>
-#include <android/hardware/tv/tuner/1.1/IFrontend.h>
-#include <android/hardware/tv/tuner/1.1/IFrontendCallback.h>
-#include <android/hardware/tv/tuner/1.1/types.h>
+#include <utils/RefBase.h>
#include "ClientHelper.h"
#include "FrontendClientCallback.h"
#include "LnbClient.h"
using Status = ::ndk::ScopedAStatus;
-
+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::FrontendType;
+using ::aidl::android::hardware::tv::tuner::Result;
using ::aidl::android::media::tv::tuner::BnTunerFrontendCallback;
using ::aidl::android::media::tv::tuner::ITunerFrontend;
-using ::aidl::android::media::tv::tuner::TunerFrontendAnalogSettings;
-using ::aidl::android::media::tv::tuner::TunerFrontendAtscSettings;
-using ::aidl::android::media::tv::tuner::TunerFrontendAtsc3Settings;
-using ::aidl::android::media::tv::tuner::TunerFrontendCableSettings;
-using ::aidl::android::media::tv::tuner::TunerFrontendDvbsSettings;
-using ::aidl::android::media::tv::tuner::TunerFrontendDvbtSettings;
-using ::aidl::android::media::tv::tuner::TunerFrontendDtmbSettings;
-using ::aidl::android::media::tv::tuner::TunerFrontendIsdbsSettings;
-using ::aidl::android::media::tv::tuner::TunerFrontendIsdbs3Settings;
-using ::aidl::android::media::tv::tuner::TunerFrontendIsdbtSettings;
-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::tv::tuner::V1_0::FrontendInfo;
-using ::android::hardware::tv::tuner::V1_0::FrontendEventType;
-using ::android::hardware::tv::tuner::V1_0::FrontendScanMessage;
-using ::android::hardware::tv::tuner::V1_0::FrontendScanMessageType;
-using ::android::hardware::tv::tuner::V1_0::FrontendScanType;
-using ::android::hardware::tv::tuner::V1_0::FrontendSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendStatus;
-using ::android::hardware::tv::tuner::V1_0::FrontendStatusType;
-using ::android::hardware::tv::tuner::V1_0::IFrontend;
-using ::android::hardware::tv::tuner::V1_0::Result;
-
-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 ::android::hardware::tv::tuner::V1_1::FrontendStatusTypeExt1_1;
-using ::android::hardware::tv::tuner::V1_1::IFrontendCallback;
using namespace std;
@@ -74,32 +50,8 @@
public:
TunerFrontendCallback(sp<FrontendClientCallback> frontendClientCallback);
- Status onEvent(int frontendEventType);
-
- Status onScanMessage(int messageType, const TunerFrontendScanMessage& message);
-
- void setFrontendType(int frontendType) { mType = frontendType; }
-
-private:
- FrontendScanMessage getHalScanMessage(int messageType, const TunerFrontendScanMessage& message);
- FrontendScanMessageExt1_1 getHalScanMessageExt1_1(int messageType,
- const TunerFrontendScanMessage& message);
- bool is1_1ExtendedScanMessage(int messageType);
-
- sp<FrontendClientCallback> mFrontendClientCallback;
- int mType;
-};
-
-struct HidlFrontendCallback : public IFrontendCallback {
-
-public:
- HidlFrontendCallback(sp<FrontendClientCallback> frontendClientCallback);
-
- 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& messageExt);
+ Status onEvent(FrontendEventType frontendEventType);
+ Status onScanMessage(FrontendScanMessageType messageType, const FrontendScanMessage& message);
private:
sp<FrontendClientCallback> mFrontendClientCallback;
@@ -108,7 +60,7 @@
struct FrontendClient : public RefBase {
public:
- FrontendClient(shared_ptr<ITunerFrontend> tunerFrontend, int type);
+ FrontendClient(shared_ptr<ITunerFrontend> tunerFrontend, FrontendType type);
~FrontendClient();
/**
@@ -116,13 +68,10 @@
*/
Result setCallback(sp<FrontendClientCallback> frontendClientCallback);
- // TODO: remove after migration to Tuner Service is done.
- void setHidlFrontend(sp<IFrontend> frontend);
-
/**
* Tuner Frontend with Frontend Settings.
*/
- Result tune(const FrontendSettings& settings, const FrontendSettingsExt1_1& settingsExt1_1);
+ Result tune(const FrontendSettings& settings);
/**
* Stop tune Frontend.
@@ -132,8 +81,7 @@
/**
* Scan the frontend to use the settings given.
*/
- Result scan(const FrontendSettings& settings, FrontendScanType frontendScanType,
- const FrontendSettingsExt1_1& settingsExt1_1);
+ Result scan(const FrontendSettings& settings, FrontendScanType frontendScanType);
/**
* Stop the previous scanning.
@@ -146,12 +94,6 @@
vector<FrontendStatus> getStatus(vector<FrontendStatusType> statusTypes);
/**
- * Gets the 1.1 extended statuses of the frontend.
- */
- vector<FrontendStatusExt1_1> getStatusExtended_1_1(
- vector<FrontendStatusTypeExt1_1> statusTypes);
-
- /**
* Sets Low-Noise Block downconverter (LNB) for satellite frontend.
*/
Result setLnb(sp<LnbClient> lnbClient);
@@ -166,68 +108,28 @@
*
* @return lts id
*/
- int linkCiCamToFrontend(int ciCamId);
+ int32_t linkCiCamToFrontend(int32_t ciCamId);
/**
* Unink Frontend to the cicam with given id.
*/
- Result unlinkCiCamToFrontend(int ciCamId);
+ Result unlinkCiCamToFrontend(int32_t ciCamId);
/**
* Close Frontend.
*/
Result close();
+ int32_t getId();
shared_ptr<ITunerFrontend> getAidlFrontend();
-
- void setId(int id);
- int getId();
-
private:
- vector<FrontendStatus> getHidlStatus(vector<TunerFrontendStatus>& aidlStatus);
- vector<FrontendStatusExt1_1> getHidlStatusExt(vector<TunerFrontendStatus>& aidlStatus);
-
- TunerFrontendSettings getAidlFrontendSettings(
- const FrontendSettings& settings, const FrontendSettingsExt1_1& settingsExt1_1);
- TunerFrontendAnalogSettings getAidlAnalogSettings(
- const FrontendSettings& settings, const FrontendSettingsExt1_1& settingsExt1_1);
- TunerFrontendDvbsSettings getAidlDvbsSettings(
- const FrontendSettings& settings, const FrontendSettingsExt1_1& settingsExt1_1);
- TunerFrontendCableSettings getAidlCableSettings(
- const FrontendSettings& settings, const FrontendSettingsExt1_1& settingsExt1_1);
- TunerFrontendDvbtSettings getAidlDvbtSettings(
- const FrontendSettings& settings, const FrontendSettingsExt1_1& settingsExt1_1);
- TunerFrontendDtmbSettings getAidlDtmbSettings(const FrontendSettingsExt1_1& settingsExt1_1);
- TunerFrontendAtscSettings getAidlAtscSettings(const FrontendSettings& settings);
- TunerFrontendAtsc3Settings getAidlAtsc3Settings(const FrontendSettings& settings);
- TunerFrontendIsdbsSettings getAidlIsdbsSettings(const FrontendSettings& settings);
- TunerFrontendIsdbs3Settings getAidlIsdbs3Settings(const FrontendSettings& settings);
- TunerFrontendIsdbtSettings getAidlIsdbtSettings(const FrontendSettings& settings);
-
- bool validateExtendedSettings(const FrontendSettingsExt1_1& settingsExt1_1);
-
/**
* An AIDL Tuner Frontend Singleton assigned at the first time when the Tuner Client
* opens a frontend cient. Default null when the service does not exist.
*/
shared_ptr<ITunerFrontend> mTunerFrontend;
- /**
- * A Frontend 1.0 HAL interface as a fall back interface when the Tuner Service does not exist.
- * This is a temprary connection before the Tuner Framework fully migrates to the TunerService.
- * Default null.
- */
- sp<IFrontend> mFrontend;
-
- /**
- * A Frontend 1.1 HAL interface as a fall back interface when the Tuner Service does not exist.
- * This is a temprary connection before the Tuner Framework fully migrates to the TunerService.
- * Default null.
- */
- sp<::android::hardware::tv::tuner::V1_1::IFrontend> mFrontend_1_1;
-
- int mId;
- int mType;
+ FrontendType mType;
};
} // namespace android
diff --git a/media/jni/tuner/FrontendClientCallback.h b/media/jni/tuner/FrontendClientCallback.h
index 94f8c40..15b08ef 100644
--- a/media/jni/tuner/FrontendClientCallback.h
+++ b/media/jni/tuner/FrontendClientCallback.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,11 +17,11 @@
#ifndef _ANDROID_MEDIA_TV_FRONTEND_CLIENT_CALLBACK_H_
#define _ANDROID_MEDIA_TV_FRONTEND_CLIENT_CALLBACK_H_
-using ::android::hardware::tv::tuner::V1_0::FrontendEventType;
-using ::android::hardware::tv::tuner::V1_0::FrontendScanMessage;
-using ::android::hardware::tv::tuner::V1_0::FrontendScanMessageType;
-using ::android::hardware::tv::tuner::V1_1::FrontendScanMessageExt1_1;
-using ::android::hardware::tv::tuner::V1_1::FrontendScanMessageTypeExt1_1;
+#include <utils/RefBase.h>
+
+using ::aidl::android::hardware::tv::tuner::FrontendEventType;
+using ::aidl::android::hardware::tv::tuner::FrontendScanMessage;
+using ::aidl::android::hardware::tv::tuner::FrontendScanMessageType;
using namespace std;
@@ -30,8 +30,6 @@
struct FrontendClientCallback : public RefBase {
virtual void onEvent(FrontendEventType frontendEventType);
virtual void onScanMessage(FrontendScanMessageType type, const FrontendScanMessage& message);
- virtual void onScanMessageExt1_1(
- FrontendScanMessageTypeExt1_1 type, const FrontendScanMessageExt1_1& messageExt);
};
} // namespace android
diff --git a/media/jni/tuner/LnbClient.cpp b/media/jni/tuner/LnbClient.cpp
index 073c49a..43198e3 100644
--- a/media/jni/tuner/LnbClient.cpp
+++ b/media/jni/tuner/LnbClient.cpp
@@ -21,148 +21,89 @@
#include "LnbClient.h"
-using ::android::hardware::tv::tuner::V1_0::Result;
-
namespace android {
/////////////// LnbClient ///////////////////////
-
LnbClient::LnbClient(shared_ptr<ITunerLnb> tunerLnb) {
mTunerLnb = tunerLnb;
- mId = -1;
}
LnbClient::~LnbClient() {
- mTunerLnb = NULL;
- mLnb = NULL;
- mId = -1;
-}
-
-// TODO: remove after migration to Tuner Service is done.
-void LnbClient::setHidlLnb(sp<ILnb> lnb) {
- mLnb = lnb;
+ mTunerLnb = nullptr;
}
Result LnbClient::setCallback(sp<LnbClientCallback> cb) {
- if (mTunerLnb != NULL) {
+ if (mTunerLnb != nullptr) {
shared_ptr<TunerLnbCallback> aidlCallback =
::ndk::SharedRefBase::make<TunerLnbCallback>(cb);
Status s = mTunerLnb->setCallback(aidlCallback);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mLnb != NULL) {
- sp<HidlLnbCallback> hidlCallback = new HidlLnbCallback(cb);
- return mLnb->setCallback(hidlCallback);
- }
-
return Result::INVALID_STATE;
}
Result LnbClient::setVoltage(LnbVoltage voltage) {
- if (mTunerLnb != NULL) {
- Status s = mTunerLnb->setVoltage((int)voltage);
+ if (mTunerLnb != nullptr) {
+ Status s = mTunerLnb->setVoltage(voltage);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mLnb != NULL) {
- return mLnb->setVoltage(voltage);
- }
-
return Result::INVALID_STATE;
}
Result LnbClient::setTone(LnbTone tone) {
- if (mTunerLnb != NULL) {
- Status s = mTunerLnb->setTone((int)tone);
+ if (mTunerLnb != nullptr) {
+ Status s = mTunerLnb->setTone(tone);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mLnb != NULL) {
- return mLnb->setTone(tone);
- }
-
return Result::INVALID_STATE;
}
Result LnbClient::setSatellitePosition(LnbPosition position) {
- if (mTunerLnb != NULL) {
- Status s = mTunerLnb->setSatellitePosition((int)position);
+ if (mTunerLnb != nullptr) {
+ Status s = mTunerLnb->setSatellitePosition(position);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mLnb != NULL) {
- return mLnb->setSatellitePosition(position);
- }
-
return Result::INVALID_STATE;
}
Result LnbClient::sendDiseqcMessage(vector<uint8_t> diseqcMessage) {
- if (mTunerLnb != NULL) {
+ if (mTunerLnb != nullptr) {
Status s = mTunerLnb->sendDiseqcMessage(diseqcMessage);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mLnb != NULL) {
- return mLnb->sendDiseqcMessage(diseqcMessage);
- }
-
return Result::INVALID_STATE;
}
Result LnbClient::close() {
- if (mTunerLnb != NULL) {
+ if (mTunerLnb != nullptr) {
Status s = mTunerLnb->close();
- mTunerLnb = NULL;
+ mTunerLnb = nullptr;
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mLnb != NULL) {
- Result res = mLnb->close();
- mLnb = NULL;
- return res;
- }
-
return Result::INVALID_STATE;
}
-/////////////// ILnbCallback ///////////////////////
-
-HidlLnbCallback::HidlLnbCallback(sp<LnbClientCallback> lnbClientCallback)
- : mLnbClientCallback(lnbClientCallback) {}
-
-Return<void> HidlLnbCallback::onEvent(const LnbEventType lnbEventType) {
- if (mLnbClientCallback != NULL) {
- mLnbClientCallback->onEvent(lnbEventType);
- }
- return Void();
-}
-
-Return<void> HidlLnbCallback::onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage) {
- if (mLnbClientCallback != NULL) {
- mLnbClientCallback->onDiseqcMessage(diseqcMessage);
- }
- return Void();
-}
-
/////////////// TunerLnbCallback ///////////////////////
-
TunerLnbCallback::TunerLnbCallback(sp<LnbClientCallback> lnbClientCallback)
: mLnbClientCallback(lnbClientCallback) {}
-Status TunerLnbCallback::onEvent(int lnbEventType) {
- if (mLnbClientCallback != NULL) {
- mLnbClientCallback->onEvent(static_cast<LnbEventType>(lnbEventType));
+Status TunerLnbCallback::onEvent(LnbEventType lnbEventType) {
+ if (mLnbClientCallback != nullptr) {
+ mLnbClientCallback->onEvent(lnbEventType);
return Status::ok();
}
return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_STATE));
}
Status TunerLnbCallback::onDiseqcMessage(const vector<uint8_t>& diseqcMessage) {
- if (mLnbClientCallback != NULL) {
- hidl_vec<uint8_t> msg(begin(diseqcMessage), end(diseqcMessage));
- mLnbClientCallback->onDiseqcMessage(msg);
+ if (mLnbClientCallback != nullptr) {
+ mLnbClientCallback->onDiseqcMessage(diseqcMessage);
return Status::ok();
}
return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_STATE));
diff --git a/media/jni/tuner/LnbClient.h b/media/jni/tuner/LnbClient.h
index 7c6118c..86e3f67 100644
--- a/media/jni/tuner/LnbClient.h
+++ b/media/jni/tuner/LnbClient.h
@@ -17,31 +17,24 @@
#ifndef _ANDROID_MEDIA_TV_LNB_CLIENT_H_
#define _ANDROID_MEDIA_TV_LNB_CLIENT_H_
+#include <aidl/android/hardware/tv/tuner/LnbPosition.h>
+#include <aidl/android/hardware/tv/tuner/LnbTone.h>
+#include <aidl/android/hardware/tv/tuner/LnbVoltage.h>
#include <aidl/android/media/tv/tuner/BnTunerLnbCallback.h>
#include <aidl/android/media/tv/tuner/ITunerLnb.h>
-#include <android/hardware/tv/tuner/1.0/ILnb.h>
-#include <android/hardware/tv/tuner/1.0/ILnbCallback.h>
-#include <android/hardware/tv/tuner/1.1/types.h>
+#include <utils/RefBase.h>
#include "ClientHelper.h"
#include "LnbClientCallback.h"
using Status = ::ndk::ScopedAStatus;
+using ::aidl::android::hardware::tv::tuner::LnbPosition;
+using ::aidl::android::hardware::tv::tuner::LnbTone;
+using ::aidl::android::hardware::tv::tuner::LnbVoltage;
using ::aidl::android::media::tv::tuner::BnTunerLnbCallback;
using ::aidl::android::media::tv::tuner::ITunerLnb;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::tv::tuner::V1_0::ILnb;
-using ::android::hardware::tv::tuner::V1_0::ILnbCallback;
-using ::android::hardware::tv::tuner::V1_0::LnbId;
-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;
-
using namespace std;
namespace android {
@@ -51,33 +44,19 @@
public:
TunerLnbCallback(sp<LnbClientCallback> lnbClientCallback);
- Status onEvent(int lnbEventType);
+ Status onEvent(LnbEventType lnbEventType);
Status onDiseqcMessage(const vector<uint8_t>& diseqcMessage);
private:
sp<LnbClientCallback> mLnbClientCallback;
};
-struct HidlLnbCallback : public ILnbCallback {
-
-public:
- HidlLnbCallback(sp<LnbClientCallback> lnbClientCallback);
- virtual Return<void> onEvent(const LnbEventType lnbEventType);
- virtual Return<void> onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
-
-private:
- sp<LnbClientCallback> mLnbClientCallback;
-};
-
struct LnbClient : public RefBase {
public:
LnbClient(shared_ptr<ITunerLnb> tunerLnb);
~LnbClient();
- // TODO: remove after migration to Tuner Service is done.
- void setHidlLnb(sp<ILnb> lnb);
-
/**
* Set the lnb callback.
*/
@@ -109,8 +88,6 @@
Result close();
shared_ptr<ITunerLnb> getAidlLnb() { return mTunerLnb; }
- void setId(LnbId id) { mId = id; }
- LnbId getId() { return mId; }
private:
/**
@@ -118,15 +95,6 @@
* opens an Lnb. Default null when lnb is not opened.
*/
shared_ptr<ITunerLnb> mTunerLnb;
-
- /**
- * A Lnb HAL interface that is ready before migrating to the TunerLnb.
- * This is a temprary interface before Tuner Framework migrates to use TunerService.
- * Default null when the HAL service does not exist.
- */
- sp<ILnb> mLnb;
-
- LnbId mId;
};
} // namespace android
diff --git a/media/jni/tuner/LnbClientCallback.h b/media/jni/tuner/LnbClientCallback.h
index 253d7ef..612514f 100644
--- a/media/jni/tuner/LnbClientCallback.h
+++ b/media/jni/tuner/LnbClientCallback.h
@@ -17,8 +17,9 @@
#ifndef _ANDROID_MEDIA_TV_LNB_CLIENT_CALLBACK_H_
#define _ANDROID_MEDIA_TV_LNB_CLIENT_CALLBACK_H_
-using ::android::hardware::hidl_vec;
-using ::android::hardware::tv::tuner::V1_0::LnbEventType;
+#include <utils/RefBase.h>
+
+using ::aidl::android::hardware::tv::tuner::LnbEventType;
using namespace std;
@@ -26,8 +27,8 @@
struct LnbClientCallback : public RefBase {
virtual void onEvent(const LnbEventType lnbEventType);
- virtual void onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
+ virtual void onDiseqcMessage(const vector<uint8_t>& diseqcMessage);
};
} // namespace android
-#endif // _ANDROID_MEDIA_TV_LNB_CLIENT_CALLBACK_H_
\ No newline at end of file
+#endif // _ANDROID_MEDIA_TV_LNB_CLIENT_CALLBACK_H_
diff --git a/media/jni/tuner/TimeFilterClient.cpp b/media/jni/tuner/TimeFilterClient.cpp
index e123c9f..40dba8b 100644
--- a/media/jni/tuner/TimeFilterClient.cpp
+++ b/media/jni/tuner/TimeFilterClient.cpp
@@ -16,14 +16,15 @@
#define LOG_TAG "TimeFilterClient"
+#include "TimeFilterClient.h"
+
+#include <aidl/android/hardware/tv/tuner/Constant64Bit.h>
#include <android-base/logging.h>
#include <utils/Log.h>
#include "ClientHelper.h"
-#include "TimeFilterClient.h"
-using ::android::hardware::tv::tuner::V1_0::Result;
-using ::android::hardware::tv::tuner::V1_1::Constant64Bit;
+using ::aidl::android::hardware::tv::tuner::Constant64Bit;
namespace android {
@@ -34,108 +35,60 @@
}
TimeFilterClient::~TimeFilterClient() {
- mTunerTimeFilter = NULL;
- mTimeFilter = NULL;
+ mTunerTimeFilter = nullptr;
}
-// TODO: remove after migration to Tuner Service is done.
-void TimeFilterClient::setHidlTimeFilter(sp<ITimeFilter> timeFilter) {
- mTimeFilter = timeFilter;
-}
-
-Result TimeFilterClient::setTimeStamp(long timeStamp) {
- if (mTunerTimeFilter != NULL) {
+Result TimeFilterClient::setTimeStamp(int64_t timeStamp) {
+ if (mTunerTimeFilter != nullptr) {
Status s = mTunerTimeFilter->setTimeStamp(timeStamp);
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mTimeFilter != NULL) {
- return mTimeFilter->setTimeStamp(timeStamp);
- }
-
return Result::INVALID_STATE;
}
Result TimeFilterClient::clearTimeStamp() {
- if (mTunerTimeFilter != NULL) {
+ if (mTunerTimeFilter != nullptr) {
Status s = mTunerTimeFilter->clearTimeStamp();
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mTimeFilter != NULL) {
- return mTimeFilter->clearTimeStamp();
- }
-
return Result::INVALID_STATE;
}
-long TimeFilterClient::getTimeStamp() {
- if (mTunerTimeFilter != NULL) {
+int64_t TimeFilterClient::getTimeStamp() {
+ if (mTunerTimeFilter != nullptr) {
int64_t timeStamp;
Status s = mTunerTimeFilter->getTimeStamp(&timeStamp);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return (long)Constant64Bit::INVALID_PRESENTATION_TIME_STAMP;
+ if (!s.isOk()) {
+ return static_cast<int64_t>(Constant64Bit::INVALID_PRESENTATION_TIME_STAMP);
}
return timeStamp;
}
- if (mTimeFilter != NULL) {
- Result res;
- long timestamp;
- mTimeFilter->getTimeStamp(
- [&](Result r, uint64_t t) {
- res = r;
- timestamp = t;
- });
- if (res != Result::SUCCESS) {
- return (long)Constant64Bit::INVALID_PRESENTATION_TIME_STAMP;
- }
- return timestamp;
- }
-
- return (long)Constant64Bit::INVALID_PRESENTATION_TIME_STAMP;
+ return static_cast<int64_t>(Constant64Bit::INVALID_PRESENTATION_TIME_STAMP);
}
-long TimeFilterClient::getSourceTime() {
- if (mTunerTimeFilter != NULL) {
+int64_t TimeFilterClient::getSourceTime() {
+ if (mTunerTimeFilter != nullptr) {
int64_t sourceTime;
Status s = mTunerTimeFilter->getTimeStamp(&sourceTime);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return (long)Constant64Bit::INVALID_PRESENTATION_TIME_STAMP;
+ if (!s.isOk()) {
+ return static_cast<int64_t>(Constant64Bit::INVALID_PRESENTATION_TIME_STAMP);
}
return sourceTime;
}
- if (mTimeFilter != NULL) {
- Result res;
- long sourceTime;
- mTimeFilter->getSourceTime(
- [&](Result r, uint64_t t) {
- res = r;
- sourceTime = t;
- });
- if (res != Result::SUCCESS) {
- return (long)Constant64Bit::INVALID_PRESENTATION_TIME_STAMP;
- }
- return sourceTime;
- }
-
- return (long)Constant64Bit::INVALID_PRESENTATION_TIME_STAMP;
+ return static_cast<int64_t>(Constant64Bit::INVALID_PRESENTATION_TIME_STAMP);
}
Result TimeFilterClient::close() {
- if (mTunerTimeFilter != NULL) {
+ if (mTunerTimeFilter != nullptr) {
Status s = mTunerTimeFilter->close();
- mTunerTimeFilter = NULL;
+ mTunerTimeFilter = nullptr;
return ClientHelper::getServiceSpecificErrorCode(s);
}
- if (mTimeFilter != NULL) {
- Result res = mTimeFilter->close();
- mTimeFilter = NULL;
- return res;
- }
-
return Result::INVALID_STATE;
}
} // namespace android
diff --git a/media/jni/tuner/TimeFilterClient.h b/media/jni/tuner/TimeFilterClient.h
index 56ddd68..46f33be 100644
--- a/media/jni/tuner/TimeFilterClient.h
+++ b/media/jni/tuner/TimeFilterClient.h
@@ -17,18 +17,14 @@
#ifndef _ANDROID_MEDIA_TV_TIME_FILTER_CLIENT_H_
#define _ANDROID_MEDIA_TV_TIME_FILTER_CLIENT_H_
+#include <aidl/android/hardware/tv/tuner/Result.h>
#include <aidl/android/media/tv/tuner/ITunerTimeFilter.h>
-#include <android/hardware/tv/tuner/1.0/ITimeFilter.h>
-#include <android/hardware/tv/tuner/1.1/types.h>
-
-using ::aidl::android::media::tv::tuner::ITunerTimeFilter;
+#include <utils/RefBase.h>
using Status = ::ndk::ScopedAStatus;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::tv::tuner::V1_0::ITimeFilter;
-using ::android::hardware::tv::tuner::V1_0::Result;
+
+using ::aidl::android::hardware::tv::tuner::Result;
+using ::aidl::android::media::tv::tuner::ITunerTimeFilter;
using namespace std;
@@ -40,13 +36,10 @@
TimeFilterClient(shared_ptr<ITunerTimeFilter> tunerTimeFilter);
~TimeFilterClient();
- // TODO: remove after migration to Tuner Service is done.
- void setHidlTimeFilter(sp<ITimeFilter> timeFilter);
-
/**
* Set time stamp for time based filter.
*/
- Result setTimeStamp(long timeStamp);
+ Result setTimeStamp(int64_t timeStamp);
/**
* Clear the time stamp in the time filter.
@@ -56,12 +49,12 @@
/**
* Get the current time in the time filter.
*/
- long getTimeStamp();
+ int64_t getTimeStamp();
/**
* Get the time from the beginning of current data source.
*/
- long getSourceTime();
+ int64_t getSourceTime();
/**
* Releases the Time Filter instance.
@@ -74,13 +67,6 @@
* opens an TimeFilter. Default null when time filter is not opened.
*/
shared_ptr<ITunerTimeFilter> mTunerTimeFilter;
-
- /**
- * A TimeFilter HAL interface that is ready before migrating to the TunerTimeFilter.
- * This is a temprary interface before Tuner Framework migrates to use TunerService.
- * Default null when the HAL service does not exist.
- */
- sp<ITimeFilter> mTimeFilter;
};
} // namespace android
diff --git a/media/jni/tuner/TunerClient.cpp b/media/jni/tuner/TunerClient.cpp
index e05dba6..d19ee0d4 100644
--- a/media/jni/tuner/TunerClient.cpp
+++ b/media/jni/tuner/TunerClient.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.
@@ -22,31 +22,20 @@
#include "TunerClient.h"
-using ::aidl::android::media::tv::tuner::TunerFrontendCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendDtmbCapabilities;
-using ::android::hardware::tv::tuner::V1_0::FrontendId;
-using ::android::hardware::tv::tuner::V1_0::FrontendStatusType;
-using ::android::hardware::tv::tuner::V1_0::FrontendType;
+using ::aidl::android::hardware::tv::tuner::FrontendStatusType;
+using ::aidl::android::hardware::tv::tuner::FrontendType;
namespace android {
-sp<ITuner> TunerClient::mTuner;
-sp<::android::hardware::tv::tuner::V1_1::ITuner> TunerClient::mTuner_1_1;
shared_ptr<ITunerService> TunerClient::mTunerService;
-int TunerClient::mTunerVersion;
+int32_t TunerClient::mTunerVersion;
/////////////// TunerClient ///////////////////////
TunerClient::TunerClient() {
- // Get HIDL Tuner in migration stage.
- getHidlTuner();
- if (mTuner != NULL) {
- updateTunerResources();
- }
- // Connect with Tuner Service.
::ndk::SpAIBinder binder(AServiceManager_getService("media.tuner"));
mTunerService = ITunerService::fromBinder(binder);
- if (mTunerService == NULL) {
+ if (mTunerService == nullptr) {
ALOGE("Failed to get tuner service");
} else {
mTunerService->getTunerHalVersion(&mTunerVersion);
@@ -54,575 +43,124 @@
}
TunerClient::~TunerClient() {
- mTuner = NULL;
- mTuner_1_1 = NULL;
mTunerVersion = 0;
- mTunerService = NULL;
+ mTunerService = nullptr;
}
-vector<FrontendId> TunerClient::getFrontendIds() {
- vector<FrontendId> ids;
+vector<int32_t> TunerClient::getFrontendIds() {
+ vector<int32_t> ids;
- if (mTunerService != NULL) {
- vector<int32_t> v;
- Status s = mTunerService->getFrontendIds(&v);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS || v.size() == 0) {
+ if (mTunerService != nullptr) {
+ Status s = mTunerService->getFrontendIds(&ids);
+ if (!s.isOk()) {
ids.clear();
- return ids;
}
- for (int32_t id : v) {
- ids.push_back(static_cast<FrontendId>(id));
- }
- return ids;
- }
-
- if (mTuner != NULL) {
- Result res;
- mTuner->getFrontendIds([&](Result r, const hardware::hidl_vec<FrontendId>& frontendIds) {
- res = r;
- ids = frontendIds;
- });
- if (res != Result::SUCCESS || ids.size() == 0) {
- ALOGW("Frontend ids not available");
- ids.clear();
- return ids;
- }
- return ids;
}
return ids;
}
-
-sp<FrontendClient> TunerClient::openFrontend(int frontendHandle) {
- if (mTunerService != NULL) {
+sp<FrontendClient> TunerClient::openFrontend(int32_t frontendHandle) {
+ if (mTunerService != nullptr) {
shared_ptr<ITunerFrontend> tunerFrontend;
Status s = mTunerService->openFrontend(frontendHandle, &tunerFrontend);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS
- || tunerFrontend == NULL) {
- return NULL;
+ if (!s.isOk() || tunerFrontend == nullptr) {
+ return nullptr;
}
- int id;
+ int32_t id;
s = tunerFrontend->getFrontendId(&id);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return NULL;
+ if (!s.isOk()) {
+ tunerFrontend->close();
+ return nullptr;
}
- TunerFrontendInfo aidlFrontendInfo;
- s = mTunerService->getFrontendInfo(id, &aidlFrontendInfo);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return NULL;
+ FrontendInfo frontendInfo;
+ s = mTunerService->getFrontendInfo(id, &frontendInfo);
+ if (!s.isOk()) {
+ tunerFrontend->close();
+ return nullptr;
}
- return new FrontendClient(tunerFrontend, aidlFrontendInfo.type);
+ return new FrontendClient(tunerFrontend, frontendInfo.type);
}
- if (mTuner != NULL) {
- int id = getResourceIdFromHandle(frontendHandle, FRONTEND);
- sp<IFrontend> hidlFrontend = openHidlFrontendById(id);
- if (hidlFrontend != NULL) {
- FrontendInfo hidlInfo;
- Result res = getHidlFrontendInfo(id, hidlInfo);
- if (res != Result::SUCCESS) {
- return NULL;
- }
- sp<FrontendClient> frontendClient = new FrontendClient(
- NULL, (int)hidlInfo.type);
- frontendClient->setHidlFrontend(hidlFrontend);
- frontendClient->setId(id);
- return frontendClient;
- }
- }
-
- return NULL;
+ return nullptr;
}
-shared_ptr<FrontendInfo> TunerClient::getFrontendInfo(int id) {
- if (mTunerService != NULL) {
- TunerFrontendInfo aidlFrontendInfo;
+shared_ptr<FrontendInfo> TunerClient::getFrontendInfo(int32_t id) {
+ if (mTunerService != nullptr) {
+ FrontendInfo aidlFrontendInfo;
Status s = mTunerService->getFrontendInfo(id, &aidlFrontendInfo);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return NULL;
+ if (!s.isOk()) {
+ return nullptr;
}
- return make_shared<FrontendInfo>(frontendInfoAidlToHidl(aidlFrontendInfo));
+ return make_shared<FrontendInfo>(aidlFrontendInfo);
}
- if (mTuner != NULL) {
- FrontendInfo hidlInfo;
- Result res = getHidlFrontendInfo(id, hidlInfo);
- if (res != Result::SUCCESS) {
- return NULL;
- }
- return make_shared<FrontendInfo>(hidlInfo);
- }
-
- return NULL;
+ return nullptr;
}
-shared_ptr<FrontendDtmbCapabilities> TunerClient::getFrontendDtmbCapabilities(int id) {
- if (mTunerService != NULL) {
- TunerFrontendDtmbCapabilities dtmbCaps;
- Status s = mTunerService->getFrontendDtmbCapabilities(id, &dtmbCaps);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return NULL;
- }
- FrontendDtmbCapabilities hidlCaps{
- .transmissionModeCap = static_cast<uint32_t>(dtmbCaps.transmissionModeCap),
- .bandwidthCap = static_cast<uint32_t>(dtmbCaps.bandwidthCap),
- .modulationCap = static_cast<uint32_t>(dtmbCaps.modulationCap),
- .codeRateCap = static_cast<uint32_t>(dtmbCaps.codeRateCap),
- .guardIntervalCap = static_cast<uint32_t>(dtmbCaps.guardIntervalCap),
- .interleaveModeCap = static_cast<uint32_t>(dtmbCaps.interleaveModeCap),
- };
- return make_shared<FrontendDtmbCapabilities>(hidlCaps);
- }
-
- if (mTuner_1_1 != NULL) {
- Result result;
- FrontendDtmbCapabilities dtmbCaps;
- mTuner_1_1->getFrontendDtmbCapabilities(id,
- [&](Result r, const FrontendDtmbCapabilities& caps) {
- dtmbCaps = caps;
- result = r;
- });
- if (result == Result::SUCCESS) {
- return make_shared<FrontendDtmbCapabilities>(dtmbCaps);
- }
- }
-
- return NULL;
-}
-
-sp<DemuxClient> TunerClient::openDemux(int demuxHandle) {
- if (mTunerService != NULL) {
+sp<DemuxClient> TunerClient::openDemux(int32_t demuxHandle) {
+ if (mTunerService != nullptr) {
shared_ptr<ITunerDemux> tunerDemux;
Status s = mTunerService->openDemux(demuxHandle, &tunerDemux);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return NULL;
+ if (!s.isOk()) {
+ return nullptr;
}
return new DemuxClient(tunerDemux);
}
- if (mTuner != NULL) {
- sp<DemuxClient> demuxClient = new DemuxClient(NULL);
- int demuxId;
- sp<IDemux> hidlDemux = openHidlDemux(demuxId);
- if (hidlDemux != NULL) {
- demuxClient->setHidlDemux(hidlDemux);
- demuxClient->setId(demuxId);
- return demuxClient;
- }
- }
-
- return NULL;
+ return nullptr;
}
shared_ptr<DemuxCapabilities> TunerClient::getDemuxCaps() {
- if (mTunerService != NULL) {
- TunerDemuxCapabilities aidlCaps;
+ if (mTunerService != nullptr) {
+ DemuxCapabilities aidlCaps;
Status s = mTunerService->getDemuxCaps(&aidlCaps);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return NULL;
+ if (!s.isOk()) {
+ return nullptr;
}
- return make_shared<DemuxCapabilities>(getHidlDemuxCaps(aidlCaps));
+ return make_shared<DemuxCapabilities>(aidlCaps);
}
- if (mTuner != NULL) {
- Result res;
- DemuxCapabilities caps;
- mTuner->getDemuxCaps([&](Result r, const DemuxCapabilities& demuxCaps) {
- caps = demuxCaps;
- res = r;
- });
- if (res == Result::SUCCESS) {
- return make_shared<DemuxCapabilities>(caps);
- }
- }
-
- return NULL;
+ return nullptr;
}
-sp<DescramblerClient> TunerClient::openDescrambler(int descramblerHandle) {
- if (mTunerService != NULL) {
+sp<DescramblerClient> TunerClient::openDescrambler(int32_t descramblerHandle) {
+ if (mTunerService != nullptr) {
shared_ptr<ITunerDescrambler> tunerDescrambler;
Status s = mTunerService->openDescrambler(descramblerHandle, &tunerDescrambler);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return NULL;
+ if (!s.isOk()) {
+ return nullptr;
}
return new DescramblerClient(tunerDescrambler);
}
- if (mTuner != NULL) {
- sp<DescramblerClient> descramblerClient = new DescramblerClient(NULL);
- sp<IDescrambler> hidlDescrambler = openHidlDescrambler();
- if (hidlDescrambler != NULL) {
- descramblerClient->setHidlDescrambler(hidlDescrambler);
- return descramblerClient;
- }
- }
-
- return NULL;
+ return nullptr;
}
-sp<LnbClient> TunerClient::openLnb(int lnbHandle) {
- if (mTunerService != NULL) {
+sp<LnbClient> TunerClient::openLnb(int32_t lnbHandle) {
+ if (mTunerService != nullptr) {
shared_ptr<ITunerLnb> tunerLnb;
Status s = mTunerService->openLnb(lnbHandle, &tunerLnb);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return NULL;
+ if (!s.isOk()) {
+ return nullptr;
}
return new LnbClient(tunerLnb);
}
- if (mTuner != NULL) {
- int id = getResourceIdFromHandle(lnbHandle, LNB);
- sp<LnbClient> lnbClient = new LnbClient(NULL);
- sp<ILnb> hidlLnb = openHidlLnbById(id);
- if (hidlLnb != NULL) {
- lnbClient->setHidlLnb(hidlLnb);
- lnbClient->setId(id);
- return lnbClient;
- }
- }
-
- return NULL;
+ return nullptr;
}
sp<LnbClient> TunerClient::openLnbByName(string lnbName) {
- if (mTunerService != NULL) {
+ if (mTunerService != nullptr) {
shared_ptr<ITunerLnb> tunerLnb;
Status s = mTunerService->openLnbByName(lnbName, &tunerLnb);
- if (ClientHelper::getServiceSpecificErrorCode(s) != Result::SUCCESS) {
- return NULL;
+ if (!s.isOk()) {
+ return nullptr;
}
return new LnbClient(tunerLnb);
}
- if (mTuner != NULL) {
- sp<LnbClient> lnbClient = new LnbClient(NULL);
- LnbId id;
- sp<ILnb> hidlLnb = openHidlLnbByName(lnbName, id);
- if (hidlLnb != NULL) {
- lnbClient->setHidlLnb(hidlLnb);
- lnbClient->setId(id);
- return lnbClient;
- }
- }
-
- return NULL;
+ return nullptr;
}
-/////////////// TunerClient Helper Methods ///////////////////////
-
-void TunerClient::updateTunerResources() {
- if (mTuner == NULL) {
- return;
- }
-
- // Connect with Tuner Resource Manager.
- ::ndk::SpAIBinder binder(AServiceManager_getService("tv_tuner_resource_mgr"));
- mTunerResourceManager = ITunerResourceManager::fromBinder(binder);
-
- updateFrontendResources();
- updateLnbResources();
- // TODO: update Demux, Descrambler.
-}
-
-// TODO: remove after migration to Tuner Service is done.
-void TunerClient::updateFrontendResources() {
- vector<FrontendId> ids = getFrontendIds();
- if (ids.size() == 0) {
- return;
- }
- vector<TunerFrontendInfo> infos;
- for (int i = 0; i < ids.size(); i++) {
- shared_ptr<FrontendInfo> frontendInfo = getFrontendInfo((int)ids[i]);
- if (frontendInfo == NULL) {
- continue;
- }
- TunerFrontendInfo tunerFrontendInfo{
- .handle = getResourceHandleFromId((int)ids[i], FRONTEND),
- .type = static_cast<int>(frontendInfo->type),
- .exclusiveGroupId = static_cast<int>(frontendInfo->exclusiveGroupId),
- };
- infos.push_back(tunerFrontendInfo);
- }
- mTunerResourceManager->setFrontendInfoList(infos);
-}
-
-void TunerClient::updateLnbResources() {
- vector<int> handles = getLnbHandles();
- if (handles.size() == 0) {
- return;
- }
- mTunerResourceManager->setLnbInfoList(handles);
-}
-
-sp<ITuner> TunerClient::getHidlTuner() {
- if (mTuner == NULL) {
- mTunerVersion = TUNER_HAL_VERSION_UNKNOWN;
- mTuner_1_1 = ::android::hardware::tv::tuner::V1_1::ITuner::getService();
-
- if (mTuner_1_1 == NULL) {
- ALOGW("Failed to get tuner 1.1 service.");
- mTuner = ITuner::getService();
- if (mTuner == NULL) {
- ALOGW("Failed to get tuner 1.0 service.");
- } else {
- mTunerVersion = TUNER_HAL_VERSION_1_0;
- }
- } else {
- mTuner = static_cast<sp<ITuner>>(mTuner_1_1);
- mTunerVersion = TUNER_HAL_VERSION_1_1;
- }
- }
- return mTuner;
-}
-
-sp<IFrontend> TunerClient::openHidlFrontendById(int id) {
- sp<IFrontend> fe;
- Result res;
- mTuner->openFrontendById(id, [&](Result r, const sp<IFrontend>& frontend) {
- fe = frontend;
- res = r;
- });
- if (res != Result::SUCCESS || fe == nullptr) {
- ALOGE("Failed to open frontend");
- return NULL;
- }
- return fe;
-}
-
-Result TunerClient::getHidlFrontendInfo(int id, FrontendInfo& feInfo) {
- Result res;
- mTuner->getFrontendInfo(id, [&](Result r, const FrontendInfo& info) {
- feInfo = info;
- res = r;
- });
- return res;
-}
-
-sp<IDemux> TunerClient::openHidlDemux(int& demuxId) {
- sp<IDemux> demux;
- Result res;
-
- mTuner->openDemux([&](Result result, uint32_t id, const sp<IDemux>& demuxSp) {
- demux = demuxSp;
- demuxId = id;
- res = result;
- });
- if (res != Result::SUCCESS || demux == nullptr) {
- ALOGE("Failed to open demux");
- return NULL;
- }
- return demux;
-}
-
-sp<ILnb> TunerClient::openHidlLnbById(int id) {
- sp<ILnb> lnb;
- Result res;
-
- mTuner->openLnbById(id, [&](Result r, const sp<ILnb>& lnbSp) {
- res = r;
- lnb = lnbSp;
- });
- if (res != Result::SUCCESS || lnb == nullptr) {
- ALOGE("Failed to open lnb by id");
- return NULL;
- }
- return lnb;
-}
-
-sp<ILnb> TunerClient::openHidlLnbByName(string name, LnbId& lnbId) {
- sp<ILnb> lnb;
- Result res;
-
- mTuner->openLnbByName(name, [&](Result r, LnbId id, const sp<ILnb>& lnbSp) {
- res = r;
- lnb = lnbSp;
- lnbId = id;
- });
- if (res != Result::SUCCESS || lnb == nullptr) {
- ALOGE("Failed to open lnb by name");
- return NULL;
- }
- return lnb;
-}
-
-// TODO: remove after migration to Tuner Service is done.
-vector<int> TunerClient::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) {
- ALOGW("Lnb isn't available");
- } else {
- for (int i = 0; i < lnbIds.size(); i++) {
- lnbHandles.push_back(getResourceHandleFromId((int)lnbIds[i], LNB));
- }
- }
- }
-
- return lnbHandles;
-}
-
-sp<IDescrambler> TunerClient::openHidlDescrambler() {
- sp<IDescrambler> descrambler;
- Result res;
-
- mTuner->openDescrambler([&](Result r, const sp<IDescrambler>& descramblerSp) {
- res = r;
- descrambler = descramblerSp;
- });
-
- if (res != Result::SUCCESS || descrambler == NULL) {
- return NULL;
- }
-
- return descrambler;
-}
-
-DemuxCapabilities TunerClient::getHidlDemuxCaps(TunerDemuxCapabilities& aidlCaps) {
- DemuxCapabilities caps{
- .numDemux = (uint32_t)aidlCaps.numDemux,
- .numRecord = (uint32_t)aidlCaps.numRecord,
- .numPlayback = (uint32_t)aidlCaps.numPlayback,
- .numTsFilter = (uint32_t)aidlCaps.numTsFilter,
- .numSectionFilter = (uint32_t)aidlCaps.numSectionFilter,
- .numAudioFilter = (uint32_t)aidlCaps.numAudioFilter,
- .numVideoFilter = (uint32_t)aidlCaps.numVideoFilter,
- .numPesFilter = (uint32_t)aidlCaps.numPesFilter,
- .numPcrFilter = (uint32_t)aidlCaps.numPcrFilter,
- .numBytesInSectionFilter = (uint32_t)aidlCaps.numBytesInSectionFilter,
- .filterCaps = (uint32_t)aidlCaps.filterCaps,
- .bTimeFilter = aidlCaps.bTimeFilter,
- };
- caps.linkCaps.resize(aidlCaps.linkCaps.size());
- copy(aidlCaps.linkCaps.begin(), aidlCaps.linkCaps.end(), caps.linkCaps.begin());
- return caps;
-}
-
-FrontendInfo TunerClient::frontendInfoAidlToHidl(TunerFrontendInfo aidlFrontendInfo) {
- FrontendInfo hidlFrontendInfo {
- .type = static_cast<FrontendType>(aidlFrontendInfo.type),
- .minFrequency = static_cast<uint32_t>(aidlFrontendInfo.minFrequency),
- .maxFrequency = static_cast<uint32_t>(aidlFrontendInfo.maxFrequency),
- .minSymbolRate = static_cast<uint32_t>(aidlFrontendInfo.minSymbolRate),
- .maxSymbolRate = static_cast<uint32_t>(aidlFrontendInfo.maxSymbolRate),
- .acquireRange = static_cast<uint32_t>(aidlFrontendInfo.acquireRange),
- .exclusiveGroupId = static_cast<uint32_t>(aidlFrontendInfo.exclusiveGroupId),
- };
-
- int size = aidlFrontendInfo.statusCaps.size();
- hidlFrontendInfo.statusCaps.resize(size);
- for (int i = 0; i < size; i++) {
- hidlFrontendInfo.statusCaps[i] =
- static_cast<FrontendStatusType>(aidlFrontendInfo.statusCaps[i]);
- }
-
- switch (aidlFrontendInfo.caps.getTag()) {
- case TunerFrontendCapabilities::analogCaps: {
- auto analog = aidlFrontendInfo.caps.get<TunerFrontendCapabilities::analogCaps>();
- hidlFrontendInfo.frontendCaps.analogCaps({
- .typeCap = static_cast<uint32_t>(analog.typeCap),
- .sifStandardCap = static_cast<uint32_t>(analog.sifStandardCap),
- });
- break;
- }
- case TunerFrontendCapabilities::atscCaps: {
- auto atsc = aidlFrontendInfo.caps.get<TunerFrontendCapabilities::atscCaps>();
- hidlFrontendInfo.frontendCaps.atscCaps({
- .modulationCap = static_cast<uint32_t>(atsc.modulationCap),
- });
- break;
- }
- case TunerFrontendCapabilities::atsc3Caps: {
- auto atsc3 = aidlFrontendInfo.caps.get<TunerFrontendCapabilities::atsc3Caps>();
- hidlFrontendInfo.frontendCaps.atsc3Caps({
- .bandwidthCap = static_cast<uint32_t>(atsc3.bandwidthCap),
- .modulationCap = static_cast<uint32_t>(atsc3.modulationCap),
- .timeInterleaveModeCap = static_cast<uint32_t>(atsc3.timeInterleaveModeCap),
- .codeRateCap = static_cast<uint32_t>(atsc3.codeRateCap),
- .fecCap = static_cast<uint32_t>(atsc3.fecCap),
- .demodOutputFormatCap = static_cast<uint8_t>(atsc3.demodOutputFormatCap),
- });
- break;
- }
- case TunerFrontendCapabilities::cableCaps: {
- auto cable = aidlFrontendInfo.caps.get<TunerFrontendCapabilities::cableCaps>();
- hidlFrontendInfo.frontendCaps.dvbcCaps({
- .modulationCap = static_cast<uint32_t>(cable.modulationCap),
- .fecCap = static_cast<uint64_t>(cable.codeRateCap),
- .annexCap = static_cast<uint8_t>(cable.annexCap),
- });
- break;
- }
- case TunerFrontendCapabilities::dvbsCaps: {
- auto dvbs = aidlFrontendInfo.caps.get<TunerFrontendCapabilities::dvbsCaps>();
- hidlFrontendInfo.frontendCaps.dvbsCaps({
- .modulationCap = static_cast<int32_t>(dvbs.modulationCap),
- .innerfecCap = static_cast<uint64_t>(dvbs.codeRateCap),
- .standard = static_cast<uint8_t>(dvbs.standard),
- });
- break;
- }
- case TunerFrontendCapabilities::dvbtCaps: {
- auto dvbt = aidlFrontendInfo.caps.get<TunerFrontendCapabilities::dvbtCaps>();
- hidlFrontendInfo.frontendCaps.dvbtCaps({
- .transmissionModeCap = static_cast<uint32_t>(dvbt.transmissionModeCap),
- .bandwidthCap = static_cast<uint32_t>(dvbt.bandwidthCap),
- .constellationCap = static_cast<uint32_t>(dvbt.constellationCap),
- .coderateCap = static_cast<uint32_t>(dvbt.codeRateCap),
- .hierarchyCap = static_cast<uint32_t>(dvbt.hierarchyCap),
- .guardIntervalCap = static_cast<uint32_t>(dvbt.guardIntervalCap),
- .isT2Supported = dvbt.isT2Supported,
- .isMisoSupported = dvbt.isMisoSupported,
- });
- break;
- }
- case TunerFrontendCapabilities::isdbsCaps: {
- auto isdbs = aidlFrontendInfo.caps.get<TunerFrontendCapabilities::isdbsCaps>();
- hidlFrontendInfo.frontendCaps.isdbsCaps({
- .modulationCap = static_cast<uint32_t>(isdbs.modulationCap),
- .coderateCap = static_cast<uint32_t>(isdbs.codeRateCap),
- });
- break;
- }
- case TunerFrontendCapabilities::isdbs3Caps: {
- auto isdbs3 = aidlFrontendInfo.caps.get<TunerFrontendCapabilities::isdbs3Caps>();
- hidlFrontendInfo.frontendCaps.isdbs3Caps({
- .modulationCap = static_cast<uint32_t>(isdbs3.modulationCap),
- .coderateCap = static_cast<uint32_t>(isdbs3.codeRateCap),
- });
- break;
- }
- case TunerFrontendCapabilities::isdbtCaps: {
- auto isdbt = aidlFrontendInfo.caps.get<TunerFrontendCapabilities::isdbtCaps>();
- hidlFrontendInfo.frontendCaps.isdbtCaps({
- .modeCap = static_cast<uint32_t>(isdbt.modeCap),
- .bandwidthCap = static_cast<uint32_t>(isdbt.bandwidthCap),
- .modulationCap = static_cast<uint32_t>(isdbt.modulationCap),
- .coderateCap = static_cast<uint32_t>(isdbt.codeRateCap),
- .guardIntervalCap = static_cast<uint32_t>(isdbt.guardIntervalCap),
- });
- break;
- }
- }
- return hidlFrontendInfo;
-}
-
-// TODO: remove after migration to Tuner Service is done.
-int TunerClient::getResourceIdFromHandle(int handle, int /*resourceType*/) {
- return (handle & 0x00ff0000) >> 16;
-}
-
-// TODO: remove after migration to Tuner Service is done.
-int TunerClient::getResourceHandleFromId(int id, int resourceType) {
- return (resourceType & 0x000000ff) << 24
- | (id << 16)
- | (mResourceRequestCount++ & 0xffff);
-}
} // namespace android
diff --git a/media/jni/tuner/TunerClient.h b/media/jni/tuner/TunerClient.h
index 9671cf7..641f106 100644
--- a/media/jni/tuner/TunerClient.h
+++ b/media/jni/tuner/TunerClient.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,12 +17,8 @@
#ifndef _ANDROID_MEDIA_TV_TUNER_CLIENT_H_
#define _ANDROID_MEDIA_TV_TUNER_CLIENT_H_
-#include <aidl/android/media/tv/tunerresourcemanager/ITunerResourceManager.h>
#include <aidl/android/media/tv/tuner/ITunerService.h>
-#include <aidl/android/media/tv/tuner/TunerFrontendInfo.h>
#include <android/binder_parcel_utils.h>
-#include <android/hardware/tv/tuner/1.1/ITuner.h>
-#include <android/hardware/tv/tuner/1.1/types.h>
#include "DemuxClient.h"
#include "ClientHelper.h"
@@ -32,32 +28,19 @@
using Status = ::ndk::ScopedAStatus;
-using ::aidl::android::media::tv::tuner::TunerDemuxCapabilities;
+using ::aidl::android::hardware::tv::tuner::DemuxCapabilities;
+using ::aidl::android::hardware::tv::tuner::FrontendInfo;
+using ::aidl::android::hardware::tv::tuner::Result;
using ::aidl::android::media::tv::tuner::ITunerService;
-using ::aidl::android::media::tv::tuner::TunerFrontendInfo;
-using ::aidl::android::media::tv::tunerresourcemanager::ITunerResourceManager;
-
-using ::android::hardware::tv::tuner::V1_0::DemuxCapabilities;
-using ::android::hardware::tv::tuner::V1_0::FrontendId;
-using ::android::hardware::tv::tuner::V1_0::ITuner;
-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 namespace std;
namespace android {
-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;
-
-typedef enum {
- FRONTEND,
- LNB,
- DEMUX,
- DESCRAMBLER,
-} TunerResourceType;
+const static int32_t TUNER_HAL_VERSION_UNKNOWN = 0;
+const static int32_t TUNER_HAL_VERSION_1_0 = 1 << 16;
+const static int32_t TUNER_HAL_VERSION_1_1 = (1 << 16) | 1;
+const static int32_t TUNER_HAL_VERSION_2_0 = 2 << 16;
struct TunerClient : public RefBase {
@@ -70,7 +53,7 @@
*
* @return a list of the available frontend ids
*/
- vector<FrontendId> getFrontendIds();
+ vector<int32_t> getFrontendIds();
/**
* Open a new interface of FrontendClient given a frontendHandle.
@@ -78,7 +61,7 @@
* @param frontendHandle the handle of the frontend granted by TRM.
* @return a newly created FrontendClient interface.
*/
- sp<FrontendClient> openFrontend(int frontendHandle);
+ sp<FrontendClient> openFrontend(int32_t frontendHandle);
/**
* Retrieve the granted frontend's information.
@@ -86,15 +69,7 @@
* @param id the id of the frontend granted by TRM.
* @return the information for the frontend.
*/
- shared_ptr<FrontendInfo> getFrontendInfo(int id);
-
- /**
- * Retrieve the DTMB frontend's capabilities.
- *
- * @param id the id of the DTMB frontend.
- * @return the capabilities of the frontend.
- */
- shared_ptr<FrontendDtmbCapabilities> getFrontendDtmbCapabilities(int id);
+ shared_ptr<FrontendInfo> getFrontendInfo(int32_t id);
/**
* Open a new interface of DemuxClient given a demuxHandle.
@@ -102,7 +77,7 @@
* @param demuxHandle the handle of the demux granted by TRM.
* @return a newly created DemuxClient interface.
*/
- sp<DemuxClient> openDemux(int demuxHandle);
+ sp<DemuxClient> openDemux(int32_t demuxHandle);
/**
* Retrieve the Demux capabilities.
@@ -117,7 +92,7 @@
* @param descramblerHandle the handle of the descrambler granted by TRM.
* @return a newly created DescramblerClient interface.
*/
- sp<DescramblerClient> openDescrambler(int descramblerHandle);
+ sp<DescramblerClient> openDescrambler(int32_t descramblerHandle);
/**
* Open a new interface of LnbClient given an lnbHandle.
@@ -125,7 +100,7 @@
* @param lnbHandle the handle of the LNB granted by TRM.
* @return a newly created LnbClient interface.
*/
- sp<LnbClient> openLnb(int lnbHandle);
+ sp<LnbClient> openLnb(int32_t lnbHandle);
/**
* Open a new interface of LnbClient given a LNB name.
@@ -139,54 +114,18 @@
* Get the current Tuner HAL version. The high 16 bits are the major version number
* while the low 16 bits are the minor version. Default value is unknown version 0.
*/
- int getHalTunerVersion() { return mTunerVersion; }
+ int32_t getHalTunerVersion() { return mTunerVersion; }
private:
- sp<ITuner> getHidlTuner();
- sp<IFrontend> openHidlFrontendById(int id);
- sp<IDemux> openHidlDemux(int& demuxId);
- Result getHidlFrontendInfo(int id, FrontendInfo& info);
- sp<ILnb> openHidlLnbById(int id);
- sp<ILnb> openHidlLnbByName(string name, LnbId& lnbId);
- sp<IDescrambler> openHidlDescrambler();
- vector<int> getLnbHandles();
- DemuxCapabilities getHidlDemuxCaps(TunerDemuxCapabilities& aidlCaps);
- FrontendInfo frontendInfoAidlToHidl(TunerFrontendInfo aidlFrontendInfo);
- void updateTunerResources();
- void updateFrontendResources();
- void updateLnbResources();
-
- int getResourceIdFromHandle(int handle, int resourceType);
-
- int getResourceHandleFromId(int id, int resourceType);
-
/**
* An AIDL Tuner Service Singleton assigned at the first time the Tuner Client
* connects with the Tuner Service. Default null when the service does not exist.
*/
static shared_ptr<ITunerService> mTunerService;
- /**
- * A Tuner 1.0 HAL interface that is ready before connecting to the TunerService
- * This is a temprary connection before the Tuner Framework fully migrates to the TunerService.
- * Default null.
- */
- static sp<ITuner> mTuner;
-
- /**
- * A Tuner 1.1 HAL interface that is ready before connecting to the TunerService
- * This is a temprary connection before the Tuner Framework fully migrates to the TunerService.
- * Default null.
- */
- static sp<::android::hardware::tv::tuner::V1_1::ITuner> mTuner_1_1;
-
// An integer that carries the Tuner version. The high 16 bits are the major version number
// while the low 16 bits are the minor version. Default value is unknown version 0.
- static int mTunerVersion;
-
- shared_ptr<ITunerResourceManager> mTunerResourceManager;
-
- int mResourceRequestCount = 0;
+ static int32_t mTunerVersion;
};
} // namespace android