Merge "Add API to configure Scambling Status event to monitor specific status type"
This commit is contained in:
@@ -5309,6 +5309,7 @@ package android.media.tv.tuner.filter {
|
||||
public class Filter implements java.lang.AutoCloseable {
|
||||
method public void close();
|
||||
method public int configure(@NonNull android.media.tv.tuner.filter.FilterConfiguration);
|
||||
method public int configureScramblingStatusEvent(int);
|
||||
method public int flush();
|
||||
method public int getId();
|
||||
method public long getId64Bit();
|
||||
@@ -5316,6 +5317,9 @@ package android.media.tv.tuner.filter {
|
||||
method public int setDataSource(@Nullable android.media.tv.tuner.filter.Filter);
|
||||
method public int start();
|
||||
method public int stop();
|
||||
field public static final int SCRAMBLING_STATUS_NOT_SCRAMBLED = 2; // 0x2
|
||||
field public static final int SCRAMBLING_STATUS_SCRAMBLED = 4; // 0x4
|
||||
field public static final int SCRAMBLING_STATUS_UNKNOWN = 1; // 0x1
|
||||
field public static final int STATUS_DATA_READY = 1; // 0x1
|
||||
field public static final int STATUS_HIGH_WATER = 4; // 0x4
|
||||
field public static final int STATUS_LOW_WATER = 2; // 0x2
|
||||
@@ -5494,6 +5498,10 @@ package android.media.tv.tuner.filter {
|
||||
method @NonNull public android.media.tv.tuner.filter.RecordSettings.Builder setTsIndexMask(int);
|
||||
}
|
||||
|
||||
public final class ScramblingStatusEvent extends android.media.tv.tuner.filter.FilterEvent {
|
||||
method public int getScramblingStatus();
|
||||
}
|
||||
|
||||
public class SectionEvent extends android.media.tv.tuner.filter.FilterEvent {
|
||||
method public int getDataLength();
|
||||
method public int getSectionNumber();
|
||||
|
||||
@@ -5249,6 +5249,7 @@ package android.media.tv.tuner.filter {
|
||||
public class Filter implements java.lang.AutoCloseable {
|
||||
method public void close();
|
||||
method public int configure(@NonNull android.media.tv.tuner.filter.FilterConfiguration);
|
||||
method public int configureScramblingStatusEvent(int);
|
||||
method public int flush();
|
||||
method public int getId();
|
||||
method public long getId64Bit();
|
||||
@@ -5256,6 +5257,9 @@ package android.media.tv.tuner.filter {
|
||||
method public int setDataSource(@Nullable android.media.tv.tuner.filter.Filter);
|
||||
method public int start();
|
||||
method public int stop();
|
||||
field public static final int SCRAMBLING_STATUS_NOT_SCRAMBLED = 2; // 0x2
|
||||
field public static final int SCRAMBLING_STATUS_SCRAMBLED = 4; // 0x4
|
||||
field public static final int SCRAMBLING_STATUS_UNKNOWN = 1; // 0x1
|
||||
field public static final int STATUS_DATA_READY = 1; // 0x1
|
||||
field public static final int STATUS_HIGH_WATER = 4; // 0x4
|
||||
field public static final int STATUS_LOW_WATER = 2; // 0x2
|
||||
@@ -5434,6 +5438,10 @@ package android.media.tv.tuner.filter {
|
||||
method @NonNull public android.media.tv.tuner.filter.RecordSettings.Builder setTsIndexMask(int);
|
||||
}
|
||||
|
||||
public final class ScramblingStatusEvent extends android.media.tv.tuner.filter.FilterEvent {
|
||||
method public int getScramblingStatus();
|
||||
}
|
||||
|
||||
public class SectionEvent extends android.media.tv.tuner.filter.FilterEvent {
|
||||
method public int getDataLength();
|
||||
method public int getSectionNumber();
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.hardware.tv.tuner.V1_0.Constants;
|
||||
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 java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -148,7 +149,6 @@ public class Filter implements AutoCloseable {
|
||||
public static final int SUBTYPE_PTP = 16;
|
||||
|
||||
|
||||
|
||||
/** @hide */
|
||||
@IntDef(flag = true, prefix = "STATUS_", value = {STATUS_DATA_READY, STATUS_LOW_WATER,
|
||||
STATUS_HIGH_WATER, STATUS_OVERFLOW})
|
||||
@@ -180,6 +180,31 @@ public class Filter implements AutoCloseable {
|
||||
*/
|
||||
public static final int STATUS_OVERFLOW = Constants.DemuxFilterStatus.OVERFLOW;
|
||||
|
||||
/** @hide */
|
||||
@IntDef(flag = true,
|
||||
prefix = "SCRAMBLING_STATUS_",
|
||||
value = {SCRAMBLING_STATUS_UNKNOWN, SCRAMBLING_STATUS_NOT_SCRAMBLED,
|
||||
SCRAMBLING_STATUS_SCRAMBLED})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ScramblingStatusMask {}
|
||||
|
||||
/**
|
||||
* Content’s scrambling status is unknown
|
||||
*/
|
||||
public static final int SCRAMBLING_STATUS_UNKNOWN =
|
||||
android.hardware.tv.tuner.V1_1.Constants.ScramblingStatus.UNKNOWN;
|
||||
/**
|
||||
* Content is not scrambled.
|
||||
*/
|
||||
public static final int SCRAMBLING_STATUS_NOT_SCRAMBLED =
|
||||
android.hardware.tv.tuner.V1_1.Constants.ScramblingStatus.NOT_SCRAMBLED;
|
||||
/**
|
||||
* Content is scrambled.
|
||||
*/
|
||||
public static final int SCRAMBLING_STATUS_SCRAMBLED =
|
||||
android.hardware.tv.tuner.V1_1.Constants.ScramblingStatus.SCRAMBLED;
|
||||
|
||||
|
||||
private static final String TAG = "Filter";
|
||||
|
||||
private long mNativeContext;
|
||||
@@ -197,6 +222,7 @@ public class Filter implements AutoCloseable {
|
||||
int type, int subType, FilterConfiguration settings);
|
||||
private native int nativeGetId();
|
||||
private native long nativeGetId64Bit();
|
||||
private native int nativeconfigureScramblingEvent(int scramblingStatusMask);
|
||||
private native int nativeSetDataSource(Filter source);
|
||||
private native int nativeStartFilter();
|
||||
private native int nativeStopFilter();
|
||||
@@ -279,6 +305,38 @@ public class Filter implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the Filter to monitor specific Scrambling Status through
|
||||
* {@link ScramblingStatusEvent}.
|
||||
*
|
||||
* <p>{@link ScramblingStatusEvent} should be sent at the following two scenarios:
|
||||
*
|
||||
* <ul>
|
||||
* <li>When this method is called, the first detected scrambling status should be sent.
|
||||
* <li>When the filter transits into the monitored statuses configured in
|
||||
* {@code scramblingStatusMask}, event should be sent.
|
||||
* <ul/>
|
||||
*
|
||||
* <p>This configuration is only supported in Tuner 1.1 or higher version. Unsupported version
|
||||
* will cause no-op. Use {@link TunerVersionChecker.getTunerVersion()} to get the version
|
||||
* information.
|
||||
*
|
||||
* @param scramblingStatusMask Scrambling Statuses to be monitored. Set corresponding bit to
|
||||
* monitor it. Reset to stop monitoring.
|
||||
* @return result status of the operation.
|
||||
*/
|
||||
@Result
|
||||
public int configureScramblingStatusEvent(@ScramblingStatusMask int scramblingStatusMask) {
|
||||
synchronized (mLock) {
|
||||
TunerUtils.checkResourceState(TAG, mIsClosed);
|
||||
if (!TunerVersionChecker.checkHigherOrEqualVersionTo(
|
||||
TunerVersionChecker.TUNER_VERSION_1_1, "configureScramblingStatusEvent")) {
|
||||
return Tuner.RESULT_UNAVAILABLE;
|
||||
}
|
||||
return nativeconfigureScramblingEvent(scramblingStatusMask);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the filter's data source.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2020 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.filter;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
|
||||
/**
|
||||
* Scrambling Status event sent from {@link Filter} objects with Scrambling Status type.
|
||||
*
|
||||
* <p>This event is only sent in Tuner 1.1 or higher version. Use
|
||||
* {@link TunerVersionChecker.getTunerVersion()} to get the version information.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public final class ScramblingStatusEvent extends FilterEvent {
|
||||
private final int mScramblingStatus;
|
||||
|
||||
private ScramblingStatusEvent(@Filter.ScramblingStatusMask int scramblingStatus) {
|
||||
mScramblingStatus = scramblingStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Scrambling Status Type.
|
||||
*
|
||||
* <p>This event field is only sent in Tuner 1.1 or higher version. Unsupported version returns
|
||||
* default value 0. Use {@link TunerVersionChecker.getTunerVersion()} to get the version
|
||||
* information.
|
||||
*/
|
||||
@Filter.ScramblingStatusMask
|
||||
public int getScramblingStatus() {
|
||||
return mScramblingStatus;
|
||||
}
|
||||
}
|
||||
@@ -4024,6 +4024,28 @@ static jlong android_media_tv_Tuner_get_filter_64bit_id(JNIEnv* env, jobject fil
|
||||
::android::hardware::tv::tuner::V1_1::Constant64Bit::INVALID_FILTER_ID_64BIT);
|
||||
}
|
||||
|
||||
static jint android_media_tv_Tuner_configure_scrambling_status_event(
|
||||
JNIEnv* env, jobject filter, int scramblingStatusMask) {
|
||||
sp<IFilter> iFilterSp = getFilter(env, filter)->getIFilter();
|
||||
if (iFilterSp == NULL) {
|
||||
ALOGD("Failed to configure scrambling event: filter not found");
|
||||
return (jint) Result::NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
sp<::android::hardware::tv::tuner::V1_1::IFilter> iFilterSp_1_1;
|
||||
iFilterSp_1_1 = ::android::hardware::tv::tuner::V1_1::IFilter::castFrom(iFilterSp);
|
||||
Result res;
|
||||
|
||||
if (iFilterSp_1_1 != NULL) {
|
||||
res = iFilterSp_1_1->configureScramblingEvent(scramblingStatusMask);
|
||||
} else {
|
||||
ALOGW("configureScramblingEvent is not supported with the current HAL implementation.");
|
||||
return (jint) Result::INVALID_STATE;
|
||||
}
|
||||
|
||||
return (jint) res;
|
||||
}
|
||||
|
||||
static jint android_media_tv_Tuner_set_filter_data_source(
|
||||
JNIEnv* env, jobject filter, jobject srcFilter) {
|
||||
sp<IFilter> iFilterSp = getFilter(env, filter)->getIFilter();
|
||||
@@ -4695,6 +4717,8 @@ static const JNINativeMethod gFilterMethods[] = {
|
||||
{ "nativeGetId", "()I", (void *)android_media_tv_Tuner_get_filter_id },
|
||||
{ "nativeGetId64Bit", "()J",
|
||||
(void *)android_media_tv_Tuner_get_filter_64bit_id },
|
||||
{ "nativeconfigureScramblingEvent", "(I)I",
|
||||
(void *)android_media_tv_Tuner_configure_scrambling_status_event },
|
||||
{ "nativeSetDataSource", "(Landroid/media/tv/tuner/filter/Filter;)I",
|
||||
(void *)android_media_tv_Tuner_set_filter_data_source },
|
||||
{ "nativeStartFilter", "()I", (void *)android_media_tv_Tuner_start_filter },
|
||||
|
||||
Reference in New Issue
Block a user