Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec3ec874 authored by Hongguang Chen's avatar Hongguang Chen Committed by Android (Google) Code Review
Browse files

Merge "Add some new features to tuner."

parents e0081af2 54c79100
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -6308,6 +6308,7 @@ package android.media.tv.tuner.filter {
    method public int getAudioStreamType();
    method public int getVideoStreamType();
    method public boolean isPassthrough();
    method public boolean useSecureMemory();
    field public static final int AUDIO_STREAM_TYPE_AAC = 6; // 0x6
    field public static final int AUDIO_STREAM_TYPE_AC3 = 7; // 0x7
    field public static final int AUDIO_STREAM_TYPE_AC4 = 9; // 0x9
@@ -6343,6 +6344,7 @@ package android.media.tv.tuner.filter {
    method @NonNull public android.media.tv.tuner.filter.AvSettings build();
    method @NonNull public android.media.tv.tuner.filter.AvSettings.Builder setAudioStreamType(int);
    method @NonNull public android.media.tv.tuner.filter.AvSettings.Builder setPassthrough(boolean);
    method @NonNull public android.media.tv.tuner.filter.AvSettings.Builder setUseSecureMemory(boolean);
    method @NonNull public android.media.tv.tuner.filter.AvSettings.Builder setVideoStreamType(int);
  }
@@ -6518,6 +6520,7 @@ package android.media.tv.tuner.filter {
    method public int getTsIndexMask();
    field public static final int INDEX_TYPE_NONE = 0; // 0x0
    field public static final int INDEX_TYPE_SC = 1; // 0x1
    field public static final int INDEX_TYPE_SC_AVC = 3; // 0x3
    field public static final int INDEX_TYPE_SC_HEVC = 2; // 0x2
    field public static final int MPT_INDEX_AUDIO = 262144; // 0x40000
    field public static final int MPT_INDEX_MPT = 65536; // 0x10000
@@ -6610,6 +6613,7 @@ package android.media.tv.tuner.filter {
    method @NonNull public static android.media.tv.tuner.filter.SectionSettingsWithTableInfo.Builder builder(int);
    method public int getTableId();
    method public int getVersion();
    field public static final int INVALID_TABLE_INFO_VERSION = -1; // 0xffffffff
  }
  public static class SectionSettingsWithTableInfo.Builder extends android.media.tv.tuner.filter.SectionSettings.Builder<android.media.tv.tuner.filter.SectionSettingsWithTableInfo.Builder> {
+41 −5
Original line number Diff line number Diff line
@@ -186,9 +186,10 @@ public class AvSettings extends Settings {
    private final boolean mIsPassthrough;
    private int mAudioStreamType = AUDIO_STREAM_TYPE_UNDEFINED;
    private int mVideoStreamType = VIDEO_STREAM_TYPE_UNDEFINED;
    private final boolean mUseSecureMemory;

    private AvSettings(int mainType, boolean isAudio, boolean isPassthrough,
            int audioStreamType, int videoStreamType) {
    private AvSettings(int mainType, boolean isAudio, boolean isPassthrough, int audioStreamType,
            int videoStreamType, boolean useSecureMemory) {
        super(TunerUtils.getFilterSubtype(
                mainType,
                isAudio
@@ -197,6 +198,7 @@ public class AvSettings extends Settings {
        mIsPassthrough = isPassthrough;
        mAudioStreamType = audioStreamType;
        mVideoStreamType = videoStreamType;
        mUseSecureMemory = useSecureMemory;
    }

    /**
@@ -222,6 +224,16 @@ public class AvSettings extends Settings {
        return mVideoStreamType;
    }

    /**
     * Checks whether secure memory is used.
     *
     * <p>This query is only supported by Tuner HAL 2.0 or higher. The return value on HAL 1.1 and
     * lower is undefined. Use {@link TunerVersionChecker#getTunerVersion()} to check the version.
     */
    public boolean useSecureMemory() {
        return mUseSecureMemory;
    }

    /**
     * Creates a builder for {@link AvSettings}.
     *
@@ -239,9 +251,10 @@ public class AvSettings extends Settings {
    public static class Builder {
        private final int mMainType;
        private final boolean mIsAudio;
        private boolean mIsPassthrough;
        private boolean mIsPassthrough = false;
        private int mAudioStreamType = AUDIO_STREAM_TYPE_UNDEFINED;
        private int mVideoStreamType = VIDEO_STREAM_TYPE_UNDEFINED;
        boolean mUseSecureMemory = false;

        private Builder(int mainType, boolean isAudio) {
            mMainType = mainType;
@@ -250,6 +263,8 @@ public class AvSettings extends Settings {

        /**
         * Sets whether it's passthrough.
         *
         * <p>Default value is {@code false}.
         */
        @NonNull
        public Builder setPassthrough(boolean isPassthrough) {
@@ -263,6 +278,8 @@ public class AvSettings extends Settings {
         * <p>This API is only supported by Tuner HAL 1.1 or higher. Unsupported version would cause
         * no-op. Use {@link TunerVersionChecker#getTunerVersion()} to check the version.
         *
         * <p>Default is {@link #AUDIO_STREAM_TYPE_UNDEFINED}.
         *
         * @param audioStreamType the audio stream type to set.
         */
        @NonNull
@@ -281,6 +298,8 @@ public class AvSettings extends Settings {
         * <p>This API is only supported by Tuner HAL 1.1 or higher. Unsupported version would cause
         * no-op. Use {@link TunerVersionChecker#getTunerVersion()} to check the version.
         *
         * <p>Default value is {@link #VIDEO_STREAM_TYPE_UNDEFINED}.
         *
         * @param videoStreamType the video stream type to set.
         */
        @NonNull
@@ -293,13 +312,30 @@ public class AvSettings extends Settings {
            return this;
        }

        /**
         * Sets whether secure memory should be used.
         *
         * <p>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.
         *
         * <p>Default value is {@code false}.
         */
        @NonNull
        public Builder setUseSecureMemory(boolean useSecureMemory) {
            if (TunerVersionChecker.checkHigherOrEqualVersionTo(
                        TunerVersionChecker.TUNER_VERSION_2_0, "setSecureMemory")) {
                mUseSecureMemory = useSecureMemory;
            }
            return this;
        }

        /**
         * Builds a {@link AvSettings} object.
         */
        @NonNull
        public AvSettings build() {
            return new AvSettings(mMainType, mIsAudio, mIsPassthrough,
                    mAudioStreamType, mVideoStreamType);
            return new AvSettings(mMainType, mIsAudio, mIsPassthrough, mAudioStreamType,
                    mVideoStreamType, mUseSecureMemory);
        }
    }
}
+11 −7
Original line number Diff line number Diff line
@@ -20,11 +20,11 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.hardware.tv.tuner.DemuxRecordScIndexType;
import android.hardware.tv.tuner.DemuxScAvcIndex;
import android.hardware.tv.tuner.DemuxScHevcIndex;
import android.hardware.tv.tuner.DemuxScIndex;
import android.hardware.tv.tuner.DemuxTsIndex;
import android.media.tv.tuner.TunerUtils;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@@ -139,7 +139,7 @@ public class RecordSettings extends Settings {
    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = "INDEX_TYPE_", value =
            {INDEX_TYPE_NONE, INDEX_TYPE_SC, INDEX_TYPE_SC_HEVC})
            {INDEX_TYPE_NONE, INDEX_TYPE_SC, INDEX_TYPE_SC_HEVC, INDEX_TYPE_SC_AVC})
    public @interface ScIndexType {}

    /**
@@ -154,6 +154,10 @@ public class RecordSettings extends Settings {
     * Start Code index for HEVC.
     */
    public static final int INDEX_TYPE_SC_HEVC = DemuxRecordScIndexType.SC_HEVC;
    /**
     * Start Code index for AVC.
     */
    public static final int INDEX_TYPE_SC_AVC = DemuxRecordScIndexType.SC_AVC;

    /**
     * Indexes can be tagged by Start Code in PES (Packetized Elementary Stream)
@@ -187,23 +191,23 @@ public class RecordSettings extends Settings {
    /**
     * All blocks are coded as I blocks.
     */
    public static final int SC_INDEX_I_SLICE = DemuxScIndex.I_SLICE;
    public static final int SC_INDEX_I_SLICE = DemuxScAvcIndex.I_SLICE << 4;
    /**
     * Blocks are coded as I or P blocks.
     */
    public static final int SC_INDEX_P_SLICE = DemuxScIndex.P_SLICE;
    public static final int SC_INDEX_P_SLICE = DemuxScAvcIndex.P_SLICE << 4;
    /**
     * Blocks are coded as I, P or B blocks.
     */
    public static final int SC_INDEX_B_SLICE = DemuxScIndex.B_SLICE;
    public static final int SC_INDEX_B_SLICE = DemuxScAvcIndex.B_SLICE << 4;
    /**
     * A so-called switching I slice that is coded.
     */
    public static final int SC_INDEX_SI_SLICE = DemuxScIndex.SI_SLICE;
    public static final int SC_INDEX_SI_SLICE = DemuxScAvcIndex.SI_SLICE << 4;
    /**
     * A so-called switching P slice that is coded.
     */
    public static final int SC_INDEX_SP_SLICE = DemuxScIndex.SP_SLICE;
    public static final int SC_INDEX_SP_SLICE = DemuxScAvcIndex.SP_SLICE << 4;

    /**
     * Indexes can be tagged by NAL unit group in HEVC according to ISO/IEC 23008-2.
+8 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.media.tv.tuner.filter;

import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.hardware.tv.tuner.Constant;

/**
 * Table information for Section Filter.
@@ -26,6 +27,12 @@ import android.annotation.SystemApi;
 */
@SystemApi
public class SectionSettingsWithTableInfo extends SectionSettings {
    /**
     * The invalid version number of {@link SectionSettingsWithTableInfo}. Tuner HAL will ignore the
     * {@link SectionSettingsWithTableInfo} version number if this invalid version is set.
     */
    public static final int INVALID_TABLE_INFO_VERSION = Constant.INVALID_TABINFO_VERSION;

    private final int mTableId;
    private final int mVersion;

@@ -64,7 +71,7 @@ public class SectionSettingsWithTableInfo extends SectionSettings {
     */
    public static class Builder extends SectionSettings.Builder<Builder> {
        private int mTableId;
        private int mVersion;
        private int mVersion = INVALID_TABLE_INFO_VERSION;

        private Builder(int mainType) {
            super(mainType);
+17 −2
Original line number Diff line number Diff line
@@ -693,6 +693,10 @@ void FilterClientCallbackImpl::getTsRecordEvent(jobjectArray &arr, const int siz
        sc = tsRecordEvent.scIndexMask.get<DemuxFilterScIndexMask::Tag::scIndex>();
    } else if (tsRecordEvent.scIndexMask.getTag() == DemuxFilterScIndexMask::Tag::scHevc) {
        sc = tsRecordEvent.scIndexMask.get<DemuxFilterScIndexMask::Tag::scHevc>();
    } else if (tsRecordEvent.scIndexMask.getTag() == DemuxFilterScIndexMask::Tag::scAvc) {
        sc = tsRecordEvent.scIndexMask.get<DemuxFilterScIndexMask::Tag::scAvc>();
        // Java uses the values defined by HIDL HAL. Left shift 4 bits.
        sc = sc << 4;
    }

    jint ts = tsRecordEvent.tsIndexMask;
@@ -3391,8 +3395,11 @@ static DemuxFilterAvSettings getFilterAvSettings(JNIEnv *env, const jobject& set
    jclass clazz = env->FindClass("android/media/tv/tuner/filter/AvSettings");
    bool isPassthrough =
            env->GetBooleanField(settings, env->GetFieldID(clazz, "mIsPassthrough", "Z"));
    bool isSecureMemory =
            env->GetBooleanField(settings, env->GetFieldID(clazz, "mUseSecureMemory", "Z"));
    DemuxFilterAvSettings filterAvSettings{
            .isPassthrough = isPassthrough,
            .isSecureMemory = isSecureMemory,
    };
    return filterAvSettings;
}
@@ -3440,6 +3447,11 @@ static DemuxFilterRecordSettings getFilterRecordSettings(JNIEnv *env, const jobj
            env->GetIntField(settings, env->GetFieldID(clazz, "mScIndexType", "I")));
    jint scIndexMask = env->GetIntField(settings, env->GetFieldID(clazz, "mScIndexMask", "I"));

    // Backward compatibility for S- apps.
    if (scIndexType == DemuxRecordScIndexType::SC &&
        scIndexMask > static_cast<int32_t>(DemuxScIndex::SEQUENCE)) {
        scIndexType = DemuxRecordScIndexType::SC_AVC;
    }
    DemuxFilterRecordSettings filterRecordSettings {
        .tsIndexMask = tsIndexMask,
        .scIndexType = scIndexType,
@@ -3448,6 +3460,9 @@ static DemuxFilterRecordSettings getFilterRecordSettings(JNIEnv *env, const jobj
        filterRecordSettings.scIndexMask.set<DemuxFilterScIndexMask::Tag::scIndex>(scIndexMask);
    } else if (scIndexType == DemuxRecordScIndexType::SC_HEVC) {
        filterRecordSettings.scIndexMask.set<DemuxFilterScIndexMask::Tag::scHevc>(scIndexMask);
    } else if (scIndexType == DemuxRecordScIndexType::SC_AVC) {
        // Java uses the values defined by HIDL HAL. Right shift 4 bits.
        filterRecordSettings.scIndexMask.set<DemuxFilterScIndexMask::Tag::scAvc>(scIndexMask >> 4);
    }
    return filterRecordSettings;
}