diff options
| author | 2019-12-11 15:29:09 -0800 | |
|---|---|---|
| committer | 2019-12-23 10:48:36 -0800 | |
| commit | d5b845f537a08df32f4a106100e76fe7233ad4fc (patch) | |
| tree | 6c4179439bc36f02e3d206e5a4fbd6ecdf84ee04 | |
| parent | b1575f6a52bf011ee413574c739435048b2030c1 (diff) | |
Add Scan to tuner
Test: make;
Change-Id: Ia7d971a13be89865eb3a6426024cfd88ecc394c7
| -rw-r--r-- | media/java/android/media/tv/tuner/ScanMessage.java | 131 | ||||
| -rw-r--r-- | media/java/android/media/tv/tuner/Tuner.java | 17 | ||||
| -rw-r--r-- | media/java/android/media/tv/tuner/TunerConstants.java | 45 | ||||
| -rw-r--r-- | media/jni/android_media_tv_Tuner.cpp | 18 | ||||
| -rw-r--r-- | media/jni/android_media_tv_Tuner.h | 2 |
5 files changed, 212 insertions, 1 deletions
diff --git a/media/java/android/media/tv/tuner/ScanMessage.java b/media/java/android/media/tv/tuner/ScanMessage.java new file mode 100644 index 000000000000..35f54f8447c0 --- /dev/null +++ b/media/java/android/media/tv/tuner/ScanMessage.java @@ -0,0 +1,131 @@ +/* + * Copyright 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.media.tv.tuner; + +import android.media.tv.tuner.TunerConstants.ScanMessageType; + +/** + * Message from frontend during scan operations. + * + * @hide + */ +public class ScanMessage { + private final int mType; + private final Object mValue; + + private ScanMessage(int type, Object value) { + mType = type; + mValue = value; + } + + /** Gets scan message type. */ + @ScanMessageType + public int getMessageType() { + return mType; + } + /** Message indicates whether frontend is locked or not. */ + public boolean getIsLocked() { + if (mType != TunerConstants.SCAN_MESSAGE_TYPE_LOCKED) { + throw new IllegalStateException(); + } + return (Boolean) mValue; + } + /** Message indicates whether the scan has reached the end or not. */ + public boolean getIsEnd() { + if (mType != TunerConstants.SCAN_MESSAGE_TYPE_END) { + throw new IllegalStateException(); + } + return (Boolean) mValue; + } + /** Progress message in percent. */ + public int getProgressPercent() { + if (mType != TunerConstants.SCAN_MESSAGE_TYPE_PROGRESS_PERCENT) { + throw new IllegalStateException(); + } + return (Integer) mValue; + } + /** Gets frequency. */ + public int getFrequency() { + if (mType != TunerConstants.SCAN_MESSAGE_TYPE_FREQUENCY) { + throw new IllegalStateException(); + } + return (Integer) mValue; + } + /** Gets symbol rate. */ + public int getSymbolRate() { + if (mType != TunerConstants.SCAN_MESSAGE_TYPE_SYMBOL_RATE) { + throw new IllegalStateException(); + } + return (Integer) mValue; + } + /** Gets PLP IDs. */ + public int[] getPlpIds() { + if (mType != TunerConstants.SCAN_MESSAGE_TYPE_PLP_IDS) { + throw new IllegalStateException(); + } + return (int[]) mValue; + } + /** Gets group IDs. */ + public int[] getGroupIds() { + if (mType != TunerConstants.SCAN_MESSAGE_TYPE_GROUP_IDS) { + throw new IllegalStateException(); + } + return (int[]) mValue; + } + /** Gets Input stream IDs. */ + public int[] getInputStreamIds() { + if (mType != TunerConstants.SCAN_MESSAGE_TYPE_INPUT_STREAM_IDS) { + throw new IllegalStateException(); + } + return (int[]) mValue; + } + /** Gets the DVB-T or DVB-S standard. */ + public int getStandard() { + if (mType != TunerConstants.SCAN_MESSAGE_TYPE_STANDARD) { + throw new IllegalStateException(); + } + return (int) mValue; + } + + /** Gets PLP information for ATSC3. */ + public Atsc3PlpInfo[] getAtsc3PlpInfos() { + if (mType != TunerConstants.SCAN_MESSAGE_TYPE_ATSC3_PLP_INFO) { + throw new IllegalStateException(); + } + return (Atsc3PlpInfo[]) mValue; + } + + /** PLP information for ATSC3. */ + public static class Atsc3PlpInfo { + private final int mPlpId; + private final boolean mLlsFlag; + + private Atsc3PlpInfo(int plpId, boolean llsFlag) { + mPlpId = plpId; + mLlsFlag = llsFlag; + } + + /** Gets PLP IDs. */ + public int getPlpId() { + return mPlpId; + } + /** Gets LLS flag. */ + public boolean getLlsFlag() { + return mLlsFlag; + } + } +} diff --git a/media/java/android/media/tv/tuner/Tuner.java b/media/java/android/media/tv/tuner/Tuner.java index 62d069d7a80f..f02c4aa10311 100644 --- a/media/java/android/media/tv/tuner/Tuner.java +++ b/media/java/android/media/tv/tuner/Tuner.java @@ -24,6 +24,7 @@ import android.content.Context; import android.media.tv.tuner.TunerConstants.DemuxPidType; import android.media.tv.tuner.TunerConstants.FilterSubtype; import android.media.tv.tuner.TunerConstants.FilterType; +import android.media.tv.tuner.TunerConstants.FrontendScanType; import android.os.Handler; import android.os.Looper; import android.os.Message; @@ -100,9 +101,9 @@ public final class Tuner implements AutoCloseable { private native Frontend nativeOpenFrontendById(int id); private native int nativeTune(int type, FrontendSettings settings); private native int nativeStopTune(); + private native int nativeScan(int settingsType, FrontendSettings settings, int scanType); private native int nativeSetLnb(int lnbId); private native int nativeSetLna(boolean enable); - private native Filter nativeOpenFilter(int type, int subType, int bufferSize); private native List<Integer> nativeGetLnbIds(); @@ -123,6 +124,12 @@ public final class Tuner implements AutoCloseable { * Invoked when there is a frontend event. */ void onEvent(int frontendEventType); + + /** + * Invoked when there is a scan message. + * @param msg + */ + void onScanMessage(ScanMessage msg); } /** @@ -266,6 +273,14 @@ public final class Tuner implements AutoCloseable { } /** + * Scan channels. + * @hide + */ + public int scan(@NonNull FrontendSettings settings, @FrontendScanType int scanType) { + return nativeScan(settings.getType(), settings, scanType); + } + + /** * Sets Low-Noise Block downconverter (LNB) for satellite frontend. * * This assigns a hardware LNB resource to the satellite tuner. It can be diff --git a/media/java/android/media/tv/tuner/TunerConstants.java b/media/java/android/media/tv/tuner/TunerConstants.java index 4973b05f5c14..2c6d850b10da 100644 --- a/media/java/android/media/tv/tuner/TunerConstants.java +++ b/media/java/android/media/tv/tuner/TunerConstants.java @@ -75,6 +75,7 @@ final class TunerConstants { public static final int DEMUX_T_PID = 1; public static final int DEMUX_MMPT_PID = 2; + @Retention(RetentionPolicy.SOURCE) @IntDef({FRONTEND_SETTINGS_ANALOG, FRONTEND_SETTINGS_ATSC, FRONTEND_SETTINGS_ATSC3, FRONTEND_SETTINGS_DVBS, FRONTEND_SETTINGS_DVBC, FRONTEND_SETTINGS_DVBT, FRONTEND_SETTINGS_ISDBS, FRONTEND_SETTINGS_ISDBS3, FRONTEND_SETTINGS_ISDBT}) @@ -127,6 +128,50 @@ final class TunerConstants { public static final int FILTER_SUBTYPE_PTP = 16; @Retention(RetentionPolicy.SOURCE) + @IntDef({FRONTEND_SCAN_UNDEFINED, FRONTEND_SCAN_AUTO, FRONTEND_SCAN_BLIND}) + public @interface FrontendScanType {} + + public static final int FRONTEND_SCAN_UNDEFINED = Constants.FrontendScanType.SCAN_UNDEFINED; + public static final int FRONTEND_SCAN_AUTO = Constants.FrontendScanType.SCAN_AUTO; + public static final int FRONTEND_SCAN_BLIND = Constants.FrontendScanType.SCAN_BLIND; + + @Retention(RetentionPolicy.SOURCE) + @IntDef({SCAN_MESSAGE_TYPE_LOCKED, SCAN_MESSAGE_TYPE_END, SCAN_MESSAGE_TYPE_PROGRESS_PERCENT, + SCAN_MESSAGE_TYPE_FREQUENCY, SCAN_MESSAGE_TYPE_SYMBOL_RATE, SCAN_MESSAGE_TYPE_PLP_IDS, + SCAN_MESSAGE_TYPE_GROUP_IDS, SCAN_MESSAGE_TYPE_INPUT_STREAM_IDS, + SCAN_MESSAGE_TYPE_STANDARD, SCAN_MESSAGE_TYPE_ATSC3_PLP_INFO}) + public @interface ScanMessageType {} + + public static final int SCAN_MESSAGE_TYPE_LOCKED = Constants.FrontendScanMessageType.LOCKED; + public static final int SCAN_MESSAGE_TYPE_END = Constants.FrontendScanMessageType.END; + public static final int SCAN_MESSAGE_TYPE_PROGRESS_PERCENT = + Constants.FrontendScanMessageType.PROGRESS_PERCENT; + public static final int SCAN_MESSAGE_TYPE_FREQUENCY = + Constants.FrontendScanMessageType.FREQUENCY; + public static final int SCAN_MESSAGE_TYPE_SYMBOL_RATE = + Constants.FrontendScanMessageType.SYMBOL_RATE; + public static final int SCAN_MESSAGE_TYPE_PLP_IDS = Constants.FrontendScanMessageType.PLP_IDS; + public static final int SCAN_MESSAGE_TYPE_GROUP_IDS = + Constants.FrontendScanMessageType.GROUP_IDS; + public static final int SCAN_MESSAGE_TYPE_INPUT_STREAM_IDS = + Constants.FrontendScanMessageType.INPUT_STREAM_IDS; + public static final int SCAN_MESSAGE_TYPE_STANDARD = + Constants.FrontendScanMessageType.STANDARD; + public static final int SCAN_MESSAGE_TYPE_ATSC3_PLP_INFO = + Constants.FrontendScanMessageType.ATSC3_PLP_INFO; + + @Retention(RetentionPolicy.SOURCE) + @IntDef({FILTER_SETTINGS_TS, FILTER_SETTINGS_MMTP, FILTER_SETTINGS_IP, FILTER_SETTINGS_TLV, + FILTER_SETTINGS_ALP}) + public @interface FilterSettingsType {} + + public static final int FILTER_SETTINGS_TS = Constants.DemuxFilterMainType.TS; + public static final int FILTER_SETTINGS_MMTP = Constants.DemuxFilterMainType.MMTP; + public static final int FILTER_SETTINGS_IP = Constants.DemuxFilterMainType.IP; + public static final int FILTER_SETTINGS_TLV = Constants.DemuxFilterMainType.TLV; + public static final int FILTER_SETTINGS_ALP = Constants.DemuxFilterMainType.ALP; + + @Retention(RetentionPolicy.SOURCE) @IntDef({DVR_SETTINGS_RECORD, DVR_SETTINGS_PLAYBACK}) public @interface DvrSettingsType {} diff --git a/media/jni/android_media_tv_Tuner.cpp b/media/jni/android_media_tv_Tuner.cpp index 4a2baed72bd9..0cac2af9adc3 100644 --- a/media/jni/android_media_tv_Tuner.cpp +++ b/media/jni/android_media_tv_Tuner.cpp @@ -312,6 +312,15 @@ int JTuner::tune(const FrontendSettings& settings) { return (int)result; } +int JTuner::scan(const FrontendSettings& settings, FrontendScanType scanType) { + if (mFe == NULL) { + ALOGE("frontend is not initialized"); + return (int)Result::INVALID_STATE; + } + Result result = mFe->scan(settings, scanType); + return (int)result; +} + bool JTuner::openDemux() { if (mTuner == nullptr) { return false; @@ -604,6 +613,13 @@ static int android_media_tv_Tuner_stop_tune(JNIEnv, jobject) { return 0; } +static int android_media_tv_Tuner_scan( + JNIEnv *env, jobject thiz, jint settingsType, jobject settings, jint scanType) { + sp<JTuner> tuner = getTuner(env, thiz); + return tuner->scan(getFrontendSettings( + env, settingsType, settings), static_cast<FrontendScanType>(scanType)); +} + static int android_media_tv_Tuner_set_lnb(JNIEnv, jobject, jint) { return 0; } @@ -863,6 +879,8 @@ static const JNINativeMethod gTunerMethods[] = { { "nativeTune", "(ILandroid/media/tv/tuner/FrontendSettings;)I", (void *)android_media_tv_Tuner_tune }, { "nativeStopTune", "()I", (void *)android_media_tv_Tuner_stop_tune }, + { "nativeScan", "(ILandroid/media/tv/tuner/FrontendSettings;I)I", + (void *)android_media_tv_Tuner_scan }, { "nativeSetLnb", "(I)I", (void *)android_media_tv_Tuner_set_lnb }, { "nativeSetLna", "(Z)I", (void *)android_media_tv_Tuner_set_lna }, { "nativeOpenFilter", "(III)Landroid/media/tv/tuner/Tuner$Filter;", diff --git a/media/jni/android_media_tv_Tuner.h b/media/jni/android_media_tv_Tuner.h index 9f9fb2748581..d37a2d96c60b 100644 --- a/media/jni/android_media_tv_Tuner.h +++ b/media/jni/android_media_tv_Tuner.h @@ -39,6 +39,7 @@ using ::android::hardware::tv::tuner::V1_0::FrontendEventType; using ::android::hardware::tv::tuner::V1_0::FrontendId; using ::android::hardware::tv::tuner::V1_0::FrontendScanMessage; using ::android::hardware::tv::tuner::V1_0::FrontendScanMessageType; +using ::android::hardware::tv::tuner::V1_0::FrontendScanType; using ::android::hardware::tv::tuner::V1_0::FrontendSettings; using ::android::hardware::tv::tuner::V1_0::IDemux; using ::android::hardware::tv::tuner::V1_0::IDescrambler; @@ -122,6 +123,7 @@ struct JTuner : public RefBase { jobject getFrontendIds(); jobject openFrontendById(int id); int tune(const FrontendSettings& settings); + int scan(const FrontendSettings& settings, FrontendScanType scanType); jobject getLnbIds(); jobject openLnbById(int id); jobject openFilter(DemuxFilterType type, int bufferSize); |