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

Commit 90dd6749 authored by Hongguang's avatar Hongguang
Browse files

Add some new features to tuner.

*) Add DTS info to DemuxFilterMediaEvent.
*) Allow to ignore download Id in DemuxFilterDownloadSettings and put
download id into DemuxFilterDownloadEvent.
*) Change section data size 64 bits.
*) Support DvrPlayback seek.
*) Support FrontendStatus streamIdList.

Bug: 183583908
Bug: 183024067
Bug: 203181023
Bug: 198195793
Bug: 171540818
Test: atest android.media.tv.tuner.cts on AIDL and HILD HALs
Change-Id: I5872e5f042f5803c367cf7624dbefc31292fd7e9
parent 0451ef6f
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -6250,6 +6250,7 @@ package android.media.tv.tuner.dvr {
    method public int flush();
    method public long read(long);
    method public long read(@NonNull byte[], long, long);
    method public long seek(long);
    method public void setFileDescriptor(@NonNull android.os.ParcelFileDescriptor);
    method public int start();
    method public int stop();
@@ -6385,6 +6386,7 @@ package android.media.tv.tuner.filter {
  public class DownloadEvent extends android.media.tv.tuner.filter.FilterEvent {
    method public int getDataLength();
    method public int getDownloadId();
    method public int getItemFragmentIndex();
    method public int getItemId();
    method public int getLastItemFragmentIndex();
@@ -6394,11 +6396,13 @@ package android.media.tv.tuner.filter {
  public class DownloadSettings extends android.media.tv.tuner.filter.Settings {
    method @NonNull public static android.media.tv.tuner.filter.DownloadSettings.Builder builder(int);
    method public int getDownloadId();
    method public boolean useDownloadId();
  }
  public static class DownloadSettings.Builder {
    method @NonNull public android.media.tv.tuner.filter.DownloadSettings build();
    method @NonNull public android.media.tv.tuner.filter.DownloadSettings.Builder setDownloadId(int);
    method @NonNull public android.media.tv.tuner.filter.DownloadSettings.Builder setUseDownloadId(boolean);
  }
  public class Filter implements java.lang.AutoCloseable {
@@ -6497,12 +6501,14 @@ package android.media.tv.tuner.filter {
    method public long getAudioHandle();
    method public long getAvDataId();
    method public long getDataLength();
    method public long getDts();
    method @Nullable public android.media.tv.tuner.filter.AudioDescriptor getExtraMetaData();
    method @Nullable public android.media.MediaCodec.LinearBlock getLinearBlock();
    method @IntRange(from=0) public int getMpuSequenceNumber();
    method public long getOffset();
    method public long getPts();
    method public int getStreamId();
    method public boolean isDtsPresent();
    method public boolean isPrivateData();
    method public boolean isPtsPresent();
    method public boolean isSecureMemory();
@@ -6612,7 +6618,8 @@ package android.media.tv.tuner.filter {
  }
  public class SectionEvent extends android.media.tv.tuner.filter.FilterEvent {
    method public int getDataLength();
    method @Deprecated public int getDataLength();
    method public long getDataLengthLong();
    method public int getSectionNumber();
    method public int getTableId();
    method public int getVersion();
@@ -7344,6 +7351,7 @@ package android.media.tv.tuner.frontend {
    method public int getSignalStrength();
    method public int getSnr();
    method public int getSpectralInversion();
    method @NonNull public int[] getStreamIdList();
    method public int getSymbolRate();
    method @IntRange(from=0, to=65535) public int getSystemId();
    method public int getTransmissionMode();
@@ -7390,6 +7398,7 @@ package android.media.tv.tuner.frontend {
    field public static final int FRONTEND_STATUS_TYPE_SIGNAL_STRENGTH = 6; // 0x6
    field public static final int FRONTEND_STATUS_TYPE_SNR = 1; // 0x1
    field public static final int FRONTEND_STATUS_TYPE_SPECTRAL = 10; // 0xa
    field public static final int FRONTEND_STATUS_TYPE_STREAM_ID_LIST = 39; // 0x27
    field public static final int FRONTEND_STATUS_TYPE_SYMBOL_RATE = 7; // 0x7
    field public static final int FRONTEND_STATUS_TYPE_T2_SYSTEM_ID = 29; // 0x1d
    field public static final int FRONTEND_STATUS_TYPE_TRANSMISSION_MODE = 27; // 0x1b
+20 −8
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ public class DvrPlayback implements AutoCloseable {
    private native void nativeSetFileDescriptor(int fd);
    private native long nativeRead(long size);
    private native long nativeRead(byte[] bytes, long offset, long size);
    private native long nativeSeek(long pos);

    private DvrPlayback() {
        mUserId = Process.myUid();
@@ -243,7 +244,7 @@ public class DvrPlayback implements AutoCloseable {
     *
     * @param fd the file descriptor to read data.
     * @see #read(long)
     * @see #read(byte[], long, long)
     * @see #seek(long)
     */
    public void setFileDescriptor(@NonNull ParcelFileDescriptor fd) {
        nativeSetFileDescriptor(fd.getFd());
@@ -261,19 +262,30 @@ public class DvrPlayback implements AutoCloseable {
    }

    /**
     * Reads data from the buffer for DVR playback and copies to the given byte array.
     * Reads data from the buffer for DVR playback.
     *
     * @param bytes the byte array to store the data.
     * @param offset the index of the first byte in {@code bytes} to copy to.
     * @param buffer the byte array where DVR reads data from.
     * @param offset the index of the first byte in {@code buffer} to read.
     * @param size the maximum number of bytes to read.
     * @return the number of bytes read.
     */
    @BytesLong
    public long read(@NonNull byte[] bytes, @BytesLong long offset, @BytesLong long size) {
        if (size + offset > bytes.length) {
    public long read(@NonNull byte[] buffer, @BytesLong long offset, @BytesLong long size) {
        if (size + offset > buffer.length) {
            throw new ArrayIndexOutOfBoundsException(
                    "Array length=" + bytes.length + ", offset=" + offset + ", size=" + size);
                    "Array length=" + buffer.length + ", offset=" + offset + ", size=" + size);
        }
        return nativeRead(bytes, offset, size);
        return nativeRead(buffer, offset, size);
    }

    /**
     * Sets the file pointer offset of the file descriptor.
     *
     * @param pos the offset position, measured in bytes from the beginning of the file.
     * @return the new offset position.
     */
    @BytesLong
    public long seek(@BytesLong long pos) {
        return nativeSeek(pos);
    }
}
+6 −7
Original line number Diff line number Diff line
@@ -216,7 +216,6 @@ public class DvrRecorder implements AutoCloseable {
     *
     * @param fd the file descriptor to write data.
     * @see #write(long)
     * @see #write(byte[], long, long)
     */
    public void setFileDescriptor(@NonNull ParcelFileDescriptor fd) {
        nativeSetFileDescriptor(fd.getFd());
@@ -236,17 +235,17 @@ public class DvrRecorder implements AutoCloseable {
    /**
     * Writes recording data to buffer.
     *
     * @param bytes the byte array stores the data to be written to DVR.
     * @param offset the index of the first byte in {@code bytes} to be written to DVR.
     * @param buffer the byte array stores the data from DVR.
     * @param offset the index of the first byte in {@code buffer} to write the data from DVR.
     * @param size the maximum number of bytes to write.
     * @return the number of bytes written.
     */
    @BytesLong
    public long write(@NonNull byte[] bytes, @BytesLong long offset, @BytesLong long size) {
        if (size + offset > bytes.length) {
    public long write(@NonNull byte[] buffer, @BytesLong long offset, @BytesLong long size) {
        if (size + offset > buffer.length) {
            throw new ArrayIndexOutOfBoundsException(
                    "Array length=" + bytes.length + ", offset=" + offset + ", size=" + size);
                    "Array length=" + buffer.length + ", offset=" + offset + ", size=" + size);
        }
        return nativeWrite(bytes, offset, size);
        return nativeWrite(buffer, offset, size);
    }
}
+12 −2
Original line number Diff line number Diff line
@@ -27,15 +27,17 @@ import android.annotation.SystemApi;
@SystemApi
public class DownloadEvent extends FilterEvent {
    private final int mItemId;
    private final int mDownloadId;
    private final int mMpuSequenceNumber;
    private final int mItemFragmentIndex;
    private final int mLastItemFragmentIndex;
    private final int mDataLength;

    // This constructor is used by JNI code only
    private DownloadEvent(int itemId, int mpuSequenceNumber, int itemFragmentIndex,
    private DownloadEvent(int itemId, int downloadId, int mpuSequenceNumber, int itemFragmentIndex,
            int lastItemFragmentIndex, int dataLength) {
        mItemId = itemId;
        mDownloadId = downloadId;
        mMpuSequenceNumber = mpuSequenceNumber;
        mItemFragmentIndex = itemFragmentIndex;
        mLastItemFragmentIndex = lastItemFragmentIndex;
@@ -49,6 +51,15 @@ public class DownloadEvent extends FilterEvent {
        return mItemId;
    }

    /**
     * Gets download ID.
     *
     * <p>This query is only supported in Tuner 2.0 or higher version. Unsupported version will
     * return {@code -1}.
     * Use {@link TunerVersionChecker#getTunerVersion()} to get the version information.
     */
    public int getDownloadId() { return mDownloadId; }

    /**
     * Gets MPU sequence number of filtered data.
     */
@@ -80,4 +91,3 @@ public class DownloadEvent extends FilterEvent {
        return mDataLength;
    }
}
+33 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.media.tv.tuner.filter;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.media.tv.tuner.TunerUtils;
import android.media.tv.tuner.TunerVersionChecker;

/**
 * Filter Settings for a Download.
@@ -27,10 +28,12 @@ import android.media.tv.tuner.TunerUtils;
 */
@SystemApi
public class DownloadSettings extends Settings {
    private final boolean mUseDownloadId;
    private final int mDownloadId;

    private DownloadSettings(int mainType, int downloadId) {
    private DownloadSettings(int mainType, boolean useDownloadId, int downloadId) {
        super(TunerUtils.getFilterSubtype(mainType, Filter.SUBTYPE_DOWNLOAD));
        mUseDownloadId = useDownloadId;
        mDownloadId = downloadId;
    }

@@ -41,6 +44,15 @@ public class DownloadSettings extends Settings {
        return mDownloadId;
    }

    /**
     * Gets whether download ID is used.
     *
     * <p>This query is only supported in Tuner 2.0 or higher version. Unsupported version will
     * return {@code false}.
     * Use {@link TunerVersionChecker#getTunerVersion()} to get the version information.
     */
    public boolean useDownloadId() { return mUseDownloadId; }

    /**
     * Creates a builder for {@link DownloadSettings}.
     *
@@ -56,12 +68,31 @@ public class DownloadSettings extends Settings {
     */
    public static class Builder {
        private final int mMainType;
        private boolean mUseDownloadId = false;
        private int mDownloadId;

        private Builder(int mainType) {
            mMainType = mainType;
        }

        /**
         * Sets whether download ID is used or not.
         *
         * <p>This configuration is only supported in Tuner 2.0 or higher version. Unsupported
         * version will cause no-op. Use {@link TunerVersionChecker#getTunerVersion()} to get the
         * version information.
         *
         * <p>Default value is {@code false}.
         */
        @NonNull
        public Builder setUseDownloadId(boolean useDownloadId) {
            if (TunerVersionChecker.checkHigherOrEqualVersionTo(
                        TunerVersionChecker.TUNER_VERSION_2_0, "setUseDownloadId")) {
                mUseDownloadId = useDownloadId;
            }
            return this;
        }

        /**
         * Sets download ID.
         */
@@ -76,7 +107,7 @@ public class DownloadSettings extends Settings {
         */
        @NonNull
        public DownloadSettings build() {
            return new DownloadSettings(mMainType, mDownloadId);
            return new DownloadSettings(mMainType, mUseDownloadId, mDownloadId);
        }
    }
}
Loading