Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26ddfc59 authored by Jiyong Park's avatar Jiyong Park
Browse files

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
parent 5c504ee4
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -260,12 +260,15 @@ media_status_t VideoTrackTranscoder::configureDestinationFormat(
        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 @@ media_status_t VideoTrackTranscoder::configureDestinationFormat(
        return AMEDIA_ERROR_INVALID_PARAMETER;
    }

#if !defined(__ANDROID_APEX__)
    // TODO(jiyong): replace this #ifdef with a __builtin_available check.
    if (__builtin_available(android __TRANSCODING_MIN_API__, *)) {
        mDecoder = AMediaCodec_createDecoderByTypeForClient(sourceMime, mPid, mUid);
#else
    } else {
        mDecoder = AMediaCodec_createDecoderByType(sourceMime);
#endif
    }
    if (mDecoder == nullptr) {
        LOG(ERROR) << "Unable to create decoder for type " << sourceMime;
        return AMEDIA_ERROR_UNSUPPORTED;
+0 −4
Original line number Diff line number Diff line
@@ -97,12 +97,8 @@ private:
    BlockingQueue<std::function<void()>> mCodecMessageQueue;
    std::shared_ptr<AMediaFormat> mDestinationFormat;
    std::shared_ptr<AMediaFormat> mActualOutputFormat;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
    // These could be unused on older platforms
    pid_t mPid;
    uid_t mUid;
#pragma clang diagnostic pop
};

}  // namespace android
+0 −4
Original line number Diff line number Diff line
@@ -41,8 +41,6 @@ enum {
    AMEDIACODEC_CALLING_PID = -1,
};

#if __ANDROID_API__ >= 31

/**
 * Create codec by name on behalf of a client.
 *
@@ -91,8 +89,6 @@ AMediaCodec* AMediaCodec_createEncoderByTypeForClient(const char *mime_type,
                                                      pid_t pid,
                                                      uid_t uid) __INTRODUCED_IN(31);

#endif // __ANDROID_API__ >= 31

__END_DECLS

#endif //_NDK_MEDIA_CODEC_PLATFORM_H