diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 434f3fedd4850..75c9be966f816 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -6701,6 +6701,8 @@ package android.media.tv.tuner.filter { method @Nullable public String acquireSharedFilterToken(); method public void close(); method public int configure(@NonNull android.media.tv.tuner.filter.FilterConfiguration); + method public int delayCallbackUntilBufferFilled(int); + method public int delayCallbackUntilTimeMillis(long); method public int flush(); method public void freeSharedFilterToken(@NonNull String); method @Deprecated public int getId(); diff --git a/media/java/android/media/tv/tuner/filter/Filter.java b/media/java/android/media/tv/tuner/filter/Filter.java index 5d71a13bf7012..f9fc17fdb4728 100644 --- a/media/java/android/media/tv/tuner/filter/Filter.java +++ b/media/java/android/media/tv/tuner/filter/Filter.java @@ -254,6 +254,8 @@ public class Filter implements AutoCloseable { private native int nativeClose(); private native String nativeAcquireSharedFilterToken(); private native void nativeFreeSharedFilterToken(String token); + private native int nativeSetTimeDelayHint(int timeDelayInMs); + private native int nativeSetDataSizeDelayHint(int dataSizeDelayInBytes); // Called by JNI private Filter(long id) { @@ -599,4 +601,52 @@ public class Filter implements AutoCloseable { mIsShared = false; } } + + /** + * Set filter time delay. + * + *
Setting a time delay instructs the filter to delay its event callback invocation until + * the specified amount of time has passed. The default value (delay disabled) is {@code 0}. + * + *
This functionality is only available in Tuner version 2.0 and higher and will otherwise + * be a no-op. Use {@link TunerVersionChecker#getTunerVersion()} to get the version information. + * + * @param delayInMs specifies the duration of the delay in milliseconds. + */ + public int delayCallbackUntilTimeMillis(long delayInMs) { + if (!TunerVersionChecker.checkHigherOrEqualVersionTo( + TunerVersionChecker.TUNER_VERSION_2_0, "setTimeDelayHint")) { + return Tuner.RESULT_UNAVAILABLE; + } + + if (delayInMs >= 0 && delayInMs <= Integer.MAX_VALUE) { + synchronized (mLock) { + return nativeSetTimeDelayHint((int) delayInMs); + } + } + return Tuner.RESULT_INVALID_ARGUMENT; + } + + /** + * Set filter data size delay. + * + *
Setting a data size delay instructs the filter to delay its event callback invocation + * until a specified amount of data has accumulated. The default value (delay disabled) is + * {@code 0}. + * + *
This functionality is only available in Tuner version 2.0 and higher and will otherwise
+ * be a no-op. Use {@link TunerVersionChecker#getTunerVersion()} to get the version information.
+ *
+ * @param delayInBytes specifies the duration of the delay in bytes.
+ */
+ public int delayCallbackUntilBufferFilled(int delayInBytes) {
+ if (!TunerVersionChecker.checkHigherOrEqualVersionTo(
+ TunerVersionChecker.TUNER_VERSION_2_0, "setTimeDelayHint")) {
+ return Tuner.RESULT_UNAVAILABLE;
+ }
+
+ synchronized (mLock) {
+ return nativeSetDataSizeDelayHint(delayInBytes);
+ }
+ }
}
diff --git a/media/jni/android_media_tv_Tuner.cpp b/media/jni/android_media_tv_Tuner.cpp
index 64eede5ef88fd..f5606bc3539f2 100644
--- a/media/jni/android_media_tv_Tuner.cpp
+++ b/media/jni/android_media_tv_Tuner.cpp
@@ -62,6 +62,8 @@
#include