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

Commit 185c80ab authored by Hongguang's avatar Hongguang
Browse files

Add CRC32 checking hint

Bug: 172985025
Fix: 172985025
Test: atest android.media.tv.tuner.cts
Change-Id: If463e4e6bf84e656677785d79feb7d48355fb9ea
parent 82cf9d7a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6934,12 +6934,14 @@ package android.media.tv.tuner.filter {
  }
  public abstract class SectionSettings extends android.media.tv.tuner.filter.Settings {
    method public int getBitWidthOfLengthField();
    method public boolean isCrcEnabled();
    method public boolean isRaw();
    method public boolean isRepeat();
  }
  public abstract static class SectionSettings.Builder<T extends android.media.tv.tuner.filter.SectionSettings.Builder<T>> {
    method @NonNull public T setBitWidthOfLengthField(@IntRange(from=0) int);
    method @NonNull public T setCrcEnabled(boolean);
    method @NonNull public T setRaw(boolean);
    method @NonNull public T setRepeat(boolean);
+37 −2
Original line number Diff line number Diff line
@@ -16,12 +16,13 @@

package android.media.tv.tuner.filter;

import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.media.tv.tuner.TunerUtils;

/**
 * Filter Settings for Section data according to ISO/IEC 13818-1.
 * Filter Settings for Section data according to ISO/IEC 13818-1 and ISO/IEC 23008-1.
 *
 * @hide
 */
@@ -30,12 +31,15 @@ public abstract class SectionSettings extends Settings {
    final boolean mCrcEnabled;
    final boolean mIsRepeat;
    final boolean mIsRaw;
    final int mBitWidthOfLengthField;

    SectionSettings(int mainType, boolean crcEnabled, boolean isRepeat, boolean isRaw) {
    SectionSettings(int mainType, boolean crcEnabled, boolean isRepeat, boolean isRaw,
            int bitWidthOfLengthField) {
        super(TunerUtils.getFilterSubtype(mainType, Filter.SUBTYPE_SECTION));
        mCrcEnabled = crcEnabled;
        mIsRepeat = isRepeat;
        mIsRaw = isRaw;
        mBitWidthOfLengthField = bitWidthOfLengthField;
    }

    /**
@@ -62,6 +66,7 @@ public abstract class SectionSettings extends Settings {
    public boolean isRepeat() {
        return mIsRepeat;
    }

    /**
     * Returns whether the filter sends {@link FilterCallback#onFilterStatusChanged} instead of
     * {@link FilterCallback#onFilterEvent}.
@@ -70,6 +75,17 @@ public abstract class SectionSettings extends Settings {
        return mIsRaw;
    }

    /**
     * Returns the bit width of the MMTP (MPEG Media Transport Protocol) section message's length
     * field according to ISO/IEC 23008-1.
     *
     * The section filter uses this for CRC (Cyclic redundancy check) checking when
     * {@link #isCrcEnabled()} is {@code true}.
     */
    public int getBitWidthOfLengthField() {
        return mBitWidthOfLengthField;
    }

    /**
     * Builder for {@link SectionSettings}.
     *
@@ -80,6 +96,7 @@ public abstract class SectionSettings extends Settings {
        boolean mCrcEnabled;
        boolean mIsRepeat;
        boolean mIsRaw;
        int mBitWidthOfLengthField;

        Builder(int mainType) {
            mMainType = mainType;
@@ -114,6 +131,7 @@ public abstract class SectionSettings extends Settings {
            mIsRepeat = isRepeat;
            return self();
        }

        /**
         * Sets whether the filter send onFilterStatus instead of
         * {@link FilterCallback#onFilterEvent}.
@@ -124,6 +142,23 @@ public abstract class SectionSettings extends Settings {
            return self();
        }

        /**
         * Sets the bit width for the MMTP(MPEG Media Transport Protocol) section message's length
         * field according to ISO/IEC 23008-1.
         *
         * The section filter uses this for CRC (Cyclic redundancy check) checking when
         * {@link #isCrcEnabled()} is {@code true}.
         *
         * <p>This field is only supported in Tuner 2.0 or higher version. Unsupported version will
         * cause no-op. Use {@link android.media.tv.tuner.TunerVersionChecker#getTunerVersion()}
         * to get the version information.
         */
        @NonNull
        public T setBitWidthOfLengthField(@IntRange(from = 0) int bitWidthOfLengthField) {
            mBitWidthOfLengthField = bitWidthOfLengthField;
            return self();
        }

        /* package */ abstract T self();
    }
}
+4 −5
Original line number Diff line number Diff line
@@ -30,10 +30,9 @@ public class SectionSettingsWithSectionBits extends SectionSettings {
    private final byte[] mMask;
    private final byte[] mMode;


    private SectionSettingsWithSectionBits(int mainType, boolean isCheckCrc, boolean isRepeat,
            boolean isRaw, byte[] filter, byte[] mask, byte[] mode) {
        super(mainType, isCheckCrc, isRepeat, isRaw);
            boolean isRaw, int bitWidthOfLengthField, byte[] filter, byte[] mask, byte[] mode) {
        super(mainType, isCheckCrc, isRepeat, isRaw, bitWidthOfLengthField);
        mFilter = filter;
        mMask = mask;
        mMode = mode;
@@ -126,8 +125,8 @@ public class SectionSettingsWithSectionBits extends SectionSettings {
         */
        @NonNull
        public SectionSettingsWithSectionBits build() {
            return new SectionSettingsWithSectionBits(
                    mMainType, mCrcEnabled, mIsRepeat, mIsRaw, mFilter, mMask, mMode);
            return new SectionSettingsWithSectionBits(mMainType, mCrcEnabled, mIsRepeat, mIsRaw,
                    mBitWidthOfLengthField, mFilter, mMask, mMode);
        }

        @Override
+4 −4
Original line number Diff line number Diff line
@@ -37,8 +37,8 @@ public class SectionSettingsWithTableInfo extends SectionSettings {
    private final int mVersion;

    private SectionSettingsWithTableInfo(int mainType, boolean isCheckCrc, boolean isRepeat,
            boolean isRaw, int tableId, int version) {
        super(mainType, isCheckCrc, isRepeat, isRaw);
            boolean isRaw, int bitWidthOfLengthField, int tableId, int version) {
        super(mainType, isCheckCrc, isRepeat, isRaw, bitWidthOfLengthField);
        mTableId = tableId;
        mVersion = version;
    }
@@ -99,8 +99,8 @@ public class SectionSettingsWithTableInfo extends SectionSettings {
         */
        @NonNull
        public SectionSettingsWithTableInfo build() {
            return new SectionSettingsWithTableInfo(
                    mMainType, mCrcEnabled, mIsRepeat, mIsRaw, mTableId, mVersion);
            return new SectionSettingsWithTableInfo(mMainType, mCrcEnabled, mIsRepeat, mIsRaw,
                    mBitWidthOfLengthField, mTableId, mVersion);
        }

        @Override
+3 −0
Original line number Diff line number Diff line
@@ -3515,11 +3515,14 @@ static DemuxFilterSectionSettings getFilterSectionSettings(JNIEnv *env, const jo
    bool isCheckCrc = env->GetBooleanField(settings, env->GetFieldID(clazz, "mCrcEnabled", "Z"));
    bool isRepeat = env->GetBooleanField(settings, env->GetFieldID(clazz, "mIsRepeat", "Z"));
    bool isRaw = env->GetBooleanField(settings, env->GetFieldID(clazz, "mIsRaw", "Z"));
    int32_t bitWidthOfLengthField =
            env->GetIntField(settings, env->GetFieldID(clazz, "mBitWidthOfLengthField", "I"));

    DemuxFilterSectionSettings filterSectionSettings {
        .isCheckCrc = isCheckCrc,
        .isRepeat = isRepeat,
        .isRaw = isRaw,
        .bitWidthOfLengthField = bitWidthOfLengthField,
    };
    if (env->IsInstanceOf(
            settings,