Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -22757,6 +22757,7 @@ package android.media { method public abstract void close(); method public android.graphics.Rect getCropRect(); method public abstract int getFormat(); method public android.hardware.HardwareBuffer getHardwareBuffer(); method public abstract int getHeight(); method public abstract android.media.Image.Plane[] getPlanes(); method public abstract long getTimestamp(); media/java/android/media/Image.java +19 −0 Original line number Diff line number Diff line Loading @@ -19,7 +19,9 @@ package android.media; import java.nio.ByteBuffer; import java.lang.AutoCloseable; import android.annotation.Nullable; import android.graphics.Rect; import android.hardware.HardwareBuffer; /** * <p>A single complete image buffer to use with a media source such as a Loading Loading @@ -183,6 +185,23 @@ public abstract class Image implements AutoCloseable { */ public abstract long getTimestamp(); /** * Get the {@link android.hardware.HardwareBuffer HardwareBuffer} handle of the input image * intended for GPU and/or hardware access. * <p> * The returned {@link android.hardware.HardwareBuffer HardwareBuffer} shall not be used * after {@link Image#close Image.close()} has been called. * </p> * @return the HardwareBuffer associated with this Image or null if this Image doesn't support * this feature (e.g. {@link android.media.ImageWriter ImageWriter} or * {@link android.media.MediaCodec MediaCodec} don't). */ @Nullable public HardwareBuffer getHardwareBuffer() { throwISEIfImageIsInvalid(); return null; } /** * Set the timestamp associated with this frame. * <p> Loading media/java/android/media/ImageReader.java +7 −0 Original line number Diff line number Diff line Loading @@ -875,6 +875,12 @@ public class ImageReader implements AutoCloseable { return mTimestamp; } @Override public HardwareBuffer getHardwareBuffer() { throwISEIfImageIsInvalid(); return nativeGetHardwareBuffer(); } @Override public void setTimestamp(long timestampNs) { throwISEIfImageIsInvalid(); Loading Loading @@ -1017,6 +1023,7 @@ public class ImageReader implements AutoCloseable { private synchronized native int nativeGetWidth(); private synchronized native int nativeGetHeight(); private synchronized native int nativeGetFormat(int readerFormat); private synchronized native HardwareBuffer nativeGetHardwareBuffer(); } private synchronized native void nativeInit(Object weakSelf, int w, int h, Loading media/jni/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ cc_library_shared { shared_libs: [ "libandroid_runtime", "libnativehelper", "libnativewindow", "libutils", "libbinder", "libmedia", Loading media/jni/android_media_ImageReader.cpp +17 −4 Original line number Diff line number Diff line Loading @@ -33,11 +33,14 @@ #include <android_runtime/android_hardware_HardwareBuffer.h> #include <grallocusage/GrallocUsageConversion.h> #include <private/android/AHardwareBufferHelpers.h> #include <jni.h> #include <nativehelper/JNIHelp.h> #include <stdint.h> #include <inttypes.h> #include <android/hardware_buffer_jni.h> #define ANDROID_MEDIA_IMAGEREADER_CTX_JNI_ID "mNativeContext" #define ANDROID_MEDIA_SURFACEIMAGE_BUFFER_JNI_ID "mNativeBuffer" Loading Loading @@ -797,6 +800,14 @@ static jint Image_getFormat(JNIEnv* env, jobject thiz, jint readerFormat) } } static jobject Image_getHardwareBuffer(JNIEnv* env, jobject thiz) { BufferItem* buffer = Image_getBufferItem(env, thiz); AHardwareBuffer* b = AHardwareBuffer_from_GraphicBuffer(buffer->mGraphicBuffer.get()); // don't user the public AHardwareBuffer_toHardwareBuffer() because this would force us // to link against libandroid.so return android_hardware_HardwareBuffer_createFromAHardwareBuffer(env, b); } } // extern "C" // ---------------------------------------------------------------------------- Loading @@ -818,6 +829,8 @@ static const JNINativeMethod gImageMethods[] = { {"nativeGetWidth", "()I", (void*)Image_getWidth }, {"nativeGetHeight", "()I", (void*)Image_getHeight }, {"nativeGetFormat", "(I)I", (void*)Image_getFormat }, {"nativeGetHardwareBuffer", "()Landroid/hardware/HardwareBuffer;", (void*)Image_getHardwareBuffer }, }; int register_android_media_ImageReader(JNIEnv *env) { Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -22757,6 +22757,7 @@ package android.media { method public abstract void close(); method public android.graphics.Rect getCropRect(); method public abstract int getFormat(); method public android.hardware.HardwareBuffer getHardwareBuffer(); method public abstract int getHeight(); method public abstract android.media.Image.Plane[] getPlanes(); method public abstract long getTimestamp();
media/java/android/media/Image.java +19 −0 Original line number Diff line number Diff line Loading @@ -19,7 +19,9 @@ package android.media; import java.nio.ByteBuffer; import java.lang.AutoCloseable; import android.annotation.Nullable; import android.graphics.Rect; import android.hardware.HardwareBuffer; /** * <p>A single complete image buffer to use with a media source such as a Loading Loading @@ -183,6 +185,23 @@ public abstract class Image implements AutoCloseable { */ public abstract long getTimestamp(); /** * Get the {@link android.hardware.HardwareBuffer HardwareBuffer} handle of the input image * intended for GPU and/or hardware access. * <p> * The returned {@link android.hardware.HardwareBuffer HardwareBuffer} shall not be used * after {@link Image#close Image.close()} has been called. * </p> * @return the HardwareBuffer associated with this Image or null if this Image doesn't support * this feature (e.g. {@link android.media.ImageWriter ImageWriter} or * {@link android.media.MediaCodec MediaCodec} don't). */ @Nullable public HardwareBuffer getHardwareBuffer() { throwISEIfImageIsInvalid(); return null; } /** * Set the timestamp associated with this frame. * <p> Loading
media/java/android/media/ImageReader.java +7 −0 Original line number Diff line number Diff line Loading @@ -875,6 +875,12 @@ public class ImageReader implements AutoCloseable { return mTimestamp; } @Override public HardwareBuffer getHardwareBuffer() { throwISEIfImageIsInvalid(); return nativeGetHardwareBuffer(); } @Override public void setTimestamp(long timestampNs) { throwISEIfImageIsInvalid(); Loading Loading @@ -1017,6 +1023,7 @@ public class ImageReader implements AutoCloseable { private synchronized native int nativeGetWidth(); private synchronized native int nativeGetHeight(); private synchronized native int nativeGetFormat(int readerFormat); private synchronized native HardwareBuffer nativeGetHardwareBuffer(); } private synchronized native void nativeInit(Object weakSelf, int w, int h, Loading
media/jni/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ cc_library_shared { shared_libs: [ "libandroid_runtime", "libnativehelper", "libnativewindow", "libutils", "libbinder", "libmedia", Loading
media/jni/android_media_ImageReader.cpp +17 −4 Original line number Diff line number Diff line Loading @@ -33,11 +33,14 @@ #include <android_runtime/android_hardware_HardwareBuffer.h> #include <grallocusage/GrallocUsageConversion.h> #include <private/android/AHardwareBufferHelpers.h> #include <jni.h> #include <nativehelper/JNIHelp.h> #include <stdint.h> #include <inttypes.h> #include <android/hardware_buffer_jni.h> #define ANDROID_MEDIA_IMAGEREADER_CTX_JNI_ID "mNativeContext" #define ANDROID_MEDIA_SURFACEIMAGE_BUFFER_JNI_ID "mNativeBuffer" Loading Loading @@ -797,6 +800,14 @@ static jint Image_getFormat(JNIEnv* env, jobject thiz, jint readerFormat) } } static jobject Image_getHardwareBuffer(JNIEnv* env, jobject thiz) { BufferItem* buffer = Image_getBufferItem(env, thiz); AHardwareBuffer* b = AHardwareBuffer_from_GraphicBuffer(buffer->mGraphicBuffer.get()); // don't user the public AHardwareBuffer_toHardwareBuffer() because this would force us // to link against libandroid.so return android_hardware_HardwareBuffer_createFromAHardwareBuffer(env, b); } } // extern "C" // ---------------------------------------------------------------------------- Loading @@ -818,6 +829,8 @@ static const JNINativeMethod gImageMethods[] = { {"nativeGetWidth", "()I", (void*)Image_getWidth }, {"nativeGetHeight", "()I", (void*)Image_getHeight }, {"nativeGetFormat", "(I)I", (void*)Image_getFormat }, {"nativeGetHardwareBuffer", "()Landroid/hardware/HardwareBuffer;", (void*)Image_getHardwareBuffer }, }; int register_android_media_ImageReader(JNIEnv *env) { Loading