transcoding: use builtin_available macro instead of __ANDROID_APEX__

This is a follow-up of Id0c23d90b69de3cd5ddfd73de6ebcf7154cb2b1d.
The uses of the Android S APIs are correctly with __builtin_available
guard.

Bug: 177365934
Test: m
Change-Id: Ib70e7c5128449c3e1abe1df79ca20e22bd7af781
diff --git a/media/libmediatranscoding/transcoder/VideoTrackTranscoder.cpp b/media/libmediatranscoding/transcoder/VideoTrackTranscoder.cpp
index 21d60ea..45e25ac 100644
--- a/media/libmediatranscoding/transcoder/VideoTrackTranscoder.cpp
+++ b/media/libmediatranscoding/transcoder/VideoTrackTranscoder.cpp
@@ -260,12 +260,15 @@
         return AMEDIA_ERROR_INVALID_PARAMETER;
     }
 
-#if !defined(__ANDROID_APEX__)
-    // TODO(jiyong): replace this #ifdef with a __builtin_available check.
-    AMediaCodec* encoder = AMediaCodec_createEncoderByTypeForClient(destinationMime, mPid, mUid);
-#else
-    AMediaCodec* encoder = AMediaCodec_createEncoderByType(destinationMime);
-#endif
+    // TODO: replace __ANDROID_API_FUTURE__with 31 when it's official (b/178144708)
+    #define __TRANSCODING_MIN_API__ __ANDROID_API_FUTURE__
+
+    AMediaCodec* encoder;
+    if (__builtin_available(android __TRANSCODING_MIN_API__, *)) {
+        encoder = AMediaCodec_createEncoderByTypeForClient(destinationMime, mPid, mUid);
+    } else {
+        encoder = AMediaCodec_createEncoderByType(destinationMime);
+    }
     if (encoder == nullptr) {
         LOG(ERROR) << "Unable to create encoder for type " << destinationMime;
         return AMEDIA_ERROR_UNSUPPORTED;
@@ -295,12 +298,11 @@
         return AMEDIA_ERROR_INVALID_PARAMETER;
     }
 
-#if !defined(__ANDROID_APEX__)
-    // TODO(jiyong): replace this #ifdef with a __builtin_available check.
-    mDecoder = AMediaCodec_createDecoderByTypeForClient(sourceMime, mPid, mUid);
-#else
-    mDecoder = AMediaCodec_createDecoderByType(sourceMime);
-#endif
+    if (__builtin_available(android __TRANSCODING_MIN_API__, *)) {
+        mDecoder = AMediaCodec_createDecoderByTypeForClient(sourceMime, mPid, mUid);
+    } else {
+        mDecoder = AMediaCodec_createDecoderByType(sourceMime);
+    }
     if (mDecoder == nullptr) {
         LOG(ERROR) << "Unable to create decoder for type " << sourceMime;
         return AMEDIA_ERROR_UNSUPPORTED;