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

Commit 2bdd1fc5 authored by shubang's avatar shubang
Browse files

Complete FilterConfiguration getters and builders

Test: make
Change-Id: I6ac1b9bdd43e24f3b101a6efc977ea9ef3f2415b
parent ac8a052c
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -124,6 +124,34 @@ public final class TunerConstants {
     */
    public static final int FILTER_STATUS_OVERFLOW = Constants.DemuxFilterStatus.OVERFLOW;


    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = "INDEX_TYPE_", value =
            {INDEX_TYPE_NONE, INDEX_TYPE_TS, INDEX_TYPE_SC, INDEX_TYPE_SC_HEVC})
    public @interface IndexType {}

    /**
     * Index is not used.
     * @hide
     */
    public static final int INDEX_TYPE_NONE = Constants.DemuxRecordIndexType.NONE;
    /**
     * TS index.
     * @hide
     */
    public static final int INDEX_TYPE_TS = Constants.DemuxRecordIndexType.TS;
    /**
     * Start Code index.
     * @hide
     */
    public static final int INDEX_TYPE_SC = Constants.DemuxRecordIndexType.SC;
    /**
     * Start Code index for HEVC.
     * @hide
     */
    public static final int INDEX_TYPE_SC_HEVC = Constants.DemuxRecordIndexType.SC_HEVC;

    /**
     * Indexes can be tagged through TS (Transport Stream) header.
     *
+106 −3
Original line number Diff line number Diff line
@@ -16,20 +16,123 @@

package android.media.tv.tuner.filter;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.content.Context;
import android.hardware.tv.tuner.V1_0.Constants;
import android.media.tv.tuner.TunerUtils;

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

/**
 * Filter configuration for a ALP filter.
 * @hide
 */
public class AlpFilterConfiguration extends FilterConfiguration {
    private int mPacketType;
    private int mLengthType;
    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = "LENGTH_TYPE_", value =
            {LENGTH_TYPE_UNDEFINED, LENGTH_TYPE_WITHOUT_ADDITIONAL_HEADER,
            LENGTH_TYPE_WITH_ADDITIONAL_HEADER})
    public @interface LengthType {}

    /**
     * Length type not defined.
     */
    public static final int LENGTH_TYPE_UNDEFINED = Constants.DemuxAlpLengthType.UNDEFINED;
    /**
     * Length does NOT include additional header.
     */
    public static final int LENGTH_TYPE_WITHOUT_ADDITIONAL_HEADER =
            Constants.DemuxAlpLengthType.WITHOUT_ADDITIONAL_HEADER;
    /**
     * Length includes additional header.
     */
    public static final int LENGTH_TYPE_WITH_ADDITIONAL_HEADER =
            Constants.DemuxAlpLengthType.WITH_ADDITIONAL_HEADER;


    public AlpFilterConfiguration(Settings settings) {
    private final int mPacketType;
    private final int mLengthType;

    public AlpFilterConfiguration(Settings settings, int packetType, int lengthType) {
        super(settings);
        mPacketType = packetType;
        mLengthType = lengthType;
    }

    @Override
    public int getType() {
        return FilterConfiguration.FILTER_TYPE_ALP;
    }

    /**
     * Gets packet type.
     */
    @FilterConfiguration.PacketType
    public int getPacketType() {
        return mPacketType;
    }
    /**
     * Gets length type.
     */
    @LengthType
    public int getLengthType() {
        return mLengthType;
    }

    /**
     * Creates a builder for {@link AlpFilterConfiguration}.
     *
     * @param context the context of the caller.
     */
    @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
    @NonNull
    public static Builder builder(@NonNull Context context) {
        TunerUtils.checkTunerPermission(context);
        return new Builder();
    }

    /**
     * Builder for {@link AlpFilterConfiguration}.
     */
    public static class Builder extends FilterConfiguration.Builder<Builder> {
        private int mPacketType;
        private int mLengthType;

        private Builder() {
        }

        /**
         * Sets packet type.
         */
        @NonNull
        public Builder setPacketType(@FilterConfiguration.PacketType int packetType) {
            mPacketType = packetType;
            return this;
        }
        /**
         * Sets length type.
         */
        @NonNull
        public Builder setLengthType(@LengthType int lengthType) {
            mLengthType = lengthType;
            return this;
        }

        /**
         * Builds a {@link AlpFilterConfiguration} object.
         */
        @NonNull
        public AlpFilterConfiguration build() {
            return new AlpFilterConfiguration(mSettings, mPacketType, mLengthType);
        }

        @Override
        Builder self() {
            return this;
        }
    }
}
+65 −2
Original line number Diff line number Diff line
@@ -16,21 +16,84 @@

package android.media.tv.tuner.filter;

import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.content.Context;
import android.media.tv.tuner.TunerConstants;
import android.media.tv.tuner.TunerUtils;
import android.media.tv.tuner.filter.FilterConfiguration.FilterType;

/**
 * Filter Settings for a Video and Audio.
 *
 * @hide
 */
public class AvSettings extends Settings {
    private boolean mIsPassthrough;
    private final boolean mIsPassthrough;

    private AvSettings(int mainType, boolean isAudio) {
    private AvSettings(int mainType, boolean isAudio, boolean isPassthrough) {
        super(TunerUtils.getFilterSubtype(
                mainType,
                isAudio
                        ? TunerConstants.FILTER_SUBTYPE_AUDIO
                        : TunerConstants.FILTER_SUBTYPE_VIDEO));
        mIsPassthrough = isPassthrough;
    }

    /**
     * Checks whether it's passthrough.
     */
    public boolean isPassthrough() {
        return mIsPassthrough;
    }

    /**
     * Creates a builder for {@link AvSettings}.
     *
     * @param context the context of the caller.
     * @param mainType the filter main type.
     * @param isAudio {@code true} if it's audio settings; {@code false} if it's video settings.
     */
    @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
    @NonNull
    public static Builder builder(
            @NonNull Context context, @FilterType int mainType, boolean isAudio) {
        TunerUtils.checkTunerPermission(context);
        return new Builder(mainType, isAudio);
    }

    /**
     * Builder for {@link AvSettings}.
     */
    public static class Builder extends Settings.Builder<Builder> {
        private final boolean mIsAudio;
        private boolean mIsPassthrough;

        private Builder(int mainType, boolean isAudio) {
            super(mainType);
            mIsAudio = isAudio;
        }

        /**
         * Sets whether it's passthrough.
         */
        @NonNull
        public Builder setPassthrough(boolean isPassthrough) {
            mIsPassthrough = isPassthrough;
            return this;
        }

        /**
         * Builds a {@link AvSettings} object.
         */
        @NonNull
        public AvSettings build() {
            return new AvSettings(mMainType, mIsAudio, mIsPassthrough);
        }

        @Override
        Builder self() {
            return this;
        }
    }
}
+60 −2
Original line number Diff line number Diff line
@@ -16,17 +16,75 @@

package android.media.tv.tuner.filter;

import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.content.Context;
import android.media.tv.tuner.TunerConstants;
import android.media.tv.tuner.TunerUtils;
import android.media.tv.tuner.filter.FilterConfiguration.FilterType;

/**
 * Filter Settings for a Download.
 * @hide
 */
public class DownloadSettings extends Settings {
    private int mDownloadId;
    private final int mDownloadId;

    public DownloadSettings(int mainType) {
    private DownloadSettings(int mainType, int downloadId) {
        super(TunerUtils.getFilterSubtype(mainType, TunerConstants.FILTER_SUBTYPE_DOWNLOAD));
        mDownloadId = downloadId;
    }

    /**
     * Gets download ID.
     */
    public int getDownloadId() {
        return mDownloadId;
    }

    /**
     * Creates a builder for {@link DownloadSettings}.
     *
     * @param context the context of the caller.
     * @param mainType the filter main type.
     */
    @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
    @NonNull
    public static Builder builder(@NonNull Context context, @FilterType int mainType) {
        TunerUtils.checkTunerPermission(context);
        return new Builder(mainType);
    }

    /**
     * Builder for {@link DownloadSettings}.
     */
    public static class Builder extends Settings.Builder<Builder> {
        private int mDownloadId;

        private Builder(int mainType) {
            super(mainType);
        }

        /**
         * Sets download ID.
         */
        @NonNull
        public Builder setDownloadId(int downloadId) {
            mDownloadId = downloadId;
            return this;
        }

        /**
         * Builds a {@link DownloadSettings} object.
         */
        @NonNull
        public DownloadSettings build() {
            return new DownloadSettings(mMainType, mDownloadId);
        }

        @Override
        Builder self() {
            return this;
        }
    }
}
+49 −1
Original line number Diff line number Diff line
@@ -33,7 +33,8 @@ import java.lang.annotation.RetentionPolicy;
public abstract class FilterConfiguration {

    /** @hide */
    @IntDef({FILTER_TYPE_TS, FILTER_TYPE_MMTP, FILTER_TYPE_IP, FILTER_TYPE_TLV, FILTER_TYPE_ALP})
    @IntDef(prefix = "FILTER_TYPE_", value =
            {FILTER_TYPE_TS, FILTER_TYPE_MMTP, FILTER_TYPE_IP, FILTER_TYPE_TLV, FILTER_TYPE_ALP})
    @Retention(RetentionPolicy.SOURCE)
    public @interface FilterType {}

@@ -58,6 +59,30 @@ public abstract class FilterConfiguration {
     */
    public static final int FILTER_TYPE_ALP = Constants.DemuxFilterMainType.ALP;


    /** @hide */
    @IntDef(prefix = "PACKET_TYPE_", value =
            {PACKET_TYPE_IPV4, PACKET_TYPE_COMPRESSED, PACKET_TYPE_SIGNALING})
    @Retention(RetentionPolicy.SOURCE)
    public @interface PacketType {}

    /**
     * IP v4 packet type.
     * @hide
     */
    public static final int PACKET_TYPE_IPV4 = 0;
    /**
     * Compressed packet type.
     * @hide
     */
    public static final int PACKET_TYPE_COMPRESSED = 2;
    /**
     * Signaling packet type.
     * @hide
     */
    public static final int PACKET_TYPE_SIGNALING = 4;


    @Nullable
    /* package */ final Settings mSettings;

@@ -77,4 +102,27 @@ public abstract class FilterConfiguration {
    public Settings getSettings() {
        return mSettings;
    }

    /**
     * Builder for {@link FilterConfiguration}.
     *
     * @param <T> The subclass to be built.
     * @hide
     */
    public abstract static class Builder<T extends Builder<T>> {
        /* package */ Settings mSettings;

        /* package */ Builder() {
        }

        /**
         * Sets filter settings.
         */
        @Nullable
        public T setFrequency(Settings settings) {
            mSettings = settings;
            return self();
        }
        /* package */ abstract T self();
    }
}
Loading