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

Commit 82530bf9 authored by shubang's avatar shubang
Browse files

Tuner API: Remove superclass Dvr

Bug: 149785982
Test: make;
Change-Id: I39721db253ec1212c5cd9774c8466afdf47799d2
parent 0fcf7f11
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -4944,30 +4944,32 @@ package android.media.tv.tuner {
package android.media.tv.tuner.dvr {
  public class Dvr implements java.lang.AutoCloseable {
    ctor protected Dvr(int);
  public class DvrPlayback implements java.lang.AutoCloseable {
    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 long read(long);
    method public long read(@NonNull byte[], long, long);
    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 {
  public class DvrRecorder implements java.lang.AutoCloseable {
    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();
    method public long write(long);
    method public long write(@NonNull byte[], long, long);
  }
+20 −0
Original line number Diff line number Diff line
@@ -18,11 +18,13 @@ package android.media.tv.tuner;

import android.annotation.BytesLong;
import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.content.Context;
import android.hardware.tv.tuner.V1_0.Constants;
import android.media.tv.TvInputService;
import android.media.tv.tuner.TunerConstants.Result;
import android.media.tv.tuner.dvr.DvrPlayback;
@@ -45,6 +47,8 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executor;
@@ -67,6 +71,22 @@ public class Tuner implements AutoCloseable {
    private static final int MSG_ON_FILTER_STATUS = 3;
    private static final int MSG_ON_LNB_EVENT = 4;

    /** @hide */
    @IntDef(prefix = "DVR_TYPE_", value = {DVR_TYPE_RECORD, DVR_TYPE_PLAYBACK})
    @Retention(RetentionPolicy.SOURCE)
    public @interface DvrType {}

    /**
     * DVR for recording.
     * @hide
     */
    public static final int DVR_TYPE_RECORD = Constants.DvrType.RECORD;
    /**
     * DVR for playback of recorded programs.
     * @hide
     */
    public static final int DVR_TYPE_PLAYBACK = Constants.DvrType.PLAYBACK;

    static {
        System.loadLibrary("media_tv_tuner");
        nativeInit();
+0 −159
Original line number 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.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.hardware.tv.tuner.V1_0.Constants;
import android.media.tv.tuner.TunerConstants.Result;
import android.media.tv.tuner.filter.Filter;
import android.os.ParcelFileDescriptor;

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

/**
 * Digital Video Record (DVR) interface provides record control on Demux's output buffer and
 * playback control on Demux's input buffer.
 *
 * @hide
 */
@SystemApi
public class Dvr implements AutoCloseable {

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

    /**
     * DVR for recording.
     */
    public static final int TYPE_RECORD = Constants.DvrType.RECORD;
    /**
     * DVR for playback of recorded programs.
     */
    public static final int TYPE_PLAYBACK = Constants.DvrType.PLAYBACK;


    final int mType;
    long mNativeContext;

    private native int nativeAttachFilter(Filter filter);
    private native int nativeDetachFilter(Filter filter);
    private native int nativeConfigureDvr(DvrSettings settings);
    private native int nativeStartDvr();
    private native int nativeStopDvr();
    private native int nativeFlushDvr();
    private native int nativeClose();
    private native void nativeSetFileDescriptor(int fd);

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

    /**
     * Attaches a filter to DVR interface for recording.
     *
     * @param filter the filter to be attached.
     * @return result status of the operation.
     */
    @Result
    public int attachFilter(@NonNull Filter filter) {
        return nativeAttachFilter(filter);
    }

    /**
     * Detaches a filter from DVR interface.
     *
     * @param filter the filter to be detached.
     * @return result status of the operation.
     */
    @Result
    public int detachFilter(@NonNull Filter filter) {
        return nativeDetachFilter(filter);
    }

    /**
     * Configures the DVR.
     *
     * @param settings the settings of the DVR interface.
     * @return result status of the operation.
     */
    @Result
    public int configure(@NonNull DvrSettings settings) {
        return nativeConfigureDvr(settings);
    }

    /**
     * Starts DVR.
     *
     * <p>Starts consuming playback data or producing data for recording.
     *
     * @return result status of the operation.
     */
    @Result
    public int start() {
        return nativeStartDvr();
    }

    /**
     * Stops DVR.
     *
     * <p>Stops consuming playback data or producing data for recording.
     *
     * @return result status of the operation.
     */
    @Result
    public int stop() {
        return nativeStopDvr();
    }

    /**
     * Flushed DVR data.
     *
     * <p>The data in DVR buffer is cleared.
     *
     * @return result status of the operation.
     */
    @Result
    public int flush() {
        return nativeFlushDvr();
    }

    /**
     * Closes the DVR instance to release resources.
     */
    public void close() {
        nativeClose();
    }

    /**
     * Sets file descriptor to read/write data.
     *
     * @param fd the file descriptor to read/write data.
     */
    public void setFileDescriptor(@NonNull ParcelFileDescriptor fd) {
        nativeSetFileDescriptor(fd.getFd());
    }

    @Type
    int getType() {
        return mType;
    }
}
+99 −3
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.hardware.tv.tuner.V1_0.Constants;
import android.media.tv.tuner.TunerConstants.Result;
import android.media.tv.tuner.filter.Filter;
import android.os.ParcelFileDescriptor;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -33,7 +36,7 @@ import java.lang.annotation.RetentionPolicy;
 * @hide
 */
@SystemApi
public class DvrPlayback extends Dvr {
public class DvrPlayback implements AutoCloseable {


    /** @hide */
@@ -66,16 +69,109 @@ public class DvrPlayback extends Dvr {
     */
    public static final int PLAYBACK_STATUS_FULL = Constants.PlaybackStatus.SPACE_FULL;

    long mNativeContext;


    private native int nativeAttachFilter(Filter filter);
    private native int nativeDetachFilter(Filter filter);
    private native int nativeConfigureDvr(DvrSettings settings);
    private native int nativeStartDvr();
    private native int nativeStopDvr();
    private native int nativeFlushDvr();
    private native int nativeClose();
    private native void nativeSetFileDescriptor(int fd);
    private native long nativeRead(long size);
    private native long nativeRead(byte[] bytes, long offset, long size);

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


    /**
     * Attaches a filter to DVR interface for recording.
     *
     * @param filter the filter to be attached.
     * @return result status of the operation.
     */
    @Result
    public int attachFilter(@NonNull Filter filter) {
        return nativeAttachFilter(filter);
    }

    /**
     * Detaches a filter from DVR interface.
     *
     * @param filter the filter to be detached.
     * @return result status of the operation.
     */
    @Result
    public int detachFilter(@NonNull Filter filter) {
        return nativeDetachFilter(filter);
    }

    /**
     * Configures the DVR.
     *
     * @param settings the settings of the DVR interface.
     * @return result status of the operation.
     */
    @Result
    public int configure(@NonNull DvrSettings settings) {
        return nativeConfigureDvr(settings);
    }

    /**
     * Starts DVR.
     *
     * <p>Starts consuming playback data or producing data for recording.
     *
     * @return result status of the operation.
     */
    @Result
    public int start() {
        return nativeStartDvr();
    }

    /**
     * Stops DVR.
     *
     * <p>Stops consuming playback data or producing data for recording.
     *
     * @return result status of the operation.
     */
    @Result
    public int stop() {
        return nativeStopDvr();
    }

    /**
     * Flushed DVR data.
     *
     * <p>The data in DVR buffer is cleared.
     *
     * @return result status of the operation.
     */
    @Result
    public int flush() {
        return nativeFlushDvr();
    }

    /**
     * Closes the DVR instance to release resources.
     */
    @Override
    public void close() {
        nativeClose();
    }

    /**
     * Sets file descriptor to read/write data.
     *
     * @param fd the file descriptor to read/write data.
     */
    public void setFileDescriptor(@NonNull ParcelFileDescriptor fd) {
        nativeSetFileDescriptor(fd.getFd());
    }

    /**
     * Reads data from the file for DVR playback.
     *
+101 −2
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ package android.media.tv.tuner.dvr;
import android.annotation.BytesLong;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.media.tv.tuner.TunerConstants.Result;
import android.media.tv.tuner.filter.Filter;
import android.os.ParcelFileDescriptor;

/**
 * Digital Video Record (DVR) recorder class which provides record control on Demux's output buffer.
@@ -26,12 +29,108 @@ import android.annotation.SystemApi;
 * @hide
 */
@SystemApi
public class DvrRecorder extends Dvr {
public class DvrRecorder implements AutoCloseable {
    long mNativeContext;

    private native int nativeAttachFilter(Filter filter);
    private native int nativeDetachFilter(Filter filter);
    private native int nativeConfigureDvr(DvrSettings settings);
    private native int nativeStartDvr();
    private native int nativeStopDvr();
    private native int nativeFlushDvr();
    private native int nativeClose();
    private native void nativeSetFileDescriptor(int fd);
    private native long nativeWrite(long size);
    private native long nativeWrite(byte[] bytes, long offset, long size);

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


    /**
     * Attaches a filter to DVR interface for recording.
     *
     * @param filter the filter to be attached.
     * @return result status of the operation.
     */
    @Result
    public int attachFilter(@NonNull Filter filter) {
        return nativeAttachFilter(filter);
    }

    /**
     * Detaches a filter from DVR interface.
     *
     * @param filter the filter to be detached.
     * @return result status of the operation.
     */
    @Result
    public int detachFilter(@NonNull Filter filter) {
        return nativeDetachFilter(filter);
    }

    /**
     * Configures the DVR.
     *
     * @param settings the settings of the DVR interface.
     * @return result status of the operation.
     */
    @Result
    public int configure(@NonNull DvrSettings settings) {
        return nativeConfigureDvr(settings);
    }

    /**
     * Starts DVR.
     *
     * <p>Starts consuming playback data or producing data for recording.
     *
     * @return result status of the operation.
     */
    @Result
    public int start() {
        return nativeStartDvr();
    }

    /**
     * Stops DVR.
     *
     * <p>Stops consuming playback data or producing data for recording.
     *
     * @return result status of the operation.
     */
    @Result
    public int stop() {
        return nativeStopDvr();
    }

    /**
     * Flushed DVR data.
     *
     * <p>The data in DVR buffer is cleared.
     *
     * @return result status of the operation.
     */
    @Result
    public int flush() {
        return nativeFlushDvr();
    }

    /**
     * Closes the DVR instance to release resources.
     */
    @Override
    public void close() {
        nativeClose();
    }

    /**
     * Sets file descriptor to read/write data.
     *
     * @param fd the file descriptor to read/write data.
     */
    public void setFileDescriptor(@NonNull ParcelFileDescriptor fd) {
        nativeSetFileDescriptor(fd.getFd());
    }

    /**
Loading