Merge "Fully remove Frontend HAL from Tuner JNI and use Frontend Client instead"
This commit is contained in:
@@ -862,8 +862,7 @@ sp<ITimeFilter> TimeFilter::getITimeFilter() {
|
||||
|
||||
/////////////// FrontendClientCallbackImpl ///////////////////////
|
||||
|
||||
FrontendClientCallbackImpl::FrontendClientCallbackImpl(
|
||||
jweak tunerObj, FrontendId id) : mObject(tunerObj), mId(id) {}
|
||||
FrontendClientCallbackImpl::FrontendClientCallbackImpl(jweak tunerObj) : mObject(tunerObj) {}
|
||||
|
||||
void FrontendClientCallbackImpl::onEvent(FrontendEventType frontendEventType) {
|
||||
ALOGD("FrontendClientCallbackImpl::onEvent, type=%d", frontendEventType);
|
||||
@@ -1126,8 +1125,8 @@ JTuner::JTuner(JNIEnv *env, jobject thiz)
|
||||
}
|
||||
|
||||
JTuner::~JTuner() {
|
||||
if (mFe != NULL) {
|
||||
mFe->close();
|
||||
if (mFeClient != NULL) {
|
||||
mFeClient->close();
|
||||
}
|
||||
if (mDemux != NULL) {
|
||||
mDemux->close();
|
||||
@@ -1137,7 +1136,6 @@ JTuner::~JTuner() {
|
||||
env->DeleteWeakGlobalRef(mObject);
|
||||
env->DeleteGlobalRef(mClass);
|
||||
mTuner = NULL;
|
||||
mFe = NULL;
|
||||
mDemux = NULL;
|
||||
mTunerClient = NULL;
|
||||
mFeClient = NULL;
|
||||
@@ -1192,27 +1190,6 @@ jobject JTuner::getFrontendIds() {
|
||||
}
|
||||
|
||||
jobject JTuner::openFrontendByHandle(int feHandle) {
|
||||
sp<IFrontend> fe;
|
||||
Result res;
|
||||
uint32_t id = getResourceIdFromHandle(feHandle);
|
||||
|
||||
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;
|
||||
}
|
||||
mFe = fe;
|
||||
mFe_1_1 = ::android::hardware::tv::tuner::V1_1::IFrontend::castFrom(mFe);
|
||||
mFeId = id;
|
||||
if (mDemux != NULL) {
|
||||
mDemux->setFrontendDataSource(mFeId);
|
||||
}
|
||||
|
||||
jint jId = (jint) id;
|
||||
|
||||
// TODO: Handle reopening frontend with different handle
|
||||
sp<FrontendClient> feClient = mTunerClient->openFrontend(feHandle);
|
||||
if (feClient == NULL) {
|
||||
@@ -1222,11 +1199,10 @@ jobject JTuner::openFrontendByHandle(int feHandle) {
|
||||
mFeClient = feClient;
|
||||
|
||||
mFeId = mFeClient->getId();
|
||||
jId = (jint) id;
|
||||
if (mDemuxClient != NULL) {
|
||||
mDemuxClient->setFrontendDataSource(mFeClient);
|
||||
}
|
||||
sp<FrontendClientCallbackImpl> feClientCb = new FrontendClientCallbackImpl(mObject, id);
|
||||
sp<FrontendClientCallbackImpl> feClientCb = new FrontendClientCallbackImpl(mObject);
|
||||
mFeClient->setCallback(feClientCb);
|
||||
|
||||
JNIEnv *env = AndroidRuntime::getJNIEnv();
|
||||
@@ -1235,7 +1211,7 @@ jobject JTuner::openFrontendByHandle(int feHandle) {
|
||||
env->FindClass("android/media/tv/tuner/Tuner$Frontend"),
|
||||
gFields.frontendInitID,
|
||||
mObject,
|
||||
(jint) jId);
|
||||
(jint) mFeId);
|
||||
}
|
||||
|
||||
jobject JTuner::getAnalogFrontendCaps(JNIEnv *env, FrontendInfo::FrontendCapabilities& caps) {
|
||||
@@ -1539,29 +1515,20 @@ int JTuner::stopTune() {
|
||||
|
||||
int JTuner::scan(const FrontendSettings& settings, FrontendScanType scanType,
|
||||
const FrontendSettingsExt1_1& settingsExt1_1) {
|
||||
if (mFe == NULL) {
|
||||
ALOGE("frontend is not initialized");
|
||||
if (mFeClient == NULL) {
|
||||
ALOGE("frontend client is not initialized");
|
||||
return (int)Result::INVALID_STATE;
|
||||
}
|
||||
Result result;
|
||||
sp<::android::hardware::tv::tuner::V1_1::IFrontend> fe_1_1 =
|
||||
::android::hardware::tv::tuner::V1_1::IFrontend::castFrom(mFe);
|
||||
if (fe_1_1 == NULL) {
|
||||
ALOGD("1.1 frontend is not found. Using 1.0 instead.");
|
||||
result = mFe->scan(settings, scanType);
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
result = fe_1_1->scan_1_1(settings, scanType, settingsExt1_1);
|
||||
Result result = mFeClient->scan(settings, scanType, settingsExt1_1);
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
int JTuner::stopScan() {
|
||||
if (mFe == NULL) {
|
||||
ALOGE("frontend is not initialized");
|
||||
if (mFeClient == NULL) {
|
||||
ALOGE("frontend client is not initialized");
|
||||
return (int)Result::INVALID_STATE;
|
||||
}
|
||||
Result result = mFe->stopScan();
|
||||
Result result = mFeClient->stopScan();
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
@@ -1579,11 +1546,11 @@ int JTuner::setLnb(sp<LnbClient> lnbClient) {
|
||||
}
|
||||
|
||||
int JTuner::setLna(bool enable) {
|
||||
if (mFe == NULL) {
|
||||
ALOGE("frontend is not initialized");
|
||||
if (mFeClient == NULL) {
|
||||
ALOGE("frontend client is not initialized");
|
||||
return (int)Result::INVALID_STATE;
|
||||
}
|
||||
Result result = mFe->setLna(enable);
|
||||
Result result = mFeClient->setLna(enable);
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
@@ -1606,9 +1573,6 @@ Result JTuner::openDemux() {
|
||||
if (res == Result::SUCCESS) {
|
||||
mDemux = demuxSp;
|
||||
mDemuxId = id;
|
||||
if (mFe != NULL) {
|
||||
mDemux->setFrontendDataSource(mFeId);
|
||||
}
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
@@ -1634,12 +1598,6 @@ Result JTuner::openDemux() {
|
||||
|
||||
jint JTuner::close() {
|
||||
Result res = Result::SUCCESS;
|
||||
if (mFe != NULL) {
|
||||
res = mFe->close();
|
||||
if (res != Result::SUCCESS) {
|
||||
return (jint) res;
|
||||
}
|
||||
}
|
||||
if (mDemux != NULL) {
|
||||
res = mDemux->close();
|
||||
if (res != Result::SUCCESS) {
|
||||
@@ -1705,24 +1663,11 @@ int JTuner::connectCiCam(jint id) {
|
||||
}
|
||||
|
||||
int JTuner::linkCiCam(int id) {
|
||||
if (mFe_1_1 == NULL) {
|
||||
ALOGE("frontend 1.1 is not initialized");
|
||||
if (mFeClient == NULL) {
|
||||
ALOGE("frontend client is not initialized");
|
||||
return (int)Constant::INVALID_LTS_ID;
|
||||
}
|
||||
|
||||
Result res;
|
||||
uint32_t ltsId;
|
||||
mFe_1_1->linkCiCam(static_cast<uint32_t>(id),
|
||||
[&](Result r, uint32_t id) {
|
||||
res = r;
|
||||
ltsId = id;
|
||||
});
|
||||
|
||||
if (res != Result::SUCCESS) {
|
||||
return (int)Constant::INVALID_LTS_ID;
|
||||
}
|
||||
|
||||
return (int) ltsId;
|
||||
return mFeClient->linkCiCamToFrontend(id);
|
||||
}
|
||||
|
||||
int JTuner::disconnectCiCam() {
|
||||
@@ -1738,12 +1683,12 @@ int JTuner::disconnectCiCam() {
|
||||
|
||||
|
||||
int JTuner::unlinkCiCam(int id) {
|
||||
if (mFe_1_1 == NULL) {
|
||||
ALOGE("frontend 1.1 is not initialized");
|
||||
if (mFeClient == NULL) {
|
||||
ALOGE("frontend client is not initialized");
|
||||
return (int)Result::INVALID_STATE;
|
||||
}
|
||||
|
||||
Result r = mFe_1_1->unlinkCiCam(static_cast<uint32_t>(id));
|
||||
Result r = mFeClient->unlinkCiCamToFrontend(id);
|
||||
|
||||
return (int) r;
|
||||
}
|
||||
@@ -1913,7 +1858,7 @@ jobject JTuner::getDemuxCaps() {
|
||||
}
|
||||
|
||||
jobject JTuner::getFrontendStatus(jintArray types) {
|
||||
if (mFe == NULL) {
|
||||
if (mFeClient == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
JNIEnv *env = AndroidRuntime::getJNIEnv();
|
||||
@@ -1930,38 +1875,8 @@ jobject JTuner::getFrontendStatus(jintArray types) {
|
||||
}
|
||||
}
|
||||
|
||||
Result res;
|
||||
hidl_vec<FrontendStatus> status;
|
||||
hidl_vec<FrontendStatusExt1_1> status_1_1;
|
||||
|
||||
if (v.size() > 0) {
|
||||
mFe->getStatus(v,
|
||||
[&](Result r, const hidl_vec<FrontendStatus>& s) {
|
||||
res = r;
|
||||
status = s;
|
||||
});
|
||||
if (res != Result::SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (v_1_1.size() > 0) {
|
||||
sp<::android::hardware::tv::tuner::V1_1::IFrontend> iFeSp_1_1;
|
||||
iFeSp_1_1 = ::android::hardware::tv::tuner::V1_1::IFrontend::castFrom(mFe);
|
||||
|
||||
if (iFeSp_1_1 != NULL) {
|
||||
iFeSp_1_1->getStatusExt1_1(v_1_1,
|
||||
[&](Result r, const hidl_vec<FrontendStatusExt1_1>& s) {
|
||||
res = r;
|
||||
status_1_1 = s;
|
||||
});
|
||||
if (res != Result::SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
ALOGW("getStatusExt1_1 is not supported with the current HAL implementation.");
|
||||
}
|
||||
}
|
||||
hidl_vec<FrontendStatus> status = mFeClient->getStatus(v);
|
||||
hidl_vec<FrontendStatusExt1_1> status_1_1 = mFeClient->getStatusExtended_1_1(v_1_1);
|
||||
|
||||
jclass clazz = env->FindClass("android/media/tv/tuner/frontend/FrontendStatus");
|
||||
jmethodID init = env->GetMethodID(clazz, "<init>", "()V");
|
||||
@@ -2507,15 +2422,6 @@ bool JTuner::isV1_1ExtendedStatusType(int type) {
|
||||
|
||||
jint JTuner::closeFrontend() {
|
||||
Result r = Result::SUCCESS;
|
||||
if (mFe != NULL) {
|
||||
r = mFe->close();
|
||||
}
|
||||
if (r == Result::SUCCESS) {
|
||||
mFe = NULL;
|
||||
mFe_1_1 = NULL;
|
||||
} else {
|
||||
return (jint) r;
|
||||
}
|
||||
|
||||
if (mFeClient != NULL) {
|
||||
r = mFeClient->close();
|
||||
@@ -2573,10 +2479,6 @@ static sp<DescramblerClient> getDescramblerClient(JNIEnv *env, jobject descrambl
|
||||
return (DescramblerClient *)env->GetLongField(descrambler, gFields.descramblerContext);
|
||||
}
|
||||
|
||||
static uint32_t getResourceIdFromHandle(jint handle) {
|
||||
return (handle & 0x00ff0000) >> 16;
|
||||
}
|
||||
|
||||
static DemuxPid getDemuxPid(int pidType, int pid) {
|
||||
DemuxPid demuxPid;
|
||||
if ((int)pidType == 1) {
|
||||
|
||||
@@ -178,7 +178,7 @@ private:
|
||||
};
|
||||
|
||||
struct FrontendClientCallbackImpl : public FrontendClientCallback {
|
||||
FrontendClientCallbackImpl(jweak tunerObj, FrontendId id);
|
||||
FrontendClientCallbackImpl(jweak tunerObj);
|
||||
|
||||
virtual void onEvent(FrontendEventType frontendEventType);
|
||||
virtual void onScanMessage(
|
||||
@@ -187,7 +187,6 @@ struct FrontendClientCallbackImpl : public FrontendClientCallback {
|
||||
FrontendScanMessageTypeExt1_1 type, const FrontendScanMessageExt1_1& messageExt);
|
||||
|
||||
jweak mObject;
|
||||
FrontendId mId;
|
||||
};
|
||||
|
||||
struct TimeFilter : public RefBase {
|
||||
@@ -244,10 +243,6 @@ private:
|
||||
static sp<ITuner> mTuner;
|
||||
static sp<::android::hardware::tv::tuner::V1_1::ITuner> mTuner_1_1;
|
||||
static sp<TunerClient> mTunerClient;
|
||||
// TODO: remove after migrate to client lib
|
||||
sp<IFrontend> mFe;
|
||||
// TODO: remove after migrate to client lib
|
||||
sp<::android::hardware::tv::tuner::V1_1::IFrontend> mFe_1_1;
|
||||
sp<FrontendClient> mFeClient;
|
||||
int mFeId;
|
||||
sp<LnbClient> mLnbClient;
|
||||
@@ -267,9 +262,6 @@ private:
|
||||
static jobject getDtmbFrontendCaps(JNIEnv *env, int id);
|
||||
|
||||
bool isV1_1ExtendedStatusType(jint type);
|
||||
static uint32_t getResourceIdFromHandle(jint handle) {
|
||||
return (handle & 0x00ff0000) >> 16;
|
||||
}
|
||||
};
|
||||
|
||||
class C2DataIdInfo : public C2Param {
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "FrontendClient.h"
|
||||
|
||||
using ::aidl::android::media::tv::tuner::TunerFrontendSettings;
|
||||
using ::android::hardware::tv::tuner::V1_1::Constant;
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -99,6 +100,96 @@ Result FrontendClient::stopTune() {
|
||||
return Result::INVALID_STATE;
|
||||
}
|
||||
|
||||
Result FrontendClient::scan(const FrontendSettings& settings, FrontendScanType type,
|
||||
const FrontendSettingsExt1_1& settingsExt1_1) {
|
||||
if (mTunerFrontend != NULL) {
|
||||
// TODO: parse hidl settings to aidl settings
|
||||
// TODO: aidl frontend settings to include Tuner HAL 1.1 settings
|
||||
TunerFrontendSettings settings;
|
||||
// TODO: handle error message.
|
||||
mTunerFrontend->scan(settings, (int)type);
|
||||
return Result::SUCCESS;
|
||||
}
|
||||
|
||||
Result result;
|
||||
if (mFrontend_1_1 != NULL) {
|
||||
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) {
|
||||
// TODO: handle error message.
|
||||
mTunerFrontend->stopScan();
|
||||
return Result::SUCCESS;
|
||||
}
|
||||
|
||||
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) {
|
||||
// TODO: handle error message.
|
||||
/*status = mTunerFrontend->getStatus(statusTypes);
|
||||
return status;*/
|
||||
}
|
||||
|
||||
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) {
|
||||
// TODO: handle error message.
|
||||
/*status = mTunerFrontend->getStatusExtended_1_1(statusTypes);
|
||||
return status;*/
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
Result FrontendClient::setLnb(sp<LnbClient> lnbClient) {
|
||||
if (mTunerFrontend != NULL) {
|
||||
// TODO: handle error message.
|
||||
@@ -114,6 +205,59 @@ Result FrontendClient::setLnb(sp<LnbClient> lnbClient) {
|
||||
return Result::INVALID_STATE;
|
||||
}
|
||||
|
||||
Result FrontendClient::setLna(bool bEnable) {
|
||||
if (mTunerFrontend != NULL) {
|
||||
// TODO: handle error message.
|
||||
/*mTunerFrontend->setLna(bEnable);
|
||||
return Result::SUCCESS;*/
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (mTunerFrontend != NULL) {
|
||||
// TODO: handle error message.
|
||||
/*mTunerFrontend->linkCiCamToFrontend(ciCamId, ltsId);
|
||||
return ltsId;*/
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
return ltsId;
|
||||
}
|
||||
|
||||
Result FrontendClient::unlinkCiCamToFrontend(int ciCamId) {
|
||||
if (mTunerFrontend != NULL) {
|
||||
// TODO: handle error message.
|
||||
/*mTunerFrontend->unlinkCiCamToFrontend(ciCamId);
|
||||
return Result::SUCCESS;*/
|
||||
}
|
||||
|
||||
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) {
|
||||
// TODO: handle error message.
|
||||
|
||||
@@ -38,13 +38,18 @@ 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;
|
||||
@@ -127,11 +132,50 @@ public:
|
||||
*/
|
||||
Result stopTune();
|
||||
|
||||
/**
|
||||
* Scan the frontend to use the settings given.
|
||||
*/
|
||||
Result scan(const FrontendSettings& settings, FrontendScanType frontendScanType,
|
||||
const FrontendSettingsExt1_1& settingsExt1_1);
|
||||
|
||||
/**
|
||||
* Stop the previous scanning.
|
||||
*/
|
||||
Result stopScan();
|
||||
|
||||
/**
|
||||
* Gets the statuses of the frontend.
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* Enable or Disable Low Noise Amplifier (LNA).
|
||||
*/
|
||||
Result setLna(bool bEnable);
|
||||
|
||||
/**
|
||||
* Link Frontend to the cicam with given id.
|
||||
*
|
||||
* @return lts id
|
||||
*/
|
||||
int linkCiCamToFrontend(int ciCamId);
|
||||
|
||||
/**
|
||||
* Unink Frontend to the cicam with given id.
|
||||
*/
|
||||
Result unlinkCiCamToFrontend(int ciCamId);
|
||||
|
||||
/**
|
||||
* Close Frontend.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user