summaryrefslogtreecommitdiffstats
path: root/media/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'media/java/android')
-rw-r--r--media/java/android/media/MediaCodec.java24
-rw-r--r--media/java/android/media/MediaRecorder.java19
2 files changed, 33 insertions, 10 deletions
diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java
index d22cfda..f4a5bc3 100644
--- a/media/java/android/media/MediaCodec.java
+++ b/media/java/android/media/MediaCodec.java
@@ -681,12 +681,20 @@ final public class MediaCodec {
*/
@NonNull
public static Surface createPersistentInputSurface() {
- // TODO implement this
- return new PersistentSurface();
+ return native_createPersistentInputSurface();
}
static class PersistentSurface extends Surface {
- PersistentSurface() {}
+ @SuppressWarnings("unused")
+ PersistentSurface() {} // used by native
+
+ @Override
+ public void release() {
+ native_releasePersistentInputSurface(this);
+ super.release();
+ }
+
+ private long mPersistentObject;
};
/**
@@ -700,9 +708,17 @@ final public class MediaCodec {
* {@link #createPersistentInputSurface}.
*/
public void usePersistentInputSurface(@NonNull Surface surface) {
- throw new IllegalArgumentException("not implemented");
+ if (!(surface instanceof PersistentSurface)) {
+ throw new IllegalArgumentException("not a PersistentSurface");
+ }
+ native_usePersistentInputSurface(surface);
}
+ @NonNull
+ private static native final PersistentSurface native_createPersistentInputSurface();
+ private static native final void native_releasePersistentInputSurface(@NonNull Surface surface);
+ private native final void native_usePersistentInputSurface(@NonNull Surface surface);
+
private native final void native_setCallback(@Nullable Callback cb);
private native final void native_configure(
diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java
index 1b054cc..a2f596b 100644
--- a/media/java/android/media/MediaRecorder.java
+++ b/media/java/android/media/MediaRecorder.java
@@ -16,6 +16,7 @@
package android.media;
+import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.app.ActivityThread;
import android.app.Application;
@@ -142,22 +143,28 @@ public class MediaRecorder
/**
* Configures the recorder to use a persistent surface when using SURFACE video source.
- * <p> May only be called after {@link #prepare} in lieu of {@link #getSurface}.
- * Frames rendered to the Surface before {@link #start} will be discarded.</p>
+ * <p> May only be called before {@link #prepare}. If called, {@link #getSurface} should
+ * not be used and will throw IllegalStateException. Frames rendered to the Surface
+ * before {@link #start} will be discarded.</p>
* @param surface a persistent input surface created by
* {@link MediaCodec#createPersistentInputSurface}
- * @throws IllegalStateException if it is called before {@link #prepare}, after
- * {@link #stop}, or is called when VideoSource is not set to SURFACE.
+ * @throws IllegalStateException if it is called after {@link #prepare} and before
+ * {@link #stop}.
* @throws IllegalArgumentException if the surface was not created by
* {@link MediaCodec#createPersistentInputSurface}.
* @see MediaCodec#createPersistentInputSurface
* @see MediaRecorder.VideoSource
*/
- public void usePersistentSurface(Surface surface) {
- throw new IllegalArgumentException("not implemented");
+ public void usePersistentSurface(@NonNull Surface surface) {
+ if (!(surface instanceof MediaCodec.PersistentSurface)) {
+ throw new IllegalArgumentException("not a PersistentSurface");
+ }
+ native_usePersistentSurface(surface);
}
+ private native final void native_usePersistentSurface(@NonNull Surface surface);
+
/**
* Sets a Surface to show a preview of recorded media (video). Calls this
* before prepare() to make sure that the desirable preview display is