Merge "Tuner API: Remove superclass Dvr" into rvc-dev am: 1e1f821146

Change-Id: I1e03a22545ff547f1dd7416e3e54794da8a81c6c
This commit is contained in:
Automerger Merge Worker
2020-02-26 19:12:07 +00:00
6 changed files with 239 additions and 181 deletions

View File

@@ -4944,8 +4944,24 @@ 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 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 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);
@@ -4954,20 +4970,6 @@ package android.media.tv.tuner.dvr {
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);
}

View File

@@ -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();

View File

@@ -1,159 +0,0 @@
/*
* 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;
}
}

View File

@@ -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.
*

View File

@@ -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());
}
/**

View File

@@ -30,7 +30,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* DVR settings used to configure {@link Dvr}.
* DVR settings used to configure {@link DvrPlayback} and {@link DvrRecorder}.
*
* @hide
*/