Merge "Tuner JNI: demux" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0eba93a5ed
@@ -216,8 +216,8 @@ public class Tuner implements AutoCloseable {
|
|||||||
private native int nativeSetLnb(int lnbId);
|
private native int nativeSetLnb(int lnbId);
|
||||||
private native int nativeSetLna(boolean enable);
|
private native int nativeSetLna(boolean enable);
|
||||||
private native FrontendStatus nativeGetFrontendStatus(int[] statusTypes);
|
private native FrontendStatus nativeGetFrontendStatus(int[] statusTypes);
|
||||||
private native int nativeGetAvSyncHwId(Filter filter);
|
private native Integer nativeGetAvSyncHwId(Filter filter);
|
||||||
private native long nativeGetAvSyncTime(int avSyncId);
|
private native Long nativeGetAvSyncTime(int avSyncId);
|
||||||
private native int nativeConnectCiCam(int ciCamId);
|
private native int nativeConnectCiCam(int ciCamId);
|
||||||
private native int nativeDisconnectCiCam();
|
private native int nativeDisconnectCiCam();
|
||||||
private native FrontendInfo nativeGetFrontendInfo(int id);
|
private native FrontendInfo nativeGetFrontendInfo(int id);
|
||||||
@@ -463,7 +463,8 @@ public class Tuner implements AutoCloseable {
|
|||||||
@RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
|
@RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
|
||||||
public int getAvSyncHwId(@NonNull Filter filter) {
|
public int getAvSyncHwId(@NonNull Filter filter) {
|
||||||
TunerUtils.checkTunerPermission(mContext);
|
TunerUtils.checkTunerPermission(mContext);
|
||||||
return nativeGetAvSyncHwId(filter);
|
Integer id = nativeGetAvSyncHwId(filter);
|
||||||
|
return id == null ? TunerConstants.INVALID_AV_SYNC_ID : id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -478,7 +479,8 @@ public class Tuner implements AutoCloseable {
|
|||||||
@RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
|
@RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
|
||||||
public long getAvSyncTime(int avSyncHwId) {
|
public long getAvSyncTime(int avSyncHwId) {
|
||||||
TunerUtils.checkTunerPermission(mContext);
|
TunerUtils.checkTunerPermission(mContext);
|
||||||
return nativeGetAvSyncTime(avSyncHwId);
|
Long time = nativeGetAvSyncTime(avSyncHwId);
|
||||||
|
return time == null ? TunerConstants.TIMESTAMP_UNAVAILABLE : time;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -46,6 +46,19 @@ public final class TunerConstants {
|
|||||||
* Invalid AV Sync ID.
|
* Invalid AV Sync ID.
|
||||||
*/
|
*/
|
||||||
public static final int INVALID_AV_SYNC_ID = Constants.Constant.INVALID_AV_SYNC_ID;
|
public static final int INVALID_AV_SYNC_ID = Constants.Constant.INVALID_AV_SYNC_ID;
|
||||||
|
/**
|
||||||
|
* Timestamp is unavailable.
|
||||||
|
*
|
||||||
|
* <p>Returned by {@link android.media.tv.tuner.filter.TimeFilter#getSourceTime()},
|
||||||
|
* {@link android.media.tv.tuner.filter.TimeFilter#getTimeStamp()}, or
|
||||||
|
* {@link Tuner#getAvSyncTime(int)} when the requested timestamp is not available.
|
||||||
|
*
|
||||||
|
* @see android.media.tv.tuner.filter.TimeFilter#getSourceTime()
|
||||||
|
* @see android.media.tv.tuner.filter.TimeFilter#getTimeStamp()
|
||||||
|
* @see Tuner#getAvSyncTime(int)
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final long TIMESTAMP_UNAVAILABLE = -1L;
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@IntDef(prefix = "SCAN_TYPE_", value = {SCAN_TYPE_UNDEFINED, SCAN_TYPE_AUTO, SCAN_TYPE_BLIND})
|
@IntDef(prefix = "SCAN_TYPE_", value = {SCAN_TYPE_UNDEFINED, SCAN_TYPE_AUTO, SCAN_TYPE_BLIND})
|
||||||
|
|||||||
@@ -119,7 +119,6 @@ using ::android::hardware::tv::tuner::V1_0::FrontendType;
|
|||||||
using ::android::hardware::tv::tuner::V1_0::ITuner;
|
using ::android::hardware::tv::tuner::V1_0::ITuner;
|
||||||
using ::android::hardware::tv::tuner::V1_0::PlaybackSettings;
|
using ::android::hardware::tv::tuner::V1_0::PlaybackSettings;
|
||||||
using ::android::hardware::tv::tuner::V1_0::RecordSettings;
|
using ::android::hardware::tv::tuner::V1_0::RecordSettings;
|
||||||
using ::android::hardware::tv::tuner::V1_0::Result;
|
|
||||||
|
|
||||||
struct fields_t {
|
struct fields_t {
|
||||||
jfieldID tunerContext;
|
jfieldID tunerContext;
|
||||||
@@ -845,22 +844,85 @@ int JTuner::setLna(bool enable) {
|
|||||||
return (int)result;
|
return (int)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JTuner::openDemux() {
|
Result JTuner::openDemux() {
|
||||||
if (mTuner == nullptr) {
|
if (mTuner == nullptr) {
|
||||||
return false;
|
return Result::NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
if (mDemux != nullptr) {
|
if (mDemux != nullptr) {
|
||||||
return true;
|
return Result::SUCCESS;
|
||||||
}
|
}
|
||||||
mTuner->openDemux([&](Result, uint32_t demuxId, const sp<IDemux>& demux) {
|
Result res;
|
||||||
|
mTuner->openDemux([&](Result r, uint32_t demuxId, const sp<IDemux>& demux) {
|
||||||
mDemux = demux;
|
mDemux = demux;
|
||||||
mDemuxId = demuxId;
|
mDemuxId = demuxId;
|
||||||
|
res = r;
|
||||||
ALOGD("open demux, id = %d", demuxId);
|
ALOGD("open demux, id = %d", demuxId);
|
||||||
});
|
});
|
||||||
if (mDemux == nullptr) {
|
return res;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
jobject JTuner::getAvSyncHwId(sp<Filter> filter) {
|
||||||
|
if (mDemux == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t avSyncHwId;
|
||||||
|
Result res;
|
||||||
|
sp<IFilter> iFilterSp = filter->getIFilter();
|
||||||
|
mDemux->getAvSyncHwId(iFilterSp,
|
||||||
|
[&](Result r, uint32_t id) {
|
||||||
|
res = r;
|
||||||
|
avSyncHwId = id;
|
||||||
|
});
|
||||||
|
if (res == Result::SUCCESS) {
|
||||||
|
JNIEnv *env = AndroidRuntime::getJNIEnv();
|
||||||
|
jclass integerClazz = env->FindClass("java/lang/Integer");
|
||||||
|
jmethodID intInit = env->GetMethodID(integerClazz, "<init>", "(I)V");
|
||||||
|
return env->NewObject(integerClazz, intInit, avSyncHwId);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
jobject JTuner::getAvSyncTime(jint id) {
|
||||||
|
if (mDemux == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
uint64_t time;
|
||||||
|
Result res;
|
||||||
|
mDemux->getAvSyncTime(static_cast<uint32_t>(id),
|
||||||
|
[&](Result r, uint64_t ts) {
|
||||||
|
res = r;
|
||||||
|
time = ts;
|
||||||
|
});
|
||||||
|
if (res == Result::SUCCESS) {
|
||||||
|
JNIEnv *env = AndroidRuntime::getJNIEnv();
|
||||||
|
jclass longClazz = env->FindClass("java/lang/Long");
|
||||||
|
jmethodID longInit = env->GetMethodID(longClazz, "<init>", "(J)V");
|
||||||
|
return env->NewObject(longClazz, longInit, static_cast<jlong>(time));
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int JTuner::connectCiCam(jint id) {
|
||||||
|
if (mDemux == NULL) {
|
||||||
|
Result r = openDemux();
|
||||||
|
if (r != Result::SUCCESS) {
|
||||||
|
return (int) r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Result r = mDemux->connectCiCam(static_cast<uint32_t>(id));
|
||||||
|
return (int) r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int JTuner::disconnectCiCam() {
|
||||||
|
if (mDemux == NULL) {
|
||||||
|
Result r = openDemux();
|
||||||
|
if (r != Result::SUCCESS) {
|
||||||
|
return (int) r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Result r = mDemux->disconnectCiCam();
|
||||||
|
return (int) r;
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject JTuner::openDescrambler() {
|
jobject JTuner::openDescrambler() {
|
||||||
@@ -892,7 +954,7 @@ jobject JTuner::openDescrambler() {
|
|||||||
|
|
||||||
jobject JTuner::openFilter(DemuxFilterType type, int bufferSize) {
|
jobject JTuner::openFilter(DemuxFilterType type, int bufferSize) {
|
||||||
if (mDemux == NULL) {
|
if (mDemux == NULL) {
|
||||||
if (!openDemux()) {
|
if (openDemux() != Result::SUCCESS) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -917,7 +979,6 @@ jobject JTuner::openFilter(DemuxFilterType type, int bufferSize) {
|
|||||||
env->NewObject(
|
env->NewObject(
|
||||||
env->FindClass("android/media/tv/tuner/filter/Filter"),
|
env->FindClass("android/media/tv/tuner/filter/Filter"),
|
||||||
gFields.filterInitID,
|
gFields.filterInitID,
|
||||||
mObject,
|
|
||||||
(jint) fId);
|
(jint) fId);
|
||||||
|
|
||||||
sp<Filter> filterSp = new Filter(iFilterSp, filterObj);
|
sp<Filter> filterSp = new Filter(iFilterSp, filterObj);
|
||||||
@@ -931,7 +992,7 @@ jobject JTuner::openFilter(DemuxFilterType type, int bufferSize) {
|
|||||||
|
|
||||||
jobject JTuner::openTimeFilter() {
|
jobject JTuner::openTimeFilter() {
|
||||||
if (mDemux == NULL) {
|
if (mDemux == NULL) {
|
||||||
if (!openDemux()) {
|
if (openDemux() != Result::SUCCESS) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -962,7 +1023,7 @@ jobject JTuner::openTimeFilter() {
|
|||||||
jobject JTuner::openDvr(DvrType type, int bufferSize) {
|
jobject JTuner::openDvr(DvrType type, int bufferSize) {
|
||||||
ALOGD("JTuner::openDvr");
|
ALOGD("JTuner::openDvr");
|
||||||
if (mDemux == NULL) {
|
if (mDemux == NULL) {
|
||||||
if (!openDemux()) {
|
if (openDemux() != Result::SUCCESS) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1608,20 +1669,30 @@ static jobject android_media_tv_Tuner_get_frontend_status(JNIEnv, jobject, jintA
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int android_media_tv_Tuner_gat_av_sync_hw_id(JNIEnv*, jobject, jobject) {
|
static jobject android_media_tv_Tuner_get_av_sync_hw_id(
|
||||||
return 0;
|
JNIEnv *env, jobject thiz, jobject filter) {
|
||||||
|
sp<Filter> filterSp = getFilter(env, filter);
|
||||||
|
if (filterSp == NULL) {
|
||||||
|
ALOGD("Failed to get sync ID. Filter not found");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
sp<JTuner> tuner = getTuner(env, thiz);
|
||||||
|
return tuner->getAvSyncHwId(filterSp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jlong android_media_tv_Tuner_gat_av_sync_time(JNIEnv*, jobject, jint) {
|
static jobject android_media_tv_Tuner_get_av_sync_time(JNIEnv *env, jobject thiz, jint id) {
|
||||||
return 0;
|
sp<JTuner> tuner = getTuner(env, thiz);
|
||||||
|
return tuner->getAvSyncTime(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int android_media_tv_Tuner_connect_cicam(JNIEnv*, jobject, jint) {
|
static int android_media_tv_Tuner_connect_cicam(JNIEnv *env, jobject thiz, jint id) {
|
||||||
return 0;
|
sp<JTuner> tuner = getTuner(env, thiz);
|
||||||
|
return tuner->connectCiCam(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int android_media_tv_Tuner_disconnect_cicam(JNIEnv*, jobject) {
|
static int android_media_tv_Tuner_disconnect_cicam(JNIEnv *env, jobject thiz) {
|
||||||
return 0;
|
sp<JTuner> tuner = getTuner(env, thiz);
|
||||||
|
return tuner->disconnectCiCam();
|
||||||
}
|
}
|
||||||
|
|
||||||
static jobject android_media_tv_Tuner_get_frontend_info(JNIEnv *env, jobject thiz, jint id) {
|
static jobject android_media_tv_Tuner_get_frontend_info(JNIEnv *env, jobject thiz, jint id) {
|
||||||
@@ -2500,9 +2571,10 @@ static const JNINativeMethod gTunerMethods[] = {
|
|||||||
{ "nativeSetLna", "(Z)I", (void *)android_media_tv_Tuner_set_lna },
|
{ "nativeSetLna", "(Z)I", (void *)android_media_tv_Tuner_set_lna },
|
||||||
{ "nativeGetFrontendStatus", "([I)Landroid/media/tv/tuner/frontend/FrontendStatus;",
|
{ "nativeGetFrontendStatus", "([I)Landroid/media/tv/tuner/frontend/FrontendStatus;",
|
||||||
(void *)android_media_tv_Tuner_get_frontend_status },
|
(void *)android_media_tv_Tuner_get_frontend_status },
|
||||||
{ "nativeGetAvSyncHwId", "(Landroid/media/tv/tuner/filter/Filter;)I",
|
{ "nativeGetAvSyncHwId", "(Landroid/media/tv/tuner/filter/Filter;)Ljava/lang/Integer;",
|
||||||
(void *)android_media_tv_Tuner_gat_av_sync_hw_id },
|
(void *)android_media_tv_Tuner_get_av_sync_hw_id },
|
||||||
{ "nativeGetAvSyncTime", "(I)J", (void *)android_media_tv_Tuner_gat_av_sync_time },
|
{ "nativeGetAvSyncTime", "(I)Ljava/lang/Long;",
|
||||||
|
(void *)android_media_tv_Tuner_get_av_sync_time },
|
||||||
{ "nativeConnectCiCam", "(I)I", (void *)android_media_tv_Tuner_connect_cicam },
|
{ "nativeConnectCiCam", "(I)I", (void *)android_media_tv_Tuner_connect_cicam },
|
||||||
{ "nativeDisconnectCiCam", "()I", (void *)android_media_tv_Tuner_disconnect_cicam },
|
{ "nativeDisconnectCiCam", "()I", (void *)android_media_tv_Tuner_disconnect_cicam },
|
||||||
{ "nativeGetFrontendInfo", "(I)Landroid/media/tv/tuner/frontend/FrontendInfo;",
|
{ "nativeGetFrontendInfo", "(I)Landroid/media/tv/tuner/frontend/FrontendInfo;",
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ using ::android::hardware::tv::tuner::V1_0::LnbEventType;
|
|||||||
using ::android::hardware::tv::tuner::V1_0::LnbId;
|
using ::android::hardware::tv::tuner::V1_0::LnbId;
|
||||||
using ::android::hardware::tv::tuner::V1_0::PlaybackStatus;
|
using ::android::hardware::tv::tuner::V1_0::PlaybackStatus;
|
||||||
using ::android::hardware::tv::tuner::V1_0::RecordStatus;
|
using ::android::hardware::tv::tuner::V1_0::RecordStatus;
|
||||||
|
using ::android::hardware::tv::tuner::V1_0::Result;
|
||||||
|
|
||||||
using FilterMQ = MessageQueue<uint8_t, kSynchronizedReadWrite>;
|
using FilterMQ = MessageQueue<uint8_t, kSynchronizedReadWrite>;
|
||||||
using DvrMQ = MessageQueue<uint8_t, kSynchronizedReadWrite>;
|
using DvrMQ = MessageQueue<uint8_t, kSynchronizedReadWrite>;
|
||||||
@@ -141,6 +142,10 @@ struct TimeFilter : public RefBase {
|
|||||||
struct JTuner : public RefBase {
|
struct JTuner : public RefBase {
|
||||||
JTuner(JNIEnv *env, jobject thiz);
|
JTuner(JNIEnv *env, jobject thiz);
|
||||||
sp<ITuner> getTunerService();
|
sp<ITuner> getTunerService();
|
||||||
|
jobject getAvSyncHwId(sp<Filter> filter);
|
||||||
|
jobject getAvSyncTime(jint id);
|
||||||
|
int connectCiCam(jint id);
|
||||||
|
int disconnectCiCam();
|
||||||
jobject getFrontendIds();
|
jobject getFrontendIds();
|
||||||
jobject openFrontendById(int id);
|
jobject openFrontendById(int id);
|
||||||
jobject getFrontendInfo(int id);
|
jobject getFrontendInfo(int id);
|
||||||
@@ -158,7 +163,7 @@ struct JTuner : public RefBase {
|
|||||||
jobject openDvr(DvrType type, int bufferSize);
|
jobject openDvr(DvrType type, int bufferSize);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool openDemux();
|
Result openDemux();
|
||||||
virtual ~JTuner();
|
virtual ~JTuner();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user