android_image_reader_abi.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_ANDROID_ANDROID_IMAGE_READER_ABI_H_
  5. #define BASE_ANDROID_ANDROID_IMAGE_READER_ABI_H_
  6. // Minimal binary interface definitions for AImage,AImageReader
  7. // and ANativeWindow based on include/media/NdkImage.h,
  8. // include/media/NdkImageReader.h and include/android/native_window_jni.h
  9. // from the Android NDK for platform level 26+. This is only
  10. // intended for use from the AndroidImageReader wrapper for building
  11. // without NDK platform level support, it is not a general-use header
  12. // and is not complete. Only the functions/data types which
  13. // are currently needed by media/gpu/android/image_reader_gl_owner.h are
  14. // included in this ABI
  15. //
  16. // Please refer to the API documentation for details:
  17. // https://developer.android.com/ndk/reference/group/media (AIMage and
  18. // AImageReader)
  19. // https://developer.android.com/ndk/reference/group/native-activity
  20. // (ANativeWindow)
  21. #include <android/native_window.h>
  22. #include <media/NdkMediaError.h>
  23. #include <jni.h>
  24. #include <stdint.h>
  25. // Use "C" linkage to match the original header file. This isn't strictly
  26. // required since the file is not declaring global functions, but the types
  27. // should remain in the global namespace for compatibility, and it's a reminder
  28. // that forward declarations elsewhere should use "extern "C" to avoid
  29. // namespace issues.
  30. extern "C" {
  31. // For AImage
  32. typedef struct AHardwareBuffer AHardwareBuffer;
  33. typedef struct AImage AImage;
  34. typedef struct AImageCropRect {
  35. int32_t left;
  36. int32_t top;
  37. int32_t right;
  38. int32_t bottom;
  39. } AImageCropRect;
  40. enum AIMAGE_FORMATS {
  41. AIMAGE_FORMAT_YUV_420_888 = 0x23,
  42. AIMAGE_FORMAT_PRIVATE = 0x22
  43. };
  44. using pAImage_delete = void (*)(AImage* image);
  45. using pAImage_deleteAsync = void (*)(AImage* image, int releaseFenceFd);
  46. using pAImage_getHardwareBuffer = media_status_t (*)(const AImage* image,
  47. AHardwareBuffer** buffer);
  48. using pAImage_getWidth = media_status_t (*)(const AImage* image,
  49. int32_t* width);
  50. using pAImage_getHeight = media_status_t (*)(const AImage* image,
  51. int32_t* height);
  52. using pAImage_getCropRect = media_status_t (*)(const AImage* image,
  53. AImageCropRect* rect);
  54. // For AImageReader
  55. typedef struct AImageReader AImageReader;
  56. typedef void (*AImageReader_ImageCallback)(void* context, AImageReader* reader);
  57. typedef struct AImageReader_ImageListener {
  58. void* context;
  59. AImageReader_ImageCallback onImageAvailable;
  60. } AImageReader_ImageListener;
  61. using pAImageReader_newWithUsage = media_status_t (*)(int32_t width,
  62. int32_t height,
  63. int32_t format,
  64. uint64_t usage,
  65. int32_t maxImages,
  66. AImageReader** reader);
  67. using pAImageReader_setImageListener =
  68. media_status_t (*)(AImageReader* reader,
  69. AImageReader_ImageListener* listener);
  70. using pAImageReader_delete = void (*)(AImageReader* reader);
  71. using pAImageReader_getWindow = media_status_t (*)(AImageReader* reader,
  72. ANativeWindow** window);
  73. using pAImageReader_getFormat = media_status_t (*)(const AImageReader* reader,
  74. int32_t* format);
  75. using pAImageReader_acquireLatestImageAsync =
  76. media_status_t (*)(AImageReader* reader,
  77. AImage** image,
  78. int* acquireFenceFd);
  79. using pAImageReader_acquireNextImageAsync =
  80. media_status_t (*)(AImageReader* reader,
  81. AImage** image,
  82. int* acquireFenceFd);
  83. // For ANativeWindow
  84. using pANativeWindow_toSurface = jobject (*)(JNIEnv* env,
  85. ANativeWindow* window);
  86. } // extern "C"
  87. #endif // BASE_ANDROID_ANDROID_IMAGE_READER_ABI_H_