From 0c9470cec23a62876c398bc6ab9ac7e1588e2bba Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Thu, 19 Jul 2018 18:03:48 -0700 Subject: [PATCH] Restore __ANDROID_API__ guards for camera/media headers Partial revert of "Add __INTRODUCED_IN to audio/camera/media headers.", commit 85a41536a4885b12120ddafb4d0b3fee8a8613b6. Restore the API guards where they used to exist. I *could* add __ANDROID_API__ around only the function declarations, which is what the versioner would do, but the function declarations are mixed up with the types and constants, so I'd need to add a bunch of __ANDROID_API__ checks or reorganize the headers. NdkMediaFormat.h and AAudio.h still have __INTRODUCED_IN symbols that aren't guarded by __ANDROID_API__. Maybe those files should be reorganized so they don't alternate between APIs so much. Test: builds Bug: http://b/111668906 Change-Id: I757a6097f7840ea50e2fc92db7defef493097672 --- camera/ndk/include/camera/NdkCameraCaptureSession.h | 7 +++++++ camera/ndk/include/camera/NdkCameraDevice.h | 8 ++++++++ camera/ndk/include/camera/NdkCameraError.h | 4 ++++ camera/ndk/include/camera/NdkCameraManager.h | 4 ++++ camera/ndk/include/camera/NdkCameraMetadata.h | 4 ++++ camera/ndk/include/camera/NdkCameraMetadataTags.h | 5 +++++ camera/ndk/include/camera/NdkCaptureRequest.h | 8 ++++++++ media/ndk/include/media/NdkImage.h | 8 ++++++++ media/ndk/include/media/NdkImageReader.h | 8 ++++++++ media/ndk/include/media/NdkMediaCodec.h | 12 ++++++++++++ media/ndk/include/media/NdkMediaCrypto.h | 4 ++++ media/ndk/include/media/NdkMediaDataSource.h | 4 ++++ media/ndk/include/media/NdkMediaDrm.h | 4 ++++ media/ndk/include/media/NdkMediaExtractor.h | 12 ++++++++++++ media/ndk/include/media/NdkMediaFormat.h | 6 ++++++ media/ndk/include/media/NdkMediaMuxer.h | 4 ++++ 16 files changed, 102 insertions(+) diff --git a/camera/ndk/include/camera/NdkCameraCaptureSession.h b/camera/ndk/include/camera/NdkCameraCaptureSession.h index 9bf8247b95..5e0db60c17 100644 --- a/camera/ndk/include/camera/NdkCameraCaptureSession.h +++ b/camera/ndk/include/camera/NdkCameraCaptureSession.h @@ -45,6 +45,8 @@ __BEGIN_DECLS +#if __ANDROID_API__ >= 24 + /** * ACameraCaptureSession is an opaque type that manages frame captures of a camera device. * @@ -591,6 +593,10 @@ camera_status_t ACameraCaptureSession_stopRepeating(ACameraCaptureSession* sessi camera_status_t ACameraCaptureSession_abortCaptures(ACameraCaptureSession* session) __INTRODUCED_IN(24); +#endif /* __ANDROID_API__ >= 24 */ + +#if __ANDROID_API__ >= 28 + typedef struct ACaptureSessionOutput ACaptureSessionOutput; /** @@ -635,6 +641,7 @@ typedef struct ACaptureSessionOutput ACaptureSessionOutput; */ camera_status_t ACameraCaptureSession_updateSharedOutput(ACameraCaptureSession* session, ACaptureSessionOutput* output) __INTRODUCED_IN(28); +#endif /* __ANDROID_API__ >= 28 */ __END_DECLS diff --git a/camera/ndk/include/camera/NdkCameraDevice.h b/camera/ndk/include/camera/NdkCameraDevice.h index bdd27f9942..7c13b34a82 100644 --- a/camera/ndk/include/camera/NdkCameraDevice.h +++ b/camera/ndk/include/camera/NdkCameraDevice.h @@ -44,6 +44,8 @@ __BEGIN_DECLS +#if __ANDROID_API__ >= 24 + /** * ACameraDevice is opaque type that provides access to a camera device. * @@ -666,6 +668,10 @@ camera_status_t ACameraDevice_createCaptureSession( const ACameraCaptureSession_stateCallbacks* callbacks, /*out*/ACameraCaptureSession** session) __INTRODUCED_IN(24); +#endif /* __ANDROID_API__ >= 24 */ + +#if __ANDROID_API__ >= 28 + /** * Create a shared ACaptureSessionOutput object. * @@ -757,6 +763,8 @@ camera_status_t ACameraDevice_createCaptureSessionWithSessionParameters( const ACameraCaptureSession_stateCallbacks* callbacks, /*out*/ACameraCaptureSession** session) __INTRODUCED_IN(28); +#endif /* __ANDROID_API__ >= 28 */ + __END_DECLS #endif /* _NDK_CAMERA_DEVICE_H */ diff --git a/camera/ndk/include/camera/NdkCameraError.h b/camera/ndk/include/camera/NdkCameraError.h index e19ce362f4..6b5815502b 100644 --- a/camera/ndk/include/camera/NdkCameraError.h +++ b/camera/ndk/include/camera/NdkCameraError.h @@ -40,6 +40,8 @@ __BEGIN_DECLS +#if __ANDROID_API__ >= 24 + typedef enum { ACAMERA_OK = 0, @@ -130,6 +132,8 @@ typedef enum { ACAMERA_ERROR_PERMISSION_DENIED = ACAMERA_ERROR_BASE - 13, } camera_status_t; +#endif /* __ANDROID_API__ >= 24 */ + __END_DECLS #endif /* _NDK_CAMERA_ERROR_H */ diff --git a/camera/ndk/include/camera/NdkCameraManager.h b/camera/ndk/include/camera/NdkCameraManager.h index df102f25aa..ea76738806 100644 --- a/camera/ndk/include/camera/NdkCameraManager.h +++ b/camera/ndk/include/camera/NdkCameraManager.h @@ -44,6 +44,8 @@ __BEGIN_DECLS +#if __ANDROID_API__ >= 24 + /** * ACameraManager is opaque type that provides access to camera service. * @@ -274,6 +276,8 @@ camera_status_t ACameraManager_openCamera( ACameraDevice_StateCallbacks* callback, /*out*/ACameraDevice** device) __INTRODUCED_IN(24); +#endif /* __ANDROID_API__ >= 24 */ + __END_DECLS #endif /* _NDK_CAMERA_MANAGER_H */ diff --git a/camera/ndk/include/camera/NdkCameraMetadata.h b/camera/ndk/include/camera/NdkCameraMetadata.h index 2078da7d31..611e270e56 100644 --- a/camera/ndk/include/camera/NdkCameraMetadata.h +++ b/camera/ndk/include/camera/NdkCameraMetadata.h @@ -44,6 +44,8 @@ __BEGIN_DECLS +#if __ANDROID_API__ >= 24 + /** * ACameraMetadata is opaque type that provides access to read-only camera metadata like camera * characteristics (via {@link ACameraManager_getCameraCharacteristics}) or capture results (via @@ -229,6 +231,8 @@ ACameraMetadata* ACameraMetadata_copy(const ACameraMetadata* src) __INTRODUCED_I */ void ACameraMetadata_free(ACameraMetadata* metadata) __INTRODUCED_IN(24); +#endif /* __ANDROID_API__ >= 24 */ + __END_DECLS #endif /* _NDK_CAMERA_METADATA_H */ diff --git a/camera/ndk/include/camera/NdkCameraMetadataTags.h b/camera/ndk/include/camera/NdkCameraMetadataTags.h index bd854694fc..05010060e4 100644 --- a/camera/ndk/include/camera/NdkCameraMetadataTags.h +++ b/camera/ndk/include/camera/NdkCameraMetadataTags.h @@ -40,6 +40,8 @@ __BEGIN_DECLS +#if __ANDROID_API__ >= 24 + typedef enum acamera_metadata_section { ACAMERA_COLOR_CORRECTION, ACAMERA_CONTROL, @@ -7894,6 +7896,9 @@ typedef enum acamera_metadata_enum_acamera_distortion_correction_mode { } acamera_metadata_enum_android_distortion_correction_mode_t; + +#endif /* __ANDROID_API__ >= 24 */ + __END_DECLS #endif /* _NDK_CAMERA_METADATA_TAGS_H */ diff --git a/camera/ndk/include/camera/NdkCaptureRequest.h b/camera/ndk/include/camera/NdkCaptureRequest.h index 2fb5d12c7b..5340e76044 100644 --- a/camera/ndk/include/camera/NdkCaptureRequest.h +++ b/camera/ndk/include/camera/NdkCaptureRequest.h @@ -44,6 +44,8 @@ __BEGIN_DECLS +#if __ANDROID_API__ >= 24 + // Container for output targets typedef struct ACameraOutputTargets ACameraOutputTargets; @@ -302,6 +304,10 @@ camera_status_t ACaptureRequest_setEntry_rational( */ void ACaptureRequest_free(ACaptureRequest* request) __INTRODUCED_IN(24); +#endif /* __ANDROID_API__ >= 24 */ + +#if __ANDROID_API__ >= 28 + /** * Associate an arbitrary user context pointer to the {@link ACaptureRequest} * @@ -350,6 +356,8 @@ camera_status_t ACaptureRequest_getUserContext( */ ACaptureRequest* ACaptureRequest_copy(const ACaptureRequest* src) __INTRODUCED_IN(28); +#endif /* __ANDROID_API__ >= 28 */ + __END_DECLS #endif /* _NDK_CAPTURE_REQUEST_H */ diff --git a/media/ndk/include/media/NdkImage.h b/media/ndk/include/media/NdkImage.h index 38e12e32bf..5562e82cfd 100644 --- a/media/ndk/include/media/NdkImage.h +++ b/media/ndk/include/media/NdkImage.h @@ -516,6 +516,8 @@ typedef struct AImageCropRect { int32_t bottom; } AImageCropRect; +#if __ANDROID_API__ >= 24 + /** * Return the image back the the system and delete the AImage object from memory. * @@ -712,6 +714,10 @@ media_status_t AImage_getPlaneData( const AImage* image, int planeIdx, /*out*/uint8_t** data, /*out*/int* dataLength) __INTRODUCED_IN(24); +#endif /* __ANDROID_API__ >= 24 */ + +#if __ANDROID_API__ >= 26 + /** * Return the image back the the system and delete the AImage object from memory asynchronously. * @@ -756,6 +762,8 @@ void AImage_deleteAsync(AImage* image, int releaseFenceFd) __INTRODUCED_IN(26); */ media_status_t AImage_getHardwareBuffer(const AImage* image, /*out*/AHardwareBuffer** buffer) __INTRODUCED_IN(26); +#endif /* __ANDROID_API__ >= 26 */ + __END_DECLS #endif //_NDK_IMAGE_H diff --git a/media/ndk/include/media/NdkImageReader.h b/media/ndk/include/media/NdkImageReader.h index eb1a44aaa2..68de17687e 100644 --- a/media/ndk/include/media/NdkImageReader.h +++ b/media/ndk/include/media/NdkImageReader.h @@ -50,6 +50,8 @@ __BEGIN_DECLS */ typedef struct AImageReader AImageReader; +#if __ANDROID_API__ >= 24 + /** * Create a new reader for images of the desired size and format. * @@ -296,6 +298,10 @@ typedef struct AImageReader_ImageListener { media_status_t AImageReader_setImageListener( AImageReader* reader, AImageReader_ImageListener* listener) __INTRODUCED_IN(24); +#endif /* __ANDROID_API__ >= 24 */ + +#if __ANDROID_API__ >= 26 + /** * AImageReader constructor similar to {@link AImageReader_new} that takes an additional parameter * for the consumer usage. All other parameters and the return values are identical to those passed @@ -455,6 +461,8 @@ typedef struct AImageReader_BufferRemovedListener { media_status_t AImageReader_setBufferRemovedListener( AImageReader* reader, AImageReader_BufferRemovedListener* listener) __INTRODUCED_IN(26); +#endif /* __ANDROID_API__ >= 26 */ + __END_DECLS #endif //_NDK_IMAGE_READER_H diff --git a/media/ndk/include/media/NdkMediaCodec.h b/media/ndk/include/media/NdkMediaCodec.h index b329b39d75..9dc120df29 100644 --- a/media/ndk/include/media/NdkMediaCodec.h +++ b/media/ndk/include/media/NdkMediaCodec.h @@ -121,6 +121,8 @@ struct AMediaCodecOnAsyncNotifyCallback { AMediaCodecOnAsyncError onAsyncError; }; +#if __ANDROID_API__ >= 21 + /** * Create codec by name. Use this if you know the exact codec you want to use. * When configuring, you will need to specify whether to use the codec as an @@ -274,6 +276,8 @@ media_status_t AMediaCodec_setOutputSurface(AMediaCodec*, ANativeWindow* surface media_status_t AMediaCodec_releaseOutputBufferAtTime( AMediaCodec *mData, size_t idx, int64_t timestampNs) __INTRODUCED_IN(21); +#if __ANDROID_API__ >= 26 + /** * Creates a Surface that can be used as the input to encoder, in place of input buffers * @@ -344,6 +348,10 @@ media_status_t AMediaCodec_setParameters( */ media_status_t AMediaCodec_signalEndOfInputStream(AMediaCodec *mData) __INTRODUCED_IN(26); +#endif /* __ANDROID_API__ >= 26 */ + +#if __ANDROID_API__ >= 28 + /** * Get the component name. If the codec was created by createDecoderByType * or createEncoderByType, what component is chosen is not known beforehand. @@ -405,6 +413,8 @@ bool AMediaCodecActionCode_isRecoverable(int32_t actionCode) __INTRODUCED_IN(28) */ bool AMediaCodecActionCode_isTransient(int32_t actionCode) __INTRODUCED_IN(28); +#endif /* __ANDROID_API__ >= 28 */ + typedef enum { AMEDIACODECRYPTOINFO_MODE_CLEAR = 0, AMEDIACODECRYPTOINFO_MODE_AES_CTR = 1, @@ -483,6 +493,8 @@ media_status_t AMediaCodecCryptoInfo_getClearBytes(AMediaCodecCryptoInfo*, size_ */ media_status_t AMediaCodecCryptoInfo_getEncryptedBytes(AMediaCodecCryptoInfo*, size_t *dst) __INTRODUCED_IN(21); +#endif /* __ANDROID_API__ >= 21 */ + __END_DECLS #endif //_NDK_MEDIA_CODEC_H diff --git a/media/ndk/include/media/NdkMediaCrypto.h b/media/ndk/include/media/NdkMediaCrypto.h index b673adc6a4..bcdf9a004d 100644 --- a/media/ndk/include/media/NdkMediaCrypto.h +++ b/media/ndk/include/media/NdkMediaCrypto.h @@ -47,6 +47,8 @@ typedef struct AMediaCrypto AMediaCrypto; typedef uint8_t AMediaUUID[16]; +#if __ANDROID_API__ >= 21 + bool AMediaCrypto_isCryptoSchemeSupported(const AMediaUUID uuid) __INTRODUCED_IN(21); bool AMediaCrypto_requiresSecureDecoderComponent(const char *mime) __INTRODUCED_IN(21); @@ -55,6 +57,8 @@ AMediaCrypto* AMediaCrypto_new(const AMediaUUID uuid, const void *initData, size void AMediaCrypto_delete(AMediaCrypto* crypto) __INTRODUCED_IN(21); +#endif /* __ANDROID_API__ >= 21 */ + __END_DECLS #endif // _NDK_MEDIA_CRYPTO_H diff --git a/media/ndk/include/media/NdkMediaDataSource.h b/media/ndk/include/media/NdkMediaDataSource.h index 3a4373c8a1..ea5ba0c43b 100644 --- a/media/ndk/include/media/NdkMediaDataSource.h +++ b/media/ndk/include/media/NdkMediaDataSource.h @@ -38,6 +38,8 @@ __BEGIN_DECLS struct AMediaDataSource; typedef struct AMediaDataSource AMediaDataSource; +#if __ANDROID_API__ >= 28 + /* * AMediaDataSource's callbacks will be invoked on an implementation-defined thread * or thread pool. No guarantees are provided about which thread(s) will be used for @@ -133,6 +135,8 @@ void AMediaDataSource_setClose( AMediaDataSource*, AMediaDataSourceClose) __INTRODUCED_IN(28); +#endif /*__ANDROID_API__ >= 28 */ + __END_DECLS #endif // _NDK_MEDIA_DATASOURCE_H diff --git a/media/ndk/include/media/NdkMediaDrm.h b/media/ndk/include/media/NdkMediaDrm.h index 24c0d6d86f..020968173b 100644 --- a/media/ndk/include/media/NdkMediaDrm.h +++ b/media/ndk/include/media/NdkMediaDrm.h @@ -87,6 +87,8 @@ typedef enum AMediaDrmEventType { typedef void (*AMediaDrmEventListener)(AMediaDrm *, const AMediaDrmSessionId *sessionId, AMediaDrmEventType eventType, int extra, const uint8_t *data, size_t dataSize); +#if __ANDROID_API__ >= 21 + /** * Query if the given scheme identified by its UUID is supported on this device, and * whether the drm plugin is able to handle the media container format specified by mimeType. @@ -459,6 +461,8 @@ media_status_t AMediaDrm_verify(AMediaDrm *, const AMediaDrmSessionId *sessionId const char *macAlgorithm, uint8_t *keyId, const uint8_t *message, size_t messageSize, const uint8_t *signature, size_t signatureSize) __INTRODUCED_IN(21); +#endif /* __ANDROID_API__ >= 21 */ + __END_DECLS #endif //_NDK_MEDIA_DRM_H diff --git a/media/ndk/include/media/NdkMediaExtractor.h b/media/ndk/include/media/NdkMediaExtractor.h index 9f6089182c..6a1796f977 100644 --- a/media/ndk/include/media/NdkMediaExtractor.h +++ b/media/ndk/include/media/NdkMediaExtractor.h @@ -49,6 +49,8 @@ __BEGIN_DECLS struct AMediaExtractor; typedef struct AMediaExtractor AMediaExtractor; +#if __ANDROID_API__ >= 21 + /** * Create new media extractor */ @@ -72,12 +74,16 @@ media_status_t AMediaExtractor_setDataSource(AMediaExtractor*, const char *location) __INTRODUCED_IN(21); // TODO support headers +#if __ANDROID_API__ >= 28 + /** * Set the custom data source implementation from which the extractor will read. */ media_status_t AMediaExtractor_setDataSourceCustom(AMediaExtractor*, AMediaDataSource *src) __INTRODUCED_IN(28); +#endif /* __ANDROID_API__ >= 28 */ + /** * Return the number of tracks in the previously specified media file */ @@ -173,6 +179,8 @@ enum { AMEDIAEXTRACTOR_SAMPLE_FLAG_ENCRYPTED = 2, }; +#if __ANDROID_API__ >= 28 + /** * Returns the format of the extractor. The caller must free the returned format * using AMediaFormat_delete(format). @@ -219,6 +227,10 @@ int64_t AMediaExtractor_getCachedDuration(AMediaExtractor *) __INTRODUCED_IN(28) media_status_t AMediaExtractor_getSampleFormat(AMediaExtractor *ex, AMediaFormat *fmt) __INTRODUCED_IN(28); +#endif /* __ANDROID_API__ >= 28 */ + +#endif /* __ANDROID_API__ >= 21 */ + __END_DECLS #endif // _NDK_MEDIA_EXTRACTOR_H diff --git a/media/ndk/include/media/NdkMediaFormat.h b/media/ndk/include/media/NdkMediaFormat.h index 8f37f7b0b3..5f7804d8a8 100644 --- a/media/ndk/include/media/NdkMediaFormat.h +++ b/media/ndk/include/media/NdkMediaFormat.h @@ -46,6 +46,8 @@ __BEGIN_DECLS struct AMediaFormat; typedef struct AMediaFormat AMediaFormat; +#if __ANDROID_API__ >= 21 + AMediaFormat *AMediaFormat_new() __INTRODUCED_IN(21); media_status_t AMediaFormat_delete(AMediaFormat*) __INTRODUCED_IN(21); @@ -155,6 +157,9 @@ extern const char* AMEDIAFORMAT_KEY_TRACK_ID __INTRODUCED_IN(28); extern const char* AMEDIAFORMAT_KEY_TRACK_INDEX __INTRODUCED_IN(28); extern const char* AMEDIAFORMAT_KEY_WIDTH __INTRODUCED_IN(21); +#endif /* __ANDROID_API__ >= 21 */ + +#if __ANDROID_API__ >= 28 bool AMediaFormat_getDouble(AMediaFormat*, const char *name, double *out) __INTRODUCED_IN(28); bool AMediaFormat_getRect(AMediaFormat*, const char *name, int32_t *left, int32_t *top, int32_t *right, int32_t *bottom) __INTRODUCED_IN(28); @@ -163,6 +168,7 @@ void AMediaFormat_setDouble(AMediaFormat*, const char* name, double value) __INT void AMediaFormat_setSize(AMediaFormat*, const char* name, size_t value) __INTRODUCED_IN(28); void AMediaFormat_setRect(AMediaFormat*, const char* name, int32_t left, int32_t top, int32_t right, int32_t bottom) __INTRODUCED_IN(28); +#endif /* __ANDROID_API__ >= 28 */ __END_DECLS diff --git a/media/ndk/include/media/NdkMediaMuxer.h b/media/ndk/include/media/NdkMediaMuxer.h index 75c70edba8..7393867c41 100644 --- a/media/ndk/include/media/NdkMediaMuxer.h +++ b/media/ndk/include/media/NdkMediaMuxer.h @@ -53,6 +53,8 @@ typedef enum { AMEDIAMUXER_OUTPUT_FORMAT_WEBM = 1, } OutputFormat; +#if __ANDROID_API__ >= 21 + /** * Create new media muxer */ @@ -121,6 +123,8 @@ media_status_t AMediaMuxer_writeSampleData(AMediaMuxer *muxer, size_t trackIdx, const uint8_t *data, const AMediaCodecBufferInfo *info) __INTRODUCED_IN(21); +#endif /* __ANDROID_API__ >= 21 */ + __END_DECLS #endif // _NDK_MEDIA_MUXER_H