diff --git a/core/api/system-current.txt b/core/api/system-current.txt index f48d956f0de79..bc86cccbf44e9 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -6495,6 +6495,7 @@ package android.media.tv.tuner { method @Nullable public android.media.tv.tuner.Lnb openLnbByName(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull android.media.tv.tuner.LnbCallback); method @Nullable @RequiresPermission(android.Manifest.permission.ACCESS_TV_SHARED_FILTER) public static android.media.tv.tuner.filter.SharedFilter openSharedFilter(@NonNull android.content.Context, @NonNull String, @NonNull java.util.concurrent.Executor, @NonNull android.media.tv.tuner.filter.SharedFilterCallback); method @Nullable public android.media.tv.tuner.filter.TimeFilter openTimeFilter(); + method public int removeOutputPid(@IntRange(from=0) int); method public int scan(@NonNull android.media.tv.tuner.frontend.FrontendSettings, int, @NonNull java.util.concurrent.Executor, @NonNull android.media.tv.tuner.frontend.ScanCallback); method public int setLnaEnabled(boolean); method public int setMaxNumberOfFrontends(int, @IntRange(from=0) int); diff --git a/media/java/android/media/tv/tuner/Tuner.java b/media/java/android/media/tv/tuner/Tuner.java index 4128abf03e071..9fbbd4b559e9c 100644 --- a/media/java/android/media/tv/tuner/Tuner.java +++ b/media/java/android/media/tv/tuner/Tuner.java @@ -691,7 +691,7 @@ public class Tuner implements AutoCloseable { private native String nativeGetFrontendHardwareInfo(); private native int nativeSetMaxNumberOfFrontends(int frontendType, int maxNumber); private native int nativeGetMaxNumberOfFrontends(int frontendType); - + private native int nativeRemoveOutputPid(int pid); private native Lnb nativeOpenLnbByHandle(int handle); private native Lnb nativeOpenLnbByName(String name); @@ -1238,6 +1238,36 @@ public class Tuner implements AutoCloseable { } } + /** + * Filter out unnecessary PID (packet identifier) from frontend output. + * + *
It is used by the client to remove some video or audio PIDs of other program to reduce the + * total amount of recorded TS. + * + *
This API is only supported by Tuner HAL 2.0 or higher. Unsupported version would cause
+ * no-op. Use {@link TunerVersionChecker#getTunerVersion()} to check the version.
+ *
+ * @return result status of the operation. Unsupported version or if current active frontend
+ * doesn’t support PID filtering out would return {@link #RESULT_UNAVAILABLE}.
+ * @throws IllegalStateException if there is no active frontend currently.
+ */
+ @Result
+ public int removeOutputPid(@IntRange(from = 0) int pid) {
+ mFrontendLock.lock();
+ try {
+ if (!TunerVersionChecker.checkHigherOrEqualVersionTo(
+ TunerVersionChecker.TUNER_VERSION_2_0, "Remove output PID")) {
+ return RESULT_UNAVAILABLE;
+ }
+ if (mFrontend == null) {
+ throw new IllegalStateException("frontend is not initialized");
+ }
+ return nativeRemoveOutputPid(pid);
+ } finally {
+ mFrontendLock.unlock();
+ }
+ }
+
/**
* Gets the currently initialized and activated frontend information. To get all the available
* frontend info on the device, use {@link getAvailableFrontendInfos()}.
diff --git a/media/jni/android_media_tv_Tuner.cpp b/media/jni/android_media_tv_Tuner.cpp
index 9572e18066433..c3449dc848448 100644
--- a/media/jni/android_media_tv_Tuner.cpp
+++ b/media/jni/android_media_tv_Tuner.cpp
@@ -1595,6 +1595,15 @@ int32_t JTuner::getMaxNumberOfFrontends(int32_t type) {
return mTunerClient->getMaxNumberOfFrontends(static_cast