Merge "Add setStatusCheckIntervalHint method"

This commit is contained in:
Ray Chin
2022-10-12 07:04:30 +00:00
committed by Android (Google) Code Review
8 changed files with 100 additions and 1 deletions

View File

@@ -7132,6 +7132,7 @@ package android.media.tv.tuner {
field public static final int TUNER_VERSION_1_0 = 65536; // 0x10000
field public static final int TUNER_VERSION_1_1 = 65537; // 0x10001
field public static final int TUNER_VERSION_2_0 = 131072; // 0x20000
field public static final int TUNER_VERSION_3_0 = 196608; // 0x30000
field public static final int TUNER_VERSION_UNKNOWN = 0; // 0x0
}
@@ -7149,6 +7150,7 @@ package android.media.tv.tuner.dvr {
method public long read(@NonNull byte[], long, long);
method public long seek(long);
method public void setFileDescriptor(@NonNull android.os.ParcelFileDescriptor);
method public int setPlaybackBufferStatusCheckIntervalHint(long);
method public int start();
method public int stop();
field public static final int PLAYBACK_STATUS_ALMOST_EMPTY = 2; // 0x2
@@ -7164,6 +7166,7 @@ package android.media.tv.tuner.dvr {
method public int detachFilter(@NonNull android.media.tv.tuner.filter.Filter);
method public int flush();
method public void setFileDescriptor(@NonNull android.os.ParcelFileDescriptor);
method public int setRecordBufferStatusCheckIntervalHint(long);
method public int start();
method public int stop();
method public long write(long);

View File

@@ -59,6 +59,10 @@ public final class TunerVersionChecker {
* Tuner version 2.0.
*/
public static final int TUNER_VERSION_2_0 = (2 << 16);
/**
* Tuner version 3.0.
*/
public static final int TUNER_VERSION_3_0 = (3 << 16);
/**
* Get the current running Tuner version.

View File

@@ -23,6 +23,7 @@ import android.annotation.SystemApi;
import android.media.tv.tuner.Tuner;
import android.media.tv.tuner.Tuner.Result;
import android.media.tv.tuner.TunerUtils;
import android.media.tv.tuner.TunerVersionChecker;
import android.media.tv.tuner.filter.Filter;
import android.os.ParcelFileDescriptor;
import android.os.Process;
@@ -91,6 +92,7 @@ public class DvrPlayback implements AutoCloseable {
private native int nativeAttachFilter(Filter filter);
private native int nativeDetachFilter(Filter filter);
private native int nativeConfigureDvr(DvrSettings settings);
private native int nativeSetStatusCheckIntervalHint(long durationInMs);
private native int nativeStartDvr();
private native int nativeStopDvr();
private native int nativeFlushDvr();
@@ -176,6 +178,35 @@ public class DvrPlayback implements AutoCloseable {
return nativeConfigureDvr(settings);
}
/**
* Set playback buffer status check time interval.
*
* This status check time interval will be used by the Dvr to decide how often to evaluate
* data. The default value will be decided by HAL if it’s not set.
*
* <p>This functionality is only available in Tuner version 3.0 and higher and will otherwise
* return a {@link Tuner#RESULT_UNAVAILABLE}. Use {@link TunerVersionChecker#getTunerVersion()}
* to get the version information.
*
* @param durationInMs specifies the duration of the delay in milliseconds.
*
* @return one of the following results:
* {@link Tuner#RESULT_SUCCESS} if succeed,
* {@link Tuner#RESULT_UNAVAILABLE} if Dvr is unavailable or unsupported HAL versions,
* {@link Tuner#RESULT_NOT_INITIALIZED} if Dvr is not initialized,
* {@link Tuner#RESULT_INVALID_STATE} if Dvr is in a wrong state,
* {@link Tuner#RESULT_INVALID_ARGUMENT} if the input parameter is invalid.
*/
@Result
public int setPlaybackBufferStatusCheckIntervalHint(long durationInMs) {
if (!TunerVersionChecker.checkHigherOrEqualVersionTo(
TunerVersionChecker.TUNER_VERSION_3_0, "Set status check interval hint")) {
// no-op
return Tuner.RESULT_UNAVAILABLE;
}
return nativeSetStatusCheckIntervalHint(durationInMs);
}
/**
* Starts DVR.
*

View File

@@ -22,6 +22,7 @@ import android.annotation.SystemApi;
import android.media.tv.tuner.Tuner;
import android.media.tv.tuner.Tuner.Result;
import android.media.tv.tuner.TunerUtils;
import android.media.tv.tuner.TunerVersionChecker;
import android.media.tv.tuner.filter.Filter;
import android.os.ParcelFileDescriptor;
import android.os.Process;
@@ -53,6 +54,7 @@ public class DvrRecorder implements AutoCloseable {
private native int nativeAttachFilter(Filter filter);
private native int nativeDetachFilter(Filter filter);
private native int nativeConfigureDvr(DvrSettings settings);
private native int nativeSetStatusCheckIntervalHint(long durationInMs);
private native int nativeStartDvr();
private native int nativeStopDvr();
private native int nativeFlushDvr();
@@ -130,6 +132,35 @@ public class DvrRecorder implements AutoCloseable {
return nativeConfigureDvr(settings);
}
/**
* Set record buffer status check time interval.
*
* This status check time interval will be used by the Dvr to decide how often to evaluate
* data. The default value will be decided by HAL if it’s not set.
*
* <p>This functionality is only available in Tuner version 3.0 and higher and will otherwise
* return a {@link Tuner#RESULT_UNAVAILABLE}. Use {@link TunerVersionChecker#getTunerVersion()}
* to get the version information.
*
* @param durationInMs specifies the duration of the delay in milliseconds.
*
* @return one of the following results:
* {@link Tuner#RESULT_SUCCESS} if succeed,
* {@link Tuner#RESULT_UNAVAILABLE} if Dvr is unavailable or unsupported HAL versions,
* {@link Tuner#RESULT_NOT_INITIALIZED} if Dvr is not initialized,
* {@link Tuner#RESULT_INVALID_STATE} if Dvr is in a wrong state,
* {@link Tuner#RESULT_INVALID_ARGUMENT} if the input parameter is invalid.
*/
@Result
public int setRecordBufferStatusCheckIntervalHint(long durationInMs) {
if (!TunerVersionChecker.checkHigherOrEqualVersionTo(
TunerVersionChecker.TUNER_VERSION_3_0, "Set status check interval hint")) {
// no-op
return Tuner.RESULT_UNAVAILABLE;
}
return nativeSetStatusCheckIntervalHint(durationInMs);
}
/**
* Starts DVR.
*

View File

@@ -175,7 +175,7 @@ cc_library_shared {
shared_libs: [
"android.hardware.graphics.bufferqueue@2.0",
"android.hardware.tv.tuner-V1-ndk",
"android.hardware.tv.tuner-V2-ndk",
"libbinder_ndk",
"libandroid_runtime",
"libcutils",

View File

@@ -4485,6 +4485,17 @@ static jint android_media_tv_Tuner_configure_dvr(JNIEnv *env, jobject dvr, jobje
return (jint)result;
}
static jint android_media_tv_Tuner_set_status_check_interval_hint(JNIEnv *env, jobject dvr,
jlong durationInMs) {
sp<DvrClient> dvrClient = getDvrClient(env, dvr);
if (dvrClient == nullptr) {
ALOGD("Failed to set status check interval hint: dvr client not found");
return (int)Result::NOT_INITIALIZED;
}
Result result = dvrClient->setStatusCheckIntervalHint(durationInMs);
return (jint)result;
}
static jint android_media_tv_Tuner_start_dvr(JNIEnv *env, jobject dvr) {
sp<DvrClient> dvrClient = getDvrClient(env, dvr);
if (dvrClient == nullptr) {
@@ -4828,6 +4839,8 @@ static const JNINativeMethod gDvrRecorderMethods[] = {
(void *)android_media_tv_Tuner_detach_filter },
{ "nativeConfigureDvr", "(Landroid/media/tv/tuner/dvr/DvrSettings;)I",
(void *)android_media_tv_Tuner_configure_dvr },
{ "nativeSetStatusCheckIntervalHint", "(J)I",
(void *)android_media_tv_Tuner_set_status_check_interval_hint},
{ "nativeStartDvr", "()I", (void *)android_media_tv_Tuner_start_dvr },
{ "nativeStopDvr", "()I", (void *)android_media_tv_Tuner_stop_dvr },
{ "nativeFlushDvr", "()I", (void *)android_media_tv_Tuner_flush_dvr },
@@ -4844,6 +4857,8 @@ static const JNINativeMethod gDvrPlaybackMethods[] = {
(void *)android_media_tv_Tuner_detach_filter},
{ "nativeConfigureDvr", "(Landroid/media/tv/tuner/dvr/DvrSettings;)I",
(void *)android_media_tv_Tuner_configure_dvr},
{ "nativeSetStatusCheckIntervalHint", "(J)I",
(void *)android_media_tv_Tuner_set_status_check_interval_hint},
{ "nativeStartDvr", "()I", (void *)android_media_tv_Tuner_start_dvr},
{ "nativeStopDvr", "()I", (void *)android_media_tv_Tuner_stop_dvr},
{ "nativeFlushDvr", "()I", (void *)android_media_tv_Tuner_flush_dvr},

View File

@@ -303,7 +303,17 @@ Result DvrClient::close() {
return Result::INVALID_STATE;
}
Result DvrClient::setStatusCheckIntervalHint(int64_t durationInMs) {
if (mTunerDvr == nullptr) {
return Result::INVALID_STATE;
}
if (durationInMs < 0) {
return Result::INVALID_ARGUMENT;
}
Status s = mTunerDvr->setStatusCheckIntervalHint(durationInMs);
return ClientHelper::getServiceSpecificErrorCode(s);
}
/////////////// TunerDvrCallback ///////////////////////
TunerDvrCallback::TunerDvrCallback(sp<DvrClientCallback> dvrClientCallback)
: mDvrClientCallback(dvrClientCallback) {}

View File

@@ -126,6 +126,11 @@ public:
*/
Result close();
/**
* Set status check time interval.
*/
Result setStatusCheckIntervalHint(int64_t durationInMs);
private:
/**
* An AIDL Tuner Dvr Singleton assigned at the first time the Tuner Client