Merge "Revert "Complete FilterConfiguration getters and builders""
This commit is contained in:
@@ -124,34 +124,6 @@ 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.
|
||||
*
|
||||
|
||||
@@ -16,123 +16,20 @@
|
||||
|
||||
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 {
|
||||
/** @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 {}
|
||||
private int mPacketType;
|
||||
private int mLengthType;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
private final int mPacketType;
|
||||
private final int mLengthType;
|
||||
|
||||
public AlpFilterConfiguration(Settings settings, int packetType, int lengthType) {
|
||||
public AlpFilterConfiguration(Settings settings) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,84 +16,21 @@
|
||||
|
||||
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 final boolean mIsPassthrough;
|
||||
private boolean mIsPassthrough;
|
||||
|
||||
private AvSettings(int mainType, boolean isAudio, boolean isPassthrough) {
|
||||
private AvSettings(int mainType, boolean isAudio) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,75 +16,17 @@
|
||||
|
||||
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 final int mDownloadId;
|
||||
private int mDownloadId;
|
||||
|
||||
private DownloadSettings(int mainType, int downloadId) {
|
||||
public DownloadSettings(int mainType) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
public abstract class FilterConfiguration {
|
||||
|
||||
/** @hide */
|
||||
@IntDef(prefix = "FILTER_TYPE_", value =
|
||||
{FILTER_TYPE_TS, FILTER_TYPE_MMTP, FILTER_TYPE_IP, FILTER_TYPE_TLV, FILTER_TYPE_ALP})
|
||||
@IntDef({FILTER_TYPE_TS, FILTER_TYPE_MMTP, FILTER_TYPE_IP, FILTER_TYPE_TLV, FILTER_TYPE_ALP})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface FilterType {}
|
||||
|
||||
@@ -59,30 +58,6 @@ 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;
|
||||
|
||||
@@ -102,27 +77,4 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,152 +16,23 @@
|
||||
|
||||
package android.media.tv.tuner.filter;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.Size;
|
||||
import android.content.Context;
|
||||
import android.media.tv.tuner.TunerUtils;
|
||||
|
||||
/**
|
||||
* Filter configuration for a IP filter.
|
||||
* @hide
|
||||
*/
|
||||
public class IpFilterConfiguration extends FilterConfiguration {
|
||||
private final byte[] mSrcIpAddress;
|
||||
private final byte[] mDstIpAddress;
|
||||
private final int mSrcPort;
|
||||
private final int mDstPort;
|
||||
private final boolean mPassthrough;
|
||||
private byte[] mSrcIpAddress;
|
||||
private byte[] mDstIpAddress;
|
||||
private int mSrcPort;
|
||||
private int mDstPort;
|
||||
private boolean mPassthrough;
|
||||
|
||||
public IpFilterConfiguration(Settings settings, byte[] srcAddr, byte[] dstAddr, int srcPort,
|
||||
int dstPort, boolean passthrough) {
|
||||
public IpFilterConfiguration(Settings settings) {
|
||||
super(settings);
|
||||
mSrcIpAddress = srcAddr;
|
||||
mDstIpAddress = dstAddr;
|
||||
mSrcPort = srcPort;
|
||||
mDstPort = dstPort;
|
||||
mPassthrough = passthrough;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return FilterConfiguration.FILTER_TYPE_IP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets source IP address.
|
||||
*/
|
||||
@Size(min = 4, max = 16)
|
||||
public byte[] getSrcIpAddress() {
|
||||
return mSrcIpAddress;
|
||||
}
|
||||
/**
|
||||
* Gets destination IP address.
|
||||
*/
|
||||
@Size(min = 4, max = 16)
|
||||
public byte[] getDstIpAddress() {
|
||||
return mDstIpAddress;
|
||||
}
|
||||
/**
|
||||
* Gets source port.
|
||||
*/
|
||||
public int getSrcPort() {
|
||||
return mSrcPort;
|
||||
}
|
||||
/**
|
||||
* Gets destination port.
|
||||
*/
|
||||
public int getDstPort() {
|
||||
return mDstPort;
|
||||
}
|
||||
/**
|
||||
* Checks whether the filter is passthrough.
|
||||
*
|
||||
* @return {@code true} if the data from IP subtype go to next filter directly;
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
public boolean isPassthrough() {
|
||||
return mPassthrough;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a builder for {@link IpFilterConfiguration}.
|
||||
*
|
||||
* @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 IpFilterConfiguration}.
|
||||
*/
|
||||
public static class Builder extends FilterConfiguration.Builder<Builder> {
|
||||
private byte[] mSrcIpAddress;
|
||||
private byte[] mDstIpAddress;
|
||||
private int mSrcPort;
|
||||
private int mDstPort;
|
||||
private boolean mPassthrough;
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets source IP address.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setSrcIpAddress(byte[] srcIpAddress) {
|
||||
mSrcIpAddress = srcIpAddress;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets destination IP address.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setDstIpAddress(byte[] dstIpAddress) {
|
||||
mDstIpAddress = dstIpAddress;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets source port.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setSrcPort(int srcPort) {
|
||||
mSrcPort = srcPort;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets destination port.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setDstPort(int dstPort) {
|
||||
mDstPort = dstPort;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets passthrough.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setPassthrough(boolean passthrough) {
|
||||
mPassthrough = passthrough;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a {@link IpFilterConfiguration} object.
|
||||
*/
|
||||
@NonNull
|
||||
public IpFilterConfiguration build() {
|
||||
return new IpFilterConfiguration(
|
||||
mSettings, mSrcIpAddress, mDstIpAddress, mSrcPort, mDstPort, mPassthrough);
|
||||
}
|
||||
|
||||
@Override
|
||||
Builder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,78 +16,19 @@
|
||||
|
||||
package android.media.tv.tuner.filter;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.content.Context;
|
||||
import android.media.tv.tuner.TunerUtils;
|
||||
|
||||
/**
|
||||
* Filter configuration for a MMTP filter.
|
||||
* @hide
|
||||
*/
|
||||
public class MmtpFilterConfiguration extends FilterConfiguration {
|
||||
private final int mMmtpPid;
|
||||
private int mMmtpPid;
|
||||
|
||||
public MmtpFilterConfiguration(Settings settings, int mmtpPid) {
|
||||
public MmtpFilterConfiguration(Settings settings) {
|
||||
super(settings);
|
||||
mMmtpPid = mmtpPid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return FilterConfiguration.FILTER_TYPE_MMTP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets MMPT PID.
|
||||
*
|
||||
* <p>Packet ID is used to specify packets in MMTP.
|
||||
*/
|
||||
public int getMmtpPid() {
|
||||
return mMmtpPid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a builder for {@link IpFilterConfiguration}.
|
||||
*
|
||||
* @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 IpFilterConfiguration}.
|
||||
*/
|
||||
public static class Builder extends FilterConfiguration.Builder<Builder> {
|
||||
private int mMmtpPid;
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets MMPT PID.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setMmtpPid(int mmtpPid) {
|
||||
mMmtpPid = mmtpPid;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a {@link IpFilterConfiguration} object.
|
||||
*/
|
||||
@NonNull
|
||||
public MmtpFilterConfiguration build() {
|
||||
return new MmtpFilterConfiguration(mSettings, mMmtpPid);
|
||||
}
|
||||
|
||||
@Override
|
||||
Builder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,96 +16,18 @@
|
||||
|
||||
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.TunerConstants.IndexType;
|
||||
import android.media.tv.tuner.TunerUtils;
|
||||
import android.media.tv.tuner.filter.FilterConfiguration.FilterType;
|
||||
|
||||
/**
|
||||
* The Settings for the record in DVR.
|
||||
* @hide
|
||||
*/
|
||||
public class RecordSettings extends Settings {
|
||||
private final int mIndexType;
|
||||
private final int mIndexMask;
|
||||
private int mIndexType;
|
||||
private int mIndexMask;
|
||||
|
||||
private RecordSettings(int mainType, int indexType, int indexMask) {
|
||||
public RecordSettings(int mainType) {
|
||||
super(TunerUtils.getFilterSubtype(mainType, TunerConstants.FILTER_SUBTYPE_RECORD));
|
||||
mIndexType = indexType;
|
||||
mIndexMask = indexMask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets index type.
|
||||
*/
|
||||
@IndexType
|
||||
public int getIndexType() {
|
||||
return mIndexType;
|
||||
}
|
||||
/**
|
||||
* Gets index mask.
|
||||
*/
|
||||
@TsRecordEvent.IndexMask
|
||||
public int getIndexMask() {
|
||||
return mIndexMask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a builder for {@link RecordSettings}.
|
||||
*
|
||||
* @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 RecordSettings}.
|
||||
*/
|
||||
public static class Builder extends Settings.Builder<Builder> {
|
||||
private int mIndexType;
|
||||
private int mIndexMask;
|
||||
|
||||
private Builder(int mainType) {
|
||||
super(mainType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets index type.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setIndexType(@IndexType int indexType) {
|
||||
mIndexType = indexType;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets index mask.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setIndexMask(@TsRecordEvent.IndexMask int indexMask) {
|
||||
mIndexMask = indexMask;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a {@link RecordSettings} object.
|
||||
*/
|
||||
@NonNull
|
||||
public RecordSettings build() {
|
||||
return new RecordSettings(mMainType, mIndexType, mIndexMask);
|
||||
}
|
||||
|
||||
@Override
|
||||
Builder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,116 +16,18 @@
|
||||
|
||||
package android.media.tv.tuner.filter;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.content.Context;
|
||||
import android.media.tv.tuner.TunerUtils;
|
||||
import android.media.tv.tuner.filter.FilterConfiguration.FilterType;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bits Settings for Section Filters.
|
||||
* Bits Settings for Section Filter.
|
||||
* @hide
|
||||
*/
|
||||
public class SectionSettingsWithSectionBits extends SectionSettings {
|
||||
private final byte[] mFilter;
|
||||
private final byte[] mMask;
|
||||
private final byte[] mMode;
|
||||
private List<Byte> mFilter;
|
||||
private List<Byte> mMask;
|
||||
private List<Byte> mMode;
|
||||
|
||||
|
||||
private SectionSettingsWithSectionBits(int mainType, byte[] filter, byte[] mask, byte[] mode) {
|
||||
private SectionSettingsWithSectionBits(int mainType) {
|
||||
super(mainType);
|
||||
mFilter = filter;
|
||||
mMask = mask;
|
||||
mMode = mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bytes configured for Section Filter
|
||||
*/
|
||||
public byte[] getFilterBytes() {
|
||||
return mFilter;
|
||||
}
|
||||
/**
|
||||
* Gets bit mask.
|
||||
*
|
||||
* <p>The bits in the bytes are used for filtering.
|
||||
*/
|
||||
public byte[] getMask() {
|
||||
return mMask;
|
||||
}
|
||||
/**
|
||||
* Gets mode.
|
||||
*
|
||||
* <p>Do positive match at the bit position of the configured bytes when the bit at same
|
||||
* position of the mode is 0.
|
||||
* <p>Do negative match at the bit position of the configured bytes when the bit at same
|
||||
* position of the mode is 1.
|
||||
*/
|
||||
public byte[] getMode() {
|
||||
return mMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a builder for {@link SectionSettingsWithSectionBits}.
|
||||
*
|
||||
* @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 SectionSettingsWithSectionBits}.
|
||||
*/
|
||||
public static class Builder extends Settings.Builder<Builder> {
|
||||
private byte[] mFilter;
|
||||
private byte[] mMask;
|
||||
private byte[] mMode;
|
||||
|
||||
private Builder(int mainType) {
|
||||
super(mainType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets filter bytes.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setFilter(byte[] filter) {
|
||||
mFilter = filter;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets bit mask.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setMask(byte[] mask) {
|
||||
mMask = mask;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets mode.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setMode(byte[] mode) {
|
||||
mMode = mode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a {@link SectionSettingsWithSectionBits} object.
|
||||
*/
|
||||
@NonNull
|
||||
public SectionSettingsWithSectionBits build() {
|
||||
return new SectionSettingsWithSectionBits(mMainType, mFilter, mMask, mMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
Builder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,92 +16,15 @@
|
||||
|
||||
package android.media.tv.tuner.filter;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.content.Context;
|
||||
import android.media.tv.tuner.TunerUtils;
|
||||
import android.media.tv.tuner.filter.FilterConfiguration.FilterType;
|
||||
|
||||
/**
|
||||
* Table information for Section Filter.
|
||||
* @hide
|
||||
*/
|
||||
public class SectionSettingsWithTableInfo extends SectionSettings {
|
||||
private final int mTableId;
|
||||
private final int mVersion;
|
||||
private int mTableId;
|
||||
private int mVersion;
|
||||
|
||||
private SectionSettingsWithTableInfo(int mainType, int tableId, int version) {
|
||||
private SectionSettingsWithTableInfo(int mainType) {
|
||||
super(mainType);
|
||||
mTableId = tableId;
|
||||
mVersion = version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets table ID.
|
||||
*/
|
||||
public int getTableId() {
|
||||
return mTableId;
|
||||
}
|
||||
/**
|
||||
* Gets version.
|
||||
*/
|
||||
public int getVersion() {
|
||||
return mVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a builder for {@link SectionSettingsWithTableInfo}.
|
||||
*
|
||||
* @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 SectionSettingsWithTableInfo}.
|
||||
*/
|
||||
public static class Builder extends Settings.Builder<Builder> {
|
||||
private int mTableId;
|
||||
private int mVersion;
|
||||
|
||||
private Builder(int mainType) {
|
||||
super(mainType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets table ID.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setTableId(int tableId) {
|
||||
mTableId = tableId;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets version.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setVersion(int version) {
|
||||
mVersion = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a {@link SectionSettingsWithTableInfo} object.
|
||||
*/
|
||||
@NonNull
|
||||
public SectionSettingsWithTableInfo build() {
|
||||
return new SectionSettingsWithTableInfo(mMainType, mTableId, mVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
Builder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,20 +39,4 @@ public abstract class Settings {
|
||||
public int getType() {
|
||||
return mType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builder for {@link Settings}.
|
||||
*
|
||||
* @param <T> The subclass to be built.
|
||||
* @hide
|
||||
*/
|
||||
public abstract static class Builder<T extends Builder<T>> {
|
||||
/* package */ final int mMainType;
|
||||
|
||||
/* package */ Builder(int mainType) {
|
||||
mMainType = mainType;
|
||||
}
|
||||
/* package */ abstract T self();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,118 +16,21 @@
|
||||
|
||||
package android.media.tv.tuner.filter;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.content.Context;
|
||||
import android.media.tv.tuner.TunerUtils;
|
||||
|
||||
/**
|
||||
* Filter configuration for a TLV filter.
|
||||
* @hide
|
||||
*/
|
||||
public class TlvFilterConfiguration extends FilterConfiguration {
|
||||
private final int mPacketType;
|
||||
private final boolean mIsCompressedIpPacket;
|
||||
private final boolean mPassthrough;
|
||||
private int mPacketType;
|
||||
private boolean mIsCompressedIpPacket;
|
||||
private boolean mPassthrough;
|
||||
|
||||
public TlvFilterConfiguration(Settings settings, int packetType, boolean isCompressed,
|
||||
boolean passthrough) {
|
||||
public TlvFilterConfiguration(Settings settings) {
|
||||
super(settings);
|
||||
mPacketType = packetType;
|
||||
mIsCompressedIpPacket = isCompressed;
|
||||
mPassthrough = passthrough;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return FilterConfiguration.FILTER_TYPE_TLV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets packet type.
|
||||
*/
|
||||
@FilterConfiguration.PacketType
|
||||
public int getPacketType() {
|
||||
return mPacketType;
|
||||
}
|
||||
/**
|
||||
* Checks whether the data is compressed IP packet.
|
||||
*
|
||||
* @return {@code true} if the filtered data is compressed IP packet; {@code false} otherwise.
|
||||
*/
|
||||
public boolean isCompressedIpPacket() {
|
||||
return mIsCompressedIpPacket;
|
||||
}
|
||||
/**
|
||||
* Checks whether it's passthrough.
|
||||
*
|
||||
* @return {@code true} if the data from TLV subtype go to next filter directly;
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
public boolean isPassthrough() {
|
||||
return mPassthrough;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a builder for {@link TlvFilterConfiguration}.
|
||||
*
|
||||
* @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 TlvFilterConfiguration}.
|
||||
*/
|
||||
public static class Builder extends FilterConfiguration.Builder<Builder> {
|
||||
private int mPacketType;
|
||||
private boolean mIsCompressedIpPacket;
|
||||
private boolean mPassthrough;
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets packet type.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setPacketType(@FilterConfiguration.PacketType int packetType) {
|
||||
mPacketType = packetType;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets whether the data is compressed IP packet.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setIsCompressedIpPacket(boolean isCompressedIpPacket) {
|
||||
mIsCompressedIpPacket = isCompressedIpPacket;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets whether it's passthrough.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setPassthrough(boolean passthrough) {
|
||||
mPassthrough = passthrough;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a {@link TlvFilterConfiguration} object.
|
||||
*/
|
||||
@NonNull
|
||||
public TlvFilterConfiguration build() {
|
||||
return new TlvFilterConfiguration(
|
||||
mSettings, mPacketType, mIsCompressedIpPacket, mPassthrough);
|
||||
}
|
||||
|
||||
@Override
|
||||
Builder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user