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

Commit 2f6e9b48 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Mark Dvr class @SystemApi"

parents e21d279b c798780a
Loading
Loading
Loading
Loading
+38 −4
Original line number Original line Diff line number Diff line
@@ -4700,6 +4700,8 @@ package android.media.tv.tuner {
    ctor public Tuner(@NonNull android.content.Context);
    ctor public Tuner(@NonNull android.content.Context);
    method @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public void clearOnTuneEventListener();
    method @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public void clearOnTuneEventListener();
    method @Nullable @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public android.media.tv.tuner.Tuner.Descrambler openDescrambler();
    method @Nullable @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public android.media.tv.tuner.Tuner.Descrambler openDescrambler();
    method @Nullable @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public android.media.tv.tuner.dvr.DvrPlayback openDvrPlayback(long, @Nullable java.util.concurrent.Executor, @Nullable android.media.tv.tuner.dvr.OnPlaybackStatusChangedListener);
    method @Nullable @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public android.media.tv.tuner.dvr.DvrRecorder openDvrRecorder(long, @Nullable java.util.concurrent.Executor, @Nullable android.media.tv.tuner.dvr.OnRecordStatusChangedListener);
    method @Nullable @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public android.media.tv.tuner.filter.Filter openFilter(int, int, long, @Nullable java.util.concurrent.Executor, @Nullable android.media.tv.tuner.filter.FilterCallback);
    method @Nullable @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public android.media.tv.tuner.filter.Filter openFilter(int, int, long, @Nullable java.util.concurrent.Executor, @Nullable android.media.tv.tuner.filter.FilterCallback);
    method @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public void setOnTuneEventListener(@NonNull java.util.concurrent.Executor, @NonNull android.media.tv.tuner.frontend.OnTuneEventListener);
    method @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public void setOnTuneEventListener(@NonNull java.util.concurrent.Executor, @NonNull android.media.tv.tuner.frontend.OnTuneEventListener);
    method @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public int stopTune();
    method @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public int stopTune();
@@ -4723,6 +4725,34 @@ package android.media.tv.tuner {
package android.media.tv.tuner.dvr {
package android.media.tv.tuner.dvr {
  public class Dvr implements java.lang.AutoCloseable {
    ctor protected Dvr(int);
    method public int attachFilter(@NonNull android.media.tv.tuner.filter.Filter);
    method public void close();
    method public int configure(@NonNull android.media.tv.tuner.dvr.DvrSettings);
    method public int detachFilter(@NonNull android.media.tv.tuner.filter.Filter);
    method public int flush();
    method public void setFileDescriptor(@NonNull android.os.ParcelFileDescriptor);
    method public int start();
    method public int stop();
    field public static final int TYPE_PLAYBACK = 1; // 0x1
    field public static final int TYPE_RECORD = 0; // 0x0
  }
  public class DvrPlayback extends android.media.tv.tuner.dvr.Dvr {
    method public long read(long);
    method public long read(@NonNull byte[], long, long);
    field public static final int PLAYBACK_STATUS_ALMOST_EMPTY = 2; // 0x2
    field public static final int PLAYBACK_STATUS_ALMOST_FULL = 4; // 0x4
    field public static final int PLAYBACK_STATUS_EMPTY = 1; // 0x1
    field public static final int PLAYBACK_STATUS_FULL = 8; // 0x8
  }
  public class DvrRecorder extends android.media.tv.tuner.dvr.Dvr {
    method public long write(long);
    method public long write(@NonNull byte[], long, long);
  }
  public class DvrSettings {
  public class DvrSettings {
    method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public static android.media.tv.tuner.dvr.DvrSettings.Builder builder(@NonNull android.content.Context);
    method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public static android.media.tv.tuner.dvr.DvrSettings.Builder builder(@NonNull android.content.Context);
    method public int getDataFormat();
    method public int getDataFormat();
@@ -4730,13 +4760,10 @@ package android.media.tv.tuner.dvr {
    method public long getLowThreshold();
    method public long getLowThreshold();
    method public long getPacketSize();
    method public long getPacketSize();
    method public int getStatusMask();
    method public int getStatusMask();
    method public int getType();
    field public static final int DATA_FORMAT_ES = 2; // 0x2
    field public static final int DATA_FORMAT_ES = 2; // 0x2
    field public static final int DATA_FORMAT_PES = 1; // 0x1
    field public static final int DATA_FORMAT_PES = 1; // 0x1
    field public static final int DATA_FORMAT_SHV_TLV = 3; // 0x3
    field public static final int DATA_FORMAT_SHV_TLV = 3; // 0x3
    field public static final int DATA_FORMAT_TS = 0; // 0x0
    field public static final int DATA_FORMAT_TS = 0; // 0x0
    field public static final int TYPE_PLAYBACK = 1; // 0x1
    field public static final int TYPE_RECORD = 0; // 0x0
  }
  }
  public static final class DvrSettings.Builder {
  public static final class DvrSettings.Builder {
@@ -4747,7 +4774,14 @@ package android.media.tv.tuner.dvr {
    method @NonNull public android.media.tv.tuner.dvr.DvrSettings.Builder setLowThreshold(long);
    method @NonNull public android.media.tv.tuner.dvr.DvrSettings.Builder setLowThreshold(long);
    method @NonNull public android.media.tv.tuner.dvr.DvrSettings.Builder setPacketSize(long);
    method @NonNull public android.media.tv.tuner.dvr.DvrSettings.Builder setPacketSize(long);
    method @NonNull public android.media.tv.tuner.dvr.DvrSettings.Builder setStatusMask(int);
    method @NonNull public android.media.tv.tuner.dvr.DvrSettings.Builder setStatusMask(int);
    method @NonNull public android.media.tv.tuner.dvr.DvrSettings.Builder setType(int);
  }
  public interface OnPlaybackStatusChangedListener {
    method public void onPlaybackStatusChanged(int);
  }
  public interface OnRecordStatusChangedListener {
    method public void onRecordStatusChanged(int);
  }
  }
}
}
+34 −12
Original line number Original line Diff line number Diff line
@@ -24,9 +24,10 @@ import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemApi;
import android.content.Context;
import android.content.Context;
import android.media.tv.tuner.TunerConstants.Result;
import android.media.tv.tuner.TunerConstants.Result;
import android.media.tv.tuner.dvr.Dvr;
import android.media.tv.tuner.dvr.DvrPlayback;
import android.media.tv.tuner.dvr.DvrCallback;
import android.media.tv.tuner.dvr.DvrRecorder;
import android.media.tv.tuner.dvr.DvrSettings;
import android.media.tv.tuner.dvr.OnPlaybackStatusChangedListener;
import android.media.tv.tuner.dvr.OnRecordStatusChangedListener;
import android.media.tv.tuner.filter.Filter;
import android.media.tv.tuner.filter.Filter;
import android.media.tv.tuner.filter.Filter.Subtype;
import android.media.tv.tuner.filter.Filter.Subtype;
import android.media.tv.tuner.filter.Filter.Type;
import android.media.tv.tuner.filter.Filter.Type;
@@ -166,7 +167,8 @@ public final class Tuner implements AutoCloseable {


    private native Descrambler nativeOpenDescrambler();
    private native Descrambler nativeOpenDescrambler();


    private native Dvr nativeOpenDvr(int type, long bufferSize);
    private native DvrRecorder nativeOpenDvrRecorder(long bufferSize);
    private native DvrPlayback nativeOpenDvrPlayback(long bufferSize);


    private static native DemuxCapabilities nativeGetDemuxCapabilities();
    private static native DemuxCapabilities nativeGetDemuxCapabilities();


@@ -639,24 +641,44 @@ public final class Tuner implements AutoCloseable {
    }
    }


    /**
    /**
     * Open a DVR (Digital Video Record) instance.
     * Open a DVR (Digital Video Record) recorder instance.
     *
     *
     * @param type the DVR type to be opened.
     * @param bufferSize the buffer size of the output in bytes. It's used to hold output data of
     * @param bufferSize the buffer size of the output in bytes. It's used to hold output data of
     * the attached filters.
     * the attached filters.
     * @param executor the executor on which callback will be invoked. The default event handler
     * @param executor the executor on which callback will be invoked. The default event handler
     * executor is used if it's {@code null}.
     * executor is used if it's {@code null}.
     * @param cb the callback to receive notifications from DVR.
     * @param l the listener to receive notifications from DVR recorder.
     * @return the opened DVR object. {@code null} if the operation failed.
     * @return the opened DVR recorder object. {@code null} if the operation failed.
     */
    @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
    @Nullable
    public DvrRecorder openDvrRecorder(
            @BytesLong long bufferSize,
            @CallbackExecutor @Nullable Executor executor,
            @Nullable OnRecordStatusChangedListener l) {
        TunerUtils.checkTunerPermission(mContext);
        DvrRecorder dvr = nativeOpenDvrRecorder(bufferSize);
        return dvr;
    }

    /**
     * Open a DVR (Digital Video Record) playback instance.
     *
     *
     * @hide
     * @param bufferSize the buffer size of the output in bytes. It's used to hold output data of
     * the attached filters.
     * @param executor the executor on which callback will be invoked. The default event handler
     * executor is used if it's {@code null}.
     * @param l the listener to receive notifications from DVR recorder.
     * @return the opened DVR playback object. {@code null} if the operation failed.
     */
     */
    @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
    @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
    @Nullable
    @Nullable
    public Dvr openDvr(@DvrSettings.Type int type, @BytesLong long bufferSize,
    public DvrPlayback openDvrPlayback(
            @CallbackExecutor @Nullable Executor executor, DvrCallback cb) {
            @BytesLong long bufferSize,
            @CallbackExecutor @Nullable Executor executor,
            @Nullable OnPlaybackStatusChangedListener l) {
        TunerUtils.checkTunerPermission(mContext);
        TunerUtils.checkTunerPermission(mContext);
        Dvr dvr = nativeOpenDvr(type, bufferSize);
        DvrPlayback dvr = nativeOpenDvrPlayback(bufferSize);
        return dvr;
        return dvr;
    }
    }
}
}
+20 −82
Original line number Original line Diff line number Diff line
@@ -16,9 +16,9 @@


package android.media.tv.tuner.dvr;
package android.media.tv.tuner.dvr;


import android.annotation.BytesLong;
import android.annotation.IntDef;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.hardware.tv.tuner.V1_0.Constants;
import android.hardware.tv.tuner.V1_0.Constants;
import android.media.tv.tuner.TunerConstants.Result;
import android.media.tv.tuner.TunerConstants.Result;
import android.media.tv.tuner.filter.Filter;
import android.media.tv.tuner.filter.Filter;
@@ -33,40 +33,26 @@ import java.lang.annotation.RetentionPolicy;
 *
 *
 * @hide
 * @hide
 */
 */
public class Dvr {
@SystemApi
public class Dvr implements AutoCloseable {

    /** @hide */
    /** @hide */
    @IntDef(prefix = "TYPE_", value = {TYPE_RECORD, TYPE_PLAYBACK})
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = "PLAYBACK_STATUS_",
    public @interface Type {}
            value = {PLAYBACK_STATUS_EMPTY, PLAYBACK_STATUS_ALMOST_EMPTY,
                    PLAYBACK_STATUS_ALMOST_FULL, PLAYBACK_STATUS_FULL})
    @interface PlaybackStatus {}


    /**
    /**
     * The space of the playback is empty.
     * DVR for recording.
     */
    public static final int PLAYBACK_STATUS_EMPTY = Constants.PlaybackStatus.SPACE_EMPTY;
    /**
     * The space of the playback is almost empty.
     *
     * <p> the threshold is set in {@link DvrSettings}.
     */
    public static final int PLAYBACK_STATUS_ALMOST_EMPTY =
            Constants.PlaybackStatus.SPACE_ALMOST_EMPTY;
    /**
     * The space of the playback is almost full.
     *
     * <p> the threshold is set in {@link DvrSettings}.
     */
     */
    public static final int PLAYBACK_STATUS_ALMOST_FULL =
    public static final int TYPE_RECORD = Constants.DvrType.RECORD;
            Constants.PlaybackStatus.SPACE_ALMOST_FULL;
    /**
    /**
     * The space of the playback is full.
     * DVR for playback of recorded programs.
     */
     */
    public static final int PLAYBACK_STATUS_FULL = Constants.PlaybackStatus.SPACE_FULL;
    public static final int TYPE_PLAYBACK = Constants.DvrType.PLAYBACK;




    private long mNativeContext;
    final int mType;
    private DvrCallback mCallback;
    long mNativeContext;


    private native int nativeAttachFilter(Filter filter);
    private native int nativeAttachFilter(Filter filter);
    private native int nativeDetachFilter(Filter filter);
    private native int nativeDetachFilter(Filter filter);
@@ -76,12 +62,10 @@ public class Dvr {
    private native int nativeFlushDvr();
    private native int nativeFlushDvr();
    private native int nativeClose();
    private native int nativeClose();
    private native void nativeSetFileDescriptor(int fd);
    private native void nativeSetFileDescriptor(int fd);
    private native int nativeRead(long size);
    private native int nativeRead(byte[] bytes, long offset, long size);
    private native int nativeWrite(long size);
    private native int nativeWrite(byte[] bytes, long offset, long size);


    private Dvr() {}
    protected Dvr(int type) {
        mType = type;
    }


    /**
    /**
     * Attaches a filter to DVR interface for recording.
     * Attaches a filter to DVR interface for recording.
@@ -154,12 +138,9 @@ public class Dvr {


    /**
    /**
     * Closes the DVR instance to release resources.
     * Closes the DVR instance to release resources.
     *
     * @return result status of the operation.
     */
     */
    @Result
    public void close() {
    public int close() {
        nativeClose();
        return nativeClose();
    }
    }


    /**
    /**
@@ -171,51 +152,8 @@ public class Dvr {
        nativeSetFileDescriptor(fd.getFd());
        nativeSetFileDescriptor(fd.getFd());
    }
    }


    /**
    @Type
     * Reads data from the file for DVR playback.
    int getType() {
     *
        return mType;
     * @param size the maximum number of bytes to read.
     * @return the number of bytes read.
     */
    public int read(@BytesLong long size) {
        return nativeRead(size);
    }

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

    /**
     * Writes recording data to file.
     *
     * @param size the maximum number of bytes to write.
     * @return the number of bytes written.
     */
    public int write(@BytesLong long size) {
        return nativeWrite(size);
    }

    /**
     * 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 size the maximum number of bytes to write.
     * @return the number of bytes written.
     */
    public int write(@NonNull byte[] bytes, @BytesLong long offset, @BytesLong long size) {
        return nativeWrite(bytes, offset, size);
    }
    }
}
}
+106 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media.tv.tuner.dvr;

import android.annotation.BytesLong;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.hardware.tv.tuner.V1_0.Constants;

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

/**
 * Digital Video Record (DVR) class which provides playback control on Demux's input buffer.
 *
 * <p>It's used to play recorded programs.
 *
 * @hide
 */
@SystemApi
public class DvrPlayback extends Dvr {


    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = "PLAYBACK_STATUS_",
            value = {PLAYBACK_STATUS_EMPTY, PLAYBACK_STATUS_ALMOST_EMPTY,
                    PLAYBACK_STATUS_ALMOST_FULL, PLAYBACK_STATUS_FULL})
    @interface PlaybackStatus {}

    /**
     * The space of the playback is empty.
     */
    public static final int PLAYBACK_STATUS_EMPTY = Constants.PlaybackStatus.SPACE_EMPTY;
    /**
     * The space of the playback is almost empty.
     *
     * <p> the threshold is set in {@link DvrSettings}.
     */
    public static final int PLAYBACK_STATUS_ALMOST_EMPTY =
            Constants.PlaybackStatus.SPACE_ALMOST_EMPTY;
    /**
     * The space of the playback is almost full.
     *
     * <p> the threshold is set in {@link DvrSettings}.
     */
    public static final int PLAYBACK_STATUS_ALMOST_FULL =
            Constants.PlaybackStatus.SPACE_ALMOST_FULL;
    /**
     * The space of the playback is full.
     */
    public static final int PLAYBACK_STATUS_FULL = Constants.PlaybackStatus.SPACE_FULL;



    private native long nativeRead(long size);
    private native long nativeRead(byte[] bytes, long offset, long size);

    private DvrPlayback() {
        super(Dvr.TYPE_PLAYBACK);
    }


    /**
     * Reads data from the file for DVR playback.
     *
     * @param size the maximum number of bytes to read.
     * @return the number of bytes read.
     */
    @BytesLong
    public long read(@BytesLong long size) {
        return nativeRead(size);
    }

    /**
     * Reads data from the buffer for DVR playback and copies to the given byte array.
     *
     * @param bytes the byte array to store the data.
     * @param offset the index of the first byte in {@code bytes} to copy to.
     * @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) {
            throw new ArrayIndexOutOfBoundsException(
                    "Array length=" + bytes.length + ", offset=" + offset + ", size=" + size);
        }
        return nativeRead(bytes, offset, size);
    }
}
+60 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media.tv.tuner.dvr;

import android.annotation.BytesLong;
import android.annotation.NonNull;
import android.annotation.SystemApi;

/**
 * Digital Video Record (DVR) recorder class which provides record control on Demux's output buffer.
 *
 * @hide
 */
@SystemApi
public class DvrRecorder extends Dvr {
    private native long nativeWrite(long size);
    private native long nativeWrite(byte[] bytes, long offset, long size);

    private DvrRecorder() {
        super(Dvr.TYPE_RECORD);
    }

    /**
     * Writes recording data to file.
     *
     * @param size the maximum number of bytes to write.
     * @return the number of bytes written.
     */
    @BytesLong
    public long write(@BytesLong long size) {
        return nativeWrite(size);
    }

    /**
     * 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 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) {
        return nativeWrite(bytes, offset, size);
    }
}
Loading